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 <paratr.hxx>
29 #include <swcache.hxx>
30 #include <swtblfmt.hxx>
31 #include <frmatr.hxx>
32 #include <svl/grabbagitem.hxx>
35 #include <svx/xdef.hxx>
36 #include <sal/log.hxx>
37 
38 using namespace com::sun::star;
39 
40 
41 SwFormat::SwFormat( SwAttrPool& rPool, const sal_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;
53  m_bFormatInDTOR = m_bHidden = false;
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;
74  m_bFormatInDTOR = m_bHidden = false;
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;
95 
96  if( auto pDerived = rFormat.DerivedFrom() )
97  {
98  pDerived->Add(this);
99  m_aSet.SetParent( &pDerived->m_aSet );
100  }
101  // a few special treatments for attributes
102  m_aSet.SetModifyAtAttr( this );
103 }
104 
106 {
107  if(this == &rFormat)
108  return *this;
109 
110  m_nWhichId = rFormat.m_nWhichId;
111  m_nPoolFormatId = rFormat.GetPoolFormatId();
112  m_nPoolHelpId = rFormat.GetPoolHelpId();
114 
115  if ( IsInCache() )
116  {
117  SwFrame::GetCache().Delete( this );
118  SetInCache( false );
119  }
120  SetInSwFntCache( false );
121 
122  // copy only array with attributes delta
123  SwAttrSet aOld( *m_aSet.GetPool(), m_aSet.GetRanges() ),
124  aNew( *m_aSet.GetPool(), m_aSet.GetRanges() );
125  m_aSet.Intersect_BC( rFormat.m_aSet, &aOld, &aNew );
126  (void)m_aSet.Put_BC( rFormat.m_aSet, &aOld, &aNew );
127 
128  // a few special treatments for attributes
129  m_aSet.SetModifyAtAttr( this );
130 
131  // create PoolItem attribute for Modify
132  if( aOld.Count() )
133  {
134  SwAttrSetChg aChgOld( m_aSet, aOld );
135  SwAttrSetChg aChgNew( m_aSet, aNew );
136  ModifyNotification( &aChgOld, &aChgNew ); // send all modified ones
137  }
138 
139  if(GetRegisteredIn() != rFormat.GetRegisteredIn())
140  {
143  ? &rFormat.m_aSet
144  : nullptr);
145  }
146 
147  m_bAutoFormat = rFormat.m_bAutoFormat;
148  m_bHidden = rFormat.m_bHidden;
150  return *this;
151 }
152 
153 void SwFormat::SetName( const OUString& rNewName, bool bBroadcast )
154 {
155  OSL_ENSURE( !IsDefault(), "SetName: Defaultformat" );
156  if( bBroadcast )
157  {
159  SwStringMsgPoolItem aNew( RES_NAME_CHANGED, rNewName );
160  m_aFormatName = rNewName;
161  ModifyNotification( &aOld, &aNew );
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  SetInSwFntCache( 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  ModifyNotification( &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 a ObjectDying message. Thus put all dependent
219  // ones on DerivedFrom.
220  if( HasWriterListeners() )
221  {
222  m_bFormatInDTOR = true;
223 
224  SwFormat* pParentFormat = DerivedFrom();
225  if( !pParentFormat )
226  {
227  SAL_WARN(
228  "sw.core",
229  "~SwFormat: parent format missing from: " << GetName() );
230  }
231  else
232  {
233  SwFormatChg aOldFormat( this );
234  SwFormatChg aNewFormat( pParentFormat );
235  SwIterator<SwClient,SwFormat> aIter(*this);
236  for(SwClient* pClient = aIter.First(); pClient && pParentFormat; pClient = aIter.Next())
237  {
238  SAL_INFO("sw.core", "reparenting " << typeid(*pClient).name() << " at " << pClient << " from " << typeid(*this).name() << " at " << this << " to " << typeid(*pParentFormat).name() << " at " << pParentFormat);
239  pParentFormat->Add( pClient );
240  pClient->ModifyNotification( &aOldFormat, &aNewFormat );
241  }
242  }
243  }
244 }
245 
246 void SwFormat::Modify( const SfxPoolItem* pOldValue, const SfxPoolItem* pNewValue )
247 {
248  bool bContinue = true; // true = pass on to dependent ones
249 
250  sal_uInt16 nWhich = pOldValue ? pOldValue->Which() :
251  pNewValue ? pNewValue->Which() : 0 ;
252  switch( nWhich )
253  {
254  case 0: break; // Which-Id of 0?
255 
256  case RES_OBJECTDYING:
257  if (pNewValue)
258  {
259  // If the dying object is the parent format of this format so
260  // attach this to the parent of the parent
261  SwFormat* pFormat = static_cast<SwFormat*>(static_cast<const SwPtrMsgPoolItem*>(pNewValue)->pObject);
262 
263  // do not move if this is the topmost format
264  if( GetRegisteredIn() && GetRegisteredIn() == pFormat )
265  {
266  if( pFormat->GetRegisteredIn() )
267  {
268  // if parent so register in new parent
269  pFormat->DerivedFrom()->Add( this );
271  }
272  else
273  {
274  // otherwise de-register at least from dying one
275  EndListeningAll();
276  m_aSet.SetParent( nullptr );
277  }
278  }
279  }
280  break;
281  case RES_ATTRSET_CHG:
282  if (pOldValue && pNewValue && static_cast<const SwAttrSetChg*>(pOldValue)->GetTheChgdSet() != &m_aSet)
283  {
284  // pass only those that are not set
285  SwAttrSetChg aOld( *static_cast<const SwAttrSetChg*>(pOldValue) );
286  SwAttrSetChg aNew( *static_cast<const SwAttrSetChg*>(pNewValue) );
287 
288  aOld.GetChgSet()->Differentiate( m_aSet );
289  aNew.GetChgSet()->Differentiate( m_aSet );
290 
291  if( aNew.Count() )
292  NotifyClients( &aOld, &aNew );
293  bContinue = false;
294  }
295  break;
296  case RES_FMT_CHG:
297  // if the format parent will be moved so register my attribute set at
298  // the new one
299 
300  // skip my own Modify
301  if ( pOldValue && pNewValue &&
302  static_cast<const SwFormatChg*>(pOldValue)->pChangedFormat != this &&
303  static_cast<const SwFormatChg*>(pNewValue)->pChangedFormat == GetRegisteredIn() )
304  {
305  // attach Set to new parent
306  m_aSet.SetParent( DerivedFrom() ? &DerivedFrom()->m_aSet : nullptr );
307  }
308  break;
309  default:
310  {
311  // attribute is defined in this format
312  if( SfxItemState::SET == m_aSet.GetItemState( nWhich, false ))
313  {
314  // DropCaps might come into this block
315  OSL_ENSURE( RES_PARATR_DROP == nWhich, "Modify was sent without sender" );
316  bContinue = false;
317  }
318  }
319  }
320 
321  if( bContinue )
322  {
323  // walk over all dependent formats
324  NotifyClients( pOldValue, pNewValue );
325  }
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::shared_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.get() && 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::shared_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::shared_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.get() && 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.get())
771  m_pGrabBagItem->QueryValue(rVal);
772  else
773  rVal <<= uno::Sequence<beans::PropertyValue>();
774 }
775 
777 {
778  if (!m_pGrabBagItem.get())
779  m_pGrabBagItem.reset(new SfxGrabBagItem);
780 
781  m_pGrabBagItem->PutValue(rVal, 0);
782 }
783 
784 std::shared_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::shared_ptr<SvxBrushItem>(static_cast<SvxBrushItem*>(m_aSet.GetBackground(bInP).Clone()));
798 }
799 
801 {
803 }
804 
805 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const SwAttrSet * GetChgSet() const
What has changed.
Definition: hints.hxx:239
sal_uInt16 m_nPoolFormatId
Id for "automatically" created formats.
Definition: format.hxx:51
void Add(SwClient *pDepend)
Definition: calbck.cxx:217
#define RES_GRFFMTCOLL
Definition: hintids.hxx:276
#define RES_FRMFMT
Definition: hintids.hxx:273
#define RES_CONDTXTFMTCOLL
Definition: hintids.hxx:278
sal_uInt16 m_nWhichId
Definition: format.hxx:50
bool IsDefault() const
Definition: format.hxx:109
bool IsInSwFntCache() const
Definition: calbck.hxx:223
#define RES_ATTRSET_CHG
Definition: hintids.hxx:285
const SvxBrushItem & GetBackground(bool=true) const
Definition: frmatr.hxx:58
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:43
OUString m_aFormatName
Definition: format.hxx:47
Handle the background jobs of a Writer document.
static SwCache & GetCache()
Definition: frame.hxx:500
std::shared_ptr< SvxBrushItem > getSvxBrushItemFromSourceSet(const SfxItemSet &rSourceSet, sal_uInt16 nBackgroundID, bool bSearchInParents, bool bXMLImportHack)
TElementType * Next()
Definition: calbck.hxx:376
void DelDiffs(const SfxItemSet &rSet)
Delete all attributes that are not in rFormat.
Definition: format.cxx:713
virtual ~SwFormat() override
Definition: format.cxx:216
void SetInCache(bool bNew)
Definition: calbck.hxx:218
SwAttrSet m_aSet
Definition: format.hxx:48
IDocumentChartDataProviderAccess & getIDocumentChartDataProviderAccess()
Gives access to the chart data-provider.
Definition: format.cxx:766
IDocumentTimerAccess & getIDocumentTimerAccess()
Provides access to the document idle timer interface.
Definition: format.cxx:764
bool HasWriterListeners() const
Definition: calbck.hxx:211
IDocumentDrawModelAccess const & getIDocumentDrawModelAccess() const
Definition: doc.cxx:187
void StartListeningToSameModifyAs(const SwClient &)
Definition: calbck.cxx:116
IDocumentFieldsAccess const & getIDocumentFieldsAccess() const
Definition: doc.cxx:389
bool Put_BC(const SfxPoolItem &rAttr, SwAttrSet *pOld, SwAttrSet *pNew)
Definition: swatrset.cxx:185
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
char sal_Char
virtual SfxPoolItem * Clone(SfxItemPool *pPool=nullptr) const override
const OUString & GetName() const
Definition: format.hxx:111
bool SetModifyAtAttr(const SwModify *pModify)
special treatment for some attributes
Definition: swatrset.cxx:255
std::shared_ptr< SdrAllFillAttributesHelper > SdrAllFillAttributesHelperPtr
Definition: format.hxx:38
#define RES_PARATR_NUMRULE
Definition: hintids.hxx:170
#define RES_TXTFMTCOLL
Definition: hintids.hxx:275
void Intersect(const SfxItemSet &rSet)
SwFormat & operator=(const SwFormat &)
Definition: format.cxx:105
sal_uInt8 m_nPoolHlpFileId
FilePos to Doc to these style helps.
Definition: format.hxx:54
SwAttrPool * GetPool() const
Definition: swatrset.hxx:190
bool SetDerivedFrom(SwFormat *pDerivedFrom=nullptr)
0 is Default.
Definition: format.cxx:328
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:154
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
SwFormat(SwAttrPool &rPool, const sal_Char *pFormatNm, const sal_uInt16 *pWhichRanges, SwFormat *pDrvdFrame, sal_uInt16 nFormatWhich)
Definition: format.cxx:41
#define RES_BACKGROUND
Definition: hintids.hxx:210
#define RES_FLYFRMFMT
Definition: hintids.hxx:274
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:293
sal_uInt16 Count() const
virtual void SetName(const OUString &rNewName, bool bBroadcast=false)
Definition: format.cxx:153
sal_uInt8 GetPoolHlpFileId() const
Definition: format.hxx:149
std::shared_ptr< SvxBrushItem > makeBackgroundBrushItem(bool=true) const
Definition: format.cxx:784
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:259
#define RES_FMT_CHG
Definition: hintids.hxx:284
int Intersect_BC(const SfxItemSet &rSet, SwAttrSet *pOld, SwAttrSet *pNew)
Definition: swatrset.cxx:228
IDocumentLayoutAccess const & getIDocumentLayoutAccess() const
Definition: doc.cxx:437
void SetGrabBagItem(const css::uno::Any &rVal)
Definition: format.cxx:776
SfxItemState GetBackgroundState(std::shared_ptr< SvxBrushItem > &rItem) const
Definition: format.cxx:432
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
sal_uInt16 Count() const
Definition: hints.hxx:245
bool IsModifyLocked() const
Definition: calbck.hxx:221
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:222
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:180
virtual drawinglayer::attribute::SdrAllFillAttributesHelperPtr getSdrAllFillAttributesHelper() const
Definition: format.cxx:800
const o3tl::enumarray< SvxAdjust, unsigned short > aSvxToUnoAdjust USHRT_MAX
Definition: unosett.cxx:261
#define SAL_INFO(area, stream)
void GetGrabBagItem(css::uno::Any &rVal) const
Definition: format.cxx:768
void Differentiate(const SfxItemSet &rSet)
virtual void Modify(const SfxPoolItem *pOld, const SfxPoolItem *pNewValue) override
Definition: format.cxx:246
bool m_bFormatInDTOR
TRUE: Format becomes deleted.
Definition: format.hxx:57
::sw::DocumentSettingManager & GetDocumentSettingManager()
Definition: doc.cxx:218
const SwModify * GetRegisteredIn() const
Definition: calbck.hxx:157
#define RES_NAME_CHANGED
Definition: hintids.hxx:310
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
#define RES_OBJECTDYING
Definition: hintids.hxx:283
const sal_uInt16 * GetRanges() const
Provides access to the layout of a document.
void CheckForUniqueItemForLineFillNameOrIndex(SfxItemSet &rSet)
Definition: docfly.cxx:491
#define SAL_WARN(area, stream)
bool m_bAutoFormat
FALSE: it is a template.
Definition: format.hxx:55
#define RES_PARATR_DROP
Definition: hintids.hxx:168
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:205
sal_uInt16 Which() const
void SetInSwFntCache(bool bNew)
Definition: calbck.hxx:219
IDocumentTimerAccess const & getIDocumentTimerAccess() const
Definition: doc.cxx:281
const IDocumentDrawModelAccess & getIDocumentDrawModelAccess() const
Provides access to the document draw model interface.
Definition: format.cxx:760
typedef void(CALLTYPE *GetFuncDataPtr)(sal_uInt16 &nNo