sw/inc/ndarr.hxx | 1 + sw/source/core/docnode/node.cxx | 23 ++++++++++++----------- 2 files changed, 13 insertions(+), 11 deletions(-)
New commits: commit 5ee87e861e3147d6a3a9411296cd2498d77555db Author: Stephan Bergmann <[email protected]> Date: Thu Jul 31 12:12:17 2014 +0200 Avoid undef downcast in base class ctor Change-Id: I71eecfdc657b153f9289e8e9af52fba9ed22d3a8 diff --git a/sw/inc/ndarr.hxx b/sw/inc/ndarr.hxx index 7d65a95..26fee7e 100644 --- a/sw/inc/ndarr.hxx +++ b/sw/inc/ndarr.hxx @@ -90,6 +90,7 @@ class SW_DLLPUBLIC SwNodes friend class SwDoc; friend class SwNode; friend class SwNodeIndex; + friend class SwStartNode; friend class ::sw::DocumentContentOperationsManager; SwNodeIndex* pRoot; ///< List of all indices on nodes. diff --git a/sw/source/core/docnode/node.cxx b/sw/source/core/docnode/node.cxx index 399bfc4..e315529 100644 --- a/sw/source/core/docnode/node.cxx +++ b/sw/source/core/docnode/node.cxx @@ -289,9 +289,9 @@ SwNode::SwNode( const SwNodeIndex &rWhere, const sal_uInt8 nNdType ) #endif , pStartOfSection( 0 ) { - SwNodes& rNodes = const_cast<SwNodes&> (rWhere.GetNodes()); if( rWhere.GetIndex() ) { + SwNodes& rNodes = const_cast<SwNodes&> (rWhere.GetNodes()); SwNode* pNd = rNodes[ rWhere.GetIndex() -1 ]; rNodes.InsertNode( this, rWhere ); if( 0 == ( pStartOfSection = pNd->GetStartNode()) ) @@ -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 @@ -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() @@ -851,6 +841,12 @@ SwStartNode::SwStartNode( const SwNodeIndex &rWhere, const sal_uInt8 nNdType, SwStartNodeType 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 pEndOfSection = (SwEndNode*)this; } @@ -858,6 +854,11 @@ SwStartNode::SwStartNode( const SwNodeIndex &rWhere, const sal_uInt8 nNdType, SwStartNode::SwStartNode( SwNodes& rNodes, sal_uLong nPos ) : SwNode( rNodes, nPos, ND_STARTNODE ), eSttNdTyp( SwNormalStartNode ) { + if( !nPos ) + { + rNodes.InsertNode( this, nPos ); + pStartOfSection = this; + } // Just do this temporarily until the EndNode is inserted pEndOfSection = (SwEndNode*)this; } _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
