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