LibreOffice Module sw (master)  1
doctxm.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 <limits.h>
21 #include <hintids.hxx>
23 #include <comphelper/classids.hxx>
24 #include <docsh.hxx>
25 #include <ndole.hxx>
26 #include <txttxmrk.hxx>
27 #include <fmtpdsc.hxx>
28 #include <frmatr.hxx>
29 #include <pagedesc.hxx>
30 #include <doc.hxx>
31 #include <IDocumentUndoRedo.hxx>
35 #include <IDocumentState.hxx>
38 #include <pagefrm.hxx>
39 #include <ndtxt.hxx>
40 #include <swtable.hxx>
41 #include <doctxm.hxx>
42 #include <txmsrt.hxx>
43 #include <rolbck.hxx>
44 #include <poolfmt.hxx>
45 #include <txtfrm.hxx>
46 #include <rootfrm.hxx>
47 #include <UndoAttribute.hxx>
48 #include <UndoSection.hxx>
49 #include <swundo.hxx>
50 #include <mdiexp.hxx>
51 #include <docary.hxx>
52 #include <charfmt.hxx>
53 #include <fchrfmt.hxx>
54 #include <fldbas.hxx>
55 #include <fmtfld.hxx>
56 #include <txtfld.hxx>
57 #include <expfld.hxx>
58 #include <mvsave.hxx>
59 #include <node2lay.hxx>
60 #include <SwStyleNameMapper.hxx>
61 #include <breakit.hxx>
62 #include <scriptinfo.hxx>
63 #include <calbck.hxx>
64 #include <ToxTextGenerator.hxx>
66 #include <tools/datetimeutils.hxx>
67 #include <tools/globname.hxx>
68 #include <com/sun/star/embed/XEmbeddedObject.hpp>
69 
70 #include <memory>
71 
72 using namespace ::com::sun::star;
73 
74 template<typename T, typename... Args> static
75 typename std::enable_if<!std::is_array<T>::value, std::unique_ptr<T>>::type
76 MakeSwTOXSortTabBase(SwRootFrame const*const pLayout, Args&& ... args)
77 {
78  std::unique_ptr<T> pRet(new T(std::forward<Args>(args)...));
79  pRet->InitText(pLayout); // ensure it's expanded with the layout
80  return pRet;
81 }
82 
83 void SwDoc::GetTOIKeys(SwTOIKeyType eTyp, std::vector<OUString>& rArr,
84  SwRootFrame const& rLayout) const
85 {
86  rArr.clear();
87 
88  // Look up all Primary and Secondary via the Pool
89  for (const SfxPoolItem* pPoolItem : GetAttrPool().GetItemSurrogates(RES_TXTATR_TOXMARK))
90  {
91  const SwTOXMark* pItem = dynamic_cast<const SwTOXMark*>(pPoolItem);
92  if( !pItem )
93  continue;
94  const SwTOXType* pTOXType = pItem->GetTOXType();
95  if ( !pTOXType || pTOXType->GetType()!=TOX_INDEX )
96  continue;
97  const SwTextTOXMark* pMark = pItem->GetTextTOXMark();
98  if ( pMark && pMark->GetpTextNd() &&
99  pMark->GetpTextNd()->GetNodes().IsDocNodes() &&
100  (!rLayout.IsHideRedlines()
101  || !sw::IsMarkHintHidden(rLayout, *pMark->GetpTextNd(), *pMark)))
102  {
103  const OUString sStr = TOI_PRIMARY == eTyp
104  ? pItem->GetPrimaryKey()
105  : pItem->GetSecondaryKey();
106 
107  if( !sStr.isEmpty() )
108  rArr.push_back( sStr );
109  }
110  }
111 }
112 
114 sal_uInt16 SwDoc::GetCurTOXMark( const SwPosition& rPos,
115  SwTOXMarks& rArr )
116 {
117  // search on Position rPos for all SwTOXMarks
118  SwTextNode *const pTextNd = rPos.nNode.GetNode().GetTextNode();
119  if( !pTextNd || !pTextNd->GetpSwpHints() )
120  return 0;
121 
122  const SwpHints & rHts = *pTextNd->GetpSwpHints();
123  sal_Int32 nSttIdx;
124  const sal_Int32 *pEndIdx;
125 
126  const sal_Int32 nCurrentPos = rPos.nContent.GetIndex();
127 
128  for( size_t n = 0; n < rHts.Count(); ++n )
129  {
130  const SwTextAttr* pHt = rHts.Get(n);
131  if( RES_TXTATR_TOXMARK != pHt->Which() )
132  continue;
133  if( ( nSttIdx = pHt->GetStart() ) < nCurrentPos )
134  {
135  // also check the end
136  if( nullptr == ( pEndIdx = pHt->End() ) ||
137  *pEndIdx <= nCurrentPos )
138  continue; // keep searching
139  }
140  else if( nSttIdx > nCurrentPos )
141  // If Hint's Start is greater than rPos, break, because
142  // the attributes are sorted by Start!
143  break;
144 
145  SwTOXMark* pTMark = const_cast<SwTOXMark*>(&pHt->GetTOXMark());
146  rArr.push_back( pTMark );
147  }
148  return rArr.size();
149 }
150 
152 void SwDoc::DeleteTOXMark( const SwTOXMark* pTOXMark )
153 {
154  const SwTextTOXMark* pTextTOXMark = pTOXMark->GetTextTOXMark();
155  assert(pTextTOXMark);
156 
157  SwTextNode& rTextNd = const_cast<SwTextNode&>(pTextTOXMark->GetTextNode());
158  assert(rTextNd.GetpSwpHints());
159 
160  if (pTextTOXMark->HasDummyChar())
161  {
162  // tdf#106377 don't use SwUndoResetAttr, it uses NOTXTATRCHR
163  SwPaM tmp(rTextNd, pTextTOXMark->GetStart(),
164  rTextNd, pTextTOXMark->GetStart()+1);
165  assert(rTextNd.GetText()[pTextTOXMark->GetStart()] == CH_TXTATR_INWORD);
167  }
168  else
169  {
170  std::unique_ptr<SwRegHistory> aRHst;
171  if (GetIDocumentUndoRedo().DoesUndo())
172  {
173  // save attributes for Undo
174  SwUndoResetAttr* pUndo = new SwUndoResetAttr(
175  SwPosition( rTextNd, SwIndex( &rTextNd, pTextTOXMark->GetStart() ) ),
177  GetIDocumentUndoRedo().AppendUndo( std::unique_ptr<SwUndo>(pUndo) );
178 
179  aRHst.reset(new SwRegHistory(rTextNd, &pUndo->GetHistory()));
180  rTextNd.GetpSwpHints()->Register(aRHst.get());
181  }
182 
183  rTextNd.DeleteAttribute( const_cast<SwTextTOXMark*>(pTextTOXMark) );
184 
185  if (GetIDocumentUndoRedo().DoesUndo())
186  {
187  if( rTextNd.GetpSwpHints() )
188  rTextNd.GetpSwpHints()->DeRegister();
189  }
190  }
191 
193 }
194 
197 {
199  sal_Int32 nContent;
200 public:
201  CompareNodeContent( sal_uLong nNd, sal_Int32 nCnt )
202  : nNode( nNd ), nContent( nCnt ) {}
203 
204  bool operator==( const CompareNodeContent& rCmp ) const
205  { return nNode == rCmp.nNode && nContent == rCmp.nContent; }
206  bool operator!=( const CompareNodeContent& rCmp ) const
207  { return nNode != rCmp.nNode || nContent != rCmp.nContent; }
208  bool operator< ( const CompareNodeContent& rCmp ) const
209  { return nNode < rCmp.nNode ||
210  ( nNode == rCmp.nNode && nContent < rCmp.nContent); }
211  bool operator<=( const CompareNodeContent& rCmp ) const
212  { return nNode < rCmp.nNode ||
213  ( nNode == rCmp.nNode && nContent <= rCmp.nContent); }
214  bool operator> ( const CompareNodeContent& rCmp ) const
215  { return nNode > rCmp.nNode ||
216  ( nNode == rCmp.nNode && nContent > rCmp.nContent); }
217  bool operator>=( const CompareNodeContent& rCmp ) const
218  { return nNode > rCmp.nNode ||
219  ( nNode == rCmp.nNode && nContent >= rCmp.nContent); }
220 };
221 
222 const SwTOXMark& SwDoc::GotoTOXMark( const SwTOXMark& rCurTOXMark,
223  SwTOXSearch eDir, bool bInReadOnly )
224 {
225  const SwTextTOXMark* pMark = rCurTOXMark.GetTextTOXMark();
226  OSL_ENSURE(pMark, "pMark==0 invalid TextTOXMark");
227 
228  const SwTextNode *pTOXSrc = pMark->GetpTextNd();
229 
230  CompareNodeContent aAbsIdx( pTOXSrc->GetIndex(), pMark->GetStart() );
231  CompareNodeContent aPrevPos( 0, 0 );
232  CompareNodeContent aNextPos( ULONG_MAX, SAL_MAX_INT32 );
233  CompareNodeContent aMax( 0, 0 );
234  CompareNodeContent aMin( ULONG_MAX, SAL_MAX_INT32 );
235 
236  const SwTOXMark* pNew = nullptr;
237  const SwTOXMark* pMax = &rCurTOXMark;
238  const SwTOXMark* pMin = &rCurTOXMark;
239 
240  const SwTOXType* pType = rCurTOXMark.GetTOXType();
241  SwTOXMarks aMarks;
242  SwTOXMark::InsertTOXMarks( aMarks, *pType );
243 
244  for(SwTOXMark* pTOXMark : aMarks)
245  {
246  if ( pTOXMark == &rCurTOXMark )
247  continue;
248 
249  pMark = pTOXMark->GetTextTOXMark();
250  if (!pMark)
251  continue;
252 
253  pTOXSrc = pMark->GetpTextNd();
254  if (!pTOXSrc)
255  continue;
256 
257  Point aPt;
258  std::pair<Point, bool> const tmp(aPt, false);
259  const SwContentFrame* pCFrame = pTOXSrc->getLayoutFrame(
260  getIDocumentLayoutAccess().GetCurrentLayout(), nullptr, &tmp);
261  if (!pCFrame)
262  continue;
263 
264  if ( bInReadOnly || !pCFrame->IsProtected() )
265  {
266  CompareNodeContent aAbsNew( pTOXSrc->GetIndex(), pMark->GetStart() );
267  switch( eDir )
268  {
269  // The following (a bit more complicated) statements make it
270  // possible to also travel across Entries on the same (!)
271  // position. If someone has time, please feel free to optimize.
272  case TOX_SAME_PRV:
273  if (pTOXMark->GetText(nullptr) != rCurTOXMark.GetText(nullptr))
274  break;
275  [[fallthrough]];
276  case TOX_PRV:
277  if ( (aAbsNew < aAbsIdx && aAbsNew > aPrevPos) ||
278  (aAbsIdx == aAbsNew &&
279  (sal_uLong(&rCurTOXMark) > sal_uLong(pTOXMark) &&
280  (!pNew || aPrevPos < aAbsIdx || sal_uLong(pNew) < sal_uLong(pTOXMark) ) )) ||
281  (aPrevPos == aAbsNew && aAbsIdx != aAbsNew &&
282  sal_uLong(pTOXMark) > sal_uLong(pNew)) )
283  {
284  pNew = pTOXMark;
285  aPrevPos = aAbsNew;
286  if ( aAbsNew >= aMax )
287  {
288  aMax = aAbsNew;
289  pMax = pTOXMark;
290  }
291  }
292  break;
293 
294  case TOX_SAME_NXT:
295  if (pTOXMark->GetText(nullptr) != rCurTOXMark.GetText(nullptr))
296  break;
297  [[fallthrough]];
298  case TOX_NXT:
299  if ( (aAbsNew > aAbsIdx && aAbsNew < aNextPos) ||
300  (aAbsIdx == aAbsNew &&
301  (sal_uLong(&rCurTOXMark) < sal_uLong(pTOXMark) &&
302  (!pNew || aNextPos > aAbsIdx || sal_uLong(pNew) > sal_uLong(pTOXMark)) )) ||
303  (aNextPos == aAbsNew && aAbsIdx != aAbsNew &&
304  sal_uLong(pTOXMark) < sal_uLong(pNew)) )
305  {
306  pNew = pTOXMark;
307  aNextPos = aAbsNew;
308  if ( aAbsNew <= aMin )
309  {
310  aMin = aAbsNew;
311  pMin = pTOXMark;
312  }
313  }
314  break;
315  }
316  }
317  }
318 
319  // We couldn't find a successor
320  // Use minimum or maximum
321  if(!pNew)
322  {
323  switch(eDir)
324  {
325  case TOX_PRV:
326  case TOX_SAME_PRV:
327  pNew = pMax;
328  break;
329  case TOX_NXT:
330  case TOX_SAME_NXT:
331  pNew = pMin;
332  break;
333  default:
334  pNew = &rCurTOXMark;
335  }
336  }
337  return *pNew;
338 }
339 
341  const SwTOXBase& rTOX,
342  const SfxItemSet* pSet,
343  bool bExpand,
344  SwRootFrame const*const pLayout)
345 {
346  SwPaM aPam( rPos );
347  return InsertTableOf( aPam, rTOX, pSet, bExpand, pLayout );
348 }
349 
351  const SwTOXBase& rTOX,
352  const SfxItemSet* pSet,
353  bool bExpand,
354  SwRootFrame const*const pLayout )
355 {
356  assert(!bExpand || pLayout != nullptr);
358 
359  OUString sSectNm = GetUniqueTOXBaseName( *rTOX.GetTOXType(), rTOX.GetTOXName() );
360  SwSectionData aSectionData( TOX_CONTENT_SECTION, sSectNm );
361 
362  std::pair<SwTOXBase const*, sw::RedlineMode> const tmp(&rTOX,
363  pLayout && pLayout->IsHideRedlines()
366  SwTOXBaseSection *const pNewSection = dynamic_cast<SwTOXBaseSection *>(
367  InsertSwSection(aPam, aSectionData, & tmp, pSet, false));
368  if (pNewSection)
369  {
370  SwSectionNode *const pSectNd = pNewSection->GetFormat()->GetSectionNode();
371  pNewSection->SetTOXName(sSectNm); // rTOX may have had no name...
372 
373  if( bExpand )
374  {
375  // add value for 2nd parameter = true to
376  // indicate, that a creation of a new table of content has to be performed.
377  // Value of 1st parameter = default value.
378  pNewSection->Update( nullptr, pLayout, true );
379  }
380  else if( rTOX.GetTitle().getLength()==1 && IsInReading() )
381  // insert title of TOX
382  {
383  // then insert the headline section
384  SwNodeIndex aIdx( *pSectNd, +1 );
385 
386  SwTextNode* pHeadNd = GetNodes().MakeTextNode( aIdx,
387  getIDocumentStylePoolAccess().GetTextCollFromPool( RES_POOLCOLL_STANDARD ) );
388 
389  SwSectionData headerData( TOX_HEADER_SECTION, pNewSection->GetTOXName()+"_Head" );
390 
391  SwNodeIndex aStt( *pHeadNd ); --aIdx;
392  SwSectionFormat* pSectFormat = MakeSectionFormat();
394  aStt, *pSectFormat, headerData, nullptr, &aIdx, true, false);
395  }
396  }
397 
399 
400  return pNewSection;
401 }
402 
404  const SwTOXBase& rTOX,
405  const SfxItemSet* pSet )
406 {
407  // check for recursive TOX
408  SwNode* pNd = GetNodes()[ nSttNd ];
409  SwSectionNode* pSectNd = pNd->FindSectionNode();
410  while( pSectNd )
411  {
412  SectionType eT = pSectNd->GetSection().GetType();
413  if( TOX_HEADER_SECTION == eT || TOX_CONTENT_SECTION == eT )
414  return;
415  pSectNd = pSectNd->StartOfSectionNode()->FindSectionNode();
416  }
417 
418  const OUString sSectNm = GetUniqueTOXBaseName(*rTOX.GetTOXType(), rTOX.GetTOXName());
419 
420  SwSectionData aSectionData( TOX_CONTENT_SECTION, sSectNm );
421 
422  SwNodeIndex aStt( GetNodes(), nSttNd ), aEnd( GetNodes(), nEndNd );
423  SwSectionFormat* pFormat = MakeSectionFormat();
424  if(pSet)
425  pFormat->SetFormatAttr(*pSet);
426 
427  SwSectionNode *const pNewSectionNode =
428  GetNodes().InsertTextSection(aStt, *pFormat, aSectionData, &rTOX, &aEnd);
429  if (!pNewSectionNode)
430  {
431  DelSectionFormat( pFormat );
432  return;
433  }
434 
435  SwTOXBaseSection *const pNewSection(
436  dynamic_cast<SwTOXBaseSection*>(& pNewSectionNode->GetSection()));
437  if (pNewSection)
438  pNewSection->SetTOXName(sSectNm); // rTOX may have had no name...
439 }
440 
443 {
444  SwNode& rNd = rPos.nNode.GetNode();
445  SwSectionNode* pSectNd = rNd.FindSectionNode();
446  while( pSectNd )
447  {
448  SectionType eT = pSectNd->GetSection().GetType();
449  if( TOX_CONTENT_SECTION == eT )
450  {
451  OSL_ENSURE( dynamic_cast< const SwTOXBaseSection *>( &pSectNd->GetSection()) != nullptr,
452  "no TOXBaseSection!" );
453  SwTOXBaseSection& rTOXSect = static_cast<SwTOXBaseSection&>(
454  pSectNd->GetSection());
455  return &rTOXSect;
456  }
457  pSectNd = pSectNd->StartOfSectionNode()->FindSectionNode();
458  }
459  return nullptr;
460 }
461 
463 {
464  OSL_ENSURE( dynamic_cast<const SwTOXBaseSection*>( &rTOXBase) != nullptr, "no TOXBaseSection!" );
465  const SwTOXBaseSection& rTOXSect = static_cast<const SwTOXBaseSection&>(rTOXBase);
466  SwSectionFormat const * pFormat = rTOXSect.GetFormat();
467  OSL_ENSURE( pFormat, "invalid TOXBaseSection!" );
468  return pFormat->GetAttrSet();
469 }
470 
471 const SwTOXBase* SwDoc::GetDefaultTOXBase( TOXTypes eTyp, bool bCreate )
472 {
473  std::unique_ptr<SwTOXBase>* prBase = nullptr;
474  switch(eTyp)
475  {
476  case TOX_CONTENT: prBase = &mpDefTOXBases->pContBase; break;
477  case TOX_INDEX: prBase = &mpDefTOXBases->pIdxBase; break;
478  case TOX_USER: prBase = &mpDefTOXBases->pUserBase; break;
479  case TOX_TABLES: prBase = &mpDefTOXBases->pTableBase; break;
480  case TOX_OBJECTS: prBase = &mpDefTOXBases->pObjBase; break;
481  case TOX_ILLUSTRATIONS: prBase = &mpDefTOXBases->pIllBase; break;
482  case TOX_AUTHORITIES: prBase = &mpDefTOXBases->pAuthBase; break;
483  case TOX_BIBLIOGRAPHY: prBase = &mpDefTOXBases->pBiblioBase; break;
484  case TOX_CITATION: break;
485  }
486  if (!prBase)
487  return nullptr;
488  if(!(*prBase) && bCreate)
489  {
490  SwForm aForm(eTyp);
491  const SwTOXType* pType = GetTOXType(eTyp, 0);
492  prBase->reset(new SwTOXBase(pType, aForm, SwTOXElement::NONE, pType->GetTypeName()));
493  }
494  return prBase->get();
495 }
496 
498 {
499  std::unique_ptr<SwTOXBase>* prBase = nullptr;
500  switch(rBase.GetType())
501  {
502  case TOX_CONTENT: prBase = &mpDefTOXBases->pContBase; break;
503  case TOX_INDEX: prBase = &mpDefTOXBases->pIdxBase; break;
504  case TOX_USER: prBase = &mpDefTOXBases->pUserBase; break;
505  case TOX_TABLES: prBase = &mpDefTOXBases->pTableBase; break;
506  case TOX_OBJECTS: prBase = &mpDefTOXBases->pObjBase; break;
507  case TOX_ILLUSTRATIONS: prBase = &mpDefTOXBases->pIllBase; break;
508  case TOX_AUTHORITIES: prBase = &mpDefTOXBases->pAuthBase; break;
509  case TOX_BIBLIOGRAPHY: prBase = &mpDefTOXBases->pBiblioBase; break;
510  case TOX_CITATION: break;
511  }
512  if (!prBase)
513  return;
514  prBase->reset(new SwTOXBase(rBase));
515 }
516 
518 bool SwDoc::DeleteTOX( const SwTOXBase& rTOXBase, bool bDelNodes )
519 {
520  // We only delete the TOX, not the Nodes
521  bool bRet = false;
522  OSL_ENSURE( dynamic_cast<const SwTOXBaseSection*>( &rTOXBase) != nullptr, "no TOXBaseSection!" );
523 
524  const SwTOXBaseSection& rTOXSect = static_cast<const SwTOXBaseSection&>(rTOXBase);
525  SwSectionFormat const * pFormat = rTOXSect.GetFormat();
526  /* Save the start node of the TOX' section. */
527  SwSectionNode const * pMyNode = pFormat ? pFormat->GetSectionNode() : nullptr;
528  if (pMyNode)
529  {
531 
532  /* Save start node of section's surrounding. */
533  SwNode const * pStartNd = pMyNode->StartOfSectionNode();
534 
535  /* Look for the point where to move the cursors in the area to
536  delete to. This is done by first searching forward from the
537  end of the TOX' section. If no content node is found behind
538  the TOX one is searched before it. If this is not
539  successful, too, insert new text node behind the end of
540  the TOX' section. The cursors from the TOX' section will be
541  moved to the content node found or the new text node. */
542 
543  /* Set PaM to end of TOX' section and search following content node.
544  aSearchPam will contain the point where to move the cursors
545  to. */
546  SwPaM aSearchPam(*pMyNode->EndOfSectionNode());
547  SwPosition aEndPos(*pStartNd->EndOfSectionNode());
548  if (! aSearchPam.Move() /* no content node found */
549  || *aSearchPam.GetPoint() >= aEndPos /* content node found
550  outside surrounding */
551  )
552  {
553  /* Set PaM to beginning of TOX' section and search previous
554  content node */
555  SwPaM aTmpPam(*pMyNode);
556  aSearchPam = aTmpPam;
557  SwPosition aStartPos(*pStartNd);
558 
559  if ( ! aSearchPam.Move(fnMoveBackward) /* no content node found */
560  || *aSearchPam.GetPoint() <= aStartPos /* content node
561  found outside
562  surrounding */
563  )
564  {
565  /* There is no content node in the surrounding of
566  TOX'. Append text node behind TOX' section. */
567 
568  SwPosition aInsPos(*pMyNode->EndOfSectionNode());
570 
571  SwPaM aTmpPam1(aInsPos);
572  aSearchPam = aTmpPam1;
573  }
574  }
575 
576  /* PaM containing the TOX. */
577  SwPaM aPam(*pMyNode->EndOfSectionNode(), *pMyNode);
578 
579  /* Move cursors contained in TOX to the above calculated point. */
580  PaMCorrAbs(aPam, *aSearchPam.GetPoint());
581 
582  if( !bDelNodes )
583  {
584  SwSections aArr( 0 );
585  pFormat->GetChildSections( aArr, SectionSort::Not, false );
586  for( const auto pSect : aArr )
587  {
588  if( TOX_HEADER_SECTION == pSect->GetType() )
589  {
590  DelSectionFormat( pSect->GetFormat(), bDelNodes );
591  }
592  }
593  }
594 
595  DelSectionFormat( const_cast<SwSectionFormat *>(pFormat), bDelNodes );
596 
598  bRet = true;
599  }
600 
601  return bRet;
602 }
603 
605 sal_uInt16 SwDoc::GetTOXTypeCount(TOXTypes eTyp) const
606 {
607  sal_uInt16 nCnt = 0;
608  for( auto const & pTOXType : *mpTOXTypes )
609  if( eTyp == pTOXType->GetType() )
610  ++nCnt;
611  return nCnt;
612 }
613 
614 const SwTOXType* SwDoc::GetTOXType( TOXTypes eTyp, sal_uInt16 nId ) const
615 {
616  sal_uInt16 nCnt = 0;
617  for( auto const & pTOXType : *mpTOXTypes )
618  if( eTyp == pTOXType->GetType() && nCnt++ == nId )
619  return pTOXType.get();
620  return nullptr;
621 }
622 
624 {
625  SwTOXType * pNew = new SwTOXType( rTyp );
626  mpTOXTypes->emplace_back( pNew );
627  return pNew;
628 }
629 
630 OUString SwDoc::GetUniqueTOXBaseName( const SwTOXType& rType,
631  const OUString& sChkStr ) const
632 {
633  if( IsInMailMerge())
634  {
635  OUString newName = "MailMergeTOX"
636  + OStringToOUString( DateTimeToOString( DateTime( DateTime::SYSTEM )), RTL_TEXTENCODING_ASCII_US )
637  + OUString::number( mpSectionFormatTable->size() + 1 );
638  if( !sChkStr.isEmpty())
639  newName += sChkStr;
640  return newName;
641  }
642 
643  bool bUseChkStr = !sChkStr.isEmpty();
644  const OUString& aName( rType.GetTypeName() );
645  const sal_Int32 nNmLen = aName.getLength();
646 
648  const SwSectionFormats::size_type nFlagSize = ( mpSectionFormatTable->size() / 8 ) +2;
649  std::unique_ptr<sal_uInt8[]> pSetFlags(new sal_uInt8[ nFlagSize ]);
650  memset( pSetFlags.get(), 0, nFlagSize );
651 
652  for( auto pSectionFormat : *mpSectionFormatTable )
653  {
654  const SwSectionNode *pSectNd = pSectionFormat->GetSectionNode();
655  if ( !pSectNd )
656  continue;
657 
658  const SwSection& rSect = pSectNd->GetSection();
659  if (rSect.GetType()==TOX_CONTENT_SECTION)
660  {
661  const OUString& rNm = rSect.GetSectionName();
662  if ( rNm.startsWith(aName) )
663  {
664  // Calculate number and set the Flag
665  nNum = rNm.copy( nNmLen ).toInt32();
666  if( nNum-- && nNum < mpSectionFormatTable->size() )
667  pSetFlags[ nNum / 8 ] |= (0x01 << ( nNum & 0x07 ));
668  }
669  if ( bUseChkStr && sChkStr==rNm )
670  bUseChkStr = false;
671  }
672  }
673 
674  if( !bUseChkStr )
675  {
676  // All Numbers have been flagged accordingly, so get the right Number
677  nNum = mpSectionFormatTable->size();
678  for( SwSectionFormats::size_type n = 0; n < nFlagSize; ++n )
679  {
680  sal_uInt8 nTmp = pSetFlags[ n ];
681  if( nTmp != 0xff )
682  {
683  // so get the Number
684  nNum = n * 8;
685  while( nTmp & 1 )
686  {
687  ++nNum;
688  nTmp >>= 1;
689  }
690  break;
691  }
692  }
693  }
694  if ( bUseChkStr )
695  return sChkStr;
696  return aName + OUString::number( ++nNum );
697 }
698 
699 bool SwDoc::SetTOXBaseName(const SwTOXBase& rTOXBase, const OUString& rName)
700 {
701  OSL_ENSURE( dynamic_cast<const SwTOXBaseSection*>( &rTOXBase) != nullptr,
702  "no TOXBaseSection!" );
703  SwTOXBaseSection* pTOX = const_cast<SwTOXBaseSection*>(static_cast<const SwTOXBaseSection*>(&rTOXBase));
704 
705  if (GetUniqueTOXBaseName(*rTOXBase.GetTOXType(), rName) == rName)
706  {
707  pTOX->SetTOXName(rName);
708  pTOX->SetSectionName(rName);
710  return true;
711  }
712  return false;
713 }
714 
715 static const SwTextNode* lcl_FindChapterNode( const SwNode& rNd,
716  SwRootFrame const*const pLayout, sal_uInt8 const nLvl = 0 )
717 {
718  const SwNode* pNd = &rNd;
719  if( pNd->GetNodes().GetEndOfExtras().GetIndex() > pNd->GetIndex() )
720  {
721  // then find the "Anchor" (Body) position
722  Point aPt;
723  SwNode2Layout aNode2Layout( *pNd, pNd->GetIndex() );
724  const SwFrame* pFrame = aNode2Layout.GetFrame( &aPt );
725 
726  if( pFrame )
727  {
728  SwPosition aPos( *pNd );
729  pNd = GetBodyTextNode( *pNd->GetDoc(), aPos, *pFrame );
730  OSL_ENSURE( pNd, "Where's the paragraph?" );
731  }
732  }
733  return pNd ? pNd->FindOutlineNodeOfLevel(nLvl, pLayout) : nullptr;
734 }
735 
736 // Table of contents class
738  : SwTOXBase( rBase )
739  , SwSection( TOX_CONTENT_SECTION, OUString(), rFormat )
740 {
741  SetProtect( rBase.IsProtected() );
743 }
744 
746 {
747 }
748 
750 {
751  bool bRet = false;
752  const SwSectionNode* pSectNd = GetFormat()->GetSectionNode();
753  if( pSectNd )
754  {
755  rPos.nNode = *pSectNd;
756  SwContentNode* pCNd = pSectNd->GetDoc()->GetNodes().GoNext( &rPos.nNode );
757  rPos.nContent.Assign( pCNd, 0 );
758  bRet = true;
759  }
760  return bRet;
761 }
762 
765  SwRootFrame const*const pLayout,
766  const bool _bNewTOX)
767 {
768  if (!SwTOXBase::GetRegisteredIn()->HasWriterListeners() ||
769  !GetFormat())
770  {
771  return;
772  }
773  SwSectionNode const*const pSectNd(GetFormat()->GetSectionNode());
774  if (nullptr == pSectNd ||
775  !pSectNd->GetNodes().IsDocNodes() ||
776  IsHiddenFlag() ||
777  (pLayout->IsHideRedlines() && pSectNd->GetRedlineMergeFlag() == SwNode::Merge::Hidden))
778  {
779  return;
780  }
781 
782  if ( !mbKeepExpression )
783  {
784  maMSTOCExpression.clear();
785  }
786 
787  SwDoc* pDoc = const_cast<SwDoc*>(pSectNd->GetDoc());
788 
789  assert(pDoc); //Where is the document?
790 
791  if (pAttr && GetFormat())
792  pDoc->ChgFormat(*GetFormat(), *pAttr);
793 
794  // determine default page description, which will be used by the content nodes,
795  // if no appropriate one is found.
796  const SwPageDesc* pDefaultPageDesc;
797  {
798  pDefaultPageDesc =
799  pSectNd->GetSection().GetFormat()->GetPageDesc().GetPageDesc();
800  if ( !_bNewTOX && !pDefaultPageDesc )
801  {
802  // determine page description of table-of-content
803  size_t nPgDescNdIdx = pSectNd->GetIndex() + 1;
804  size_t* pPgDescNdIdx = &nPgDescNdIdx;
805  pDefaultPageDesc = pSectNd->FindPageDesc( pPgDescNdIdx );
806  if ( nPgDescNdIdx < pSectNd->GetIndex() )
807  {
808  pDefaultPageDesc = nullptr;
809  }
810  }
811  // consider end node of content section in the node array.
812  if ( !pDefaultPageDesc &&
813  ( pSectNd->EndOfSectionNode()->GetIndex() <
814  (pSectNd->GetNodes().GetEndOfContent().GetIndex() - 1) )
815  )
816  {
817  // determine page description of content after table-of-content
818  SwNodeIndex aIdx( *(pSectNd->EndOfSectionNode()) );
819  const SwContentNode* pNdAfterTOX = pSectNd->GetNodes().GoNext( &aIdx );
820  const SwAttrSet& aNdAttrSet = pNdAfterTOX->GetSwAttrSet();
821  const SvxBreak eBreak = aNdAttrSet.GetBreak().GetBreak();
822  if ( !( eBreak == SvxBreak::PageBefore ||
823  eBreak == SvxBreak::PageBoth )
824  )
825  {
826  pDefaultPageDesc = pNdAfterTOX->FindPageDesc();
827  }
828  }
829  // consider start node of content section in the node array.
830  if ( !pDefaultPageDesc &&
831  ( pSectNd->GetIndex() >
832  (pSectNd->GetNodes().GetEndOfContent().StartOfSectionIndex() + 1) )
833  )
834  {
835  // determine page description of content before table-of-content
836  SwNodeIndex aIdx( *pSectNd );
837  pDefaultPageDesc =
838  SwNodes::GoPrevious( &aIdx )->FindPageDesc();
839 
840  }
841  if ( !pDefaultPageDesc )
842  {
843  // determine default page description
844  pDefaultPageDesc = &pDoc->GetPageDesc( 0 );
845  }
846  }
847 
848  pDoc->getIDocumentState().SetModified();
849 
850  // get current Language
852  TOX_INDEX == GetTOXType()->GetType() ?
854  GetSortAlgorithm() );
855 
856  m_aSortArr.clear();
857 
858  // find the first layout node for this TOX, if it only find the content
859  // in his own chapter
860  const SwTextNode* pOwnChapterNode = IsFromChapter()
861  ? ::lcl_FindChapterNode( *pSectNd, pLayout )
862  : nullptr;
863 
864  SwNode2LayoutSaveUpperFrames aN2L(*pSectNd);
865  const_cast<SwSectionNode*>(pSectNd)->DelFrames();
866 
867  // This would be a good time to update the Numbering
868  pDoc->UpdateNumRule();
869 
871  UpdateMarks( aIntl, pOwnChapterNode, pLayout );
872 
874  UpdateOutline( pOwnChapterNode, pLayout );
875 
877  UpdateTemplate( pOwnChapterNode, pLayout );
878 
881  UpdateContent( SwTOXElement::Ole, pOwnChapterNode, pLayout );
882 
885  UpdateTable( pOwnChapterNode, pLayout );
886 
889  UpdateContent( SwTOXElement::Graphic, pOwnChapterNode, pLayout );
890 
891  if( !GetSequenceName().isEmpty() && !IsFromObjectNames() &&
894  UpdateSequence( pOwnChapterNode, pLayout );
895 
897  UpdateContent( SwTOXElement::Frame, pOwnChapterNode, pLayout );
898 
900  UpdateAuthorities( aIntl, pLayout );
901 
902  // Insert AlphaDelimiters if needed (just for keywords)
903  if( TOX_INDEX == SwTOXBase::GetType() &&
905  InsertAlphaDelimiter( aIntl );
906 
907  // remove old content an insert one empty textnode (to hold the layout!)
908  SwTextNode* pFirstEmptyNd;
909 
910  SwUndoUpdateIndex * pUndo(nullptr);
911  {
912  pDoc->getIDocumentRedlineAccess().DeleteRedline( *pSectNd, true, RedlineType::Any );
913 
914  SwNodeIndex aSttIdx( *pSectNd, +1 );
915  SwNodeIndex aEndIdx( *pSectNd->EndOfSectionNode() );
916  pFirstEmptyNd = pDoc->GetNodes().MakeTextNode( aEndIdx,
918 
919  {
920  // Task 70995 - save and restore PageDesc and Break Attributes
921  SwNodeIndex aNxtIdx( aSttIdx );
922  const SwContentNode* pCNd = aNxtIdx.GetNode().GetContentNode();
923  if( !pCNd )
924  pCNd = pDoc->GetNodes().GoNext( &aNxtIdx );
925  assert(pCNd != pFirstEmptyNd);
926  assert(pCNd->GetIndex() < pFirstEmptyNd->GetIndex());
927  if( pCNd->HasSwAttrSet() )
928  {
929  SfxItemSet aBrkSet( pDoc->GetAttrPool(), aBreakSetRange );
930  aBrkSet.Put( *pCNd->GetpSwAttrSet() );
931  if( aBrkSet.Count() )
932  pFirstEmptyNd->SetAttr( aBrkSet );
933  }
934  }
935 
936  if (pDoc->GetIDocumentUndoRedo().DoesUndo())
937  {
938  // note: this will first append a SwUndoDelSection from the ctor...
939  pUndo = new SwUndoUpdateIndex(*this);
940  // tdf#123313 insert Undo *after* all CrossRefBookmark Undos have
941  // been inserted by the Update*() functions
942  pDoc->GetIDocumentUndoRedo().AppendUndo(std::unique_ptr<SwUndoUpdateIndex>(pUndo));
943  }
944  else
945  {
946  --aEndIdx;
947  SwPosition aPos( aEndIdx, SwIndex( pFirstEmptyNd, 0 ));
948  SwDoc::CorrAbs( aSttIdx, aEndIdx, aPos, true );
949 
950  // delete flys in whole range including start node which requires
951  // giving the node before start node as Mark parameter, hence -1.
952  // (flys must be deleted because the anchor nodes are removed)
953  DelFlyInRange( SwNodeIndex(aSttIdx, -1), aEndIdx );
954 
955  pDoc->GetNodes().Delete( aSttIdx, aEndIdx.GetIndex() - aSttIdx.GetIndex() );
956  }
957  }
958 
959  // insert title of TOX
960  if ( !GetTitle().isEmpty() )
961  {
962  // then insert the headline section
963  SwNodeIndex aIdx( *pSectNd, +1 );
964 
965  SwTextNode* pHeadNd = pDoc->GetNodes().MakeTextNode( aIdx,
967  pHeadNd->InsertText( GetTitle(), SwIndex( pHeadNd ) );
968 
969  SwSectionData headerData( TOX_HEADER_SECTION, GetTOXName()+"_Head" );
970 
971  SwNodeIndex aStt( *pHeadNd ); --aIdx;
972  SwSectionFormat* pSectFormat = pDoc->MakeSectionFormat();
973  pDoc->GetNodes().InsertTextSection(
974  aStt, *pSectFormat, headerData, nullptr, &aIdx, true, false);
975 
976  if (pUndo)
977  {
978  pUndo->TitleSectionInserted(*pSectFormat);
979  }
980  }
981 
982  // Sort the List of all TOC Marks and TOC Sections
983  std::vector<SwTextFormatColl*> aCollArr( GetTOXForm().GetFormMax(), nullptr );
984  SwNodeIndex aInsPos( *pFirstEmptyNd, 1 );
985  for( size_t nCnt = 0; nCnt < m_aSortArr.size(); ++nCnt )
986  {
987  ::SetProgressState( 0, pDoc->GetDocShell() );
988 
989  // Put the Text into the TOC
990  sal_uInt16 nLvl = m_aSortArr[ nCnt ]->GetLevel();
991  SwTextFormatColl* pColl = aCollArr[ nLvl ];
992  if( !pColl )
993  {
994  pColl = GetTextFormatColl( nLvl );
995  aCollArr[ nLvl ] = pColl;
996  }
997 
998  // Generate: Set dynamic TabStops
999  SwTextNode* pTOXNd = pDoc->GetNodes().MakeTextNode( aInsPos , pColl );
1000  m_aSortArr[ nCnt ]->pTOXNd = pTOXNd;
1001 
1002  // Generate: Evaluate Form and insert the place holder for the
1003  // page number. If it is a TOX_INDEX and the SwForm IsCommaSeparated()
1004  // then a range of entries must be generated into one paragraph
1005  size_t nRange = 1;
1006  if(TOX_INDEX == SwTOXBase::GetType() &&
1007  GetTOXForm().IsCommaSeparated() &&
1008  m_aSortArr[nCnt]->GetType() == TOX_SORT_INDEX)
1009  {
1010  const SwTOXMark& rMark = m_aSortArr[nCnt]->pTextMark->GetTOXMark();
1011  const OUString& sPrimKey = rMark.GetPrimaryKey();
1012  const OUString& sSecKey = rMark.GetSecondaryKey();
1013  const SwTOXMark* pNextMark = nullptr;
1014  while(m_aSortArr.size() > (nCnt + nRange)&&
1015  m_aSortArr[nCnt + nRange]->GetType() == TOX_SORT_INDEX &&
1016  nullptr != (pNextMark = &(m_aSortArr[nCnt + nRange]->pTextMark->GetTOXMark())) &&
1017  pNextMark->GetPrimaryKey() == sPrimKey &&
1018  pNextMark->GetSecondaryKey() == sSecKey)
1019  nRange++;
1020  }
1021  // pass node index of table-of-content section and default page description
1022  // to method <GenerateText(..)>.
1023  ::SetProgressState( 0, pDoc->GetDocShell() );
1024 
1025  std::shared_ptr<sw::ToxTabStopTokenHandler> tabStopTokenHandler =
1026  std::make_shared<sw::DefaultToxTabStopTokenHandler>(
1027  pSectNd->GetIndex(), *pDefaultPageDesc, GetTOXForm().IsRelTabPos(),
1031  sw::ToxTextGenerator ttgn(GetTOXForm(), tabStopTokenHandler);
1032  ttgn.GenerateText(GetFormat()->GetDoc(), m_aSortArr, nCnt, nRange, pLayout);
1033  nCnt += nRange - 1;
1034  }
1035 
1036  // delete the first dummy node and remove all Cursor into the previous node
1037  aInsPos = *pFirstEmptyNd;
1038  {
1039  SwPaM aCorPam( *pFirstEmptyNd );
1040  aCorPam.GetPoint()->nContent.Assign( pFirstEmptyNd, 0 );
1041  if( !aCorPam.Move( fnMoveForward ) )
1042  aCorPam.Move( fnMoveBackward );
1043  SwNodeIndex aEndIdx( aInsPos, 1 );
1044  SwDoc::CorrAbs( aInsPos, aEndIdx, *aCorPam.GetPoint(), true );
1045 
1046  // Task 70995 - save and restore PageDesc and Break Attributes
1047  if( pFirstEmptyNd->HasSwAttrSet() )
1048  {
1049  if( !GetTitle().isEmpty() )
1050  aEndIdx = *pSectNd;
1051  else
1052  aEndIdx = *pFirstEmptyNd;
1053  SwContentNode* pCNd = pDoc->GetNodes().GoNext( &aEndIdx );
1054  if( pCNd ) // Robust against defect documents, e.g. i60336
1055  pCNd->SetAttr( *pFirstEmptyNd->GetpSwAttrSet() );
1056  }
1057  }
1058 
1059  // now create the new Frames
1060  sal_uLong nIdx = pSectNd->GetIndex();
1061  // don't delete if index is empty
1062  if(nIdx + 2 < pSectNd->EndOfSectionIndex())
1063  pDoc->GetNodes().Delete( aInsPos );
1064 
1065  aN2L.RestoreUpperFrames( pDoc->GetNodes(), nIdx, nIdx + 1 );
1066  std::set<SwRootFrame*> aAllLayouts = pDoc->GetAllLayouts();
1067  for ( const auto& rpLayout : aAllLayouts )
1068  {
1069  SwFrame::CheckPageDescs( static_cast<SwPageFrame*>(rpLayout->Lower()) );
1070  }
1071 
1073 }
1074 
1076 {
1077  SwDoc* pDoc = GetFormat()->GetDoc();
1078  OUString sLastDeli;
1079  size_t i = 0;
1080  while( i < m_aSortArr.size() )
1081  {
1082  ::SetProgressState( 0, pDoc->GetDocShell() );
1083 
1084  sal_uInt16 nLevel = m_aSortArr[i]->GetLevel();
1085 
1086  // Skip AlphaDelimiter
1087  if( nLevel == FORM_ALPHA_DELIMITER )
1088  continue;
1089 
1090  const OUString sDeli = rIntl.GetIndexKey( m_aSortArr[i]->GetText(),
1091  m_aSortArr[i]->GetLocale() );
1092 
1093  // Do we already have a Delimiter?
1094  if( !sDeli.isEmpty() && sLastDeli != sDeli )
1095  {
1096  // We skip all that are less than a small Blank (these are special characters)
1097  if( ' ' <= sDeli[0] )
1098  {
1099  std::unique_ptr<SwTOXCustom> pCst(
1100  MakeSwTOXSortTabBase<SwTOXCustom>(nullptr,
1101  TextAndReading(sDeli, OUString()),
1103  rIntl, m_aSortArr[i]->GetLocale() ));
1104  m_aSortArr.insert( m_aSortArr.begin() + i, std::move(pCst));
1105  i++;
1106  }
1107  sLastDeli = sDeli;
1108  }
1109 
1110  // Skip until we get to the same or a lower Level
1111  do {
1112  i++;
1113  } while (i < m_aSortArr.size() && m_aSortArr[i]->GetLevel() > nLevel);
1114  }
1115 }
1116 
1119 {
1120  SwDoc* pDoc = GetFormat()->GetDoc();
1121  const OUString& rName = GetTOXForm().GetTemplate( nLevel );
1122  SwTextFormatColl* pColl = !rName.isEmpty() ? pDoc->FindTextFormatCollByName(rName) :nullptr;
1123  if( !pColl )
1124  {
1125  sal_uInt16 nPoolFormat = 0;
1126  const TOXTypes eMyType = SwTOXBase::GetType();
1127  switch( eMyType )
1128  {
1129  case TOX_INDEX: nPoolFormat = RES_POOLCOLL_TOX_IDXH; break;
1130  case TOX_USER:
1131  if( nLevel < 6 )
1132  nPoolFormat = RES_POOLCOLL_TOX_USERH;
1133  else
1134  nPoolFormat = RES_POOLCOLL_TOX_USER6 - 6;
1135  break;
1136  case TOX_ILLUSTRATIONS: nPoolFormat = RES_POOLCOLL_TOX_ILLUSH; break;
1137  case TOX_OBJECTS: nPoolFormat = RES_POOLCOLL_TOX_OBJECTH; break;
1138  case TOX_TABLES: nPoolFormat = RES_POOLCOLL_TOX_TABLESH; break;
1139  case TOX_AUTHORITIES:
1140  case TOX_BIBLIOGRAPHY:
1141  nPoolFormat = RES_POOLCOLL_TOX_AUTHORITIESH; break;
1142  case TOX_CITATION: break;
1143  case TOX_CONTENT:
1144  // There's a jump in the ContentArea!
1145  if( nLevel < 6 )
1146  nPoolFormat = RES_POOLCOLL_TOX_CNTNTH;
1147  else
1148  nPoolFormat = RES_POOLCOLL_TOX_CNTNT6 - 6;
1149  break;
1150  }
1151 
1152  if(eMyType == TOX_AUTHORITIES && nLevel)
1153  nPoolFormat = nPoolFormat + 1;
1154  else if(eMyType == TOX_INDEX && nLevel)
1155  {
1156  // pool: Level 1,2,3, Delimiter
1157  // SwForm: Delimiter, Level 1,2,3
1158  nPoolFormat += 1 == nLevel ? nLevel + 3 : nLevel - 1;
1159  }
1160  else
1161  nPoolFormat = nPoolFormat + nLevel;
1162  pColl = pDoc->getIDocumentStylePoolAccess().GetTextCollFromPool( nPoolFormat );
1163  }
1164  return pColl;
1165 }
1166 
1169  const SwTextNode* pOwnChapterNode,
1170  SwRootFrame const*const pLayout)
1171 {
1172  const SwTOXType* pType = static_cast<SwTOXType*>( SwTOXBase::GetRegisteredIn() );
1173  if( !pType->HasWriterListeners() )
1174  return;
1175 
1176  SwDoc* pDoc = GetFormat()->GetDoc();
1177  TOXTypes eTOXTyp = GetTOXType()->GetType();
1178  SwIterator<SwTOXMark,SwTOXType> aIter( *pType );
1179 
1180  for (SwTOXMark* pMark = aIter.First(); pMark; pMark = aIter.Next())
1181  {
1182  ::SetProgressState( 0, pDoc->GetDocShell() );
1183 
1184  if (pMark->GetTOXType()->GetType() == eTOXTyp)
1185  {
1186  SwTextTOXMark *const pTextMark(pMark->GetTextTOXMark());
1187  if (nullptr == pTextMark)
1188  continue;
1189  const SwTextNode* pTOXSrc = pTextMark->GetpTextNd();
1190  // Only insert TOXMarks from the Doc, not from the
1191  // UNDO.
1192 
1193  // If selected use marks from the same chapter only
1194  if( pTOXSrc->GetNodes().IsDocNodes() &&
1195  pTOXSrc->GetText().getLength() && pTOXSrc->HasWriterListeners() &&
1197  (!IsFromChapter() || ::lcl_FindChapterNode(*pTOXSrc, pLayout) == pOwnChapterNode) &&
1198  !pTOXSrc->IsHiddenByParaField() &&
1199  !SwScriptInfo::IsInHiddenRange(*pTOXSrc, pTextMark->GetStart()) &&
1200  (!pLayout || !pLayout->IsHideRedlines()
1201  || !sw::IsMarkHintHidden(*pLayout, *pTOXSrc, *pTextMark)))
1202  {
1203  if(TOX_INDEX == eTOXTyp)
1204  {
1205  // index entry mark
1206  assert(g_pBreakIt);
1207  lang::Locale aLocale = g_pBreakIt->GetLocale(pTOXSrc->GetLang(pTextMark->GetStart()));
1208 
1209  InsertSorted(MakeSwTOXSortTabBase<SwTOXIndex>(pLayout, *pTOXSrc, pTextMark,
1210  GetOptions(), FORM_ENTRY, rIntl, aLocale ));
1212  !pTextMark->GetTOXMark().GetPrimaryKey().isEmpty())
1213  {
1214  InsertSorted(MakeSwTOXSortTabBase<SwTOXIndex>(pLayout, *pTOXSrc, pTextMark,
1215  GetOptions(), FORM_PRIMARY_KEY, rIntl, aLocale ));
1216  if (!pTextMark->GetTOXMark().GetSecondaryKey().isEmpty())
1217  {
1218  InsertSorted(MakeSwTOXSortTabBase<SwTOXIndex>(pLayout, *pTOXSrc, pTextMark,
1219  GetOptions(), FORM_SECONDARY_KEY, rIntl, aLocale ));
1220  }
1221  }
1222  }
1223  else if( TOX_USER == eTOXTyp ||
1224  pMark->GetLevel() <= GetLevel())
1225  { // table of content mark
1226  // also used for user marks
1227  InsertSorted(MakeSwTOXSortTabBase<SwTOXContent>(pLayout, *pTOXSrc, pTextMark, rIntl));
1228  }
1229  }
1230  }
1231  }
1232 }
1233 
1235 void SwTOXBaseSection::UpdateOutline( const SwTextNode* pOwnChapterNode,
1236  SwRootFrame const*const pLayout)
1237 {
1238  SwDoc* pDoc = GetFormat()->GetDoc();
1239  SwNodes& rNds = pDoc->GetNodes();
1240 
1241  const SwOutlineNodes& rOutlNds = rNds.GetOutLineNds();
1242  for( auto pOutlineNode : rOutlNds )
1243  {
1244  ::SetProgressState( 0, pDoc->GetDocShell() );
1245  SwTextNode* pTextNd = pOutlineNode->GetTextNode();
1246  if( pTextNd && pTextNd->Len() && pTextNd->HasWriterListeners() &&
1247  sal_uInt16( pTextNd->GetAttrOutlineLevel()) <= GetLevel() &&
1248  pTextNd->getLayoutFrame(pLayout) &&
1249  !pTextNd->IsHiddenByParaField() &&
1250  !pTextNd->HasHiddenCharAttribute( true ) &&
1251  (!pLayout || !pLayout->IsHideRedlines()
1252  || static_cast<SwTextFrame*>(pTextNd->getLayoutFrame(pLayout))->GetTextNodeForParaProps() == pTextNd) &&
1253  ( !IsFromChapter() ||
1254  ::lcl_FindChapterNode(*pTextNd, pLayout) == pOwnChapterNode ))
1255  {
1256  InsertSorted(MakeSwTOXSortTabBase<SwTOXPara>(pLayout, *pTextNd, SwTOXElement::OutlineLevel));
1257  }
1258  }
1259 }
1260 
1262 void SwTOXBaseSection::UpdateTemplate(const SwTextNode* pOwnChapterNode,
1263  SwRootFrame const*const pLayout)
1264 {
1265  SwDoc* pDoc = GetFormat()->GetDoc();
1266  for(sal_uInt16 i = 0; i < MAXLEVEL; i++)
1267  {
1268  const OUString sTmpStyleNames = GetStyleNames(i);
1269  if (sTmpStyleNames.isEmpty())
1270  continue;
1271 
1272  sal_Int32 nIndex = 0;
1273  while (nIndex >= 0)
1274  {
1276  sTmpStyleNames.getToken( 0, TOX_STYLE_DELIMITER, nIndex ));
1277  //TODO: no outline Collections in content indexes if OutlineLevels are already included
1278  if( !pColl ||
1282  continue;
1283 
1284  SwIterator<SwTextNode,SwFormatColl> aIter( *pColl );
1285  for( SwTextNode* pTextNd = aIter.First(); pTextNd; pTextNd = aIter.Next() )
1286  {
1287  ::SetProgressState( 0, pDoc->GetDocShell() );
1288 
1289  if (pTextNd->GetText().getLength() &&
1290  pTextNd->getLayoutFrame(pLayout) &&
1291  pTextNd->GetNodes().IsDocNodes() &&
1292  (!pLayout || !pLayout->IsHideRedlines()
1293  || static_cast<SwTextFrame*>(pTextNd->getLayoutFrame(pLayout))->GetTextNodeForParaProps() == pTextNd) &&
1294  (!IsFromChapter() || pOwnChapterNode ==
1295  ::lcl_FindChapterNode(*pTextNd, pLayout)))
1296  {
1297  InsertSorted(MakeSwTOXSortTabBase<SwTOXPara>(pLayout, *pTextNd, SwTOXElement::Template, i + 1));
1298  }
1299  }
1300  }
1301  }
1302 }
1303 
1305 void SwTOXBaseSection::UpdateSequence(const SwTextNode* pOwnChapterNode,
1306  SwRootFrame const*const pLayout)
1307 {
1308  SwDoc* pDoc = GetFormat()->GetDoc();
1310  if(!pSeqField)
1311  return;
1312 
1313  SwIterator<SwFormatField,SwFieldType> aIter( *pSeqField );
1314  for( SwFormatField* pFormatField = aIter.First(); pFormatField; pFormatField = aIter.Next() )
1315  {
1316  const SwTextField* pTextField = pFormatField->GetTextField();
1317  if(!pTextField)
1318  continue;
1319  SwTextNode& rTextNode = pTextField->GetTextNode();
1320  ::SetProgressState( 0, pDoc->GetDocShell() );
1321 
1322  if (rTextNode.GetText().getLength() &&
1323  rTextNode.getLayoutFrame(pLayout) &&
1324  rTextNode.GetNodes().IsDocNodes() &&
1325  ( !IsFromChapter() ||
1326  ::lcl_FindChapterNode(rTextNode, pLayout) == pOwnChapterNode)
1327  && (!pLayout || !pLayout->IsHideRedlines()
1328  || !sw::IsFieldDeletedInModel(pDoc->getIDocumentRedlineAccess(), *pTextField)))
1329  {
1330  const SwSetExpField& rSeqField = dynamic_cast<const SwSetExpField&>(*(pFormatField->GetField()));
1331  const OUString sName = GetSequenceName()
1332  + OUStringChar(cSequenceMarkSeparator)
1333  + OUString::number( rSeqField.GetSeqNumber() );
1334  std::unique_ptr<SwTOXPara> pNew(new SwTOXPara( rTextNode, SwTOXElement::Sequence, 1, sName ));
1335  // set indexes if the number or the reference text are to be displayed
1336  if( GetCaptionDisplay() == CAPTION_TEXT )
1337  {
1338  pNew->SetStartIndex(
1339  SwGetExpField::GetReferenceTextPos( *pFormatField, *pDoc ));
1340  }
1341  else if(GetCaptionDisplay() == CAPTION_NUMBER)
1342  {
1343  pNew->SetEndIndex(pTextField->GetStart() + 1);
1344  }
1345  pNew->InitText(pLayout);
1346  InsertSorted(std::move(pNew));
1347  }
1348  }
1349 }
1350 
1352  SwRootFrame const*const pLayout)
1353 {
1354  SwDoc* pDoc = GetFormat()->GetDoc();
1355  SwFieldType* pAuthField = pDoc->getIDocumentFieldsAccess().GetFieldType(SwFieldIds::TableOfAuthorities, OUString(), false);
1356  if(!pAuthField)
1357  return;
1358 
1359  SwIterator<SwFormatField,SwFieldType> aIter( *pAuthField );
1360  for( SwFormatField* pFormatField = aIter.First(); pFormatField; pFormatField = aIter.Next() )
1361  {
1362  const SwTextField* pTextField = pFormatField->GetTextField();
1363  // undo
1364  if(!pTextField)
1365  continue;
1366  const SwTextNode& rTextNode = pTextField->GetTextNode();
1367  ::SetProgressState( 0, pDoc->GetDocShell() );
1368 
1369  if (rTextNode.GetText().getLength() &&
1370  rTextNode.getLayoutFrame(pLayout) &&
1371  rTextNode.GetNodes().IsDocNodes()
1372  && (!pLayout || !pLayout->IsHideRedlines()
1373  || !sw::IsFieldDeletedInModel(pDoc->getIDocumentRedlineAccess(), *pTextField)))
1374  {
1375  //#106485# the body node has to be used!
1376  SwContentFrame *const pFrame = rTextNode.getLayoutFrame(pLayout);
1377  SwPosition aFieldPos(rTextNode);
1378  const SwTextNode* pTextNode = nullptr;
1379  if(pFrame && !pFrame->IsInDocBody())
1380  pTextNode = GetBodyTextNode( *pDoc, aFieldPos, *pFrame );
1381  if(!pTextNode)
1382  pTextNode = &rTextNode;
1383 
1384  InsertSorted(MakeSwTOXSortTabBase<SwTOXAuthority>(pLayout, *pTextNode, *pFormatField, rIntl));
1385  }
1386  }
1387 }
1388 
1389 static SwTOOElements lcl_IsSOObject( const SvGlobalName& rFactoryNm )
1390 {
1391  static const struct SoObjType {
1392  SwTOOElements const nFlag;
1393  // GlobalNameId
1394  struct GlobalNameIds {
1395  sal_uInt32 n1;
1396  sal_uInt16 n2, n3;
1397  sal_uInt8 b8, b9, b10, b11, b12, b13, b14, b15;
1398  } aGlNmIds[4];
1399  } aArr[] = {
1414  };
1415 
1416  for( SoObjType const & rArr : aArr )
1417  for (auto & rId : rArr.aGlNmIds)
1418  {
1419  if( !rId.n1 )
1420  break;
1421  SvGlobalName aGlbNm( rId.n1, rId.n2, rId.n3,
1422  rId.b8, rId.b9, rId.b10, rId.b11,
1423  rId.b12, rId.b13, rId.b14, rId.b15 );
1424  if( rFactoryNm == aGlbNm )
1425  {
1426  return rArr.nFlag;
1427  }
1428  }
1429 
1430  return SwTOOElements::NONE;
1431 }
1432 
1434  const SwTextNode* pOwnChapterNode,
1435  SwRootFrame const*const pLayout)
1436 {
1437  SwDoc* pDoc = GetFormat()->GetDoc();
1438  SwNodes& rNds = pDoc->GetNodes();
1439  // on the 1st Node of the 1st Section
1440  sal_uLong nIdx = rNds.GetEndOfAutotext().StartOfSectionIndex() + 2,
1441  nEndIdx = rNds.GetEndOfAutotext().GetIndex();
1442 
1443  while( nIdx < nEndIdx )
1444  {
1445  ::SetProgressState( 0, pDoc->GetDocShell() );
1446 
1447  SwNode* pNd = rNds[ nIdx ];
1448  SwContentNode* pCNd = nullptr;
1449  switch( eMyType )
1450  {
1451  case SwTOXElement::Frame:
1452  if( !pNd->IsNoTextNode() )
1453  {
1454  pCNd = pNd->GetContentNode();
1455  if( !pCNd )
1456  {
1457  SwNodeIndex aTmp( *pNd );
1458  pCNd = rNds.GoNext( &aTmp );
1459  }
1460  }
1461  break;
1462  case SwTOXElement::Graphic:
1463  if( pNd->IsGrfNode() )
1464  pCNd = static_cast<SwContentNode*>(pNd);
1465  break;
1466  case SwTOXElement::Ole:
1467  if( pNd->IsOLENode() )
1468  {
1469  bool bInclude = true;
1471  {
1472  SwOLENode* pOLENode = pNd->GetOLENode();
1473  SwTOOElements nMyOLEOptions = GetOLEOptions();
1474  SwOLEObj& rOLEObj = pOLENode->GetOLEObj();
1475 
1476  if( rOLEObj.IsOleRef() ) // Not yet loaded
1477  {
1478  SvGlobalName aTmpName( rOLEObj.GetOleRef()->getClassID() );
1479  SwTOOElements nObj = ::lcl_IsSOObject( aTmpName );
1480  bInclude = ( (nMyOLEOptions & SwTOOElements::Other) && SwTOOElements::NONE == nObj )
1481  || (nMyOLEOptions & nObj);
1482  }
1483  else
1484  {
1485  OSL_FAIL("OLE Object no loaded?");
1486  bInclude = false;
1487  }
1488  }
1489 
1490  if(bInclude)
1491  pCNd = static_cast<SwContentNode*>(pNd);
1492  }
1493  break;
1494  default: break;
1495  }
1496 
1497  if( pCNd )
1498  {
1499  // find node in body text
1500  int nSetLevel = USHRT_MAX;
1501 
1502  //#111105# tables of tables|illustrations|objects don't support hierarchies
1503  if( IsLevelFromChapter() &&
1507  {
1508  const SwTextNode* pOutlNd = ::lcl_FindChapterNode( *pCNd,
1509  pLayout, MAXLEVEL - 1);
1510  if( pOutlNd )
1511  {
1513  {
1514  nSetLevel = pOutlNd->GetTextColl()->GetAttrOutlineLevel();
1515  }
1516  }
1517  }
1518 
1519  if (pCNd->getLayoutFrame(pLayout)
1520  && (!pLayout || !pLayout->IsHideRedlines()
1522  && ( !IsFromChapter() ||
1523  ::lcl_FindChapterNode(*pCNd, pLayout) == pOwnChapterNode ))
1524  {
1525  std::unique_ptr<SwTOXPara> pNew( MakeSwTOXSortTabBase<SwTOXPara>(
1526  pLayout, *pCNd, eMyType,
1527  ( USHRT_MAX != nSetLevel )
1528  ? static_cast<sal_uInt16>(nSetLevel)
1529  : FORM_ALPHA_DELIMITER ) );
1530  InsertSorted( std::move(pNew) );
1531  }
1532  }
1533 
1534  nIdx = pNd->StartOfSectionNode()->EndOfSectionIndex() + 2; // 2 == End/Start Node
1535  }
1536 }
1537 
1539 void SwTOXBaseSection::UpdateTable(const SwTextNode* pOwnChapterNode,
1540  SwRootFrame const*const pLayout)
1541 {
1542  SwDoc* pDoc = GetFormat()->GetDoc();
1543  SwNodes& rNds = pDoc->GetNodes();
1544  const SwFrameFormats& rArr = *pDoc->GetTableFrameFormats();
1545 
1546  for( auto pFrameFormat : rArr )
1547  {
1548  ::SetProgressState( 0, pDoc->GetDocShell() );
1549 
1550  SwTable* pTmpTable = SwTable::FindTable( pFrameFormat );
1551  SwTableBox* pFBox;
1552  if( pTmpTable && nullptr != (pFBox = pTmpTable->GetTabSortBoxes()[0] ) &&
1553  pFBox->GetSttNd() && pFBox->GetSttNd()->GetNodes().IsDocNodes() )
1554  {
1555  const SwTableNode* pTableNd = pFBox->GetSttNd()->FindTableNode();
1556  SwNodeIndex aContentIdx( *pTableNd, 1 );
1557 
1558  SwContentNode* pCNd;
1559  while( nullptr != ( pCNd = rNds.GoNext( &aContentIdx ) ) &&
1560  aContentIdx.GetIndex() < pTableNd->EndOfSectionIndex() )
1561  {
1562  if (pCNd->getLayoutFrame(pLayout)
1563  && (!pLayout || !pLayout->IsHideRedlines()
1565  && (!IsFromChapter()
1566  || ::lcl_FindChapterNode(*pCNd, pLayout) == pOwnChapterNode))
1567  {
1568  std::unique_ptr<SwTOXTable> pNew(new SwTOXTable( *pCNd ));
1570  {
1571  const SwTextNode* pOutlNd =
1572  ::lcl_FindChapterNode(*pCNd, pLayout, MAXLEVEL - 1);
1573  if( pOutlNd )
1574  {
1576  {
1577  const int nTmp = pOutlNd->GetTextColl()->GetAttrOutlineLevel();
1578  pNew->SetLevel(static_cast<sal_uInt16>(nTmp));
1579  }
1580  }
1581  }
1582  pNew->InitText(pLayout);
1583  InsertSorted(std::move(pNew));
1584  break;
1585  }
1586  }
1587  }
1588  }
1589 }
1590 
1593 {
1594  if( m_aSortArr.empty() )
1595  return ;
1596 
1597  // Insert the current PageNumber into the TOC
1598  SwPageFrame* pCurrentPage = nullptr;
1599  sal_uInt16 nPage = 0;
1600  SwDoc* pDoc = GetFormat()->GetDoc();
1601 
1603  TOX_INDEX == GetTOXType()->GetType() ?
1605  GetSortAlgorithm() );
1606 
1607  for( size_t nCnt = 0; nCnt < m_aSortArr.size(); ++nCnt )
1608  {
1609  // Loop over all SourceNodes
1610 
1611  // process run in lines
1612  size_t nRange = 0;
1613  if(GetTOXForm().IsCommaSeparated() &&
1614  m_aSortArr[nCnt]->GetType() == TOX_SORT_INDEX)
1615  {
1616  const SwTOXMark& rMark = m_aSortArr[nCnt]->pTextMark->GetTOXMark();
1617  const OUString& sPrimKey = rMark.GetPrimaryKey();
1618  const OUString& sSecKey = rMark.GetSecondaryKey();
1619  const SwTOXMark* pNextMark = nullptr;
1620  while(m_aSortArr.size() > (nCnt + nRange)&&
1621  m_aSortArr[nCnt + nRange]->GetType() == TOX_SORT_INDEX &&
1622  nullptr != (pNextMark = &(m_aSortArr[nCnt + nRange]->pTextMark->GetTOXMark())) &&
1623  pNextMark->GetPrimaryKey() == sPrimKey &&
1624  pNextMark->GetSecondaryKey() == sSecKey)
1625  nRange++;
1626  }
1627  else
1628  nRange = 1;
1629 
1630  for(size_t nRunInEntry = nCnt; nRunInEntry < nCnt + nRange; ++nRunInEntry)
1631  {
1632  std::vector<sal_uInt16> aNums; // the PageNumber
1633  std::vector<SwPageDesc*> aDescs; // The PageDescriptors matching the PageNumbers
1634  std::vector<sal_uInt16> aMainNums; // contains page numbers of main entries
1635  SwTOXSortTabBase* pSortBase = m_aSortArr[nRunInEntry].get();
1636  size_t nSize = pSortBase->aTOXSources.size();
1637  for (size_t j = 0; j < nSize; ++j)
1638  {
1639  ::SetProgressState( 0, pDoc->GetDocShell() );
1640 
1641  SwTOXSource& rTOXSource = pSortBase->aTOXSources[j];
1642  if( rTOXSource.pNd )
1643  {
1644  SwContentFrame* pFrame = rTOXSource.pNd->getLayoutFrame( pDoc->getIDocumentLayoutAccess().GetCurrentLayout() );
1645  OSL_ENSURE( pFrame || pDoc->IsUpdateTOX(), "TOX, no Frame found");
1646  if( !pFrame )
1647  continue;
1648  if( pFrame->IsTextFrame() && static_cast<SwTextFrame*>(pFrame)->HasFollow() )
1649  {
1650  // find the right one
1651  SwTextFrame* pNext;
1652  TextFrameIndex const nPos(static_cast<SwTextFrame*>(pFrame)
1653  ->MapModelToView(static_cast<SwTextNode const*>(rTOXSource.pNd),
1654  rTOXSource.nPos));
1655  while( nullptr != ( pNext = static_cast<SwTextFrame*>(pFrame->GetFollow()) )
1656  && nPos >= pNext->GetOfst())
1657  pFrame = pNext;
1658  }
1659 
1660  SwPageFrame* pTmpPage = pFrame->FindPageFrame();
1661  if( pTmpPage != pCurrentPage )
1662  {
1663  nPage = pTmpPage->GetVirtPageNum();
1664  pCurrentPage = pTmpPage;
1665  }
1666 
1667  // Insert as sorted
1668  std::vector<sal_uInt16>::size_type i;
1669  for( i = 0; i < aNums.size() && aNums[i] < nPage; ++i )
1670  ;
1671 
1672  if( i >= aNums.size() || aNums[ i ] != nPage )
1673  {
1674  aNums.insert(aNums.begin() + i, nPage);
1675  aDescs.insert(aDescs.begin() + i, pCurrentPage->GetPageDesc() );
1676  }
1677  // is it a main entry?
1678  if(TOX_SORT_INDEX == pSortBase->GetType() &&
1679  rTOXSource.bMainEntry)
1680  {
1681  aMainNums.push_back(nPage);
1682  }
1683  }
1684  }
1685  // Insert the PageNumber into the TOC TextNode
1686  const SwTOXSortTabBase* pBase = m_aSortArr[ nCnt ].get();
1687  if(pBase->pTOXNd)
1688  {
1689  const SwTextNode* pTextNd = pBase->pTOXNd->GetTextNode();
1690  OSL_ENSURE( pTextNd, "no TextNode, wrong TOC" );
1691 
1692  UpdatePageNum_( const_cast<SwTextNode*>(pTextNd), aNums, aDescs, &aMainNums,
1693  aIntl );
1694  }
1695  }
1696  }
1697  // Delete the mapping array after setting the right PageNumber
1698  m_aSortArr.clear();
1699 }
1700 
1703 static bool lcl_HasMainEntry( const std::vector<sal_uInt16>* pMainEntryNums, sal_uInt16 nToFind )
1704 {
1705  if (!pMainEntryNums)
1706  return false;
1707 
1708  for( auto nMainEntry : *pMainEntryNums )
1709  if (nToFind == nMainEntry)
1710  return true;
1711  return false;
1712 }
1713 
1715  const std::vector<sal_uInt16>& rNums,
1716  const std::vector<SwPageDesc*>& rDescs,
1717  const std::vector<sal_uInt16>* pMainEntryNums,
1718  const SwTOXInternational& rIntl )
1719 {
1720  // collect starts end ends of main entry character style
1721  std::unique_ptr< std::vector<sal_uInt16> > xCharStyleIdx(pMainEntryNums ? new std::vector<sal_uInt16> : nullptr);
1722 
1723  OUString sSrchStr = OUStringChar(C_NUM_REPL) + S_PAGE_DELI + OUStringChar(C_NUM_REPL);
1724  sal_Int32 nStartPos = pNd->GetText().indexOf(sSrchStr);
1725  sSrchStr = OUStringChar(C_NUM_REPL) + OUStringChar(C_END_PAGE_NUM);
1726  sal_Int32 nEndPos = pNd->GetText().indexOf(sSrchStr);
1727 
1728  if (-1 == nEndPos || rNums.empty())
1729  return;
1730 
1731  if (-1 == nStartPos || nStartPos > nEndPos)
1732  nStartPos = nEndPos;
1733 
1734  sal_uInt16 nOld = rNums[0],
1735  nBeg = nOld,
1736  nCount = 0;
1737  OUString aNumStr( rDescs[0]->GetNumType().GetNumStr( nBeg ) );
1738  if( xCharStyleIdx && lcl_HasMainEntry( pMainEntryNums, nBeg ))
1739  {
1740  xCharStyleIdx->push_back( 0 );
1741  }
1742 
1743  // Delete place holder
1744  SwIndex aPos(pNd, nStartPos);
1745  SwCharFormat* pPageNoCharFormat = nullptr;
1746  SwpHints* pHints = pNd->GetpSwpHints();
1747  if(pHints)
1748  for(size_t nHintIdx = 0; nHintIdx < pHints->Count(); ++nHintIdx)
1749  {
1750  const SwTextAttr* pAttr = pHints->Get(nHintIdx);
1751  const sal_Int32 nTmpEnd = pAttr->End() ? *pAttr->End() : 0;
1752  if( nStartPos >= pAttr->GetStart() &&
1753  (nStartPos + 2) <= nTmpEnd &&
1754  pAttr->Which() == RES_TXTATR_CHARFMT)
1755  {
1756  pPageNoCharFormat = pAttr->GetCharFormat().GetCharFormat();
1757  break;
1758  }
1759  }
1760  pNd->EraseText(aPos, nEndPos - nStartPos + 2);
1761 
1762  std::vector<sal_uInt16>::size_type i;
1763  for( i = 1; i < rNums.size(); ++i)
1764  {
1765  SvxNumberType aType( rDescs[i]->GetNumType() );
1766  if( TOX_INDEX == SwTOXBase::GetType() )
1767  { // Summarize for the following
1768  // Add up all following
1769  // break up if main entry starts or ends and
1770  // insert a char style index
1771  bool bMainEntryChanges = lcl_HasMainEntry(pMainEntryNums, nOld)
1772  != lcl_HasMainEntry(pMainEntryNums, rNums[i]);
1773 
1774  if(nOld == rNums[i]-1 && !bMainEntryChanges &&
1776  nCount++;
1777  else
1778  {
1779  // Flush for the following old values
1781  {
1782  if ( nCount >= 1 )
1783  aNumStr += rIntl.GetFollowingText( nCount > 1 );
1784  }
1785  else if (nCount) //#58127# If nCount == 0, then the only PageNumber is already in aNumStr!
1786  {
1787  if (nCount == 1 )
1788  aNumStr += S_PAGE_DELI;
1789  else
1790  aNumStr += "-";
1791 
1792  aNumStr += aType.GetNumStr( nBeg + nCount );
1793  }
1794 
1795  // Create new String
1796  nBeg = rNums[i];
1797  aNumStr += S_PAGE_DELI;
1798  //the change of the character style must apply after sPageDeli is appended
1799  if (xCharStyleIdx && bMainEntryChanges)
1800  {
1801  xCharStyleIdx->push_back(aNumStr.getLength());
1802  }
1803  aNumStr += aType.GetNumStr( nBeg );
1804  nCount = 0;
1805  }
1806  nOld = rNums[i];
1807  }
1808  else
1809  { // Insert all Numbers
1810  aNumStr += aType.GetNumStr( rNums[i] );
1811  if (i+1 != rNums.size())
1812  aNumStr += S_PAGE_DELI;
1813  }
1814  }
1815  // Flush when ending and the following old values
1816  if( TOX_INDEX == SwTOXBase::GetType() )
1817  {
1819  {
1820  if( nCount >= 1 )
1821  aNumStr += rIntl.GetFollowingText( nCount > 1 );
1822  }
1823  else
1824  {
1825  if(nCount >= 2)
1826  aNumStr += "-";
1827  else if(nCount == 1)
1828  aNumStr += S_PAGE_DELI;
1829  //#58127# If nCount == 0, then the only PageNumber is already in aNumStr!
1830  if(nCount)
1831  aNumStr += rDescs[i-1]->GetNumType().GetNumStr( nBeg+nCount );
1832  }
1833  }
1835  if(pPageNoCharFormat)
1836  {
1837  SwFormatCharFormat aCharFormat( pPageNoCharFormat );
1838  pNd->InsertItem(aCharFormat, nStartPos, nStartPos + aNumStr.getLength(), SetAttrMode::DONTEXPAND);
1839  }
1840 
1841  // The main entries should get their character style
1842  if (xCharStyleIdx && !xCharStyleIdx->empty() && !GetMainEntryCharStyle().isEmpty())
1843  {
1844  // eventually the last index must me appended
1845  if (xCharStyleIdx->size()&0x01)
1846  xCharStyleIdx->push_back(aNumStr.getLength());
1847 
1848  // search by name
1849  SwDoc* pDoc = pNd->GetDoc();
1851  SwCharFormat* pCharFormat = nullptr;
1852  if(USHRT_MAX != nPoolId)
1853  pCharFormat = pDoc->getIDocumentStylePoolAccess().GetCharFormatFromPool(nPoolId);
1854  else
1855  pCharFormat = pDoc->FindCharFormatByName( GetMainEntryCharStyle() );
1856  if(!pCharFormat)
1857  pCharFormat = pDoc->MakeCharFormat(GetMainEntryCharStyle(), nullptr);
1858 
1859  // find the page numbers in aNumStr and set the character style
1860  sal_Int32 nOffset = pNd->GetText().getLength() - aNumStr.getLength();
1861  SwFormatCharFormat aCharFormat(pCharFormat);
1862  for (size_t j = 0; j < xCharStyleIdx->size(); j += 2)
1863  {
1864  sal_Int32 nStartIdx = (*xCharStyleIdx)[j] + nOffset;
1865  sal_Int32 nEndIdx = (*xCharStyleIdx)[j + 1] + nOffset;
1866  pNd->InsertItem(aCharFormat, nStartIdx, nEndIdx, SetAttrMode::DONTEXPAND);
1867  }
1868 
1869  }
1870 }
1871 
1872 void SwTOXBaseSection::InsertSorted(std::unique_ptr<SwTOXSortTabBase> pNew)
1873 {
1874  Range aRange(0, m_aSortArr.size());
1875  if( TOX_INDEX == SwTOXBase::GetType() && pNew->pTextMark )
1876  {
1877  const SwTOXMark& rMark = pNew->pTextMark->GetTOXMark();
1878  // Evaluate Key
1879  // Calculate the range where to insert
1880  if( !(GetOptions() & SwTOIOptions::KeyAsEntry) &&
1881  !rMark.GetPrimaryKey().isEmpty() )
1882  {
1883  aRange = GetKeyRange( rMark.GetPrimaryKey(),
1884  rMark.GetPrimaryKeyReading(),
1885  *pNew, FORM_PRIMARY_KEY, aRange );
1886 
1887  if( !rMark.GetSecondaryKey().isEmpty() )
1888  aRange = GetKeyRange( rMark.GetSecondaryKey(),
1889  rMark.GetSecondaryKeyReading(),
1890  *pNew, FORM_SECONDARY_KEY, aRange );
1891  }
1892  }
1893  // Search for identical entries and remove the trailing one
1895  {
1896  for(short i = static_cast<short>(aRange.Min()); i < static_cast<short>(aRange.Max()); ++i)
1897  {
1898  SwTOXSortTabBase* pOld = m_aSortArr[i].get();
1899  if (pOld->equivalent(*pNew))
1900  {
1901  if (pOld->sort_lt(*pNew))
1902  {
1903  return;
1904  }
1905  else
1906  {
1907  // remove the old content
1908  m_aSortArr.erase( m_aSortArr.begin() + i );
1909  aRange.Max()--;
1910  break;
1911  }
1912  }
1913  }
1914  }
1915 
1916  // find position and insert
1917  long i;
1918 
1919  for( i = aRange.Min(); i < aRange.Max(); ++i)
1920  { // Only check for same level
1921  SwTOXSortTabBase* pOld = m_aSortArr[i].get();
1922  if (pOld->equivalent(*pNew))
1923  {
1925  {
1926  // Own entry for double entries or keywords
1927  if( pOld->GetType() == TOX_SORT_CUSTOM &&
1929  continue;
1930 
1932  { // Own entry
1933  m_aSortArr.insert(m_aSortArr.begin() + i, std::move(pNew));
1934  return;
1935  }
1936  // If the own entry is already present, add it to the references list
1937  pOld->aTOXSources.push_back(pNew->aTOXSources[0]);
1938 
1939  return;
1940  }
1941 #if OSL_DEBUG_LEVEL > 0
1942  else
1943  OSL_FAIL("Bibliography entries cannot be found here");
1944 #endif
1945  }
1946  if (pNew->sort_lt(*pOld))
1947  break;
1948  }
1949  // Skip SubLevel
1950  while( TOX_INDEX == SwTOXBase::GetType() && i < aRange.Max() &&
1951  m_aSortArr[i]->GetLevel() > pNew->GetLevel() )
1952  i++;
1953 
1954  // Insert at position i
1955  m_aSortArr.insert(m_aSortArr.begin()+i, std::move(pNew));
1956 }
1957 
1959 Range SwTOXBaseSection::GetKeyRange(const OUString& rStr, const OUString& rStrReading,
1960  const SwTOXSortTabBase& rNew,
1961  sal_uInt16 nLevel, const Range& rRange )
1962 {
1963  const SwTOXInternational& rIntl = *rNew.pTOXIntl;
1964  TextAndReading aToCompare(rStr, rStrReading);
1965 
1967  {
1968  aToCompare.sText = rIntl.ToUpper( aToCompare.sText, 0 )
1969  + aToCompare.sText.copy(1);
1970  }
1971 
1972  OSL_ENSURE(rRange.Min() >= 0 && rRange.Max() >= 0, "Min Max < 0");
1973 
1974  const long nMin = rRange.Min();
1975  const long nMax = rRange.Max();
1976 
1977  long i;
1978 
1979  for( i = nMin; i < nMax; ++i)
1980  {
1981  SwTOXSortTabBase* pBase = m_aSortArr[i].get();
1982 
1983  if( rIntl.IsEqual( pBase->GetText(), pBase->GetLocale(),
1984  aToCompare, rNew.GetLocale() ) &&
1985  pBase->GetLevel() == nLevel )
1986  break;
1987  }
1988  if(i == nMax)
1989  { // If not already present, create and insert
1990  std::unique_ptr<SwTOXCustom> pKey(MakeSwTOXSortTabBase<SwTOXCustom>(
1991  nullptr, aToCompare, nLevel, rIntl, rNew.GetLocale() ));
1992  for(i = nMin; i < nMax; ++i)
1993  {
1994  if (nLevel == m_aSortArr[i]->GetLevel() && pKey->sort_lt(*m_aSortArr[i]))
1995  break;
1996  }
1997  m_aSortArr.insert(m_aSortArr.begin() + i, std::move(pKey));
1998  }
1999  const long nStart = i+1;
2000  const long nEnd = m_aSortArr.size();
2001 
2002  // Find end of range
2003  for(i = nStart; i < nEnd; ++i)
2004  {
2005  if(m_aSortArr[i]->GetLevel() <= nLevel)
2006  {
2007  return Range(nStart, i);
2008  }
2009  }
2010  return Range(nStart, nEnd);
2011 }
2012 
2014 {
2015  const SwTOXBaseSection *pSect = dynamic_cast<const SwTOXBaseSection*>(this);
2016  if (!pSect || !pSect->GetFormat())
2017  return false;
2018 
2019  const SwSectionNode* pSectNode = pSect->GetFormat()->GetSectionNode();
2020  if (!pSectNode)
2021  return false;
2022 
2023  const SwDocShell* pDocSh = pSectNode->GetDoc()->GetDocShell();
2024  if (!pDocSh)
2025  return false;
2026 
2027  if (pDocSh->IsReadOnly())
2028  return true;
2029 
2030  pSectNode = pSectNode->StartOfSectionNode()->FindSectionNode();
2031  if (!pSectNode)
2032  return false;
2033 
2034  return pSectNode->GetSection().IsProtectFlag();
2035 }
2036 
2038 {
2039  const SwTOXBaseSection *pSect = dynamic_cast<const SwTOXBaseSection*>(this);
2040  if(pSect && pSect->GetFormat())
2041  return &pSect->GetFormat()->GetAttrSet();
2042  return nullptr;
2043 }
2044 
2046 {
2047  SwTOXBaseSection *pSect = dynamic_cast<SwTOXBaseSection*>(this);
2048  if( pSect && pSect->GetFormat() )
2049  pSect->GetFormat()->SetFormatAttr( rSet );
2050 }
2051 
2052 bool SwTOXBase::GetInfo( SfxPoolItem& rInfo ) const
2053 {
2054  switch( rInfo.Which() )
2055  {
2056  case RES_CONTENT_VISIBLE:
2057  {
2058  const SwTOXBaseSection *pSect = dynamic_cast<const SwTOXBaseSection*>(this);
2059  if( pSect && pSect->GetFormat() )
2060  pSect->GetFormat()->GetInfo( rInfo );
2061  }
2062  return false;
2063  }
2064  return true;
2065 }
2066 
2067 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual SwCharFormat * GetCharFormatFromPool(sal_uInt16 nId)=0
OUString GetNumStr(sal_Int32 nNo) const
SwSectionNode * FindSectionNode()
Search section node, in which it is.
Definition: ndsect.cxx:955
Instances of SwFields and those derived from it occur 0 to n times.
Definition: fldbas.hxx:234
#define SO3_SM_CLASSID_60
const SwEndNode * EndOfSectionNode() const
Definition: node.hxx:682
SwSectionNode * InsertTextSection(SwNodeIndex const &rNdIdx, SwSectionFormat &rSectionFormat, SwSectionData const &, SwTOXBase const *const pTOXBase, SwNodeIndex const *const pEnde, bool const bInsAtStart=true, bool const bCreateFrames=true)
Insert a new SwSection.
Definition: ndsect.cxx:779
SvxBreak
const css::lang::Locale & GetLocale() const
Definition: txmsrt.hxx:182
OUString GetIndexKey(const TextAndReading &rTaR, const css::lang::Locale &rLcl) const
Definition: txmsrt.cxx:121
Base class of the Writer layout elements.
Definition: frame.hxx:295
const sal_Unicode C_NUM_REPL
Definition: tox.cxx:46
Represents the visualization of a paragraph.
Definition: txtfrm.hxx:149
const SfxItemSet * GetAttrSet() const
Definition: doctxm.cxx:2037
TOXTypes
Definition: toxe.hxx:39
bool IsMarkHintHidden(SwRootFrame const &rLayout, SwTextNode const &rNode, SwTextAttrEnd const &rHint)
Definition: reffld.cxx:1102
bool operator<=(const CompareNodeContent &rCmp) const
Definition: doctxm.cxx:211
void SetAttrSet(const SfxItemSet &)
Definition: doctxm.cxx:2045
std::vector< SwSection * > SwSections
Definition: section.hxx:42
bool IsInMailMerge() const
Definition: doc.hxx:953
sal_uLong nNode
Definition: doctxm.cxx:198
sal_uLong GetIndex() const
Definition: node.hxx:282
OUString const & GetSecondaryKeyReading() const
Definition: tox.hxx:628
SwNode & GetEndOfAutotext() const
Section for all Flys/Header/Footers.
Definition: ndarr.hxx:157
Represents the style of a paragraph.
Definition: fmtcol.hxx:55
std::unique_ptr< SwDefTOXBase_Impl > mpDefTOXBases
Definition: doc.hxx:246
Marks a position in the document model.
Definition: pam.hxx:35
SwTOXElement GetCreateType() const
Definition: tox.hxx:671
bool IsInDocBody() const
Definition: frame.hxx:919
SwTOIOptions GetOptions() const
Definition: tox.hxx:710
SwOLENode * GetOLENode()
Inline methods from Node.hxx.
Definition: ndole.hxx:161
sal_uLong StartOfSectionIndex() const
Definition: node.hxx:673
SwPageDesc * GetPageDesc()
Definition: fmtpdsc.hxx:62
const SwOLEObj & GetOLEObj() const
Definition: ndole.hxx:112
SwCharFormat * MakeCharFormat(const OUString &rFormatName, SwCharFormat *pDerivedFrom, bool bBroadcast=false)
Definition: docfmt.cxx:835
const OUString & GetText() const
Definition: ndtxt.hxx:210
virtual const SwRootFrame * GetCurrentLayout() const =0
static void CheckPageDescs(SwPageFrame *pStart, bool bNotifyFields=true, SwPageFrame **ppPrev=nullptr)
Check all pages (starting from the given one) if they use the right frame format. ...
Definition: pagechg.cxx:1002
virtual bool get(DocumentSettingId id) const override
Return the specified document setting.
OUString const & GetPrimaryKey() const
Definition: tox.hxx:604
SwDocShell * GetDocShell()
Definition: doc.hxx:1342
bool IsProtected() const
Definition: tox.hxx:502
SwpHints * GetpSwpHints()
Definition: ndtxt.hxx:218
Definition: toxe.hxx:25
const SwFrameFormats * GetTableFrameFormats() const
Definition: doc.hxx:807
void DelSectionFormat(SwSectionFormat *pFormat, bool bDelNodes=false)
Definition: ndsect.cxx:512
virtual SwFieldType * GetFieldType(SwFieldIds nResId, const OUString &rName, bool bDbFieldMatching) const =0
static SwTOXBase * GetCurTOX(const SwPosition &rPos)
Get current table of contents.
Definition: doctxm.cxx:442
SwTOOElements
Definition: tox.hxx:373
Definition: tox.hxx:276
SwNodeIndex nNode
Definition: pam.hxx:37
const SwTOXType * InsertTOXType(const SwTOXType &rTyp)
Definition: doctxm.cxx:623
void InsertAlphaDelimiter(const SwTOXInternational &rIntl)
Definition: doctxm.cxx:1075
SvxBreak GetBreak() const
SwTextFormatColl * FindTextFormatCollByName(const OUString &rName) const
Definition: doc.hxx:795
void SetSectionName(OUString const &rName)
Definition: section.hxx:170
const SwTextNode * GetBodyTextNode(const SwDoc &rDoc, SwPosition &rPos, const SwFrame &rFrame)
Forward declaration: get "BodyTextNode" for exp.fld in Fly's headers/footers/footnotes.
Definition: expfld.cxx:163
static bool lcl_HasMainEntry(const std::vector< sal_uInt16 > *pMainEntryNums, sal_uInt16 nToFind)
Replace the PageNumber place holders.
Definition: doctxm.cxx:1703
SwHistory & GetHistory()
virtual void SetModified()=0
Must be called manually at changes of format.
sal_uInt16 GetType() const
Definition: txmsrt.hxx:142
sal_uIntPtr sal_uLong
std::vector< SwTOXMark * > SwTOXMarks
Definition: tox.hxx:44
Subgroup user indices.
Definition: poolfmt.hxx:382
OUString const & GetTemplate(sal_uInt16 nLevel) const
Definition: tox.hxx:642
#define SO3_SIMPRESS_CLASSID_30
#define RES_CONTENT_VISIBLE
Definition: hintids.hxx:309
#define SO3_SIMPRESS_CLASSID_60
const SwPageDesc * FindPageDesc(size_t *pPgDescNdIdx=nullptr) const
Search PageDesc with which this node is formatted.
Definition: node.cxx:464
virtual sal_uInt16 GetLevel() const =0
#define SO3_SCH_CLASSID_30
css::uno::Reference< css::embed::XEmbeddedObject > const & GetOleRef()
Definition: ndole.cxx:913
#define TOX_STYLE_DELIMITER
Definition: tox.hxx:386
SwContentFrame * getLayoutFrame(const SwRootFrame *, const SwPosition *pPos=nullptr, std::pair< Point, bool > const *pViewPosAndCalcFrame=nullptr) const
Definition: node.cxx:1147
virtual SwUndoId EndUndo(SwUndoId const eUndoId, SwRewriter const *const pRewriter)=0
Closes undo block.
Definition: doc.hxx:185
void TitleSectionInserted(SwSectionFormat &rSectionFormat)
Definition: unsect.cxx:541
static void InsertTOXMarks(SwTOXMarks &aMarks, const SwTOXType &rType)
Definition: tox.cxx:187
TElementType * Next()
Definition: calbck.hxx:373
This class generates text for the entries of a table of x.
tuple args
TextFrameIndex GetOfst() const
Definition: txtfrm.hxx:426
WW8LvlType GetNumType(sal_uInt8 nWwLevelNo)
Definition: ww8par2.cxx:874
#define SO3_SDRAW_CLASSID_50
bool IsHiddenByParaField() const
is the paragraph visible?
Definition: ndtxt.hxx:708
bool IsUpdateTOX() const
Definition: doc.hxx:945
virtual void DeleteRange(SwPaM &)=0
Delete a range SwFlyFrameFormat.
static SwContentNode * GoPrevious(SwNodeIndex *)
Definition: nodes.cxx:1288
bool HasDummyChar() const
Definition: txatbase.hxx:101
SwNode & GetNode() const
Definition: ndindex.hxx:119
void UpdateTemplate(const SwTextNode *pOwnChapterNode, SwRootFrame const *pLayout)
Generate table of contents from template areas.
Definition: doctxm.cxx:1262
SwSectionFormat * GetFormat()
Definition: section.hxx:336
bool IsTOXBaseInReadonly() const
Definition: doctxm.cxx:2013
IDocumentUndoRedo & GetIDocumentUndoRedo()
Definition: doc.cxx:143
#define SO3_SC_CLASSID_40
const SwTOXType * GetTOXType() const
Definition: tox.hxx:542
#define RES_TXTATR_CHARFMT
Definition: hintids.hxx:143
sal_uInt16 Which() const
Definition: txatbase.hxx:110
static const SwAttrSet & GetTOXBaseAttrSet(const SwTOXBase &rTOX)
Definition: doctxm.cxx:462
sal_uInt16 nLevel
Definition: tox.hxx:406
#define FORM_SECONDARY_KEY
Definition: tox.hxx:172
IDocumentContentOperations const & getIDocumentContentOperations() const
Definition: doc.cxx:314
bool HasWriterListeners() const
Definition: calbck.hxx:208
The root element of a Writer document layout.
Definition: rootfrm.hxx:79
OUString GetFollowingText(bool bMorePages) const
Definition: txmsrt.cxx:127
bool SetTOXBaseName(const SwTOXBase &rTOXBase, const OUString &rName)
Definition: doctxm.cxx:699
const SwSection & GetSection() const
Definition: node.hxx:541
IDocumentFieldsAccess const & getIDocumentFieldsAccess() const
Definition: doc.cxx:356
bool operator>=(const CompareNodeContent &rCmp) const
Definition: doctxm.cxx:217
#define SO3_SCH_CLASSID_40
void Delete(const SwNodeIndex &rPos, sal_uLong nNodes=1)
delete nodes
Definition: nodes.cxx:1061
OUString const & GetPrimaryKeyReading() const
Definition: tox.hxx:622
bool IsAssignedToListLevelOfOutlineStyle() const
Definition: fmtcol.hxx:109
static SwTOOElements lcl_IsSOObject(const SvGlobalName &rFactoryNm)
Definition: doctxm.cxx:1389
const SwTOXType * GetTOXType() const
Definition: tox.hxx:668
const SvxFormatBreakItem & GetBreak(bool=true) const
Definition: frmatr.hxx:62
#define CH_TXTATR_INWORD
Definition: hintids.hxx:44
SwTOXBaseSection * InsertTableOf(const SwPosition &rPos, const SwTOXBase &rTOX, const SfxItemSet *pSet=nullptr, bool bExpand=false, SwRootFrame const *pLayout=nullptr)
Definition: doctxm.cxx:340
const SwTOXMark & GetTOXMark() const
Definition: txatbase.hxx:212
SwIndex nContent
Definition: pam.hxx:38
#define SO3_SC_CLASSID_30
SwSectionNode * GetSectionNode()
Definition: section.cxx:1000
const OUString S_PAGE_DELI
IDocumentStylePoolAccess const & getIDocumentStylePoolAccess() const
Definition: doc.cxx:425
SwTOXSearch
Definition: toxe.hxx:22
virtual bool equivalent(const SwTOXSortTabBase &)
Definition: txmsrt.cxx:203
SwBreakIt * g_pBreakIt
Definition: breakit.cxx:33
SwTOIKeyType
Definition: toxe.hxx:30
bool IsEqual(const TextAndReading &rTaR1, const css::lang::Locale &rLocale1, const TextAndReading &rTaR2, const css::lang::Locale &rLocale2) const
Definition: txmsrt.hxx:92
sal_uLong GetIndex() const
Definition: ndindex.hxx:152
Content 6th level.
Definition: poolfmt.hxx:389
bool IsTextFrame() const
Definition: frame.hxx:1210
sal_Int32 GetStart() const
Definition: txatbase.hxx:82
const sal_uInt8 MAXLEVEL
Definition: swtypes.hxx:95
static SW_DLLPUBLIC sal_uInt16 GetPoolIdFromUIName(const OUString &rName, SwGetPoolIdFromName)
const SwTextNode * pTOXNd
Definition: txmsrt.hxx:127
SwTextAttr * InsertItem(SfxPoolItem &rAttr, const sal_Int32 nStart, const sal_Int32 nEnd, const SetAttrMode nMode=SetAttrMode::DEFAULT)
create new text attribute from rAttr and insert it
Definition: thints.cxx:1226
SwSection * InsertSwSection(SwPaM const &rRange, SwSectionData &, std::pair< SwTOXBase const *, sw::RedlineMode > const *pTOXBase, SfxItemSet const *const pAttr, bool const bUpdate=true)
Definition: ndsect.cxx:151
bool DeleteTOX(const SwTOXBase &rTOXBase, bool bDelNodes)
Delete table of contents.
Definition: doctxm.cxx:518
sal_uInt16 GetTOXTypeCount(TOXTypes eTyp) const
Manage table of content types.
Definition: doctxm.cxx:605
bool IsProtectFlag() const
Definition: section.hxx:189
Travel between table of content Marks.
Definition: doctxm.cxx:196
const OUString & GetSequenceName() const
Definition: tox.hxx:505
#define SO3_SC_CLASSID_60
SwSectionFormat * MakeSectionFormat()
Definition: ndsect.cxx:505
OUString ToUpper(const OUString &rStr, sal_Int32 nPos) const
Definition: txmsrt.cxx:102
#define SO3_SCH_CLASSID_60
SwTOOElements GetOLEOptions() const
Definition: tox.hxx:478
virtual bool DoesUndo() const =0
Is Undo enabled?
bool operator>(const CompareNodeContent &rCmp) const
Definition: doctxm.cxx:214
bool operator<(const CompareNodeContent &rCmp) const
Definition: doctxm.cxx:208
OUString maMSTOCExpression
Definition: tox.hxx:422
void SetProgressState(long nPosition, SwDocShell const *pDocShell)
Definition: mainwn.cxx:78
Specific frame formats (frames, DrawObjects).
Definition: docary.hxx:201
sal_uInt16 GetSeqNumber() const
Definition: expfld.hxx:243
SwNode & GetEndOfContent() const
Regular ContentSection (i.e. the BodyText).
Definition: ndarr.hxx:164
#define SO3_SC_CLASSID_50
sal_uInt16 GetVirtPageNum() const
Definition: trvlfrm.cxx:1805
object index.
Definition: poolfmt.hxx:400
void UpdatePageNum()
Calculate PageNumber and insert after formatting.
Definition: doctxm.cxx:1592
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:136
Range GetKeyRange(const OUString &rStr, const OUString &rStrReading, const SwTOXSortTabBase &rNew, sal_uInt16 nLevel, const Range &rRange)
Find Key Range and insert if possible.
Definition: doctxm.cxx:1959
const SwAttrSet * GetpSwAttrSet() const
Definition: node.hxx:443
bool Move(SwMoveFnCollection const &fnMove=fnMoveForward, SwGoInDoc fnGo=GoInContent)
Movement of cursor.
Definition: pam.cxx:485
static sal_Int32 GetReferenceTextPos(const SwFormatField &rFormat, SwDoc &rDoc, sal_Int32 nHint=0)
Find the index of the reference text following the current field.
Definition: expfld.cxx:974
#define SO3_SM_CLASSID_50
#define SO3_SCH_CLASSID_50
static SwTable * FindTable(SwFrameFormat const *const pFormat)
Definition: swtable.cxx:1920
virtual void AppendUndo(std::unique_ptr< SwUndo > pUndo)=0
Add new Undo action.
std::vector< std::unique_ptr< SwTOXSortTabBase > > m_aSortArr
Definition: doctxm.hxx:36
size_t Count() const
Definition: ndhints.hxx:142
void DeRegister()
deregister the currently registered History
Definition: ndhints.hxx:197
virtual SwUndoId StartUndo(SwUndoId const eUndoId, SwRewriter const *const pRewriter)=0
Opens undo block.
#define SAL_MAX_INT32
const SwContentFrame * GetFollow() const
Definition: cntfrm.hxx:114
SwTextAttr * Get(size_t nPos) const
Definition: ndhints.hxx:144
SwTOXBaseSection(SwTOXBase const &rBase, SwSectionFormat &rFormat)
Definition: doctxm.cxx:737
std::unique_ptr< SwTOXTypes > mpTOXTypes
Definition: doc.hxx:245
SwTOXElement
Definition: tox.hxx:328
const SwStartNode * StartOfSectionNode() const
Definition: node.hxx:131
const OUString & GetSectionName() const
Definition: section.hxx:169
const SwPosition * GetPoint() const
Definition: pam.hxx:207
std::vector< SwSectionFormat * >::size_type size_type
Definition: docary.hxx:70
void UpdateOutline(const SwTextNode *pOwnChapterNode, SwRootFrame const *pLayout)
Generate table of contents from outline.
Definition: doctxm.cxx:1235
SwIndex & Assign(SwIndexReg *, sal_Int32)
Definition: index.cxx:198
const SwPageDesc & GetPageDesc(const size_t i) const
Definition: doc.hxx:877
void SetProtect(bool const bFlag=true)
Definition: section.cxx:375
SwPageFrame * FindPageFrame()
Definition: frame.hxx:658
Text body.
Definition: poolfmt.hxx:251
OUString sName
TextFrameIndex MapModelToView(MergedPara const &, SwTextNode const *pNode, sal_Int32 nIndex)
Definition: txtfrm.cxx:1182
TElementType * First()
Definition: calbck.hxx:342
int i
bool IsFromObjectNames() const
Definition: tox.hxx:496
bool IsHiddenFlag() const
Definition: section.hxx:188
virtual bool DeleteRedline(const SwPaM &rPam, bool bSaveInUndo, RedlineType nDelType)=0
SwPageDesc * GetPageDesc()
Definition: pagefrm.hxx:129
bool SetPosAtStartEnd(SwPosition &rPos) const
Definition: doctxm.cxx:749
SwContentNode * GetContentNode()
Definition: node.hxx:615
#define SO3_SIMPRESS_CLASSID_40
SwDoc * GetDoc()
Definition: node.hxx:702
void UpdateNumRule()
Definition: docnum.cxx:2585
OUString GetText(SwRootFrame const *pLayout) const
Definition: tox.cxx:168
Marks a character position inside a document model node.
Definition: index.hxx:37
void UpdateTable(const SwTextNode *pOwnChapterNode, SwRootFrame const *pLayout)
Collect table entries.
Definition: doctxm.cxx:1539
const OUString & GetTypeName() const
Definition: tox.hxx:660
const SwTextNode * GetpTextNd() const
Definition: txttxmrk.hxx:44
IDocumentState const & getIDocumentState() const
Definition: doc.cxx:393
std::set< SwRootFrame * > GetAllLayouts()
Definition: doclay.cxx:1660
Definition: toxe.hxx:24
size
#define RES_TXTATR_TOXMARK
Definition: hintids.hxx:138
void GetTOIKeys(SwTOIKeyType eTyp, std::vector< OUString > &rArr, SwRootFrame const &rLayout) const
Definition: doctxm.cxx:83
const SwTOXInternational * pTOXIntl
Definition: txmsrt.hxx:129
Marks a node in the document model.
Definition: ndindex.hxx:31
const SwOutlineNodes & GetOutLineNds() const
Array of all OutlineNodes.
Definition: ndarr.hxx:234
SwNodes & GetNodes()
Node is in which nodes-array/doc?
Definition: node.hxx:693
SwTextFormatColl * GetTextFormatColl(sal_uInt16 nLevel)
Evaluate Template.
Definition: doctxm.cxx:1118
static std::enable_if<!std::is_array< T >::value, std::unique_ptr< T > >::type MakeSwTOXSortTabBase(SwRootFrame const *const pLayout, Args &&...args)
Definition: doctxm.cxx:76
OUString newName(const OUString &aNewPrefix, const OUString &aOldPrefix, const OUString &old_Name)
bool HasSwAttrSet() const
Definition: node.hxx:444
void Register(SwRegHistory *pHist)
register a History, which receives all attribute changes (for Undo)
Definition: ndhints.hxx:195
SectionType
Definition: section.hxx:46
void UpdateAuthorities(const SwTOXInternational &rIntl, SwRootFrame const *pLayout)
Definition: doctxm.cxx:1351
const SwDoc * GetDoc() const
The document is set in SwAttrPool now, therefore you always can access it.
Definition: format.hxx:119
bool IsFromChapter() const
Definition: tox.hxx:493
sal_uInt16 GetLevel() const
Definition: tox.hxx:704
A page of the document layout.
Definition: pagefrm.hxx:40
const SwTOXMark & GotoTOXMark(const SwTOXMark &rCurTOXMark, SwTOXSearch eDir, bool bInReadOnly)
Definition: doctxm.cxx:222
const OUString & GetTitle() const
Definition: tox.hxx:674
virtual ~SwTOXBaseSection() override
Definition: doctxm.cxx:745
bool IsInReading() const
Definition: doc.hxx:950
IDocumentLayoutAccess const & getIDocumentLayoutAccess() const
Definition: doc.cxx:404
SwCaptionDisplay GetCaptionDisplay() const
Definition: tox.hxx:508
SwTable is one table in the document model, containing rows (which contain cells).
Definition: swtable.hxx:110
bool IsReadOnly() const
const sal_Unicode C_END_PAGE_NUM
Definition: tox.cxx:47
void UpdateSequence(const SwTextNode *pOwnChapterNode, SwRootFrame const *pLayout)
Generate content from sequence fields.
Definition: doctxm.cxx:1305
const OUString & GetSortAlgorithm() const
Definition: tox.hxx:519
void DeleteAttribute(SwTextAttr *const pTextAttr)
delete the attribute pTextAttr
Definition: thints.cxx:1637
user index 6..10.
Definition: poolfmt.hxx:412
virtual bool SetFormatAttr(const SfxPoolItem &rAttr)
Definition: format.cxx:458
std::unique_ptr< SwSectionFormats > mpSectionFormatTable
Definition: doc.hxx:240
void RestoreUpperFrames(SwNodes &rNds, sal_uLong nStt, sal_uLong nEnd)
Definition: node2lay.cxx:438
bool IsOleRef() const
To avoid unnecessary loading of object.
Definition: ndole.cxx:908
const SwTextNode & GetTextNode() const
Definition: txttxmrk.hxx:49
illustrations index.
Definition: poolfmt.hxx:396
void EraseText(const SwIndex &rIdx, const sal_Int32 nCount=SAL_MAX_INT32, const SwInsertFlags nMode=SwInsertFlags::DEFAULT)
delete text content ATTENTION: must not be called with a range that overlaps the start of an attribut...
Definition: ndtxt.cxx:2668
OUString InsertText(const OUString &rStr, const SwIndex &rIdx, const SwInsertFlags nMode=SwInsertFlags::DEFAULT)
insert text content
Definition: ndtxt.cxx:2285
SwCharFormat * FindCharFormatByName(const OUString &rName) const
Definition: doc.hxx:767
long Max() const
const css::lang::Locale & GetLocale(const LanguageType aLang)
Definition: breakit.hxx:67
sal_uLong EndOfSectionIndex() const
Definition: node.hxx:677
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:79
void DeleteTOXMark(const SwTOXMark *pTOXMark)
Delete table of contents Mark.
Definition: doctxm.cxx:152
OUString sText
Definition: txmsrt.hxx:60
IDocumentRedlineAccess const & getIDocumentRedlineAccess() const
Definition: doc.cxx:334
bool IsRelTabPos() const
Definition: tox.hxx:307
#define SO3_SIMPRESS_CLASSID_50
void SetTOXName(const OUString &rSet)
Definition: tox.hxx:442
SwCharFormat * GetCharFormat() const
Definition: fchrfmt.hxx:70
const SwStartNode * GetSttNd() const
Definition: swtable.hxx:439
CompareNodeContent(sal_uLong nNd, sal_Int32 nCnt)
Definition: doctxm.cxx:201
const SwTextNode * FindOutlineNodeOfLevel(sal_uInt8 nLvl, SwRootFrame const *pLayout=nullptr) const
Definition: node.cxx:762
virtual bool SetAttr(const SfxPoolItem &)
made virtual
Definition: node.cxx:1484
An SwTextAttr container, stores all directly formatted text portions for a text node.
Definition: ndhints.hxx:67
void InsertSorted(std::unique_ptr< SwTOXSortTabBase > pBase)
Definition: doctxm.cxx:1872
void Update(const SfxItemSet *pAttr=nullptr, SwRootFrame const *pLayout=nullptr, const bool _bNewTOX=false)
Collect table of contents content.
Definition: doctxm.cxx:764
OUString GetUniqueTOXBaseName(const SwTOXType &rType, const OUString &sChkStr) const
Definition: doctxm.cxx:630
void CorrAbs(const SwNodeIndex &rOldNode, const SwPosition &rNewPos, const sal_Int32 nOffset=0, bool bMoveCursor=false)
Definition: doccorr.cxx:162
bool IsFieldDeletedInModel(IDocumentRedlineAccess const &rIDRA, SwTextField const &rTextField)
OUString const & GetSecondaryKey() const
Definition: tox.hxx:610
static const SwTextNode * lcl_FindChapterNode(const SwNode &rNd, SwRootFrame const *const pLayout, sal_uInt8 const nLvl=0)
Definition: doctxm.cxx:715
unsigned char sal_uInt8
static sal_uInt16 GetCurTOXMark(const SwPosition &rPos, SwTOXMarks &)
Get current table of contents Mark.
Definition: doctxm.cxx:114
TOXTypes GetType() const
Definition: tox.hxx:695
const o3tl::enumarray< SvxAdjust, unsigned short > aSvxToUnoAdjust USHRT_MAX
Definition: unosett.cxx:261
SwMoveFnCollection const & fnMoveForward
SwPam::Move()/Find() default argument.
Definition: paminit.cxx:59
sal_Int32 nContent
Definition: doctxm.cxx:199
OUString const & GetStyleNames(sal_uInt16 nLevel) const
Definition: tox.hxx:483
#define SO3_SM_CLASSID_40
bool mbKeepExpression
Definition: tox.hxx:423
sal_Int32 GetIndex() const
Definition: index.hxx:95
OString DateTimeToOString(const DateTime &rDateTime)
LanguageType GetLanguage() const
Definition: tox.hxx:516
bool IsCommaSeparated() const
Definition: tox.hxx:310
bool operator==(const CompareNodeContent &rCmp) const
Definition: doctxm.cxx:204
SwNodes & GetNodes()
Definition: doc.hxx:402
virtual SwTextFormatColl * GetTextCollFromPool(sal_uInt16 nId, bool bRegardLanguage=true)=0
Return "Auto-Collection with ID.
::sw::DocumentSettingManager & GetDocumentSettingManager()
Definition: doc.cxx:185
LanguageType GetLang(const sal_Int32 nBegin, const sal_Int32 nLen=0, sal_uInt16 nScript=0) const
Definition: thints.cxx:3367
const SwModify * GetRegisteredIn() const
Definition: calbck.hxx:157
const sal_Int32 * End() const
Definition: txatbase.hxx:148
SwTableBox is one table cell in the document model.
Definition: swtable.hxx:386
#define FORM_ALPHA_DELIMITER
Definition: tox.hxx:170
void PaMCorrAbs(const SwPaM &rRange, const SwPosition &rNewPos)
Function declarations so that everything below the CursorShell can move the Cursor once in a while...
Definition: doccorr.cxx:85
bool operator!=(const CompareNodeContent &rCmp) const
Definition: doctxm.cxx:206
#define FORM_ENTRY
Definition: tox.hxx:173
tables index.
Definition: poolfmt.hxx:404
bool IsHideRedlines() const
Replacement for sw::DocumentRedlineManager::GetRedlineFlags() (this is layout-level redline hiding)...
Definition: rootfrm.hxx:416
const SvxPageUsage aArr[]
virtual bool AppendTextNode(SwPosition &rPos)=0
virtual bool GetInfo(SfxPoolItem &rInfo) const override
Definition: doctxm.cxx:2052
const OUString & GetMainEntryCharStyle() const
Definition: tox.hxx:462
TOXTypes GetType() const
Definition: tox.hxx:663
const SwAttrSet & GetSwAttrSet() const
Does node has already its own auto-attributes? Access to SwAttrSet.
Definition: node.hxx:723
SwMoveFnCollection const & fnMoveBackward
Definition: paminit.cxx:58
const char cSequenceMarkSeparator
Definition: swtypes.hxx:139
void UpdatePageNum_(SwTextNode *pNd, const std::vector< sal_uInt16 > &rNums, const std::vector< SwPageDesc * > &rDescs, const std::vector< sal_uInt16 > *pMainEntryNums, const SwTOXInternational &rIntl)
Definition: doctxm.cxx:1714
SwTableNode * FindTableNode()
Search table node, in which it is.
Definition: node.cxx:349
void ChgFormat(SwFormat &rFormat, const SfxItemSet &rSet)
Definition: docfmt.cxx:1846
OString const aName
void UpdateMarks(const SwTOXInternational &rIntl, const SwTextNode *pOwnChapterNode, SwRootFrame const *pLayout)
Create from Marks.
Definition: doctxm.cxx:1168
static bool IsInHiddenRange(const SwTextNode &rNode, sal_Int32 nPos)
Definition: porlay.cxx:1660
static SwTOIOptions GetOptions()
Definition: txmsrt.hxx:143
#define FORM_PRIMARY_KEY
Definition: tox.hxx:171
void DelFlyInRange(const SwNodeIndex &rMkNdIdx, const SwNodeIndex &rPtNdIdx, SwIndex const *const pMkIdx, SwIndex const *const pPtIdx)
Delete and move all Flys at the paragraph, that are within the selection.
Definition: docedt.cxx:214
bool IsDocNodes() const
Is the NodesArray the regular one of Doc? (and not the UndoNds, ...) Implementation in doc...
Definition: nodes.cxx:2334
Subgroup index tables.
Definition: poolfmt.hxx:367
Subgroup table of contents.
Definition: poolfmt.hxx:374
SwSectionNode * GetSectionNode()
Definition: node.hxx:607
const SwTextTOXMark * GetTextTOXMark() const
Definition: tox.hxx:137
virtual bool GetInfo(SfxPoolItem &) const override
Definition: section.cxx:833
long Min() const
SectionType GetType() const
Definition: section.hxx:171
const SwTOXType * GetTOXType(TOXTypes eTyp, sal_uInt16 nId) const
Definition: doctxm.cxx:614
const SwAttrSet & GetAttrSet() const
For querying the attribute array.
Definition: format.hxx:116
const SwFormatPageDesc & GetPageDesc(bool=true) const
Definition: fmtpdsc.hxx:79
const SwForm & GetTOXForm() const
Definition: tox.hxx:686
SwTextNode & GetTextNode() const
Definition: txtfld.hxx:53
const SwFormatCharFormat & GetCharFormat() const
Definition: txatbase.hxx:179
#define SO3_SDRAW_CLASSID_60
int GetAttrOutlineLevel() const
Definition: fmtcol.cxx:582
SwNode & GetEndOfExtras() const
This is the last EndNode of a special section.
Definition: ndarr.hxx:162
void SetDefaultTOXBase(const SwTOXBase &rBase)
Definition: doctxm.cxx:497
TextAndReading const & GetText() const
Definition: txmsrt.hxx:176
#define FORM_TITLE
Definition: tox.hxx:169
index of authorities.
Definition: poolfmt.hxx:408
sal_uInt16 const aBreakSetRange[]
Definition: init.cxx:142
void GetChildSections(SwSections &rArr, SectionSort eSort=SectionSort::Not, bool bAllSections=true) const
Definition: section.cxx:880
#define SO3_SM_CLASSID_30
virtual bool sort_lt(const SwTOXSortTabBase &)
Definition: txmsrt.cxx:229
sal_Int32 nPos
Class for sorting directories.
Definition: txmsrt.hxx:120
Merge GetRedlineMergeFlag() const
Definition: node.hxx:97
SwContentNode * GoNext(SwNodeIndex *) const
Definition: nodes.cxx:1271
void UpdateContent(SwTOXElement eType, const SwTextNode *pOwnChapterNode, SwRootFrame const *pLayout)
Definition: doctxm.cxx:1433
std::vector< SwTOXSource > aTOXSources
Definition: txmsrt.hxx:125
const SwTOXBase * GetDefaultTOXBase(TOXTypes eTyp, bool bCreate)
Definition: doctxm.cxx:471
sal_uInt16 Which() const
bool IsLevelFromChapter() const
Definition: tox.hxx:499
const SwAttrPool & GetAttrPool() const
Definition: doc.hxx:1309
const OUString & GetTOXName() const
Definition: tox.hxx:441
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
Definition: ndtxt.hxx:842
SwTextNode * MakeTextNode(const SwNodeIndex &rWhere, SwTextFormatColl *pColl, bool bNewFrames=true)
Implementations of "Make...Node" are in the given .cxx-files.
Definition: ndtxt.cxx:114
bool IsProtected() const
Is the Frame or rather the Section in which it lies protected?
Definition: trvlfrm.cxx:1621
Base class of the Writer document model elements.
Definition: node.hxx:79
SwTextFormatColl * GetTextColl() const
Definition: ndtxt.hxx:836