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