Kaydet (Commit) 5ee87e86 authored tarafından Stephan Bergmann's avatar Stephan Bergmann

Avoid undef downcast in base class ctor

Change-Id: I71eecfdc657b153f9289e8e9af52fba9ed22d3a8
üst ee8f76a3
...@@ -90,6 +90,7 @@ class SW_DLLPUBLIC SwNodes ...@@ -90,6 +90,7 @@ class SW_DLLPUBLIC SwNodes
friend class SwDoc; friend class SwDoc;
friend class SwNode; friend class SwNode;
friend class SwNodeIndex; friend class SwNodeIndex;
friend class SwStartNode;
friend class ::sw::DocumentContentOperationsManager; friend class ::sw::DocumentContentOperationsManager;
SwNodeIndex* pRoot; ///< List of all indices on nodes. SwNodeIndex* pRoot; ///< List of all indices on nodes.
......
...@@ -289,9 +289,9 @@ SwNode::SwNode( const SwNodeIndex &rWhere, const sal_uInt8 nNdType ) ...@@ -289,9 +289,9 @@ SwNode::SwNode( const SwNodeIndex &rWhere, const sal_uInt8 nNdType )
#endif #endif
, pStartOfSection( 0 ) , pStartOfSection( 0 )
{ {
SwNodes& rNodes = const_cast<SwNodes&> (rWhere.GetNodes());
if( rWhere.GetIndex() ) if( rWhere.GetIndex() )
{ {
SwNodes& rNodes = const_cast<SwNodes&> (rWhere.GetNodes());
SwNode* pNd = rNodes[ rWhere.GetIndex() -1 ]; SwNode* pNd = rNodes[ rWhere.GetIndex() -1 ];
rNodes.InsertNode( this, rWhere ); rNodes.InsertNode( this, rWhere );
if( 0 == ( pStartOfSection = pNd->GetStartNode()) ) if( 0 == ( pStartOfSection = pNd->GetStartNode()) )
...@@ -304,11 +304,6 @@ SwNode::SwNode( const SwNodeIndex &rWhere, const sal_uInt8 nNdType ) ...@@ -304,11 +304,6 @@ SwNode::SwNode( const SwNodeIndex &rWhere, const sal_uInt8 nNdType )
} }
} }
} }
else
{
rNodes.InsertNode( this, rWhere );
pStartOfSection = (SwStartNode*)this;
}
} }
/** Inserts a node into the rNodes array at the rWhere position /** Inserts a node into the rNodes array at the rWhere position
...@@ -341,11 +336,6 @@ SwNode::SwNode( SwNodes& rNodes, sal_uLong nPos, const sal_uInt8 nNdType ) ...@@ -341,11 +336,6 @@ SwNode::SwNode( SwNodes& rNodes, sal_uLong nPos, const sal_uInt8 nNdType )
} }
} }
} }
else
{
rNodes.InsertNode( this, nPos );
pStartOfSection = (SwStartNode*)this;
}
} }
SwNode::~SwNode() SwNode::~SwNode()
...@@ -851,6 +841,12 @@ SwStartNode::SwStartNode( const SwNodeIndex &rWhere, const sal_uInt8 nNdType, ...@@ -851,6 +841,12 @@ SwStartNode::SwStartNode( const SwNodeIndex &rWhere, const sal_uInt8 nNdType,
SwStartNodeType eSttNd ) SwStartNodeType eSttNd )
: SwNode( rWhere, nNdType ), eSttNdTyp( eSttNd ) : SwNode( rWhere, nNdType ), eSttNdTyp( eSttNd )
{ {
if( !rWhere.GetIndex() )
{
SwNodes& rNodes = const_cast<SwNodes&> (rWhere.GetNodes());
rNodes.InsertNode( this, rWhere );
pStartOfSection = this;
}
// Just do this temporarily until the EndNode is inserted // Just do this temporarily until the EndNode is inserted
pEndOfSection = (SwEndNode*)this; pEndOfSection = (SwEndNode*)this;
} }
...@@ -858,6 +854,11 @@ SwStartNode::SwStartNode( const SwNodeIndex &rWhere, const sal_uInt8 nNdType, ...@@ -858,6 +854,11 @@ SwStartNode::SwStartNode( const SwNodeIndex &rWhere, const sal_uInt8 nNdType,
SwStartNode::SwStartNode( SwNodes& rNodes, sal_uLong nPos ) SwStartNode::SwStartNode( SwNodes& rNodes, sal_uLong nPos )
: SwNode( rNodes, nPos, ND_STARTNODE ), eSttNdTyp( SwNormalStartNode ) : SwNode( rNodes, nPos, ND_STARTNODE ), eSttNdTyp( SwNormalStartNode )
{ {
if( !nPos )
{
rNodes.InsertNode( this, nPos );
pStartOfSection = this;
}
// Just do this temporarily until the EndNode is inserted // Just do this temporarily until the EndNode is inserted
pEndOfSection = (SwEndNode*)this; pEndOfSection = (SwEndNode*)this;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment