LibreOffice Module sw (master) 1
format.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 <DocumentSettingManager.hxx> //For SwFmt::getIDocumentSettingAccess()
22#include <doc.hxx>
23#include <fmtcolfunc.hxx>
24#include <format.hxx>
25#include <frmatr.hxx>
26#include <hintids.hxx>
27#include <hints.hxx>
29#include <osl/diagnose.h>
30#include <sal/log.hxx>
31#include <svl/grabbagitem.hxx>
34#include <svx/xdef.hxx>
35#include <utility>
36
37using namespace com::sun::star;
38
39SwFormat::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 )
48{
49 m_bAutoUpdateOnDirectFormat = false; // LAYER_IMPL
50 m_bAutoFormat = true;
51 m_bFormatInDTOR = m_bHidden = false;
52
53 if( pDrvdFrame )
54 {
55 pDrvdFrame->Add(this);
56 m_aSet.SetParent( &pDrvdFrame->m_aSet );
57 }
58}
59
60SwFormat::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 )
69{
70 m_bAutoUpdateOnDirectFormat = false; // LAYER_IMPL
71 m_bAutoFormat = true;
72 m_bFormatInDTOR = m_bHidden = false;
73
74 if( pDrvdFrame )
75 {
76 pDrvdFrame->Add(this);
77 m_aSet.SetParent( &pDrvdFrame->m_aSet );
78 }
79}
80
81SwFormat::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() )
89{
90 m_bFormatInDTOR = false; // LAYER_IMPL
92 m_bHidden = rFormat.m_bHidden;
94
95 if( auto pDerived = rFormat.DerivedFrom() )
96 {
97 pDerived->Add(this);
98 m_aSet.SetParent( &pDerived->m_aSet );
99 }
100 // a few special treatments for attributes
101 m_aSet.SetModifyAtAttr( this );
102}
103
105{
106 if(this == &rFormat)
107 return *this;
108
109 m_nWhichId = rFormat.m_nWhichId;
111 m_nPoolHelpId = rFormat.GetPoolHelpId();
113
115
116 // copy only array with attributes delta
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 );
121
122 // a few special treatments for attributes
123 m_aSet.SetModifyAtAttr( this );
124
125 // create PoolItem attribute for Modify
126 if( aOld.Count() )
127 {
128 sw::ClientNotifyAttrChg(*this, m_aSet, aOld, aNew);
129 }
130
131 if(GetRegisteredIn() != rFormat.GetRegisteredIn())
132 {
133 StartListeningToSameModifyAs(rFormat);
134 m_aSet.SetParent( GetRegisteredIn()
135 ? &rFormat.m_aSet
136 : nullptr);
137 }
138
140 m_bHidden = rFormat.m_bHidden;
142 return *this;
143}
144
145void SwFormat::SetFormatName( const OUString& rNewName, bool bBroadcast )
146{
147 OSL_ENSURE( !IsDefault(), "SetName: Defaultformat" );
148 if( bBroadcast )
149 {
150 m_aFormatName = rNewName;
151 const sw::NameChanged aHint(m_aFormatName, rNewName);
152 SwClientNotify(*this, aHint);
153 }
154 else
155 {
156 m_aFormatName = rNewName;
157 }
158}
159
171void SwFormat::CopyAttrs( const SwFormat& rFormat )
172{
173 // copy only array with attributes delta
176
177 // special treatments for some attributes
178 SwAttrSet* pChgSet = const_cast<SwAttrSet*>(&rFormat.m_aSet);
179
180 // copy only array with attributes delta
181 if( pChgSet->GetPool() != m_aSet.GetPool() )
182 pChgSet->CopyToModify( *this );
183 else
184 {
186 aNew( *m_aSet.GetPool(), m_aSet.GetRanges() );
187
188 if ( m_aSet.Put_BC( *pChgSet, &aOld, &aNew ) )
189 {
190 // a few special treatments for attributes
191 m_aSet.SetModifyAtAttr( this );
192
193 SwAttrSetChg aChgOld( m_aSet, aOld );
194 SwAttrSetChg aChgNew( m_aSet, aNew );
195 SwClientNotify(*this, sw::LegacyModifyHint(&aChgOld, &aChgNew)); // send all modified ones
196 }
197 }
198
199 if( pChgSet != &rFormat.m_aSet ) // was a Set created?
200 delete pChgSet;
201}
202
204{
205 // This happens at an ObjectDying message. Thus put all dependent
206 // ones on DerivedFrom.
207 if(!HasWriterListeners())
208 return;
209
210 m_bFormatInDTOR = true;
211
212 if(!DerivedFrom())
213 {
215 SAL_WARN("sw.core", "~SwFormat: format still has clients on death, but parent format is missing: " << GetName());
216 return;
217 }
219 for(SwClient* pClient = aIter.First(); pClient; pClient = aIter.Next())
220 pClient->CheckRegistrationFormat(*this);
221 assert(!HasWriterListeners());
222}
223
224void SwFormat::SwClientNotify(const SwModify&, const SfxHint& rHint)
225{
226 if (rHint.GetId() != SfxHintId::SwLegacyModify)
227 return;
228 auto pLegacy = static_cast<const sw::LegacyModifyHint*>(&rHint);
229
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);
234 switch(nWhich)
235 {
236 case 0:
237 break;
238 case RES_OBJECTDYING:
239 {
240 // NB: this still notifies depends even if pLegacy->m_pNew is nullptr, which seems non-obvious
241 if(!pLegacy->m_pNew)
242 break;
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);
246
247 // do not move if this is the topmost format
248 if(GetRegisteredIn() && GetRegisteredIn() == pFormat)
249 {
250 if(pFormat->GetRegisteredIn())
251 {
252 // if parent so register in new parent
253 pFormat->DerivedFrom()->Add(this);
255 }
256 else
257 {
258 // otherwise de-register at least from dying one
259 EndListeningAll();
260 m_aSet.SetParent(nullptr);
261 }
262 }
263 break;
264 }
265 case RES_ATTRSET_CHG:
266 {
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)
271 {
272 // pass only those that are not set...
273 oNewClientChg.emplace(*pNewAttrSetChg);
274 oNewClientChg->GetChgSet()->Differentiate(m_aSet);
275 if(oNewClientChg->Count()) // ... if any
276 {
277 oOldClientChg.emplace(*pOldAttrSetChg);
278 oOldClientChg->GetChgSet()->Differentiate(m_aSet);
279 oDependsHint.emplace(&*oOldClientChg, &*oNewClientChg);
280 }
281 else
282 oDependsHint.reset();
283 }
284 break;
285 }
286 case RES_FMT_CHG:
287 {
288 // if the format parent will be moved so register my attribute set at
289 // the new one
290
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())
296 {
297 // attach Set to new parent
298 m_aSet.SetParent(DerivedFrom() ? &DerivedFrom()->m_aSet : nullptr);
299 }
300 break;
301 }
302 default:
303 // attribute is defined in this format
304 if(SfxItemState::SET == m_aSet.GetItemState(nWhich, false))
305 {
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();
309 }
310 }
311 if(oDependsHint)
312 {
313 InvalidateInSwFntCache(oDependsHint->GetWhich());
314 SwModify::SwClientNotify(*this, *oDependsHint);
315 }
316}
317
319{
320 if ( pDerFrom )
321 {
322 const SwFormat* pFormat = pDerFrom;
323 while ( pFormat != nullptr )
324 {
325 if ( pFormat == this )
326 return false;
327
328 pFormat=pFormat->DerivedFrom();
329 }
330 }
331 else
332 {
333 // nothing provided, search for Dflt format
334 pDerFrom = this;
335 while ( pDerFrom->DerivedFrom() )
336 pDerFrom = pDerFrom->DerivedFrom();
337 }
338 if ( (pDerFrom == DerivedFrom()) || (pDerFrom == this) )
339 return false;
340
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)
345 );
346
349
350 pDerFrom->Add( this );
351 m_aSet.SetParent( &pDerFrom->m_aSet );
352
353 SwFormatChg aOldFormat( this );
354 SwFormatChg aNewFormat( this );
355 const sw::LegacyModifyHint aHint(&aOldFormat, &aNewFormat);
356 SwClientNotify(*this, aHint);
357
358 return true;
359}
360
362{
363 return false;
364}
365
366const SfxPoolItem& SwFormat::GetFormatAttr( sal_uInt16 nWhich, bool bInParents ) const
367{
369 {
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));
373
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);
378
379 return *aSvxBrushItem;
380 }
381
382 return m_aSet.Get( nWhich, bInParents );
383}
384
385SfxItemState SwFormat::GetItemState( sal_uInt16 nWhich, bool bSrchInParent, const SfxPoolItem **ppItem ) const
386{
388 {
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)");
392
393 // check if the new fill attributes are used
394 if(aFill && aFill->isUsed())
395 {
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);
400
401 aSvxBrushItem = getSvxBrushItemFromSourceSet(m_aSet, RES_BACKGROUND, bSrchInParent);
402 if( ppItem )
403 *ppItem = aSvxBrushItem.get();
404
405 return SfxItemState::SET;
406 }
407
408 // if not, reset pointer and return SfxItemState::DEFAULT to signal that
409 // the item is not set
410 if( ppItem )
411 *ppItem = nullptr;
412
413 return SfxItemState::DEFAULT;
414 }
415
416 return m_aSet.GetItemState( nWhich, bSrchInParent, ppItem );
417}
418
419SfxItemState SwFormat::GetBackgroundState(std::unique_ptr<SvxBrushItem>& rItem) const
420{
422 {
423 // FALLBACKBREAKHERE should not be used; instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST]
425
426 // check if the new fill attributes are used
427 if(aFill && aFill->isUsed())
428 {
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
433 return SfxItemState::SET;
434 }
435
436 // if not return SfxItemState::DEFAULT to signal that the item is not set
437 return SfxItemState::DEFAULT;
438 }
439
440 const SvxBrushItem* pItem = nullptr;
441 SfxItemState eRet = m_aSet.GetItemState(RES_BACKGROUND, true, &pItem);
442 if (pItem)
443 rItem.reset(pItem->Clone());
444 return eRet;
445}
446
448{
449 const sal_uInt16 nWhich = rAttr.Which();
450 InvalidateInSwFntCache( nWhich );
451 InvalidateInSwCache( nWhich );
452
453 bool bRet = false;
454
456 {
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)");
460 const SvxBrushItem& rSource = rAttr.StaticWhichCast(RES_BACKGROUND);
461
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
464 // as ItemSet
466
467 if(IsModifyLocked())
468 {
469 bRet = m_aSet.Put( aTempSet );
470 if( bRet )
471 {
472 m_aSet.SetModifyAtAttr( this );
473 }
474 }
475 else
476 {
478
479 bRet = m_aSet.Put_BC(aTempSet, &aOld, &aNew);
480
481 if(bRet)
482 {
484 sw::ClientNotifyAttrChg(*this, m_aSet, aOld, aNew);
485 }
486 }
487
488 return bRet;
489 }
490
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 ) ) )
498 {
499 bRet = nullptr != m_aSet.Put( rAttr );
500 if( bRet )
501 m_aSet.SetModifyAtAttr( this );
502 // #i71574#
503 if ( nFormatWhich == RES_TXTFMTCOLL && rAttr.Which() == RES_PARATR_NUMRULE )
504 {
506 }
507 }
508 else
509 {
510 // copy only array with attributes delta
512 aNew( *m_aSet.GetPool(), m_aSet.GetRanges() );
513
514 bRet = m_aSet.Put_BC( rAttr, &aOld, &aNew );
515 if( bRet )
516 {
517 // some special treatments for attributes
518 m_aSet.SetModifyAtAttr( this );
519
520 sw::ClientNotifyAttrChg(*this, m_aSet, aOld, aNew);
521 }
522 }
523 return bRet;
524}
525
527{
528 if( !rSet.Count() )
529 return false;
530
533
534 bool bRet = false;
535
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);
539
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
543 if(GetDoc())
544 {
546 }
547
549 {
550 if(const SvxBrushItem* pSource = aTempSet.GetItemIfSet(RES_BACKGROUND, false))
551 {
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)");
554
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
559
560 if(IsModifyLocked())
561 {
562 bRet = m_aSet.Put( aTempSet );
563 if( bRet )
564 {
565 m_aSet.SetModifyAtAttr( this );
566 }
567 }
568 else
569 {
571
572 bRet = m_aSet.Put_BC(aTempSet, &aOld, &aNew);
573
574 if(bRet)
575 {
577 sw::ClientNotifyAttrChg(*this, m_aSet, aOld, aNew);
578 }
579 }
580
581 return bRet;
582 }
583 }
584
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 ) ) )
592 {
593 bRet = m_aSet.Put( aTempSet );
594 if( bRet )
595 m_aSet.SetModifyAtAttr( this );
596 // #i71574#
597 if ( nFormatWhich == RES_TXTFMTCOLL )
598 {
600 }
601 }
602 else
603 {
605 aNew( *m_aSet.GetPool(), m_aSet.GetRanges() );
606 bRet = m_aSet.Put_BC( aTempSet, &aOld, &aNew );
607 if( bRet )
608 {
609 // some special treatments for attributes
610 m_aSet.SetModifyAtAttr( this );
611 sw::ClientNotifyAttrChg(*this, m_aSet, aOld, aNew);
612 }
613 }
614 return bRet;
615}
616
617// remove Hint using nWhich from array with delta
618bool SwFormat::ResetFormatAttr( sal_uInt16 nWhich1, sal_uInt16 nWhich2 )
619{
620 if( !m_aSet.Count() )
621 return false;
622
623 if( !nWhich2 || nWhich2 < nWhich1 )
624 nWhich2 = nWhich1; // then set to 1st ID, only this item
625
626 for( sal_uInt16 n = nWhich1; n < nWhich2; ++n )
628 for( sal_uInt16 n = nWhich1; n < nWhich2 && IsInCache(); ++n )
630
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 ));
636
638 aNew( *m_aSet.GetPool(), m_aSet.GetRanges() );
639 bool bRet = 0 != m_aSet.ClearItem_BC( nWhich1, nWhich2, &aOld, &aNew );
640 if( bRet )
641 sw::ClientNotifyAttrChg(*this, m_aSet, aOld, aNew);
642 return bRet;
643}
644
645// #i73790#
647{
648 if( !m_aSet.Count() )
649 return 0;
650
653
654 // if Modify is locked then no modifications will be sent
655 if( IsModifyLocked() )
656 return m_aSet.ClearItem();
657
659 aNew( *m_aSet.GetPool(), m_aSet.GetRanges() );
660 bool bRet = 0 != m_aSet.ClearItem_BC( 0, &aOld, &aNew );
661 if( bRet )
662 sw::ClientNotifyAttrChg(*this, m_aSet, aOld, aNew);
663 return aNew.Count();
664}
665
667{
668 if( !m_aSet.Count() )
669 return;
670
673
674 // if Modify is locked then no modifications will be sent
675 if( IsModifyLocked() )
676 {
678 return;
679 }
680
682 aNew( *m_aSet.GetPool(), m_aSet.GetRanges() );
683 bool bRet = 0 != m_aSet.Intersect_BC( rSet, &aOld, &aNew );
684 if( bRet )
685 sw::ClientNotifyAttrChg(*this, m_aSet, aOld, aNew);
686}
687
689{
690 const sal_Int32 nSize = o3tl::convert(2, o3tl::Length::cm, o3tl::Length::twip);
691 SetFormatAttr(SvxLRSpaceItem(nSize, nSize, 0, RES_LR_SPACE));
693}
694
704{
705 return false;
706}
707
708/*
709 * Document Interface Access
710 */
719
721{
722 if (m_pGrabBagItem)
723 m_pGrabBagItem->QueryValue(rVal);
724 else
725 rVal <<= uno::Sequence<beans::PropertyValue>();
726}
727
729{
730 if (!m_pGrabBagItem)
731 m_pGrabBagItem = std::make_shared<SfxGrabBagItem>();
732
733 m_pGrabBagItem->PutValue(rVal, 0);
734}
735
736std::unique_ptr<SvxBrushItem> SwFormat::makeBackgroundBrushItem(bool bInP) const
737{
739 {
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)");
742
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
747 }
748
749 return std::unique_ptr<SvxBrushItem>(m_aSet.GetBackground(bInP).Clone());
750}
751
753{
755}
756
758{
760 SwClientNotify(*this, sw::LegacyModifyHint(&aMsgHint, &aMsgHint));
761}
762
764{}
765
766SwFormat* SwFormatsBase::FindFormatByName( const OUString& rName ) const
767{
768 SwFormat* pFnd = nullptr;
769 for( size_t n = 0; n < GetFormatCount(); ++n )
770 {
771 // Does the Doc already contain the template?
772 if( GetFormat(n)->HasName( rName ) )
773 {
774 pFnd = GetFormat(n);
775 break;
776 }
777 }
778 return pFnd;
779}
780
781/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Give access to the data-provider for chart.
Document fields related interfaces.
Provides access to the layout of a document.
Provides access to settings of a document.
Handle the background jobs of a Writer document.
SfxHintId GetId() const
const WhichRangesContainer & GetRanges() const
void SetParent(const SfxItemSet *pNew)
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)
void Intersect(const SfxItemSet &rSet)
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
void Differentiate(const SfxItemSet &rSet)
T & StaticWhichCast(TypedWhichId< T > nId)
sal_uInt16 Which() const
virtual SvxBrushItem * Clone(SfxItemPool *pPool=nullptr) const override
const SwAttrSet * GetChgSet() const
What has changed.
Definition: hints.hxx:347
SwAttrPool * GetPool() const
Definition: swatrset.hxx:190
const SvxBrushItem & GetBackground(bool=true) const
Definition: frmatr.hxx:70
void CopyToModify(sw::BroadcastingModify &rMod) const
Definition: swatrset.cxx:251
sal_uInt16 ClearItem_BC(sal_uInt16 nWhich, SwAttrSet *pOld, SwAttrSet *pNew)
Definition: swatrset.cxx:164
bool Put_BC(const SfxPoolItem &rAttr, SwAttrSet *pOld, SwAttrSet *pNew)
Definition: swatrset.cxx:144
bool SetModifyAtAttr(const sw::BroadcastingModify *pModify)
special treatment for some attributes
Definition: swatrset.cxx:214
int Intersect_BC(const SfxItemSet &rSet, SwAttrSet *pOld, SwAttrSet *pNew)
Definition: swatrset.cxx:187
IDocumentChartDataProviderAccess const & getIDocumentChartDataProviderAccess() const
Definition: doc.cxx:241
void CheckForUniqueItemForLineFillNameOrIndex(SfxItemSet &rSet)
Definition: docfly.cxx:480
IDocumentFieldsAccess const & getIDocumentFieldsAccess() const
Definition: doc.cxx:371
IDocumentLayoutAccess const & getIDocumentLayoutAccess() const
Definition: doc.cxx:419
IDocumentDrawModelAccess const & getIDocumentDrawModelAccess() const
Definition: doc.cxx:169
::sw::DocumentSettingManager & GetDocumentSettingManager()
Definition: doc.cxx:200
IDocumentTimerAccess const & getIDocumentTimerAccess() const
Definition: doc.cxx:263
Base class for various Writer styles.
Definition: format.hxx:47
bool IsDefault() const
Definition: format.hxx:129
IDocumentTimerAccess & getIDocumentTimerAccess()
Provides access to the document idle timer interface.
Definition: format.cxx:716
void SetGrabBagItem(const css::uno::Any &rVal)
Definition: format.cxx:728
virtual drawinglayer::attribute::SdrAllFillAttributesHelperPtr getSdrAllFillAttributesHelper() const
Definition: format.cxx:752
const SwDoc * GetDoc() const
The document is set in SwAttrPool now, therefore you always can access it.
Definition: format.hxx:139
virtual ~SwFormat() override
Definition: format.cxx:203
sal_uInt16 GetPoolFormatId() const
Get and set Pool style IDs.
Definition: format.hxx:163
const IDocumentDrawModelAccess & getIDocumentDrawModelAccess() const
Provides access to the document draw model interface.
Definition: format.cxx:712
sal_uInt16 m_nPoolFormatId
Id for "automatically" created formats.
Definition: format.hxx:54
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
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
IDocumentFieldsAccess & getIDocumentFieldsAccess()
Provides access to the document idle timer interface.
Definition: format.cxx:717
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
Definition: format.cxx:385
bool HasName(std::u16string_view rName) const
Definition: format.hxx:132
sal_uInt8 GetPoolHlpFileId() const
Definition: format.hxx:169
bool m_bHidden
Definition: format.hxx:64
virtual void InvalidateInSwFntCache(sal_uInt16)
Definition: format.hxx:66
bool SetDerivedFrom(SwFormat *pDerivedFrom=nullptr)
0 is Default.
Definition: format.cxx:318
void SetPageFormatToDefault()
Definition: format.cxx:688
SwFormat * DerivedFrom() const
Definition: format.hxx:128
virtual bool supportsFullDrawingLayerFillAttributeSet() const
Definition: format.cxx:361
SwAttrSet m_aSet
Definition: format.hxx:51
void CopyAttrs(const SwFormat &)
Copy attributes even among documents.
Definition: format.cxx:171
std::shared_ptr< SfxGrabBagItem > m_pGrabBagItem
Style InteropGrabBag.
Definition: format.hxx:65
virtual void SwClientNotify(const SwModify &, const SfxHint &) override
Definition: format.cxx:224
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
bool m_bAutoFormat
FALSE: it is a template.
Definition: format.hxx:58
virtual bool SetFormatAttr(const SfxPoolItem &rAttr)
Definition: format.cxx:447
virtual bool IsBackgroundTransparent() const
SwFormat::IsBackgroundTransparent.
Definition: format.cxx:703
sal_uInt8 m_nPoolHlpFileId
FilePos to Doc to these style helps.
Definition: format.hxx:57
bool m_bFormatInDTOR
TRUE: Format becomes deleted.
Definition: format.hxx:60
bool m_bAutoUpdateOnDirectFormat
TRUE: Set attributes of a whole paragraph at format (UI-side!).
Definition: format.hxx:62
void DelDiffs(const SfxItemSet &rSet)
Delete all attributes that are not in rFormat.
Definition: format.cxx:666
const IDocumentLayoutAccess & getIDocumentLayoutAccess() const
Provides access to the document layout interface.
Definition: format.cxx:714
SfxItemState GetBackgroundState(std::unique_ptr< SvxBrushItem > &rItem) const
Definition: format.cxx:419
sal_uInt16 m_nWhichId
Definition: format.hxx:53
sal_uInt16 m_nPoolHelpId
HelpId for this Pool-style.
Definition: format.hxx:56
OUString m_aFormatName
Definition: format.hxx:50
virtual sal_uInt16 ResetAllFormatAttr()
Takes all hints from Delta-Array,.
Definition: format.cxx:646
SwFormat & operator=(const SwFormat &)
Definition: format.cxx:104
const IDocumentSettingAccess & getIDocumentSettingAccess() const
Provides access to the document settings interface.
Definition: format.cxx:711
SwFormat(SwAttrPool &rPool, const char *pFormatNm, const WhichRangesContainer &pWhichRanges, SwFormat *pDrvdFrame, sal_uInt16 nFormatWhich)
Definition: format.cxx:39
void GetGrabBagItem(css::uno::Any &rVal) const
Definition: format.cxx:720
IDocumentChartDataProviderAccess & getIDocumentChartDataProviderAccess()
Gives access to the chart data-provider.
Definition: format.cxx:718
std::unique_ptr< SvxBrushItem > makeBackgroundBrushItem(bool=true) const
Definition: format.cxx:736
void RemoveAllUnos()
Definition: format.cxx:757
virtual SwFormat * GetFormat(size_t idx) const =0
virtual ~SwFormatsBase()
Definition: format.cxx:763
virtual SwFormat * FindFormatByName(const OUString &rName) const
Definition: format.cxx:766
virtual size_t GetFormatCount() const =0
TElementType * Next()
Definition: calbck.hxx:380
TElementType * First()
Definition: calbck.hxx:372
virtual void SwClientNotify(const SwModify &, const SfxHint &rHint) override
Definition: calbck.cxx:303
void InvalidateInSwCache(const sal_uInt16)
std::vector< bool, std::allocator< bool > > m_aSet
constexpr TypedWhichId< SwPtrMsgPoolItem > RES_REMOVE_UNO_OBJECT(181)
constexpr TypedWhichId< SwGrfFormatColl > RES_GRFFMTCOLL(164)
constexpr TypedWhichId< SwConditionTextFormatColl > RES_CONDTXTFMTCOLL(166)
constexpr TypedWhichId< SwFormatPageDesc > RES_PAGEDESC(99)
constexpr TypedWhichId< SvxBrushItem > RES_BACKGROUND(111)
constexpr TypedWhichId< SwAttrSetChg > RES_ATTRSET_CHG(169)
constexpr TypedWhichId< SwFlyFrameFormat > RES_FLYFRMFMT(162)
constexpr TypedWhichId< SwNumRuleItem > RES_PARATR_NUMRULE(72)
constexpr TypedWhichId< SwFormatDrop > RES_PARATR_DROP(70)
constexpr TypedWhichId< SwTextFormatColl > RES_TXTFMTCOLL(163)
constexpr TypedWhichId< SwPtrMsgPoolItem > RES_OBJECTDYING(RES_FORMAT_MSG_BEGIN)
constexpr TypedWhichId< SvxLRSpaceItem > RES_LR_SPACE(97)
constexpr TypedWhichId< SvxULSpaceItem > RES_UL_SPACE(98)
constexpr TypedWhichId< SwFrameFormat > RES_FRMFMT(161)
constexpr TypedWhichId< SwFormatChg > RES_FMT_CHG(168)
sal_Int64 n
#define SAL_WARN_IF(condition, area, stream)
#define SAL_WARN(area, stream)
#define SAL_INFO(area, stream)
void CheckTextFormatCollForDeletionOfAssignmentToOutlineStyle(SwFormat *pFormat, const SwNumRuleItem *pNewNumRuleItem)
Checks, if assignment of paragraph style to list level of outline style has to be deleted,...
Definition: fmtcol.cxx:42
std::shared_ptr< SdrAllFillAttributesHelper > SdrAllFillAttributesHelperPtr
Definition: format.hxx:41
constexpr Point convert(const Point &rPoint, o3tl::Length eFrom, o3tl::Length eTo)
Dialog to specify the properties of date form field.
void ClientNotifyAttrChg(SwModify &rModify, const SwAttrSet &aSet, SwAttrSet &aOld, SwAttrSet &aNew)
Definition: calbck.cxx:331
SfxItemState
static SfxItemSet & rSet
SVXCORE_DLLPUBLIC std::unique_ptr< SvxBrushItem > getSvxBrushItemFromSourceSet(const SfxItemSet &rSourceSet, sal_uInt16 nBackgroundID, bool bSearchInParents=true, bool bXMLImportHack=false)
SVXCORE_DLLPUBLIC void setSvxBrushItemAsFillAttributesToTargetSet(const SvxBrushItem &rBrush, SfxItemSet &rToSet)