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