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 sal_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  {
220  m_bFormatInDTOR = true;
221 
222  SwFormat* pParentFormat = DerivedFrom();
223  if( !pParentFormat )
224  {
225  SAL_WARN(
226  "sw.core",
227  "~SwFormat: parent format missing from: " << GetName() );
228  }
229  else
230  {
231  SwFormatChg aOldFormat( this );
232  SwFormatChg aNewFormat( pParentFormat );
233  SwIterator<SwClient,SwFormat> aIter(*this);
234  for(SwClient* pClient = aIter.First(); pClient && pParentFormat; pClient = aIter.Next())
235  {
236  SAL_INFO("sw.core", "reparenting " << typeid(*pClient).name() << " at " << pClient << " from " << typeid(*this).name() << " at " << this << " to " << typeid(*pParentFormat).name() << " at " << pParentFormat);
237  pParentFormat->Add( pClient );
238  pClient->ModifyNotification( &aOldFormat, &aNewFormat );
239  }
240  }
241  }
242 }
243 
244 void SwFormat::Modify( const SfxPoolItem* pOldValue, const SfxPoolItem* pNewValue )
245 {
246  bool bContinue = true; // true = pass on to dependent ones
247 
248  sal_uInt16 nWhich = pOldValue ? pOldValue->Which() :
249  pNewValue ? pNewValue->Which() : 0 ;
250  switch( nWhich )
251  {
252  case 0: break; // Which-Id of 0?
253 
254  case RES_OBJECTDYING:
255  if (pNewValue)
256  {
257  // If the dying object is the parent format of this format so
258  // attach this to the parent of the parent
259  SwFormat* pFormat = static_cast<SwFormat*>(static_cast<const SwPtrMsgPoolItem*>(pNewValue)->pObject);
260 
261  // do not move if this is the topmost format
262  if( GetRegisteredIn() && GetRegisteredIn() == pFormat )
263  {
264  if( pFormat->GetRegisteredIn() )
265  {
266  // if parent so register in new parent
267  pFormat->DerivedFrom()->Add( this );
269  }
270  else
271  {
272  // otherwise de-register at least from dying one
273  EndListeningAll();
274  m_aSet.SetParent( nullptr );
275  }
276  }
277  }
278  break;
279  case RES_ATTRSET_CHG:
280  if (pOldValue && pNewValue && static_cast<const SwAttrSetChg*>(pOldValue)->GetTheChgdSet() != &m_aSet)
281  {
282  // pass only those that are not set
283  SwAttrSetChg aOld( *static_cast<const SwAttrSetChg*>(pOldValue) );
284  SwAttrSetChg aNew( *static_cast<const SwAttrSetChg*>(pNewValue) );
285 
286  aOld.GetChgSet()->Differentiate( m_aSet );
287  aNew.GetChgSet()->Differentiate( m_aSet );
288 
289  if( aNew.Count() )
290  NotifyClients( &aOld, &aNew );
291  bContinue = false;
292  }
293  break;
294  case RES_FMT_CHG:
295  // if the format parent will be moved so register my attribute set at
296  // the new one
297 
298  // skip my own Modify
299  if ( pOldValue && pNewValue &&
300  static_cast<const SwFormatChg*>(pOldValue)->pChangedFormat != this &&
301  static_cast<const SwFormatChg*>(pNewValue)->pChangedFormat == GetRegisteredIn() )
302  {
303  // attach Set to new parent
304  m_aSet.SetParent( DerivedFrom() ? &DerivedFrom()->m_aSet : nullptr );
305  }
306  break;
307  default:
308  {
309  // attribute is defined in this format
310  if( SfxItemState::SET == m_aSet.GetItemState( nWhich, false ))
311  {
312  // DropCaps might come into this block
313  OSL_ENSURE( RES_PARATR_DROP == nWhich, "Modify was sent without sender" );
314  bContinue = false;
315  }
316  }
317  }
318 
319  if( bContinue )
320  {
321  // walk over all dependent formats
322  NotifyClients( pOldValue, pNewValue );
323  }
324 }
325 
327 {
328  if ( pDerFrom )
329  {
330  const SwFormat* pFormat = pDerFrom;
331  while ( pFormat != nullptr )
332  {
333  if ( pFormat == this )
334  return false;
335 
336  pFormat=pFormat->DerivedFrom();
337  }
338  }
339  else
340  {
341  // nothing provided, search for Dflt format
342  pDerFrom = this;
343  while ( pDerFrom->DerivedFrom() )
344  pDerFrom = pDerFrom->DerivedFrom();
345  }
346  if ( (pDerFrom == DerivedFrom()) || (pDerFrom == this) )
347  return false;
348 
349  assert( Which()==pDerFrom->Which()
350  || (Which()==RES_CONDTXTFMTCOLL && pDerFrom->Which()==RES_TXTFMTCOLL)
351  || (Which()==RES_TXTFMTCOLL && pDerFrom->Which()==RES_CONDTXTFMTCOLL)
352  || (Which()==RES_FLYFRMFMT && pDerFrom->Which()==RES_FRMFMT)
353  );
354 
355  if ( IsInCache() )
356  {
357  SwFrame::GetCache().Delete( this );
358  SetInCache( false );
359  }
360  SetInSwFntCache( false );
361 
362  pDerFrom->Add( this );
363  m_aSet.SetParent( &pDerFrom->m_aSet );
364 
365  SwFormatChg aOldFormat( this );
366  SwFormatChg aNewFormat( this );
367  ModifyNotification( &aOldFormat, &aNewFormat );
368 
369  return true;
370 }
371 
373 {
374  return false;
375 }
376 
377 const SfxPoolItem& SwFormat::GetFormatAttr( sal_uInt16 nWhich, bool bInParents ) const
378 {
380  {
381  // FALLBACKBREAKHERE should not be used; instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST]
382  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)");
383  static std::shared_ptr<SvxBrushItem> aSvxBrushItem; //(std::make_shared<SvxBrushItem>(RES_BACKGROUND));
384 
385  // fill the local static SvxBrushItem from the current ItemSet so that
386  // the fill attributes [XATTR_FILL_FIRST .. XATTR_FILL_LAST] are used
387  // as good as possible to create a fallback representation and return that
388  aSvxBrushItem = getSvxBrushItemFromSourceSet(m_aSet, RES_BACKGROUND, bInParents);
389 
390  return *aSvxBrushItem;
391  }
392 
393  return m_aSet.Get( nWhich, bInParents );
394 }
395 
396 SfxItemState SwFormat::GetItemState( sal_uInt16 nWhich, bool bSrchInParent, const SfxPoolItem **ppItem ) const
397 {
399  {
400  // FALLBACKBREAKHERE should not be used; instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST]
401  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)");
403 
404  // check if the new fill attributes are used
405  if(aFill.get() && aFill->isUsed())
406  {
407  // if yes, fill the local SvxBrushItem using the new fill attributes
408  // as good as possible to have an instance for the pointer to point
409  // to and return as state that it is set
410  static std::shared_ptr<SvxBrushItem> aSvxBrushItem; //(RES_BACKGROUND);
411 
412  aSvxBrushItem = getSvxBrushItemFromSourceSet(m_aSet, RES_BACKGROUND, bSrchInParent);
413  if( ppItem )
414  *ppItem = aSvxBrushItem.get();
415 
416  return SfxItemState::SET;
417  }
418 
419  // if not, reset pointer and return SfxItemState::DEFAULT to signal that
420  // the item is not set
421  if( ppItem )
422  *ppItem = nullptr;
423 
424  return SfxItemState::DEFAULT;
425  }
426 
427  return m_aSet.GetItemState( nWhich, bSrchInParent, ppItem );
428 }
429 
430 SfxItemState SwFormat::GetBackgroundState(std::shared_ptr<SvxBrushItem>& rItem) const
431 {
433  {
434  // FALLBACKBREAKHERE should not be used; instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST]
436 
437  // check if the new fill attributes are used
438  if(aFill.get() && aFill->isUsed())
439  {
440  // if yes, fill the local SvxBrushItem using the new fill attributes
441  // as good as possible to have an instance for the pointer to point
442  // to and return as state that it is set
444  return SfxItemState::SET;
445  }
446 
447  // if not return SfxItemState::DEFAULT to signal that the item is not set
448  return SfxItemState::DEFAULT;
449  }
450 
451  const SfxPoolItem* pItem = nullptr;
452  SfxItemState eRet = m_aSet.GetItemState(RES_BACKGROUND, true, &pItem);
453  if (pItem)
454  rItem.reset(static_cast<SvxBrushItem*>(pItem->Clone()));
455  return eRet;
456 }
457 
459 {
460  if ( IsInCache() || IsInSwFntCache() )
461  {
462  const sal_uInt16 nWhich = rAttr.Which();
463  CheckCaching( nWhich );
464  }
465 
466  bool bRet = false;
467 
469  {
470  // FALLBACKBREAKHERE should not be used; instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST]
471  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)");
473  const SvxBrushItem& rSource = static_cast< const SvxBrushItem& >(rAttr);
474 
475  // fill a local ItemSet with the attributes corresponding as good as possible
476  // to the new fill properties [XATTR_FILL_FIRST .. XATTR_FILL_LAST] and set these
477  // as ItemSet
479 
480  if(IsModifyLocked())
481  {
482  bRet = m_aSet.Put( aTempSet );
483  if( bRet )
484  {
485  m_aSet.SetModifyAtAttr( this );
486  }
487  }
488  else
489  {
491 
492  bRet = m_aSet.Put_BC(aTempSet, &aOld, &aNew);
493 
494  if(bRet)
495  {
496  m_aSet.SetModifyAtAttr(this);
497 
498  SwAttrSetChg aChgOld(m_aSet, aOld);
499  SwAttrSetChg aChgNew(m_aSet, aNew);
500 
501  ModifyNotification(&aChgOld, &aChgNew);
502  }
503  }
504 
505  return bRet;
506  }
507 
508  // if Modify is locked then no modifications will be sent;
509  // but call Modify always for FrameFormats
510  const sal_uInt16 nFormatWhich = Which();
511  if( IsModifyLocked() ||
512  ( !HasWriterListeners() &&
513  (RES_GRFFMTCOLL == nFormatWhich ||
514  RES_TXTFMTCOLL == nFormatWhich ) ) )
515  {
516  bRet = nullptr != m_aSet.Put( rAttr );
517  if( bRet )
518  m_aSet.SetModifyAtAttr( this );
519  // #i71574#
520  if ( nFormatWhich == RES_TXTFMTCOLL && rAttr.Which() == RES_PARATR_NUMRULE )
521  {
523  }
524  }
525  else
526  {
527  // copy only array with attributes delta
528  SwAttrSet aOld( *m_aSet.GetPool(), m_aSet.GetRanges() ),
529  aNew( *m_aSet.GetPool(), m_aSet.GetRanges() );
530 
531  bRet = m_aSet.Put_BC( rAttr, &aOld, &aNew );
532  if( bRet )
533  {
534  // some special treatments for attributes
535  m_aSet.SetModifyAtAttr( this );
536 
537  SwAttrSetChg aChgOld( m_aSet, aOld );
538  SwAttrSetChg aChgNew( m_aSet, aNew );
539  ModifyNotification( &aChgOld, &aChgNew ); // send all modified ones
540  }
541  }
542  return bRet;
543 }
544 
546 {
547  if( !rSet.Count() )
548  return false;
549 
550  if ( IsInCache() )
551  {
552  SwFrame::GetCache().Delete( this );
553  SetInCache( false );
554  }
555  SetInSwFntCache( false );
556 
557  bool bRet = false;
558 
559  // Use local copy to be able to apply needed changes, e.g. call
560  // CheckForUniqueItemForLineFillNameOrIndex which is needed for NameOrIndex stuff
561  SfxItemSet aTempSet(rSet);
562 
563  // Need to check for unique item for DrawingLayer items of type NameOrIndex
564  // and evtl. correct that item to ensure unique names for that type. This call may
565  // modify/correct entries inside of the given SfxItemSet
566  if(GetDoc())
567  {
569  }
570 
572  {
573  const SfxPoolItem* pSource = nullptr;
574 
575  if(SfxItemState::SET == aTempSet.GetItemState(RES_BACKGROUND, false, &pSource))
576  {
577  // FALLBACKBREAKHERE should not be used; instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST]
578  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)");
579 
580  // copy all items to be set anyways to a local ItemSet with is also prepared for the new
581  // fill attribute ranges [XATTR_FILL_FIRST .. XATTR_FILL_LAST]. Add the attributes
582  // corresponding as good as possible to the new fill properties and set the whole ItemSet
583  const SvxBrushItem& rSource(static_cast< const SvxBrushItem& >(*pSource));
585 
586  if(IsModifyLocked())
587  {
588  bRet = m_aSet.Put( aTempSet );
589  if( bRet )
590  {
591  m_aSet.SetModifyAtAttr( this );
592  }
593  }
594  else
595  {
597 
598  bRet = m_aSet.Put_BC(aTempSet, &aOld, &aNew);
599 
600  if(bRet)
601  {
602  m_aSet.SetModifyAtAttr(this);
603 
604  SwAttrSetChg aChgOld(m_aSet, aOld);
605  SwAttrSetChg aChgNew(m_aSet, aNew);
606 
607  ModifyNotification(&aChgOld, &aChgNew);
608  }
609  }
610 
611  return bRet;
612  }
613  }
614 
615  // if Modify is locked then no modifications will be sent;
616  // but call Modify always for FrameFormats
617  const sal_uInt16 nFormatWhich = Which();
618  if ( IsModifyLocked() ||
619  ( !HasWriterListeners() &&
620  ( RES_GRFFMTCOLL == nFormatWhich ||
621  RES_TXTFMTCOLL == nFormatWhich ) ) )
622  {
623  bRet = m_aSet.Put( aTempSet );
624  if( bRet )
625  m_aSet.SetModifyAtAttr( this );
626  // #i71574#
627  if ( nFormatWhich == RES_TXTFMTCOLL )
628  {
630  }
631  }
632  else
633  {
634  SwAttrSet aOld( *m_aSet.GetPool(), m_aSet.GetRanges() ),
635  aNew( *m_aSet.GetPool(), m_aSet.GetRanges() );
636  bRet = m_aSet.Put_BC( aTempSet, &aOld, &aNew );
637  if( bRet )
638  {
639  // some special treatments for attributes
640  m_aSet.SetModifyAtAttr( this );
641  SwAttrSetChg aChgOld( m_aSet, aOld );
642  SwAttrSetChg aChgNew( m_aSet, aNew );
643  ModifyNotification( &aChgOld, &aChgNew ); // send all modified ones
644  }
645  }
646  return bRet;
647 }
648 
649 // remove Hint using nWhich from array with delta
650 bool SwFormat::ResetFormatAttr( sal_uInt16 nWhich1, sal_uInt16 nWhich2 )
651 {
652  if( !m_aSet.Count() )
653  return false;
654 
655  if( !nWhich2 || nWhich2 < nWhich1 )
656  nWhich2 = nWhich1; // then set to 1st ID, only this item
657 
658  if ( IsInCache() || IsInSwFntCache() )
659  {
660  for( sal_uInt16 n = nWhich1; n < nWhich2; ++n )
661  CheckCaching( n );
662  }
663 
664  // if Modify is locked then no modifications will be sent
665  if( IsModifyLocked() )
666  return 0 != (( nWhich2 == nWhich1 )
667  ? m_aSet.ClearItem( nWhich1 )
668  : m_aSet.ClearItem_BC( nWhich1, nWhich2 ));
669 
670  SwAttrSet aOld( *m_aSet.GetPool(), m_aSet.GetRanges() ),
671  aNew( *m_aSet.GetPool(), m_aSet.GetRanges() );
672  bool bRet = 0 != m_aSet.ClearItem_BC( nWhich1, nWhich2, &aOld, &aNew );
673  if( bRet )
674  {
675  SwAttrSetChg aChgOld( m_aSet, aOld );
676  SwAttrSetChg aChgNew( m_aSet, aNew );
677  ModifyNotification( &aChgOld, &aChgNew ); // send all modified ones
678  }
679  return bRet;
680 }
681 
682 // #i73790#
684 {
685  if( !m_aSet.Count() )
686  return 0;
687 
688  if ( IsInCache() )
689  {
690  SwFrame::GetCache().Delete( this );
691  SetInCache( false );
692  }
693  SetInSwFntCache( false );
694 
695  // if Modify is locked then no modifications will be sent
696  if( IsModifyLocked() )
697  return m_aSet.ClearItem();
698 
699  SwAttrSet aOld( *m_aSet.GetPool(), m_aSet.GetRanges() ),
700  aNew( *m_aSet.GetPool(), m_aSet.GetRanges() );
701  bool bRet = 0 != m_aSet.ClearItem_BC( 0, &aOld, &aNew );
702  if( bRet )
703  {
704  SwAttrSetChg aChgOld( m_aSet, aOld );
705  SwAttrSetChg aChgNew( m_aSet, aNew );
706  ModifyNotification( &aChgOld, &aChgNew ); // send all modified ones
707  }
708  return aNew.Count();
709 }
710 
711 void SwFormat::DelDiffs( const SfxItemSet& rSet )
712 {
713  if( !m_aSet.Count() )
714  return;
715 
716  if ( IsInCache() )
717  {
718  SwFrame::GetCache().Delete( this );
719  SetInCache( false );
720  }
721  SetInSwFntCache( false );
722 
723  // if Modify is locked then no modifications will be sent
724  if( IsModifyLocked() )
725  {
726  m_aSet.Intersect( rSet );
727  return;
728  }
729 
730  SwAttrSet aOld( *m_aSet.GetPool(), m_aSet.GetRanges() ),
731  aNew( *m_aSet.GetPool(), m_aSet.GetRanges() );
732  bool bRet = 0 != m_aSet.Intersect_BC( rSet, &aOld, &aNew );
733  if( bRet )
734  {
735  SwAttrSetChg aChgOld( m_aSet, aOld );
736  SwAttrSetChg aChgNew( m_aSet, aNew );
737  ModifyNotification( &aChgOld, &aChgNew ); // send all modified ones
738  }
739 }
740 
750 {
751  return false;
752 }
753 
754 /*
755  * Document Interface Access
756  */
765 
767 {
768  if (m_pGrabBagItem.get())
769  m_pGrabBagItem->QueryValue(rVal);
770  else
771  rVal <<= uno::Sequence<beans::PropertyValue>();
772 }
773 
775 {
776  if (!m_pGrabBagItem.get())
777  m_pGrabBagItem.reset(new SfxGrabBagItem);
778 
779  m_pGrabBagItem->PutValue(rVal, 0);
780 }
781 
782 std::shared_ptr<SvxBrushItem> SwFormat::makeBackgroundBrushItem(bool bInP) const
783 {
785  {
786  // FALLBACKBREAKHERE should not be used; instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST]
787  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)");
788 
789  // fill the local static SvxBrushItem from the current ItemSet so that
790  // the fill attributes [XATTR_FILL_FIRST .. XATTR_FILL_LAST] are used
791  // as good as possible to create a fallback representation and return that
793  }
794 
795  return std::shared_ptr<SvxBrushItem>(static_cast<SvxBrushItem*>(m_aSet.GetBackground(bInP).Clone()));
796 }
797 
799 {
801 }
802 
803 /* 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:711
virtual ~SwFormat() override
Definition: format.cxx:214
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:764
IDocumentTimerAccess & getIDocumentTimerAccess()
Provides access to the document idle timer interface.
Definition: format.cxx:762
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:178
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:248
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: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:326
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:683
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:763
SwFormat(SwAttrPool &rPool, const sal_Char *pFormatNm, const sal_uInt16 *pWhichRanges, SwFormat *pDrvdFrame, sal_uInt16 nFormatWhich)
Definition: format.cxx:39
#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:760
Document fields related interfaces.
TElementType * First()
Definition: calbck.hxx:345
void CopyToModify(SwModify &rMod) const
Definition: swatrset.cxx:286
sal_uInt16 Count() const
virtual void SetName(const OUString &rNewName, bool bBroadcast=false)
Definition: format.cxx:151
sal_uInt8 GetPoolHlpFileId() const
Definition: format.hxx:149
std::shared_ptr< SvxBrushItem > makeBackgroundBrushItem(bool=true) const
Definition: format.cxx:782
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:396
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:757
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:221
IDocumentLayoutAccess const & getIDocumentLayoutAccess() const
Definition: doc.cxx:437
void SetGrabBagItem(const css::uno::Any &rVal)
Definition: format.cxx:774
SfxItemState GetBackgroundState(std::shared_ptr< SvxBrushItem > &rItem) const
Definition: format.cxx:430
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:458
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:650
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:178
virtual drawinglayer::attribute::SdrAllFillAttributesHelperPtr getSdrAllFillAttributesHelper() const
Definition: format.cxx:798
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:766
void Differentiate(const SfxItemSet &rSet)
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: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:377
#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:749
virtual bool supportsFullDrawingLayerFillAttributeSet() const
Definition: format.cxx:372
sal_uInt16 ClearItem_BC(sal_uInt16 nWhich, SwAttrSet *pOld, SwAttrSet *pNew)
Definition: swatrset.cxx:198
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:758
typedef void(CALLTYPE *GetFuncDataPtr)(sal_uInt16 &nNo