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