LibreOffice Module sw (master)  1
nodes.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #include <stdlib.h>
21 
22 #include <libxml/xmlwriter.h>
23 #include <osl/diagnose.h>
24 
25 #include <node.hxx>
26 #include <doc.hxx>
27 #include <IDocumentUndoRedo.hxx>
30 #include <pam.hxx>
31 #include <txtfld.hxx>
32 #include <fmtfld.hxx>
33 #include <numrule.hxx>
34 #include <ndtxt.hxx>
35 #include <ndnotxt.hxx>
36 #include <swtable.hxx>
37 #include <section.hxx>
38 #include <ddefld.hxx>
39 #include <swddetbl.hxx>
40 #include <txtatr.hxx>
41 #include <tox.hxx>
42 #include <fmtrfmrk.hxx>
43 #include <fmtftn.hxx>
44 
45 #include <docsh.hxx>
46 
47 typedef std::vector<SwStartNode*> SwStartNodePointers;
48 
49 // function to determine the highest level in the given range
50 static sal_uInt16 HighestLevel( SwNodes & rNodes, const SwNodeRange & rRange );
51 
58 SwNodes::SwNodes( SwDoc* pDocument )
59  : m_vIndices(nullptr), m_pMyDoc( pDocument )
60 {
62 
63  assert(m_pMyDoc);
64 
65  sal_uLong nPos = 0;
66  SwStartNode* pSttNd = new SwStartNode( *this, nPos++ );
67  m_pEndOfPostIts = new SwEndNode( *this, nPos++, *pSttNd );
68 
69  SwStartNode* pTmp = new SwStartNode( *this, nPos++ );
70  m_pEndOfInserts = new SwEndNode( *this, nPos++, *pTmp );
71 
72  pTmp = new SwStartNode( *this, nPos++ );
73  pTmp->m_pStartOfSection = pSttNd;
74  m_pEndOfAutotext = new SwEndNode( *this, nPos++, *pTmp );
75 
76  pTmp = new SwStartNode( *this, nPos++ );
77  pTmp->m_pStartOfSection = pSttNd;
78  m_pEndOfRedlines = new SwEndNode( *this, nPos++, *pTmp );
79 
80  pTmp = new SwStartNode( *this, nPos++ );
81  pTmp->m_pStartOfSection = pSttNd;
82  m_pEndOfContent.reset(new SwEndNode( *this, nPos++, *pTmp ));
83 
85 }
86 
94 {
95  m_pOutlineNodes.reset();
96 
97  {
98  SwNodeIndex aNdIdx( *this );
99  while( true )
100  {
101  SwNode *pNode = &aNdIdx.GetNode();
102  if( pNode == m_pEndOfContent.get() )
103  break;
104 
105  ++aNdIdx;
106  delete pNode;
107  }
108  }
109 
110  // here, all SwNodeIndices must be unregistered
111  m_pEndOfContent.reset();
112 }
113 
114 void SwNodes::ChgNode( SwNodeIndex const & rDelPos, sal_uLong nSz,
115  SwNodeIndex& rInsPos, bool bNewFrames )
116 {
117  // no need for frames in the UndoArea
118  SwNodes& rNds = rInsPos.GetNodes();
119  const SwNode* pPrevInsNd = rNds[ rInsPos.GetIndex() -1 ];
120 
121  // declare all fields as invalid, updating will happen
122  // in the idle-handler of the doc
123  if( GetDoc()->getIDocumentFieldsAccess().SetFieldsDirty( true, &rDelPos.GetNode(), nSz ) &&
124  rNds.GetDoc() != GetDoc() )
125  rNds.GetDoc()->getIDocumentFieldsAccess().SetFieldsDirty( true, nullptr, 0 );
126 
127  // NEVER include nodes from the RedLineArea
128  sal_uLong nNd = rInsPos.GetIndex();
129  bool bInsOutlineIdx = !(
130  rNds.GetEndOfRedlines().StartOfSectionNode()->GetIndex() < nNd &&
131  nNd < rNds.GetEndOfRedlines().GetIndex() );
132 
133  if( &rNds == this ) // if in the same node array -> move
134  {
135  // Move order: from front to back, so that new entries are added at
136  // first position, thus, deletion position stays the same
137  const sal_uLong nDiff = rDelPos.GetIndex() < rInsPos.GetIndex() ? 0 : 1;
138 
139  for( sal_uLong n = rDelPos.GetIndex(); nSz; n += nDiff, --nSz )
140  {
141  SwNodeIndex aDelIdx( *this, n );
142  SwNode& rNd = aDelIdx.GetNode();
143 
144  // #i57920# - correction of refactoring done by cws swnumtree:
145  // - <SwTextNode::SetLevel( NO_NUMBERING ) is deprecated and
146  // set <IsCounted> state of the text node to <false>, which
147  // isn't correct here.
148  if ( rNd.IsTextNode() )
149  {
150  SwTextNode* pTextNode = rNd.GetTextNode();
151 
152  pTextNode->RemoveFromList();
153 
154  if (pTextNode->IsOutline())
155  {
156  const SwNodePtr pSrch = &rNd;
157  m_pOutlineNodes->erase( pSrch );
158  }
159  }
160 
161  BigPtrArray::Move( aDelIdx.GetIndex(), rInsPos.GetIndex() );
162 
163  if( rNd.IsTextNode() )
164  {
165  SwTextNode& rTextNd = static_cast<SwTextNode&>(rNd);
166 
167  rTextNd.AddToList();
168 
169  if (bInsOutlineIdx && rTextNd.IsOutline())
170  {
171  const SwNodePtr pSrch = &rNd;
172  m_pOutlineNodes->insert( pSrch );
173  }
174  rTextNd.InvalidateNumRule();
175 
176 //FEATURE::CONDCOLL
177  if( RES_CONDTXTFMTCOLL == rTextNd.GetTextColl()->Which() )
178  rTextNd.ChkCondColl();
179 //FEATURE::CONDCOLL
180  }
181  else if( rNd.IsContentNode() )
182  static_cast<SwContentNode&>(rNd).InvalidateNumRule();
183  }
184  }
185  else
186  {
187  bool bSavePersData(GetDoc()->GetIDocumentUndoRedo().IsUndoNodes(rNds));
188  bool bRestPersData(GetDoc()->GetIDocumentUndoRedo().IsUndoNodes(*this));
189  SwDoc* pDestDoc = rNds.GetDoc() != GetDoc() ? rNds.GetDoc() : nullptr;
190  OSL_ENSURE(!pDestDoc, "SwNodes::ChgNode(): "
191  "the code to handle text fields here looks broken\n"
192  "if the target is in a different document.");
193  if( !bRestPersData && !bSavePersData && pDestDoc )
194  bSavePersData = bRestPersData = true;
195 
196  OUString sNumRule;
197  for( sal_uLong n = 0; n < nSz; n++ )
198  {
199  SwNode* pNd = &rDelPos.GetNode();
200 
201  // NoTextNode keep their persistent data
202  if( pNd->IsNoTextNode() )
203  {
204  if( bSavePersData )
205  static_cast<SwNoTextNode*>(pNd)->SavePersistentData();
206  }
207  else if( pNd->IsTextNode() )
208  {
209  SwTextNode* pTextNd = static_cast<SwTextNode*>(pNd);
210 
211  // remove outline index from old nodes array
212  if (pTextNd->IsOutline())
213  {
214  m_pOutlineNodes->erase( pNd );
215  }
216 
217  // copy rules if needed
218  if( pDestDoc )
219  {
220  const SwNumRule* pNumRule = pTextNd->GetNumRule();
221  if( pNumRule && sNumRule != pNumRule->GetName() )
222  {
223  sNumRule = pNumRule->GetName();
224  SwNumRule* pDestRule = pDestDoc->FindNumRulePtr( sNumRule );
225  if( pDestRule )
226  pDestRule->SetInvalidRule( true );
227  else
228  pDestDoc->MakeNumRule( sNumRule, pNumRule );
229  }
230  }
231  else
232  // if movement into the UndoNodes-array, update numbering
233  pTextNd->InvalidateNumRule();
234 
235  pTextNd->RemoveFromList();
236  }
237 
238  RemoveNode( rDelPos.GetIndex(), 1, false ); // move indices
239  SwContentNode * pCNd = pNd->GetContentNode();
240  rNds.InsertNode( pNd, rInsPos );
241 
242  if( pCNd )
243  {
244  SwTextNode* pTextNd = pCNd->GetTextNode();
245  if( pTextNd )
246  {
247  SwpHints * const pHts = pTextNd->GetpSwpHints();
248  // OutlineNodes set the new nodes in the array
249  if (bInsOutlineIdx && pTextNd->IsOutline())
250  {
251  rNds.m_pOutlineNodes->insert( pTextNd );
252  }
253 
254  pTextNd->AddToList();
255 
256  // special treatment for fields
257  if( pHts && pHts->Count() )
258  {
259  bool const bToUndo = !pDestDoc &&
261  for( size_t i = pHts->Count(); i; )
262  {
263  SwTextAttr * const pAttr = pHts->Get( --i );
264  switch ( pAttr->Which() )
265  {
266  case RES_TXTATR_FIELD:
269  {
270  SwTextField* pTextField = static_txtattr_cast<SwTextField*>(pAttr);
271  rNds.GetDoc()->getIDocumentFieldsAccess().InsDelFieldInFieldLst( !bToUndo, *pTextField );
272 
273  const SwFieldType* pTyp = pTextField->GetFormatField().GetField()->GetTyp();
274  if ( SwFieldIds::Postit == pTyp->Which() )
275  {
276  rNds.GetDoc()->GetDocShell()->Broadcast(
278  &pTextField->GetFormatField(),
279  ( pTextField->GetFormatField().IsFieldInDoc()
282  }
283  else if( SwFieldIds::Dde == pTyp->Which() )
284  {
285  if( bToUndo )
286  const_cast<SwDDEFieldType*>(static_cast<const SwDDEFieldType*>(pTyp))->DecRefCnt();
287  else
288  const_cast<SwDDEFieldType*>(static_cast<const SwDDEFieldType*>(pTyp))->IncRefCnt();
289  }
290  static_cast<SwFormatField&>(pAttr->GetAttr())
291  .InvalidateField();
292  }
293  break;
294 
295  case RES_TXTATR_FTN:
296  static_cast<SwFormatFootnote&>(pAttr->GetAttr())
297  .InvalidateFootnote();
298  break;
299 
300  case RES_TXTATR_TOXMARK:
301  static_cast<SwTOXMark&>(pAttr->GetAttr())
302  .InvalidateTOXMark();
303  break;
304 
305  case RES_TXTATR_REFMARK:
306  static_cast<SwFormatRefMark&>(pAttr->GetAttr())
307  .InvalidateRefMark();
308  break;
309 
310  case RES_TXTATR_META:
312  {
313  SwTextMeta *const pTextMeta(
314  static_txtattr_cast<SwTextMeta*>(pAttr));
315  // force removal of UNO object
316  pTextMeta->ChgTextNode(nullptr);
317  pTextMeta->ChgTextNode(pTextNd);
318  }
319  break;
320 
321  default:
322  break;
323  }
324  }
325  }
326  //FEATURE::CONDCOLL
327  if( RES_CONDTXTFMTCOLL == pTextNd->GetTextColl()->Which() )
328  pTextNd->ChkCondColl();
329  //FEATURE::CONDCOLL
330  }
331  else
332  {
333  // Moved into different Docs? Persist data again!
334  if( pCNd->IsNoTextNode() && bRestPersData )
335  static_cast<SwNoTextNode*>(pCNd)->RestorePersistentData();
336  }
337  }
338  }
339  }
340 
341  // declare all fields as invalid, updating will happen
342  // in the idle-handler of the doc
343  GetDoc()->getIDocumentFieldsAccess().SetFieldsDirty( true, nullptr, 0 );
344  if( rNds.GetDoc() != GetDoc() )
345  rNds.GetDoc()->getIDocumentFieldsAccess().SetFieldsDirty( true, nullptr, 0 );
346 
347  if( bNewFrames )
348  bNewFrames = &GetDoc()->GetNodes() == &rNds &&
350 
351  if( bNewFrames )
352  {
353  // get the frames:
354  SwNodeIndex aIdx( *pPrevInsNd, 1 );
355  SwNodeIndex aFrameNdIdx( aIdx );
356  SwNode* pFrameNd = rNds.FindPrvNxtFrameNode( aFrameNdIdx,
357  rNds[ rInsPos.GetIndex() - 1 ] );
358 
359  if( pFrameNd )
360  while( aIdx != rInsPos )
361  {
362  SwContentNode* pCNd = aIdx.GetNode().GetContentNode();
363  if( pCNd )
364  {
365  if( pFrameNd->IsTableNode() )
366  static_cast<SwTableNode*>(pFrameNd)->MakeFramesForAdjacentContentNode(aIdx);
367  else if( pFrameNd->IsSectionNode() )
368  static_cast<SwSectionNode*>(pFrameNd)->MakeFramesForAdjacentContentNode(aIdx);
369  else
370  static_cast<SwContentNode*>(pFrameNd)->MakeFramesForAdjacentContentNode(*pCNd);
371  pFrameNd = pCNd;
372  }
373  ++aIdx;
374  }
375  }
376 }
377 
378 // TODO: provide documentation
394 bool SwNodes::MoveNodes( const SwNodeRange& aRange, SwNodes & rNodes,
395  const SwNodeIndex& aIndex, bool bNewFrames )
396 {
397  SwNode * pCurrentNode;
398  if( aIndex == 0 ||
399  ( (pCurrentNode = &aIndex.GetNode())->GetStartNode() &&
400  !pCurrentNode->StartOfSectionIndex() ))
401  return false;
402 
403  SwNodeRange aRg( aRange );
404 
405  // skip "simple" start or end nodes
406  while( SwNodeType::Start == (pCurrentNode = &aRg.aStart.GetNode())->GetNodeType()
407  || ( pCurrentNode->IsEndNode() &&
408  !pCurrentNode->m_pStartOfSection->IsSectionNode() ) )
409  ++aRg.aStart;
410  --aRg.aStart;
411 
412  // if aEnd-1 points to no ContentNode, search previous one
413  --aRg.aEnd;
414  while( ( (( pCurrentNode = &aRg.aEnd.GetNode())->GetStartNode() &&
415  !pCurrentNode->IsSectionNode() ) ||
416  ( pCurrentNode->IsEndNode() &&
417  SwNodeType::Start == pCurrentNode->m_pStartOfSection->GetNodeType()) ) &&
418  aRg.aEnd > aRg.aStart )
419  --aRg.aEnd;
420 
421  // if in same array, check insertion position
422  if( aRg.aStart >= aRg.aEnd )
423  return false;
424 
425  if( this == &rNodes )
426  {
427  if( ( aIndex.GetIndex()-1 >= aRg.aStart.GetIndex() &&
428  aIndex.GetIndex()-1 < aRg.aEnd.GetIndex()) ||
429  ( aIndex.GetIndex()-1 == aRg.aEnd.GetIndex() ) )
430  return false;
431  }
432 
433  sal_uLong nInsPos = 0; // counter for tmp array
434 
435  // array as a stack, storing all StartOfSelections
436  SwStartNodePointers aSttNdStack;
437  SwStartNodePointers::size_type nLevel = 0; // level counter
438 
439  // set start index
440  SwNodeIndex aIdx( aIndex );
441 
442  SwStartNode* pStartNode = aIdx.GetNode().m_pStartOfSection;
443  aSttNdStack.insert( aSttNdStack.begin(), pStartNode );
444 
445  SwNodeRange aOrigInsPos( aIdx, -1, aIdx ); // original insertion position
446 
447  // call DelFrames/MakeFrames for the upmost SectionNode
448  int nSectNdCnt = 0;
449  bool bSaveNewFrames = bNewFrames;
450 
451  // continue until everything has been moved
452  while( aRg.aStart < aRg.aEnd )
453  {
454  pCurrentNode = &aRg.aEnd.GetNode();
455  switch( pCurrentNode->GetNodeType() )
456  {
457  case SwNodeType::End:
458  {
459  if( nInsPos ) // move everything until here
460  {
461  // delete and copy. CAUTION: all indices after
462  // "aRg.aEnd+1" will be moved as well!
463  SwNodeIndex aSwIndex( aRg.aEnd, 1 );
464  ChgNode( aSwIndex, nInsPos, aIdx, bNewFrames );
465  aIdx -= nInsPos;
466  nInsPos = 0;
467  }
468 
469  SwStartNode* pSttNd = pCurrentNode->m_pStartOfSection;
470  if( pSttNd->IsTableNode() )
471  {
472  SwTableNode* pTableNd = static_cast<SwTableNode*>(pSttNd);
473 
474  // move the whole table/range
475  nInsPos = (aRg.aEnd.GetIndex() -
476  pSttNd->GetIndex() )+1;
477  aRg.aEnd -= nInsPos;
478 
479  // NEVER include nodes from the RedLineArea
480  sal_uLong nNd = aIdx.GetIndex();
481  bool bInsOutlineIdx = !( rNodes.GetEndOfRedlines().
482  StartOfSectionNode()->GetIndex() < nNd &&
483  nNd < rNodes.GetEndOfRedlines().GetIndex() );
484 
485  if( bNewFrames )
486  // delete all frames
487  pTableNd->DelFrames(nullptr);
488  if( &rNodes == this ) // move into self?
489  {
490  // move all Start/End/ContentNodes
491  // ContentNodes: delete also the frames!
492  pTableNd->m_pStartOfSection = aIdx.GetNode().m_pStartOfSection;
493  for( sal_uLong n = 0; n < nInsPos; ++n )
494  {
495  SwNodeIndex aMvIdx( aRg.aEnd, 1 );
496  SwContentNode* pCNd = nullptr;
497  SwNode* pTmpNd = &aMvIdx.GetNode();
498  if( pTmpNd->IsContentNode() )
499  {
500  pCNd = static_cast<SwContentNode*>(pTmpNd);
501  if( pTmpNd->IsTextNode() )
502  static_cast<SwTextNode*>(pTmpNd)->RemoveFromList();
503 
504  // remove outline index from old nodes array
505  if (pCNd->IsTextNode() && pCNd->GetTextNode()->IsOutline())
506  {
507  m_pOutlineNodes->erase( pCNd );
508  }
509  else
510  pCNd = nullptr;
511  }
512 
513  BigPtrArray::Move( aMvIdx.GetIndex(), aIdx.GetIndex() );
514 
515  if( bInsOutlineIdx && pCNd )
516  m_pOutlineNodes->insert( pCNd );
517  if( pTmpNd->IsTextNode() )
518  static_cast<SwTextNode*>(pTmpNd)->AddToList();
519  }
520  }
521  else
522  {
523  // get StartNode
524  // Even aIdx points to a startnode, we need the startnode
525  // of the environment of aIdx (#i80941)
526  SwStartNode* pSttNode = aIdx.GetNode().m_pStartOfSection;
527 
528  // get all boxes with content because their indices
529  // pointing to the StartNodes need to be reset
530  // (copying the array and deleting all found ones eases
531  // searching)
532  SwNodeIndex aMvIdx( aRg.aEnd, 1 );
533  for( sal_uLong n = 0; n < nInsPos; ++n )
534  {
535  SwNode* pNd = &aMvIdx.GetNode();
536 
537  const bool bOutlNd = pNd->IsTextNode() && pNd->GetTextNode()->IsOutline();
538  // delete outline indices from old node array
539  if( bOutlNd )
540  m_pOutlineNodes->erase( pNd );
541 
542  RemoveNode( aMvIdx.GetIndex(), 1, false );
543  pNd->m_pStartOfSection = pSttNode;
544  rNodes.InsertNode( pNd, aIdx );
545 
546  // set correct indices in Start/EndNodes
547  if( bInsOutlineIdx && bOutlNd )
548  // and put them into the new node array
549  rNodes.m_pOutlineNodes->insert( pNd );
550  else if( pNd->IsStartNode() )
551  pSttNode = static_cast<SwStartNode*>(pNd);
552  else if( pNd->IsEndNode() )
553  {
554  pSttNode->m_pEndOfSection = static_cast<SwEndNode*>(pNd);
555  if( pSttNode->IsSectionNode() )
556  static_cast<SwSectionNode*>(pSttNode)->NodesArrChgd();
557  pSttNode = pSttNode->m_pStartOfSection;
558  }
559  }
560 
561  if( dynamic_cast<const SwDDETable*>(&pTableNd->GetTable()) != nullptr )
562  {
563  SwDDEFieldType* pTyp = static_cast<SwDDETable&>(pTableNd->
564  GetTable()).GetDDEFieldType();
565  if( pTyp )
566  {
567  if( rNodes.IsDocNodes() )
568  pTyp->IncRefCnt();
569  else
570  pTyp->DecRefCnt();
571  }
572  }
573 
574  if (GetDoc()->GetIDocumentUndoRedo().IsUndoNodes(
575  rNodes))
576  {
577  SwFrameFormat* pTableFormat = pTableNd->GetTable().GetFrameFormat();
578  pTableFormat->GetNotifier().Broadcast(SfxHint(SfxHintId::Dying));
579  }
580  }
581  if( bNewFrames )
582  {
583  SwNodeIndex aTmp( aIdx );
584  pTableNd->MakeOwnFrames(&aTmp);
585  }
586  aIdx -= nInsPos;
587  nInsPos = 0;
588  }
589  else if( pSttNd->GetIndex() < aRg.aStart.GetIndex() )
590  {
591  // SectionNode: not the whole section will be moved, thus,
592  // move only the ContentNodes
593  // StartNode: create a new section at the given position
594  do { // middle check loop
595  if( !pSttNd->IsSectionNode() )
596  {
597  // create StartNode and EndNode at InsertPos
598  SwStartNode* pTmp = new SwStartNode( aIdx,
600 /*?? NodeType ??*/ SwNormalStartNode );
601 
602  nLevel++; // put the index to StartNode on the stack
603  aSttNdStack.insert( aSttNdStack.begin() + nLevel, pTmp );
604 
605  // create EndNode
606  new SwEndNode( aIdx, *pTmp );
607  }
608  else if (GetDoc()->GetIDocumentUndoRedo().IsUndoNodes(
609  rNodes))
610  {
611  // use placeholder in UndoNodes array
612  new SwPlaceholderNode(aIdx);
613  }
614  else
615  {
616  // JP 18.5.2001 (Bug 70454) creating new section?
617  --aRg.aEnd;
618  break;
619 
620  }
621 
622  --aRg.aEnd;
623  --aIdx;
624  } while( false );
625  }
626  else
627  {
628  // move StartNode and EndNode in total
629 
630  // if Start is exactly the Start of the area,
631  // then the Node needs to be re-visited
632  if( &aRg.aStart.GetNode() == pSttNd )
633  --aRg.aStart;
634 
635  SwSectionNode* pSctNd = pSttNd->GetSectionNode();
636  if( bNewFrames && pSctNd )
637  pSctNd->DelFrames();
638 
639  RemoveNode( aRg.aEnd.GetIndex(), 1, false ); // delete EndNode
640  sal_uLong nSttPos = pSttNd->GetIndex();
641 
642  // this StartNode will be removed later
643  SwStartNode* pTmpSttNd = new SwStartNode( *this, nSttPos+1 );
644  pTmpSttNd->m_pStartOfSection = pSttNd->m_pStartOfSection;
645 
646  RemoveNode( nSttPos, 1, false ); // delete SttNode
647 
649  rNodes.InsertNode( pSttNd, aIdx );
650  rNodes.InsertNode( pCurrentNode, aIdx );
651  --aIdx;
652  pSttNd->m_pEndOfSection = static_cast<SwEndNode*>(pCurrentNode);
653 
654  --aRg.aEnd;
655 
656  nLevel++; // put the index pointing to the StartNode onto the stack
657  aSttNdStack.insert( aSttNdStack.begin() + nLevel, pSttNd );
658 
659  // reset remaining indices if SectionNode
660  if( pSctNd )
661  {
662  pSctNd->NodesArrChgd();
663  ++nSectNdCnt;
664  bNewFrames = false;
665  }
666  }
667  }
668  break;
669 
670  case SwNodeType::Section:
671  if( !nLevel &&
672  GetDoc()->GetIDocumentUndoRedo().IsUndoNodes(rNodes))
673  {
674  // here, a SectionDummyNode needs to be inserted at the current position
675  if( nInsPos ) // move everything until here
676  {
677  // delete and copy. CAUTION: all indices after
678  // "aRg.aEnd+1" will be moved as well!
679  SwNodeIndex aSwIndex( aRg.aEnd, 1 );
680  ChgNode( aSwIndex, nInsPos, aIdx, bNewFrames );
681  aIdx -= nInsPos;
682  nInsPos = 0;
683  }
684  new SwPlaceholderNode(aIdx);
685  --aRg.aEnd;
686  --aIdx;
687  break;
688  }
689  [[fallthrough]];
690  case SwNodeType::Table:
691  case SwNodeType::Start:
692  {
693  // empty section -> nothing to do
694  // and only if it's a top level section
695  if( !nInsPos && !nLevel )
696  {
697  --aRg.aEnd;
698  break;
699  }
700 
701  if( !nLevel ) // level is decreasing
702  {
703  // create decrease
704  SwNodeIndex aTmpSIdx( aOrigInsPos.aStart, 1 );
705  SwStartNode* pTmpStt = new SwStartNode( aTmpSIdx,
707  static_cast<SwStartNode*>(pCurrentNode)->GetStartNodeType() );
708 
709  --aTmpSIdx;
710 
711  SwNodeIndex aTmpEIdx( aOrigInsPos.aEnd );
712  new SwEndNode( aTmpEIdx, *pTmpStt );
713  --aTmpEIdx;
714  ++aTmpSIdx;
715 
716  // set correct StartOfSection
717  ++aRg.aEnd;
718  {
719  SwNodeIndex aCntIdx( aRg.aEnd );
720  for( sal_uLong n = 0; n < nInsPos; n++, ++aCntIdx)
721  aCntIdx.GetNode().m_pStartOfSection = pTmpStt;
722  }
723 
724  // also set correct StartNode for all decreased nodes
725  while( aTmpSIdx < aTmpEIdx )
726  if( nullptr != (( pCurrentNode = &aTmpEIdx.GetNode())->GetEndNode()) )
727  aTmpEIdx = pCurrentNode->StartOfSectionIndex();
728  else
729  {
730  pCurrentNode->m_pStartOfSection = pTmpStt;
731  --aTmpEIdx;
732  }
733 
734  --aIdx; // after the inserted StartNode
735  --aRg.aEnd; // before StartNode
736  // copy array. CAUTION: all indices after
737  // "aRg.aEnd+1" will be moved as well!
738  SwNodeIndex aSwIndex( aRg.aEnd, 1 );
739  ChgNode( aSwIndex, nInsPos, aIdx, bNewFrames );
740  aIdx -= nInsPos+1;
741  nInsPos = 0;
742  }
743  else // all nodes between StartNode and EndNode were moved
744  {
745  OSL_ENSURE( pCurrentNode == aSttNdStack[nLevel] ||
746  ( pCurrentNode->IsStartNode() &&
747  aSttNdStack[nLevel]->IsSectionNode()),
748  "wrong StartNode" );
749 
750  SwNodeIndex aSwIndex( aRg.aEnd, 1 );
751  ChgNode( aSwIndex, nInsPos, aIdx, bNewFrames );
752  aIdx -= nInsPos+1; // before inserted StartNode
753  nInsPos = 0;
754 
755  // remove pointer from node array
756  RemoveNode( aRg.aEnd.GetIndex(), 1, true );
757  --aRg.aEnd;
758 
759  SwSectionNode* pSectNd = aSttNdStack[ nLevel ]->GetSectionNode();
760  if( pSectNd && !--nSectNdCnt )
761  {
762  SwNodeIndex aTmp( *pSectNd );
763  pSectNd->MakeOwnFrames(&aTmp);
764  bNewFrames = bSaveNewFrames;
765  }
766  aSttNdStack.erase( aSttNdStack.begin() + nLevel ); // remove from stack
767  nLevel--;
768  }
769 
770  // delete all resulting empty start/end node pairs
771  SwNode* pTmpNode = (*this)[ aRg.aEnd.GetIndex()+1 ]->GetEndNode();
772  if( pTmpNode && SwNodeType::Start == (pCurrentNode = &aRg.aEnd.GetNode())
773  ->GetNodeType() && pCurrentNode->StartOfSectionIndex() &&
774  pTmpNode->StartOfSectionNode() == pCurrentNode )
775  {
776  DelNodes( aRg.aEnd, 2 );
777  --aRg.aEnd;
778  }
779  }
780  break;
781 
782  case SwNodeType::Text:
783  //Add special function to text node.
784  {
785  if( bNewFrames && pCurrentNode->GetContentNode() )
786  static_cast<SwContentNode*>(pCurrentNode)->DelFrames(nullptr);
787  pCurrentNode->m_pStartOfSection = aSttNdStack[ nLevel ];
788  nInsPos++;
789  --aRg.aEnd;
790  }
791  break;
792  case SwNodeType::Grf:
793  case SwNodeType::Ole:
794  {
795  if( bNewFrames && pCurrentNode->GetContentNode() )
796  static_cast<SwContentNode*>(pCurrentNode)->DelFrames(nullptr);
797 
798  pCurrentNode->m_pStartOfSection = aSttNdStack[ nLevel ];
799  nInsPos++;
800  --aRg.aEnd;
801  }
802  break;
803 
805  if (GetDoc()->GetIDocumentUndoRedo().IsUndoNodes(*this))
806  {
807  if( &rNodes == this ) // inside UndoNodesArray
808  {
809  // move everything
810  pCurrentNode->m_pStartOfSection = aSttNdStack[ nLevel ];
811  nInsPos++;
812  }
813  else // move into "normal" node array
814  {
815  // than a SectionNode (start/end) is needed at the current
816  // InsPos; if so skip it, otherwise ignore current node
817  if( nInsPos ) // move everything until here
818  {
819  // delete and copy. CAUTION: all indices after
820  // "aRg.aEnd+1" will be moved as well!
821  SwNodeIndex aSwIndex( aRg.aEnd, 1 );
822  ChgNode( aSwIndex, nInsPos, aIdx, bNewFrames );
823  aIdx -= nInsPos;
824  nInsPos = 0;
825  }
826  SwNode* pTmpNd = &aIdx.GetNode();
827  if( pTmpNd->IsSectionNode() ||
828  pTmpNd->StartOfSectionNode()->IsSectionNode() )
829  --aIdx; // skip
830  }
831  }
832  else {
833  assert(!"How can this node be in the node array?");
834  }
835  --aRg.aEnd;
836  break;
837 
838  default:
839  assert(!"Unknown node type");
840  break;
841  }
842  }
843 
844  if( nInsPos ) // copy remaining rest
845  {
846  // rest should be ok
847  SwNodeIndex aSwIndex( aRg.aEnd, 1 );
848  ChgNode( aSwIndex, nInsPos, aIdx, bNewFrames );
849  }
850  ++aRg.aEnd; // again, exclusive end
851 
852  // delete all resulting empty start/end node pairs
853  if( ( pCurrentNode = &aRg.aStart.GetNode())->GetStartNode() &&
854  pCurrentNode->StartOfSectionIndex() &&
855  aRg.aEnd.GetNode().GetEndNode() )
856  DelNodes( aRg.aStart, 2 );
857 
858  // initialize numbering update
859  ++aOrigInsPos.aStart;
860  // Moved in same node array? Then call update top down!
861  if( this == &rNodes &&
862  aRg.aEnd.GetIndex() >= aOrigInsPos.aStart.GetIndex() )
863  {
864  UpdateOutlineIdx( aOrigInsPos.aStart.GetNode() );
865  UpdateOutlineIdx( aRg.aEnd.GetNode() );
866  }
867  else
868  {
869  UpdateOutlineIdx( aRg.aEnd.GetNode() );
870  rNodes.UpdateOutlineIdx( aOrigInsPos.aStart.GetNode() );
871  }
872 
873  return true;
874 }
875 
893 {
894  if( pRange->aStart >= pRange->aEnd ||
895  pRange->aEnd >= Count() ||
896  !::CheckNodesRange(pRange->aStart, pRange->aEnd, false))
897  {
898  return;
899  }
900 
901  // If the beginning of a range is before or at a start node position, so
902  // delete it, otherwise empty S/E or E/S nodes would be created.
903  // For other nodes, create a new start node.
904  SwNode * pCurrentNode = &pRange->aStart.GetNode();
905  SwNodeIndex aTmpIdx( *pCurrentNode->StartOfSectionNode() );
906 
907  if( pCurrentNode->GetEndNode() )
908  DelNodes( pRange->aStart ); // prevent empty section
909  else
910  {
911  // insert a new StartNode
912  SwNode* pSttNd = new SwStartNode( pRange->aStart, SwNodeType::Start, eSttNdTyp );
913  pRange->aStart = *pSttNd;
914  aTmpIdx = pRange->aStart;
915  }
916 
917  // If the end of a range is before or at a StartNode, so delete it,
918  // otherwise empty S/E or E/S nodes would be created.
919  // For other nodes, insert a new end node.
920  --pRange->aEnd;
921  if( pRange->aEnd.GetNode().GetStartNode() )
922  DelNodes( pRange->aEnd );
923  else
924  {
925  ++pRange->aEnd;
926  // insert a new EndNode
927  new SwEndNode( pRange->aEnd, *pRange->aStart.GetNode().GetStartNode() );
928  }
929  --pRange->aEnd;
930 
931  SectionUpDown( aTmpIdx, pRange->aEnd );
932 }
933 
947 {
948  if( pRange->aStart >= pRange->aEnd ||
949  pRange->aEnd >= Count() ||
950  !::CheckNodesRange(pRange->aStart, pRange->aEnd, false) ||
951  ( HighestLevel( *this, *pRange ) <= 1 ))
952  {
953  return;
954  }
955 
956  // If the beginning of a range is before or at a start node position, so
957  // delete it, otherwise empty S/E or E/S nodes would be created.
958  // For other nodes, create a new start node.
959  SwNode * pCurrentNode = &pRange->aStart.GetNode();
960  SwNodeIndex aIdx( *pCurrentNode->StartOfSectionNode() );
961  if( pCurrentNode->IsStartNode() ) // is StartNode itself
962  {
963  SwEndNode* pEndNd = pRange->aEnd.GetNode().GetEndNode();
964  if (pEndNd && pCurrentNode == pEndNd->m_pStartOfSection)
965  {
966  // there was a pairwise reset, adjust only those in the range
967  SwStartNode* pTmpSttNd = pCurrentNode->m_pStartOfSection;
968  RemoveNode( pRange->aStart.GetIndex(), 1, true );
969  RemoveNode( pRange->aEnd.GetIndex(), 1, true );
970 
971  SwNodeIndex aTmpIdx( pRange->aStart );
972  while( aTmpIdx < pRange->aEnd )
973  {
974  pCurrentNode = &aTmpIdx.GetNode();
975  pCurrentNode->m_pStartOfSection = pTmpSttNd;
976  if( pCurrentNode->IsStartNode() )
977  aTmpIdx = pCurrentNode->EndOfSectionIndex() + 1;
978  else
979  ++aTmpIdx;
980  }
981  return ;
982  }
983  DelNodes( pRange->aStart );
984  }
985  else if( aIdx == pRange->aStart.GetIndex()-1 ) // before StartNode
986  DelNodes( aIdx );
987  else
988  new SwEndNode( pRange->aStart, *aIdx.GetNode().GetStartNode() );
989 
990  // If the end of a range is before or at a StartNode, so delete it,
991  // otherwise empty S/E or E/S nodes would be created.
992  // For other nodes, insert a new end node.
993  SwNodeIndex aTmpIdx( pRange->aEnd );
994  if( pRange->aEnd.GetNode().IsEndNode() )
995  DelNodes( pRange->aEnd );
996  else
997  {
998  new SwStartNode( pRange->aEnd );
999 /*?? which NodeType ??*/
1000  aTmpIdx = *pRange->aEnd.GetNode().EndOfSectionNode();
1001  --pRange->aEnd;
1002  }
1003 
1004  SectionUpDown( aIdx, aTmpIdx );
1005 }
1006 
1017 void SwNodes::SectionUpDown( const SwNodeIndex & aStart, const SwNodeIndex & aEnd )
1018 {
1019  SwNodeIndex aTmpIdx( aStart, +1 );
1020  // array forms a stack, holding all StartOfSelections
1021  SwStartNodePointers aSttNdStack;
1022  SwStartNode* pTmp = aStart.GetNode().GetStartNode();
1023  aSttNdStack.push_back( pTmp );
1024 
1025  // loop until the first start node that needs to be change was found
1026  // (the indices are updated from the end node backwards to the start)
1027  for( ;; ++aTmpIdx )
1028  {
1029  SwNode * pCurrentNode = &aTmpIdx.GetNode();
1030  pCurrentNode->m_pStartOfSection = aSttNdStack[ aSttNdStack.size()-1 ];
1031 
1032  if( pCurrentNode->GetStartNode() )
1033  {
1034  pTmp = static_cast<SwStartNode*>(pCurrentNode);
1035  aSttNdStack.push_back( pTmp );
1036  }
1037  else if( pCurrentNode->GetEndNode() )
1038  {
1039  SwStartNode* pSttNd = aSttNdStack[ aSttNdStack.size() - 1 ];
1040  pSttNd->m_pEndOfSection = static_cast<SwEndNode*>(pCurrentNode);
1041  aSttNdStack.pop_back();
1042  if( !aSttNdStack.empty() )
1043  continue; // still enough EndNodes on the stack
1044 
1045  else if( aTmpIdx < aEnd ) // too many StartNodes
1046  // if the end is not reached, yet, get the start of the section above
1047  {
1048  aSttNdStack.insert( aSttNdStack.begin(), pSttNd->m_pStartOfSection );
1049  }
1050  else // finished, as soon as out of the range
1051  break;
1052  }
1053  }
1054 }
1055 
1065 void SwNodes::Delete(const SwNodeIndex &rIndex, sal_uLong nNodes)
1066 {
1067  int nLevel = 0; // level counter
1068  SwNode * pCurrentNode;
1069 
1070  sal_uLong nCnt = Count() - rIndex.GetIndex() - 1;
1071  if( nCnt > nNodes ) nCnt = nNodes;
1072 
1073  if( nCnt == 0 ) // no count -> return
1074  return;
1075 
1076  SwNodeRange aRg( rIndex, 0, rIndex, nCnt-1 );
1077  // check if [rIndex..rIndex + nCnt] is larger than the range
1078  if( ( !aRg.aStart.GetNode().StartOfSectionIndex() &&
1079  !aRg.aStart.GetIndex() ) ||
1080  !::CheckNodesRange(aRg.aStart, aRg.aEnd, false))
1081  {
1082  return;
1083  }
1084 
1085  // if aEnd is not on a ContentNode, search the previous one
1086  while( ( pCurrentNode = &aRg.aEnd.GetNode())->GetStartNode() ||
1087  ( pCurrentNode->GetEndNode() &&
1088  !pCurrentNode->m_pStartOfSection->IsTableNode() ))
1089  --aRg.aEnd;
1090 
1091  nCnt = 0;
1092 //TODO: check/improve comment
1093  // increase start so that we are able to use "<" (using "<=" might cause
1094  // problems if aEnd == aStart and aEnd is deleted, so aEnd <= aStart)
1095  --aRg.aStart;
1096 
1097  bool bSaveInNodesDel = m_bInNodesDel;
1098  m_bInNodesDel = true;
1099  bool bUpdateOutline = false;
1100 
1101  // loop until everything is deleted
1102  while( aRg.aStart < aRg.aEnd )
1103  {
1104  pCurrentNode = &aRg.aEnd.GetNode();
1105 
1106  if( pCurrentNode->GetEndNode() )
1107  {
1108  // delete the whole section?
1109  if( pCurrentNode->StartOfSectionIndex() > aRg.aStart.GetIndex() )
1110  {
1111  SwTableNode* pTableNd = pCurrentNode->m_pStartOfSection->GetTableNode();
1112  if( pTableNd )
1113  pTableNd->DelFrames();
1114 
1115  SwNode *pNd, *pChkNd = pCurrentNode->m_pStartOfSection;
1116  SwOutlineNodes::size_type nIdxPos;
1117  do {
1118  pNd = &aRg.aEnd.GetNode();
1119 
1120  if( pNd->IsTextNode() )
1121  {
1122  SwTextNode *const pTextNode(pNd->GetTextNode());
1123  if (pTextNode->IsOutline() &&
1124  m_pOutlineNodes->Seek_Entry( pNd, &nIdxPos ))
1125  {
1126  // remove outline indices
1127  m_pOutlineNodes->erase(nIdxPos);
1128  bUpdateOutline = true;
1129  }
1130  pTextNode->InvalidateNumRule();
1131  }
1132  else if( pNd->IsEndNode() &&
1133  pNd->m_pStartOfSection->IsTableNode() )
1134  static_cast<SwTableNode*>(pNd->m_pStartOfSection)->DelFrames();
1135 
1136  --aRg.aEnd;
1137  nCnt++;
1138 
1139  } while( pNd != pChkNd );
1140  }
1141  else
1142  {
1143  RemoveNode( aRg.aEnd.GetIndex()+1, nCnt, true ); // delete
1144  nCnt = 0;
1145  --aRg.aEnd; // before the EndNode
1146  nLevel++;
1147  }
1148  }
1149  else if( pCurrentNode->GetStartNode() ) // found StartNode
1150  {
1151  if( nLevel == 0 ) // decrease one level
1152  {
1153  if( nCnt )
1154  {
1155  // now delete array
1156  ++aRg.aEnd;
1157  RemoveNode( aRg.aEnd.GetIndex(), nCnt, true );
1158  nCnt = 0;
1159  }
1160  }
1161  else // remove all nodes between start and end node (incl. both)
1162  {
1163  RemoveNode( aRg.aEnd.GetIndex(), nCnt + 2, true ); // delete array
1164  nCnt = 0;
1165  nLevel--;
1166  }
1167 
1168  // after deletion, aEnd might point to an EndNode...
1169  // delete all empty start/end node pairs
1170  SwNode* pTmpNode = aRg.aEnd.GetNode().GetEndNode();
1171  --aRg.aEnd;
1172  while( pTmpNode &&
1173  ( pCurrentNode = &aRg.aEnd.GetNode())->GetStartNode() &&
1174  pCurrentNode->StartOfSectionIndex() )
1175  {
1176  // remove end and start node
1177  DelNodes( aRg.aEnd, 2 );
1178  pTmpNode = aRg.aEnd.GetNode().GetEndNode();
1179  --aRg.aEnd;
1180  }
1181  }
1182  else // "normal" node, so insert into TmpArray
1183  {
1184  SwTextNode* pTextNd = pCurrentNode->GetTextNode();
1185  if( pTextNd )
1186  {
1187  if( pTextNd->IsOutline())
1188  {
1189  // delete outline indices
1190  m_pOutlineNodes->erase( pTextNd );
1191  bUpdateOutline = true;
1192  }
1193  pTextNd->InvalidateNumRule();
1194  }
1195  else if( pCurrentNode->IsContentNode() )
1196  static_cast<SwContentNode*>(pCurrentNode)->InvalidateNumRule();
1197 
1198  --aRg.aEnd;
1199  nCnt++;
1200  }
1201  }
1202 
1203  ++aRg.aEnd;
1204  if( nCnt != 0 )
1205  RemoveNode( aRg.aEnd.GetIndex(), nCnt, true ); // delete the rest
1206 
1207  // delete all empty start/end node pairs
1208  while( aRg.aEnd.GetNode().GetEndNode() &&
1209  ( pCurrentNode = &aRg.aStart.GetNode())->GetStartNode() &&
1210  pCurrentNode->StartOfSectionIndex() )
1211  // but none of the holy 5. (???)
1212  {
1213  DelNodes( aRg.aStart, 2 ); // delete start and end node
1214  --aRg.aStart;
1215  }
1216 
1217  m_bInNodesDel = bSaveInNodesDel;
1218 
1219  if( !m_bInNodesDel )
1220  {
1221  // update numbering
1222  if( bUpdateOutline || m_bInDelUpdOutline )
1223  {
1224  UpdateOutlineIdx( aRg.aEnd.GetNode() );
1225  m_bInDelUpdOutline = false;
1226  }
1227 
1228  }
1229  else
1230  {
1231  if( bUpdateOutline )
1232  m_bInDelUpdOutline = true;
1233  }
1234 }
1235 
1245 sal_uInt16 SwNodes::GetSectionLevel(const SwNodeIndex &rIdx)
1246 {
1247  // special treatment for 1st Node
1248  if(rIdx == 0) return 1;
1249  // no recursion! This calls a SwNode::GetSectionLevel (missing "s")
1250  return rIdx.GetNode().GetSectionLevel();
1251 }
1252 
1254 {
1255  // after the next start node
1256  SwNodeIndex aTmp( *pIdx->GetNode().StartOfSectionNode(), +1 );
1257 
1258  // If index points to no ContentNode, then go to one.
1259  // If there is no further available, do not change the index' position!
1260  while( !aTmp.GetNode().IsContentNode() )
1261  { // go from this StartNode (can only be one) to its end
1262  if( *pIdx <= aTmp )
1263  return; // ERROR: already after the section
1264  aTmp = aTmp.GetNode().EndOfSectionIndex()+1;
1265  if( *pIdx <= aTmp )
1266  return; // ERROR: already after the section
1267  }
1268  (*pIdx) = aTmp; // is on a ContentNode
1269 }
1270 
1272 {
1273  if( !pIdx->GetNode().IsEndNode() )
1274  (*pIdx) = *pIdx->GetNode().EndOfSectionNode();
1275 }
1276 
1278 {
1279  if( pIdx->GetIndex() >= Count() - 1 )
1280  return nullptr;
1281 
1282  SwNodeIndex aTmp(*pIdx, +1);
1283  SwNode* pNd = nullptr;
1284  while( aTmp < Count()-1 && !( pNd = &aTmp.GetNode())->IsContentNode() )
1285  ++aTmp;
1286 
1287  if( aTmp == Count()-1 )
1288  pNd = nullptr;
1289  else
1290  (*pIdx) = aTmp;
1291  return static_cast<SwContentNode*>(pNd);
1292 }
1293 
1295 {
1296  if( !pIdx->GetIndex() )
1297  return nullptr;
1298 
1299  SwNodeIndex aTmp( *pIdx, -1 );
1300  SwNode* pNd = nullptr;
1301  while( aTmp.GetIndex() && !( pNd = &aTmp.GetNode())->IsContentNode() )
1302  --aTmp;
1303 
1304  if( !aTmp.GetIndex() )
1305  pNd = nullptr;
1306  else
1307  (*pIdx) = aTmp;
1308  return static_cast<SwContentNode*>(pNd);
1309 }
1310 
1316 void SwNodes::DelNodes( const SwNodeIndex & rStart, sal_uLong nCnt )
1317 {
1318  sal_uLong nSttIdx = rStart.GetIndex();
1319 
1320  if( !nSttIdx && nCnt == GetEndOfContent().GetIndex()+1 )
1321  {
1322  // The whole nodes array will be destroyed, you're in the Doc's DTOR!
1323  // The initial start/end nodes should be only destroyed in the SwNodes' DTOR!
1324  SwNode* aEndNdArr[] = { m_pEndOfContent.get(),
1327  nullptr
1328  };
1329 
1330  SwNode** ppEndNdArr = aEndNdArr;
1331  while( *ppEndNdArr )
1332  {
1333  nSttIdx = (*ppEndNdArr)->StartOfSectionIndex() + 1;
1334  sal_uLong nEndIdx = (*ppEndNdArr)->GetIndex();
1335 
1336  if( nSttIdx != nEndIdx )
1337  RemoveNode( nSttIdx, nEndIdx - nSttIdx, true );
1338 
1339  ++ppEndNdArr;
1340  }
1341  }
1342  else
1343  {
1344  int bUpdateNum = 0;
1345  for( sal_uLong n = nSttIdx, nEnd = nSttIdx + nCnt; n < nEnd; ++n )
1346  {
1347  SwNode* pNd = (*this)[ n ];
1348 
1349  if (pNd->IsTextNode() && pNd->GetTextNode()->IsOutline())
1350  {
1351  // remove the outline indices
1352  SwOutlineNodes::size_type nIdxPos;
1353  if( m_pOutlineNodes->Seek_Entry( pNd, &nIdxPos ))
1354  {
1355  m_pOutlineNodes->erase(nIdxPos);
1356  bUpdateNum = 1;
1357  }
1358  }
1359  if( pNd->IsContentNode() )
1360  {
1361  static_cast<SwContentNode*>(pNd)->InvalidateNumRule();
1362  static_cast<SwContentNode*>(pNd)->DelFrames(nullptr);
1363  }
1364  }
1365  RemoveNode( nSttIdx, nCnt, true );
1366 
1367  // update numbering
1368  if( bUpdateNum )
1369  UpdateOutlineIdx( rStart.GetNode() );
1370  }
1371 }
1372 
1373 namespace {
1374 
1375 struct HighLevel
1376 {
1377  sal_uInt16 nLevel, nTop;
1378  explicit HighLevel( sal_uInt16 nLv ) : nLevel( nLv ), nTop( nLv ) {}
1379 };
1380 
1381 }
1382 
1383 static bool lcl_HighestLevel( const SwNodePtr& rpNode, void * pPara )
1384 {
1385  HighLevel * pHL = static_cast<HighLevel*>(pPara);
1386  if( rpNode->GetStartNode() )
1387  pHL->nLevel++;
1388  else if( rpNode->GetEndNode() )
1389  pHL->nLevel--;
1390  if( pHL->nTop > pHL->nLevel )
1391  pHL->nTop = pHL->nLevel;
1392  return true;
1393 
1394 }
1395 
1402 sal_uInt16 HighestLevel( SwNodes & rNodes, const SwNodeRange & rRange )
1403 {
1404  HighLevel aPara( SwNodes::GetSectionLevel( rRange.aStart ));
1405  rNodes.ForEach( rRange.aStart, rRange.aEnd, lcl_HighestLevel, &aPara );
1406  return aPara.nTop;
1407 
1408 }
1409 
1416 void SwNodes::MoveRange( SwPaM & rPam, SwPosition & rPos, SwNodes& rNodes )
1417 {
1418  SwPosition * const pStt = rPam.Start();
1419  SwPosition * const pEnd = rPam.End();
1420 
1421  if( !rPam.HasMark() || *pStt >= *pEnd )
1422  return;
1423 
1424  if( this == &rNodes && *pStt <= rPos && rPos < *pEnd )
1425  return;
1426 
1427  SwNodeIndex aEndIdx( pEnd->nNode );
1428  SwNodeIndex aSttIdx( pStt->nNode );
1429  SwTextNode *const pSrcNd = aSttIdx.GetNode().GetTextNode();
1430  SwTextNode * pDestNd = rPos.nNode.GetNode().GetTextNode();
1431  bool bSplitDestNd = true;
1432  bool bCopyCollFormat = pDestNd && pDestNd->GetText().isEmpty();
1433 
1434  if( pSrcNd )
1435  {
1436  // if the first node is a TextNode, then there must
1437  // be also a TextNode in the NodesArray to store the content
1438  if( !pDestNd )
1439  {
1440  pDestNd = rNodes.MakeTextNode( rPos.nNode, pSrcNd->GetTextColl() );
1441  --rPos.nNode;
1442  rPos.nContent.Assign( pDestNd, 0 );
1443  bCopyCollFormat = true;
1444  }
1445  bSplitDestNd = pDestNd->Len() > rPos.nContent.GetIndex() ||
1446  pEnd->nNode.GetNode().IsTextNode();
1447 
1448  // move the content into the new node
1449  bool bOneNd = pStt->nNode == pEnd->nNode;
1450  const sal_Int32 nLen =
1451  ( bOneNd ? std::min(pEnd->nContent.GetIndex(), pSrcNd->Len()) : pSrcNd->Len() )
1452  - pStt->nContent.GetIndex();
1453 
1454  if( !pEnd->nNode.GetNode().IsContentNode() )
1455  {
1456  bOneNd = true;
1457  sal_uLong nSttNdIdx = pStt->nNode.GetIndex() + 1;
1458  const sal_uLong nEndNdIdx = pEnd->nNode.GetIndex();
1459  for( ; nSttNdIdx < nEndNdIdx; ++nSttNdIdx )
1460  {
1461  if( (*this)[ nSttNdIdx ]->IsContentNode() )
1462  {
1463  bOneNd = false;
1464  break;
1465  }
1466  }
1467  }
1468 
1469  // templates must be copied/set after a split
1470  if( !bOneNd && bSplitDestNd )
1471  {
1472  if( !rPos.nContent.GetIndex() )
1473  {
1474  bCopyCollFormat = true;
1475  }
1476  if( rNodes.IsDocNodes() )
1477  {
1478  SwDoc* const pInsDoc = pDestNd->GetDoc();
1479  ::sw::UndoGuard const ug(pInsDoc->GetIDocumentUndoRedo());
1480  pInsDoc->getIDocumentContentOperations().SplitNode( rPos, false );
1481  }
1482  else
1483  {
1484  pDestNd->SplitContentNode(rPos, nullptr);
1485  }
1486 
1487  if( rPos.nNode == aEndIdx )
1488  {
1489  --aEndIdx;
1490  }
1491  bSplitDestNd = true;
1492 
1493  pDestNd = rNodes[ rPos.nNode.GetIndex() - 1 ]->GetTextNode();
1494  if( nLen )
1495  {
1496  pSrcNd->CutText( pDestNd, SwIndex( pDestNd, pDestNd->Len()),
1497  pStt->nContent, nLen );
1498  }
1499  }
1500  else if ( nLen )
1501  {
1502  pSrcNd->CutText( pDestNd, rPos.nContent, pStt->nContent, nLen );
1503  }
1504 
1505  if( bCopyCollFormat )
1506  {
1507  SwDoc* const pInsDoc = pDestNd->GetDoc();
1508  ::sw::UndoGuard const undoGuard(pInsDoc->GetIDocumentUndoRedo());
1509  pSrcNd->CopyCollFormat( *pDestNd );
1510  bCopyCollFormat = false;
1511  }
1512 
1513  if( bOneNd )
1514  {
1515  // Correct the PaM, because it might have happened that the move
1516  // went over the node borders (so the data might be in different nodes).
1517  // Also, a selection is invalidated.
1518  pEnd->nContent = pStt->nContent;
1519  rPam.DeleteMark();
1520  GetDoc()->GetDocShell()->Broadcast( SwFormatFieldHint( nullptr,
1522  return;
1523  }
1524 
1525  ++aSttIdx;
1526  }
1527  else if( pDestNd )
1528  {
1529  if( rPos.nContent.GetIndex() )
1530  {
1531  if( rPos.nContent.GetIndex() == pDestNd->Len() )
1532  {
1533  ++rPos.nNode;
1534  }
1535  else if( rPos.nContent.GetIndex() )
1536  {
1537  // if the EndNode is split than correct the EndIdx
1538  const bool bCorrEnd = aEndIdx == rPos.nNode;
1539 
1540  // if no text is attached to the TextNode, split it
1541  if( rNodes.IsDocNodes() )
1542  {
1543  SwDoc* const pInsDoc = pDestNd->GetDoc();
1544  ::sw::UndoGuard const ug(pInsDoc->GetIDocumentUndoRedo());
1545  pInsDoc->getIDocumentContentOperations().SplitNode( rPos, false );
1546  }
1547  else
1548  {
1549  pDestNd->SplitContentNode(rPos, nullptr);
1550  }
1551 
1552  if ( bCorrEnd )
1553  {
1554  --aEndIdx;
1555  }
1556  }
1557  }
1558  // at the end only an empty TextNode is left over
1559  bSplitDestNd = true;
1560  }
1561 
1562  SwTextNode* const pEndSrcNd = aEndIdx.GetNode().GetTextNode();
1563  if ( pEndSrcNd )
1564  {
1565  // at the end of this range a new TextNode will be created
1566  if( !bSplitDestNd )
1567  {
1568  if( rPos.nNode < rNodes.GetEndOfContent().GetIndex() )
1569  {
1570  ++rPos.nNode;
1571  }
1572 
1573  pDestNd =
1574  rNodes.MakeTextNode( rPos.nNode, pEndSrcNd->GetTextColl() );
1575  --rPos.nNode;
1576  rPos.nContent.Assign( pDestNd, 0 );
1577  }
1578  else
1579  {
1580  pDestNd = rPos.nNode.GetNode().GetTextNode();
1581  }
1582 
1583  if (pDestNd && pEnd->nContent.GetIndex())
1584  {
1585  // move the content into the new node
1586  SwIndex aIdx( pEndSrcNd, 0 );
1587  pEndSrcNd->CutText( pDestNd, rPos.nContent, aIdx,
1588  pEnd->nContent.GetIndex());
1589  }
1590 
1591  if (pDestNd && bCopyCollFormat)
1592  {
1593  SwDoc* const pInsDoc = pDestNd->GetDoc();
1594  ::sw::UndoGuard const ug(pInsDoc->GetIDocumentUndoRedo());
1595  pEndSrcNd->CopyCollFormat( *pDestNd );
1596  }
1597  }
1598  else
1599  {
1600  if ( pSrcNd && aEndIdx.GetNode().IsContentNode() )
1601  {
1602  ++aEndIdx;
1603  }
1604  if( !bSplitDestNd )
1605  {
1606  ++rPos.nNode;
1607  rPos.nContent.Assign( rPos.nNode.GetNode().GetContentNode(), 0 );
1608  }
1609  }
1610 
1611  if( aEndIdx != aSttIdx )
1612  {
1613  // move the nodes into the NodesArary
1614  const sal_uLong nSttDiff = aSttIdx.GetIndex() - pStt->nNode.GetIndex();
1615  SwNodeRange aRg( aSttIdx, aEndIdx );
1616  MoveNodes( aRg, rNodes, rPos.nNode );
1617 
1618  // if in the same node array, all indices are now at new positions (so correct them)
1619  if( &rNodes == this )
1620  {
1621  pStt->nNode = aRg.aEnd.GetIndex() - nSttDiff;
1622  }
1623  }
1624 
1625  // if the StartNode was moved to whom the cursor pointed, so
1626  // the content must be registered in the current content!
1627  if ( &pStt->nNode.GetNode() == &GetEndOfContent() )
1628  {
1629  const bool bSuccess = GoPrevious( &pStt->nNode );
1630  OSL_ENSURE( bSuccess, "Move() - no ContentNode here" );
1631  }
1632  pStt->nContent.Assign( pStt->nNode.GetNode().GetContentNode(),
1633  pStt->nContent.GetIndex() );
1634  // Correct the PaM, because it might have happened that the move
1635  // went over the node borders (so the data might be in different nodes).
1636  // Also, a selection is invalidated.
1637  *pEnd = *pStt;
1638  rPam.DeleteMark();
1639  GetDoc()->GetDocShell()->Broadcast( SwFormatFieldHint( nullptr,
1641 }
1642 
1644 void SwNodes::CopyNodes( const SwNodeRange& rRange,
1645  const SwNodeIndex& rIndex, bool bNewFrames, bool bTableInsDummyNode ) const
1646 {
1647  SwDoc* pDoc = rIndex.GetNode().GetDoc();
1648 
1649  SwNode * pCurrentNode;
1650  if( rIndex == 0 ||
1651  ( (pCurrentNode = &rIndex.GetNode())->GetStartNode() &&
1652  !pCurrentNode->StartOfSectionIndex() ))
1653  return;
1654 
1655  SwNodeRange aRg( rRange );
1656 
1657  // skip "simple" StartNodes or EndNodes
1658  while( SwNodeType::Start == (pCurrentNode = & aRg.aStart.GetNode())->GetNodeType()
1659  || ( pCurrentNode->IsEndNode() &&
1660  !pCurrentNode->m_pStartOfSection->IsSectionNode() ) )
1661  ++aRg.aStart;
1662 
1663  const SwNode *aEndNode = &aRg.aEnd.GetNode();
1664  int nIsEndOfContent = (aEndNode == &aEndNode->GetNodes().GetEndOfContent()) ? 1 : 0;
1665 
1666  if (0 == nIsEndOfContent)
1667  {
1668  // if aEnd-1 points to no ContentNode, search previous one
1669  --aRg.aEnd;
1670  // #i107142#: if aEnd is start node of a special section, do nothing.
1671  // Otherwise this could lead to crash: going through all previous
1672  // special section nodes and then one before the first.
1673  if (aRg.aEnd.GetNode().StartOfSectionIndex() != 0)
1674  {
1675  while( ((pCurrentNode = & aRg.aEnd.GetNode())->GetStartNode() &&
1676  !pCurrentNode->IsSectionNode() ) ||
1677  ( pCurrentNode->IsEndNode() &&
1678  SwNodeType::Start == pCurrentNode->m_pStartOfSection->GetNodeType()) )
1679  {
1680  --aRg.aEnd;
1681  }
1682  }
1683  ++aRg.aEnd;
1684  }
1685 
1686  // is there anything left to copy?
1687  if( aRg.aStart >= aRg.aEnd )
1688  return;
1689 
1690  // when inserting into the source range, nothing need to be done
1691  OSL_ENSURE( &aRg.aStart.GetNodes() == this,
1692  "aRg should use this node array" );
1693  OSL_ENSURE( &aRg.aStart.GetNodes() == &aRg.aEnd.GetNodes(),
1694  "Range across different nodes arrays? You deserve punishment!");
1695  if( &rIndex.GetNodes() == &aRg.aStart.GetNodes() &&
1696  rIndex.GetIndex() >= aRg.aStart.GetIndex() &&
1697  rIndex.GetIndex() < aRg.aEnd.GetIndex() )
1698  return;
1699 
1700  SwNodeIndex aInsPos( rIndex );
1701  SwNodeIndex aOrigInsPos( rIndex, -1 ); // original insertion position
1702  int nLevel = 0; // level counter
1703 
1704  for( long nNodeCnt = aRg.aEnd.GetIndex() - aRg.aStart.GetIndex();
1705  nNodeCnt > 0; --nNodeCnt )
1706  {
1707  pCurrentNode = &aRg.aStart.GetNode();
1708  switch( pCurrentNode->GetNodeType() )
1709  {
1710  case SwNodeType::Table:
1711  // Does it copy a table in(to) a footnote?
1712  if( aInsPos < pDoc->GetNodes().GetEndOfInserts().GetIndex() &&
1714  < aInsPos.GetIndex() )
1715  {
1716  const long nDistance =
1717  pCurrentNode->EndOfSectionIndex() -
1718  aRg.aStart.GetIndex();
1719  if (nDistance < nNodeCnt)
1720  nNodeCnt -= nDistance;
1721  else
1722  nNodeCnt = 1;
1723 
1724  // insert a DummyNode for a TableNode
1725  if( bTableInsDummyNode )
1726  new SwPlaceholderNode(aInsPos);
1727 
1728  // copy all of the table's nodes into the current cell
1729  for( ++aRg.aStart; aRg.aStart.GetIndex() <
1730  pCurrentNode->EndOfSectionIndex();
1731  ++aRg.aStart )
1732  {
1733  // insert a DummyNode for the box-StartNode?
1734  if( bTableInsDummyNode )
1735  new SwPlaceholderNode(aInsPos);
1736 
1737  SwStartNode* pSttNd = aRg.aStart.GetNode().GetStartNode();
1738  CopyNodes( SwNodeRange( *pSttNd, + 1,
1739  *pSttNd->EndOfSectionNode() ),
1740  aInsPos, bNewFrames );
1741 
1742  // insert a DummyNode for the box-EndNode?
1743  if( bTableInsDummyNode )
1744  new SwPlaceholderNode(aInsPos);
1745  aRg.aStart = *pSttNd->EndOfSectionNode();
1746  }
1747  // insert a DummyNode for the table-EndNode
1748  if( bTableInsDummyNode )
1749  new SwPlaceholderNode(aInsPos);
1750  aRg.aStart = *pCurrentNode->EndOfSectionNode();
1751  }
1752  else
1753  {
1754  SwNodeIndex nStt( aInsPos, -1 );
1755  SwTableNode* pTableNd = static_cast<SwTableNode*>(pCurrentNode)->
1756  MakeCopy( pDoc, aInsPos );
1757  const long nDistance = aInsPos.GetIndex() - nStt.GetIndex() - 2;
1758  if (nDistance < nNodeCnt)
1759  nNodeCnt -= nDistance;
1760  else
1761  nNodeCnt = 1 - nIsEndOfContent;
1762 
1763  aRg.aStart = pCurrentNode->EndOfSectionIndex();
1764 
1765  if( bNewFrames && pTableNd )
1766  {
1767  nStt = aInsPos;
1768  pTableNd->MakeOwnFrames(&nStt);
1769  }
1770  }
1771  break;
1772 
1773  case SwNodeType::Section:
1774  // If the end of the section is outside the copy range,
1775  // the section node will skipped, not copied!
1776  // If someone want to change this behaviour, he has to adjust the function
1777  // lcl_NonCopyCount(..) in ndcopy.cxx which relies on it.
1778  if( pCurrentNode->EndOfSectionIndex() < aRg.aEnd.GetIndex() )
1779  {
1780  // copy of the whole section, so create a new SectionNode
1781  SwNodeIndex nStt( aInsPos, -1 );
1782  SwSectionNode* pSectNd = static_cast<SwSectionNode*>(pCurrentNode)->
1783  MakeCopy( pDoc, aInsPos );
1784 
1785  const long nDistance = aInsPos.GetIndex() - nStt.GetIndex() - 2;
1786  if (nDistance < nNodeCnt)
1787  nNodeCnt -= nDistance;
1788  else
1789  nNodeCnt = 1 - nIsEndOfContent;
1790  aRg.aStart = pCurrentNode->EndOfSectionIndex();
1791 
1792  if( bNewFrames && pSectNd &&
1793  !pSectNd->GetSection().IsHidden() )
1794  pSectNd->MakeOwnFrames(&nStt);
1795  }
1796  break;
1797 
1798  case SwNodeType::Start:
1799  {
1800  SwStartNode* pTmp = new SwStartNode( aInsPos, SwNodeType::Start,
1801  static_cast<SwStartNode*>(pCurrentNode)->GetStartNodeType() );
1802  new SwEndNode( aInsPos, *pTmp );
1803  --aInsPos;
1804  nLevel++;
1805  }
1806  break;
1807 
1808  case SwNodeType::End:
1809  if( nLevel ) // complete section
1810  {
1811  --nLevel;
1812  ++aInsPos; // EndNode already exists
1813  }
1814  else if( 1 == nNodeCnt && 1 == nIsEndOfContent )
1815  // we have reached the EndOfContent node - nothing to do!
1816  continue;
1817  else if( !pCurrentNode->m_pStartOfSection->IsSectionNode() )
1818  {
1819  // create a section at the original InsertPosition
1820  SwNodeRange aTmpRg( aOrigInsPos, 1, aInsPos );
1821  pDoc->GetNodes().SectionDown( &aTmpRg,
1822  pCurrentNode->m_pStartOfSection->GetStartNodeType() );
1823  }
1824  break;
1825 
1826  case SwNodeType::Text:
1827  case SwNodeType::Grf:
1828  case SwNodeType::Ole:
1829  {
1830  static_cast<SwContentNode*>(pCurrentNode)->MakeCopy(
1831  pDoc, aInsPos, bNewFrames);
1832  }
1833  break;
1834 
1836  if (GetDoc()->GetIDocumentUndoRedo().IsUndoNodes(*this))
1837  {
1838  // than a SectionNode (start/end) is needed at the current
1839  // InsPos; if so skip it, otherwise ignore current node
1840  SwNode *const pTmpNd = & aInsPos.GetNode();
1841  if( pTmpNd->IsSectionNode() ||
1842  pTmpNd->StartOfSectionNode()->IsSectionNode() )
1843  ++aInsPos; // skip
1844  }
1845  else {
1846  assert(!"How can this node be in the node array?");
1847  }
1848  break;
1849 
1850  default:
1851  assert(false);
1852  }
1853  ++aRg.aStart;
1854  }
1855 }
1856 
1858 {
1859  SwNodeIndex aIdx( rRg.aStart );
1860  while( aIdx.GetIndex() < rRg.aEnd.GetIndex() )
1861  {
1863  RemoveNode( aIdx.GetIndex(), 1, true );
1864  else
1865  ++aIdx;
1866  }
1867 }
1868 
1870  SwStartNodeType eSttNdTyp )
1871 {
1872  SwStartNode* pSttNd = new SwStartNode( rIdx, SwNodeType::Start, eSttNdTyp );
1873  new SwEndNode( rIdx, *pSttNd );
1874  return pSttNd;
1875 }
1876 
1878  SwStartNodeType eSttNdTyp,
1879  SwTextFormatColl *pColl )
1880 {
1881  SwStartNode* pSttNd = new SwStartNode( rWhere, SwNodeType::Start, eSttNdTyp );
1882  new SwEndNode( rWhere, *pSttNd );
1883  MakeTextNode( SwNodeIndex( rWhere, - 1 ), pColl );
1884  return pSttNd;
1885 }
1886 
1887 //TODO: provide better documentation
1901  bool bSkipHidden, bool bSkipProtect ) const
1902 {
1903  bool bFirst = true;
1904  SwNodeIndex aTmp( *pIdx );
1905  const SwNode* pNd;
1906  while( aTmp < Count() - 1 )
1907  {
1908  pNd = & aTmp.GetNode();
1909  if (SwNodeType::Section == pNd->GetNodeType())
1910  {
1911  const SwSection& rSect = static_cast<const SwSectionNode*>(pNd)->GetSection();
1912  if( (bSkipHidden && rSect.IsHiddenFlag()) ||
1913  (bSkipProtect && rSect.IsProtectFlag()) )
1914  // than skip the section
1915  aTmp = *pNd->EndOfSectionNode();
1916  }
1917  else if( bFirst )
1918  {
1919  if( pNd->m_pStartOfSection->IsSectionNode() )
1920  {
1921  const SwSection& rSect = static_cast<SwSectionNode*>(pNd->
1922  m_pStartOfSection)->GetSection();
1923  if( (bSkipHidden && rSect.IsHiddenFlag()) ||
1924  (bSkipProtect && rSect.IsProtectFlag()) )
1925  // than skip the section
1926  aTmp = *pNd->EndOfSectionNode();
1927  }
1928  }
1929  else if( SwNodeType::ContentMask & pNd->GetNodeType() )
1930  {
1931  const SwSectionNode* pSectNd;
1932  if( ( bSkipHidden || bSkipProtect ) &&
1933  nullptr != (pSectNd = pNd->FindSectionNode() ) &&
1934  ( ( bSkipHidden && pSectNd->GetSection().IsHiddenFlag() ) ||
1935  ( bSkipProtect && pSectNd->GetSection().IsProtectFlag() )) )
1936  {
1937  aTmp = *pSectNd->EndOfSectionNode();
1938  }
1939  else
1940  {
1941  (*pIdx) = aTmp;
1942  return const_cast<SwContentNode*>(static_cast<const SwContentNode*>(pNd));
1943  }
1944  }
1945  ++aTmp;
1946  bFirst = false;
1947  }
1948  return nullptr;
1949 }
1950 
1953  bool bSkipHidden, bool bSkipProtect )
1954 {
1955  bool bFirst = true;
1956  SwNodeIndex aTmp( *pIdx );
1957  const SwNode* pNd;
1958  while( aTmp > 0 )
1959  {
1960  pNd = & aTmp.GetNode();
1961  if (SwNodeType::End == pNd->GetNodeType())
1962  {
1963  if( pNd->m_pStartOfSection->IsSectionNode() )
1964  {
1965  const SwSection& rSect = static_cast<SwSectionNode*>(pNd->
1966  m_pStartOfSection)->GetSection();
1967  if( (bSkipHidden && rSect.IsHiddenFlag()) ||
1968  (bSkipProtect && rSect.IsProtectFlag()) )
1969  // than skip section
1970  aTmp = *pNd->StartOfSectionNode();
1971  }
1972  bFirst = false;
1973  }
1974  else if( bFirst )
1975  {
1976  bFirst = false;
1977  if( pNd->m_pStartOfSection->IsSectionNode() )
1978  {
1979  const SwSection& rSect = static_cast<SwSectionNode*>(pNd->
1980  m_pStartOfSection)->GetSection();
1981  if( (bSkipHidden && rSect.IsHiddenFlag()) ||
1982  (bSkipProtect && rSect.IsProtectFlag()) )
1983  // than skip section
1984  aTmp = *pNd->StartOfSectionNode();
1985  }
1986  }
1987  else if( SwNodeType::ContentMask & pNd->GetNodeType() )
1988  {
1989  const SwSectionNode* pSectNd;
1990  if( ( bSkipHidden || bSkipProtect ) &&
1991  nullptr != (pSectNd = pNd->FindSectionNode() ) &&
1992  ( ( bSkipHidden && pSectNd->GetSection().IsHiddenFlag() ) ||
1993  ( bSkipProtect && pSectNd->GetSection().IsProtectFlag() )) )
1994  {
1995  aTmp = *pSectNd;
1996  }
1997  else
1998  {
1999  (*pIdx) = aTmp;
2000  return const_cast<SwContentNode*>(static_cast<const SwContentNode*>(pNd));
2001  }
2002  }
2003  --aTmp;
2004  }
2005  return nullptr;
2006 }
2007 
2008 //TODO: improve documentation
2009 //TODO: The inventor of the "single responsibility principle" will be crying if you ever show this code to him!
2020  const SwNode* pEnd ) const
2021 {
2022  SwNode* pFrameNd = nullptr;
2023 
2024  // no layout -> skip
2025  if( GetDoc()->getIDocumentLayoutAccess().GetCurrentViewShell() )
2026  {
2027  SwNode* pSttNd = &rFrameIdx.GetNode();
2028 
2029  // move of a hidden section?
2030  SwSectionNode* pSectNd = pSttNd->IsSectionNode()
2031  ? pSttNd->StartOfSectionNode()->FindSectionNode()
2032  : pSttNd->FindSectionNode();
2033  if( !( pSectNd && pSectNd->GetSection().CalcHiddenFlag() ) )
2034  {
2035  // in a table in table situation we have to assure that we don't leave the
2036  // outer table cell when the inner table is looking for a PrvNxt...
2037  SwTableNode* pTableNd = pSttNd->IsTableNode()
2038  ? pSttNd->StartOfSectionNode()->FindTableNode()
2039  : pSttNd->FindTableNode();
2040  SwNodeIndex aIdx( rFrameIdx );
2041  SwNode* pNd;
2042  if( pEnd )
2043  {
2044  --aIdx;
2045  pNd = &aIdx.GetNode();
2046  }
2047  else
2048  pNd = pSttNd;
2049 
2050  if( ( pFrameNd = pNd )->IsContentNode() )
2051  rFrameIdx = aIdx;
2052 
2053  // search forward or backward for a content node
2054  else if( nullptr != ( pFrameNd = GoPrevSection( &aIdx, true, false )) &&
2055  ::CheckNodesRange( aIdx, rFrameIdx, true ) &&
2056  // Never out of the table at the start
2057  pFrameNd->FindTableNode() == pTableNd &&
2058  // Bug 37652: Never out of the table at the end
2059  (!pFrameNd->FindTableNode() || pFrameNd->FindTableBoxStartNode()
2060  == pSttNd->FindTableBoxStartNode() ) &&
2061  (!pSectNd || pSttNd->IsSectionNode() ||
2062  pSectNd->GetIndex() < pFrameNd->GetIndex())
2063  )
2064  {
2065  rFrameIdx = aIdx;
2066  }
2067  else
2068  {
2069  if( pEnd )
2070  aIdx = pEnd->GetIndex() + 1;
2071  else
2072  aIdx = rFrameIdx;
2073 
2074  // NEVER leave the section when doing this!
2075  if( ( pEnd && ( pFrameNd = &aIdx.GetNode())->IsContentNode() ) ||
2076  ( nullptr != ( pFrameNd = GoNextSection( &aIdx, true, false )) &&
2077  ::CheckNodesRange( aIdx, rFrameIdx, true ) &&
2078  ( pFrameNd->FindTableNode() == pTableNd &&
2079  // NEVER go out of the table cell at the end
2080  (!pFrameNd->FindTableNode() || pFrameNd->FindTableBoxStartNode()
2081  == pSttNd->FindTableBoxStartNode() ) ) &&
2082  (!pSectNd || pSttNd->IsSectionNode() ||
2083  pSectNd->EndOfSectionIndex() > pFrameNd->GetIndex())
2084  ))
2085  {
2086  // Undo when merging a table with one before, if there is also one after it.
2087  // However, if the node is in a table, it needs to be returned if the
2088  // SttNode is a section or a table!
2089  SwTableNode* pTableNode;
2090  if (pSttNd->IsTableNode() &&
2091  nullptr != (pTableNode = pFrameNd->FindTableNode()) &&
2092  // TABLE IN TABLE:
2093  pTableNode != pSttNd->StartOfSectionNode()->FindTableNode())
2094  {
2095  pFrameNd = pTableNode;
2096  rFrameIdx = *pFrameNd;
2097  }
2098  else
2099  rFrameIdx = aIdx;
2100  }
2101  else if( pNd->IsEndNode() && pNd->StartOfSectionNode()->IsTableNode() )
2102  {
2103  pFrameNd = pNd->StartOfSectionNode();
2104  rFrameIdx = *pFrameNd;
2105  }
2106  else
2107  {
2108  if( pEnd )
2109  aIdx = pEnd->GetIndex() + 1;
2110  else
2111  aIdx = rFrameIdx.GetIndex() + 1;
2112 
2113  if( (pFrameNd = &aIdx.GetNode())->IsTableNode() )
2114  rFrameIdx = aIdx;
2115  else
2116  {
2117  pFrameNd = nullptr;
2118 
2119  // is there some sectionnodes before a tablenode?
2120  while( aIdx.GetNode().IsSectionNode() )
2121  {
2122  const SwSection& rSect = aIdx.GetNode().
2123  GetSectionNode()->GetSection();
2124  if( rSect.IsHiddenFlag() )
2125  aIdx = aIdx.GetNode().EndOfSectionIndex()+1;
2126  else
2127  ++aIdx;
2128  }
2129  if( aIdx.GetNode().IsTableNode() )
2130  {
2131  rFrameIdx = aIdx;
2132  pFrameNd = &aIdx.GetNode();
2133  }
2134  }
2135  }
2136  }
2137  }
2138  }
2139  return pFrameNd;
2140 }
2141 
2143  FnForEach_SwNodes fn, void* pArgs )
2144 {
2145  if( nEnd > m_nSize )
2146  nEnd = m_nSize;
2147 
2148  if( nStart < nEnd )
2149  {
2150  sal_uInt16 cur = Index2Block( nStart );
2151  BlockInfo** pp = m_ppInf.get() + cur;
2152  BlockInfo* p = *pp;
2153  sal_uInt16 nElem = sal_uInt16( nStart - p->nStart );
2154  auto pElem = p->mvData.begin() + nElem;
2155  nElem = p->nElem - nElem;
2156  for(;;)
2157  {
2158  if( !(*fn)( static_cast<SwNode *>(*pElem++), pArgs ) || ++nStart >= nEnd )
2159  break;
2160 
2161  // next element
2162  if( !--nElem )
2163  {
2164  // new block
2165  p = *++pp;
2166  pElem = p->mvData.begin();
2167  nElem = p->nElem;
2168  }
2169  }
2170  }
2171 }
2172 
2173 void SwNodes::ForEach( const SwNodeIndex& rStart, const SwNodeIndex& rEnd,
2174  FnForEach_SwNodes fnForEach, void* pArgs )
2175 {
2176  ForEach( rStart.GetIndex(), rEnd.GetIndex(), fnForEach, pArgs );
2177 }
2178 
2179 void SwNodes::RemoveNode( sal_uLong nDelPos, sal_uLong nSz, bool bDel )
2180 {
2181 #ifndef NDEBUG
2182  SwNode *const pFirst((*this)[nDelPos]);
2183 #endif
2184  for (sal_uLong nCnt = 0; nCnt < nSz; nCnt++)
2185  {
2186  SwNode* pNode = (*this)[ nDelPos + nCnt ];
2187  SwTextNode * pTextNd = pNode->GetTextNode();
2188 
2189  if (pTextNd)
2190  {
2191  pTextNd->RemoveFromList();
2192  // remove RndStdIds::FLY_AS_CHAR *before* adjusting SwNodeIndex
2193  // so their anchor still points to correct node when deleted!
2194  // NOTE: this will call RemoveNode() recursively!
2195  // so adjust our indexes to account for removed nodes
2196  sal_uLong const nPos = pTextNd->GetIndex();
2197  SwpHints *const pHints(pTextNd->GetpSwpHints());
2198  if (pHints)
2199  {
2200  std::vector<SwTextAttr*> flys;
2201  for (size_t i = 0; i < pHints->Count(); ++i)
2202  {
2203  SwTextAttr *const pHint(pHints->Get(i));
2204  if (RES_TXTATR_FLYCNT == pHint->Which())
2205  {
2206  flys.push_back(pHint);
2207  }
2208  }
2209  for (SwTextAttr * pHint : flys)
2210  {
2211  pTextNd->DeleteAttribute(pHint);
2212  } // pHints may be dead now
2213  sal_uLong const nDiff = nPos - pTextNd->GetIndex();
2214  if (nDiff)
2215  {
2216  nDelPos -= nDiff;
2217  }
2218  assert(pTextNd == (*this)[nDelPos + nCnt]);
2219  assert(pFirst == (*this)[nDelPos]);
2220  }
2221  }
2222  SwTableNode* pTableNode = pNode->GetTableNode();
2223  if (pTableNode)
2224  {
2225  // The node that is deleted is a table node.
2226  // Need to make sure that all the redlines that are
2227  // related to this table are removed from the
2228  // 'Extra Redlines' array
2229  pTableNode->RemoveRedlines();
2230  }
2231  }
2232 
2233  sal_uLong nEnd = nDelPos + nSz;
2234  SwNode* pNew = (*this)[ nEnd ];
2235 
2236  for (SwNodeIndex& rIndex : m_vIndices->GetRingContainer())
2237  {
2238  sal_uLong const nIdx = rIndex.GetIndex();
2239  if (nDelPos <= nIdx && nIdx < nEnd)
2240  rIndex = *pNew;
2241  }
2242 
2243  std::vector<BigPtrEntry> aTempEntries;
2244  if( bDel )
2245  {
2246  sal_uLong nCnt = nSz;
2247  BigPtrEntry *pDel = (*this)[ nDelPos+nCnt-1 ], *pPrev = (*this)[ nDelPos+nCnt-2 ];
2248 
2249  // set temporary object
2250  // JP 24.08.98: this should actually be removed because one could
2251  // call Remove recursively, e.g. for character bound frames. However,
2252  // since there happens way too much here, this temporary object was
2253  // inserted that will be deleted in Remove again (see Bug 55406)
2254  aTempEntries.resize(nCnt);
2255 
2256  while( nCnt-- )
2257  {
2258  delete pDel;
2259  pDel = pPrev;
2260  sal_uLong nPrevNdIdx = pPrev->GetPos();
2261  BigPtrEntry* pTempEntry = &aTempEntries[nCnt];
2262  BigPtrArray::Replace( nPrevNdIdx+1, pTempEntry );
2263  if( nCnt )
2264  pPrev = BigPtrArray::operator []( nPrevNdIdx - 1 );
2265  // the accessed element can be a naked BigPtrEntry from
2266  // aTempEntries, so the downcast to SwNode* in
2267  // SwNodes::operator[] would be illegal (and unnecessary)
2268  }
2269  nDelPos = pDel->GetPos() + 1;
2270  }
2271 
2272  BigPtrArray::Remove( nDelPos, nSz );
2273 }
2274 
2275 void SwNodes::InsertNode( const SwNodePtr pNode,
2276  const SwNodeIndex& rPos )
2277 {
2278  BigPtrEntry* pIns = pNode;
2279  BigPtrArray::Insert( pIns, rPos.GetIndex() );
2280 }
2281 
2282 void SwNodes::InsertNode( const SwNodePtr pNode,
2283  sal_uLong nPos )
2284 {
2285  BigPtrEntry* pIns = pNode;
2286  BigPtrArray::Insert( pIns, nPos );
2287 }
2288 
2289 // ->#112139#
2291 {
2292  if (nullptr != pNode)
2293  {
2294  SwNodeIndex aIdx(*pNode);
2295 
2296  if (aIdx <= (*this)[0]->EndOfSectionIndex())
2297  pNode = (*this)[0];
2298  else
2299  {
2300  while ((*this)[0] != pNode->StartOfSectionNode())
2301  pNode = pNode->StartOfSectionNode();
2302  }
2303  }
2304 
2305  return pNode;
2306 }
2307 
2309 {
2310  return DocumentSectionStartNode(pNode)->EndOfSectionNode();
2311 }
2312 
2314 {
2315  return this == &m_pMyDoc->GetNodes();
2316 }
2317 
2319 {
2320  xmlTextWriterStartElement(pWriter, BAD_CAST("SwNodes"));
2321  for (sal_uLong i = 0; i < Count(); ++i)
2322  (*this)[i]->dumpAsXml(pWriter);
2323  xmlTextWriterEndElement(pWriter);
2324 }
2325 
2326 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SwSectionNode * FindSectionNode()
Search section node, in which it is.
Definition: ndsect.cxx:958
Instances of SwFields and those derived from it occur 0 to n times.
Definition: fldbas.hxx:240
const SwEndNode * EndOfSectionNode() const
Definition: node.hxx:682
Starts a section of nodes in the document model.
Definition: node.hxx:303
void DeleteMark()
Definition: pam.hxx:177
SwNode & GetEndOfInserts() const
Section for all footnotes.
Definition: ndarr.hxx:154
sal_uLong GetIndex() const
Definition: node.hxx:282
SwStartNode * m_pStartOfSection
Definition: node.hxx:112
sal_uLong Count() const
Definition: ndarr.hxx:142
Represents the style of a paragraph.
Definition: fmtcol.hxx:55
Marks a position in the document model.
Definition: pam.hxx:35
bool IsSectionNode() const
Definition: node.hxx:644
const SwField * GetField() const
Definition: fmtfld.hxx:111
sal_uLong StartOfSectionIndex() const
Definition: node.hxx:673
void DelFrames(SwRootFrame const *pLayout=nullptr)
Method deletes all views of document for the node.
Definition: ndtbl.cxx:2415
constexpr TypedWhichId< SwFormatMeta > RES_TXTATR_METAFIELD(49)
const OUString & GetText() const
Definition: ndtxt.hxx:211
bool IsOutline() const
Returns if this text node is an outline.
Definition: ndtxt.cxx:3994
SwDocShell * GetDocShell()
Definition: doc.hxx:1350
SwpHints * GetpSwpHints()
Definition: ndtxt.hxx:219
constexpr TypedWhichId< SwFormatMeta > RES_TXTATR_META(48)
SwNodeIndex nNode
Definition: pam.hxx:37
static sal_uInt16 HighestLevel(SwNodes &rNodes, const SwNodeRange &rRange)
Calculate the highest level in a range.
Definition: nodes.cxx:1402
void AddToList()
Definition: ndtxt.cxx:4263
static sal_uInt16 GetSectionLevel(const SwNodeIndex &rIndex)
get section level at the given position
Definition: nodes.cxx:1245
virtual sal_Int32 Len() const override
Definition: ndtxt.cxx:274
sal_uIntPtr sal_uLong
SwNode * DocumentSectionStartNode(SwNode *pNode) const
Definition: nodes.cxx:2290
sal_Int64 n
Definition: doc.hxx:186
static SwContentNode * GoPrevSection(SwNodeIndex *, bool bSkipHidden=true, bool bSkipProtect=true)
Definition: nodes.cxx:1952
SwNode * m_pEndOfInserts
These are the fixed ranges.
Definition: ndarr.hxx:106
void CutText(SwTextNode *const pDest, const SwIndex &rStart, const sal_Int32 nLen)
Definition: ndtxt.cxx:2397
SwSectionNode is derived from SwStartNode.
void DelDummyNodes(const SwNodeRange &rRg)
Definition: nodes.cxx:1857
constexpr TypedWhichId< SwFormatFlyCnt > RES_TXTATR_FLYCNT(57)
static SwContentNode * GoPrevious(SwNodeIndex *)
Definition: nodes.cxx:1294
SwNode & GetNode() const
Definition: ndindex.hxx:119
bool(* FnForEach_SwNodes)(const SwNodePtr &, void *pArgs)
Definition: ndarr.hxx:68
const OUString & GetName() const
Definition: numrule.hxx:222
SwNode * DocumentSectionEndNode(SwNode *pNode) const
Definition: nodes.cxx:2308
~SwNodes()
Destructor.
Definition: nodes.cxx:93
void RemoveRedlines()
Definition: ndtbl.cxx:2468
sal_uInt16 nElem
number of elements
Definition: bparr.hxx:61
SwTextNode * SplitContentNode(const SwPosition &, std::function< void(SwTextNode *, sw::mark::RestoreMode)> const *pContentIndexRestore)
Definition: ndtxt.cxx:411
IDocumentUndoRedo & GetIDocumentUndoRedo()
Definition: doc.cxx:143
sal_uInt16 Which() const
Definition: txatbase.hxx:110
void UpdateOutlineIdx(const SwNode &)
Update all OutlineNodes starting from Node.
Definition: ndnum.cxx:75
sal_uLong m_nSize
number of elements
Definition: bparr.hxx:69
IDocumentContentOperations const & getIDocumentContentOperations() const
Definition: doc.cxx:314
constexpr TypedWhichId< SwFormatField > RES_TXTATR_ANNOTATION(59)
sal_uInt16 Index2Block(sal_uLong) const
block search
Definition: bparr.cxx:91
SwTableFormat * GetFrameFormat()
Definition: swtable.hxx:201
void ChgNode(SwNodeIndex const &rDelPos, sal_uLong nSize, SwNodeIndex &rInsPos, bool bNewFrames)
Definition: nodes.cxx:114
const SwSection & GetSection() const
Definition: node.hxx:541
void Move(sal_uLong from, sal_uLong to)
Definition: bparr.cxx:70
void MakeFramesForAdjacentContentNode(SwContentNode &rNode)
Method creates all views of document for given node.
Definition: node.cxx:1299
IDocumentFieldsAccess const & getIDocumentFieldsAccess() const
Definition: doc.cxx:356
void Delete(const SwNodeIndex &rPos, sal_uLong nNodes=1)
delete nodes
Definition: nodes.cxx:1065
SwTableNode * GetTableNode()
Definition: node.hxx:599
SwNodeType GetNodeType() const
Definition: node.hxx:144
SwIndex nContent
Definition: pam.hxx:38
friend class SwStartNode
Definition: ndarr.hxx:93
SwNodeIndex aStart
Definition: ndindex.hxx:132
virtual void InsDelFieldInFieldLst(bool bIns, const SwTextField &rField)=0
void MakeOwnFrames(SwNodeIndex *pIdxBehind, SwNodeIndex *pEnd=nullptr)
Creates the frms for the SectionNode (i.e.
Definition: ndsect.cxx:1138
void Replace(sal_uLong pos, BigPtrEntry *p)
Definition: bparr.cxx:390
sal_uLong GetIndex() const
Definition: ndindex.hxx:152
virtual bool IsUndoNodes(SwNodes const &rNodes) const =0
bool IsStartNode() const
Definition: node.hxx:624
virtual bool SetFieldsDirty(bool b, const SwNode *pChk, sal_uLong nLen)=0
static void GoEndOfSection(SwNodeIndex *)
Definition: nodes.cxx:1271
bool CheckNodesRange(const SwNodeIndex &rStt, const SwNodeIndex &rEnd, bool bChkSection)
Check if the given range is inside one of the defined top-level sections.
Definition: pam.cxx:256
const SwTable & GetTable() const
Definition: node.hxx:497
void DelNodes(const SwNodeIndex &rStart, sal_uLong nCnt=1)
Delete a number of nodes.
Definition: nodes.cxx:1316
bool IsProtectFlag() const
Definition: section.hxx:189
const SwFormatField & GetFormatField() const
Definition: txatbase.hxx:191
constexpr TypedWhichId< SwFormatFootnote > RES_TXTATR_FTN(58)
void ChgTextNode(SwTextNode *const pNode)
Definition: txtatr2.cxx:305
std::unique_ptr< SwNode > m_pEndOfContent
Definition: ndarr.hxx:108
std::unique_ptr< SwOutlineNodes > m_pOutlineNodes
Array of all outline nodes.
Definition: ndarr.hxx:110
SwNode & GetEndOfContent() const
Regular ContentSection (i.e. the BodyText).
Definition: ndarr.hxx:163
SwStartNode * MakeTextSection(const SwNodeIndex &rWhere, SwStartNodeType eSttNdTyp, SwTextFormatColl *pColl)
Definition: nodes.cxx:1877
static bool lcl_HighestLevel(const SwNodePtr &rpNode, void *pPara)
Definition: nodes.cxx:1383
bool IsContentNode() const
Definition: node.hxx:628
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:136
void RemoveFromList()
Definition: ndtxt.cxx:4311
struct _xmlTextWriter * xmlTextWriterPtr
SwNumRule * FindNumRulePtr(const OUString &rName) const
Definition: docnum.cxx:2416
static SwNodePtr GetStartNode(SwOutlineNodes const *pOutlNds, int nOutlineLevel, SwOutlineNodes::size_type *nOutl)
Definition: docglbl.cxx:89
constexpr TypedWhichId< SwFormatField > RES_TXTATR_FIELD(RES_TXTATR_NOEND_BEGIN)
SwDoc * m_pMyDoc
This Doc contains the nodes-array.
Definition: ndarr.hxx:104
sal_uLong nStart
Definition: bparr.hxx:60
Style of a layout element.
Definition: frmfmt.hxx:57
std::unique_ptr< BlockInfo *[]> m_ppInf
block info
Definition: bparr.hxx:68
size_t Count() const
Definition: ndhints.hxx:142
void SectionDown(SwNodeRange *pRange, SwStartNodeType=SwNormalStartNode)
create a start/end section pair
Definition: nodes.cxx:892
void Broadcast(const SfxHint &rHint)
SwTextAttr * Get(size_t nPos) const
Definition: ndhints.hxx:144
int i
SwEndNode * GetEndNode()
Definition: node.hxx:583
const SwStartNode * StartOfSectionNode() const
Definition: node.hxx:131
void ForEach(FnForEach_SwNodes fnForEach, void *pArgs=nullptr)
Definition: ndarr.hxx:143
SwIndex & Assign(SwIndexReg *, sal_Int32)
Definition: index.cxx:206
void Insert(BigPtrEntry *p, sal_uLong pos)
Definition: bparr.cxx:201
bool IsHidden() const
Definition: section.hxx:179
static void GoStartOfSection(SwNodeIndex *)
Definition: nodes.cxx:1253
bool IsHiddenFlag() const
Definition: section.hxx:188
SwContentNode * GetContentNode()
Definition: node.hxx:615
bool HasMark() const
A PaM marks a selection if Point and Mark are distinct positions.
Definition: pam.hxx:205
std::array< BigPtrEntry *, MAXENTRY > mvData
data block
Definition: bparr.hxx:59
SwDoc * GetDoc()
Definition: node.hxx:702
Marks a character position inside a document model node.
Definition: index.hxx:37
SwNumRule * GetNumRule(bool bInParent=true) const
Returns numbering rule of this text node.
Definition: ndtxt.cxx:2805
std::vector< SwStartNode * > SwStartNodePointers
Definition: nodes.cxx:47
bool IsNoTextNode() const
Definition: node.hxx:648
void MakeOwnFrames(SwNodeIndex *pIdxBehind)
Creates the frms for the table node (i.e. the TabFrames).
Definition: ndtbl.cxx:2376
Marks a node in the document model.
Definition: ndindex.hxx:31
bool IsEndNode() const
Definition: node.hxx:632
SwNodes & GetNodes()
Node is in which nodes-array/doc?
Definition: node.hxx:693
T static_txtattr_cast(S *s)
Definition: txatbase.hxx:237
ring_container GetRingContainer()
Definition: ring.hxx:240
SwNodeIndex * m_vIndices
ring of all indices on nodes.
Definition: ndarr.hxx:96
SwStartNodeType GetStartNodeType() const
Definition: node.hxx:320
SwStartNode * GetStartNode()
Definition: node.hxx:591
void DecRefCnt()
Definition: ddefld.hxx:99
IDocumentLayoutAccess const & getIDocumentLayoutAccess() const
Definition: doc.cxx:404
const SwPosition * Start() const
Definition: pam.hxx:212
SwFieldType * GetTyp() const
Definition: fldbas.hxx:396
void DeleteAttribute(SwTextAttr *const pTextAttr)
delete the attribute pTextAttr
Definition: thints.cxx:1666
SwDoc * GetDoc()
Which Doc contains the nodes-array?
Definition: ndarr.hxx:302
bool CalcHiddenFlag() const
Definition: section.cxx:339
SwNodes(SwNodes const &)=delete
SvtBroadcaster & GetNotifier()
Definition: calbck.hxx:93
sal_uInt16 Which() const
for Querying of Writer-functions.
Definition: format.hxx:78
static void SectionUpDown(const SwNodeIndex &aStart, const SwNodeIndex &aEnd)
correct indices after movement
Definition: nodes.cxx:1017
bool IsFieldInDoc() const
Definition: atrfld.cxx:393
sal_uLong EndOfSectionIndex() const
Definition: node.hxx:677
void CopyCollFormat(SwTextNode &rDestNd)
Copy collection with all auto formats to dest-node.
Definition: ndcopy.cxx:334
BigPtrEntry * operator[](sal_uLong) const
Definition: bparr.cxx:82
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:80
SwNode * m_pEndOfPostIts
Definition: ndarr.hxx:106
void dumpAsXml(xmlTextWriterPtr pWriter) const
Dumps the entire nodes structure to the given destination (file nodes.xml in the current directory by...
Definition: nodes.cxx:2318
bool m_bInNodesDel
In Case of recursive calling.
Definition: ndarr.hxx:112
void SetInvalidRule(bool bFlag)
Definition: number.cxx:900
An SwTextAttr container, stores all directly formatted text portions for a text node.
Definition: ndhints.hxx:67
void ChkCondColl()
Definition: node.cxx:1960
virtual const SwViewShell * GetCurrentViewShell() const =0
Returns the layout set at the document.
const SwNodes & GetNodes() const
Definition: ndindex.hxx:156
void SectionUp(SwNodeRange *)
increase level of the given range
Definition: nodes.cxx:946
sal_uLong GetPos() const
Definition: bparr.hxx:97
SwEndNode * m_pEndOfSection
Definition: node.hxx:309
sal_Int32 GetIndex() const
Definition: index.hxx:95
SwNodes & GetNodes()
Definition: doc.hxx:405
const SwPosition * End() const
Definition: pam.hxx:217
SwNodeIndex aEnd
Definition: ndindex.hxx:133
void InsertNode(const SwNodePtr pNode, const SwNodeIndex &rPos)
Definition: nodes.cxx:2275
void DelFrames(SwRootFrame const *pLayout=nullptr)
Method deletes all views of document for the node.
Definition: ndsect.cxx:1158
SwTableNode is derived from SwStartNode.
void * p
sal_uInt16 MakeNumRule(const OUString &rName, const SwNumRule *pCpy=nullptr, bool bBroadcast=false, const SvxNumberFormat::SvxNumPositionAndSpaceMode eDefaultNumberFormatPositionAndSpaceMode=SvxNumberFormat::LABEL_WIDTH_AND_POSITION)
Definition: docnum.cxx:2450
constexpr TypedWhichId< SwConditionTextFormatColl > RES_CONDTXTFMTCOLL(158)
constexpr TypedWhichId< SwTOXMark > RES_TXTATR_TOXMARK(47)
SwNode * m_pEndOfAutotext
Definition: ndarr.hxx:106
constexpr TypedWhichId< SwFormatField > RES_TXTATR_INPUTFIELD(55)
SwStartNodeType
Definition: ndtyp.hxx:50
const SwStartNode * FindTableBoxStartNode() const
Definition: node.hxx:196
bool InvalidateNumRule()
Invalidates NumRule at the node.
Definition: node.cxx:1133
SwTableNode * FindTableNode()
Search table node, in which it is.
Definition: node.cxx:350
void Remove(sal_uLong pos, sal_uLong n=1)
Definition: bparr.cxx:306
virtual bool SplitNode(const SwPosition &rPos, bool bChkTableStart)=0
Split a node at rPos (implemented only for TextNode).
const SfxPoolItem & GetAttr() const
Definition: txatbase.hxx:159
static SwNodePtr GetEndNode(SwOutlineNodes const *pOutlNds, int nOutlineLevel, SwOutlineNodes::size_type *nOutl)
Definition: docglbl.cxx:103
SwContentNode * GoNextSection(SwNodeIndex *, bool bSkipHidden=true, bool bSkipProtect=true) const
Go to next content-node that is not protected or hidden (Both set FALSE ==> GoNext/GoPrevious!!!).
Definition: nodes.cxx:1900
bool IsDocNodes() const
Is the NodesArray the regular one of Doc? (and not the UndoNds, ...) Implementation in doc...
Definition: nodes.cxx:2313
bool IsTableNode() const
Definition: node.hxx:640
SwSectionNode * GetSectionNode()
Definition: node.hxx:607
void CopyNodes(const SwNodeRange &, const SwNodeIndex &, bool bNewFrames, bool bTableInsDummyNode=false) const
Definition: nodes.cxx:1644
Ends a section of nodes in the document model.
Definition: node.hxx:333
constexpr TypedWhichId< SwFormatRefMark > RES_TXTATR_REFMARK(RES_TXTATR_WITHEND_BEGIN)
sal_uInt16 GetSectionLevel() const
Returns the section level at the position given by aIndex.
Definition: node.cxx:267
SwNode & GetEndOfRedlines() const
Section for all Redlines.
Definition: ndarr.hxx:158
bool m_bInDelUpdOutline
Flag for updating of Outline.
Definition: ndarr.hxx:114
std::vector< SwNode * >::size_type size_type
This class is internal, used only during DocumentContentOperationsManager::CopyWithFlyInFly(), and for undo.
Definition: node.hxx:576
bool IsTextNode() const
Definition: node.hxx:636
SwFieldIds Which() const
Definition: fldbas.hxx:272
SwNode * FindPrvNxtFrameNode(SwNodeIndex &rFrameIdx, const SwNode *pEnd) const
Search previous / next content node or table node with frames.
Definition: nodes.cxx:2019
SwContentNode * GoNext(SwNodeIndex *) const
Definition: nodes.cxx:1277
void IncRefCnt()
Definition: ddefld.hxx:98
sal_uInt16 nPos
void RemoveNode(sal_uLong nDelPos, sal_uLong nLen, bool bDel)
Definition: nodes.cxx:2179
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
Definition: ndtxt.hxx:836
friend class SwNodeIndex
Definition: ndarr.hxx:92
SwTextNode * MakeTextNode(const SwNodeIndex &rWhere, SwTextFormatColl *pColl, bool bNewFrames=true)
Implementations of "Make...Node" are in the given .cxx-files.
Definition: ndtxt.cxx:104
bool MoveNodes(const SwNodeRange &, SwNodes &rNodes, const SwNodeIndex &, bool bNewFrames=true)
move the node pointer
Definition: nodes.cxx:394
SwNode * m_pEndOfRedlines
Definition: ndarr.hxx:106
static SwStartNode * MakeEmptySection(const SwNodeIndex &rIdx, SwStartNodeType=SwNormalStartNode)
Create an empty section of Start- and EndNote.
Definition: nodes.cxx:1869
Base class of the Writer document model elements.
Definition: node.hxx:79
SwTextFormatColl * GetTextColl() const
Definition: ndtxt.hxx:830
void MoveRange(SwPaM &, SwPosition &, SwNodes &rNodes)
move a range
Definition: nodes.cxx:1416