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