Date: prev next · Thread: first prev next last
2011 Archives by date, by thread · List index


On Fri, 2011-12-09 at 13:31 +0100, Michael Stahl wrote:
On 09/12/11 12:34, Caolán McNamara wrote:

Looking at your original patch anyway it looks right to me. Can't cast
something whose NodeType is ND_CONTENTNODE which is a superset of the
ND_TEXTNODE bits to a SwTxtNode seeing as a SwTxtNode inherits from
SwCntntNode so not all SwCntntNodes are SwTxtNodes.

The previous test was on ND_TEXTNODE, so the patch shouldn't change
the behaviour, it is however a nice stylistic cleanup

Just to be clear, given my later confusion, in the "good case" where it
is a SwTxtNode there is no change, while if it was somehow a underived
SwCntntNode there would be a desirable change in behaviour.

const sal_uInt8 ND_CONTENTNODE  = 0x38;
const sal_uInt8 ND_TEXTNODE     = 0x08;

inline sal_Bool SwNode::IsTxtNode() const
{
    return ND_TEXTNODE == nNodeType  ? sal_True : sal_False;
}

nNdTyp = ND_CONTENTNODE; //evil

- if( ND_TEXTNODE & nNdTyp )
^^^ would be 8, i.e. true
+ if( rNd.IsTxtNode() )
^^^ would be false

nNdTyp = ND_TEXTNODE; //good

- if( ND_TEXTNODE & nNdTyp )
^^^ would be 8, i.e. true
+ if( rNd.IsTxtNode() )
^^^ would be true


It's all a little strange, i.e. 
ND_TEXTNODE of 0x08 and a
ND_CONTENTNODE of 0x38
with
inline sal_Bool SwNode::IsCntntNode() const
{
    return ND_CONTENTNODE & nNodeType  ? sal_True : sal_False;
}

d'oh!  no, we are just unable to read & correctly:
if _any_ of the bits in 0x38 is set in the nNodeType, then the &
evaluates to true; so it doesn't seem broken after all.

*slap forehead*, sigh, indeed. SwTxtNodes are SwCntntNodes alright wrt 
ND_CONTENTNODE & ND_TEXTNODE.

Ah well, its probably worth munging in the derivation of the bits as |
of the super-class bits anyway so its a little more clear. Should ditch
this in favour of real rtti if there's no gotchass.

C.


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.