1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <DocumentSettingManager.hxx> //For SwFmt::getIDocumentSettingAccess()
21 #include <IDocumentTimerAccess.hxx>
23 #include <fmtcolfunc.hxx>
26 #include <hintids.hxx>
28 #include <o3tl/unit_conversion.hxx>
29 #include <osl/diagnose.h>
30 #include <sal/log.hxx>
31 #include <svl/grabbagitem.hxx>
32 #include <svx/sdr/attribute/sdrallfillattributeshelper.hxx>
33 #include <svx/unobrushitemhelper.hxx>
34 #include <svx/xdef.hxx>
37 using namespace com::sun::star
;
39 SwFormat::SwFormat( SwAttrPool
& rPool
, const char* pFormatNm
,
40 const WhichRangesContainer
& pWhichRanges
, SwFormat
*pDrvdFrame
,
41 sal_uInt16 nFormatWhich
) :
42 m_aFormatName( OUString::createFromAscii(pFormatNm
) ),
43 m_aSet( rPool
, pWhichRanges
),
44 m_nWhichId( nFormatWhich
),
45 m_nPoolFormatId( USHRT_MAX
),
46 m_nPoolHelpId( USHRT_MAX
),
47 m_nPoolHlpFileId( UCHAR_MAX
)
49 m_bAutoUpdateOnDirectFormat
= false; // LAYER_IMPL
51 m_bFormatInDTOR
= m_bHidden
= false;
55 pDrvdFrame
->Add(this);
56 m_aSet
.SetParent( &pDrvdFrame
->m_aSet
);
60 SwFormat::SwFormat( SwAttrPool
& rPool
, OUString aFormatNm
,
61 const WhichRangesContainer
& pWhichRanges
, SwFormat
* pDrvdFrame
,
62 sal_uInt16 nFormatWhich
) :
63 m_aFormatName( std::move(aFormatNm
) ),
64 m_aSet( rPool
, pWhichRanges
),
65 m_nWhichId( nFormatWhich
),
66 m_nPoolFormatId( USHRT_MAX
),
67 m_nPoolHelpId( USHRT_MAX
),
68 m_nPoolHlpFileId( UCHAR_MAX
)
70 m_bAutoUpdateOnDirectFormat
= false; // LAYER_IMPL
72 m_bFormatInDTOR
= m_bHidden
= false;
76 pDrvdFrame
->Add(this);
77 m_aSet
.SetParent( &pDrvdFrame
->m_aSet
);
81 SwFormat::SwFormat( const SwFormat
& rFormat
) :
82 sw::BorderCacheOwner(),
83 m_aFormatName( rFormat
.m_aFormatName
),
84 m_aSet( rFormat
.m_aSet
),
85 m_nWhichId( rFormat
.m_nWhichId
),
86 m_nPoolFormatId( rFormat
.GetPoolFormatId() ),
87 m_nPoolHelpId( rFormat
.GetPoolHelpId() ),
88 m_nPoolHlpFileId( rFormat
.GetPoolHlpFileId() )
90 m_bFormatInDTOR
= false; // LAYER_IMPL
91 m_bAutoFormat
= rFormat
.m_bAutoFormat
;
92 m_bHidden
= rFormat
.m_bHidden
;
93 m_bAutoUpdateOnDirectFormat
= rFormat
.m_bAutoUpdateOnDirectFormat
;
95 if( auto pDerived
= rFormat
.DerivedFrom() )
98 m_aSet
.SetParent( &pDerived
->m_aSet
);
100 // a few special treatments for attributes
101 m_aSet
.SetModifyAtAttr( this );
104 SwFormat
&SwFormat::operator=(const SwFormat
& rFormat
)
109 m_nWhichId
= rFormat
.m_nWhichId
;
110 m_nPoolFormatId
= rFormat
.GetPoolFormatId();
111 m_nPoolHelpId
= rFormat
.GetPoolHelpId();
112 m_nPoolHlpFileId
= rFormat
.GetPoolHlpFileId();
114 InvalidateInSwCache(RES_OBJECTDYING
);
116 // copy only array with attributes delta
117 SwAttrSet
aOld( *m_aSet
.GetPool(), m_aSet
.GetRanges() ),
118 aNew( *m_aSet
.GetPool(), m_aSet
.GetRanges() );
119 m_aSet
.Intersect_BC( rFormat
.m_aSet
, &aOld
, &aNew
);
120 (void)m_aSet
.Put_BC( rFormat
.m_aSet
, &aOld
, &aNew
);
122 // a few special treatments for attributes
123 m_aSet
.SetModifyAtAttr( this );
125 // create PoolItem attribute for Modify
128 sw::ClientNotifyAttrChg(*this, m_aSet
, aOld
, aNew
);
131 if(GetRegisteredIn() != rFormat
.GetRegisteredIn())
133 StartListeningToSameModifyAs(rFormat
);
134 m_aSet
.SetParent( GetRegisteredIn()
139 m_bAutoFormat
= rFormat
.m_bAutoFormat
;
140 m_bHidden
= rFormat
.m_bHidden
;
141 m_bAutoUpdateOnDirectFormat
= rFormat
.m_bAutoUpdateOnDirectFormat
;
145 void SwFormat::SetFormatName( const OUString
& rNewName
, bool bBroadcast
)
147 OSL_ENSURE( !IsDefault(), "SetName: Defaultformat" );
150 m_aFormatName
= rNewName
;
151 const sw::NameChanged
aHint(m_aFormatName
, rNewName
);
152 SwClientNotify(*this, aHint
);
156 m_aFormatName
= rNewName
;
162 This function is called in every Copy-Ctor for copying the attributes.
163 The latter can be only copied as soon as the derived class exists since
164 for setting them the Which() function is called and that has the default
165 value of 0 in the base class and is then overridden by the derived class.
167 If we copy over multiple documents then the new document has to be provided
168 in which <this> is defined. Currently this is important for DropCaps
169 because that contains data that needs to be copied deeply.
171 void SwFormat::CopyAttrs( const SwFormat
& rFormat
)
173 // copy only array with attributes delta
174 InvalidateInSwCache(RES_ATTRSET_CHG
);
175 InvalidateInSwFntCache(RES_ATTRSET_CHG
);
177 // special treatments for some attributes
178 SwAttrSet
* pChgSet
= const_cast<SwAttrSet
*>(&rFormat
.m_aSet
);
180 // copy only array with attributes delta
181 if( pChgSet
->GetPool() != m_aSet
.GetPool() )
182 pChgSet
->CopyToModify( *this );
185 SwAttrSet
aOld( *m_aSet
.GetPool(), m_aSet
.GetRanges() ),
186 aNew( *m_aSet
.GetPool(), m_aSet
.GetRanges() );
188 if ( m_aSet
.Put_BC( *pChgSet
, &aOld
, &aNew
) )
190 // a few special treatments for attributes
191 m_aSet
.SetModifyAtAttr( this );
193 SwAttrSetChg
aChgOld( m_aSet
, aOld
);
194 SwAttrSetChg
aChgNew( m_aSet
, aNew
);
195 SwClientNotify(*this, sw::LegacyModifyHint(&aChgOld
, &aChgNew
)); // send all modified ones
199 if( pChgSet
!= &rFormat
.m_aSet
) // was a Set created?
203 SwFormat::~SwFormat()
205 // This happens at an ObjectDying message. Thus put all dependent
206 // ones on DerivedFrom.
207 if(!HasWriterListeners())
210 m_bFormatInDTOR
= true;
214 SwFormat::ResetFormatAttr(RES_PAGEDESC
);
215 SAL_WARN("sw.core", "~SwFormat: format still has clients on death, but parent format is missing: " << GetName());
218 SwIterator
<SwClient
,SwFormat
> aIter(*this);
219 for(SwClient
* pClient
= aIter
.First(); pClient
; pClient
= aIter
.Next())
220 pClient
->CheckRegistrationFormat(*this);
221 assert(!HasWriterListeners());
224 void SwFormat::SwClientNotify(const SwModify
&, const SfxHint
& rHint
)
226 if (rHint
.GetId() != SfxHintId::SwLegacyModify
)
228 auto pLegacy
= static_cast<const sw::LegacyModifyHint
*>(&rHint
);
230 std::optional
<SwAttrSetChg
> oOldClientChg
, oNewClientChg
;
231 std::optional
<sw::LegacyModifyHint
> oDependsHint(std::in_place
, pLegacy
->m_pOld
, pLegacy
->m_pNew
);
232 const sal_uInt16 nWhich
= pLegacy
->GetWhich();
233 InvalidateInSwCache(nWhich
);
238 case RES_OBJECTDYING
:
240 // NB: this still notifies depends even if pLegacy->m_pNew is nullptr, which seems non-obvious
243 // If the dying object is the parent format of this format so
244 // attach this to the parent of the parent
245 SwFormat
* pFormat
= static_cast<SwFormat
*>(pLegacy
->m_pNew
->StaticWhichCast(RES_OBJECTDYING
).pObject
);
247 // do not move if this is the topmost format
248 if(GetRegisteredIn() && GetRegisteredIn() == pFormat
)
250 if(pFormat
->GetRegisteredIn())
252 // if parent so register in new parent
253 pFormat
->DerivedFrom()->Add(this);
254 m_aSet
.SetParent(&DerivedFrom()->m_aSet
);
258 // otherwise de-register at least from dying one
260 m_aSet
.SetParent(nullptr);
265 case RES_ATTRSET_CHG
:
267 // NB: this still notifies depends even if this condition is not met, which seems non-obvious
268 auto pOldAttrSetChg
= static_cast<const SwAttrSetChg
*>(pLegacy
->m_pOld
);
269 auto pNewAttrSetChg
= static_cast<const SwAttrSetChg
*>(pLegacy
->m_pNew
);
270 if (pOldAttrSetChg
&& pNewAttrSetChg
&& pOldAttrSetChg
->GetTheChgdSet() != &m_aSet
)
272 // pass only those that are not set...
273 oNewClientChg
.emplace(*pNewAttrSetChg
);
274 oNewClientChg
->GetChgSet()->Differentiate(m_aSet
);
275 if(oNewClientChg
->Count()) // ... if any
277 oOldClientChg
.emplace(*pOldAttrSetChg
);
278 oOldClientChg
->GetChgSet()->Differentiate(m_aSet
);
279 oDependsHint
.emplace(&*oOldClientChg
, &*oNewClientChg
);
282 oDependsHint
.reset();
288 // if the format parent will be moved so register my attribute set at
291 // skip my own Modify
292 // NB: this still notifies depends even if this condition is not met, which seems non-obvious
293 auto pOldFormatChg
= static_cast<const SwFormatChg
*>(pLegacy
->m_pOld
);
294 auto pNewFormatChg
= static_cast<const SwFormatChg
*>(pLegacy
->m_pNew
);
295 if(pOldFormatChg
&& pNewFormatChg
&& pOldFormatChg
->pChangedFormat
!= this && pNewFormatChg
->pChangedFormat
== GetRegisteredIn())
297 // attach Set to new parent
298 m_aSet
.SetParent(DerivedFrom() ? &DerivedFrom()->m_aSet
: nullptr);
303 // attribute is defined in this format
304 if(SfxItemState::SET
== m_aSet
.GetItemState(nWhich
, false))
306 // DropCaps might come into this block
307 SAL_WARN_IF(RES_PARATR_DROP
!= nWhich
, "sw.core", "Hint was sent without sender");
308 oDependsHint
.reset();
313 InvalidateInSwFntCache(oDependsHint
->GetWhich());
314 SwModify::SwClientNotify(*this, *oDependsHint
);
318 bool SwFormat::SetDerivedFrom(SwFormat
*pDerFrom
)
322 const SwFormat
* pFormat
= pDerFrom
;
323 while ( pFormat
!= nullptr )
325 if ( pFormat
== this )
328 pFormat
=pFormat
->DerivedFrom();
333 // nothing provided, search for Dflt format
335 while ( pDerFrom
->DerivedFrom() )
336 pDerFrom
= pDerFrom
->DerivedFrom();
338 if ( (pDerFrom
== DerivedFrom()) || (pDerFrom
== this) )
341 assert( Which()==pDerFrom
->Which()
342 || (Which()==RES_CONDTXTFMTCOLL
&& pDerFrom
->Which()==RES_TXTFMTCOLL
)
343 || (Which()==RES_TXTFMTCOLL
&& pDerFrom
->Which()==RES_CONDTXTFMTCOLL
)
344 || (Which()==RES_FLYFRMFMT
&& pDerFrom
->Which()==RES_FRMFMT
)
347 InvalidateInSwCache(RES_ATTRSET_CHG
);
348 InvalidateInSwFntCache(RES_ATTRSET_CHG
);
350 pDerFrom
->Add( this );
351 m_aSet
.SetParent( &pDerFrom
->m_aSet
);
353 SwFormatChg
aOldFormat( this );
354 SwFormatChg
aNewFormat( this );
355 const sw::LegacyModifyHint
aHint(&aOldFormat
, &aNewFormat
);
356 SwClientNotify(*this, aHint
);
361 bool SwFormat::supportsFullDrawingLayerFillAttributeSet() const
366 const SfxPoolItem
& SwFormat::GetFormatAttr( sal_uInt16 nWhich
, bool bInParents
) const
368 if (RES_BACKGROUND
== nWhich
&& supportsFullDrawingLayerFillAttributeSet())
370 // FALLBACKBREAKHERE should not be used; instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST]
371 SAL_INFO("sw.core", "Do no longer use SvxBrushItem, instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST] FillAttributes or makeBackgroundBrushItem (simple fallback is in place and used)");
372 static std::unique_ptr
<SvxBrushItem
> aSvxBrushItem
; //(std::make_shared<SvxBrushItem>(RES_BACKGROUND));
374 // fill the local static SvxBrushItem from the current ItemSet so that
375 // the fill attributes [XATTR_FILL_FIRST .. XATTR_FILL_LAST] are used
376 // as good as possible to create a fallback representation and return that
377 aSvxBrushItem
= getSvxBrushItemFromSourceSet(m_aSet
, RES_BACKGROUND
, bInParents
);
379 return *aSvxBrushItem
;
382 return m_aSet
.Get( nWhich
, bInParents
);
385 SfxItemState
SwFormat::GetItemState( sal_uInt16 nWhich
, bool bSrchInParent
, const SfxPoolItem
**ppItem
) const
387 if (RES_BACKGROUND
== nWhich
&& supportsFullDrawingLayerFillAttributeSet())
389 // FALLBACKBREAKHERE should not be used; instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST]
390 SAL_INFO("sw.core", "Do no longer use SvxBrushItem, instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST] FillAttributes or SwFormat::GetBackgroundStat (simple fallback is in place and used)");
391 const drawinglayer::attribute::SdrAllFillAttributesHelperPtr aFill
= getSdrAllFillAttributesHelper();
393 // check if the new fill attributes are used
394 if(aFill
&& aFill
->isUsed())
396 // if yes, fill the local SvxBrushItem using the new fill attributes
397 // as good as possible to have an instance for the pointer to point
398 // to and return as state that it is set
399 static std::unique_ptr
<SvxBrushItem
> aSvxBrushItem
; //(RES_BACKGROUND);
401 aSvxBrushItem
= getSvxBrushItemFromSourceSet(m_aSet
, RES_BACKGROUND
, bSrchInParent
);
403 *ppItem
= aSvxBrushItem
.get();
405 return SfxItemState::SET
;
408 // if not, reset pointer and return SfxItemState::DEFAULT to signal that
409 // the item is not set
413 return SfxItemState::DEFAULT
;
416 return m_aSet
.GetItemState( nWhich
, bSrchInParent
, ppItem
);
419 SfxItemState
SwFormat::GetBackgroundState(std::unique_ptr
<SvxBrushItem
>& rItem
) const
421 if (supportsFullDrawingLayerFillAttributeSet())
423 // FALLBACKBREAKHERE should not be used; instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST]
424 const drawinglayer::attribute::SdrAllFillAttributesHelperPtr aFill
= getSdrAllFillAttributesHelper();
426 // check if the new fill attributes are used
427 if(aFill
&& aFill
->isUsed())
429 // if yes, fill the local SvxBrushItem using the new fill attributes
430 // as good as possible to have an instance for the pointer to point
431 // to and return as state that it is set
432 rItem
= getSvxBrushItemFromSourceSet(m_aSet
, RES_BACKGROUND
);
433 return SfxItemState::SET
;
436 // if not return SfxItemState::DEFAULT to signal that the item is not set
437 return SfxItemState::DEFAULT
;
440 const SvxBrushItem
* pItem
= nullptr;
441 SfxItemState eRet
= m_aSet
.GetItemState(RES_BACKGROUND
, true, &pItem
);
443 rItem
.reset(pItem
->Clone());
447 bool SwFormat::SetFormatAttr( const SfxPoolItem
& rAttr
)
449 const sal_uInt16 nWhich
= rAttr
.Which();
450 InvalidateInSwFntCache( nWhich
);
451 InvalidateInSwCache( nWhich
);
455 if (RES_BACKGROUND
== rAttr
.Which() && supportsFullDrawingLayerFillAttributeSet())
457 // FALLBACKBREAKHERE should not be used; instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST]
458 SAL_INFO("sw.core", "Do no longer use SvxBrushItem, instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST] FillAttributes (simple fallback is in place and used)");
459 SfxItemSetFixed
<XATTR_FILL_FIRST
, XATTR_FILL_LAST
> aTempSet(*m_aSet
.GetPool());
460 const SvxBrushItem
& rSource
= rAttr
.StaticWhichCast(RES_BACKGROUND
);
462 // fill a local ItemSet with the attributes corresponding as good as possible
463 // to the new fill properties [XATTR_FILL_FIRST .. XATTR_FILL_LAST] and set these
465 setSvxBrushItemAsFillAttributesToTargetSet(rSource
, aTempSet
);
469 bRet
= m_aSet
.Put( aTempSet
);
472 m_aSet
.SetModifyAtAttr( this );
477 SwAttrSet
aOld(*m_aSet
.GetPool(), m_aSet
.GetRanges()), aNew(*m_aSet
.GetPool(), m_aSet
.GetRanges());
479 bRet
= m_aSet
.Put_BC(aTempSet
, &aOld
, &aNew
);
483 m_aSet
.SetModifyAtAttr(this);
484 sw::ClientNotifyAttrChg(*this, m_aSet
, aOld
, aNew
);
491 // if Modify is locked then no modifications will be sent;
492 // but call Modify always for FrameFormats
493 const sal_uInt16 nFormatWhich
= Which();
494 if( IsModifyLocked() ||
495 ( !HasWriterListeners() &&
496 (RES_GRFFMTCOLL
== nFormatWhich
||
497 RES_TXTFMTCOLL
== nFormatWhich
) ) )
499 bRet
= nullptr != m_aSet
.Put( rAttr
);
501 m_aSet
.SetModifyAtAttr( this );
503 if ( nFormatWhich
== RES_TXTFMTCOLL
&& rAttr
.Which() == RES_PARATR_NUMRULE
)
505 TextFormatCollFunc::CheckTextFormatCollForDeletionOfAssignmentToOutlineStyle( this );
510 // copy only array with attributes delta
511 SwAttrSet
aOld( *m_aSet
.GetPool(), m_aSet
.GetRanges() ),
512 aNew( *m_aSet
.GetPool(), m_aSet
.GetRanges() );
514 bRet
= m_aSet
.Put_BC( rAttr
, &aOld
, &aNew
);
517 // some special treatments for attributes
518 m_aSet
.SetModifyAtAttr( this );
520 sw::ClientNotifyAttrChg(*this, m_aSet
, aOld
, aNew
);
526 bool SwFormat::SetFormatAttr( const SfxItemSet
& rSet
)
531 InvalidateInSwCache(RES_ATTRSET_CHG
);
532 InvalidateInSwFntCache(RES_ATTRSET_CHG
);
536 // Use local copy to be able to apply needed changes, e.g. call
537 // CheckForUniqueItemForLineFillNameOrIndex which is needed for NameOrIndex stuff
538 SfxItemSet
aTempSet(rSet
);
540 // Need to check for unique item for DrawingLayer items of type NameOrIndex
541 // and evtl. correct that item to ensure unique names for that type. This call may
542 // modify/correct entries inside of the given SfxItemSet
545 GetDoc()->CheckForUniqueItemForLineFillNameOrIndex(aTempSet
);
548 if (supportsFullDrawingLayerFillAttributeSet())
550 if(const SvxBrushItem
* pSource
= aTempSet
.GetItemIfSet(RES_BACKGROUND
, false))
552 // FALLBACKBREAKHERE should not be used; instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST]
553 SAL_INFO("sw.core", "Do no longer use SvxBrushItem, instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST] FillAttributes (simple fallback is in place and used)");
555 // copy all items to be set anyways to a local ItemSet with is also prepared for the new
556 // fill attribute ranges [XATTR_FILL_FIRST .. XATTR_FILL_LAST]. Add the attributes
557 // corresponding as good as possible to the new fill properties and set the whole ItemSet
558 setSvxBrushItemAsFillAttributesToTargetSet(*pSource
, aTempSet
);
562 bRet
= m_aSet
.Put( aTempSet
);
565 m_aSet
.SetModifyAtAttr( this );
570 SwAttrSet
aOld(*m_aSet
.GetPool(), m_aSet
.GetRanges()), aNew(*m_aSet
.GetPool(), m_aSet
.GetRanges());
572 bRet
= m_aSet
.Put_BC(aTempSet
, &aOld
, &aNew
);
576 m_aSet
.SetModifyAtAttr(this);
577 sw::ClientNotifyAttrChg(*this, m_aSet
, aOld
, aNew
);
585 // if Modify is locked then no modifications will be sent;
586 // but call Modify always for FrameFormats
587 const sal_uInt16 nFormatWhich
= Which();
588 if ( IsModifyLocked() ||
589 ( !HasWriterListeners() &&
590 ( RES_GRFFMTCOLL
== nFormatWhich
||
591 RES_TXTFMTCOLL
== nFormatWhich
) ) )
593 bRet
= m_aSet
.Put( aTempSet
);
595 m_aSet
.SetModifyAtAttr( this );
597 if ( nFormatWhich
== RES_TXTFMTCOLL
)
599 TextFormatCollFunc::CheckTextFormatCollForDeletionOfAssignmentToOutlineStyle( this );
604 SwAttrSet
aOld( *m_aSet
.GetPool(), m_aSet
.GetRanges() ),
605 aNew( *m_aSet
.GetPool(), m_aSet
.GetRanges() );
606 bRet
= m_aSet
.Put_BC( aTempSet
, &aOld
, &aNew
);
609 // some special treatments for attributes
610 m_aSet
.SetModifyAtAttr( this );
611 sw::ClientNotifyAttrChg(*this, m_aSet
, aOld
, aNew
);
617 // remove Hint using nWhich from array with delta
618 bool SwFormat::ResetFormatAttr( sal_uInt16 nWhich1
, sal_uInt16 nWhich2
)
620 if( !m_aSet
.Count() )
623 if( !nWhich2
|| nWhich2
< nWhich1
)
624 nWhich2
= nWhich1
; // then set to 1st ID, only this item
626 for( sal_uInt16 n
= nWhich1
; n
< nWhich2
; ++n
)
627 InvalidateInSwFntCache( n
);
628 for( sal_uInt16 n
= nWhich1
; n
< nWhich2
&& IsInCache(); ++n
)
629 InvalidateInSwCache( n
);
631 // if Modify is locked then no modifications will be sent
632 if( IsModifyLocked() )
633 return 0 != (( nWhich2
== nWhich1
)
634 ? m_aSet
.ClearItem( nWhich1
)
635 : m_aSet
.ClearItem_BC( nWhich1
, nWhich2
));
637 SwAttrSet
aOld( *m_aSet
.GetPool(), m_aSet
.GetRanges() ),
638 aNew( *m_aSet
.GetPool(), m_aSet
.GetRanges() );
639 bool bRet
= 0 != m_aSet
.ClearItem_BC( nWhich1
, nWhich2
, &aOld
, &aNew
);
641 sw::ClientNotifyAttrChg(*this, m_aSet
, aOld
, aNew
);
646 sal_uInt16
SwFormat::ResetAllFormatAttr()
648 if( !m_aSet
.Count() )
651 InvalidateInSwCache(RES_ATTRSET_CHG
);
652 InvalidateInSwFntCache(RES_ATTRSET_CHG
);
654 // if Modify is locked then no modifications will be sent
655 if( IsModifyLocked() )
656 return m_aSet
.ClearItem();
658 SwAttrSet
aOld( *m_aSet
.GetPool(), m_aSet
.GetRanges() ),
659 aNew( *m_aSet
.GetPool(), m_aSet
.GetRanges() );
660 bool bRet
= 0 != m_aSet
.ClearItem_BC( 0, &aOld
, &aNew
);
662 sw::ClientNotifyAttrChg(*this, m_aSet
, aOld
, aNew
);
666 void SwFormat::DelDiffs( const SfxItemSet
& rSet
)
668 if( !m_aSet
.Count() )
671 InvalidateInSwCache(RES_ATTRSET_CHG
);
672 InvalidateInSwFntCache(RES_ATTRSET_CHG
);
674 // if Modify is locked then no modifications will be sent
675 if( IsModifyLocked() )
677 m_aSet
.Intersect( rSet
);
681 SwAttrSet
aOld( *m_aSet
.GetPool(), m_aSet
.GetRanges() ),
682 aNew( *m_aSet
.GetPool(), m_aSet
.GetRanges() );
683 bool bRet
= 0 != m_aSet
.Intersect_BC( rSet
, &aOld
, &aNew
);
685 sw::ClientNotifyAttrChg(*this, m_aSet
, aOld
, aNew
);
688 void SwFormat::SetPageFormatToDefault()
690 const sal_Int32 nSize
= o3tl::convert(2, o3tl::Length::cm
, o3tl::Length::twip
);
691 SetFormatAttr(SvxLRSpaceItem(nSize
, nSize
, 0, RES_LR_SPACE
));
692 SetFormatAttr(SvxULSpaceItem(nSize
, nSize
, RES_UL_SPACE
));
695 /** SwFormat::IsBackgroundTransparent
697 Virtual method to determine, if background of format is transparent.
698 Default implementation returns false. Thus, subclasses have to override
699 method, if the specific subclass can have a transparent background.
701 @return false, default implementation
703 bool SwFormat::IsBackgroundTransparent() const
709 * Document Interface Access
711 const IDocumentSettingAccess
& SwFormat::getIDocumentSettingAccess() const { return GetDoc()->GetDocumentSettingManager(); }
712 const IDocumentDrawModelAccess
& SwFormat::getIDocumentDrawModelAccess() const { return GetDoc()->getIDocumentDrawModelAccess(); }
713 IDocumentDrawModelAccess
& SwFormat::getIDocumentDrawModelAccess() { return GetDoc()->getIDocumentDrawModelAccess(); }
714 const IDocumentLayoutAccess
& SwFormat::getIDocumentLayoutAccess() const { return GetDoc()->getIDocumentLayoutAccess(); }
715 IDocumentLayoutAccess
& SwFormat::getIDocumentLayoutAccess() { return GetDoc()->getIDocumentLayoutAccess(); }
716 IDocumentTimerAccess
& SwFormat::getIDocumentTimerAccess() { return GetDoc()->getIDocumentTimerAccess(); }
717 IDocumentFieldsAccess
& SwFormat::getIDocumentFieldsAccess() { return GetDoc()->getIDocumentFieldsAccess(); }
718 IDocumentChartDataProviderAccess
& SwFormat::getIDocumentChartDataProviderAccess() { return GetDoc()->getIDocumentChartDataProviderAccess(); }
720 void SwFormat::GetGrabBagItem(uno::Any
& rVal
) const
723 m_pGrabBagItem
->QueryValue(rVal
);
725 rVal
<<= uno::Sequence
<beans::PropertyValue
>();
728 void SwFormat::SetGrabBagItem(const uno::Any
& rVal
)
731 m_pGrabBagItem
= std::make_shared
<SfxGrabBagItem
>();
733 m_pGrabBagItem
->PutValue(rVal
, 0);
736 std::unique_ptr
<SvxBrushItem
> SwFormat::makeBackgroundBrushItem(bool bInP
) const
738 if (supportsFullDrawingLayerFillAttributeSet())
740 // FALLBACKBREAKHERE should not be used; instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST]
741 SAL_INFO("sw.core", "Do no longer use SvxBrushItem, instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST] FillAttributes (simple fallback is in place and used)");
743 // fill the local static SvxBrushItem from the current ItemSet so that
744 // the fill attributes [XATTR_FILL_FIRST .. XATTR_FILL_LAST] are used
745 // as good as possible to create a fallback representation and return that
746 return getSvxBrushItemFromSourceSet(m_aSet
, RES_BACKGROUND
, bInP
);
749 return std::unique_ptr
<SvxBrushItem
>(m_aSet
.GetBackground(bInP
).Clone());
752 drawinglayer::attribute::SdrAllFillAttributesHelperPtr
SwFormat::getSdrAllFillAttributesHelper() const
754 return drawinglayer::attribute::SdrAllFillAttributesHelperPtr();
757 void SwFormat::RemoveAllUnos()
759 SwPtrMsgPoolItem
aMsgHint(RES_REMOVE_UNO_OBJECT
, this);
760 SwClientNotify(*this, sw::LegacyModifyHint(&aMsgHint
, &aMsgHint
));
763 SwFormatsBase::~SwFormatsBase()
766 SwFormat
* SwFormatsBase::FindFormatByName( const OUString
& rName
) const
768 SwFormat
* pFnd
= nullptr;
769 for( size_t n
= 0; n
< GetFormatCount(); ++n
)
771 // Does the Doc already contain the template?
772 if( GetFormat(n
)->HasName( rName
) )
781 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */