Hi Noel,

On Tuesday, 2007-06-26 10:24:50 +0100, Noel Power wrote:

> From your comments below it would seem you imply SC_VALID getting set
> for a single reference is not VALID ( pardon the pun ), and that causes
> subsequent problems correct? 

Actually SCA_VALID means that the string could be parsed as a reference;
if ScAddress::Parse() was called an address could be parsed and if
ScRange::Parse() was called a range could be parsed. So, returning
SCA_VALID from ScRange::Parse() if only an address could be parsed is
wrong. Additionally the SCA_VALID_* bits are set when the parsed part
indicates a valid reference part. So for ScAddress::Parse("blah.A1")
without a sheet named "blah" being existent you'd get the return value
(SCA_VALID | SCA_VALID_COL | SCA_VALID_ROW). Because SCA_VALID_TAB is
missing the reference generated would be #REF!.A1 indicating an error.


> The parsing code ( or at least the call to the parse code ) that Jody
> added for me always seems to expect SCA_VALID to be set ( and indeed
> it's also passed as the mask ) 
> 
> e.g. 
>               USHORT nMask = SCA_VALID;
>               rResFlags = rCellRanges.Parse( sAddress, pDoc, nMask, eConv, 0 
> );
>               if ( rResFlags & SCA_VALID )
>                       return true;
>               return false;

As Niklas mentioned, the situation with ScRangeList::Parse() is special
because it handles the differentiation of address and range itself and
converts an address to a range anyway. The return value is a bitwise AND
of all parser calls. A test for all strings being not only "parseable"
as a reference but also being valid references could include the mask

    USHORT nMask = (SCA_VALID |
        SCA_VALID_TAB | SCA_VALID_COL | SCA_VALID_ROW |
        SCA_VALID_TAB2 | SCA_VALID_COL2 | SCA_VALID_ROW2);
    rResFlags = rCellRanges.Parse( sAddress, pDoc, nMask, eConv, 0 );
    return (rResFlags & nMask) == nMask;

Passing the complete nMask to the call also has the effect that only
valid references are added to the range list, otherwise also all
"parseable" ranges but not necessarily valid references are added with
default coordinates (0 for the bad col/row/tab). However, this
requirement may be application specific and you may want to pass only
a SCA_VALID to the call but test the return value for the complete
condition.

  Eike

-- 
 OOo/SO Calc core developer. Number formatter stricken i18n transpositionizer.
 OpenOffice.org Engineering at Sun: http://blogs.sun.com/GullFOSS
 Please don't send personal mail to this [EMAIL PROTECTED] account, which I use 
for
 mailing lists only and don't read from outside Sun. Use [EMAIL PROTECTED] 
Thanks.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to