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()
21 #include <IDocumentTimerAccess.hxx>
22 #include <doc.hxx>
23 #include <fmtcolfunc.hxx>
24 #include <format.hxx>
25 #include <frame.hxx>
26 #include <frmatr.hxx>
27 #include <hintids.hxx>
28 #include <hints.hxx>
29 #include <o3tl/unit_conversion.hxx>
30 #include <osl/diagnose.h>
31 #include <sal/log.hxx>
32 #include <svl/grabbagitem.hxx>
35 #include <svx/xdef.hxx>
36 #include <swcache.hxx>
37 
38 using namespace com::sun::star;
39 
40 SwFormat::SwFormat( SwAttrPool& rPool, const char* pFormatNm,
41  const sal_uInt16* pWhichRanges, SwFormat *pDrvdFrame,
42  sal_uInt16 nFormatWhich ) :
43  m_aFormatName( OUString::createFromAscii(pFormatNm) ),
44  m_aSet( rPool, pWhichRanges ),
45  m_nWhichId( nFormatWhich ),
46  m_nPoolFormatId( USHRT_MAX ),
47  m_nPoolHelpId( USHRT_MAX ),
48  m_nPoolHlpFileId( UCHAR_MAX )
49 {
50  m_bAutoUpdateFormat = false; // LAYER_IMPL
51  m_bAutoFormat = true;
52  m_bFormatInDTOR = m_bHidden = false;
53 
54  if( pDrvdFrame )
55  {
56  pDrvdFrame->Add(this);
57  m_aSet.SetParent( &pDrvdFrame->m_aSet );
58  }
59 }
60 
61 SwFormat::SwFormat( SwAttrPool& rPool, const OUString& rFormatNm,
62  const sal_uInt16* pWhichRanges, SwFormat* pDrvdFrame,
63  sal_uInt16 nFormatWhich ) :
64  m_aFormatName( rFormatNm ),
65  m_aSet( rPool, pWhichRanges ),
66  m_nWhichId( nFormatWhich ),
67  m_nPoolFormatId( USHRT_MAX ),
68  m_nPoolHelpId( USHRT_MAX ),
69  m_nPoolHlpFileId( UCHAR_MAX )
70 {
71  m_bAutoUpdateFormat = false; // LAYER_IMPL
72  m_bAutoFormat = true;
73  m_bFormatInDTOR = m_bHidden = false;
74 
75  if( pDrvdFrame )
76  {
77  pDrvdFrame->Add(this);
78  m_aSet.SetParent( &pDrvdFrame->m_aSet );
79  }
80 }
81 
82 SwFormat::SwFormat( const SwFormat& rFormat ) :
83  sw::BorderCacheOwner(),
84  m_aFormatName( rFormat.m_aFormatName ),
85  m_aSet( rFormat.m_aSet ),
86  m_nWhichId( rFormat.m_nWhichId ),
87  m_nPoolFormatId( rFormat.GetPoolFormatId() ),
88  m_nPoolHelpId( rFormat.GetPoolHelpId() ),
89  m_nPoolHlpFileId( rFormat.GetPoolHlpFileId() )
90 {
91  m_bFormatInDTOR = false; // LAYER_IMPL
92  m_bAutoFormat = rFormat.m_bAutoFormat;
93  m_bHidden = rFormat.m_bHidden;
95 
96  if( auto pDerived = rFormat.DerivedFrom() )
97  {
98  pDerived->Add(this);
99  m_aSet.SetParent( &pDerived->m_aSet );
100  }
101  // a few special treatments for attributes
102  m_aSet.SetModifyAtAttr( this );
103 }
104 
106 {
107  if(this == &rFormat)
108  return *this;
109 
110  m_nWhichId = rFormat.m_nWhichId;
111  m_nPoolFormatId = rFormat.GetPoolFormatId();
112  m_nPoolHelpId = rFormat.GetPoolHelpId();
114 
116 
117  // copy only array with attributes delta
118  SwAttrSet aOld( *m_aSet.GetPool(), m_aSet.GetRanges() ),
119  aNew( *m_aSet.GetPool(), m_aSet.GetRanges() );
120  m_aSet.Intersect_BC( rFormat.m_aSet, &aOld, &aNew );
121  (void)m_aSet.Put_BC( rFormat.m_aSet, &aOld, &aNew );
122 
123  // a few special treatments for attributes
124  m_aSet.SetModifyAtAttr( this );
125 
126  // create PoolItem attribute for Modify
127  if( aOld.Count() )
128  {
129  sw::ClientNotifyAttrChg(*this, m_aSet, aOld, aNew);
130  }
131 
132  if(GetRegisteredIn() != rFormat.GetRegisteredIn())
133  {
136  ? &rFormat.m_aSet
137  : nullptr);
138  }
139 
140  m_bAutoFormat = rFormat.m_bAutoFormat;
141  m_bHidden = rFormat.m_bHidden;
143  return *this;
144 }
145 
146 void SwFormat::SetName( const OUString& rNewName, bool bBroadcast )
147 {
148  OSL_ENSURE( !IsDefault(), "SetName: Defaultformat" );
149  if( bBroadcast )
150  {
152  SwStringMsgPoolItem aNew( RES_NAME_CHANGED, rNewName );
153  m_aFormatName = rNewName;
154  const sw::LegacyModifyHint aHint(&aOld, &aNew);
155  SwClientNotify(*this, aHint);
156  }
157  else
158  {
159  m_aFormatName = rNewName;
160  }
161 }
162 
174 void SwFormat::CopyAttrs( const SwFormat& rFormat )
175 {
176  // copy only array with attributes delta
179 
180  // special treatments for some attributes
181  SwAttrSet* pChgSet = const_cast<SwAttrSet*>(&rFormat.m_aSet);
182 
183  // copy only array with attributes delta
184  if( pChgSet->GetPool() != m_aSet.GetPool() )
185  pChgSet->CopyToModify( *this );
186  else
187  {
188  SwAttrSet aOld( *m_aSet.GetPool(), m_aSet.GetRanges() ),
189  aNew( *m_aSet.GetPool(), m_aSet.GetRanges() );
190 
191  if ( m_aSet.Put_BC( *pChgSet, &aOld, &aNew ) )
192  {
193  // a few special treatments for attributes
194  m_aSet.SetModifyAtAttr( this );
195 
196  SwAttrSetChg aChgOld( m_aSet, aOld );
197  SwAttrSetChg aChgNew( m_aSet, aNew );
198  SwClientNotify(*this, sw::LegacyModifyHint(&aChgOld, &aChgNew)); // send all modified ones
199  }
200  }
201 
202  if( pChgSet != &rFormat.m_aSet ) // was a Set created?
203  delete pChgSet;
204 }
205 
207 {
208  // This happens at an ObjectDying message. Thus put all dependent
209  // ones on DerivedFrom.
210  if(!HasWriterListeners())
211  return;
212 
213  m_bFormatInDTOR = true;
214 
215  if(!DerivedFrom())
216  {
218  SAL_WARN("sw.core", "~SwFormat: format still has clients on death, but parent format is missing: " << GetName());
219  return;
220  }
221  SwIterator<SwClient,SwFormat> aIter(*this);
222  for(SwClient* pClient = aIter.First(); pClient; pClient = aIter.Next())
223  pClient->CheckRegistrationFormat(*this);
225 }
226 
227 void SwFormat::SwClientNotify(const SwModify&, const SfxHint& rHint)
228 {
229  auto pLegacy = dynamic_cast<const sw::LegacyModifyHint*>(&rHint);
230  if(!pLegacy)
231  return;
232 
233  std::unique_ptr<SwAttrSetChg> pOldClientChg, pNewClientChg;
234  auto pDependsHint = std::make_unique<sw::LegacyModifyHint>(pLegacy->m_pOld, pLegacy->m_pNew);
235  const sal_uInt16 nWhich = pLegacy->GetWhich();
236  InvalidateInSwCache(nWhich);
237  switch(nWhich)
238  {
239  case 0:
240  break;
241  case RES_OBJECTDYING:
242  {
243  // NB: this still notifies depends even if pLegacy->m_pNew is nullptr, which seems non-obvious
244  if(!pLegacy->m_pNew)
245  break;
246  // If the dying object is the parent format of this format so
247  // attach this to the parent of the parent
248  SwFormat* pFormat = static_cast<SwFormat*>(pLegacy->m_pNew->StaticWhichCast(RES_OBJECTDYING).pObject);
249 
250  // do not move if this is the topmost format
251  if(GetRegisteredIn() && GetRegisteredIn() == pFormat)
252  {
253  if(pFormat->GetRegisteredIn())
254  {
255  // if parent so register in new parent
256  pFormat->DerivedFrom()->Add(this);
258  }
259  else
260  {
261  // otherwise de-register at least from dying one
262  EndListeningAll();
263  m_aSet.SetParent(nullptr);
264  }
265  }
266  break;
267  }
268  case RES_ATTRSET_CHG:
269  {
270  // NB: this still notifies depends even if this condition is not met, which seems non-obvious
271  auto pOldAttrSetChg = static_cast<const SwAttrSetChg*>(pLegacy->m_pOld);
272  auto pNewAttrSetChg = static_cast<const SwAttrSetChg*>(pLegacy->m_pNew);
273  if (pOldAttrSetChg && pNewAttrSetChg && pOldAttrSetChg->GetTheChgdSet() != &m_aSet)
274  {
275  // pass only those that are not set...
276  pNewClientChg.reset(new SwAttrSetChg(*pNewAttrSetChg));
277  pNewClientChg->GetChgSet()->Differentiate(m_aSet);
278  if(pNewClientChg->Count()) // ... if any
279  {
280  pOldClientChg.reset(new SwAttrSetChg(*pOldAttrSetChg));
281  pOldClientChg->GetChgSet()->Differentiate(m_aSet);
282  pDependsHint.reset(new sw::LegacyModifyHint(pOldClientChg.get(), pNewClientChg.get()));
283  }
284  else
285  pDependsHint.reset(nullptr);
286  }
287  break;
288  }
289  case RES_FMT_CHG:
290  {
291  // if the format parent will be moved so register my attribute set at
292  // the new one
293 
294  // skip my own Modify
295  // NB: this still notifies depends even if this condition is not met, which seems non-obvious
296  auto pOldFormatChg = static_cast<const SwFormatChg*>(pLegacy->m_pOld);
297  auto pNewFormatChg = static_cast<const SwFormatChg*>(pLegacy->m_pNew);
298  if(pOldFormatChg && pNewFormatChg && pOldFormatChg->pChangedFormat != this && pNewFormatChg->pChangedFormat == GetRegisteredIn())
299  {
300  // attach Set to new parent
301  m_aSet.SetParent(DerivedFrom() ? &DerivedFrom()->m_aSet : nullptr);
302  }
303  break;
304  }
305  default:
306  // attribute is defined in this format
307  if(SfxItemState::SET == m_aSet.GetItemState(nWhich, false))
308  {
309  // DropCaps might come into this block
310  SAL_WARN_IF(RES_PARATR_DROP != nWhich, "sw.core", "Hint was sent without sender");
311  pDependsHint.reset(nullptr);
312  }
313  }
314  if(pDependsHint)
315  {
316  InvalidateInSwFntCache(pDependsHint->GetWhich());
317  SwModify::SwClientNotify(*this, *pDependsHint);
318  }
319 }
320 
322 {
323  if ( pDerFrom )
324  {
325  const SwFormat* pFormat = pDerFrom;
326  while ( pFormat != nullptr )
327  {
328  if ( pFormat == this )
329  return false;
330 
331  pFormat=pFormat->DerivedFrom();
332  }
333  }
334  else
335  {
336  // nothing provided, search for Dflt format
337  pDerFrom = this;
338  while ( pDerFrom->DerivedFrom() )
339  pDerFrom = pDerFrom->DerivedFrom();
340  }
341  if ( (pDerFrom == DerivedFrom()) || (pDerFrom == this) )
342  return false;
343 
344  assert( Which()==pDerFrom->Which()
345  || (Which()==RES_CONDTXTFMTCOLL && pDerFrom->Which()==RES_TXTFMTCOLL)
346  || (Which()==RES_TXTFMTCOLL && pDerFrom->Which()==RES_CONDTXTFMTCOLL)
347  || (Which()==RES_FLYFRMFMT && pDerFrom->Which()==RES_FRMFMT)
348  );
349 
352 
353  pDerFrom->Add( this );
354  m_aSet.SetParent( &pDerFrom->m_aSet );
355 
356  SwFormatChg aOldFormat( this );
357  SwFormatChg aNewFormat( this );
358  const sw::LegacyModifyHint aHint(&aOldFormat, &aNewFormat);
359  SwClientNotify(*this, aHint);
360 
361  return true;
362 }
363 
365 {
366  return false;
367 }
368 
369 const SfxPoolItem& SwFormat::GetFormatAttr( sal_uInt16 nWhich, bool bInParents ) const
370 {
372  {
373  // FALLBACKBREAKHERE should not be used; instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST]
374  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)");
375  static std::unique_ptr<SvxBrushItem> aSvxBrushItem; //(std::make_shared<SvxBrushItem>(RES_BACKGROUND));
376 
377  // fill the local static SvxBrushItem from the current ItemSet so that
378  // the fill attributes [XATTR_FILL_FIRST .. XATTR_FILL_LAST] are used
379  // as good as possible to create a fallback representation and return that
380  aSvxBrushItem = getSvxBrushItemFromSourceSet(m_aSet, RES_BACKGROUND, bInParents);
381 
382  return *aSvxBrushItem;
383  }
384 
385  return m_aSet.Get( nWhich, bInParents );
386 }
387 
388 SfxItemState SwFormat::GetItemState( sal_uInt16 nWhich, bool bSrchInParent, const SfxPoolItem **ppItem ) const
389 {
391  {
392  // FALLBACKBREAKHERE should not be used; instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST]
393  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)");
395 
396  // check if the new fill attributes are used
397  if(aFill && aFill->isUsed())
398  {
399  // if yes, fill the local SvxBrushItem using the new fill attributes
400  // as good as possible to have an instance for the pointer to point
401  // to and return as state that it is set
402  static std::unique_ptr<SvxBrushItem> aSvxBrushItem; //(RES_BACKGROUND);
403 
404  aSvxBrushItem = getSvxBrushItemFromSourceSet(m_aSet, RES_BACKGROUND, bSrchInParent);
405  if( ppItem )
406  *ppItem = aSvxBrushItem.get();
407 
408  return SfxItemState::SET;
409  }
410 
411  // if not, reset pointer and return SfxItemState::DEFAULT to signal that
412  // the item is not set
413  if( ppItem )
414  *ppItem = nullptr;
415 
416  return SfxItemState::DEFAULT;
417  }
418 
419  return m_aSet.GetItemState( nWhich, bSrchInParent, ppItem );
420 }
421 
422 SfxItemState SwFormat::GetBackgroundState(std::unique_ptr<SvxBrushItem>& rItem) const
423 {
425  {
426  // FALLBACKBREAKHERE should not be used; instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST]
428 
429  // check if the new fill attributes are used
430  if(aFill && aFill->isUsed())
431  {
432  // if yes, fill the local SvxBrushItem using the new fill attributes
433  // as good as possible to have an instance for the pointer to point
434  // to and return as state that it is set
436  return SfxItemState::SET;
437  }
438 
439  // if not return SfxItemState::DEFAULT to signal that the item is not set
440  return SfxItemState::DEFAULT;
441  }
442 
443  const SfxPoolItem* pItem = nullptr;
444  SfxItemState eRet = m_aSet.GetItemState(RES_BACKGROUND, true, &pItem);
445  if (pItem)
446  rItem.reset(&pItem->Clone()->StaticWhichCast(RES_BACKGROUND));
447  return eRet;
448 }
449 
451 {
452  const sal_uInt16 nWhich = rAttr.Which();
453  InvalidateInSwFntCache( nWhich );
454  InvalidateInSwCache( nWhich );
455 
456  bool bRet = false;
457 
459  {
460  // FALLBACKBREAKHERE should not be used; instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST]
461  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)");
463  const SvxBrushItem& rSource = rAttr.StaticWhichCast(RES_BACKGROUND);
464 
465  // fill a local ItemSet with the attributes corresponding as good as possible
466  // to the new fill properties [XATTR_FILL_FIRST .. XATTR_FILL_LAST] and set these
467  // as ItemSet
469 
470  if(IsModifyLocked())
471  {
472  bRet = m_aSet.Put( aTempSet );
473  if( bRet )
474  {
475  m_aSet.SetModifyAtAttr( this );
476  }
477  }
478  else
479  {
481 
482  bRet = m_aSet.Put_BC(aTempSet, &aOld, &aNew);
483 
484  if(bRet)
485  {
486  m_aSet.SetModifyAtAttr(this);
487  sw::ClientNotifyAttrChg(*this, m_aSet, aOld, aNew);
488  }
489  }
490 
491  return bRet;
492  }
493 
494  // if Modify is locked then no modifications will be sent;
495  // but call Modify always for FrameFormats
496  const sal_uInt16 nFormatWhich = Which();
497  if( IsModifyLocked() ||
498  ( !HasWriterListeners() &&
499  (RES_GRFFMTCOLL == nFormatWhich ||
500  RES_TXTFMTCOLL == nFormatWhich ) ) )
501  {
502  bRet = nullptr != m_aSet.Put( rAttr );
503  if( bRet )
504  m_aSet.SetModifyAtAttr( this );
505  // #i71574#
506  if ( nFormatWhich == RES_TXTFMTCOLL && rAttr.Which() == RES_PARATR_NUMRULE )
507  {
509  }
510  }
511  else
512  {
513  // copy only array with attributes delta
514  SwAttrSet aOld( *m_aSet.GetPool(), m_aSet.GetRanges() ),
515  aNew( *m_aSet.GetPool(), m_aSet.GetRanges() );
516 
517  bRet = m_aSet.Put_BC( rAttr, &aOld, &aNew );
518  if( bRet )
519  {
520  // some special treatments for attributes
521  m_aSet.SetModifyAtAttr( this );
522 
523  sw::ClientNotifyAttrChg(*this, m_aSet, aOld, aNew);
524  }
525  }
526  return bRet;
527 }
528 
530 {
531  if( !rSet.Count() )
532  return false;
533 
536 
537  bool bRet = false;
538 
539  // Use local copy to be able to apply needed changes, e.g. call
540  // CheckForUniqueItemForLineFillNameOrIndex which is needed for NameOrIndex stuff
541  SfxItemSet aTempSet(rSet);
542 
543  // Need to check for unique item for DrawingLayer items of type NameOrIndex
544  // and evtl. correct that item to ensure unique names for that type. This call may
545  // modify/correct entries inside of the given SfxItemSet
546  if(GetDoc())
547  {
549  }
550 
552  {
553  const SfxPoolItem* pSource = nullptr;
554 
555  if(SfxItemState::SET == aTempSet.GetItemState(RES_BACKGROUND, false, &pSource))
556  {
557  // FALLBACKBREAKHERE should not be used; instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST]
558  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)");
559 
560  // copy all items to be set anyways to a local ItemSet with is also prepared for the new
561  // fill attribute ranges [XATTR_FILL_FIRST .. XATTR_FILL_LAST]. Add the attributes
562  // corresponding as good as possible to the new fill properties and set the whole ItemSet
563  const SvxBrushItem& rSource(pSource->StaticWhichCast(RES_BACKGROUND));
565 
566  if(IsModifyLocked())
567  {
568  bRet = m_aSet.Put( aTempSet );
569  if( bRet )
570  {
571  m_aSet.SetModifyAtAttr( this );
572  }
573  }
574  else
575  {
577 
578  bRet = m_aSet.Put_BC(aTempSet, &aOld, &aNew);
579 
580  if(bRet)
581  {
582  m_aSet.SetModifyAtAttr(this);
583  sw::ClientNotifyAttrChg(*this, m_aSet, aOld, aNew);
584  }
585  }
586 
587  return bRet;
588  }
589  }
590 
591  // if Modify is locked then no modifications will be sent;
592  // but call Modify always for FrameFormats
593  const sal_uInt16 nFormatWhich = Which();
594  if ( IsModifyLocked() ||
595  ( !HasWriterListeners() &&
596  ( RES_GRFFMTCOLL == nFormatWhich ||
597  RES_TXTFMTCOLL == nFormatWhich ) ) )
598  {
599  bRet = m_aSet.Put( aTempSet );
600  if( bRet )
601  m_aSet.SetModifyAtAttr( this );
602  // #i71574#
603  if ( nFormatWhich == RES_TXTFMTCOLL )
604  {
606  }
607  }
608  else
609  {
610  SwAttrSet aOld( *m_aSet.GetPool(), m_aSet.GetRanges() ),
611  aNew( *m_aSet.GetPool(), m_aSet.GetRanges() );
612  bRet = m_aSet.Put_BC( aTempSet, &aOld, &aNew );
613  if( bRet )
614  {
615  // some special treatments for attributes
616  m_aSet.SetModifyAtAttr( this );
617  sw::ClientNotifyAttrChg(*this, m_aSet, aOld, aNew);
618  }
619  }
620  return bRet;
621 }
622 
623 // remove Hint using nWhich from array with delta
624 bool SwFormat::ResetFormatAttr( sal_uInt16 nWhich1, sal_uInt16 nWhich2 )
625 {
626  if( !m_aSet.Count() )
627  return false;
628 
629  if( !nWhich2 || nWhich2 < nWhich1 )
630  nWhich2 = nWhich1; // then set to 1st ID, only this item
631 
632  for( sal_uInt16 n = nWhich1; n < nWhich2; ++n )
634  for( sal_uInt16 n = nWhich1; n < nWhich2 && IsInCache(); ++n )
636 
637  // if Modify is locked then no modifications will be sent
638  if( IsModifyLocked() )
639  return 0 != (( nWhich2 == nWhich1 )
640  ? m_aSet.ClearItem( nWhich1 )
641  : m_aSet.ClearItem_BC( nWhich1, nWhich2 ));
642 
643  SwAttrSet aOld( *m_aSet.GetPool(), m_aSet.GetRanges() ),
644  aNew( *m_aSet.GetPool(), m_aSet.GetRanges() );
645  bool bRet = 0 != m_aSet.ClearItem_BC( nWhich1, nWhich2, &aOld, &aNew );
646  if( bRet )
647  sw::ClientNotifyAttrChg(*this, m_aSet, aOld, aNew);
648  return bRet;
649 }
650 
651 // #i73790#
653 {
654  if( !m_aSet.Count() )
655  return 0;
656 
659 
660  // if Modify is locked then no modifications will be sent
661  if( IsModifyLocked() )
662  return m_aSet.ClearItem();
663 
664  SwAttrSet aOld( *m_aSet.GetPool(), m_aSet.GetRanges() ),
665  aNew( *m_aSet.GetPool(), m_aSet.GetRanges() );
666  bool bRet = 0 != m_aSet.ClearItem_BC( 0, &aOld, &aNew );
667  if( bRet )
668  sw::ClientNotifyAttrChg(*this, m_aSet, aOld, aNew);
669  return aNew.Count();
670 }
671 
672 void SwFormat::DelDiffs( const SfxItemSet& rSet )
673 {
674  if( !m_aSet.Count() )
675  return;
676 
679 
680  // if Modify is locked then no modifications will be sent
681  if( IsModifyLocked() )
682  {
683  m_aSet.Intersect( rSet );
684  return;
685  }
686 
687  SwAttrSet aOld( *m_aSet.GetPool(), m_aSet.GetRanges() ),
688  aNew( *m_aSet.GetPool(), m_aSet.GetRanges() );
689  bool bRet = 0 != m_aSet.Intersect_BC( rSet, &aOld, &aNew );
690  if( bRet )
691  sw::ClientNotifyAttrChg(*this, m_aSet, aOld, aNew);
692 }
693 
695 {
696  const sal_Int32 nSize = o3tl::convert(2, o3tl::Length::cm, o3tl::Length::twip);
697  SetFormatAttr(SvxLRSpaceItem(nSize, nSize, nSize, 0, RES_LR_SPACE));
698  SetFormatAttr(SvxULSpaceItem(nSize, nSize, RES_UL_SPACE));
699 }
700 
710 {
711  return false;
712 }
713 
714 /*
715  * Document Interface Access
716  */
725 
727 {
728  if (m_pGrabBagItem)
729  m_pGrabBagItem->QueryValue(rVal);
730  else
731  rVal <<= uno::Sequence<beans::PropertyValue>();
732 }
733 
735 {
736  if (!m_pGrabBagItem)
737  m_pGrabBagItem = std::make_shared<SfxGrabBagItem>();
738 
739  m_pGrabBagItem->PutValue(rVal, 0);
740 }
741 
742 std::unique_ptr<SvxBrushItem> SwFormat::makeBackgroundBrushItem(bool bInP) const
743 {
745  {
746  // FALLBACKBREAKHERE should not be used; instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST]
747  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)");
748 
749  // fill the local static SvxBrushItem from the current ItemSet so that
750  // the fill attributes [XATTR_FILL_FIRST .. XATTR_FILL_LAST] are used
751  // as good as possible to create a fallback representation and return that
753  }
754 
755  return std::unique_ptr<SvxBrushItem>(m_aSet.GetBackground(bInP).Clone());
756 }
757 
759 {
761 }
762 
764 {
765  SwPtrMsgPoolItem aMsgHint(RES_REMOVE_UNO_OBJECT, this);
766  SwClientNotify(*this, sw::LegacyModifyHint(&aMsgHint, &aMsgHint));
767 }
768 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const SwAttrSet * GetChgSet() const
What has changed.
Definition: hints.hxx:281
constexpr TypedWhichId< SwFormatPageDesc > RES_PAGEDESC(93)
sal_uInt16 m_nPoolFormatId
Id for "automatically" created formats.
Definition: format.hxx:54
void Add(SwClient *pDepend)
Definition: calbck.cxx:171
sal_uInt16 GetWhich() const
Definition: calbck.hxx:71
sal_uInt16 m_nWhichId
Definition: format.hxx:53
bool IsDefault() const
Definition: format.hxx:113
const SvxBrushItem & GetBackground(bool=true) const
Definition: frmatr.hxx:58
constexpr TypedWhichId< SwFormatChg > RES_FMT_CHG(162)
constexpr TypedWhichId< SwPtrMsgPoolItem > RES_REMOVE_UNO_OBJECT(181)
std::unique_ptr< SvxBrushItem > getSvxBrushItemFromSourceSet(const SfxItemSet &rSourceSet, sal_uInt16 nBackgroundID, bool bSearchInParents, bool bXMLImportHack)
virtual SfxPoolItem * Clone(SfxItemPool *pPool=nullptr) const =0
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:44
constexpr TypedWhichId< SwNumRuleItem > RES_PARATR_NUMRULE(72)
OUString m_aFormatName
Definition: format.hxx:50
Handle the background jobs of a Writer document.
sal_Int64 n
TElementType * Next()
Definition: calbck.hxx:333
void DelDiffs(const SfxItemSet &rSet)
Delete all attributes that are not in rFormat.
Definition: format.cxx:672
virtual ~SwFormat() override
Definition: format.cxx:206
constexpr TypedWhichId< SwConditionTextFormatColl > RES_CONDTXTFMTCOLL(160)
Dialog to specify the properties of date form field.
SwAttrSet m_aSet
Definition: format.hxx:51
IDocumentChartDataProviderAccess & getIDocumentChartDataProviderAccess()
Gives access to the chart data-provider.
Definition: format.cxx:724
virtual SvxBrushItem * Clone(SfxItemPool *pPool=nullptr) const override
IDocumentTimerAccess & getIDocumentTimerAccess()
Provides access to the document idle timer interface.
Definition: format.cxx:722
bool HasWriterListeners() const
Definition: calbck.hxx:197
SwFormat(SwAttrPool &rPool, const char *pFormatNm, const sal_uInt16 *pWhichRanges, SwFormat *pDrvdFrame, sal_uInt16 nFormatWhich)
Definition: format.cxx:40
constexpr TypedWhichId< SwFlyFrameFormat > RES_FLYFRMFMT(156)
IDocumentDrawModelAccess const & getIDocumentDrawModelAccess() const
Definition: doc.cxx:155
void StartListeningToSameModifyAs(const SwClient &)
Definition: calbck.cxx:127
IDocumentFieldsAccess const & getIDocumentFieldsAccess() const
Definition: doc.cxx:357
std::unique_ptr< SvxBrushItem > makeBackgroundBrushItem(bool=true) const
Definition: format.cxx:742
bool Put_BC(const SfxPoolItem &rAttr, SwAttrSet *pOld, SwAttrSet *pNew)
Definition: swatrset.cxx:183
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
std::shared_ptr< SfxGrabBagItem > m_pGrabBagItem
Style InteropGrabBag.
Definition: format.hxx:65
sal_uInt16 m_nPoolHelpId
HelpId for this Pool-style.
Definition: format.hxx:56
constexpr TypedWhichId< SwFormatDrop > RES_PARATR_DROP(70)
const OUString & GetName() const
Definition: format.hxx:115
std::shared_ptr< SdrAllFillAttributesHelper > SdrAllFillAttributesHelperPtr
Definition: format.hxx:41
virtual void SwClientNotify(const SwModify &, const SfxHint &) override
Definition: format.cxx:227
constexpr TypedWhichId< SwFrameFormat > RES_FRMFMT(155)
void Intersect(const SfxItemSet &rSet)
SwFormat & operator=(const SwFormat &)
Definition: format.cxx:105
sal_uInt8 m_nPoolHlpFileId
FilePos to Doc to these style helps.
Definition: format.hxx:57
SwAttrPool * GetPool() const
Definition: swatrset.hxx:190
bool SetDerivedFrom(SwFormat *pDerivedFrom=nullptr)
0 is Default.
Definition: format.cxx:321
sal_uInt16 GetPoolFormatId() const
Get and set Pool style IDs.
Definition: format.hxx:147
constexpr auto convert(N n, sal_Int64 mul, sal_Int64 div)
virtual sal_uInt16 ResetAllFormatAttr()
Takes all hints from Delta-Array,.
Definition: format.cxx:652
void ClientNotifyAttrChg(SwModify &rModify, const SwAttrSet &aSet, SwAttrSet &aOld, SwAttrSet &aNew)
Definition: calbck.cxx:330
void EndListeningAll()
Definition: calbck.cxx:135
Base class for various Writer styles.
Definition: format.hxx:46
IDocumentFieldsAccess & getIDocumentFieldsAccess()
Provides access to the document idle timer interface.
Definition: format.cxx:723
void CopyToModify(sw::BroadcastingModify &rMod) const
Definition: swatrset.cxx:291
sal_uInt16 ClearItem(sal_uInt16 nWhich=0)
bool m_bHidden
Definition: format.hxx:64
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
T & StaticWhichCast(TypedWhichId< T > nId)
const IDocumentLayoutAccess & getIDocumentLayoutAccess() const
Provides access to the document layout interface.
Definition: format.cxx:720
Document fields related interfaces.
constexpr TypedWhichId< SwGrfFormatColl > RES_GRFFMTCOLL(158)
TElementType * First()
Definition: calbck.hxx:325
sal_uInt16 Count() const
SfxItemState GetBackgroundState(std::unique_ptr< SvxBrushItem > &rItem) const
Definition: format.cxx:422
virtual void SetName(const OUString &rNewName, bool bBroadcast=false)
Definition: format.cxx:146
void InvalidateInSwCache(const sal_uInt16)
constexpr TypedWhichId< SwAttrSetChg > RES_ATTRSET_CHG(163)
sal_uInt8 GetPoolHlpFileId() const
Definition: format.hxx:153
Provides access to settings of a document.
void setSvxBrushItemAsFillAttributesToTargetSet(const SvxBrushItem &rBrush, SfxItemSet &rToSet)
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
Definition: format.cxx:388
constexpr TypedWhichId< SwTextFormatColl > RES_TXTFMTCOLL(157)
const SwDoc * GetDoc() const
The document is set in SwAttrPool now, therefore you always can access it.
Definition: format.hxx:123
const IDocumentSettingAccess & getIDocumentSettingAccess() const
Provides access to the document settings interface.
Definition: format.cxx:717
IDocumentChartDataProviderAccess const & getIDocumentChartDataProviderAccess() const
Definition: doc.cxx:227
int Intersect_BC(const SfxItemSet &rSet, SwAttrSet *pOld, SwAttrSet *pNew)
Definition: swatrset.cxx:226
IDocumentLayoutAccess const & getIDocumentLayoutAccess() const
Definition: doc.cxx:405
void SetGrabBagItem(const css::uno::Any &rVal)
Definition: format.cxx:734
void SetParent(const SfxItemSet *pNew)
virtual bool SetFormatAttr(const SfxPoolItem &rAttr)
Definition: format.cxx:450
sal_uInt16 Which() const
for Querying of Writer-functions.
Definition: format.hxx:82
bool IsModifyLocked() const
Definition: calbck.hxx:205
SwFormat * DerivedFrom() const
Definition: format.hxx:112
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
virtual bool ResetFormatAttr(sal_uInt16 nWhich1, sal_uInt16 nWhich2=0)
Definition: format.cxx:624
bool m_bAutoUpdateFormat
TRUE: Set attributes of a whole paragraph at format (UI-side!).
Definition: format.hxx:62
SfxItemState
constexpr TypedWhichId< SvxBrushItem > RES_BACKGROUND(105)
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
sal_uInt16 GetPoolHelpId() const
Get and set Help-IDs for document templates.
Definition: format.hxx:151
#define SAL_WARN_IF(condition, area, stream)
void CopyAttrs(const SwFormat &)
Copy attributes even among documents.
Definition: format.cxx:174
virtual drawinglayer::attribute::SdrAllFillAttributesHelperPtr getSdrAllFillAttributesHelper() const
Definition: format.cxx:758
const o3tl::enumarray< SvxAdjust, unsigned short > aSvxToUnoAdjust USHRT_MAX
Definition: unosett.cxx:254
#define SAL_INFO(area, stream)
void GetGrabBagItem(css::uno::Any &rVal) const
Definition: format.cxx:726
void Differentiate(const SfxItemSet &rSet)
bool SetModifyAtAttr(const sw::BroadcastingModify *pModify)
special treatment for some attributes
Definition: swatrset.cxx:253
bool m_bFormatInDTOR
TRUE: Format becomes deleted.
Definition: format.hxx:60
::sw::DocumentSettingManager & GetDocumentSettingManager()
Definition: doc.cxx:186
const SwModify * GetRegisteredIn() const
Definition: calbck.hxx:159
const SfxPoolItem & GetFormatAttr(sal_uInt16 nWhich, bool bInParents=true) const
If bInParents is FALSE, search only in this format for attribute.
Definition: format.cxx:369
constexpr TypedWhichId< SvxLRSpaceItem > RES_LR_SPACE(91)
void RemoveAllUnos()
Definition: format.cxx:763
constexpr TypedWhichId< SwStringMsgPoolItem > RES_NAME_CHANGED(187)
const sal_uInt16 * GetRanges() const
Provides access to the layout of a document.
void CheckForUniqueItemForLineFillNameOrIndex(SfxItemSet &rSet)
Definition: docfly.cxx:501
#define SAL_WARN(area, stream)
bool m_bAutoFormat
FALSE: it is a template.
Definition: format.hxx:58
virtual void SwClientNotify(const SwModify &, const SfxHint &rHint) override
Definition: calbck.cxx:302
Give access to the data-provider for chart.
void SetPageFormatToDefault()
Definition: format.cxx:694
std::vector< bool, std::allocator< bool > > m_aSet
virtual bool IsBackgroundTransparent() const
SwFormat::IsBackgroundTransparent.
Definition: format.cxx:709
virtual bool supportsFullDrawingLayerFillAttributeSet() const
Definition: format.cxx:364
sal_uInt16 ClearItem_BC(sal_uInt16 nWhich, SwAttrSet *pOld, SwAttrSet *pNew)
Definition: swatrset.cxx:203
constexpr TypedWhichId< SvxULSpaceItem > RES_UL_SPACE(92)
sal_uInt16 Which() const
constexpr TypedWhichId< SwPtrMsgPoolItem > RES_OBJECTDYING(RES_MSG_BEGIN)
IDocumentTimerAccess const & getIDocumentTimerAccess() const
Definition: doc.cxx:249
virtual void InvalidateInSwFntCache(sal_uInt16)
Definition: format.hxx:66
const IDocumentDrawModelAccess & getIDocumentDrawModelAccess() const
Provides access to the document draw model interface.
Definition: format.cxx:718
typedef void(CALLTYPE *GetFuncDataPtr)(sal_uInt16 &nNo