LibreOffice Module sw (master)  1
docfmt.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 <libxml/xmlwriter.h>
21 #include <hintids.hxx>
22 #include <svl/itemiter.hxx>
23 #include <editeng/tstpitem.hxx>
24 #include <editeng/lrspitem.hxx>
26 #include <editeng/rsiditem.hxx>
27 #include <editeng/colritem.hxx>
28 #include <svl/zforlist.hxx>
31 #include <unotools/configmgr.hxx>
32 #include <unotools/misccfg.hxx>
33 #include <sal/log.hxx>
34 #include <com/sun/star/i18n/WordType.hpp>
35 #include <com/sun/star/i18n/XBreakIterator.hpp>
36 #include <fmtpdsc.hxx>
37 #include <fmthdft.hxx>
38 #include <fmtcntnt.hxx>
39 #include <doc.hxx>
40 #include <docfunc.hxx>
41 #include <drawdoc.hxx>
42 #include <MarkManager.hxx>
44 #include <IDocumentUndoRedo.hxx>
47 #include <IDocumentState.hxx>
50 #include <rootfrm.hxx>
51 #include <txtfrm.hxx>
52 #include <hints.hxx>
53 #include <ndtxt.hxx>
54 #include <pam.hxx>
55 #include <UndoCore.hxx>
56 #include <UndoAttribute.hxx>
57 #include <UndoInsert.hxx>
58 #include <pagedesc.hxx>
59 #include <rolbck.hxx>
60 #include <mvsave.hxx>
61 #include <txatbase.hxx>
62 #include <swtblfmt.hxx>
63 #include <charfmt.hxx>
64 #include <docary.hxx>
65 #include <paratr.hxx>
66 #include <redline.hxx>
67 #include <reffld.hxx>
68 #include <fmtinfmt.hxx>
69 #include <breakit.hxx>
70 #include <SwUndoFmt.hxx>
71 #include <UndoManager.hxx>
72 #include <swmodule.hxx>
73 #include <modcfg.hxx>
74 #include <memory>
75 
76 using namespace ::com::sun::star::i18n;
77 using namespace ::com::sun::star::lang;
78 using namespace ::com::sun::star::uno;
79 
80 /*
81  * Internal functions
82  */
83 
84 static void SetTextFormatCollNext( SwTextFormatColl* pTextColl, const SwTextFormatColl* pDel )
85 {
86  if ( &pTextColl->GetNextTextFormatColl() == pDel )
87  {
88  pTextColl->SetNextTextFormatColl( *pTextColl );
89  }
90 }
91 
92 static bool lcl_RstAttr( const SwNodePtr& rpNd, void* pArgs )
93 {
95  SwContentNode* pNode = rpNd->GetContentNode();
96  if (pPara && pPara->pLayout && pPara->pLayout->IsHideRedlines()
97  && pNode && pNode->GetRedlineMergeFlag() == SwNode::Merge::Hidden)
98  {
99  return true;
100  }
101  if( pNode && pNode->HasSwAttrSet() )
102  {
103  const bool bLocked = pNode->IsModifyLocked();
104  pNode->LockModify();
105 
106  SwDoc* pDoc = pNode->GetDoc();
107 
108  // remove unused attribute RES_LR_SPACE
109  // add list attributes
110  SfxItemSet aSavedAttrsSet(
111  pDoc->GetAttrPool(),
112  svl::Items<
115  RES_PAGEDESC, RES_BREAK>{});
116  const SfxItemSet* pAttrSetOfNode = pNode->GetpSwAttrSet();
117 
118  std::vector<sal_uInt16> aClearWhichIds;
119  // restoring all paragraph list attributes
120  {
121  SfxItemSet aListAttrSet( pDoc->GetAttrPool(), svl::Items<RES_PARATR_LIST_BEGIN, RES_PARATR_LIST_END - 1>{} );
122  aListAttrSet.Set(*pAttrSetOfNode);
123  if ( aListAttrSet.Count() )
124  {
125  aSavedAttrsSet.Put(aListAttrSet);
126  SfxItemIter aIter( aListAttrSet );
127  const SfxPoolItem* pItem = aIter.GetCurItem();
128  while( pItem )
129  {
130  aClearWhichIds.push_back( pItem->Which() );
131  pItem = aIter.NextItem();
132  }
133  }
134  }
135 
136  const SfxPoolItem* pItem;
137 
138  sal_uInt16 const aSavIds[3] = { RES_PAGEDESC, RES_BREAK, RES_PARATR_NUMRULE };
139  for (sal_uInt16 aSavId : aSavIds)
140  {
141  if (SfxItemState::SET == pAttrSetOfNode->GetItemState(aSavId, false, &pItem))
142  {
143  bool bSave = false;
144  switch( aSavId )
145  {
146  case RES_PAGEDESC:
147  bSave = nullptr != static_cast<const SwFormatPageDesc*>(pItem)->GetPageDesc();
148  break;
149  case RES_BREAK:
150  bSave = SvxBreak::NONE != static_cast<const SvxFormatBreakItem*>(pItem)->GetBreak();
151  break;
152  case RES_PARATR_NUMRULE:
153  bSave = !static_cast<const SwNumRuleItem*>(pItem)->GetValue().isEmpty();
154  break;
155  }
156  if( bSave )
157  {
158  aSavedAttrsSet.Put(*pItem);
159  aClearWhichIds.push_back(aSavId);
160  }
161  }
162  }
163 
164  // do not clear items directly from item set and only clear to be kept
165  // attributes, if no deletion item set is found.
166  const bool bKeepAttributes =
167  !pPara || !pPara->pDelSet || pPara->pDelSet->Count() == 0;
168  if ( bKeepAttributes )
169  {
170  pNode->ResetAttr( aClearWhichIds );
171  }
172 
173  if( !bLocked )
174  pNode->UnlockModify();
175 
176  if( pPara )
177  {
178  SwRegHistory aRegH( pNode, *pNode, pPara->pHistory );
179 
180  if( pPara->pDelSet && pPara->pDelSet->Count() )
181  {
182  OSL_ENSURE( !bKeepAttributes,
183  "<lcl_RstAttr(..)> - certain attributes are kept, but not needed." );
184  SfxItemIter aIter( *pPara->pDelSet );
185  for (pItem = aIter.GetCurItem(); pItem; pItem = aIter.NextItem())
186  {
187  if ( ( pItem->Which() != RES_PAGEDESC &&
188  pItem->Which() != RES_BREAK &&
189  pItem->Which() != RES_PARATR_NUMRULE ) ||
190  ( aSavedAttrsSet.GetItemState( pItem->Which(), false ) != SfxItemState::SET ) )
191  {
192  pNode->ResetAttr( pItem->Which() );
193  }
194  }
195  }
196  else if( pPara->bResetAll )
197  pNode->ResetAllAttr();
198  else
199  pNode->ResetAttr( RES_PARATR_BEGIN, POOLATTR_END - 1 );
200  }
201  else
202  pNode->ResetAllAttr();
203 
204  // only restore saved attributes, if needed
205  if (bKeepAttributes && aSavedAttrsSet.Count())
206  {
207  pNode->LockModify();
208 
209  pNode->SetAttr(aSavedAttrsSet);
210 
211  if( !bLocked )
212  pNode->UnlockModify();
213  }
214  }
215  return true;
216 }
217 
218 void SwDoc::RstTextAttrs(const SwPaM &rRg, bool bInclRefToxMark,
219  bool bExactRange, SwRootFrame const*const pLayout)
220 {
221  SwHistory* pHst = nullptr;
222  SwDataChanged aTmp( rRg );
223  if (GetIDocumentUndoRedo().DoesUndo())
224  {
225  std::unique_ptr<SwUndoResetAttr> pUndo(new SwUndoResetAttr( rRg, RES_CHRFMT ));
226  pHst = &pUndo->GetHistory();
227  GetIDocumentUndoRedo().AppendUndo(std::move(pUndo));
228  }
229  const SwPosition *pStt = rRg.Start(), *pEnd = rRg.End();
231  pStt, pEnd, pHst, nullptr, pLayout );
232  aPara.bInclRefToxMark = bInclRefToxMark;
233  aPara.bExactRange = bExactRange;
234  GetNodes().ForEach( pStt->nNode.GetIndex(), pEnd->nNode.GetIndex()+1,
237 }
238 
239 void SwDoc::ResetAttrs( const SwPaM &rRg,
240  bool bTextAttr,
241  const std::set<sal_uInt16> &rAttrs,
242  const bool bSendDataChangedEvents,
243  SwRootFrame const*const pLayout)
244 {
245  SwPaM* pPam = const_cast<SwPaM*>(&rRg);
246  if( !bTextAttr && !rAttrs.empty() && RES_TXTATR_END > *(rAttrs.begin()) )
247  bTextAttr = true;
248 
249  if( !rRg.HasMark() )
250  {
251  SwTextNode* pTextNd = rRg.GetPoint()->nNode.GetNode().GetTextNode();
252  if( !pTextNd )
253  return ;
254 
255  pPam = new SwPaM( *rRg.GetPoint() );
256 
257  SwIndex& rSt = pPam->GetPoint()->nContent;
258  sal_Int32 nMkPos, nPtPos = rSt.GetIndex();
259 
260  // Special case: if the Cursor is located within a URL attribute, we take over it's area
261  SwTextAttr const*const pURLAttr(
262  pTextNd->GetTextAttrAt(rSt.GetIndex(), RES_TXTATR_INETFMT));
263  if (pURLAttr && !pURLAttr->GetINetFormat().GetValue().isEmpty())
264  {
265  nMkPos = pURLAttr->GetStart();
266  nPtPos = *pURLAttr->End();
267  }
268  else
269  {
270  assert(g_pBreakIt && g_pBreakIt->GetBreakIter().is());
271  Boundary aBndry = g_pBreakIt->GetBreakIter()->getWordBoundary(
272  pTextNd->GetText(), nPtPos,
273  g_pBreakIt->GetLocale( pTextNd->GetLang( nPtPos ) ),
274  WordType::ANY_WORD /*ANYWORD_IGNOREWHITESPACES*/,
275  true);
276 
277  if( aBndry.startPos < nPtPos && nPtPos < aBndry.endPos )
278  {
279  nMkPos = aBndry.startPos;
280  nPtPos = aBndry.endPos;
281  }
282  else
283  {
284  nPtPos = nMkPos = rSt.GetIndex();
285  if( bTextAttr )
286  pTextNd->DontExpandFormat( rSt );
287  }
288  }
289 
290  rSt = nMkPos;
291  pPam->SetMark();
292  pPam->GetPoint()->nContent = nPtPos;
293  }
294 
295  // #i96644#
296  std::unique_ptr< SwDataChanged > xDataChanged;
297  if ( bSendDataChangedEvents )
298  {
299  xDataChanged.reset( new SwDataChanged( *pPam ) );
300  }
301  SwHistory* pHst = nullptr;
302  if (GetIDocumentUndoRedo().DoesUndo())
303  {
304  std::unique_ptr<SwUndoResetAttr> pUndo(new SwUndoResetAttr( rRg,
305  bTextAttr ? sal_uInt16(RES_CONDTXTFMTCOLL) : sal_uInt16(RES_TXTFMTCOLL) ));
306  if( !rAttrs.empty() )
307  {
308  pUndo->SetAttrs( rAttrs );
309  }
310  pHst = &pUndo->GetHistory();
311  GetIDocumentUndoRedo().AppendUndo(std::move(pUndo));
312  }
313 
314  const SwPosition *pStt = pPam->Start(), *pEnd = pPam->End();
316  pStt, pEnd, pHst, nullptr, pLayout);
317 
318  // mst: not including META here; it seems attrs with CH_TXTATR are omitted
323  for( std::set<sal_uInt16>::const_reverse_iterator it = rAttrs.rbegin(); it != rAttrs.rend(); ++it )
324  {
325  if( POOLATTR_END > *it )
326  aDelSet.Put( *GetDfltAttr( *it ));
327  }
328  if( aDelSet.Count() )
329  aPara.pDelSet = &aDelSet;
330 
331  bool bAdd = true;
332  SwNodeIndex aTmpStt( pStt->nNode );
333  SwNodeIndex aTmpEnd( pEnd->nNode );
334  if( pStt->nContent.GetIndex() ) // just one part
335  {
336  // set up a later, and all CharFormatAttr -> TextFormatAttr
337  SwTextNode* pTNd = aTmpStt.GetNode().GetTextNode();
338  if( pTNd && pTNd->HasSwAttrSet() && pTNd->GetpSwAttrSet()->Count() )
339  {
340  if (pHst)
341  {
342  SwRegHistory history(pTNd, *pTNd, pHst);
343  pTNd->FormatToTextAttr(pTNd);
344  }
345  else
346  {
347  pTNd->FormatToTextAttr(pTNd);
348  }
349  }
350 
351  ++aTmpStt;
352  }
353  if( pEnd->nContent.GetIndex() == pEnd->nNode.GetNode().GetContentNode()->Len() )
354  {
355  // set up a later, and all CharFormatAttr -> TextFormatAttr
356  ++aTmpEnd;
357  bAdd = false;
358  }
359  else if( pStt->nNode != pEnd->nNode || !pStt->nContent.GetIndex() )
360  {
361  SwTextNode* pTNd = aTmpEnd.GetNode().GetTextNode();
362  if( pTNd && pTNd->HasSwAttrSet() && pTNd->GetpSwAttrSet()->Count() )
363  {
364  if (pHst)
365  {
366  SwRegHistory history(pTNd, *pTNd, pHst);
367  pTNd->FormatToTextAttr(pTNd);
368  }
369  else
370  {
371  pTNd->FormatToTextAttr(pTNd);
372  }
373  }
374  }
375 
376  if( aTmpStt < aTmpEnd )
377  GetNodes().ForEach( pStt->nNode, aTmpEnd, lcl_RstAttr, &aPara );
378  else if( !rRg.HasMark() )
379  {
380  aPara.bResetAll = false ;
381  ::lcl_RstAttr( &pStt->nNode.GetNode(), &aPara );
382  aPara.bResetAll = true ;
383  }
384 
385  if( bTextAttr )
386  {
387  if( bAdd )
388  ++aTmpEnd;
390  }
391 
393 
394  xDataChanged.reset(); //before delete pPam
395 
396  if( pPam != &rRg )
397  delete pPam;
398 }
399 
401 void SwDoc::UpdateRsid( const SwPaM &rRg, const sal_Int32 nLen )
402 {
403  if (!SW_MOD()->GetModuleConfig()->IsStoreRsid())
404  return;
405 
406  SwTextNode *pTextNode = rRg.GetPoint()->nNode.GetNode().GetTextNode();
407  if (!pTextNode)
408  {
409  return;
410  }
411  const sal_Int32 nStart(rRg.GetPoint()->nContent.GetIndex() - nLen);
413 
415  aSet.Put(aRsid);
416  bool const bRet(pTextNode->SetAttr(aSet, nStart,
417  rRg.GetPoint()->nContent.GetIndex()));
418 
419  if (bRet && GetIDocumentUndoRedo().DoesUndo())
420  {
421  SwUndo *const pLastUndo = GetUndoManager().GetLastUndo();
422  SwUndoInsert *const pUndoInsert(dynamic_cast<SwUndoInsert*>(pLastUndo));
423  // this function is called after Insert so expects to find SwUndoInsert
424  assert(pUndoInsert);
425  if (pUndoInsert)
426  {
427  pUndoInsert->SetWithRsid();
428  }
429  }
430 }
431 
432 bool SwDoc::UpdateParRsid( SwTextNode *pTextNode, sal_uInt32 nVal )
433 {
434  if (!SW_MOD()->GetModuleConfig()->IsStoreRsid())
435  return false;
436 
437  if (!pTextNode)
438  {
439  return false;
440  }
441 
442  SvxRsidItem aRsid( nVal ? nVal : mnRsid, RES_PARATR_RSID );
443  return pTextNode->SetAttr( aRsid );
444 }
445 
448 void SwDoc::SetAttr( const SfxPoolItem& rAttr, SwFormat& rFormat )
449 {
450  SfxItemSet aSet( GetAttrPool(), {{rAttr.Which(), rAttr.Which()}} );
451  aSet.Put( rAttr );
452  SetAttr( aSet, rFormat );
453 }
454 
457 void SwDoc::SetAttr( const SfxItemSet& rSet, SwFormat& rFormat )
458 {
459  if (GetIDocumentUndoRedo().DoesUndo())
460  {
461  SwUndoFormatAttrHelper aTmp( rFormat );
462  rFormat.SetFormatAttr( rSet );
463  if ( aTmp.GetUndo() )
464  {
466  }
467  else
468  {
470  }
471  }
472  else
473  {
474  rFormat.SetFormatAttr( rSet );
475  }
477 }
478 
479 void SwDoc::ResetAttrAtFormat( const sal_uInt16 nWhichId,
480  SwFormat& rChangedFormat )
481 {
482  std::unique_ptr<SwUndo> pUndo;
483  if (GetIDocumentUndoRedo().DoesUndo())
484  pUndo.reset(new SwUndoFormatResetAttr( rChangedFormat, nWhichId ));
485 
486  const bool bAttrReset = rChangedFormat.ResetFormatAttr( nWhichId );
487 
488  if ( bAttrReset )
489  {
490  if ( pUndo )
491  {
492  GetIDocumentUndoRedo().AppendUndo( std::move(pUndo) );
493  }
494 
496  }
497 }
498 
499 static bool lcl_SetNewDefTabStops( SwTwips nOldWidth, SwTwips nNewWidth,
500  SvxTabStopItem& rChgTabStop )
501 {
502  // Set the default values of all TabStops to the new value.
503  // Attention: we always work with the PoolAttribute here, so that
504  // we don't calculate the same value on the same TabStop (pooled!) for all sets.
505  // We send a FormatChg to modify.
506 
507  sal_uInt16 nOldCnt = rChgTabStop.Count();
508  if( !nOldCnt || nOldWidth == nNewWidth )
509  return false;
510 
511  // Find the default's beginning
512  sal_uInt16 n;
513  for( n = nOldCnt; n ; --n )
514  if( SvxTabAdjust::Default != rChgTabStop[n - 1].GetAdjustment() )
515  break;
516  ++n;
517  if( n < nOldCnt ) // delete the DefTabStops
518  rChgTabStop.Remove( n, nOldCnt - n );
519  return true;
520 }
521 
524 void SwDoc::SetDefault( const SfxPoolItem& rAttr )
525 {
526  SfxItemSet aSet( GetAttrPool(), {{rAttr.Which(), rAttr.Which()}} );
527  aSet.Put( rAttr );
528  SetDefault( aSet );
529 }
530 
531 void SwDoc::SetDefault( const SfxItemSet& rSet )
532 {
533  if( !rSet.Count() )
534  return;
535 
536  SwModify aCallMod;
537  SwAttrSet aOld( GetAttrPool(), rSet.GetRanges() ),
538  aNew( GetAttrPool(), rSet.GetRanges() );
539  SfxItemIter aIter( rSet );
540  const SfxPoolItem* pItem = aIter.GetCurItem();
541  SfxItemPool* pSdrPool = GetAttrPool().GetSecondaryPool();
542  do
543  {
544  bool bCheckSdrDflt = false;
545  const sal_uInt16 nWhich = pItem->Which();
546  aOld.Put( GetAttrPool().GetDefaultItem( nWhich ) );
547  GetAttrPool().SetPoolDefaultItem( *pItem );
548  aNew.Put( GetAttrPool().GetDefaultItem( nWhich ) );
549 
550  if (isCHRATR(nWhich) || isTXTATR(nWhich))
551  {
552  aCallMod.Add( mpDfltTextFormatColl.get() );
553  aCallMod.Add( mpDfltCharFormat.get() );
554  bCheckSdrDflt = nullptr != pSdrPool;
555  }
556  else if ( isPARATR(nWhich) ||
557  isPARATR_LIST(nWhich) )
558  {
559  aCallMod.Add( mpDfltTextFormatColl.get() );
560  bCheckSdrDflt = nullptr != pSdrPool;
561  }
562  else if (isGRFATR(nWhich))
563  {
564  aCallMod.Add( mpDfltGrfFormatColl.get() );
565  }
566  else if (isFRMATR(nWhich) || isDrawingLayerAttribute(nWhich) )
567  {
568  aCallMod.Add( mpDfltGrfFormatColl.get() );
569  aCallMod.Add( mpDfltTextFormatColl.get() );
570  aCallMod.Add( mpDfltFrameFormat.get() );
571  }
572  else if (isBOXATR(nWhich))
573  {
574  aCallMod.Add( mpDfltFrameFormat.get() );
575  }
576 
577  // also copy the defaults
578  if( bCheckSdrDflt )
579  {
580  sal_uInt16 nEdtWhich, nSlotId;
581  if( 0 != (nSlotId = GetAttrPool().GetSlotId( nWhich ) ) &&
582  nSlotId != nWhich &&
583  0 != (nEdtWhich = pSdrPool->GetWhich( nSlotId )) &&
584  nSlotId != nEdtWhich )
585  {
586  std::unique_ptr<SfxPoolItem> pCpy(pItem->Clone());
587  pCpy->SetWhich( nEdtWhich );
588  pSdrPool->SetPoolDefaultItem( *pCpy );
589  }
590  }
591 
592  pItem = aIter.NextItem();
593  } while (pItem);
594 
595  if( aNew.Count() && aCallMod.HasWriterListeners() )
596  {
598  {
599  GetIDocumentUndoRedo().AppendUndo( std::make_unique<SwUndoDefaultAttr>( aOld, this ) );
600  }
601 
602  const SfxPoolItem* pTmpItem;
603  if( ( SfxItemState::SET ==
604  aNew.GetItemState( RES_PARATR_TABSTOP, false, &pTmpItem ) ) &&
605  static_cast<const SvxTabStopItem*>(pTmpItem)->Count() )
606  {
607  // Set the default values of all TabStops to the new value.
608  // Attention: we always work with the PoolAttribute here, so that
609  // we don't calculate the same value on the same TabStop (pooled!) for all sets.
610  // We send a FormatChg to modify.
611  SwTwips nNewWidth = (*static_cast<const SvxTabStopItem*>(pTmpItem))[ 0 ].GetTabPos(),
612  nOldWidth = aOld.Get(RES_PARATR_TABSTOP)[ 0 ].GetTabPos();
613 
614  bool bChg = false;
615  for (const SfxPoolItem* pItem2 : GetAttrPool().GetItemSurrogates(RES_PARATR_TABSTOP))
616  {
617  auto pTabStopItem = dynamic_cast<const SvxTabStopItem*>(pItem2);
618  if(pTabStopItem)
619  bChg |= lcl_SetNewDefTabStops( nOldWidth, nNewWidth,
620  *const_cast<SvxTabStopItem*>(pTabStopItem) );
621  }
622 
623  aNew.ClearItem( RES_PARATR_TABSTOP );
624  aOld.ClearItem( RES_PARATR_TABSTOP );
625  if( bChg )
626  {
627  SwFormatChg aChgFormat( mpDfltCharFormat.get() );
628  // notify the frames
629  aCallMod.ModifyNotification( &aChgFormat, &aChgFormat );
630  }
631  }
632  }
633 
634  if( aNew.Count() && aCallMod.HasWriterListeners() )
635  {
636  SwAttrSetChg aChgOld( aOld, aOld );
637  SwAttrSetChg aChgNew( aNew, aNew );
638  aCallMod.ModifyNotification( &aChgOld, &aChgNew ); // all changed are sent
639  }
640 
641  // remove the default formats from the object again
642  SwIterator<SwClient, SwModify> aClientIter(aCallMod);
643  for(SwClient* pClient = aClientIter.First(); pClient; pClient = aClientIter.Next())
644  aCallMod.Remove( pClient );
645 
647 }
648 
650 const SfxPoolItem& SwDoc::GetDefault( sal_uInt16 nFormatHint ) const
651 {
652  return GetAttrPool().GetDefaultItem( nFormatHint );
653 }
654 
656 void SwDoc::DelCharFormat(size_t nFormat, bool bBroadcast)
657 {
658  SwCharFormat * pDel = (*mpCharFormatTable)[nFormat];
659 
660  if (bBroadcast)
661  BroadcastStyleOperation(pDel->GetName(), SfxStyleFamily::Char,
662  SfxHintId::StyleSheetErased);
663 
665  {
667  std::make_unique<SwUndoCharFormatDelete>(pDel, this));
668  }
669 
670  delete (*mpCharFormatTable)[nFormat];
671  mpCharFormatTable->erase(mpCharFormatTable->begin() + nFormat);
672 
674 }
675 
676 void SwDoc::DelCharFormat( SwCharFormat const *pFormat, bool bBroadcast )
677 {
678  size_t nFormat = mpCharFormatTable->GetPos( pFormat );
679  OSL_ENSURE( SIZE_MAX != nFormat, "Format not found," );
680  DelCharFormat( nFormat, bBroadcast );
681 }
682 
683 void SwDoc::DelFrameFormat( SwFrameFormat *pFormat, bool bBroadcast )
684 {
685  if( dynamic_cast<const SwTableBoxFormat*>( pFormat) != nullptr || dynamic_cast<const SwTableLineFormat*>( pFormat) != nullptr )
686  {
687  OSL_ENSURE( false, "Format is not in the DocArray any more, "
688  "so it can be deleted with delete" );
689  delete pFormat;
690  }
691  else
692  {
693  // The format has to be in the one or the other, we'll see in which one.
694  if (mpFrameFormatTable->ContainsFormat(*pFormat))
695  {
696  if (bBroadcast)
697  BroadcastStyleOperation(pFormat->GetName(),
698  SfxStyleFamily::Frame,
699  SfxHintId::StyleSheetErased);
700 
702  {
704  std::make_unique<SwUndoFrameFormatDelete>(pFormat, this));
705  }
706 
707  mpFrameFormatTable->erase( pFormat );
708  delete pFormat;
709  }
710  else
711  {
712  bool contains = GetSpzFrameFormats()->ContainsFormat(*pFormat);
713  OSL_ENSURE( contains, "FrameFormat not found." );
714  if( contains )
715  {
716  GetSpzFrameFormats()->erase( pFormat );
717  delete pFormat;
718  }
719  }
720  }
721 }
722 
724 {
726  OSL_ENSURE( it != mpTableFrameFormatTable->end(), "Format not found," );
727  mpTableFrameFormatTable->erase( it );
728  delete pFormat;
729 }
730 
732 SwFlyFrameFormat *SwDoc::MakeFlyFrameFormat( const OUString &rFormatName,
733  SwFrameFormat *pDerivedFrom )
734 {
735  SwFlyFrameFormat *pFormat = new SwFlyFrameFormat( GetAttrPool(), rFormatName, pDerivedFrom );
736  GetSpzFrameFormats()->push_back(pFormat);
738  return pFormat;
739 }
740 
741 SwDrawFrameFormat *SwDoc::MakeDrawFrameFormat( const OUString &rFormatName,
742  SwFrameFormat *pDerivedFrom )
743 {
744  SwDrawFrameFormat *pFormat = new SwDrawFrameFormat( GetAttrPool(), rFormatName, pDerivedFrom);
745  GetSpzFrameFormats()->push_back(pFormat);
747  return pFormat;
748 }
749 
750 size_t SwDoc::GetTableFrameFormatCount(bool bUsed) const
751 {
752  if (!bUsed)
753  {
754  return mpTableFrameFormatTable->size();
755  }
756 
757  SwAutoFormatGetDocNode aGetHt(&GetNodes());
758  size_t nCount = 0;
759  for (SwFrameFormat* const & pFormat : *mpTableFrameFormatTable)
760  {
761  if (!pFormat->GetInfo(aGetHt))
762  nCount++;
763  }
764  return nCount;
765 }
766 
767 SwFrameFormat& SwDoc::GetTableFrameFormat(size_t nFormat, bool bUsed) const
768 {
769  if (!bUsed)
770  {
771  return *((*mpTableFrameFormatTable)[nFormat]);
772  }
773 
774  SwAutoFormatGetDocNode aGetHt(&GetNodes());
775 
776  size_t index = 0;
777 
778  for (SwFrameFormat* const & pFormat : *mpTableFrameFormatTable)
779  {
780  if (!pFormat->GetInfo(aGetHt))
781  {
782  if (index == nFormat)
783  return *pFormat;
784  else
785  index++;
786  }
787  }
788  throw std::out_of_range("Format index out of range.");
789 }
790 
791 SwTableFormat* SwDoc::MakeTableFrameFormat( const OUString &rFormatName,
792  SwFrameFormat *pDerivedFrom )
793 {
794  SwTableFormat* pFormat = new SwTableFormat( GetAttrPool(), rFormatName, pDerivedFrom );
795  mpTableFrameFormatTable->push_back( pFormat );
797 
798  return pFormat;
799 }
800 
801 SwFrameFormat *SwDoc::MakeFrameFormat(const OUString &rFormatName,
802  SwFrameFormat *pDerivedFrom,
803  bool bBroadcast, bool bAuto)
804 {
805  SwFrameFormat *pFormat = new SwFrameFormat( GetAttrPool(), rFormatName, pDerivedFrom );
806 
807  pFormat->SetAuto(bAuto);
808  mpFrameFormatTable->push_back( pFormat );
810 
811  if (GetIDocumentUndoRedo().DoesUndo())
812  {
814  std::make_unique<SwUndoFrameFormatCreate>(pFormat, pDerivedFrom, this));
815  }
816 
817  if (bBroadcast)
818  {
819  BroadcastStyleOperation(rFormatName, SfxStyleFamily::Frame,
820  SfxHintId::StyleSheetCreated);
821  }
822 
823  return pFormat;
824 }
825 
826 SwFormat *SwDoc::MakeFrameFormat_(const OUString &rFormatName,
827  SwFormat *pDerivedFrom,
828  bool bBroadcast, bool bAuto)
829 {
830  SwFrameFormat *pFrameFormat = dynamic_cast<SwFrameFormat*>(pDerivedFrom);
831  pFrameFormat = MakeFrameFormat( rFormatName, pFrameFormat, bBroadcast, bAuto );
832  return dynamic_cast<SwFormat*>(pFrameFormat);
833 }
834 
835 SwCharFormat *SwDoc::MakeCharFormat( const OUString &rFormatName,
836  SwCharFormat *pDerivedFrom,
837  bool bBroadcast )
838 {
839  SwCharFormat *pFormat = new SwCharFormat( GetAttrPool(), rFormatName, pDerivedFrom );
840  mpCharFormatTable->push_back( pFormat );
841  pFormat->SetAuto(false);
843 
844  if (GetIDocumentUndoRedo().DoesUndo())
845  {
847  std::make_unique<SwUndoCharFormatCreate>(pFormat, pDerivedFrom, this));
848  }
849 
850  if (bBroadcast)
851  {
852  BroadcastStyleOperation(rFormatName, SfxStyleFamily::Char,
853  SfxHintId::StyleSheetCreated);
854  }
855 
856  return pFormat;
857 }
858 
859 SwFormat *SwDoc::MakeCharFormat_(const OUString &rFormatName,
860  SwFormat *pDerivedFrom,
861  bool bBroadcast, bool /*bAuto*/)
862 {
863  SwCharFormat *pCharFormat = dynamic_cast<SwCharFormat*>(pDerivedFrom);
864  pCharFormat = MakeCharFormat( rFormatName, pCharFormat, bBroadcast );
865  return dynamic_cast<SwFormat*>(pCharFormat);
866 }
867 
869 SwTextFormatColl* SwDoc::MakeTextFormatColl( const OUString &rFormatName,
870  SwTextFormatColl *pDerivedFrom,
871  bool bBroadcast)
872 {
873  SwTextFormatColl *pFormatColl = new SwTextFormatColl( GetAttrPool(), rFormatName,
874  pDerivedFrom );
875  mpTextFormatCollTable->push_back(pFormatColl);
876  pFormatColl->SetAuto(false);
878 
879  if (GetIDocumentUndoRedo().DoesUndo())
880  {
882  std::make_unique<SwUndoTextFormatCollCreate>(pFormatColl, pDerivedFrom,
883  this));
884  }
885 
886  if (bBroadcast)
887  BroadcastStyleOperation(rFormatName, SfxStyleFamily::Para,
888  SfxHintId::StyleSheetCreated);
889 
890  return pFormatColl;
891 }
892 
893 SwFormat *SwDoc::MakeTextFormatColl_(const OUString &rFormatName,
894  SwFormat *pDerivedFrom,
895  bool bBroadcast, bool /*bAuto*/)
896 {
897  SwTextFormatColl *pTextFormatColl = dynamic_cast<SwTextFormatColl*>(pDerivedFrom);
898  pTextFormatColl = MakeTextFormatColl( rFormatName, pTextFormatColl, bBroadcast );
899  return dynamic_cast<SwFormat*>(pTextFormatColl);
900 }
901 
902 //FEATURE::CONDCOLL
904  SwTextFormatColl *pDerivedFrom,
905  bool bBroadcast)
906 {
908  rFormatName, pDerivedFrom );
909  mpTextFormatCollTable->push_back(pFormatColl);
910  pFormatColl->SetAuto(false);
912 
913  if (GetIDocumentUndoRedo().DoesUndo())
914  {
916  std::make_unique<SwUndoCondTextFormatCollCreate>(pFormatColl, pDerivedFrom,
917  this));
918  }
919 
920  if (bBroadcast)
921  BroadcastStyleOperation(rFormatName, SfxStyleFamily::Para,
922  SfxHintId::StyleSheetCreated);
923 
924  return pFormatColl;
925 }
926 //FEATURE::CONDCOLL
927 
928 // GRF
929 SwGrfFormatColl* SwDoc::MakeGrfFormatColl( const OUString &rFormatName,
930  SwGrfFormatColl *pDerivedFrom )
931 {
932  SwGrfFormatColl *pFormatColl = new SwGrfFormatColl( GetAttrPool(), rFormatName,
933  pDerivedFrom );
934  mpGrfFormatCollTable->push_back( pFormatColl );
935  pFormatColl->SetAuto(false);
937  return pFormatColl;
938 }
939 
940 void SwDoc::DelTextFormatColl(size_t nFormatColl, bool bBroadcast)
941 {
942  OSL_ENSURE( nFormatColl, "Remove of Coll 0." );
943 
944  // Who has the to-be-deleted as their Next?
945  SwTextFormatColl *pDel = (*mpTextFormatCollTable)[nFormatColl];
946  if( mpDfltTextFormatColl.get() == pDel )
947  return; // never delete default!
948 
949  if (bBroadcast)
950  BroadcastStyleOperation(pDel->GetName(), SfxStyleFamily::Para,
951  SfxHintId::StyleSheetErased);
952 
954  {
955  std::unique_ptr<SwUndoTextFormatCollDelete> pUndo;
956  if (RES_CONDTXTFMTCOLL == pDel->Which())
957  {
958  pUndo.reset(new SwUndoCondTextFormatCollDelete(pDel, this));
959  }
960  else
961  {
962  pUndo.reset(new SwUndoTextFormatCollDelete(pDel, this));
963  }
964 
965  GetIDocumentUndoRedo().AppendUndo(std::move(pUndo));
966  }
967 
968  // Remove the FormatColl
969  mpTextFormatCollTable->erase(mpTextFormatCollTable->begin() + nFormatColl);
970  // Correct next
971  for( SwTextFormatColls::const_iterator it = mpTextFormatCollTable->begin() + 1; it != mpTextFormatCollTable->end(); ++it )
972  SetTextFormatCollNext( *it, pDel );
973  delete pDel;
975 }
976 
977 void SwDoc::DelTextFormatColl( SwTextFormatColl const *pColl, bool bBroadcast )
978 {
979  size_t nFormat = mpTextFormatCollTable->GetPos( pColl );
980  OSL_ENSURE( SIZE_MAX != nFormat, "Collection not found," );
981  DelTextFormatColl( nFormat, bBroadcast );
982 }
983 
984 static bool lcl_SetTextFormatColl( const SwNodePtr& rpNode, void* pArgs )
985 {
986  SwContentNode* pCNd = rpNode->GetTextNode();
987 
988  if( pCNd == nullptr)
989  return true;
990 
992 
993  if (pPara->pLayout && pPara->pLayout->IsHideRedlines())
994  {
996  {
997  return true;
998  }
999  if (pCNd->IsTextNode())
1000  {
1001  pCNd = sw::GetParaPropsNode(*pPara->pLayout, SwNodeIndex(*pCNd));
1002  }
1003  }
1004 
1005  SwTextFormatColl* pFormat = static_cast<SwTextFormatColl*>(pPara->pFormatColl);
1006  if ( pPara->bReset )
1007  {
1008  lcl_RstAttr(pCNd, pPara);
1009 
1010  // #i62675# check, if paragraph style has changed
1011  if ( pPara->bResetListAttrs &&
1012  pFormat != pCNd->GetFormatColl() &&
1013  pFormat->GetItemState( RES_PARATR_NUMRULE ) == SfxItemState::SET )
1014  {
1015  // Check, if the list style of the paragraph will change.
1016  bool bChangeOfListStyleAtParagraph( true );
1017  SwTextNode& rTNd(dynamic_cast<SwTextNode&>(*pCNd));
1018  {
1019  SwNumRule* pNumRuleAtParagraph(rTNd.GetNumRule());
1020  if ( pNumRuleAtParagraph )
1021  {
1022  const SwNumRuleItem& rNumRuleItemAtParagraphStyle =
1023  pFormat->GetNumRule();
1024  if ( rNumRuleItemAtParagraphStyle.GetValue() ==
1025  pNumRuleAtParagraph->GetName() )
1026  {
1027  bChangeOfListStyleAtParagraph = false;
1028  }
1029  }
1030  }
1031 
1032  if ( bChangeOfListStyleAtParagraph )
1033  {
1034  std::unique_ptr< SwRegHistory > pRegH;
1035  if ( pPara->pHistory )
1036  {
1037  pRegH.reset(new SwRegHistory(&rTNd, rTNd, pPara->pHistory));
1038  }
1039 
1040  pCNd->ResetAttr( RES_PARATR_NUMRULE );
1041 
1042  // reset all list attributes
1047  pCNd->ResetAttr( RES_PARATR_LIST_ID );
1048  }
1049  }
1050  }
1051 
1052  // add to History so that old data is saved, if necessary
1053  if( pPara->pHistory )
1054  pPara->pHistory->Add( pCNd->GetFormatColl(), pCNd->GetIndex(),
1055  SwNodeType::Text );
1056 
1057  pCNd->ChgFormatColl( pFormat );
1058 
1059  pPara->nWhich++;
1060 
1061  return true;
1062 }
1063 
1065  SwTextFormatColl *pFormat,
1066  const bool bReset,
1067  const bool bResetListAttrs,
1068  SwRootFrame const*const pLayout)
1069 {
1070  SwDataChanged aTmp( rRg );
1071  const SwPosition *pStt = rRg.Start(), *pEnd = rRg.End();
1072  SwHistory* pHst = nullptr;
1073  bool bRet = true;
1074 
1075  if (GetIDocumentUndoRedo().DoesUndo())
1076  {
1077  std::unique_ptr<SwUndoFormatColl> pUndo(new SwUndoFormatColl( rRg, pFormat,
1078  bReset,
1079  bResetListAttrs ));
1080  pHst = pUndo->GetHistory();
1081  GetIDocumentUndoRedo().AppendUndo(std::move(pUndo));
1082  }
1083 
1085  pStt, pEnd, pHst, nullptr, pLayout);
1086  aPara.pFormatColl = pFormat;
1087  aPara.bReset = bReset;
1088  // #i62675#
1089  aPara.bResetListAttrs = bResetListAttrs;
1090 
1091  GetNodes().ForEach( pStt->nNode.GetIndex(), pEnd->nNode.GetIndex()+1,
1092  lcl_SetTextFormatColl, &aPara );
1093  if( !aPara.nWhich )
1094  bRet = false; // didn't find a valid Node
1095 
1096  if (bRet)
1097  {
1099  }
1100 
1101  return bRet;
1102 }
1103 
1106  const SwFormatsBase& rFormatArr,
1107  FNCopyFormat fnCopyFormat, const SwFormat& rDfltFormat )
1108 {
1109  // It's no autoformat, default format or collection format,
1110  // then search for it.
1111  if( !rFormat.IsAuto() || !rFormat.GetRegisteredIn() )
1112  for( size_t n = 0; n < rFormatArr.GetFormatCount(); ++n )
1113  {
1114  // Does the Doc already contain the template?
1115  if( rFormatArr.GetFormat(n)->GetName()==rFormat.GetName() )
1116  return rFormatArr.GetFormat(n);
1117  }
1118 
1119  // Search for the "parent" first
1120  SwFormat* pParent = const_cast<SwFormat*>(&rDfltFormat);
1121  if( rFormat.DerivedFrom() && pParent != rFormat.DerivedFrom() )
1122  pParent = CopyFormat( *rFormat.DerivedFrom(), rFormatArr,
1123  fnCopyFormat, rDfltFormat );
1124 
1125  // Create the format and copy the attributes
1126  // #i40550#
1127  SwFormat* pNewFormat = (this->*fnCopyFormat)( rFormat.GetName(), pParent, false, true );
1128  pNewFormat->SetAuto( rFormat.IsAuto() );
1129  pNewFormat->CopyAttrs( rFormat ); // copy the attributes
1130 
1131  pNewFormat->SetPoolFormatId( rFormat.GetPoolFormatId() );
1132  pNewFormat->SetPoolHelpId( rFormat.GetPoolHelpId() );
1133 
1134  // Always set the HelpFile Id to default!
1135  pNewFormat->SetPoolHlpFileId( UCHAR_MAX );
1136 
1137  return pNewFormat;
1138 }
1139 
1142 {
1143  return static_cast<SwFrameFormat*>(CopyFormat( rFormat, *GetFrameFormats(), &SwDoc::MakeFrameFormat_,
1144  *GetDfltFrameFormat() ));
1145 }
1146 
1149 {
1150  return static_cast<SwCharFormat*>(CopyFormat( rFormat, *GetCharFormats(),
1152  *GetDfltCharFormat() ));
1153 }
1154 
1157 {
1158  SwTextFormatColl* pNewColl = FindTextFormatCollByName( rColl.GetName() );
1159  if( pNewColl )
1160  return pNewColl;
1161 
1162  // search for the "parent" first
1163  SwTextFormatColl* pParent = mpDfltTextFormatColl.get();
1164  if( pParent != rColl.DerivedFrom() )
1165  pParent = CopyTextColl( *static_cast<SwTextFormatColl*>(rColl.DerivedFrom()) );
1166 
1167 //FEATURE::CONDCOLL
1168  if( RES_CONDTXTFMTCOLL == rColl.Which() )
1169  {
1170  pNewColl = new SwConditionTextFormatColl( GetAttrPool(), rColl.GetName(),
1171  pParent);
1172  mpTextFormatCollTable->push_back( pNewColl );
1173  pNewColl->SetAuto(false);
1175 
1176  // copy the conditions
1177  static_cast<SwConditionTextFormatColl*>(pNewColl)->SetConditions(
1178  static_cast<const SwConditionTextFormatColl&>(rColl).GetCondColls() );
1179  }
1180  else
1181 //FEATURE::CONDCOLL
1182  pNewColl = MakeTextFormatColl( rColl.GetName(), pParent );
1183 
1184  // copy the auto formats or the attributes
1185  pNewColl->CopyAttrs( rColl );
1186 
1189  pNewColl->SetPoolFormatId( rColl.GetPoolFormatId() );
1190  pNewColl->SetPoolHelpId( rColl.GetPoolHelpId() );
1191 
1192  // Always set the HelpFile Id to default!
1193  pNewColl->SetPoolHlpFileId( UCHAR_MAX );
1194 
1195  if( &rColl.GetNextTextFormatColl() != &rColl )
1197 
1198  // create the NumRule if necessary
1199  if( this != rColl.GetDoc() )
1200  {
1201  const SfxPoolItem* pItem;
1202  if( SfxItemState::SET == pNewColl->GetItemState( RES_PARATR_NUMRULE,
1203  false, &pItem ))
1204  {
1205  const SwNumRule* pRule;
1206  const OUString& rName = static_cast<const SwNumRuleItem*>(pItem)->GetValue();
1207  if( !rName.isEmpty() &&
1208  nullptr != ( pRule = rColl.GetDoc()->FindNumRulePtr( rName )) &&
1209  !pRule->IsAutoRule() )
1210  {
1211  SwNumRule* pDestRule = FindNumRulePtr( rName );
1212  if( pDestRule )
1213  pDestRule->SetInvalidRule( true );
1214  else
1215  MakeNumRule( rName, pRule );
1216  }
1217  }
1218  }
1219  return pNewColl;
1220 }
1221 
1224 {
1225  SwGrfFormatColl* pNewColl = static_cast<SwGrfFormatColl*>(FindFormatByName( static_cast<SwFormatsBase const &>(*mpGrfFormatCollTable), rColl.GetName() ));
1226  if( pNewColl )
1227  return pNewColl;
1228 
1229  // Search for the "parent" first
1230  SwGrfFormatColl* pParent = mpDfltGrfFormatColl.get();
1231  if( pParent != rColl.DerivedFrom() )
1232  pParent = CopyGrfColl( *static_cast<SwGrfFormatColl*>(rColl.DerivedFrom()) );
1233 
1234  // if not, copy them
1235  pNewColl = MakeGrfFormatColl( rColl.GetName(), pParent );
1236 
1237  // copy the attributes
1238  pNewColl->CopyAttrs( rColl );
1239 
1240  pNewColl->SetPoolFormatId( rColl.GetPoolFormatId() );
1241  pNewColl->SetPoolHelpId( rColl.GetPoolHelpId() );
1242 
1243  // Always set the HelpFile Id to default!
1244  pNewColl->SetPoolHlpFileId( UCHAR_MAX );
1245 
1246  return pNewColl;
1247 }
1248 
1249 void SwDoc::CopyFormatArr( const SwFormatsBase& rSourceArr,
1250  SwFormatsBase const & rDestArr,
1251  FNCopyFormat fnCopyFormat,
1252  SwFormat& rDfltFormat )
1253 {
1254  SwFormat* pSrc, *pDest;
1255 
1256  // 1st step: Create all formats (skip the 0th - it's the default one)
1257  for( size_t nSrc = rSourceArr.GetFormatCount(); nSrc > 1; )
1258  {
1259  pSrc = rSourceArr.GetFormat( --nSrc );
1260  if( pSrc->IsDefault() || pSrc->IsAuto() )
1261  continue;
1262 
1263  if( nullptr == FindFormatByName( rDestArr, pSrc->GetName() ) )
1264  {
1265  if( RES_CONDTXTFMTCOLL == pSrc->Which() )
1266  MakeCondTextFormatColl( pSrc->GetName(), static_cast<SwTextFormatColl*>(&rDfltFormat) );
1267  else
1268  // #i40550#
1269  (this->*fnCopyFormat)( pSrc->GetName(), &rDfltFormat, false, true );
1270  }
1271  }
1272 
1273  // 2nd step: Copy all attributes, set the right parents
1274  for( size_t nSrc = rSourceArr.GetFormatCount(); nSrc > 1; )
1275  {
1276  pSrc = rSourceArr.GetFormat( --nSrc );
1277  if( pSrc->IsDefault() || pSrc->IsAuto() )
1278  continue;
1279 
1280  pDest = FindFormatByName( rDestArr, pSrc->GetName() );
1281  pDest->SetAuto(false);
1282  pDest->DelDiffs( *pSrc );
1283 
1284  // #i94285#: existing <SwFormatPageDesc> instance, before copying attributes
1285  const SfxPoolItem* pItem;
1286  if( &GetAttrPool() != pSrc->GetAttrSet().GetPool() &&
1287  SfxItemState::SET == pSrc->GetAttrSet().GetItemState(
1288  RES_PAGEDESC, false, &pItem ) &&
1289  static_cast<const SwFormatPageDesc*>(pItem)->GetPageDesc() )
1290  {
1291  SwFormatPageDesc aPageDesc( *static_cast<const SwFormatPageDesc*>(pItem) );
1292  const OUString& rNm = aPageDesc.GetPageDesc()->GetName();
1293  SwPageDesc* pPageDesc = FindPageDesc( rNm );
1294  if( !pPageDesc )
1295  {
1296  pPageDesc = MakePageDesc(rNm);
1297  }
1298  aPageDesc.RegisterToPageDesc( *pPageDesc );
1299  SwAttrSet aTmpAttrSet( pSrc->GetAttrSet() );
1300  aTmpAttrSet.Put( aPageDesc );
1301  pDest->SetFormatAttr( aTmpAttrSet );
1302  }
1303  else
1304  {
1305  pDest->SetFormatAttr( pSrc->GetAttrSet() );
1306  }
1307 
1308  pDest->SetPoolFormatId( pSrc->GetPoolFormatId() );
1309  pDest->SetPoolHelpId( pSrc->GetPoolHelpId() );
1310 
1311  // Always set the HelpFile Id to default!
1312  pDest->SetPoolHlpFileId( UCHAR_MAX );
1313 
1314  if( pSrc->DerivedFrom() )
1315  pDest->SetDerivedFrom( FindFormatByName( rDestArr,
1316  pSrc->DerivedFrom()->GetName() ) );
1317  if( RES_TXTFMTCOLL == pSrc->Which() ||
1318  RES_CONDTXTFMTCOLL == pSrc->Which() )
1319  {
1320  SwTextFormatColl* pSrcColl = static_cast<SwTextFormatColl*>(pSrc),
1321  * pDstColl = static_cast<SwTextFormatColl*>(pDest);
1322  if( &pSrcColl->GetNextTextFormatColl() != pSrcColl )
1323  pDstColl->SetNextTextFormatColl( *static_cast<SwTextFormatColl*>(FindFormatByName(
1324  rDestArr, pSrcColl->GetNextTextFormatColl().GetName() ) ) );
1325 
1326  if(pSrcColl->IsAssignedToListLevelOfOutlineStyle())
1327  pDstColl->AssignToListLevelOfOutlineStyle(pSrcColl->GetAssignedOutlineStyleLevel());
1328 
1329 //FEATURE::CONDCOLL
1330  if( RES_CONDTXTFMTCOLL == pSrc->Which() )
1331  // Copy the conditions, but delete the old ones first!
1332  static_cast<SwConditionTextFormatColl*>(pDstColl)->SetConditions(
1333  static_cast<SwConditionTextFormatColl*>(pSrc)->GetCondColls() );
1334 //FEATURE::CONDCOLL
1335  }
1336  }
1337 }
1338 
1340  const SwFrameFormat& rSrcFormat, SwFrameFormat& rDestFormat )
1341 {
1342  // Treat the header and footer attributes in the right way:
1343  // Copy content nodes across documents!
1344  sal_uInt16 nAttr = bCpyHeader ? sal_uInt16(RES_HEADER) : sal_uInt16(RES_FOOTER);
1345  const SfxPoolItem* pItem;
1346  if( SfxItemState::SET != rSrcFormat.GetAttrSet().GetItemState( nAttr, false, &pItem ))
1347  return ;
1348 
1349  // The header only contains the reference to the format from the other document!
1350  std::unique_ptr<SfxPoolItem> pNewItem(pItem->Clone());
1351 
1352  SwFrameFormat* pOldFormat;
1353  if( bCpyHeader )
1354  pOldFormat = static_cast<SwFormatHeader*>(pNewItem.get())->GetHeaderFormat();
1355  else
1356  pOldFormat = static_cast<SwFormatFooter*>(pNewItem.get())->GetFooterFormat();
1357 
1358  if( pOldFormat )
1359  {
1360  SwFrameFormat* pNewFormat = new SwFrameFormat( GetAttrPool(), "CpyDesc",
1361  GetDfltFrameFormat() );
1362  pNewFormat->CopyAttrs( *pOldFormat );
1363 
1364  if( SfxItemState::SET == pNewFormat->GetAttrSet().GetItemState(
1365  RES_CNTNT, false, &pItem ))
1366  {
1367  const SwFormatContent* pContent = static_cast<const SwFormatContent*>(pItem);
1368  if( pContent->GetContentIdx() )
1369  {
1370  SwNodeIndex aTmpIdx( GetNodes().GetEndOfAutotext() );
1371  const SwNodes& rSrcNds = rSrcFormat.GetDoc()->GetNodes();
1372  SwStartNode* pSttNd = SwNodes::MakeEmptySection( aTmpIdx,
1373  bCpyHeader
1375  : SwFooterStartNode );
1376  const SwNode& rCSttNd = pContent->GetContentIdx()->GetNode();
1377  SwNodeRange aRg( rCSttNd, 0, *rCSttNd.EndOfSectionNode() );
1378  aTmpIdx = *pSttNd->EndOfSectionNode();
1379  rSrcNds.Copy_( aRg, aTmpIdx );
1380  aTmpIdx = *pSttNd;
1381  rSrcFormat.GetDoc()->GetDocumentContentOperationsManager().CopyFlyInFlyImpl(aRg, nullptr, aTmpIdx);
1382  // TODO: investigate calling CopyWithFlyInFly?
1383  SwPaM const source(aRg.aStart, aRg.aEnd);
1384  SwPosition dest(aTmpIdx);
1385  sw::CopyBookmarks(source, dest);
1386  pNewFormat->SetFormatAttr( SwFormatContent( pSttNd ));
1387  }
1388  else
1389  pNewFormat->ResetFormatAttr( RES_CNTNT );
1390  }
1391  if( bCpyHeader )
1392  static_cast<SwFormatHeader*>(pNewItem.get())->RegisterToFormat(*pNewFormat);
1393  else
1394  static_cast<SwFormatFooter*>(pNewItem.get())->RegisterToFormat(*pNewFormat);
1395  rDestFormat.SetFormatAttr( *pNewItem );
1396  }
1397 }
1398 
1399 void SwDoc::CopyPageDesc( const SwPageDesc& rSrcDesc, SwPageDesc& rDstDesc,
1400  bool bCopyPoolIds )
1401 {
1402  bool bNotifyLayout = false;
1404 
1405  rDstDesc.SetLandscape( rSrcDesc.GetLandscape() );
1406  rDstDesc.SetNumType( rSrcDesc.GetNumType() );
1407  if( rDstDesc.ReadUseOn() != rSrcDesc.ReadUseOn() )
1408  {
1409  rDstDesc.WriteUseOn( rSrcDesc.ReadUseOn() );
1410  bNotifyLayout = true;
1411  }
1412 
1413  if( bCopyPoolIds )
1414  {
1415  rDstDesc.SetPoolFormatId( rSrcDesc.GetPoolFormatId() );
1416  rDstDesc.SetPoolHelpId( rSrcDesc.GetPoolHelpId() );
1417  // Always set the HelpFile Id to default!
1418  rDstDesc.SetPoolHlpFileId( UCHAR_MAX );
1419  }
1420 
1421  if( rSrcDesc.GetFollow() != &rSrcDesc )
1422  {
1423  const SwPageDesc* pSrcFollow = rSrcDesc.GetFollow();
1424  SwPageDesc* pFollow = FindPageDesc( pSrcFollow->GetName() );
1425  if( !pFollow )
1426  {
1427  // copy
1428  pFollow = MakePageDesc( pSrcFollow->GetName() );
1429  CopyPageDesc( *pSrcFollow, *pFollow );
1430  }
1431  rDstDesc.SetFollow( pFollow );
1432  bNotifyLayout = true;
1433  }
1434 
1435  // the header and footer attributes are copied separately
1436  // the content sections have to be copied in their entirety
1437  {
1438  SfxItemSet aAttrSet( rSrcDesc.GetMaster().GetAttrSet() );
1439  aAttrSet.ClearItem( RES_HEADER );
1440  aAttrSet.ClearItem( RES_FOOTER );
1441 
1442  rDstDesc.GetMaster().DelDiffs( aAttrSet );
1443  rDstDesc.GetMaster().SetFormatAttr( aAttrSet );
1444 
1445  aAttrSet.ClearItem();
1446  aAttrSet.Put( rSrcDesc.GetLeft().GetAttrSet() );
1447  aAttrSet.ClearItem( RES_HEADER );
1448  aAttrSet.ClearItem( RES_FOOTER );
1449 
1450  rDstDesc.GetLeft().DelDiffs( aAttrSet );
1451  rDstDesc.GetLeft().SetFormatAttr( aAttrSet );
1452 
1453  aAttrSet.ClearItem();
1454  aAttrSet.Put( rSrcDesc.GetFirstMaster().GetAttrSet() );
1455  aAttrSet.ClearItem( RES_HEADER );
1456  aAttrSet.ClearItem( RES_FOOTER );
1457 
1458  rDstDesc.GetFirstMaster().DelDiffs( aAttrSet );
1459  rDstDesc.GetFirstMaster().SetFormatAttr( aAttrSet );
1460 
1461  aAttrSet.ClearItem();
1462  aAttrSet.Put( rSrcDesc.GetFirstLeft().GetAttrSet() );
1463  aAttrSet.ClearItem( RES_HEADER );
1464  aAttrSet.ClearItem( RES_FOOTER );
1465 
1466  rDstDesc.GetFirstLeft().DelDiffs( aAttrSet );
1467  rDstDesc.GetFirstLeft().SetFormatAttr( aAttrSet );
1468  }
1469 
1470  CopyHeader( rSrcDesc.GetMaster(), rDstDesc.GetMaster() );
1471  CopyFooter( rSrcDesc.GetMaster(), rDstDesc.GetMaster() );
1472  if( !rDstDesc.IsHeaderShared() )
1473  CopyHeader( rSrcDesc.GetLeft(), rDstDesc.GetLeft() );
1474  else
1475  rDstDesc.GetLeft().SetFormatAttr( rDstDesc.GetMaster().GetHeader() );
1476  if( !rDstDesc.IsFirstShared() )
1477  {
1478  CopyHeader( rSrcDesc.GetFirstMaster(), rDstDesc.GetFirstMaster() );
1479  rDstDesc.GetFirstLeft().SetFormatAttr(rDstDesc.GetFirstMaster().GetHeader());
1480  }
1481  else
1482  {
1483  rDstDesc.GetFirstMaster().SetFormatAttr( rDstDesc.GetMaster().GetHeader() );
1484  rDstDesc.GetFirstLeft().SetFormatAttr(rDstDesc.GetLeft().GetHeader());
1485  }
1486 
1487  if( !rDstDesc.IsFooterShared() )
1488  CopyFooter( rSrcDesc.GetLeft(), rDstDesc.GetLeft() );
1489  else
1490  rDstDesc.GetLeft().SetFormatAttr( rDstDesc.GetMaster().GetFooter() );
1491  if( !rDstDesc.IsFirstShared() )
1492  {
1493  CopyFooter( rSrcDesc.GetFirstMaster(), rDstDesc.GetFirstMaster() );
1494  rDstDesc.GetFirstLeft().SetFormatAttr(rDstDesc.GetFirstMaster().GetFooter());
1495  }
1496  else
1497  {
1498  rDstDesc.GetFirstMaster().SetFormatAttr( rDstDesc.GetMaster().GetFooter() );
1499  rDstDesc.GetFirstLeft().SetFormatAttr(rDstDesc.GetLeft().GetFooter());
1500  }
1501 
1502  if( bNotifyLayout && pTmpRoot )
1503  {
1504  for( auto aLayout : GetAllLayouts() )
1505  aLayout->AllCheckPageDescs();
1506  }
1507 
1508  // If foot notes change the pages have to be triggered
1509  if( !(rDstDesc.GetFootnoteInfo() == rSrcDesc.GetFootnoteInfo()) )
1510  {
1511  sw::PageFootnoteHint aHint;
1512  rDstDesc.SetFootnoteInfo( rSrcDesc.GetFootnoteInfo() );
1513  rDstDesc.GetMaster().CallSwClientNotify(aHint);
1514  rDstDesc.GetLeft().CallSwClientNotify(aHint);
1515  rDstDesc.GetFirstMaster().CallSwClientNotify(aHint);
1516  rDstDesc.GetFirstLeft().CallSwClientNotify(aHint);
1517  }
1518 }
1519 
1520 void SwDoc::ReplaceStyles( const SwDoc& rSource, bool bIncludePageStyles )
1521 {
1522  ::sw::UndoGuard const undoGuard(GetIDocumentUndoRedo());
1523 
1530 
1531  //To-Do:
1532  // a) in rtf export don't export our hideous pgdsctbl
1533  // extension to rtf anymore
1534  // b) in sd rtf import (View::InsertData) don't use
1535  // a super-fragile test for mere presence of \trowd to
1536  // indicate import of rtf into a table
1537  // c) then drop use of bIncludePageStyles
1538  if (bIncludePageStyles)
1539  {
1540  // and now the page templates
1541  SwPageDescs::size_type nCnt = rSource.m_PageDescs.size();
1542  if( nCnt )
1543  {
1544  // a different Doc -> Number formatter needs to be merged
1545  SwTableNumFormatMerge aTNFM( rSource, *this );
1546 
1547  // 1st step: Create all formats (skip the 0th - it's the default!)
1548  while( nCnt )
1549  {
1550  const SwPageDesc &rSrc = *rSource.m_PageDescs[ --nCnt ];
1551  if( nullptr == FindPageDesc( rSrc.GetName() ) )
1552  MakePageDesc( rSrc.GetName() );
1553  }
1554 
1555  // 2nd step: Copy all attributes, set the right parents
1556  for (SwPageDescs::size_type i = rSource.m_PageDescs.size(); i; )
1557  {
1558  const SwPageDesc &rSrc = *rSource.m_PageDescs[ --i ];
1559  SwPageDesc* pDesc = FindPageDesc( rSrc.GetName() );
1560  CopyPageDesc( rSrc, *pDesc);
1561  }
1562  }
1563  }
1564 
1565  // then there are the numbering templates
1566  const SwNumRuleTable::size_type nCnt = rSource.GetNumRuleTable().size();
1567  if( nCnt )
1568  {
1569  const SwNumRuleTable& rArr = rSource.GetNumRuleTable();
1570  for( SwNumRuleTable::size_type n = 0; n < nCnt; ++n )
1571  {
1572  const SwNumRule& rR = *rArr[ n ];
1573  SwNumRule* pNew = FindNumRulePtr( rR.GetName());
1574  if( pNew )
1575  pNew->CopyNumRule( this, rR );
1576  else
1577  {
1578  if( !rR.IsAutoRule() )
1579  MakeNumRule( rR.GetName(), &rR );
1580  else
1581  {
1582  // as we reset all styles, there shouldn't be any unknown
1583  // automatic SwNumRules, because all should have been
1584  // created by the style copying!
1585  // So just warn and ignore.
1586  SAL_WARN( "sw.core", "Found unknown auto SwNumRule during reset!" );
1587  }
1588  }
1589  }
1590  }
1591 
1592  if (undoGuard.UndoWasEnabled())
1593  {
1594  // nodes array was modified!
1596  }
1597 
1599 }
1600 
1602  const OUString& rName )
1603 {
1604  SwFormat* pFnd = nullptr;
1605  for( size_t n = 0; n < rFormatArr.GetFormatCount(); ++n )
1606  {
1607  // Does the Doc already contain the template?
1608  if( rFormatArr.GetFormat(n)->HasName( rName ) )
1609  {
1610  pFnd = rFormatArr.GetFormat(n);
1611  break;
1612  }
1613  }
1614  return pFnd;
1615 }
1616 
1617 void SwDoc::MoveLeftMargin(const SwPaM& rPam, bool bRight, bool bModulus,
1618  SwRootFrame const*const pLayout)
1619 {
1620  SwHistory* pHistory = nullptr;
1621  if (GetIDocumentUndoRedo().DoesUndo())
1622  {
1623  std::unique_ptr<SwUndoMoveLeftMargin> pUndo(new SwUndoMoveLeftMargin( rPam, bRight,
1624  bModulus ));
1625  pHistory = &pUndo->GetHistory();
1626  GetIDocumentUndoRedo().AppendUndo( std::move(pUndo) );
1627  }
1628 
1629  const SvxTabStopItem& rTabItem = GetDefault( RES_PARATR_TABSTOP );
1630  const sal_Int32 nDefDist = rTabItem.Count() ? rTabItem[0].GetTabPos() : 1134;
1631  const SwPosition &rStt = *rPam.Start(), &rEnd = *rPam.End();
1632  SwNodeIndex aIdx( rStt.nNode );
1633  while( aIdx <= rEnd.nNode )
1634  {
1635  SwTextNode* pTNd = aIdx.GetNode().GetTextNode();
1636  if( pTNd )
1637  {
1638  pTNd = sw::GetParaPropsNode(*pLayout, aIdx);
1639  SvxLRSpaceItem aLS( static_cast<const SvxLRSpaceItem&>(pTNd->SwContentNode::GetAttr( RES_LR_SPACE )) );
1640 
1641  // #i93873# See also lcl_MergeListLevelIndentAsLRSpaceItem in thints.cxx
1642  if ( pTNd->AreListLevelIndentsApplicable() )
1643  {
1644  const SwNumRule* pRule = pTNd->GetNumRule();
1645  if ( pRule )
1646  {
1647  const int nListLevel = pTNd->GetActualListLevel();
1648  if ( nListLevel >= 0 )
1649  {
1650  const SwNumFormat& rFormat = pRule->Get(static_cast<sal_uInt16>(nListLevel));
1652  {
1653  aLS.SetTextLeft( rFormat.GetIndentAt() );
1654  aLS.SetTextFirstLineOfst( static_cast<short>(rFormat.GetFirstLineIndent()) );
1655  }
1656  }
1657  }
1658  }
1659 
1660  long nNext = aLS.GetTextLeft();
1661  if( bModulus )
1662  nNext = ( nNext / nDefDist ) * nDefDist;
1663 
1664  if( bRight )
1665  nNext += nDefDist;
1666  else
1667  if(nNext >0) // fdo#75936 set limit for decreasing indent
1668  nNext -= nDefDist;
1669 
1670  aLS.SetTextLeft( nNext );
1671 
1672  SwRegHistory aRegH( pTNd, *pTNd, pHistory );
1673  pTNd->SetAttr( aLS );
1674  aIdx = *sw::GetFirstAndLastNode(*pLayout, aIdx).second;
1675  }
1676  ++aIdx;
1677  }
1679 }
1680 
1681 bool SwDoc::DontExpandFormat( const SwPosition& rPos, bool bFlag )
1682 {
1683  bool bRet = false;
1684  SwTextNode* pTextNd = rPos.nNode.GetNode().GetTextNode();
1685  if( pTextNd )
1686  {
1687  bRet = pTextNd->DontExpandFormat( rPos.nContent, bFlag );
1688  if( bRet && GetIDocumentUndoRedo().DoesUndo() )
1689  {
1690  GetIDocumentUndoRedo().AppendUndo( std::make_unique<SwUndoDontExpandFormat>(rPos) );
1691  }
1692  }
1693  return bRet;
1694 }
1695 
1697 {
1700  return pFormat;
1701 }
1702 
1704 {
1707  return pFormat;
1708 }
1709 
1711 {
1713  {
1714  LanguageType eLang = LANGUAGE_SYSTEM;
1718  pRet->SetYear2000(static_cast<sal_uInt16>(::utl::MiscCfg().GetYear2000()));
1719  return pRet;
1720  });
1721 }
1722 
1724  : pNFormat( nullptr )
1725 {
1726  // a different Doc -> Number formatter needs to be merged
1727  SvNumberFormatter* pN;
1728  if( &rSrc != &rDest && nullptr != ( pN = const_cast<SwDoc&>(rSrc).GetNumberFormatter( false ) ))
1729  {
1730  pNFormat = rDest.GetNumberFormatter();
1731  pNFormat->MergeFormatter( *pN );
1732  }
1733 
1734  if( &rSrc != &rDest )
1736  MergeWithOtherDoc( rDest );
1737 }
1738 
1740 {
1741  if( pNFormat )
1743 }
1744 
1745 void SwDoc::SetTextFormatCollByAutoFormat( const SwPosition& rPos, sal_uInt16 nPoolId,
1746  const SfxItemSet* pSet )
1747 {
1748  SwPaM aPam( rPos );
1749  SwTextNode* pTNd = rPos.nNode.GetNode().GetTextNode();
1750  assert(pTNd);
1751 
1753  {
1754  // create the redline object
1755  const SwTextFormatColl& rColl = *pTNd->GetTextColl();
1756  SwRangeRedline* pRedl = new SwRangeRedline( RedlineType::FmtColl, aPam );
1757  pRedl->SetMark();
1758 
1759  // Only those items that are not set by the Set again in the Node
1760  // are of interest. Thus, we take the difference.
1761  SwRedlineExtraData_FormatColl aExtraData( rColl.GetName(),
1762  rColl.GetPoolFormatId() );
1763  if( pSet && pTNd->HasSwAttrSet() )
1764  {
1765  SfxItemSet aTmp( *pTNd->GetpSwAttrSet() );
1766  aTmp.Differentiate( *pSet );
1767  // we handle the adjust item separately
1768  const SfxPoolItem* pItem;
1769  if( SfxItemState::SET == pTNd->GetpSwAttrSet()->GetItemState(
1770  RES_PARATR_ADJUST, false, &pItem ))
1771  aTmp.Put( *pItem );
1772  aExtraData.SetItemSet( aTmp );
1773  }
1774  pRedl->SetExtraData( &aExtraData );
1775 
1776  //TODO: Undo is still missing!
1777  getIDocumentRedlineAccess().AppendRedline( pRedl, true );
1778  }
1779 
1780  SetTextFormatColl( aPam, getIDocumentStylePoolAccess().GetTextCollFromPool( nPoolId ) );
1781 
1782  if (pSet && pSet->Count())
1783  {
1784  aPam.SetMark();
1785  aPam.GetMark()->nContent.Assign(pTNd, pTNd->GetText().getLength());
1786  // sw_redlinehide: don't need layout currently because the only caller
1787  // passes in the properties node
1788  assert(static_cast<SwTextFrame const*>(pTNd->getLayoutFrame(nullptr))->GetTextNodeForParaProps() == pTNd);
1790  }
1791 }
1792 
1793 void SwDoc::SetFormatItemByAutoFormat( const SwPaM& rPam, const SfxItemSet& rSet )
1794 {
1795  SwTextNode* pTNd = rPam.GetPoint()->nNode.GetNode().GetTextNode();
1796  assert(pTNd);
1797 
1799 
1801  {
1802  // create the redline object
1803  SwRangeRedline* pRedl = new SwRangeRedline( RedlineType::Format, rPam );
1804  if( !pRedl->HasMark() )
1805  pRedl->SetMark();
1806 
1807  // Only those items that are not set by the Set again in the Node
1808  // are of interest. Thus, we take the difference.
1809  SwRedlineExtraData_Format aExtraData( rSet );
1810 
1811  pRedl->SetExtraData( &aExtraData );
1812 
1813  //TODO: Undo is still missing!
1814  getIDocumentRedlineAccess().AppendRedline( pRedl, true );
1815 
1817  }
1818 
1819  const sal_Int32 nEnd(rPam.End()->nContent.GetIndex());
1820  std::vector<sal_uInt16> whichIds;
1821  SfxItemIter iter(rSet);
1822  for (SfxPoolItem const* pItem = iter.GetCurItem(); pItem; pItem = iter.NextItem())
1823  {
1824  whichIds.push_back(pItem->Which());
1825  whichIds.push_back(pItem->Which());
1826  }
1827  whichIds.push_back(0);
1828  SfxItemSet currentSet(GetAttrPool(), whichIds.data());
1829  pTNd->GetParaAttr(currentSet, nEnd, nEnd);
1830  for (size_t i = 0; whichIds[i]; i += 2)
1831  { // yuk - want to explicitly set the pool defaults too :-/
1832  currentSet.Put(currentSet.Get(whichIds[i]));
1833  }
1834 
1836 
1837  // fdo#62536: DONTEXPAND does not work when there is already an AUTOFMT
1838  // here, so insert the old attributes as an empty hint to stop expand
1839  SwPaM endPam(*pTNd, nEnd);
1840  endPam.SetMark();
1841  getIDocumentContentOperations().InsertItemSet(endPam, currentSet);
1842 
1844 }
1845 
1846 void SwDoc::ChgFormat(SwFormat & rFormat, const SfxItemSet & rSet)
1847 {
1848  if (GetIDocumentUndoRedo().DoesUndo())
1849  {
1850  // copying <rSet> to <aSet>
1851  SfxItemSet aSet(rSet);
1852  // remove from <aSet> all items, which are already set at the format
1853  aSet.Differentiate(rFormat.GetAttrSet());
1854  // <aSet> contains now all *new* items for the format
1855 
1856  // copying current format item set to <aOldSet>
1857  SfxItemSet aOldSet(rFormat.GetAttrSet());
1858  // insert new items into <aOldSet>
1859  aOldSet.Put(aSet);
1860  // invalidate all new items in <aOldSet> in order to clear these items,
1861  // if the undo action is triggered.
1862  {
1863  SfxItemIter aIter(aSet);
1864 
1865  for (const SfxPoolItem* pItem = aIter.GetCurItem(); pItem; pItem = aIter.NextItem())
1866  {
1867  aOldSet.InvalidateItem(pItem->Which());
1868  }
1869  }
1870 
1872  std::make_unique<SwUndoFormatAttr>(aOldSet, rFormat, /*bSaveDrawPt*/true));
1873  }
1874 
1875  rFormat.SetFormatAttr(rSet);
1876 }
1877 
1878 void SwDoc::RenameFormat(SwFormat & rFormat, const OUString & sNewName,
1879  bool bBroadcast)
1880 {
1881  SfxStyleFamily eFamily = SfxStyleFamily::All;
1882 
1883  if (GetIDocumentUndoRedo().DoesUndo())
1884  {
1885  std::unique_ptr<SwUndo> pUndo;
1886 
1887  switch (rFormat.Which())
1888  {
1889  case RES_CHRFMT:
1890  pUndo.reset(new SwUndoRenameCharFormat(rFormat.GetName(), sNewName, this));
1891  eFamily = SfxStyleFamily::Char;
1892  break;
1893  case RES_TXTFMTCOLL:
1894  pUndo.reset(new SwUndoRenameFormatColl(rFormat.GetName(), sNewName, this));
1895  eFamily = SfxStyleFamily::Para;
1896  break;
1897  case RES_FRMFMT:
1898  pUndo.reset(new SwUndoRenameFrameFormat(rFormat.GetName(), sNewName, this));
1899  eFamily = SfxStyleFamily::Frame;
1900  break;
1901 
1902  default:
1903  break;
1904  }
1905 
1906  if (pUndo)
1907  {
1908  GetIDocumentUndoRedo().AppendUndo(std::move(pUndo));
1909  }
1910  }
1911 
1912  rFormat.SetName(sNewName);
1913 
1914  if (bBroadcast)
1915  BroadcastStyleOperation(sNewName, eFamily, SfxHintId::StyleSheetModified);
1916 }
1917 
1919 {
1920  bool bOwns = false;
1921  if (!pWriter)
1922  {
1923  pWriter = xmlNewTextWriterFilename("nodes.xml", 0);
1924  xmlTextWriterSetIndent(pWriter,1);
1925  xmlTextWriterSetIndentString(pWriter, BAD_CAST(" "));
1926  xmlTextWriterStartDocument(pWriter, nullptr, nullptr, nullptr);
1927  bOwns = true;
1928  }
1929  xmlTextWriterStartElement(pWriter, BAD_CAST("SwDoc"));
1930  xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("ptr"), "%p", this);
1931 
1932  m_pNodes->dumpAsXml(pWriter);
1933  m_PageDescs.dumpAsXml(pWriter);
1934  maDBData.dumpAsXml(pWriter);
1935  mpMarkManager->dumpAsXml(pWriter);
1936  m_pUndoManager->dumpAsXml(pWriter);
1938  mpTextFormatCollTable->dumpAsXml(pWriter);
1939  mpCharFormatTable->dumpAsXml(pWriter);
1940  mpFrameFormatTable->dumpAsXml(pWriter, "frmFormatTable");
1941  mpSpzFrameFormatTable->dumpAsXml(pWriter, "spzFrameFormatTable");
1942  mpSectionFormatTable->dumpAsXml(pWriter);
1943  mpNumRuleTable->dumpAsXml(pWriter);
1946  if (const SdrModel* pModel = getIDocumentDrawModelAccess().GetDrawModel())
1947  pModel->dumpAsXml(pWriter);
1948 
1949  xmlTextWriterStartElement(pWriter, BAD_CAST("mbModified"));
1950  xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"), BAD_CAST(OString::boolean(getIDocumentState().IsModified()).getStr()));
1951  xmlTextWriterEndElement(pWriter);
1952 
1953  xmlTextWriterEndElement(pWriter);
1954  if (bOwns)
1955  {
1956  xmlTextWriterEndDocument(pWriter);
1957  xmlFreeTextWriter(pWriter);
1958  }
1959 }
1960 
1962 {
1963  xmlTextWriterStartElement(pWriter, BAD_CAST("SwDBData"));
1964 
1965  xmlTextWriterWriteAttribute(pWriter, BAD_CAST("sDataSource"), BAD_CAST(sDataSource.toUtf8().getStr()));
1966  xmlTextWriterWriteAttribute(pWriter, BAD_CAST("sCommand"), BAD_CAST(sCommand.toUtf8().getStr()));
1967  xmlTextWriterWriteAttribute(pWriter, BAD_CAST("nCommandType"), BAD_CAST(OString::number(nCommandType).getStr()));
1968 
1969  xmlTextWriterEndElement(pWriter);
1970 }
1971 
1972 std::set<Color> SwDoc::GetDocColors()
1973 {
1974  std::set<Color> aDocColors;
1975  SwAttrPool& rPool = GetAttrPool();
1976  const sal_uInt16 pAttribs[] = {RES_CHRATR_COLOR, RES_CHRATR_HIGHLIGHT, RES_BACKGROUND};
1977  for (sal_uInt16 nAttrib : pAttribs)
1978  {
1979  for (const SfxPoolItem* pItem : rPool.GetItemSurrogates(nAttrib))
1980  {
1981  auto pColorItem = static_cast<const SvxColorItem*>(pItem);
1982  Color aColor( pColorItem->GetValue() );
1983  if (COL_AUTO != aColor)
1984  aDocColors.insert(aColor);
1985  }
1986  }
1987  return aDocColors;
1988 }
1989 
1990 // #i69627#
1991 namespace docfunc
1992 {
1994  {
1995  // If a parent paragraph style of one of the paragraph styles, which
1996  // are assigned to the list levels of the outline style, has a list style
1997  // set or inherits a list style from its parent style, the outline style
1998  // has to be written as a normal list style to the OpenDocument file
1999  // format or the OpenOffice.org file format.
2000  bool bRet( false );
2001 
2002  const SwTextFormatColls* pTextFormatColls( rDoc.GetTextFormatColls() );
2003  if ( pTextFormatColls )
2004  {
2005  for ( auto pTextFormatColl : *pTextFormatColls )
2006  {
2007  if ( pTextFormatColl->IsDefault() ||
2008  ! pTextFormatColl->IsAssignedToListLevelOfOutlineStyle() )
2009  {
2010  continue;
2011  }
2012 
2013  const SwTextFormatColl* pParentTextFormatColl =
2014  dynamic_cast<const SwTextFormatColl*>( pTextFormatColl->DerivedFrom());
2015  if ( !pParentTextFormatColl )
2016  continue;
2017 
2018  if ( SfxItemState::SET == pParentTextFormatColl->GetItemState( RES_PARATR_NUMRULE ) )
2019  {
2020  // #i106218# consider that the outline style is set
2021  const SwNumRuleItem& rDirectItem = pParentTextFormatColl->GetNumRule();
2022  if ( rDirectItem.GetValue() != rDoc.GetOutlineNumRule()->GetName() )
2023  {
2024  bRet = true;
2025  break;
2026  }
2027  }
2028  }
2029 
2030  }
2031  return bRet;
2032  }
2033 }
2034 
2036  : m_PosIndex( m_Array.get<0>() )
2037  , m_TypeAndNameIndex( m_Array.get<1>() )
2038 {
2039 }
2040 
2042 {
2044 }
2045 
2047 {
2048  ByTypeAndName::iterator it = m_TypeAndNameIndex.find(
2049  boost::make_tuple(x->Which(), x->GetName(), x) );
2050  return m_Array.project<0>( it );
2051 }
2052 
2053 std::pair<SwFrameFormats::const_range_iterator,SwFrameFormats::const_range_iterator>
2054 SwFrameFormats::rangeFind( sal_uInt16 type, const OUString& name ) const
2055 {
2056  return m_TypeAndNameIndex.equal_range( boost::make_tuple(type, name) );
2057 }
2058 
2059 std::pair<SwFrameFormats::const_range_iterator,SwFrameFormats::const_range_iterator>
2061 {
2062  return rangeFind( x->Which(), x->GetName() );
2063 }
2064 
2065 void SwFrameFormats::DeleteAndDestroyAll( bool keepDefault )
2066 {
2067  if ( empty() )
2068  return;
2069  const int _offset = keepDefault ? 1 : 0;
2070  for( const_iterator it = begin() + _offset; it != end(); ++it )
2071  delete *it;
2072  if ( _offset )
2073  m_PosIndex.erase( begin() + _offset, end() );
2074  else
2075  m_Array.clear();
2076 }
2077 
2078 std::pair<SwFrameFormats::const_iterator,bool> SwFrameFormats::push_back( const value_type& x )
2079 {
2080  SAL_WARN_IF(x->m_ffList != nullptr, "sw.core", "Inserting already assigned item");
2081  assert(x->m_ffList == nullptr);
2082  x->m_ffList = this;
2083  return m_PosIndex.push_back( x );
2084 }
2085 
2087 {
2088  const_iterator const ret = find( x );
2089  SAL_WARN_IF(x->m_ffList != this, "sw.core", "Removing invalid / unassigned item");
2090  if (ret != end()) {
2091  assert( x == *ret );
2092  m_PosIndex.erase( ret );
2093  x->m_ffList = nullptr;
2094  return true;
2095  }
2096  return false;
2097 }
2098 
2100 {
2101  erase( begin() + index_ );
2102 }
2103 
2104 void SwFrameFormats::erase( const_iterator const& position )
2105 {
2106  (*position)->m_ffList = nullptr;
2107  m_PosIndex.erase( begin() + (position - begin()) );
2108 }
2109 
2111 {
2112  return (x.m_ffList == this);
2113 }
2114 
2115 bool SwFrameFormats::IsAlive(SwFrameFormat const*const p) const
2116 {
2117  return find(const_cast<SwFrameFormat*>(p)) != end();
2118 }
2119 
2121 {
2122  std::pair<iterator,bool> res = m_PosIndex.push_front( x );
2123  if( ! res.second )
2124  newDefault( res.first );
2125  return res.second;
2126 }
2127 
2129 {
2130  if (position == begin())
2131  return;
2132  m_PosIndex.relocate( begin(), position );
2133 }
2134 
2135 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
SwTableFormat * MakeTableFrameFormat(const OUString &rFormatName, SwFrameFormat *pDerivedFrom)
Definition: docfmt.cxx:791
SwTextFormatColl * MakeTextFormatColl(const OUString &rFormatName, SwTextFormatColl *pDerivedFrom, bool bBroadcast=false)
Create the FormatCollections.
Definition: docfmt.cxx:869
const SwEndNode * EndOfSectionNode() const
Definition: node.hxx:682
const std::unique_ptr< ::sw::UndoManager > m_pUndoManager
Definition: doc.hxx:213
Starts a section of nodes in the document model.
Definition: node.hxx:303
void ResetAttrs(const SwPaM &rRg, bool bTextAttr=true, const std::set< sal_uInt16 > &rAttrs=std::set< sal_uInt16 >(), const bool bSendDataChangedEvents=true, SwRootFrame const *pLayout=nullptr)
Reset attributes.
Definition: docfmt.cxx:239
bool UndoWasEnabled() const
SwFrameFormats * m_ffList
Definition: frmfmt.hxx:73
SwPageDescs m_PageDescs
Definition: doc.hxx:195
bool erase(const value_type &x)
Definition: docfmt.cxx:2086
void EnsureNumberFormatter()
Definition: docfmt.cxx:1710
sal_uLong GetIndex() const
Definition: node.hxx:282
SwFormat * CopyFormat(const SwFormat &rFormat, const SwFormatsBase &rFormatArr, FNCopyFormat fnCopyFormat, const SwFormat &rDfltFormat)
Copy the formats to itself.
Definition: docfmt.cxx:1105
SwTableLineFormat * MakeTableLineFormat()
Definition: docfmt.cxx:1703
sal_Int32 nCommandType
Definition: swdbdata.hxx:32
void Add(SwClient *pDepend)
Definition: calbck.cxx:217
static Type * doubleCheckedInit(std::atomic< Type * > &pointer, Function function, GuardCtor guardCtor=osl::GetGlobalMutex())
int GetAssignedOutlineStyleLevel() const
Definition: fmtcol.cxx:587
#define RES_FRMFMT
Definition: hintids.hxx:275
Represents the style of a paragraph.
Definition: fmtcol.hxx:55
static bool lcl_SetNewDefTabStops(SwTwips nOldWidth, SwTwips nNewWidth, SvxTabStopItem &rChgTabStop)
Definition: docfmt.cxx:499
sal_uInt16 Count() const
std::atomic< SvNumberFormatter * > mpNumberFormatter
Definition: doc.hxx:263
Marks a position in the document model.
Definition: pam.hxx:35
#define RES_CONDTXTFMTCOLL
Definition: hintids.hxx:280
static SwFormat * FindFormatByName(const SwFormatsBase &rFormatArr, const OUString &rName)
Definition: docfmt.cxx:1601
#define RES_HEADER
Definition: hintids.hxx:203
Pagedescriptor Client of SwPageDesc that is "described" by the attribute.
Definition: fmtpdsc.hxx:35
SwFrameFormat & GetLeft()
Definition: pagedesc.hxx:218
long GetFirstLineIndent() const
bool IsDefault() const
Definition: format.hxx:109
bool UpdateParRsid(SwTextNode *pTextNode, sal_uInt32 nVal=0)
Definition: docfmt.cxx:432
size_t size() const
Definition: pagedesc.hxx:419
bool isCHRATR(const sal_uInt16 nWhich)
Definition: hintids.hxx:343
void SetPoolHelpId(sal_uInt16 nId)
Definition: format.hxx:148
SwPageDesc * GetPageDesc()
Definition: fmtpdsc.hxx:62
std::pair< const_iterator, bool > push_back(const value_type &x)
Definition: docfmt.cxx:2078
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
const SwFormatHeader & GetHeader(bool=true) const
Definition: fmthdft.hxx:97
static bool lcl_RstTextAttr(const SwNodePtr &rpNd, void *pArgs)
pArgs contains the document's ChrFormatTable Is need for selections at the beginning/end and with no ...
virtual bool SetAttr(const SfxPoolItem &) override
overriding to handle change of certain paragraph attributes
Definition: ndtxt.cxx:4892
bool isFRMATR(const sal_uInt16 nWhich)
Definition: hintids.hxx:369
void SetPoolHelpId(sal_uInt16 const nId)
Definition: pagedesc.hxx:257
std::string GetValue
SvNumberFormatter * GetNumberFormatter(bool bCreate=true)
Definition: doc.hxx:1401
bool isTXTATR(const sal_uInt16 nWhich)
Definition: hintids.hxx:357
virtual AppendResult AppendRedline(SwRangeRedline *pNewRedl, bool bCallDelete)=0
Append a new redline.
virtual void SetRedlineFlags_intern(RedlineFlags eMode)=0
Set a new redline mode.
virtual SfxPoolItem * Clone(SfxItemPool *pPool=nullptr) const =0
const_iterator find(const value_type &x) const
Definition: docfmt.cxx:2046
SwNodeIndex nNode
Definition: pam.hxx:37
const_iterator begin() const
Definition: docary.hxx:257
virtual void InsertItemSet(const SwPaM &rRg, const SfxItemSet &, const SetAttrMode nFlags=SetAttrMode::DEFAULT, SwRootFrame const *pLayout=nullptr)=0
SwTextFormatColl * FindTextFormatCollByName(const OUString &rName) const
Definition: doc.hxx:795
std::unique_ptr< SwNodes > m_pNodes
Definition: doc.hxx:193
virtual void SetModified()=0
Must be called manually at changes of format.
OUString sDataSource
Definition: swdbdata.hxx:30
const SwPosition * GetMark() const
Definition: pam.hxx:209
SwFrameFormat * MakeFrameFormat(const OUString &rFormatName, SwFrameFormat *pDerivedFrom, bool bBroadcast=false, bool bAuto=true)
Definition: docfmt.cxx:801
SwFrameFormat & GetFirstMaster()
Definition: pagedesc.hxx:219
bool IsAutoRule() const
Definition: numrule.hxx:226
bool DontExpandFormat(const SwIndex &rIdx, bool bFlag=true, bool bFormatToTextAttributes=true)
When appropriate set DontExpand-flag at INet or character styles respectively.
Definition: ndtxt.cxx:1608
#define RES_FRMATR_END
Definition: hintids.hxx:238
SwContentFrame * getLayoutFrame(const SwRootFrame *, const SwPosition *pPos=nullptr, std::pair< Point, bool > const *pViewPosAndCalcFrame=nullptr) const
Definition: node.cxx:1147
ByPos & m_PosIndex
Definition: docary.hxx:211
Definition: doc.hxx:185
TElementType * Next()
Definition: calbck.hxx:373
#define RES_TXTATR_UNKNOWN_CONTAINER
Definition: hintids.hxx:145
sal_uInt16 sal_Char sal_Char * pDesc
void DelDiffs(const SfxItemSet &rSet)
Delete all attributes that are not in rFormat.
Definition: format.cxx:711
SwFrameFormat * CopyFrameFormat(const SwFrameFormat &)
copy the frame format
Definition: docfmt.cxx:1141
void SetTextLeft(const long nL, const sal_uInt16 nProp=100)
#define RES_PARATR_LIST_ID
Definition: hintids.hxx:186
SwNode & GetNode() const
Definition: ndindex.hxx:119
bool isDrawingLayerAttribute(const sal_uInt16 nWhich)
Definition: hintids.hxx:373
long SwTwips
Definition: swtypes.hxx:49
const OUString & GetName() const
Definition: numrule.hxx:221
#define RES_PARATR_LIST_ISCOUNTED
Definition: hintids.hxx:190
void RenameFormat(SwFormat &rFormat, const OUString &sNewName, bool bBroadcast=false)
Definition: docfmt.cxx:1878
Content, content of frame (header, footer, fly).
Definition: fmtcntnt.hxx:31
#define RES_PARATR_LIST_END
Definition: hintids.hxx:192
bool AreListLevelIndentsApplicable() const
Determines, if the list level indent attributes can be applied to the paragraph.
Definition: ndtxt.cxx:4412
SwGrfFormatColl * MakeGrfFormatColl(const OUString &rFormatName, SwGrfFormatColl *pDerivedFrom)
Definition: docfmt.cxx:929
IDocumentUndoRedo & GetIDocumentUndoRedo()
Definition: doc.cxx:143
SwTextAttr * GetTextAttrAt(sal_Int32 const nIndex, sal_uInt16 const nWhich, enum GetTextAttrMode const eMode=DEFAULT) const
get the innermost text attribute covering position nIndex.
Definition: ndtxt.cxx:1729
SwDrawFrameFormat * MakeDrawFrameFormat(const OUString &rFormatName, SwFrameFormat *pDerivedFrom)
Definition: docfmt.cxx:741
std::vector< SwTextFormatColl * >::const_iterator const_iterator
Definition: docary.hxx:69
SwFormat * MakeFrameFormat_(const OUString &, SwFormat *, bool, bool)
Definition: docfmt.cxx:826
SwClient * Remove(SwClient *pDepend)
Definition: calbck.cxx:259
const_iterator end() const
Definition: docary.hxx:258
IDocumentContentOperations const & getIDocumentContentOperations() const
Definition: doc.cxx:314
#define RES_CNTNT
Definition: hintids.hxx:202
bool HasWriterListeners() const
Definition: calbck.hxx:208
#define RES_TXTATR_END
Definition: hintids.hxx:159
The root element of a Writer document layout.
Definition: rootfrm.hxx:79
void Copy_(const SwNodeRange &rRg, const SwNodeIndex &rInsPos, bool bNewFrames=true) const
Definition: ndarr.hxx:177
int GetActualListLevel() const
Returns the actual list level of this text node, when it is a list item.
Definition: ndtxt.cxx:4097
const SwFrameFormats * GetSpzFrameFormats() const
Definition: doc.hxx:737
SwFrameFormatsBase::value_type value_type
Definition: docary.hxx:218
void ReplaceStyles(const SwDoc &rSource, bool bIncludePageStyles=true)
Definition: docfmt.cxx:1520
ByTypeAndName & m_TypeAndNameIndex
Definition: docary.hxx:212
void SetFollow(const SwPageDesc *pNew)
Definition: pagedesc.hxx:293
const OUString & GetName() const
Definition: pagedesc.hxx:187
SwFlyFrameFormat * MakeFlyFrameFormat(const OUString &rFormatName, SwFrameFormat *pDerivedFrom)
Create the formats.
Definition: docfmt.cxx:732
IDocumentDrawModelAccess const & getIDocumentDrawModelAccess() const
Definition: doc.cxx:154
bool IsAlive(SwFrameFormat const *) const
not so fast check that given format is still alive (i.e. contained here)
Definition: docfmt.cxx:2115
static bool lcl_SetTextFormatColl(const SwNodePtr &rpNode, void *pArgs)
Definition: docfmt.cxx:984
void DelTableFrameFormat(SwTableFormat *pFormat)
Definition: docfmt.cxx:723
void DelCharFormat(size_t nFormat, bool bBroadcast=false)
Delete the formats.
Definition: docfmt.cxx:656
IDocumentFieldsAccess const & getIDocumentFieldsAccess() const
Definition: doc.cxx:356
constexpr::Color COL_AUTO(0xFF, 0xFF, 0xFF, 0xFF)
#define RES_PARATR_LIST_ISRESTART
Definition: hintids.hxx:188
const SwPageFootnoteInfo & GetFootnoteInfo() const
Definition: pagedesc.hxx:196
#define POOLATTR_END
Definition: hintids.hxx:65
#define RES_CHRATR_END
Definition: hintids.hxx:115
const OUString & GetValue() const
Definition: fmtinfmt.hxx:75
const SfxPoolItem * NextItem()
bool IsAssignedToListLevelOfOutlineStyle() const
Definition: fmtcol.hxx:109
const SwCharFormat * GetDfltCharFormat() const
Definition: doc.hxx:746
void SetWithRsid()
Definition: UndoInsert.hxx:88
provides some methods for generic operations on lists that contain SwFormat* subclasses.
Definition: docary.hxx:50
std::unique_ptr< SwFrameFormats > mpTableFrameFormatTable
Definition: doc.hxx:241
bool isGRFATR(const sal_uInt16 nWhich)
Definition: hintids.hxx:377
void SetFootnoteInfo(const SwPageFootnoteInfo &rNew)
Definition: pagedesc.hxx:198
SwIndex nContent
Definition: pam.hxx:38
void SetPoolFormatId(sal_uInt16 nId)
Definition: format.hxx:144
void Remove(const sal_uInt16 nPos, const sal_uInt16 nLen=1)
sal_uInt16 GetPoolFormatId() const
Query and set PoolFormat-Id.
Definition: pagedesc.hxx:254
bool SetTextFormatColl(const SwPaM &rRg, SwTextFormatColl *pFormat, const bool bReset=true, const bool bResetListAttrs=false, SwRootFrame const *pLayout=nullptr)
Add 4th optional parameter .
Definition: docfmt.cxx:1064
IDocumentStylePoolAccess const & getIDocumentStylePoolAccess() const
Definition: doc.cxx:425
void SetLandscape(bool bNew)
Definition: pagedesc.hxx:191
void SetAttr(const SfxPoolItem &, SwFormat &)
Set attribute in given format.1y If Undo is enabled, the old values is added to the Undo history...
Definition: docfmt.cxx:448
void SetNextTextFormatColl(SwTextFormatColl &rNext)
Inline implementations.
Definition: fmtcol.hxx:228
#define RES_PARATR_TABSTOP
Definition: hintids.hxx:167
SwFormat * MakeCharFormat_(const OUString &, SwFormat *, bool, bool)
Definition: docfmt.cxx:859
const OUString & GetName() const
Definition: format.hxx:111
SwBreakIt * g_pBreakIt
Definition: breakit.cxx:33
std::unique_ptr< SwNumRuleTable > mpNumRuleTable
Definition: doc.hxx:265
static bool IsFuzzing()
const SfxPoolItem & GetDefault(sal_uInt16 nFormatHint) const
Get the default attribute in this document.
Definition: docfmt.cxx:650
Footer, for pageformats Client of FrameFormat describing the footer.
Definition: fmthdft.hxx:64
sal_uLong GetIndex() const
Definition: ndindex.hxx:152
virtual void DelAllUndoObj()=0
Delete all Undo actions.
void SetPoolHlpFileId(sal_uInt8 nId)
Definition: format.hxx:150
sal_Int32 GetStart() const
Definition: txatbase.hxx:82
sal_uInt32 mnRsid
Definition: doc.hxx:291
std::unique_ptr< SwFrameFormats > mpSpzFrameFormatTable
Definition: doc.hxx:239
void SetFormatItemByAutoFormat(const SwPaM &rPam, const SfxItemSet &)
Definition: docfmt.cxx:1793
SwTextFormatColl * CopyTextColl(const SwTextFormatColl &rColl)
copy TextNodes
Definition: docfmt.cxx:1156
void SetPoolHlpFileId(sal_uInt8 const nId)
Definition: pagedesc.hxx:259
const SfxPoolItem * GetDfltAttr(sal_uInt16 nWhich)
Get the default attribute from corresponding default attribute table.
Definition: hints.cxx:153
bool empty() const
Definition: docary.hxx:224
#define RES_PARATR_NUMRULE
Definition: hintids.hxx:171
#define RES_TXTFMTCOLL
Definition: hintids.hxx:277
#define RES_PARATR_BEGIN
Definition: hintids.hxx:161
SfxStyleFamily
virtual bool DoesUndo() const =0
Is Undo enabled?
SwAttrPool * GetPool() const
Definition: swatrset.hxx:190
void SetExtraData(const SwRedlineExtraData *pData)
ExtraData gets copied, the pointer is therefore not taken over by the RedLineObject.
Definition: redline.hxx:214
virtual ~SwFrameFormats() override
Definition: docfmt.cxx:2041
bool SetDerivedFrom(SwFormat *pDerivedFrom=nullptr)
0 is Default.
Definition: format.cxx:326
sal_uInt16 GetPoolFormatId() const
Get and set Pool style IDs.
Definition: format.hxx:143
virtual void ModifyNotification(const SfxPoolItem *pOldValue, const SfxPoolItem *pNewValue)
Definition: calbck.hxx:154
SwUndoFormatAttr * GetUndo() const
SwPageDesc * FindPageDesc(const OUString &rName, size_t *pPos=nullptr) const
Definition: docdesc.cxx:822
Base class for various Writer styles.
Definition: format.hxx:43
SwDBData maDBData
Definition: doc.hxx:201
#define RES_BACKGROUND
Definition: hintids.hxx:212
virtual bool ResetAttr(sal_uInt16 nWhich1, sal_uInt16 nWhich2=0)
Definition: node.cxx:1596
void DelTextFormatColl(size_t nFormat, bool bBroadcast=false)
Definition: docfmt.cxx:940
#define RES_CHRATR_COLOR
Definition: hintids.hxx:72
SwNumRule & CopyNumRule(SwDoc *, const SwNumRule &)
A kind of copy-constructor to make sure the num formats are attached to the correctCharFormats of a d...
Definition: number.cxx:803
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:136
bool IsHeaderShared() const
Definition: pagedesc.hxx:298
struct _xmlTextWriter * xmlTextWriterPtr
const SwAttrSet * GetpSwAttrSet() const
Definition: node.hxx:443
std::unique_ptr< SwTextFormatColls > mpTextFormatCollTable
Definition: doc.hxx:242
SwNumRule * FindNumRulePtr(const OUString &rName) const
Definition: docnum.cxx:2414
virtual void AppendUndo(std::unique_ptr< SwUndo > pUndo)=0
Add new Undo action.
virtual void ClearRedo()=0
Delete all Redo actions.
Style of a layout element.
Definition: frmfmt.hxx:57
::sw::UndoManager & GetUndoManager()
Definition: doc.cxx:132
#define SW_MOD()
Definition: swmodule.hxx:256
virtual const SwExtraRedlineTable & GetExtraRedlineTable() const =0
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
void SetYear2000(sal_uInt16 nVal)
void dumpAsXml(xmlTextWriterPtr=nullptr) const
Dumps the entire nodes structure to the given destination (file nodes.xml in the current directory by...
Definition: docfmt.cxx:1918
static void SetTextFormatCollNext(SwTextFormatColl *pTextColl, const SwTextFormatColl *pDel)
Definition: docfmt.cxx:84
void ForEach(FnForEach_SwNodes fnForEach, void *pArgs=nullptr)
Definition: ndarr.hxx:144
void SetNumType(const SvxNumberType &rNew)
Definition: pagedesc.hxx:194
const SwPosition * GetPoint() const
Definition: pam.hxx:207
std::vector< SwNumRule * >::size_type size_type
Definition: docary.hxx:70
SwFormat * MakeTextFormatColl_(const OUString &, SwFormat *, bool, bool)
Definition: docfmt.cxx:893
SwIndex & Assign(SwIndexReg *, sal_Int32)
Definition: index.cxx:198
const SwPageDesc & GetPageDesc(const size_t i) const
Definition: doc.hxx:877
#define LANGUAGE_SYSTEM
const std::unique_ptr< ::sw::mark::MarkManager > mpMarkManager
Definition: doc.hxx:208
void SetAuto(bool bNew)
Definition: format.hxx:159
bool GetLandscape() const
Definition: pagedesc.hxx:190
bool GetParaAttr(SfxItemSet &rSet, sal_Int32 nStt, sal_Int32 nEnd, const bool bOnlyTextAttr=false, const bool bGetFromChrFormat=true, const bool bMergeIndentValuesOfNumRule=false, SwRootFrame const *pLayout=nullptr) const
Query the attributes of textnode over the range.
Definition: thints.cxx:2062
::sw::DocumentContentOperationsManager const & GetDocumentContentOperationsManager() const
Definition: doc.cxx:324
virtual size_t GetFormatCount() const =0
bool bExactRange
From the attributes included in the range, delete only the ones which have exactly same range...
TElementType * First()
Definition: calbck.hxx:342
int i
SwContentNode * GetContentNode()
Definition: node.hxx:615
SwPageDesc * MakePageDesc(const OUString &rName, const SwPageDesc *pCpy=nullptr, bool bRegardLanguage=true, bool bBroadcast=false)
Definition: docdesc.cxx:639
const OUString & GetValue() const
sal_uInt16 Count() const
bool HasMark() const
A PaM marks a selection if Point and Mark are distinct positions.
Definition: pam.hxx:205
std::set< Color > GetDocColors()
Definition: docfmt.cxx:1972
UseOnPage ReadUseOn() const
Definition: pagedesc.hxx:215
SwDoc * GetDoc()
Definition: node.hxx:702
std::unique_ptr< SwTextFormatColl > mpDfltTextFormatColl
Definition: doc.hxx:234
virtual void SetName(const OUString &rNewName, bool bBroadcast=false)
Definition: format.cxx:151
void dumpAsXml(xmlTextWriterPtr pWriter) const
Definition: pagedesc.cxx:621
Marks a character position inside a document model node.
Definition: index.hxx:37
size_t size() const
Definition: docary.hxx:91
void UnlockModify()
Definition: calbck.hxx:214
void dumpAsXml(xmlTextWriterPtr pWriter) const
Definition: fldbas.cxx:159
#define RES_CHRATR_BEGIN
Definition: hintids.hxx:69
void SetEvalDateFormat(NfEvalDateFormat eEDF)
const SwFormatFooter & GetFooter(bool=true) const
Definition: fmthdft.hxx:99
SwNumRule * GetNumRule(bool bInParent=true) const
Returns numbering rule of this text node.
Definition: ndtxt.cxx:2813
void dumpAsXml(xmlTextWriterPtr pWriter) const
Definition: docredln.cxx:723
IDocumentState const & getIDocumentState() const
Definition: doc.cxx:393
void LockModify()
Definition: calbck.hxx:213
std::set< SwRootFrame * > GetAllLayouts()
Definition: doclay.cxx:1660
SwPageDescsBase::size_type size_type
Definition: pagedesc.hxx:409
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
Definition: format.cxx:396
void CopyFlyInFlyImpl(const SwNodeRange &rRg, SwPaM const *const pCopiedPaM, const SwNodeIndex &rStartIdx, const bool bCopyFlyAtFly=false) const
Marks a node in the document model.
Definition: ndindex.hxx:31
bool IsFooterShared() const
Definition: pagedesc.hxx:302
virtual const SwFieldTypes * GetFieldTypes() const =0
bool mbIsAutoFormatRedline
Definition: doc.hxx:306
virtual sal_uInt16 ResetAllAttr()
Definition: node.cxx:1683
#define RES_UNKNOWNATR_BEGIN
Definition: hintids.hxx:268
bool HasSwAttrSet() const
Definition: node.hxx:444
std::unique_ptr< SwGrfFormatColls > mpGrfFormatCollTable
Definition: doc.hxx:243
tuple index
void SetPoolFormatId(sal_uInt16 const nId)
Definition: pagedesc.hxx:255
const SwDoc * GetDoc() const
The document is set in SwAttrPool now, therefore you always can access it.
Definition: format.hxx:119
virtual SwFormatColl * ChgFormatColl(SwFormatColl *)
Definition: node.cxx:1182
void CopyHeader(const SwFrameFormat &rSrcFormat, SwFrameFormat &rDestFormat)
Copy header (with contents) from SrcFormat to DestFormat (can also be copied into other document)...
Definition: doc.hxx:890
void SetTextFormatCollByAutoFormat(const SwPosition &rPos, sal_uInt16 nPoolId, const SfxItemSet *pSet)
Definition: docfmt.cxx:1745
#define RES_PARATR_LIST_BEGIN
Definition: hintids.hxx:185
const SfxPoolItem & GetDefaultItem(sal_uInt16 nWhich) const
SvxNumPositionAndSpaceMode GetPositionAndSpaceMode() const
#define RES_TXTATR_INETFMT
Definition: hintids.hxx:142
void Add(const SfxPoolItem *pOldValue, const SfxPoolItem *pNewValue, sal_uLong nNodeIdx)
Definition: rolbck.cxx:981
std::unique_ptr< SwUndoFormatAttr > ReleaseUndo()
IDocumentLayoutAccess const & getIDocumentLayoutAccess() const
Definition: doc.cxx:404
const SwPosition * Start() const
Definition: pam.hxx:212
const SwNumRuleItem & GetNumRule(bool=true) const
Definition: paratr.hxx:218
void ResetAttrAtFormat(const sal_uInt16 nWhichId, SwFormat &rChangedFormat)
Definition: docfmt.cxx:479
void RstTextAttrs(const SwPaM &rRg, bool bInclRefToxMark=false, bool bExactRange=false, SwRootFrame const *pLayout=nullptr)
Definition: docfmt.cxx:218
SwTextNode * GetParaPropsNode(SwRootFrame const &rLayout, SwNodeIndex const &rNode)
Definition: txtfrm.cxx:336
bool isPARATR(const sal_uInt16 nWhich)
Definition: hintids.hxx:361
SwGrfFormatColl * CopyGrfColl(const SwGrfFormatColl &rColl)
copy the graphic nodes
Definition: docfmt.cxx:1223
#define RES_LR_SPACE
Definition: hintids.hxx:198
const SwPageDesc * GetFollow() const
Definition: pagedesc.hxx:246
const SwNodeIndex * GetContentIdx() const
Definition: fmtcntnt.hxx:46
const SwFrameFormat * GetDfltFrameFormat() const
Definition: doc.hxx:740
void AssignToListLevelOfOutlineStyle(const int nAssignedListLevel)
Definition: fmtcol.cxx:594
#define RES_FOOTER
Definition: hintids.hxx:204
long GetIndentAt() const
virtual bool SetFormatAttr(const SfxPoolItem &rAttr)
Definition: format.cxx:458
css::uno::Reference< css::i18n::XBreakIterator > const & GetBreakIter() const
Definition: breakit.hxx:62
std::unique_ptr< SwSectionFormats > mpSectionFormatTable
Definition: doc.hxx:240
SfxItemPool * GetSecondaryPool() const
static bool lcl_RstAttr(const SwNodePtr &rpNd, void *pArgs)
Definition: docfmt.cxx:92
ignore Redlines
sal_uInt16 Which() const
for Querying of Writer-functions.
Definition: format.hxx:78
void CopyPageDescHeaderFooterImpl(bool bCpyHeader, const SwFrameFormat &rSrcFormat, SwFrameFormat &rDestFormat)
Definition: docfmt.cxx:1339
const SwNumFormat & Get(sal_uInt16 i) const
Definition: number.cxx:77
bool IsModifyLocked() const
Definition: calbck.hxx:218
SwFormat * DerivedFrom() const
Definition: format.hxx:108
const css::lang::Locale & GetLocale(const LanguageType aLang)
Definition: breakit.hxx:67
void SetDefault(const SfxPoolItem &)
Set attribute as new default attribute in current document.
Definition: docfmt.cxx:524
SwFrameFormat & GetMaster()
Definition: pagedesc.hxx:217
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
SwTableNumFormatMerge(const SwDoc &rSrc, SwDoc &rDest)
Definition: docfmt.cxx:1723
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:79
SwUndo * GetLastUndo()
Definition: docundo.cxx:237
void CopyPageDesc(const SwPageDesc &rSrcDesc, SwPageDesc &rDstDesc, bool bCopyPoolIds=true)
Copy the complete PageDesc - beyond document and "deep"! Optionally copying of PoolFormatId, -HlpId can be prevented.
Definition: docfmt.cxx:1399
void MoveLeftMargin(const SwPaM &rPam, bool bRight, bool bModulus, SwRootFrame const *pLayout=nullptr)
Adjust left margin via object bar (similar to adjustment of numerations).
Definition: docfmt.cxx:1617
virtual bool ResetFormatAttr(sal_uInt16 nWhich1, sal_uInt16 nWhich2=0)
Definition: format.cxx:650
IDocumentRedlineAccess const & getIDocumentRedlineAccess() const
Definition: doc.cxx:334
void SetInvalidRule(bool bFlag)
Definition: number.cxx:855
virtual bool SetAttr(const SfxPoolItem &)
made virtual
Definition: node.cxx:1484
void SetTextFirstLineOfst(const short nF, const sal_uInt16 nProp=100)
const SwCharFormats * GetCharFormats() const
Definition: doc.hxx:733
void UpdateRsid(const SwPaM &rRg, sal_Int32 nLen)
Set the rsid of the next nLen symbols of rRg to the current session number.
Definition: docfmt.cxx:401
ByPos::const_iterator const_iterator
Definition: docary.hxx:215
void CopyFooter(const SwFrameFormat &rSrcFormat, SwFrameFormat &rDestFormat)
Copy footer (with contents) from SrcFormat to DestFormat.
Definition: doc.hxx:895
sal_uInt16 GetPoolHelpId() const
Get and set Help-IDs for document templates.
Definition: format.hxx:147
sal_uInt16 GetWhich(sal_uInt16 nSlot, bool bDeep=true) const
#define SAL_WARN_IF(condition, area, stream)
void CopyAttrs(const SwFormat &)
Copy attributes even among documents.
Definition: format.cxx:178
const SwTextFormatColls * GetTextFormatColls() const
Definition: doc.hxx:774
std::unique_ptr< SwCharFormat > mpDfltCharFormat
Definition: doc.hxx:233
#define RES_PARATR_LIST_LEVEL
Definition: hintids.hxx:187
void dumpAsXml(xmlTextWriterPtr pWriter) const
Definition: docredln.cxx:86
SwCharFormat * CopyCharFormat(const SwCharFormat &)
copy the char format
Definition: docfmt.cxx:1148
SwConditionTextFormatColl * MakeCondTextFormatColl(const OUString &rFormatName, SwTextFormatColl *pDerivedFrom, bool bBroadcast=false)
Definition: docfmt.cxx:903
SwFrameFormat & GetFirstLeft()
Definition: pagedesc.hxx:220
const SwNumRuleTable & GetNumRuleTable() const
Definition: doc.hxx:1057
bool DontExpandFormat(const SwPosition &rPos, bool bFlag=true)
Definition: docfmt.cxx:1681
std::unique_ptr< SwCharFormats > mpCharFormatTable
Definition: doc.hxx:238
sal_Int32 GetIndex() const
Definition: index.hxx:95
void WriteUseOn(UseOnPage const eNew)
Definition: pagedesc.hxx:214
void Differentiate(const SfxItemSet &rSet)
#define RES_CHRFMT
Definition: hintids.hxx:274
SwNodes & GetNodes()
Definition: doc.hxx:402
Item2Range GetItemSurrogates(sal_uInt16 nWhich) const
const SwPosition * End() const
Definition: pam.hxx:217
std::unique_ptr< SwFrameFormats > mpFrameFormatTable
Definition: doc.hxx:237
LanguageType GetLang(const sal_Int32 nBegin, const sal_Int32 nLen=0, sal_uInt16 nScript=0) const
Definition: thints.cxx:3367
const SwModify * GetRegisteredIn() const
Definition: calbck.hxx:157
const sal_Int32 * End() const
Definition: txatbase.hxx:148
sal_uInt16 GetPoolHelpId() const
Definition: pagedesc.hxx:256
#define RES_CHRATR_HIGHLIGHT
Definition: hintids.hxx:111
Reference< XComponentContext > getProcessComponentContext()
#define RES_PARATR_ADJUST
Definition: hintids.hxx:163
sal_uInt16 MakeNumRule(const OUString &rName, const SwNumRule *pCpy=nullptr, bool bBroadcast=false, const SvxNumberFormat::SvxNumPositionAndSpaceMode eDefaultNumberFormatPositionAndSpaceMode=SvxNumberFormat::LABEL_WIDTH_AND_POSITION)
Definition: docnum.cxx:2448
size_t GetTableFrameFormatCount(bool bUsed) const
Definition: docfmt.cxx:750
bool IsHideRedlines() const
Replacement for sw::DocumentRedlineManager::GetRedlineFlags() (this is layout-level redline hiding)...
Definition: rootfrm.hxx:416
Get reference.
Definition: reffld.hxx:65
Header, for PageFormats Client of FrameFormat describing the header.
Definition: fmthdft.hxx:33
SwFrameFormat & GetTableFrameFormat(size_t nFormat, bool bUsed) const
Definition: docfmt.cxx:767
virtual void CallSwClientNotify(const SfxHint &rHint) const override
Definition: calbck.cxx:376
bool HasName(const OUString &rName) const
Definition: format.hxx:112
bool HasOutlineStyleToBeWrittenAsNormalListStyle(SwDoc &rDoc)
method to check, if the outline style has to written as a normal list style
Definition: docfmt.cxx:1993
void ChgFormat(SwFormat &rFormat, const SfxItemSet &rSet)
Definition: docfmt.cxx:1846
void DelFrameFormat(SwFrameFormat *pFormat, bool bBroadcast=false)
Definition: docfmt.cxx:683
#define RES_PARATR_RSID
Definition: hintids.hxx:179
const sal_uInt16 * GetRanges() const
void CopyFormatArr(const SwFormatsBase &rSourceArr, SwFormatsBase const &rDestArr, FNCopyFormat fnCopyFormat, SwFormat &rDfltFormat)
Definition: docfmt.cxx:1249
virtual RedlineFlags GetRedlineFlags() const =0
Query the currently set redline mode.
#define SAL_WARN(area, stream)
bool ContainsFormat(SwFrameFormat const &rFormat) const
fast check if given format is contained here pFormat must not have been deleted
Definition: docfmt.cxx:2110
std::unique_ptr< SwFrameFormat > mpDfltFrameFormat
Definition: doc.hxx:230
SwFormatColl * GetFormatColl() const
Definition: node.hxx:447
bool newDefault(const value_type &x)
Definition: docfmt.cxx:2120
virtual SwFieldType * GetSysFieldType(const SwFieldIds eWhich) const =0
SvNumberFormatter * pNFormat
Definition: mvsave.hxx:186
bool IsFirstShared() const
Definition: pagedesc.cxx:376
virtual SwFormat * GetFormat(size_t idx) const =0
SwFrameFormatsBase::size_type size_type
Definition: docary.hxx:217
virtual void SetMark()
Unless this is called, the getter method of Mark will return Point.
Definition: pam.cxx:459
#define RES_UNKNOWNATR_END
Definition: hintids.hxx:270
const SwAttrSet & GetAttrSet() const
For querying the attribute array.
Definition: format.hxx:116
void FormatToTextAttr(SwTextNode *pNd)
Convey attributes of an AttrSet (AutoFormat) to SwpHintsArray.
Definition: thints.cxx:2462
virtual const SwRedlineTable & GetRedlineTable() const =0
const SwFrameFormats * GetFrameFormats() const
Definition: doc.hxx:731
#define RES_PAGEDESC
Definition: hintids.hxx:200
#define RES_BREAK
Definition: hintids.hxx:201
NF_EVALDATEFORMAT_FORMAT_INTL
std::pair< const_range_iterator, const_range_iterator > rangeFind(sal_uInt16 type, const OUString &name) const
Definition: docfmt.cxx:2054
long GetTextLeft() const
void DeleteAndDestroyAll(bool keepDefault=false)
Definition: docfmt.cxx:2065
void RegisterToPageDesc(SwPageDesc &)
Definition: atrfrm.cxx:659
bool isBOXATR(const sal_uInt16 nWhich)
Definition: hintids.hxx:381
bool IsTextNode() const
Definition: node.hxx:636
bool IsAuto() const
Query / set AutoFormat-flag.
Definition: format.hxx:158
OUString sCommand
Definition: swdbdata.hxx:31
Merge GetRedlineMergeFlag() const
Definition: node.hxx:97
void CopyBookmarks(const SwPaM &rPam, SwPosition &rCpyPam)
SwFrameFormatsBase m_Array
Definition: docary.hxx:210
sal_uInt16 Which() const
#define RES_PARATR_LIST_RESTARTVALUE
Definition: hintids.hxx:189
void BroadcastStyleOperation(const OUString &rName, SfxStyleFamily eFamily, SfxHintId nOp)
Definition: docdesc.cxx:596
SwTableBoxFormat * MakeTableBoxFormat()
Definition: docfmt.cxx:1696
void dumpAsXml(xmlTextWriterPtr pWriter) const
Definition: docfmt.cxx:1961
const SfxPoolItem * GetCurItem() const
SwTextFormatColl & GetNextTextFormatColl() const
Definition: fmtcol.hxx:97
const SwAttrPool & GetAttrPool() const
Definition: doc.hxx:1309
std::pair< SwTextNode *, SwTextNode * > GetFirstAndLastNode(SwRootFrame const &rLayout, SwNodeIndex const &rPos)
Definition: txtfrm.cxx:363
const SwFormatINetFormat & GetINetFormat() const
Definition: txatbase.hxx:224
std::unique_ptr< SwGrfFormatColl > mpDfltGrfFormatColl
Definition: doc.hxx:235
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
Definition: ndtxt.hxx:842
SvNumberFormatterIndexTable * MergeFormatter(SvNumberFormatter &rNewTable)
void SetPoolDefaultItem(const SfxPoolItem &)
SwNumRule * GetOutlineNumRule() const
Definition: doc.hxx:1015
#define RES_CHRATR_RSID
Definition: hintids.hxx:108
bool isPARATR_LIST(const sal_uInt16 nWhich)
Definition: hintids.hxx:365
static SwStartNode * MakeEmptySection(const SwNodeIndex &rIdx, SwStartNodeType=SwNormalStartNode)
Create an empty section of Start- and EndNote.
Definition: nodes.cxx:1890
Base class of the Writer document model elements.
Definition: node.hxx:79
SwTextFormatColl * GetTextColl() const
Definition: ndtxt.hxx:836
const SvxNumberType & GetNumType() const
Definition: pagedesc.hxx:193