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 0 : TYPEINIT1( SwFmt, SwClient );
37 :
38 0 : 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 0 : nPoolHlpFileId( UCHAR_MAX )
48 : {
49 0 : bAutoUpdateFmt = sal_False; // LAYER_IMPL
50 0 : bAutoFmt = true;
51 0 : bWritten = bFmtInDTOR = bHidden = false;
52 :
53 0 : if( pDrvdFrm )
54 0 : aSet.SetParent( &pDrvdFrm->aSet );
55 0 : }
56 :
57 0 : 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 0 : nPoolHlpFileId( UCHAR_MAX )
67 : {
68 0 : bAutoUpdateFmt = sal_False; // LAYER_IMPL
69 0 : bAutoFmt = true;
70 0 : bWritten = bFmtInDTOR = bHidden = false;
71 :
72 0 : if( pDrvdFrm )
73 0 : aSet.SetParent( &pDrvdFrm->aSet );
74 0 : }
75 :
76 0 : SwFmt::SwFmt( const SwFmt& rFmt )
77 0 : : SwModify( rFmt.DerivedFrom() ),
78 : aFmtName( rFmt.aFmtName ),
79 : aSet( rFmt.aSet ),
80 : nWhichId( rFmt.nWhichId ),
81 0 : nPoolFmtId( rFmt.GetPoolFmtId() ),
82 0 : nPoolHelpId( rFmt.GetPoolHelpId() ),
83 0 : nPoolHlpFileId( rFmt.GetPoolHlpFileId() )
84 : {
85 0 : bWritten = bFmtInDTOR = false; // LAYER_IMPL
86 0 : bAutoFmt = rFmt.bAutoFmt;
87 0 : bHidden = rFmt.bHidden;
88 0 : bAutoUpdateFmt = rFmt.bAutoUpdateFmt;
89 :
90 0 : if( rFmt.DerivedFrom() )
91 0 : aSet.SetParent( &rFmt.DerivedFrom()->aSet );
92 : // a few special treatments for attributes
93 0 : aSet.SetModifyAtAttr( this );
94 0 : }
95 :
96 0 : SwFmt &SwFmt::operator=(const SwFmt& rFmt)
97 : {
98 0 : nWhichId = rFmt.nWhichId;
99 0 : nPoolFmtId = rFmt.GetPoolFmtId();
100 0 : nPoolHelpId = rFmt.GetPoolHelpId();
101 0 : nPoolHlpFileId = rFmt.GetPoolHlpFileId();
102 :
103 0 : if ( IsInCache() )
104 : {
105 0 : SwFrm::GetCache().Delete( this );
106 0 : SetInCache( sal_False );
107 : }
108 0 : SetInSwFntCache( sal_False );
109 :
110 : // copy only array with attributes delta
111 0 : SwAttrSet aOld( *aSet.GetPool(), aSet.GetRanges() ),
112 0 : aNew( *aSet.GetPool(), aSet.GetRanges() );
113 0 : aSet.Intersect_BC( rFmt.aSet, &aOld, &aNew );
114 0 : (void)aSet.Put_BC( rFmt.aSet, &aOld, &aNew );
115 :
116 : // a few special treatments for attributes
117 0 : aSet.SetModifyAtAttr( this );
118 :
119 : // create PoolItem attribute for Modify
120 0 : if( aOld.Count() )
121 : {
122 0 : SwAttrSetChg aChgOld( aSet, aOld );
123 0 : SwAttrSetChg aChgNew( aSet, aNew );
124 0 : ModifyNotification( &aChgOld, &aChgNew ); // send all modified ones
125 : }
126 :
127 0 : 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 0 : bAutoFmt = rFmt.bAutoFmt;
142 0 : bHidden = rFmt.bHidden;
143 0 : bAutoUpdateFmt = rFmt.bAutoUpdateFmt;
144 0 : return *this;
145 : }
146 :
147 0 : void SwFmt::SetName( const OUString& rNewName, sal_Bool bBroadcast )
148 : {
149 : OSL_ENSURE( !IsDefault(), "SetName: Defaultformat" );
150 0 : if( bBroadcast )
151 : {
152 0 : SwStringMsgPoolItem aOld( RES_NAME_CHANGED, aFmtName );
153 0 : SwStringMsgPoolItem aNew( RES_NAME_CHANGED, rNewName );
154 0 : aFmtName = rNewName;
155 0 : ModifyNotification( &aOld, &aNew );
156 : }
157 : else
158 : {
159 0 : aFmtName = rNewName;
160 : }
161 0 : }
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 0 : void SwFmt::CopyAttrs( const SwFmt& rFmt, sal_Bool bReplace )
175 : {
176 : // copy only array with attributes delta
177 0 : if ( IsInCache() )
178 : {
179 0 : SwFrm::GetCache().Delete( this );
180 0 : SetInCache( sal_False );
181 : }
182 0 : SetInSwFntCache( sal_False );
183 :
184 : // special treatments for some attributes
185 0 : SwAttrSet* pChgSet = (SwAttrSet*)&rFmt.aSet;
186 :
187 0 : 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 0 : if( pChgSet->GetPool() != aSet.GetPool() )
196 0 : pChgSet->CopyToModify( *this );
197 : else
198 : {
199 0 : SwAttrSet aOld( *aSet.GetPool(), aSet.GetRanges() ),
200 0 : aNew( *aSet.GetPool(), aSet.GetRanges() );
201 :
202 0 : if ( aSet.Put_BC( *pChgSet, &aOld, &aNew ) )
203 : {
204 : // a few special treatments for attributes
205 0 : aSet.SetModifyAtAttr( this );
206 :
207 0 : SwAttrSetChg aChgOld( aSet, aOld );
208 0 : SwAttrSetChg aChgNew( aSet, aNew );
209 0 : ModifyNotification( &aChgOld, &aChgNew ); // send all modified ones
210 0 : }
211 : }
212 :
213 0 : if( pChgSet != (SwAttrSet*)&rFmt.aSet ) // was a Set created?
214 0 : delete pChgSet;
215 0 : }
216 :
217 0 : SwFmt::~SwFmt()
218 : {
219 : // This happens at a ObjectDying message. Thus put all dependent
220 : // ones on DerivedFrom.
221 0 : if( GetDepends() )
222 : {
223 : OSL_ENSURE( DerivedFrom(), "SwFmt::~SwFmt: Def dependents!" );
224 :
225 0 : bFmtInDTOR = true;
226 :
227 0 : SwFmt* pParentFmt = DerivedFrom();
228 0 : if( !pParentFmt )
229 : {
230 : SAL_WARN(
231 : "sw.core",
232 : "~SwFmt: parent format missing from: " << GetName() );
233 : }
234 : else
235 : {
236 0 : while( GetDepends() && pParentFmt)
237 : {
238 0 : SwFmtChg aOldFmt( this );
239 0 : SwFmtChg aNewFmt( pParentFmt );
240 0 : SwClient* pDepend = (SwClient*)GetDepends();
241 0 : pParentFmt->Add( pDepend );
242 0 : pDepend->ModifyNotification( &aOldFmt, &aNewFmt );
243 0 : }
244 : }
245 : }
246 0 : }
247 :
248 0 : void SwFmt::Modify( const SfxPoolItem* pOldValue, const SfxPoolItem* pNewValue )
249 : {
250 0 : bool bContinue = true; // true = pass on to dependent ones
251 :
252 : sal_uInt16 nWhich = pOldValue ? pOldValue->Which() :
253 0 : pNewValue ? pNewValue->Which() : 0 ;
254 0 : 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 0 : if (pOldValue && pNewValue && ((SwAttrSetChg*)pOldValue)->GetTheChgdSet() != &aSet)
285 : {
286 : // pass only those that are not set
287 0 : SwAttrSetChg aOld( *(SwAttrSetChg*)pOldValue );
288 0 : SwAttrSetChg aNew( *(SwAttrSetChg*)pNewValue );
289 :
290 0 : aOld.GetChgSet()->Differentiate( aSet );
291 0 : aNew.GetChgSet()->Differentiate( aSet );
292 :
293 0 : if( aNew.Count() )
294 0 : NotifyClients( &aOld, &aNew );
295 0 : bContinue = false;
296 : }
297 0 : 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 0 : if( ((SwFmtChg*)pOldValue)->pChangedFmt != this &&
304 0 : ((SwFmtChg*)pNewValue)->pChangedFmt == DerivedFrom() )
305 : {
306 : // attach Set to new parent
307 0 : aSet.SetParent( DerivedFrom() ? &DerivedFrom()->aSet : 0 );
308 : }
309 0 : 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 0 : 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 0 : if( bContinue )
336 : {
337 : // walk over all dependent formats
338 0 : NotifyClients( pOldValue, pNewValue );
339 : }
340 0 : }
341 :
342 0 : sal_Bool SwFmt::SetDerivedFrom(SwFmt *pDerFrom)
343 : {
344 0 : if ( pDerFrom )
345 : {
346 0 : const SwFmt* pFmt = pDerFrom;
347 0 : while ( pFmt != 0 )
348 : {
349 0 : if ( pFmt == this )
350 0 : return sal_False;
351 :
352 0 : pFmt=pFmt->DerivedFrom();
353 : }
354 : }
355 : else
356 : {
357 : // nothing provided, search for Dflt format
358 0 : pDerFrom = this;
359 0 : while ( pDerFrom->DerivedFrom() )
360 0 : pDerFrom = pDerFrom->DerivedFrom();
361 : }
362 0 : if ( (pDerFrom == DerivedFrom()) || (pDerFrom == this) )
363 0 : 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 0 : if ( IsInCache() )
372 : {
373 0 : SwFrm::GetCache().Delete( this );
374 0 : SetInCache( sal_False );
375 : }
376 0 : SetInSwFntCache( sal_False );
377 :
378 0 : pDerFrom->Add( this );
379 0 : aSet.SetParent( &pDerFrom->aSet );
380 :
381 0 : SwFmtChg aOldFmt( this );
382 0 : SwFmtChg aNewFmt( this );
383 0 : ModifyNotification( &aOldFmt, &aNewFmt );
384 :
385 0 : return sal_True;
386 : }
387 :
388 0 : const SfxPoolItem& SwFmt::GetFmtAttr( sal_uInt16 nWhich, sal_Bool bInParents ) const
389 : {
390 0 : 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 0 : return aSet.Get( nWhich, bInParents );
405 : }
406 :
407 :
408 0 : SfxItemState SwFmt::GetItemState( sal_uInt16 nWhich, sal_Bool bSrchInParent, const SfxPoolItem **ppItem ) const
409 : {
410 0 : 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 0 : const FillAttributesPtr aFill = getFillAttributes();
415 :
416 : // check if the new fill attributes are used
417 0 : 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 0 : *ppItem = 0;
433 :
434 0 : return SFX_ITEM_DEFAULT;
435 : }
436 :
437 0 : return aSet.GetItemState( nWhich, bSrchInParent, ppItem );
438 : }
439 :
440 :
441 0 : bool SwFmt::SetFmtAttr( const SfxPoolItem& rAttr )
442 : {
443 0 : if ( IsInCache() || IsInSwFntCache() )
444 : {
445 0 : const sal_uInt16 nWhich = rAttr.Which();
446 0 : CheckCaching( nWhich );
447 : }
448 :
449 0 : bool bRet = false;
450 :
451 : //UUUU
452 0 : 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 0 : SfxItemSet aTempSet(*aSet.GetPool(), XATTR_FILL_FIRST, XATTR_FILL_LAST, 0, 0);
457 0 : 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 0 : sw::setSvxBrushItemAsFillAttributesToTargetSet(rSource, aTempSet);
463 :
464 0 : if(IsModifyLocked())
465 : {
466 0 : if( ( bRet = aSet.Put( aTempSet ) ) )
467 : {
468 0 : aSet.SetModifyAtAttr( this );
469 : }
470 : }
471 : else
472 : {
473 0 : SwAttrSet aOld(*aSet.GetPool(), aSet.GetRanges()), aNew(*aSet.GetPool(), aSet.GetRanges());
474 :
475 0 : bRet = aSet.Put_BC(aTempSet, &aOld, &aNew);
476 :
477 0 : if(bRet)
478 : {
479 0 : aSet.SetModifyAtAttr(this);
480 :
481 0 : SwAttrSetChg aChgOld(aSet, aOld);
482 0 : SwAttrSetChg aChgNew(aSet, aNew);
483 :
484 0 : ModifyNotification(&aChgOld, &aChgNew);
485 0 : }
486 : }
487 :
488 0 : return bRet;
489 : }
490 :
491 : // if Modify is locked then no modifications will be sent;
492 : // but call Modify always for FrmFmts
493 0 : const sal_uInt16 nFmtWhich = Which();
494 0 : if( IsModifyLocked() ||
495 0 : ( !GetDepends() &&
496 0 : (RES_GRFFMTCOLL == nFmtWhich ||
497 : RES_TXTFMTCOLL == nFmtWhich ) ) )
498 : {
499 0 : if( ( bRet = (0 != aSet.Put( rAttr ))) )
500 0 : aSet.SetModifyAtAttr( this );
501 : // #i71574#
502 0 : if ( nFmtWhich == RES_TXTFMTCOLL && rAttr.Which() == RES_PARATR_NUMRULE )
503 : {
504 0 : TxtFmtCollFunc::CheckTxtFmtCollForDeletionOfAssignmentToOutlineStyle( this );
505 : }
506 : }
507 : else
508 : {
509 : // copy only array with attributes delta
510 0 : SwAttrSet aOld( *aSet.GetPool(), aSet.GetRanges() ),
511 0 : aNew( *aSet.GetPool(), aSet.GetRanges() );
512 :
513 0 : bRet = aSet.Put_BC( rAttr, &aOld, &aNew );
514 0 : if( bRet )
515 : {
516 : // some special treatments for attributes
517 0 : aSet.SetModifyAtAttr( this );
518 :
519 0 : SwAttrSetChg aChgOld( aSet, aOld );
520 0 : SwAttrSetChg aChgNew( aSet, aNew );
521 0 : ModifyNotification( &aChgOld, &aChgNew ); // send all modified ones
522 0 : }
523 : }
524 0 : return bRet;
525 : }
526 :
527 0 : bool SwFmt::SetFmtAttr( const SfxItemSet& rSet )
528 : {
529 0 : if( !rSet.Count() )
530 0 : return false;
531 :
532 0 : if ( IsInCache() )
533 : {
534 0 : SwFrm::GetCache().Delete( this );
535 0 : SetInCache( sal_False );
536 : }
537 0 : SetInSwFntCache( sal_False );
538 :
539 0 : bool bRet = false;
540 :
541 : //UUUU
542 0 : if(RES_FLYFRMFMT == Which())
543 : {
544 0 : const SfxPoolItem* pSource = 0;
545 :
546 0 : 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 0 : 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 0 : const SvxBrushItem& rSource(static_cast< const SvxBrushItem& >(*pSource));
556 0 : sw::setSvxBrushItemAsFillAttributesToTargetSet(rSource, aTempSet);
557 :
558 0 : if(IsModifyLocked())
559 : {
560 0 : if( ( bRet = aSet.Put( aTempSet ) ) )
561 : {
562 0 : aSet.SetModifyAtAttr( this );
563 : }
564 : }
565 : else
566 : {
567 0 : SwAttrSet aOld(*aSet.GetPool(), aSet.GetRanges()), aNew(*aSet.GetPool(), aSet.GetRanges());
568 :
569 0 : bRet = aSet.Put_BC(aTempSet, &aOld, &aNew);
570 :
571 0 : if(bRet)
572 : {
573 0 : aSet.SetModifyAtAttr(this);
574 :
575 0 : SwAttrSetChg aChgOld(aSet, aOld);
576 0 : SwAttrSetChg aChgNew(aSet, aNew);
577 :
578 0 : ModifyNotification(&aChgOld, &aChgNew);
579 0 : }
580 : }
581 :
582 0 : return bRet;
583 : }
584 : }
585 :
586 : // if Modify is locked then no modifications will be sent;
587 : // but call Modify always for FrmFmts
588 0 : const sal_uInt16 nFmtWhich = Which();
589 0 : if ( IsModifyLocked() ||
590 0 : ( !GetDepends() &&
591 0 : ( RES_GRFFMTCOLL == nFmtWhich ||
592 : RES_TXTFMTCOLL == nFmtWhich ) ) )
593 : {
594 0 : if( ( bRet = aSet.Put( rSet )) )
595 0 : aSet.SetModifyAtAttr( this );
596 : // #i71574#
597 0 : if ( nFmtWhich == RES_TXTFMTCOLL )
598 : {
599 0 : TxtFmtCollFunc::CheckTxtFmtCollForDeletionOfAssignmentToOutlineStyle( this );
600 : }
601 : }
602 : else
603 : {
604 0 : SwAttrSet aOld( *aSet.GetPool(), aSet.GetRanges() ),
605 0 : aNew( *aSet.GetPool(), aSet.GetRanges() );
606 0 : bRet = aSet.Put_BC( rSet, &aOld, &aNew );
607 0 : if( bRet )
608 : {
609 : // some special treatments for attributes
610 0 : aSet.SetModifyAtAttr( this );
611 0 : SwAttrSetChg aChgOld( aSet, aOld );
612 0 : SwAttrSetChg aChgNew( aSet, aNew );
613 0 : ModifyNotification( &aChgOld, &aChgNew ); // send all modified ones
614 0 : }
615 : }
616 0 : return bRet;
617 : }
618 :
619 : // remove Hint using nWhich from array with delta
620 0 : bool SwFmt::ResetFmtAttr( sal_uInt16 nWhich1, sal_uInt16 nWhich2 )
621 : {
622 0 : if( !aSet.Count() )
623 0 : return false;
624 :
625 0 : if( !nWhich2 || nWhich2 < nWhich1 )
626 0 : nWhich2 = nWhich1; // then set to 1st ID, only this item
627 :
628 0 : if ( IsInCache() || IsInSwFntCache() )
629 : {
630 0 : for( sal_uInt16 n = nWhich1; n < nWhich2; ++n )
631 0 : CheckCaching( n );
632 : }
633 :
634 : // if Modify is locked then no modifications will be sent
635 0 : if( IsModifyLocked() )
636 0 : return 0 != (( nWhich2 == nWhich1 )
637 0 : ? aSet.ClearItem( nWhich1 )
638 0 : : aSet.ClearItem_BC( nWhich1, nWhich2 ));
639 :
640 0 : SwAttrSet aOld( *aSet.GetPool(), aSet.GetRanges() ),
641 0 : aNew( *aSet.GetPool(), aSet.GetRanges() );
642 0 : bool bRet = 0 != aSet.ClearItem_BC( nWhich1, nWhich2, &aOld, &aNew );
643 0 : if( bRet )
644 : {
645 0 : SwAttrSetChg aChgOld( aSet, aOld );
646 0 : SwAttrSetChg aChgNew( aSet, aNew );
647 0 : ModifyNotification( &aChgOld, &aChgNew ); // send all modified ones
648 : }
649 0 : return bRet;
650 : }
651 :
652 : // #i73790#
653 0 : sal_uInt16 SwFmt::ResetAllFmtAttr()
654 : {
655 0 : if( !aSet.Count() )
656 0 : return 0;
657 :
658 0 : if ( IsInCache() )
659 : {
660 0 : SwFrm::GetCache().Delete( this );
661 0 : SetInCache( sal_False );
662 : }
663 0 : SetInSwFntCache( sal_False );
664 :
665 : // if Modify is locked then no modifications will be sent
666 0 : if( IsModifyLocked() )
667 0 : return aSet.ClearItem( 0 );
668 :
669 0 : SwAttrSet aOld( *aSet.GetPool(), aSet.GetRanges() ),
670 0 : aNew( *aSet.GetPool(), aSet.GetRanges() );
671 0 : bool bRet = 0 != aSet.ClearItem_BC( 0, &aOld, &aNew );
672 0 : if( bRet )
673 : {
674 0 : SwAttrSetChg aChgOld( aSet, aOld );
675 0 : SwAttrSetChg aChgNew( aSet, aNew );
676 0 : ModifyNotification( &aChgOld, &aChgNew ); // send all modified ones
677 : }
678 0 : return aNew.Count();
679 : }
680 :
681 0 : bool SwFmt::GetInfo( SfxPoolItem& rInfo ) const
682 : {
683 0 : return SwModify::GetInfo( rInfo );
684 : }
685 :
686 0 : void SwFmt::DelDiffs( const SfxItemSet& rSet )
687 : {
688 0 : if( !aSet.Count() )
689 0 : return;
690 :
691 0 : if ( IsInCache() )
692 : {
693 0 : SwFrm::GetCache().Delete( this );
694 0 : SetInCache( sal_False );
695 : }
696 0 : SetInSwFntCache( sal_False );
697 :
698 : // if Modify is locked then no modifications will be sent
699 0 : if( IsModifyLocked() )
700 : {
701 0 : aSet.Intersect( rSet );
702 0 : return;
703 : }
704 :
705 0 : SwAttrSet aOld( *aSet.GetPool(), aSet.GetRanges() ),
706 0 : aNew( *aSet.GetPool(), aSet.GetRanges() );
707 0 : bool bRet = 0 != aSet.Intersect_BC( rSet, &aOld, &aNew );
708 0 : if( bRet )
709 : {
710 0 : SwAttrSetChg aChgOld( aSet, aOld );
711 0 : SwAttrSetChg aChgNew( aSet, aNew );
712 0 : ModifyNotification( &aChgOld, &aChgNew ); // send all modified ones
713 0 : }
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 0 : bool SwFmt::IsShadowTransparent() const
738 : {
739 0 : return false;
740 : }
741 :
742 : /*
743 : * Document Interface Access
744 : */
745 0 : const IDocumentSettingAccess* SwFmt::getIDocumentSettingAccess() const { return GetDoc(); }
746 0 : const IDocumentDrawModelAccess* SwFmt::getIDocumentDrawModelAccess() const { return GetDoc(); }
747 0 : IDocumentDrawModelAccess* SwFmt::getIDocumentDrawModelAccess() { return GetDoc(); }
748 0 : const IDocumentLayoutAccess* SwFmt::getIDocumentLayoutAccess() const { return GetDoc(); }
749 0 : IDocumentLayoutAccess* SwFmt::getIDocumentLayoutAccess() { return GetDoc(); }
750 0 : IDocumentTimerAccess* SwFmt::getIDocumentTimerAccess() { return GetDoc(); }
751 0 : IDocumentFieldsAccess* SwFmt::getIDocumentFieldsAccess() { return GetDoc(); }
752 0 : IDocumentChartDataProviderAccess* SwFmt::getIDocumentChartDataProviderAccess() { return GetDoc(); }
753 :
754 0 : void SwFmt::GetGrabBagItem(uno::Any& rVal) const
755 : {
756 0 : if (m_pGrabBagItem.get())
757 0 : m_pGrabBagItem->QueryValue(rVal);
758 : else
759 : {
760 0 : uno::Sequence<beans::PropertyValue> aValue(0);
761 0 : rVal = uno::makeAny(aValue);
762 : }
763 0 : }
764 :
765 0 : void SwFmt::SetGrabBagItem(const uno::Any& rVal)
766 : {
767 0 : if (!m_pGrabBagItem.get())
768 0 : m_pGrabBagItem.reset(new SfxGrabBagItem);
769 :
770 0 : m_pGrabBagItem->PutValue(rVal);
771 0 : }
772 :
773 : //UUUU
774 0 : const SvxBrushItem& SwFmt::GetBackground(sal_Bool bInP) const
775 : {
776 0 : 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 0 : 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 0 : aSvxBrushItem = sw::getSvxBrushItemFromSourceSet(aSet, bInP);
786 :
787 0 : return aSvxBrushItem;
788 : }
789 :
790 0 : 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: */
|