Line data Source code
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 <svl/grabbagitem.hxx>
32 : #include <com/sun/star/beans/PropertyValues.hpp>
33 :
34 : //UUUU
35 : #include <svx/sdr/attribute/sdrallfillattributeshelper.hxx>
36 : #include <svx/unobrushitemhelper.hxx>
37 : #include <svx/xdef.hxx>
38 :
39 : using namespace com::sun::star;
40 :
41 2030894 : TYPEINIT1( SwFmt, SwClient );
42 :
43 39400 : SwFmt::SwFmt( SwAttrPool& rPool, const sal_Char* pFmtNm,
44 : const sal_uInt16* pWhichRanges, SwFmt *pDrvdFrm,
45 : sal_uInt16 nFmtWhich )
46 : : SwModify( pDrvdFrm ),
47 : aFmtName( OUString::createFromAscii(pFmtNm) ),
48 : aSet( rPool, pWhichRanges ),
49 : nWhichId( nFmtWhich ),
50 : nPoolFmtId( USHRT_MAX ),
51 : nPoolHelpId( USHRT_MAX ),
52 39400 : nPoolHlpFileId( UCHAR_MAX )
53 : {
54 39400 : bAutoUpdateFmt = false; // LAYER_IMPL
55 39400 : bAutoFmt = true;
56 39400 : bWritten = bFmtInDTOR = bHidden = false;
57 :
58 39400 : if( pDrvdFrm )
59 19192 : aSet.SetParent( &pDrvdFrm->aSet );
60 39400 : }
61 :
62 157524 : SwFmt::SwFmt( SwAttrPool& rPool, const OUString& rFmtNm,
63 : const sal_uInt16* pWhichRanges, SwFmt* pDrvdFrm,
64 : sal_uInt16 nFmtWhich )
65 : : SwModify( pDrvdFrm ),
66 : aFmtName( rFmtNm ),
67 : aSet( rPool, pWhichRanges ),
68 : nWhichId( nFmtWhich ),
69 : nPoolFmtId( USHRT_MAX ),
70 : nPoolHelpId( USHRT_MAX ),
71 157524 : nPoolHlpFileId( UCHAR_MAX )
72 : {
73 157524 : bAutoUpdateFmt = false; // LAYER_IMPL
74 157524 : bAutoFmt = true;
75 157524 : bWritten = bFmtInDTOR = bHidden = false;
76 :
77 157524 : if( pDrvdFrm )
78 157524 : aSet.SetParent( &pDrvdFrm->aSet );
79 157524 : }
80 :
81 44880 : SwFmt::SwFmt( const SwFmt& rFmt )
82 44880 : : SwModify( rFmt.DerivedFrom() ),
83 : aFmtName( rFmt.aFmtName ),
84 : aSet( rFmt.aSet ),
85 : nWhichId( rFmt.nWhichId ),
86 44880 : nPoolFmtId( rFmt.GetPoolFmtId() ),
87 44880 : nPoolHelpId( rFmt.GetPoolHelpId() ),
88 134640 : nPoolHlpFileId( rFmt.GetPoolHlpFileId() )
89 : {
90 44880 : bWritten = bFmtInDTOR = false; // LAYER_IMPL
91 44880 : bAutoFmt = rFmt.bAutoFmt;
92 44880 : bHidden = rFmt.bHidden;
93 44880 : bAutoUpdateFmt = rFmt.bAutoUpdateFmt;
94 :
95 44880 : if( rFmt.DerivedFrom() )
96 44880 : aSet.SetParent( &rFmt.DerivedFrom()->aSet );
97 : // a few special treatments for attributes
98 44880 : aSet.SetModifyAtAttr( this );
99 44880 : }
100 :
101 23498 : SwFmt &SwFmt::operator=(const SwFmt& rFmt)
102 : {
103 23498 : nWhichId = rFmt.nWhichId;
104 23498 : nPoolFmtId = rFmt.GetPoolFmtId();
105 23498 : nPoolHelpId = rFmt.GetPoolHelpId();
106 23498 : nPoolHlpFileId = rFmt.GetPoolHlpFileId();
107 :
108 23498 : if ( IsInCache() )
109 : {
110 0 : SwFrm::GetCache().Delete( this );
111 0 : SetInCache( false );
112 : }
113 23498 : SetInSwFntCache( false );
114 :
115 : // copy only array with attributes delta
116 23498 : SwAttrSet aOld( *aSet.GetPool(), aSet.GetRanges() ),
117 46996 : aNew( *aSet.GetPool(), aSet.GetRanges() );
118 23498 : aSet.Intersect_BC( rFmt.aSet, &aOld, &aNew );
119 23498 : (void)aSet.Put_BC( rFmt.aSet, &aOld, &aNew );
120 :
121 : // a few special treatments for attributes
122 23498 : aSet.SetModifyAtAttr( this );
123 :
124 : // create PoolItem attribute for Modify
125 23498 : if( aOld.Count() )
126 : {
127 21090 : SwAttrSetChg aChgOld( aSet, aOld );
128 42180 : SwAttrSetChg aChgNew( aSet, aNew );
129 42180 : ModifyNotification( &aChgOld, &aChgNew ); // send all modified ones
130 : }
131 :
132 23498 : if( GetRegisteredIn() != rFmt.GetRegisteredIn() )
133 : {
134 0 : if( GetRegisteredIn() )
135 0 : GetRegisteredInNonConst()->Remove(this);
136 0 : if( rFmt.GetRegisteredIn() )
137 : {
138 0 : const_cast<SwFmt&>(rFmt).GetRegisteredInNonConst()->Add(this);
139 0 : aSet.SetParent( &rFmt.aSet );
140 : }
141 : else
142 : {
143 0 : aSet.SetParent( 0 );
144 : }
145 : }
146 23498 : bAutoFmt = rFmt.bAutoFmt;
147 23498 : bHidden = rFmt.bHidden;
148 23498 : bAutoUpdateFmt = rFmt.bAutoUpdateFmt;
149 46996 : return *this;
150 : }
151 :
152 2938 : void SwFmt::SetName( const OUString& rNewName, bool bBroadcast )
153 : {
154 : OSL_ENSURE( !IsDefault(), "SetName: Defaultformat" );
155 2938 : if( bBroadcast )
156 : {
157 1934 : SwStringMsgPoolItem aOld( RES_NAME_CHANGED, aFmtName );
158 3868 : SwStringMsgPoolItem aNew( RES_NAME_CHANGED, rNewName );
159 1934 : aFmtName = rNewName;
160 3868 : ModifyNotification( &aOld, &aNew );
161 : }
162 : else
163 : {
164 1004 : aFmtName = rNewName;
165 : }
166 2938 : }
167 :
168 : /** Copy attributes
169 :
170 : This function is called in every Copy-Ctor for copying the attributes.
171 : The latter can be only copied as soon as the derived class exists since
172 : for setting them the Which() function is called and that has the default
173 : value of 0 in the base class and is then overridden by the derived class.
174 :
175 : If we copy over multiple documents then the new document has to be provided
176 : in which <this> is defined. Currently this is important for DropCaps
177 : because that contains data that needs to be copied deeply.
178 : */
179 10074 : void SwFmt::CopyAttrs( const SwFmt& rFmt, bool bReplace )
180 : {
181 : // copy only array with attributes delta
182 10074 : if ( IsInCache() )
183 : {
184 0 : SwFrm::GetCache().Delete( this );
185 0 : SetInCache( false );
186 : }
187 10074 : SetInSwFntCache( false );
188 :
189 : // special treatments for some attributes
190 10074 : SwAttrSet* pChgSet = (SwAttrSet*)&rFmt.aSet;
191 :
192 10074 : if( !bReplace ) // refresh only those that are not set?
193 : {
194 0 : if( pChgSet == (SwAttrSet*)&rFmt.aSet )
195 0 : pChgSet = new SwAttrSet( rFmt.aSet );
196 0 : pChgSet->Differentiate( aSet );
197 : }
198 :
199 : // copy only array with attributes delta
200 10074 : if( pChgSet->GetPool() != aSet.GetPool() )
201 162 : pChgSet->CopyToModify( *this );
202 : else
203 : {
204 9912 : SwAttrSet aOld( *aSet.GetPool(), aSet.GetRanges() ),
205 19824 : aNew( *aSet.GetPool(), aSet.GetRanges() );
206 :
207 9912 : if ( aSet.Put_BC( *pChgSet, &aOld, &aNew ) )
208 : {
209 : // a few special treatments for attributes
210 9912 : aSet.SetModifyAtAttr( this );
211 :
212 9912 : SwAttrSetChg aChgOld( aSet, aOld );
213 19824 : SwAttrSetChg aChgNew( aSet, aNew );
214 19824 : ModifyNotification( &aChgOld, &aChgNew ); // send all modified ones
215 9912 : }
216 : }
217 :
218 10074 : if( pChgSet != (SwAttrSet*)&rFmt.aSet ) // was a Set created?
219 0 : delete pChgSet;
220 10074 : }
221 :
222 483304 : SwFmt::~SwFmt()
223 : {
224 : // This happens at a ObjectDying message. Thus put all dependent
225 : // ones on DerivedFrom.
226 241652 : if( GetDepends() )
227 : {
228 : OSL_ENSURE( DerivedFrom(), "SwFmt::~SwFmt: Def dependents!" );
229 :
230 22618 : bFmtInDTOR = true;
231 :
232 22618 : SwFmt* pParentFmt = DerivedFrom();
233 22618 : if( !pParentFmt )
234 : {
235 : SAL_WARN(
236 : "sw.core",
237 : "~SwFmt: parent format missing from: " << GetName() );
238 : }
239 : else
240 : {
241 102405 : while( GetDepends() && pParentFmt)
242 : {
243 57263 : SwFmtChg aOldFmt( this );
244 114526 : SwFmtChg aNewFmt( pParentFmt );
245 57263 : SwClient* pDepend = (SwClient*)GetDepends();
246 57263 : pParentFmt->Add( pDepend );
247 57263 : pDepend->ModifyNotification( &aOldFmt, &aNewFmt );
248 57263 : }
249 : }
250 : }
251 241652 : }
252 :
253 1731454 : void SwFmt::Modify( const SfxPoolItem* pOldValue, const SfxPoolItem* pNewValue )
254 : {
255 1731454 : bool bContinue = true; // true = pass on to dependent ones
256 :
257 : sal_uInt16 nWhich = pOldValue ? pOldValue->Which() :
258 1731454 : pNewValue ? pNewValue->Which() : 0 ;
259 1731454 : switch( nWhich )
260 : {
261 0 : case 0: break; // Which-Id of 0?
262 :
263 : case RES_OBJECTDYING:
264 0 : if (pNewValue)
265 : {
266 : // If the dying object is the parent format of this format so
267 : // attach this to the parent of the parent
268 0 : SwFmt* pFmt = (SwFmt*) ((SwPtrMsgPoolItem*)pNewValue)->pObject;
269 :
270 : // do not move if this is the topmost format
271 0 : if( GetRegisteredIn() && GetRegisteredIn() == pFmt )
272 : {
273 0 : if( pFmt->GetRegisteredIn() )
274 : {
275 : // if parent so register in new parent
276 0 : pFmt->DerivedFrom()->Add( this );
277 0 : aSet.SetParent( &DerivedFrom()->aSet );
278 : }
279 : else
280 : {
281 : // otherwise de-register at least from dying one
282 0 : DerivedFrom()->Remove( this );
283 0 : aSet.SetParent( 0 );
284 : }
285 : }
286 : }
287 0 : break;
288 : case RES_ATTRSET_CHG:
289 1618389 : if (pOldValue && pNewValue && ((SwAttrSetChg*)pOldValue)->GetTheChgdSet() != &aSet)
290 : {
291 : // pass only those that are not set
292 810669 : SwAttrSetChg aOld( *(SwAttrSetChg*)pOldValue );
293 1621338 : SwAttrSetChg aNew( *(SwAttrSetChg*)pNewValue );
294 :
295 810669 : aOld.GetChgSet()->Differentiate( aSet );
296 810669 : aNew.GetChgSet()->Differentiate( aSet );
297 :
298 810669 : if( aNew.Count() )
299 789013 : NotifyClients( &aOld, &aNew );
300 1621338 : bContinue = false;
301 : }
302 1618389 : break;
303 : case RES_FMT_CHG:
304 : // if the format parent will be moved so register my attribute set at
305 : // the new one
306 :
307 : // skip my own Modify
308 324069 : if ( pOldValue && pNewValue &&
309 278251 : ((SwFmtChg*)pOldValue)->pChangedFmt != this &&
310 62205 : ((SwFmtChg*)pNewValue)->pChangedFmt == GetRegisteredIn() )
311 : {
312 : // attach Set to new parent
313 24245 : aSet.SetParent( DerivedFrom() ? &DerivedFrom()->aSet : 0 );
314 : }
315 108023 : break;
316 : case RES_RESET_FMTWRITTEN:
317 : {
318 0 : ResetWritten();
319 :
320 : // mba: here we don't use the additional stuff from NotifyClients().
321 : // should we?!
322 : // mba: move the code that ignores this event to the clients
323 :
324 : // pass Hint only to dependent formats (no Frames)
325 0 : ModifyBroadcast( pOldValue, pNewValue, TYPE(SwFmt) );
326 0 : bContinue = false;
327 : }
328 0 : break;
329 : default:
330 : {
331 : // attribute is defined in this format
332 5042 : if( SfxItemState::SET == aSet.GetItemState( nWhich, false ))
333 : {
334 : // DropCaps might come into this block
335 : OSL_ENSURE( RES_PARATR_DROP == nWhich, "Modify was sent without sender" );
336 0 : bContinue = false;
337 : }
338 : }
339 : }
340 :
341 1731454 : if( bContinue )
342 : {
343 : // walk over all dependent formats
344 920785 : NotifyClients( pOldValue, pNewValue );
345 : }
346 1731454 : }
347 :
348 42432 : bool SwFmt::SetDerivedFrom(SwFmt *pDerFrom)
349 : {
350 42432 : if ( pDerFrom )
351 : {
352 39072 : const SwFmt* pFmt = pDerFrom;
353 166118 : while ( pFmt != 0 )
354 : {
355 87974 : if ( pFmt == this )
356 0 : return false;
357 :
358 87974 : pFmt=pFmt->DerivedFrom();
359 : }
360 : }
361 : else
362 : {
363 : // nothing provided, search for Dflt format
364 3360 : pDerFrom = this;
365 13164 : while ( pDerFrom->DerivedFrom() )
366 6444 : pDerFrom = pDerFrom->DerivedFrom();
367 : }
368 42432 : if ( (pDerFrom == DerivedFrom()) || (pDerFrom == this) )
369 1350 : return false;
370 :
371 : OSL_ENSURE( Which()==pDerFrom->Which()
372 : || ( Which()==RES_CONDTXTFMTCOLL && pDerFrom->Which()==RES_TXTFMTCOLL)
373 : || ( Which()==RES_TXTFMTCOLL && pDerFrom->Which()==RES_CONDTXTFMTCOLL)
374 : || ( Which()==RES_FLYFRMFMT && pDerFrom->Which()==RES_FRMFMT ),
375 : "SetDerivedFrom: derive apples from oranges?");
376 :
377 41082 : if ( IsInCache() )
378 : {
379 6 : SwFrm::GetCache().Delete( this );
380 6 : SetInCache( false );
381 : }
382 41082 : SetInSwFntCache( false );
383 :
384 41082 : pDerFrom->Add( this );
385 41082 : aSet.SetParent( &pDerFrom->aSet );
386 :
387 41082 : SwFmtChg aOldFmt( this );
388 82164 : SwFmtChg aNewFmt( this );
389 41082 : ModifyNotification( &aOldFmt, &aNewFmt );
390 :
391 82164 : return true;
392 : }
393 :
394 320804 : bool SwFmt::supportsFullDrawingLayerFillAttributeSet() const
395 : {
396 320804 : return false;
397 : }
398 :
399 172628 : const SfxPoolItem& SwFmt::GetFmtAttr( sal_uInt16 nWhich, bool bInParents ) const
400 : {
401 172628 : if (RES_BACKGROUND == nWhich && supportsFullDrawingLayerFillAttributeSet())
402 : {
403 : //UUUU FALLBACKBREAKHERE should not be used; instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST]
404 : 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)");
405 50 : static SvxBrushItem aSvxBrushItem(RES_BACKGROUND);
406 :
407 : // fill the local static SvxBrushItem from the current ItemSet so that
408 : // the fill attributes [XATTR_FILL_FIRST .. XATTR_FILL_LAST] are used
409 : // as good as possible to create a fallback representation and return that
410 50 : aSvxBrushItem = getSvxBrushItemFromSourceSet(aSet, RES_BACKGROUND, bInParents);
411 :
412 50 : return aSvxBrushItem;
413 : }
414 :
415 172578 : return aSet.Get( nWhich, bInParents );
416 : }
417 :
418 3109092 : SfxItemState SwFmt::GetItemState( sal_uInt16 nWhich, bool bSrchInParent, const SfxPoolItem **ppItem ) const
419 : {
420 3109092 : if (RES_BACKGROUND == nWhich && supportsFullDrawingLayerFillAttributeSet())
421 : {
422 : //UUUU FALLBACKBREAKHERE should not be used; instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST]
423 : SAL_INFO("sw.core", "Do no longer use SvxBrushItem, instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST] FillAttributes or SwFmt::GetBackgroundStat (simple fallback is in place and used)");
424 1252 : const drawinglayer::attribute::SdrAllFillAttributesHelperPtr aFill = getSdrAllFillAttributesHelper();
425 :
426 : // check if the new fill attributes are used
427 1252 : if(aFill.get() && aFill->isUsed())
428 : {
429 : // if yes, fill the local SvxBrushItem using the new fill attributes
430 : // as good as possible to have an instance for the pointer to point
431 : // to and return as state that it is set
432 :
433 14 : static SvxBrushItem aSvxBrushItem(RES_BACKGROUND);
434 :
435 14 : aSvxBrushItem = getSvxBrushItemFromSourceSet(aSet, RES_BACKGROUND, bSrchInParent);
436 14 : if( ppItem )
437 10 : *ppItem = &aSvxBrushItem;
438 :
439 14 : return SfxItemState::SET;
440 : }
441 :
442 : // if not, reset pointer and return SfxItemState::DEFAULT to signal that
443 : // the item is not set
444 1238 : if( ppItem )
445 1208 : *ppItem = NULL;
446 :
447 1238 : return SfxItemState::DEFAULT;
448 : }
449 :
450 3107840 : return aSet.GetItemState( nWhich, bSrchInParent, ppItem );
451 : }
452 :
453 1720 : SfxItemState SwFmt::GetBackgroundState(SvxBrushItem &rItem, bool bSrchInParent) const
454 : {
455 1720 : if (supportsFullDrawingLayerFillAttributeSet())
456 : {
457 : //UUUU FALLBACKBREAKHERE should not be used; instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST]
458 1720 : const drawinglayer::attribute::SdrAllFillAttributesHelperPtr aFill = getSdrAllFillAttributesHelper();
459 :
460 : // check if the new fill attributes are used
461 1720 : if(aFill.get() && aFill->isUsed())
462 : {
463 : // if yes, fill the local SvxBrushItem using the new fill attributes
464 : // as good as possible to have an instance for the pointer to point
465 : // to and return as state that it is set
466 28 : rItem = getSvxBrushItemFromSourceSet(aSet, RES_BACKGROUND, bSrchInParent);
467 28 : return SfxItemState::SET;
468 : }
469 :
470 : // if not return SfxItemState::DEFAULT to signal that the item is not set
471 1692 : return SfxItemState::DEFAULT;
472 : }
473 :
474 0 : const SfxPoolItem* pItem = 0;
475 0 : SfxItemState eRet = aSet.GetItemState(RES_BACKGROUND, bSrchInParent, &pItem);
476 0 : if (pItem)
477 0 : rItem = *(const SvxBrushItem*)pItem;
478 0 : return eRet;
479 : }
480 :
481 904004 : bool SwFmt::SetFmtAttr( const SfxPoolItem& rAttr )
482 : {
483 904004 : if ( IsInCache() || IsInSwFntCache() )
484 : {
485 4688 : const sal_uInt16 nWhich = rAttr.Which();
486 4688 : CheckCaching( nWhich );
487 : }
488 :
489 904004 : bool bRet = false;
490 :
491 : //UUUU
492 904004 : if (RES_BACKGROUND == rAttr.Which() && supportsFullDrawingLayerFillAttributeSet())
493 : {
494 : //UUUU FALLBACKBREAKHERE should not be used; instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST]
495 : 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)");
496 36 : SfxItemSet aTempSet(*aSet.GetPool(), XATTR_FILL_FIRST, XATTR_FILL_LAST, 0, 0);
497 36 : const SvxBrushItem& rSource = static_cast< const SvxBrushItem& >(rAttr);
498 :
499 : // fill a local ItemSet with the attributes corresponding as good as possible
500 : // to the new fill properties [XATTR_FILL_FIRST .. XATTR_FILL_LAST] and set these
501 : // as ItemSet
502 36 : setSvxBrushItemAsFillAttributesToTargetSet(rSource, aTempSet);
503 :
504 36 : if(IsModifyLocked())
505 : {
506 0 : if( ( bRet = aSet.Put( aTempSet ) ) )
507 : {
508 0 : aSet.SetModifyAtAttr( this );
509 : }
510 : }
511 : else
512 : {
513 72 : SwAttrSet aOld(*aSet.GetPool(), aSet.GetRanges()), aNew(*aSet.GetPool(), aSet.GetRanges());
514 :
515 36 : bRet = aSet.Put_BC(aTempSet, &aOld, &aNew);
516 :
517 36 : if(bRet)
518 : {
519 36 : aSet.SetModifyAtAttr(this);
520 :
521 36 : SwAttrSetChg aChgOld(aSet, aOld);
522 72 : SwAttrSetChg aChgNew(aSet, aNew);
523 :
524 72 : ModifyNotification(&aChgOld, &aChgNew);
525 36 : }
526 : }
527 :
528 36 : return bRet;
529 : }
530 :
531 : // if Modify is locked then no modifications will be sent;
532 : // but call Modify always for FrmFmts
533 903968 : const sal_uInt16 nFmtWhich = Which();
534 1878996 : if( IsModifyLocked() ||
535 1706498 : ( !GetDepends() &&
536 821406 : (RES_GRFFMTCOLL == nFmtWhich ||
537 : RES_TXTFMTCOLL == nFmtWhich ) ) )
538 : {
539 89936 : if( ( bRet = (0 != aSet.Put( rAttr ))) )
540 86996 : aSet.SetModifyAtAttr( this );
541 : // #i71574#
542 89936 : if ( nFmtWhich == RES_TXTFMTCOLL && rAttr.Which() == RES_PARATR_NUMRULE )
543 : {
544 912 : TxtFmtCollFunc::CheckTxtFmtCollForDeletionOfAssignmentToOutlineStyle( this );
545 : }
546 : }
547 : else
548 : {
549 : // copy only array with attributes delta
550 814032 : SwAttrSet aOld( *aSet.GetPool(), aSet.GetRanges() ),
551 1628064 : aNew( *aSet.GetPool(), aSet.GetRanges() );
552 :
553 814032 : bRet = aSet.Put_BC( rAttr, &aOld, &aNew );
554 814032 : if( bRet )
555 : {
556 : // some special treatments for attributes
557 441908 : aSet.SetModifyAtAttr( this );
558 :
559 441908 : SwAttrSetChg aChgOld( aSet, aOld );
560 883816 : SwAttrSetChg aChgNew( aSet, aNew );
561 883816 : ModifyNotification( &aChgOld, &aChgNew ); // send all modified ones
562 814032 : }
563 : }
564 903968 : return bRet;
565 : }
566 :
567 645520 : bool SwFmt::SetFmtAttr( const SfxItemSet& rSet )
568 : {
569 645520 : if( !rSet.Count() )
570 116 : return false;
571 :
572 645404 : if ( IsInCache() )
573 : {
574 198 : SwFrm::GetCache().Delete( this );
575 198 : SetInCache( false );
576 : }
577 645404 : SetInSwFntCache( false );
578 :
579 645404 : bool bRet = false;
580 :
581 : //UUUU Use local copy to be able to apply needed changes, e.g. call
582 : // CheckForUniqueItemForLineFillNameOrIndex which is needed for NameOrIndex stuff
583 645404 : SfxItemSet aTempSet(rSet);
584 :
585 : //UUUU Need to check for unique item for DrawingLayer items of type NameOrIndex
586 : // and evtl. correct that item to ensure unique names for that type. This call may
587 : // modify/correct entries inside of the given SfxItemSet
588 645404 : if(GetDoc())
589 : {
590 645404 : GetDoc()->CheckForUniqueItemForLineFillNameOrIndex(aTempSet);
591 : }
592 :
593 645404 : if (supportsFullDrawingLayerFillAttributeSet())
594 : {
595 158244 : const SfxPoolItem* pSource = 0;
596 :
597 158244 : if(SfxItemState::SET == aTempSet.GetItemState(RES_BACKGROUND, false, &pSource))
598 : {
599 : //UUUU FALLBACKBREAKHERE should not be used; instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST]
600 : 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)");
601 :
602 : // copy all items to be set anyways to a local ItemSet with is also prepared for the new
603 : // fill attribute ranges [XATTR_FILL_FIRST .. XATTR_FILL_LAST]. Add the attributes
604 : // corresponding as good as possible to the new fill properties and set the whole ItemSet
605 198 : const SvxBrushItem& rSource(static_cast< const SvxBrushItem& >(*pSource));
606 198 : setSvxBrushItemAsFillAttributesToTargetSet(rSource, aTempSet);
607 :
608 198 : if(IsModifyLocked())
609 : {
610 0 : if( ( bRet = aSet.Put( aTempSet ) ) )
611 : {
612 0 : aSet.SetModifyAtAttr( this );
613 : }
614 : }
615 : else
616 : {
617 396 : SwAttrSet aOld(*aSet.GetPool(), aSet.GetRanges()), aNew(*aSet.GetPool(), aSet.GetRanges());
618 :
619 198 : bRet = aSet.Put_BC(aTempSet, &aOld, &aNew);
620 :
621 198 : if(bRet)
622 : {
623 198 : aSet.SetModifyAtAttr(this);
624 :
625 198 : SwAttrSetChg aChgOld(aSet, aOld);
626 396 : SwAttrSetChg aChgNew(aSet, aNew);
627 :
628 396 : ModifyNotification(&aChgOld, &aChgNew);
629 198 : }
630 : }
631 :
632 198 : return bRet;
633 : }
634 : }
635 :
636 : // if Modify is locked then no modifications will be sent;
637 : // but call Modify always for FrmFmts
638 645206 : const sal_uInt16 nFmtWhich = Which();
639 1492446 : if ( IsModifyLocked() ||
640 1038616 : ( !GetDepends() &&
641 393888 : ( RES_GRFFMTCOLL == nFmtWhich ||
642 : RES_TXTFMTCOLL == nFmtWhich ) ) )
643 : {
644 202512 : if( ( bRet = aSet.Put( aTempSet )) )
645 139784 : aSet.SetModifyAtAttr( this );
646 : // #i71574#
647 202512 : if ( nFmtWhich == RES_TXTFMTCOLL )
648 : {
649 202034 : TxtFmtCollFunc::CheckTxtFmtCollForDeletionOfAssignmentToOutlineStyle( this );
650 : }
651 : }
652 : else
653 : {
654 442694 : SwAttrSet aOld( *aSet.GetPool(), aSet.GetRanges() ),
655 885388 : aNew( *aSet.GetPool(), aSet.GetRanges() );
656 442694 : bRet = aSet.Put_BC( aTempSet, &aOld, &aNew );
657 442694 : if( bRet )
658 : {
659 : // some special treatments for attributes
660 275864 : aSet.SetModifyAtAttr( this );
661 275864 : SwAttrSetChg aChgOld( aSet, aOld );
662 551728 : SwAttrSetChg aChgNew( aSet, aNew );
663 551728 : ModifyNotification( &aChgOld, &aChgNew ); // send all modified ones
664 442694 : }
665 : }
666 645206 : return bRet;
667 : }
668 :
669 : // remove Hint using nWhich from array with delta
670 2205934 : bool SwFmt::ResetFmtAttr( sal_uInt16 nWhich1, sal_uInt16 nWhich2 )
671 : {
672 2205934 : if( !aSet.Count() )
673 87068 : return false;
674 :
675 2118866 : if( !nWhich2 || nWhich2 < nWhich1 )
676 2102374 : nWhich2 = nWhich1; // then set to 1st ID, only this item
677 :
678 2118866 : if ( IsInCache() || IsInSwFntCache() )
679 : {
680 882 : for( sal_uInt16 n = nWhich1; n < nWhich2; ++n )
681 80 : CheckCaching( n );
682 : }
683 :
684 : // if Modify is locked then no modifications will be sent
685 2118866 : if( IsModifyLocked() )
686 35208 : return 0 != (( nWhich2 == nWhich1 )
687 1258 : ? aSet.ClearItem( nWhich1 )
688 33950 : : aSet.ClearItem_BC( nWhich1, nWhich2 ));
689 :
690 2101262 : SwAttrSet aOld( *aSet.GetPool(), aSet.GetRanges() ),
691 4202524 : aNew( *aSet.GetPool(), aSet.GetRanges() );
692 2101262 : bool bRet = 0 != aSet.ClearItem_BC( nWhich1, nWhich2, &aOld, &aNew );
693 2101262 : if( bRet )
694 : {
695 30756 : SwAttrSetChg aChgOld( aSet, aOld );
696 61512 : SwAttrSetChg aChgNew( aSet, aNew );
697 61512 : ModifyNotification( &aChgOld, &aChgNew ); // send all modified ones
698 : }
699 4202524 : return bRet;
700 : }
701 :
702 : // #i73790#
703 7478 : sal_uInt16 SwFmt::ResetAllFmtAttr()
704 : {
705 7478 : if( !aSet.Count() )
706 2644 : return 0;
707 :
708 4834 : if ( IsInCache() )
709 : {
710 30 : SwFrm::GetCache().Delete( this );
711 30 : SetInCache( false );
712 : }
713 4834 : SetInSwFntCache( false );
714 :
715 : // if Modify is locked then no modifications will be sent
716 4834 : if( IsModifyLocked() )
717 0 : return aSet.ClearItem( 0 );
718 :
719 4834 : SwAttrSet aOld( *aSet.GetPool(), aSet.GetRanges() ),
720 9668 : aNew( *aSet.GetPool(), aSet.GetRanges() );
721 4834 : bool bRet = 0 != aSet.ClearItem_BC( 0, &aOld, &aNew );
722 4834 : if( bRet )
723 : {
724 4834 : SwAttrSetChg aChgOld( aSet, aOld );
725 9668 : SwAttrSetChg aChgNew( aSet, aNew );
726 9668 : ModifyNotification( &aChgOld, &aChgNew ); // send all modified ones
727 : }
728 9668 : return aNew.Count();
729 : }
730 :
731 231804 : bool SwFmt::GetInfo( SfxPoolItem& rInfo ) const
732 : {
733 231804 : return SwModify::GetInfo( rInfo );
734 : }
735 :
736 42894 : void SwFmt::DelDiffs( const SfxItemSet& rSet )
737 : {
738 42894 : if( !aSet.Count() )
739 680 : return;
740 :
741 42554 : if ( IsInCache() )
742 : {
743 4 : SwFrm::GetCache().Delete( this );
744 4 : SetInCache( false );
745 : }
746 42554 : SetInSwFntCache( false );
747 :
748 : // if Modify is locked then no modifications will be sent
749 42554 : if( IsModifyLocked() )
750 : {
751 0 : aSet.Intersect( rSet );
752 0 : return;
753 : }
754 :
755 42554 : SwAttrSet aOld( *aSet.GetPool(), aSet.GetRanges() ),
756 85108 : aNew( *aSet.GetPool(), aSet.GetRanges() );
757 42554 : bool bRet = 0 != aSet.Intersect_BC( rSet, &aOld, &aNew );
758 42554 : if( bRet )
759 : {
760 24570 : SwAttrSetChg aChgOld( aSet, aOld );
761 49140 : SwAttrSetChg aChgNew( aSet, aNew );
762 49140 : ModifyNotification( &aChgOld, &aChgNew ); // send all modified ones
763 42554 : }
764 : }
765 :
766 : /** SwFmt::IsBackgroundTransparent
767 :
768 : Virtual method to determine, if background of format is transparent.
769 : Default implementation returns false. Thus, subclasses have to overload
770 : method, if the specific subclass can have a transparent background.
771 :
772 : @return false, default implementation
773 : */
774 0 : bool SwFmt::IsBackgroundTransparent() const
775 : {
776 0 : return false;
777 : }
778 :
779 : /** SwFmt::IsShadowTransparent
780 :
781 : Virtual method to determine, if shadow of format is transparent.
782 : Default implementation returns false. Thus, subclasses have to overload
783 : method, if the specific subclass can have a transparent shadow.
784 :
785 : @return false, default implementation
786 : */
787 429 : bool SwFmt::IsShadowTransparent() const
788 : {
789 429 : return false;
790 : }
791 :
792 : /*
793 : * Document Interface Access
794 : */
795 1522618 : const IDocumentSettingAccess* SwFmt::getIDocumentSettingAccess() const { return & GetDoc()->GetDocumentSettingManager(); }
796 26732 : const IDocumentDrawModelAccess* SwFmt::getIDocumentDrawModelAccess() const { return & GetDoc()->getIDocumentDrawModelAccess(); }
797 330706 : IDocumentDrawModelAccess* SwFmt::getIDocumentDrawModelAccess() { return & GetDoc()->getIDocumentDrawModelAccess(); }
798 470 : const IDocumentLayoutAccess* SwFmt::getIDocumentLayoutAccess() const { return &GetDoc()->getIDocumentLayoutAccess(); }
799 83960 : IDocumentLayoutAccess* SwFmt::getIDocumentLayoutAccess() { return &GetDoc()->getIDocumentLayoutAccess(); }
800 9446 : IDocumentTimerAccess* SwFmt::getIDocumentTimerAccess() { return & GetDoc()->getIDocumentTimerAccess(); }
801 5266 : IDocumentFieldsAccess* SwFmt::getIDocumentFieldsAccess() { return &GetDoc()->getIDocumentFieldsAccess(); }
802 0 : IDocumentChartDataProviderAccess* SwFmt::getIDocumentChartDataProviderAccess() { return & GetDoc()->getIDocumentChartDataProviderAccess(); }
803 :
804 18930 : void SwFmt::GetGrabBagItem(uno::Any& rVal) const
805 : {
806 18930 : if (m_pGrabBagItem.get())
807 13464 : m_pGrabBagItem->QueryValue(rVal);
808 : else
809 : {
810 5466 : uno::Sequence<beans::PropertyValue> aValue(0);
811 5466 : rVal = uno::makeAny(aValue);
812 : }
813 18930 : }
814 :
815 48564 : void SwFmt::SetGrabBagItem(const uno::Any& rVal)
816 : {
817 48564 : if (!m_pGrabBagItem.get())
818 48514 : m_pGrabBagItem.reset(new SfxGrabBagItem);
819 :
820 48564 : m_pGrabBagItem->PutValue(rVal);
821 48564 : }
822 :
823 : //UUUU
824 60396 : SvxBrushItem SwFmt::makeBackgroundBrushItem(bool bInP) const
825 : {
826 60396 : if (supportsFullDrawingLayerFillAttributeSet())
827 : {
828 : //UUUU FALLBACKBREAKHERE should not be used; instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST]
829 : 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)");
830 :
831 : // fill the local static SvxBrushItem from the current ItemSet so that
832 : // the fill attributes [XATTR_FILL_FIRST .. XATTR_FILL_LAST] are used
833 : // as good as possible to create a fallback representation and return that
834 5834 : return getSvxBrushItemFromSourceSet(aSet, RES_BACKGROUND, bInP);
835 : }
836 :
837 54562 : return aSet.GetBackground(bInP);
838 : }
839 :
840 : //UUUU
841 0 : drawinglayer::attribute::SdrAllFillAttributesHelperPtr SwFmt::getSdrAllFillAttributesHelper() const
842 : {
843 0 : return drawinglayer::attribute::SdrAllFillAttributesHelperPtr();
844 270 : }
845 :
846 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|