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