summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2012-03-21 10:25:45 +0100
committerMichael Stahl <mstahl@redhat.com>2012-03-21 12:08:33 +0100
commit082906e1f4cf58fdfab1a4064e2b7955fcdaeb8a (patch)
tree0719ac93a46758ef7ea744838d88a4da9bd10206
parent176ba743c12ecbfdda71522062f6d1a5749f3756 (diff)
rhbz#789022: SwNodes: fix inconsistent outline check:
SwNodes::UpdateOutlineNode will add/remove the node from SwNodes::pOutlineNds depending on IsOutline(), while various SwNodes methods that move and delete nodes check GetAttrOutlineLevel() != 0, which may be false even if IsOutline() is true.
-rw-r--r--sw/source/core/docnode/nodes.cxx34
-rw-r--r--sw/source/core/txtnode/ndtxt.cxx6
2 files changed, 23 insertions, 17 deletions
diff --git a/sw/source/core/docnode/nodes.cxx b/sw/source/core/docnode/nodes.cxx
index 518de823fd08..ab1243093d23 100644
--- a/sw/source/core/docnode/nodes.cxx
+++ b/sw/source/core/docnode/nodes.cxx
@@ -173,7 +173,7 @@ void SwNodes::ChgNode( SwNodeIndex& rDelPos, sal_uLong nSz,
pTxtNode->RemoveFromList();
- if ( pTxtNode->GetAttrOutlineLevel() != 0 )//<-end,zhaojianwei
+ if (pTxtNode->IsOutline())
{
const SwNodePtr pSrch = (SwNodePtr)&rNd;
pOutlineNds->Remove( pSrch );
@@ -188,8 +188,7 @@ void SwNodes::ChgNode( SwNodeIndex& rDelPos, sal_uLong nSz,
rTxtNd.AddToList();
- if( bInsOutlineIdx &&
- 0 != rTxtNd.GetAttrOutlineLevel() )//<-end,zhaojianwei
+ if (bInsOutlineIdx && rTxtNd.IsOutline())
{
const SwNodePtr pSrch = (SwNodePtr)&rNd;
pOutlineNds->Insert( pSrch );
@@ -232,9 +231,11 @@ void SwNodes::ChgNode( SwNodeIndex& rDelPos, sal_uLong nSz,
{
SwTxtNode* pTxtNd = (SwTxtNode*)pNd;
- // loesche die Gliederungs-Indizies aus dem alten Nodes-Array
- if( 0 != pTxtNd->GetAttrOutlineLevel() )//<-end,zhaojianwei
+ // remove outline index from old nodes array
+ if (pTxtNd->IsOutline())
+ {
pOutlineNds->Remove( pNd );
+ }
// muss die Rule kopiere werden?
if( pDestDoc )
@@ -269,8 +270,7 @@ void SwNodes::ChgNode( SwNodeIndex& rDelPos, sal_uLong nSz,
{
SwpHints * const pHts = pTxtNd->GetpSwpHints();
// OultineNodes set the new nodes in the array
- if( bInsOutlineIdx &&
- 0 != pTxtNd->GetAttrOutlineLevel() ) //#outline level,added by zhaojianwei
+ if (bInsOutlineIdx && pTxtNd->IsOutline())
{
rNds.pOutlineNds->Insert( pTxtNd );
}
@@ -537,12 +537,12 @@ sal_Bool SwNodes::_MoveNodes( const SwNodeRange& aRange, SwNodes & rNodes,
if( pTmpNd->IsTxtNode() )
((SwTxtNode*)pTmpNd)->RemoveFromList();
- // setze bei Start/EndNodes die richtigen Indizies
- // loesche die Gliederungs-Indizies aus
- // dem alten Nodes-Array
- if( pCNd->IsTxtNode() && 0 !=
- ((SwTxtNode*)pCNd)->GetAttrOutlineLevel() )//<-end,by zhaojianwei
+ // remove outline index from old nodes array
+ if (pCNd->IsTxtNode() &&
+ static_cast<SwTxtNode*>(pCNd)->IsOutline())
+ {
pOutlineNds->Remove( pCNd );
+ }
else
pCNd = 0;
}
@@ -572,7 +572,7 @@ sal_Bool SwNodes::_MoveNodes( const SwNodeRange& aRange, SwNodes & rNodes,
SwNode* pNd = &aMvIdx.GetNode();
const bool bOutlNd = pNd->IsTxtNode() &&
- 0 != ((SwTxtNode*)pNd)->GetAttrOutlineLevel();//<-end,zhaojianwei
+ static_cast<SwTxtNode*>(pNd)->IsOutline();
// loesche die Gliederungs-Indizies aus
// dem alten Nodes-Array
if( bOutlNd )
@@ -1221,14 +1221,15 @@ void SwNodes::Delete(const SwNodeIndex &rIndex, sal_uLong nNodes)
if( pNd->IsTxtNode() )
{
- if( 0 != ((SwTxtNode*)pNd)->GetAttrOutlineLevel() &&//<-end,zhaojianwei
+ SwTxtNode *const pTxtNode(static_cast<SwTxtNode*>(pNd));
+ if (pTxtNode->IsOutline() &&
pOutlineNds->Seek_Entry( pNd, &nIdxPos ))
{
// loesche die Gliederungs-Indizies.
pOutlineNds->Remove( nIdxPos );
bUpdateOutline = sal_True;
}
- ((SwTxtNode*)pNd)->InvalidateNumRule();
+ pTxtNode->InvalidateNumRule();
}
else if( pNd->IsEndNode() &&
pNd->pStartOfSection->IsTableNode() )
@@ -1522,8 +1523,7 @@ void SwNodes::DelNodes( const SwNodeIndex & rStart, sal_uLong nCnt )
{
SwNode* pNd = (*this)[ n ];
- if( pNd->IsTxtNode() &&
- 0 != ((SwTxtNode*)pNd)->GetAttrOutlineLevel() ) //<-end,zhaojianwei
+ if (pNd->IsTxtNode() && static_cast<SwTxtNode*>(pNd)->IsOutline())
{ // loesche die Gliederungs-Indizies.
sal_uInt16 nIdxPos;
if( pOutlineNds->Seek_Entry( pNd, &nIdxPos ))
diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx
index 2691f28adf97..fa6f3b0f0b4c 100644
--- a/sw/source/core/txtnode/ndtxt.cxx
+++ b/sw/source/core/txtnode/ndtxt.cxx
@@ -261,6 +261,12 @@ SwTxtNode::~SwTxtNode()
delete pTmpHints;
}
+ // must be removed from outline nodes by now
+#if OSL_DEBUG_LEVEL > 0
+ sal_uInt16 foo;
+ assert(!GetNodes().GetOutLineNds().Seek_Entry(this, &foo));
+#endif
+
RemoveFromList();
InitSwParaStatistics( false );