diff options
author | Michael Stahl <mstahl@redhat.com> | 2012-03-21 10:25:45 +0100 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2012-03-21 12:08:33 +0100 |
commit | 082906e1f4cf58fdfab1a4064e2b7955fcdaeb8a (patch) | |
tree | 0719ac93a46758ef7ea744838d88a4da9bd10206 | |
parent | 176ba743c12ecbfdda71522062f6d1a5749f3756 (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.cxx | 34 | ||||
-rw-r--r-- | sw/source/core/txtnode/ndtxt.cxx | 6 |
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, | |||
173 | 173 | ||
174 | pTxtNode->RemoveFromList(); | 174 | pTxtNode->RemoveFromList(); |
175 | 175 | ||
176 | if ( pTxtNode->GetAttrOutlineLevel() != 0 )//<-end,zhaojianwei | 176 | if (pTxtNode->IsOutline()) |
177 | { | 177 | { |
178 | const SwNodePtr pSrch = (SwNodePtr)&rNd; | 178 | const SwNodePtr pSrch = (SwNodePtr)&rNd; |
179 | pOutlineNds->Remove( pSrch ); | 179 | pOutlineNds->Remove( pSrch ); |
@@ -188,8 +188,7 @@ void SwNodes::ChgNode( SwNodeIndex& rDelPos, sal_uLong nSz, | |||
188 | 188 | ||
189 | rTxtNd.AddToList(); | 189 | rTxtNd.AddToList(); |
190 | 190 | ||
191 | if( bInsOutlineIdx && | 191 | if (bInsOutlineIdx && rTxtNd.IsOutline()) |
192 | 0 != rTxtNd.GetAttrOutlineLevel() )//<-end,zhaojianwei | ||
193 | { | 192 | { |
194 | const SwNodePtr pSrch = (SwNodePtr)&rNd; | 193 | const SwNodePtr pSrch = (SwNodePtr)&rNd; |
195 | pOutlineNds->Insert( pSrch ); | 194 | pOutlineNds->Insert( pSrch ); |
@@ -232,9 +231,11 @@ void SwNodes::ChgNode( SwNodeIndex& rDelPos, sal_uLong nSz, | |||
232 | { | 231 | { |
233 | SwTxtNode* pTxtNd = (SwTxtNode*)pNd; | 232 | SwTxtNode* pTxtNd = (SwTxtNode*)pNd; |
234 | 233 | ||
235 | // loesche die Gliederungs-Indizies aus dem alten Nodes-Array | 234 | // remove outline index from old nodes array |
236 | if( 0 != pTxtNd->GetAttrOutlineLevel() )//<-end,zhaojianwei | 235 | if (pTxtNd->IsOutline()) |
236 | { | ||
237 | pOutlineNds->Remove( pNd ); | 237 | pOutlineNds->Remove( pNd ); |
238 | } | ||
238 | 239 | ||
239 | // muss die Rule kopiere werden? | 240 | // muss die Rule kopiere werden? |
240 | if( pDestDoc ) | 241 | if( pDestDoc ) |
@@ -269,8 +270,7 @@ void SwNodes::ChgNode( SwNodeIndex& rDelPos, sal_uLong nSz, | |||
269 | { | 270 | { |
270 | SwpHints * const pHts = pTxtNd->GetpSwpHints(); | 271 | SwpHints * const pHts = pTxtNd->GetpSwpHints(); |
271 | // OultineNodes set the new nodes in the array | 272 | // OultineNodes set the new nodes in the array |
272 | if( bInsOutlineIdx && | 273 | if (bInsOutlineIdx && pTxtNd->IsOutline()) |
273 | 0 != pTxtNd->GetAttrOutlineLevel() ) //#outline level,added by zhaojianwei | ||
274 | { | 274 | { |
275 | rNds.pOutlineNds->Insert( pTxtNd ); | 275 | rNds.pOutlineNds->Insert( pTxtNd ); |
276 | } | 276 | } |
@@ -537,12 +537,12 @@ sal_Bool SwNodes::_MoveNodes( const SwNodeRange& aRange, SwNodes & rNodes, | |||
537 | if( pTmpNd->IsTxtNode() ) | 537 | if( pTmpNd->IsTxtNode() ) |
538 | ((SwTxtNode*)pTmpNd)->RemoveFromList(); | 538 | ((SwTxtNode*)pTmpNd)->RemoveFromList(); |
539 | 539 | ||
540 | // setze bei Start/EndNodes die richtigen Indizies | 540 | // remove outline index from old nodes array |
541 | // loesche die Gliederungs-Indizies aus | 541 | if (pCNd->IsTxtNode() && |
542 | // dem alten Nodes-Array | 542 | static_cast<SwTxtNode*>(pCNd)->IsOutline()) |
543 | if( pCNd->IsTxtNode() && 0 != | 543 | { |
544 | ((SwTxtNode*)pCNd)->GetAttrOutlineLevel() )//<-end,by zhaojianwei | ||
545 | pOutlineNds->Remove( pCNd ); | 544 | pOutlineNds->Remove( pCNd ); |
545 | } | ||
546 | else | 546 | else |
547 | pCNd = 0; | 547 | pCNd = 0; |
548 | } | 548 | } |
@@ -572,7 +572,7 @@ sal_Bool SwNodes::_MoveNodes( const SwNodeRange& aRange, SwNodes & rNodes, | |||
572 | SwNode* pNd = &aMvIdx.GetNode(); | 572 | SwNode* pNd = &aMvIdx.GetNode(); |
573 | 573 | ||
574 | const bool bOutlNd = pNd->IsTxtNode() && | 574 | const bool bOutlNd = pNd->IsTxtNode() && |
575 | 0 != ((SwTxtNode*)pNd)->GetAttrOutlineLevel();//<-end,zhaojianwei | 575 | static_cast<SwTxtNode*>(pNd)->IsOutline(); |
576 | // loesche die Gliederungs-Indizies aus | 576 | // loesche die Gliederungs-Indizies aus |
577 | // dem alten Nodes-Array | 577 | // dem alten Nodes-Array |
578 | if( bOutlNd ) | 578 | if( bOutlNd ) |
@@ -1221,14 +1221,15 @@ void SwNodes::Delete(const SwNodeIndex &rIndex, sal_uLong nNodes) | |||
1221 | 1221 | ||
1222 | if( pNd->IsTxtNode() ) | 1222 | if( pNd->IsTxtNode() ) |
1223 | { | 1223 | { |
1224 | if( 0 != ((SwTxtNode*)pNd)->GetAttrOutlineLevel() &&//<-end,zhaojianwei | 1224 | SwTxtNode *const pTxtNode(static_cast<SwTxtNode*>(pNd)); |
1225 | if (pTxtNode->IsOutline() && | ||
1225 | pOutlineNds->Seek_Entry( pNd, &nIdxPos )) | 1226 | pOutlineNds->Seek_Entry( pNd, &nIdxPos )) |
1226 | { | 1227 | { |
1227 | // loesche die Gliederungs-Indizies. | 1228 | // loesche die Gliederungs-Indizies. |
1228 | pOutlineNds->Remove( nIdxPos ); | 1229 | pOutlineNds->Remove( nIdxPos ); |
1229 | bUpdateOutline = sal_True; | 1230 | bUpdateOutline = sal_True; |
1230 | } | 1231 | } |
1231 | ((SwTxtNode*)pNd)->InvalidateNumRule(); | 1232 | pTxtNode->InvalidateNumRule(); |
1232 | } | 1233 | } |
1233 | else if( pNd->IsEndNode() && | 1234 | else if( pNd->IsEndNode() && |
1234 | pNd->pStartOfSection->IsTableNode() ) | 1235 | pNd->pStartOfSection->IsTableNode() ) |
@@ -1522,8 +1523,7 @@ void SwNodes::DelNodes( const SwNodeIndex & rStart, sal_uLong nCnt ) | |||
1522 | { | 1523 | { |
1523 | SwNode* pNd = (*this)[ n ]; | 1524 | SwNode* pNd = (*this)[ n ]; |
1524 | 1525 | ||
1525 | if( pNd->IsTxtNode() && | 1526 | if (pNd->IsTxtNode() && static_cast<SwTxtNode*>(pNd)->IsOutline()) |
1526 | 0 != ((SwTxtNode*)pNd)->GetAttrOutlineLevel() ) //<-end,zhaojianwei | ||
1527 | { // loesche die Gliederungs-Indizies. | 1527 | { // loesche die Gliederungs-Indizies. |
1528 | sal_uInt16 nIdxPos; | 1528 | sal_uInt16 nIdxPos; |
1529 | if( pOutlineNds->Seek_Entry( pNd, &nIdxPos )) | 1529 | 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() | |||
261 | delete pTmpHints; | 261 | delete pTmpHints; |
262 | } | 262 | } |
263 | 263 | ||
264 | // must be removed from outline nodes by now | ||
265 | #if OSL_DEBUG_LEVEL > 0 | ||
266 | sal_uInt16 foo; | ||
267 | assert(!GetNodes().GetOutLineNds().Seek_Entry(this, &foo)); | ||
268 | #endif | ||
269 | |||
264 | RemoveFromList(); | 270 | RemoveFromList(); |
265 | 271 | ||
266 | InitSwParaStatistics( false ); | 272 | InitSwParaStatistics( false ); |