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 <fmtcolfunc.hxx>
22 : #include <frame.hxx>
23 : #include <format.hxx>
24 : #include <hintids.hxx>
25 : #include <hints.hxx>
26 : #include <paratr.hxx>
27 : #include <swcache.hxx>
28 : #include <svl/grabbagitem.hxx>
29 : #include <com/sun/star/beans/PropertyValues.hpp>
30 : //UUUU
31 : #include <unobrushitemhelper.hxx>
32 : #include <svx/xdef.hxx>
33 :
34 : using namespace com::sun::star;
35 :
36 692520 : TYPEINIT1( SwFmt, SwClient );
37 :
38 13896 : SwFmt::SwFmt( SwAttrPool& rPool, const sal_Char* pFmtNm,
39 : const sal_uInt16* pWhichRanges, SwFmt *pDrvdFrm,
40 : sal_uInt16 nFmtWhich )
41 : : SwModify( pDrvdFrm ),
42 : aFmtName( OUString::createFromAscii(pFmtNm) ),
43 : aSet( rPool, pWhichRanges ),
44 : nWhichId( nFmtWhich ),
45 : nPoolFmtId( USHRT_MAX ),
46 : nPoolHelpId( USHRT_MAX ),
47 13896 : nPoolHlpFileId( UCHAR_MAX )
48 : {
49 13896 : bAutoUpdateFmt = sal_False; // LAYER_IMPL
50 13896 : bAutoFmt = true;
51 13896 : bWritten = bFmtInDTOR = bHidden = false;
52 :
53 13896 : if( pDrvdFrm )
54 6488 : aSet.SetParent( &pDrvdFrm->aSet );
55 13896 : }
56 :
57 52168 : SwFmt::SwFmt( SwAttrPool& rPool, const OUString& rFmtNm,
58 : const sal_uInt16* pWhichRanges, SwFmt* pDrvdFrm,
59 : sal_uInt16 nFmtWhich )
60 : : SwModify( pDrvdFrm ),
61 : aFmtName( rFmtNm ),
62 : aSet( rPool, pWhichRanges ),
63 : nWhichId( nFmtWhich ),
64 : nPoolFmtId( USHRT_MAX ),
65 : nPoolHelpId( USHRT_MAX ),
66 52168 : nPoolHlpFileId( UCHAR_MAX )
67 : {
68 52168 : bAutoUpdateFmt = sal_False; // LAYER_IMPL
69 52168 : bAutoFmt = true;
70 52168 : bWritten = bFmtInDTOR = bHidden = false;
71 :
72 52168 : if( pDrvdFrm )
73 52168 : aSet.SetParent( &pDrvdFrm->aSet );
74 52168 : }
75 :
76 13728 : SwFmt::SwFmt( const SwFmt& rFmt )
77 13728 : : SwModify( rFmt.DerivedFrom() ),
78 : aFmtName( rFmt.aFmtName ),
79 : aSet( rFmt.aSet ),
80 : nWhichId( rFmt.nWhichId ),
81 13728 : nPoolFmtId( rFmt.GetPoolFmtId() ),
82 13728 : nPoolHelpId( rFmt.GetPoolHelpId() ),
83 41184 : nPoolHlpFileId( rFmt.GetPoolHlpFileId() )
84 : {
85 13728 : bWritten = bFmtInDTOR = false; // LAYER_IMPL
86 13728 : bAutoFmt = rFmt.bAutoFmt;
87 13728 : bHidden = rFmt.bHidden;
88 13728 : bAutoUpdateFmt = rFmt.bAutoUpdateFmt;
89 :
90 13728 : if( rFmt.DerivedFrom() )
91 13728 : aSet.SetParent( &rFmt.DerivedFrom()->aSet );
92 : // a few special treatments for attributes
93 13728 : aSet.SetModifyAtAttr( this );
94 13728 : }
95 :
96 10057 : SwFmt &SwFmt::operator=(const SwFmt& rFmt)
97 : {
98 10057 : nWhichId = rFmt.nWhichId;
99 10057 : nPoolFmtId = rFmt.GetPoolFmtId();
100 10057 : nPoolHelpId = rFmt.GetPoolHelpId();
101 10057 : nPoolHlpFileId = rFmt.GetPoolHlpFileId();
102 :
103 10057 : if ( IsInCache() )
104 : {
105 0 : SwFrm::GetCache().Delete( this );
106 0 : SetInCache( sal_False );
107 : }
108 10057 : SetInSwFntCache( sal_False );
109 :
110 : // copy only array with attributes delta
111 10057 : SwAttrSet aOld( *aSet.GetPool(), aSet.GetRanges() ),
112 20114 : aNew( *aSet.GetPool(), aSet.GetRanges() );
113 10057 : aSet.Intersect_BC( rFmt.aSet, &aOld, &aNew );
114 10057 : (void)aSet.Put_BC( rFmt.aSet, &aOld, &aNew );
115 :
116 : // a few special treatments for attributes
117 10057 : aSet.SetModifyAtAttr( this );
118 :
119 : // create PoolItem attribute for Modify
120 10057 : if( aOld.Count() )
121 : {
122 9445 : SwAttrSetChg aChgOld( aSet, aOld );
123 18890 : SwAttrSetChg aChgNew( aSet, aNew );
124 18890 : ModifyNotification( &aChgOld, &aChgNew ); // send all modified ones
125 : }
126 :
127 10057 : if( GetRegisteredIn() != rFmt.GetRegisteredIn() )
128 : {
129 0 : if( GetRegisteredIn() )
130 0 : GetRegisteredInNonConst()->Remove(this);
131 0 : if( rFmt.GetRegisteredIn() )
132 : {
133 0 : const_cast<SwFmt&>(rFmt).GetRegisteredInNonConst()->Add(this);
134 0 : aSet.SetParent( &rFmt.aSet );
135 : }
136 : else
137 : {
138 0 : aSet.SetParent( 0 );
139 : }
140 : }
141 10057 : bAutoFmt = rFmt.bAutoFmt;
142 10057 : bHidden = rFmt.bHidden;
143 10057 : bAutoUpdateFmt = rFmt.bAutoUpdateFmt;
144 20114 : return *this;
145 : }
146 :
147 1015 : void SwFmt::SetName( const OUString& rNewName, sal_Bool bBroadcast )
148 : {
149 : OSL_ENSURE( !IsDefault(), "SetName: Defaultformat" );
150 1015 : if( bBroadcast )
151 : {
152 706 : SwStringMsgPoolItem aOld( RES_NAME_CHANGED, aFmtName );
153 1412 : SwStringMsgPoolItem aNew( RES_NAME_CHANGED, rNewName );
154 706 : aFmtName = rNewName;
155 1412 : ModifyNotification( &aOld, &aNew );
156 : }
157 : else
158 : {
159 309 : aFmtName = rNewName;
160 : }
161 1015 : }
162 :
163 : /** Copy attributes
164 :
165 : This function is called in every Copy-Ctor for copying the attributes.
166 : The latter can be only copied as soon as the derived class exists since
167 : for setting them the Which() function is called and that has the default
168 : value of 0 in the base class and is then overridden by the derived class.
169 :
170 : If we copy over multiple documents then the new document has to be provided
171 : in which <this> is defined. Currently this is important for DropCaps
172 : because that contains data that needs to be copied deeply.
173 : */
174 3471 : void SwFmt::CopyAttrs( const SwFmt& rFmt, sal_Bool bReplace )
175 : {
176 : // copy only array with attributes delta
177 3471 : if ( IsInCache() )
178 : {
179 0 : SwFrm::GetCache().Delete( this );
180 0 : SetInCache( sal_False );
181 : }
182 3471 : SetInSwFntCache( sal_False );
183 :
184 : // special treatments for some attributes
185 3471 : SwAttrSet* pChgSet = (SwAttrSet*)&rFmt.aSet;
186 :
187 3471 : if( !bReplace ) // refresh only those that are not set?
188 : {
189 0 : if( pChgSet == (SwAttrSet*)&rFmt.aSet )
190 0 : pChgSet = new SwAttrSet( rFmt.aSet );
191 0 : pChgSet->Differentiate( aSet );
192 : }
193 :
194 : // copy only array with attributes delta
195 3471 : if( pChgSet->GetPool() != aSet.GetPool() )
196 14 : pChgSet->CopyToModify( *this );
197 : else
198 : {
199 3457 : SwAttrSet aOld( *aSet.GetPool(), aSet.GetRanges() ),
200 6914 : aNew( *aSet.GetPool(), aSet.GetRanges() );
201 :
202 3457 : if ( aSet.Put_BC( *pChgSet, &aOld, &aNew ) )
203 : {
204 : // a few special treatments for attributes
205 3457 : aSet.SetModifyAtAttr( this );
206 :
207 3457 : SwAttrSetChg aChgOld( aSet, aOld );
208 6914 : SwAttrSetChg aChgNew( aSet, aNew );
209 6914 : ModifyNotification( &aChgOld, &aChgNew ); // send all modified ones
210 3457 : }
211 : }
212 :
213 3471 : if( pChgSet != (SwAttrSet*)&rFmt.aSet ) // was a Set created?
214 0 : delete pChgSet;
215 3471 : }
216 :
217 159416 : SwFmt::~SwFmt()
218 : {
219 : // This happens at a ObjectDying message. Thus put all dependent
220 : // ones on DerivedFrom.
221 79708 : if( GetDepends() )
222 : {
223 : OSL_ENSURE( DerivedFrom(), "SwFmt::~SwFmt: Def dependents!" );
224 :
225 7080 : bFmtInDTOR = true;
226 :
227 7080 : SwFmt* pParentFmt = DerivedFrom();
228 7080 : if( !pParentFmt )
229 : {
230 : SAL_WARN(
231 : "sw.core",
232 : "~SwFmt: parent format missing from: " << GetName() );
233 : }
234 : else
235 : {
236 29359 : while( GetDepends() && pParentFmt)
237 : {
238 15243 : SwFmtChg aOldFmt( this );
239 30486 : SwFmtChg aNewFmt( pParentFmt );
240 15243 : SwClient* pDepend = (SwClient*)GetDepends();
241 15243 : pParentFmt->Add( pDepend );
242 15243 : pDepend->ModifyNotification( &aOldFmt, &aNewFmt );
243 15243 : }
244 : }
245 : }
246 79708 : }
247 :
248 572779 : void SwFmt::Modify( const SfxPoolItem* pOldValue, const SfxPoolItem* pNewValue )
249 : {
250 572779 : bool bContinue = true; // true = pass on to dependent ones
251 :
252 : sal_uInt16 nWhich = pOldValue ? pOldValue->Which() :
253 572779 : pNewValue ? pNewValue->Which() : 0 ;
254 572779 : switch( nWhich )
255 : {
256 0 : case 0: break; // Which-Id of 0?
257 :
258 : case RES_OBJECTDYING:
259 0 : if (pNewValue)
260 : {
261 : // If the dying object is the parent format of this format so
262 : // attach this to the parent of the parent
263 0 : SwFmt* pFmt = (SwFmt*) ((SwPtrMsgPoolItem*)pNewValue)->pObject;
264 :
265 : // do not move if this is the topmost format
266 0 : if( GetRegisteredIn() && GetRegisteredIn() == pFmt )
267 : {
268 0 : if( pFmt->GetRegisteredIn() )
269 : {
270 : // if parent so register in new parent
271 0 : pFmt->DerivedFrom()->Add( this );
272 0 : aSet.SetParent( &DerivedFrom()->aSet );
273 : }
274 : else
275 : {
276 : // otherwise de-register at least from dying one
277 0 : DerivedFrom()->Remove( this );
278 0 : aSet.SetParent( 0 );
279 : }
280 : }
281 : }
282 0 : break;
283 : case RES_ATTRSET_CHG:
284 541229 : if (pOldValue && pNewValue && ((SwAttrSetChg*)pOldValue)->GetTheChgdSet() != &aSet)
285 : {
286 : // pass only those that are not set
287 262496 : SwAttrSetChg aOld( *(SwAttrSetChg*)pOldValue );
288 524992 : SwAttrSetChg aNew( *(SwAttrSetChg*)pNewValue );
289 :
290 262496 : aOld.GetChgSet()->Differentiate( aSet );
291 262496 : aNew.GetChgSet()->Differentiate( aSet );
292 :
293 262496 : if( aNew.Count() )
294 252721 : NotifyClients( &aOld, &aNew );
295 524992 : bContinue = false;
296 : }
297 541229 : break;
298 : case RES_FMT_CHG:
299 : // if the format parent will be moved so register my attribute set at
300 : // the new one
301 :
302 : // skip my own Modify
303 47921 : if( ((SwFmtChg*)pOldValue)->pChangedFmt != this &&
304 18291 : ((SwFmtChg*)pNewValue)->pChangedFmt == DerivedFrom() )
305 : {
306 : // attach Set to new parent
307 6135 : aSet.SetParent( DerivedFrom() ? &DerivedFrom()->aSet : 0 );
308 : }
309 29630 : break;
310 : case RES_RESET_FMTWRITTEN:
311 : {
312 0 : ResetWritten();
313 :
314 : // mba: here we don't use the additional stuff from NotifyClients().
315 : // should we?!
316 : // mba: move the code that ignores this event to the clients
317 :
318 : // pass Hint only to dependent formats (no Frames)
319 0 : ModifyBroadcast( pOldValue, pNewValue, TYPE(SwFmt) );
320 0 : bContinue = false;
321 : }
322 0 : break;
323 : default:
324 : {
325 : // attribute is defined in this format
326 1920 : if( SFX_ITEM_SET == aSet.GetItemState( nWhich, false ))
327 : {
328 : // DropCaps might come into this block
329 : OSL_ENSURE( RES_PARATR_DROP == nWhich, "Modify was sent without sender" );
330 0 : bContinue = false;
331 : }
332 : }
333 : }
334 :
335 572779 : if( bContinue )
336 : {
337 : // walk over all dependent formats
338 310283 : NotifyClients( pOldValue, pNewValue );
339 : }
340 572779 : }
341 :
342 9987 : sal_Bool SwFmt::SetDerivedFrom(SwFmt *pDerFrom)
343 : {
344 9987 : if ( pDerFrom )
345 : {
346 9048 : const SwFmt* pFmt = pDerFrom;
347 38038 : while ( pFmt != 0 )
348 : {
349 19942 : if ( pFmt == this )
350 0 : return sal_False;
351 :
352 19942 : pFmt=pFmt->DerivedFrom();
353 : }
354 : }
355 : else
356 : {
357 : // nothing provided, search for Dflt format
358 939 : pDerFrom = this;
359 3675 : while ( pDerFrom->DerivedFrom() )
360 1797 : pDerFrom = pDerFrom->DerivedFrom();
361 : }
362 9987 : if ( (pDerFrom == DerivedFrom()) || (pDerFrom == this) )
363 383 : return sal_False;
364 :
365 : OSL_ENSURE( Which()==pDerFrom->Which()
366 : || ( Which()==RES_CONDTXTFMTCOLL && pDerFrom->Which()==RES_TXTFMTCOLL)
367 : || ( Which()==RES_TXTFMTCOLL && pDerFrom->Which()==RES_CONDTXTFMTCOLL)
368 : || ( Which()==RES_FLYFRMFMT && pDerFrom->Which()==RES_FRMFMT ),
369 : "SetDerivedFrom: derive apples from oranges?");
370 :
371 9604 : if ( IsInCache() )
372 : {
373 5 : SwFrm::GetCache().Delete( this );
374 5 : SetInCache( sal_False );
375 : }
376 9604 : SetInSwFntCache( sal_False );
377 :
378 9604 : pDerFrom->Add( this );
379 9604 : aSet.SetParent( &pDerFrom->aSet );
380 :
381 9604 : SwFmtChg aOldFmt( this );
382 19208 : SwFmtChg aNewFmt( this );
383 9604 : ModifyNotification( &aOldFmt, &aNewFmt );
384 :
385 19208 : return sal_True;
386 : }
387 :
388 90808 : const SfxPoolItem& SwFmt::GetFmtAttr( sal_uInt16 nWhich, sal_Bool bInParents ) const
389 : {
390 90808 : if(RES_BACKGROUND == nWhich && RES_FLYFRMFMT == Which())
391 : {
392 : //UUUU FALLBACKBREAKHERE should not be used; instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST]
393 : OSL_ENSURE(false, "Do no longer use SvxBrushItem, instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST] FillAttributes (simple fallback is in place and used)");
394 0 : static SvxBrushItem aSvxBrushItem(RES_BACKGROUND);
395 :
396 : // fill the local static SvxBrushItem from the current ItemSet so that
397 : // the fill attributes [XATTR_FILL_FIRST .. XATTR_FILL_LAST] are used
398 : // as good as possible to create a fallback representation and return that
399 0 : aSvxBrushItem = sw::getSvxBrushItemFromSourceSet(aSet, bInParents);
400 :
401 0 : return aSvxBrushItem;
402 : }
403 :
404 90808 : return aSet.Get( nWhich, bInParents );
405 : }
406 :
407 :
408 496912 : SfxItemState SwFmt::GetItemState( sal_uInt16 nWhich, sal_Bool bSrchInParent, const SfxPoolItem **ppItem ) const
409 : {
410 496912 : if(RES_BACKGROUND == nWhich && RES_FLYFRMFMT == Which())
411 : {
412 : //UUUU FALLBACKBREAKHERE should not be used; instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST]
413 : OSL_ENSURE(false, "Do no longer use SvxBrushItem, instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST] FillAttributes (simple fallback is in place and used)");
414 2 : const FillAttributesPtr aFill = getFillAttributes();
415 :
416 : // check if the new fill attributes are used
417 2 : if(aFill.get() && aFill->isUsed())
418 : {
419 : // if yes, fill the local SvxBrushItem using the new fill attributes
420 : // as good as possible to have an instance for the pointer to point
421 : // to and return as state that it is set
422 0 : static SvxBrushItem aSvxBrushItem(RES_BACKGROUND);
423 :
424 0 : aSvxBrushItem = sw::getSvxBrushItemFromSourceSet(aSet, bSrchInParent);
425 0 : *ppItem = &aSvxBrushItem;
426 :
427 0 : return SFX_ITEM_SET;
428 : }
429 :
430 : // if not, reset pointer and return SFX_ITEM_DEFAULT to signal that
431 : // the item is not set
432 2 : *ppItem = 0;
433 :
434 2 : return SFX_ITEM_DEFAULT;
435 : }
436 :
437 496910 : return aSet.GetItemState( nWhich, bSrchInParent, ppItem );
438 : }
439 :
440 :
441 322461 : bool SwFmt::SetFmtAttr( const SfxPoolItem& rAttr )
442 : {
443 322461 : if ( IsInCache() || IsInSwFntCache() )
444 : {
445 1261 : const sal_uInt16 nWhich = rAttr.Which();
446 1261 : CheckCaching( nWhich );
447 : }
448 :
449 322461 : bool bRet = false;
450 :
451 : //UUUU
452 322461 : if(RES_BACKGROUND == rAttr.Which() && RES_FLYFRMFMT == Which())
453 : {
454 : //UUUU FALLBACKBREAKHERE should not be used; instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST]
455 : OSL_ENSURE(false, "Do no longer use SvxBrushItem, instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST] FillAttributes (simple fallback is in place and used)");
456 4 : SfxItemSet aTempSet(*aSet.GetPool(), XATTR_FILL_FIRST, XATTR_FILL_LAST, 0, 0);
457 4 : const SvxBrushItem& rSource = static_cast< const SvxBrushItem& >(rAttr);
458 :
459 : // fill a local ItemSet with the attributes corresponding as good as possible
460 : // to the new fill properties [XATTR_FILL_FIRST .. XATTR_FILL_LAST] and set these
461 : // as ItemSet
462 4 : sw::setSvxBrushItemAsFillAttributesToTargetSet(rSource, aTempSet);
463 :
464 4 : if(IsModifyLocked())
465 : {
466 0 : if( ( bRet = aSet.Put( aTempSet ) ) )
467 : {
468 0 : aSet.SetModifyAtAttr( this );
469 : }
470 : }
471 : else
472 : {
473 8 : SwAttrSet aOld(*aSet.GetPool(), aSet.GetRanges()), aNew(*aSet.GetPool(), aSet.GetRanges());
474 :
475 4 : bRet = aSet.Put_BC(aTempSet, &aOld, &aNew);
476 :
477 4 : if(bRet)
478 : {
479 4 : aSet.SetModifyAtAttr(this);
480 :
481 4 : SwAttrSetChg aChgOld(aSet, aOld);
482 8 : SwAttrSetChg aChgNew(aSet, aNew);
483 :
484 8 : ModifyNotification(&aChgOld, &aChgNew);
485 4 : }
486 : }
487 :
488 4 : return bRet;
489 : }
490 :
491 : // if Modify is locked then no modifications will be sent;
492 : // but call Modify always for FrmFmts
493 322457 : const sal_uInt16 nFmtWhich = Which();
494 669880 : if( IsModifyLocked() ||
495 606482 : ( !GetDepends() &&
496 292186 : (RES_GRFFMTCOLL == nFmtWhich ||
497 : RES_TXTFMTCOLL == nFmtWhich ) ) )
498 : {
499 33127 : if( ( bRet = (0 != aSet.Put( rAttr ))) )
500 32470 : aSet.SetModifyAtAttr( this );
501 : // #i71574#
502 33127 : if ( nFmtWhich == RES_TXTFMTCOLL && rAttr.Which() == RES_PARATR_NUMRULE )
503 : {
504 544 : TxtFmtCollFunc::CheckTxtFmtCollForDeletionOfAssignmentToOutlineStyle( this );
505 : }
506 : }
507 : else
508 : {
509 : // copy only array with attributes delta
510 289330 : SwAttrSet aOld( *aSet.GetPool(), aSet.GetRanges() ),
511 578660 : aNew( *aSet.GetPool(), aSet.GetRanges() );
512 :
513 289330 : bRet = aSet.Put_BC( rAttr, &aOld, &aNew );
514 289330 : if( bRet )
515 : {
516 : // some special treatments for attributes
517 167890 : aSet.SetModifyAtAttr( this );
518 :
519 167890 : SwAttrSetChg aChgOld( aSet, aOld );
520 335780 : SwAttrSetChg aChgNew( aSet, aNew );
521 335780 : ModifyNotification( &aChgOld, &aChgNew ); // send all modified ones
522 289330 : }
523 : }
524 322457 : return bRet;
525 : }
526 :
527 183836 : bool SwFmt::SetFmtAttr( const SfxItemSet& rSet )
528 : {
529 183836 : if( !rSet.Count() )
530 36 : return false;
531 :
532 183800 : if ( IsInCache() )
533 : {
534 92 : SwFrm::GetCache().Delete( this );
535 92 : SetInCache( sal_False );
536 : }
537 183800 : SetInSwFntCache( sal_False );
538 :
539 183800 : bool bRet = false;
540 :
541 : //UUUU
542 183800 : if(RES_FLYFRMFMT == Which())
543 : {
544 8599 : const SfxPoolItem* pSource = 0;
545 :
546 8599 : if(SFX_ITEM_SET == rSet.GetItemState(RES_BACKGROUND, false, &pSource))
547 : {
548 : //UUUU FALLBACKBREAKHERE should not be used; instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST]
549 : OSL_ENSURE(false, "Do no longer use SvxBrushItem, instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST] FillAttributes (simple fallback is in place and used)");
550 9 : SfxItemSet aTempSet(rSet);
551 :
552 : // copy all items to be set anyways to a local ItemSet with is also prepared for the new
553 : // fill attribute ranges [XATTR_FILL_FIRST .. XATTR_FILL_LAST]. Add the attributes
554 : // corresponding as good as possible to the new fill properties and set the whole ItemSet
555 9 : const SvxBrushItem& rSource(static_cast< const SvxBrushItem& >(*pSource));
556 9 : sw::setSvxBrushItemAsFillAttributesToTargetSet(rSource, aTempSet);
557 :
558 9 : if(IsModifyLocked())
559 : {
560 0 : if( ( bRet = aSet.Put( aTempSet ) ) )
561 : {
562 0 : aSet.SetModifyAtAttr( this );
563 : }
564 : }
565 : else
566 : {
567 18 : SwAttrSet aOld(*aSet.GetPool(), aSet.GetRanges()), aNew(*aSet.GetPool(), aSet.GetRanges());
568 :
569 9 : bRet = aSet.Put_BC(aTempSet, &aOld, &aNew);
570 :
571 9 : if(bRet)
572 : {
573 9 : aSet.SetModifyAtAttr(this);
574 :
575 9 : SwAttrSetChg aChgOld(aSet, aOld);
576 18 : SwAttrSetChg aChgNew(aSet, aNew);
577 :
578 18 : ModifyNotification(&aChgOld, &aChgNew);
579 9 : }
580 : }
581 :
582 9 : return bRet;
583 : }
584 : }
585 :
586 : // if Modify is locked then no modifications will be sent;
587 : // but call Modify always for FrmFmts
588 183791 : const sal_uInt16 nFmtWhich = Which();
589 412271 : if ( IsModifyLocked() ||
590 275023 : ( !GetDepends() &&
591 91410 : ( RES_GRFFMTCOLL == nFmtWhich ||
592 : RES_TXTFMTCOLL == nFmtWhich ) ) )
593 : {
594 44867 : if( ( bRet = aSet.Put( rSet )) )
595 30511 : aSet.SetModifyAtAttr( this );
596 : // #i71574#
597 44867 : if ( nFmtWhich == RES_TXTFMTCOLL )
598 : {
599 44689 : TxtFmtCollFunc::CheckTxtFmtCollForDeletionOfAssignmentToOutlineStyle( this );
600 : }
601 : }
602 : else
603 : {
604 138924 : SwAttrSet aOld( *aSet.GetPool(), aSet.GetRanges() ),
605 277848 : aNew( *aSet.GetPool(), aSet.GetRanges() );
606 138924 : bRet = aSet.Put_BC( rSet, &aOld, &aNew );
607 138924 : if( bRet )
608 : {
609 : // some special treatments for attributes
610 92712 : aSet.SetModifyAtAttr( this );
611 92712 : SwAttrSetChg aChgOld( aSet, aOld );
612 185424 : SwAttrSetChg aChgNew( aSet, aNew );
613 185424 : ModifyNotification( &aChgOld, &aChgNew ); // send all modified ones
614 138924 : }
615 : }
616 183791 : return bRet;
617 : }
618 :
619 : // remove Hint using nWhich from array with delta
620 188582 : bool SwFmt::ResetFmtAttr( sal_uInt16 nWhich1, sal_uInt16 nWhich2 )
621 : {
622 188582 : if( !aSet.Count() )
623 18813 : return false;
624 :
625 169769 : if( !nWhich2 || nWhich2 < nWhich1 )
626 162200 : nWhich2 = nWhich1; // then set to 1st ID, only this item
627 :
628 169769 : if ( IsInCache() || IsInSwFntCache() )
629 : {
630 378 : for( sal_uInt16 n = nWhich1; n < nWhich2; ++n )
631 40 : CheckCaching( n );
632 : }
633 :
634 : // if Modify is locked then no modifications will be sent
635 169769 : if( IsModifyLocked() )
636 16008 : return 0 != (( nWhich2 == nWhich1 )
637 544 : ? aSet.ClearItem( nWhich1 )
638 15464 : : aSet.ClearItem_BC( nWhich1, nWhich2 ));
639 :
640 161765 : SwAttrSet aOld( *aSet.GetPool(), aSet.GetRanges() ),
641 323530 : aNew( *aSet.GetPool(), aSet.GetRanges() );
642 161765 : bool bRet = 0 != aSet.ClearItem_BC( nWhich1, nWhich2, &aOld, &aNew );
643 161765 : if( bRet )
644 : {
645 533 : SwAttrSetChg aChgOld( aSet, aOld );
646 1066 : SwAttrSetChg aChgNew( aSet, aNew );
647 1066 : ModifyNotification( &aChgOld, &aChgNew ); // send all modified ones
648 : }
649 323530 : return bRet;
650 : }
651 :
652 : // #i73790#
653 2407 : sal_uInt16 SwFmt::ResetAllFmtAttr()
654 : {
655 2407 : if( !aSet.Count() )
656 754 : return 0;
657 :
658 1653 : if ( IsInCache() )
659 : {
660 11 : SwFrm::GetCache().Delete( this );
661 11 : SetInCache( sal_False );
662 : }
663 1653 : SetInSwFntCache( sal_False );
664 :
665 : // if Modify is locked then no modifications will be sent
666 1653 : if( IsModifyLocked() )
667 0 : return aSet.ClearItem( 0 );
668 :
669 1653 : SwAttrSet aOld( *aSet.GetPool(), aSet.GetRanges() ),
670 3306 : aNew( *aSet.GetPool(), aSet.GetRanges() );
671 1653 : bool bRet = 0 != aSet.ClearItem_BC( 0, &aOld, &aNew );
672 1653 : if( bRet )
673 : {
674 1653 : SwAttrSetChg aChgOld( aSet, aOld );
675 3306 : SwAttrSetChg aChgNew( aSet, aNew );
676 3306 : ModifyNotification( &aChgOld, &aChgNew ); // send all modified ones
677 : }
678 3306 : return aNew.Count();
679 : }
680 :
681 130957 : bool SwFmt::GetInfo( SfxPoolItem& rInfo ) const
682 : {
683 130957 : return SwModify::GetInfo( rInfo );
684 : }
685 :
686 6657 : void SwFmt::DelDiffs( const SfxItemSet& rSet )
687 : {
688 6657 : if( !aSet.Count() )
689 150 : return;
690 :
691 6582 : if ( IsInCache() )
692 : {
693 0 : SwFrm::GetCache().Delete( this );
694 0 : SetInCache( sal_False );
695 : }
696 6582 : SetInSwFntCache( sal_False );
697 :
698 : // if Modify is locked then no modifications will be sent
699 6582 : if( IsModifyLocked() )
700 : {
701 0 : aSet.Intersect( rSet );
702 0 : return;
703 : }
704 :
705 6582 : SwAttrSet aOld( *aSet.GetPool(), aSet.GetRanges() ),
706 13164 : aNew( *aSet.GetPool(), aSet.GetRanges() );
707 6582 : bool bRet = 0 != aSet.Intersect_BC( rSet, &aOld, &aNew );
708 6582 : if( bRet )
709 : {
710 3589 : SwAttrSetChg aChgOld( aSet, aOld );
711 7178 : SwAttrSetChg aChgNew( aSet, aNew );
712 7178 : ModifyNotification( &aChgOld, &aChgNew ); // send all modified ones
713 6582 : }
714 : }
715 :
716 : /** SwFmt::IsBackgroundTransparent
717 :
718 : Virtual method to determine, if background of format is transparent.
719 : Default implementation returns false. Thus, subclasses have to overload
720 : method, if the specific subclass can have a transparent background.
721 :
722 : @return false, default implementation
723 : */
724 0 : bool SwFmt::IsBackgroundTransparent() const
725 : {
726 0 : return false;
727 : }
728 :
729 : /** SwFmt::IsShadowTransparent
730 :
731 : Virtual method to determine, if shadow of format is transparent.
732 : Default implementation returns false. Thus, subclasses have to overload
733 : method, if the specific subclass can have a transparent shadow.
734 :
735 : @return false, default implementation
736 : */
737 201 : bool SwFmt::IsShadowTransparent() const
738 : {
739 201 : return false;
740 : }
741 :
742 : /*
743 : * Document Interface Access
744 : */
745 368891 : const IDocumentSettingAccess* SwFmt::getIDocumentSettingAccess() const { return GetDoc(); }
746 6609 : const IDocumentDrawModelAccess* SwFmt::getIDocumentDrawModelAccess() const { return GetDoc(); }
747 73855 : IDocumentDrawModelAccess* SwFmt::getIDocumentDrawModelAccess() { return GetDoc(); }
748 135 : const IDocumentLayoutAccess* SwFmt::getIDocumentLayoutAccess() const { return GetDoc(); }
749 27846 : IDocumentLayoutAccess* SwFmt::getIDocumentLayoutAccess() { return GetDoc(); }
750 3231 : IDocumentTimerAccess* SwFmt::getIDocumentTimerAccess() { return GetDoc(); }
751 1732 : IDocumentFieldsAccess* SwFmt::getIDocumentFieldsAccess() { return GetDoc(); }
752 0 : IDocumentChartDataProviderAccess* SwFmt::getIDocumentChartDataProviderAccess() { return GetDoc(); }
753 :
754 4734 : void SwFmt::GetGrabBagItem(uno::Any& rVal) const
755 : {
756 4734 : if (m_pGrabBagItem.get())
757 3078 : m_pGrabBagItem->QueryValue(rVal);
758 : else
759 : {
760 1656 : uno::Sequence<beans::PropertyValue> aValue(0);
761 1656 : rVal = uno::makeAny(aValue);
762 : }
763 4734 : }
764 :
765 10458 : void SwFmt::SetGrabBagItem(const uno::Any& rVal)
766 : {
767 10458 : if (!m_pGrabBagItem.get())
768 10451 : m_pGrabBagItem.reset(new SfxGrabBagItem);
769 :
770 10458 : m_pGrabBagItem->PutValue(rVal);
771 10458 : }
772 :
773 : //UUUU
774 23569 : const SvxBrushItem& SwFmt::GetBackground(sal_Bool bInP) const
775 : {
776 23569 : if(RES_FLYFRMFMT == Which())
777 : {
778 : //UUUU FALLBACKBREAKHERE should not be used; instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST]
779 : OSL_ENSURE(false, "Do no longer use SvxBrushItem, instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST] FillAttributes (simple fallback is in place and used)");
780 1 : static SvxBrushItem aSvxBrushItem(RES_BACKGROUND);
781 :
782 : // fill the local static SvxBrushItem from the current ItemSet so that
783 : // the fill attributes [XATTR_FILL_FIRST .. XATTR_FILL_LAST] are used
784 : // as good as possible to create a fallback representation and return that
785 1 : aSvxBrushItem = sw::getSvxBrushItemFromSourceSet(aSet, bInP);
786 :
787 1 : return aSvxBrushItem;
788 : }
789 :
790 23568 : return aSet.GetBackground(bInP);
791 : }
792 :
793 : //UUUU
794 0 : FillAttributesPtr SwFmt::getFillAttributes() const
795 : {
796 : // FALLBACKBREAKHERE return empty pointer
797 : OSL_ENSURE(false, "getFillAttributes() call only valid for RES_FLYFRMFMT currently (!)");
798 :
799 0 : return FillAttributesPtr();
800 : }
801 :
802 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|