1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22 // MARKER(update_precomp.py): autogen include statement, do not remove
23 #include "precompiled_sw.hxx"
24
25 #include <hintids.hxx> // fuer RES_..
26 #include <frame.hxx> // fuer AttrCache
27 #include <format.hxx>
28 #include <hints.hxx> // fuer SwFmtChg
29 #include <doc.hxx>
30 #include <paratr.hxx> // fuer SwParaFmt - SwHyphenBug
31 #include <swcache.hxx>
32 #include <fmtcolfunc.hxx>
33
34 //UUUU
35 #include <svx/sdr/attribute/sdrallfillattributeshelper.hxx>
36 #include <svx/unobrushitemhelper.hxx>
37 #include <svx/xdef.hxx>
38 #include <frmatr.hxx>
39
40 TYPEINIT1( SwFmt, SwClient ); //rtti fuer SwFmt
41
42 /*************************************************************************
43 |* SwFmt::SwFmt
44 *************************************************************************/
45
46
SwFmt(SwAttrPool & rPool,const sal_Char * pFmtNm,const sal_uInt16 * pWhichRanges,SwFmt * pDrvdFrm,sal_uInt16 nFmtWhich)47 SwFmt::SwFmt( SwAttrPool& rPool, const sal_Char* pFmtNm,
48 const sal_uInt16* pWhichRanges, SwFmt *pDrvdFrm, sal_uInt16 nFmtWhich )
49 : SwModify( pDrvdFrm ),
50 aSet( rPool, pWhichRanges ),
51 nWhichId( nFmtWhich ),
52 nFmtId( 0 ),
53 nPoolFmtId( USHRT_MAX ),
54 nPoolHelpId( USHRT_MAX ),
55 nPoolHlpFileId( UCHAR_MAX )
56 {
57 aFmtName.AssignAscii( pFmtNm );
58 bWritten = bFmtInDTOR = bAutoUpdateFmt = sal_False; // LAYER_IMPL
59 bAutoFmt = sal_True;
60
61 if( pDrvdFrm )
62 aSet.SetParent( &pDrvdFrm->aSet );
63 }
64
65
SwFmt(SwAttrPool & rPool,const String & rFmtNm,const sal_uInt16 * pWhichRanges,SwFmt * pDrvdFrm,sal_uInt16 nFmtWhich)66 SwFmt::SwFmt( SwAttrPool& rPool, const String &rFmtNm,
67 const sal_uInt16* pWhichRanges, SwFmt *pDrvdFrm, sal_uInt16 nFmtWhich )
68 : SwModify( pDrvdFrm ),
69 aFmtName( rFmtNm ),
70 aSet( rPool, pWhichRanges ),
71 nWhichId( nFmtWhich ),
72 nFmtId( 0 ),
73 nPoolFmtId( USHRT_MAX ),
74 nPoolHelpId( USHRT_MAX ),
75 nPoolHlpFileId( UCHAR_MAX )
76 {
77 bWritten = bFmtInDTOR = bAutoUpdateFmt = sal_False; // LAYER_IMPL
78 bAutoFmt = sal_True;
79
80 if( pDrvdFrm )
81 aSet.SetParent( &pDrvdFrm->aSet );
82 }
83
84
SwFmt(const SwFmt & rFmt)85 SwFmt::SwFmt( const SwFmt& rFmt )
86 : SwModify( rFmt.DerivedFrom() ),
87 aFmtName( rFmt.aFmtName ),
88 aSet( rFmt.aSet ),
89 nWhichId( rFmt.nWhichId ),
90 nFmtId( 0 ),
91 nPoolFmtId( rFmt.GetPoolFmtId() ),
92 nPoolHelpId( rFmt.GetPoolHelpId() ),
93 nPoolHlpFileId( rFmt.GetPoolHlpFileId() )
94 {
95 bWritten = bFmtInDTOR = sal_False; // LAYER_IMPL
96 bAutoFmt = rFmt.bAutoFmt;
97 bAutoUpdateFmt = rFmt.bAutoUpdateFmt;
98
99 if( rFmt.DerivedFrom() )
100 aSet.SetParent( &rFmt.DerivedFrom()->aSet );
101 // einige Sonderbehandlungen fuer Attribute
102 aSet.SetModifyAtAttr( this );
103 }
104
105 /*************************************************************************
106 |* SwFmt &SwFmt::operator=(const SwFmt& aFmt)
107 |*
108 |* Beschreibung Dokument 1.14
109 |* Ersterstellung JP 22.11.90
110 |* Letzte Aenderung JP 05.08.94
111 *************************************************************************/
112
113
operator =(const SwFmt & rFmt)114 SwFmt &SwFmt::operator=(const SwFmt& rFmt)
115 {
116 nWhichId = rFmt.nWhichId;
117 nPoolFmtId = rFmt.GetPoolFmtId();
118 nPoolHelpId = rFmt.GetPoolHelpId();
119 nPoolHlpFileId = rFmt.GetPoolHlpFileId();
120
121 if ( IsInCache() )
122 {
123 SwFrm::GetCache().Delete( this );
124 SetInCache( sal_False );
125 }
126 SetInSwFntCache( sal_False );
127
128 // kopiere nur das Attribut-Delta Array
129 SwAttrSet aOld( *aSet.GetPool(), aSet.GetRanges() ),
130 aNew( *aSet.GetPool(), aSet.GetRanges() );
131 aSet.Intersect_BC( rFmt.aSet, &aOld, &aNew );
132 aSet.Put_BC( rFmt.aSet, &aOld, &aNew );
133
134 // einige Sonderbehandlungen fuer Attribute
135 aSet.SetModifyAtAttr( this );
136
137 // PoolItem-Attr erzeugen fuers Modify !!!
138 if( aOld.Count() )
139 {
140 SwAttrSetChg aChgOld( aSet, aOld );
141 SwAttrSetChg aChgNew( aSet, aNew );
142 ModifyNotification( &aChgOld, &aChgNew ); // alle veraenderten werden verschickt
143 }
144
145 if( GetRegisteredIn() != rFmt.GetRegisteredIn() )
146 {
147 if( GetRegisteredIn() )
148 GetRegisteredInNonConst()->Remove(this);
149 if(rFmt.GetRegisteredIn())
150 {
151 const_cast<SwFmt&>(rFmt).GetRegisteredInNonConst()->Add(this);
152 aSet.SetParent( &rFmt.aSet );
153 }
154 else
155 aSet.SetParent( 0 );
156 }
157 bAutoFmt = rFmt.bAutoFmt;
158 bAutoUpdateFmt = rFmt.bAutoUpdateFmt;
159 return *this;
160 }
161
SetName(const String & rNewName,sal_Bool bBroadcast)162 void SwFmt::SetName( const String& rNewName, sal_Bool bBroadcast )
163 {
164 ASSERT(!IsDefault(), "SetName: Defaultformat" );
165 if( bBroadcast )
166 {
167 SwStringMsgPoolItem aOld( RES_NAME_CHANGED, aFmtName );
168 SwStringMsgPoolItem aNew( RES_NAME_CHANGED, rNewName );
169 aFmtName = rNewName;
170 ModifyNotification( &aOld, &aNew );
171 }
172 else
173 {
174 aFmtName = rNewName;
175 }
176 }
177
178 /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
179 * diese Funktion wird in jedem Copy-Ctor gerufen, damit die
180 * Attribute kopiert werden. Diese koennen erst kopiert werden,
181 * wenn die abgeleitet Klasse existiert, denn beim Setzen der
182 * Attribute wird die Which()-Methode gerufen, die hier in der
183 * Basis-Klasse auf 0 defaultet ist.
184 *
185 * Zusatz: JP 8.4.1994
186 * Wird ueber Dokumentgrenzen kopiert, so muss das neue Dokument
187 * mit angeben werden, in dem this steht. Z.Z. ist das fuers
188 * DropCaps wichtig, dieses haelt Daten, die tief kopiert werden
189 * muessen !!
190 * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
191
192
CopyAttrs(const SwFmt & rFmt,sal_Bool bReplace)193 void SwFmt::CopyAttrs( const SwFmt& rFmt, sal_Bool bReplace )
194 {
195 // kopiere nur das Attribut-Delta Array
196
197 if ( IsInCache() )
198 {
199 SwFrm::GetCache().Delete( this );
200 SetInCache( sal_False );
201 }
202 SetInSwFntCache( sal_False );
203
204 // Sonderbehandlung fuer einige Attribute
205 SwAttrSet* pChgSet = (SwAttrSet*)&rFmt.aSet;
206
207 if( !bReplace ) // nur die neu, die nicht gesetzt sind ??
208 {
209 if( pChgSet == (SwAttrSet*)&rFmt.aSet ) // Set hier kopieren
210 pChgSet = new SwAttrSet( rFmt.aSet );
211 pChgSet->Differentiate( aSet );
212 }
213
214 // kopiere nur das Attribut-Delta Array
215 if( pChgSet->GetPool() != aSet.GetPool() )
216 pChgSet->CopyToModify( *this );
217 else
218 {
219 SwAttrSet aOld( *aSet.GetPool(), aSet.GetRanges() ),
220 aNew( *aSet.GetPool(), aSet.GetRanges() );
221
222 if ( 0 != aSet.Put_BC( *pChgSet, &aOld, &aNew ) )
223 {
224 // einige Sonderbehandlungen fuer Attribute
225 aSet.SetModifyAtAttr( this );
226
227 SwAttrSetChg aChgOld( aSet, aOld );
228 SwAttrSetChg aChgNew( aSet, aNew );
229 ModifyNotification( &aChgOld, &aChgNew ); // alle veraenderten werden verschickt
230 }
231 }
232
233 if( pChgSet != (SwAttrSet*)&rFmt.aSet ) // Set hier angelegt ?
234 delete pChgSet;
235 }
236
237 /*************************************************************************
238 |* SwFmt::~SwFmt()
239 |*
240 |* Beschreibung Dokument 1.14
241 |* Ersterstellung JP 22.11.90
242 |* Letzte Aenderung JP 14.02.91
243 *************************************************************************/
244
245
~SwFmt()246 SwFmt::~SwFmt()
247 {
248 /* das passiert bei der ObjectDying Message */
249 /* alle Abhaengigen auf DerivedFrom umhaengen */
250 if( GetDepends() )
251 {
252 ASSERT(DerivedFrom(), "SwFmt::~SwFmt: Def Abhaengige!" );
253
254 bFmtInDTOR = sal_True;
255
256 SwFmt *pParentFmt = DerivedFrom();
257 if (!pParentFmt) // see #112405#
258 {
259 DBG_ERROR( "~SwFmt: parent format missing" );
260 }
261 else
262 {
263 while( GetDepends() && pParentFmt)
264 {
265 SwFmtChg aOldFmt(this);
266 SwFmtChg aNewFmt(pParentFmt);
267 SwClient * pDepend = (SwClient*)GetDepends();
268 pParentFmt->Add(pDepend);
269 pDepend->ModifyNotification(&aOldFmt, &aNewFmt);
270 }
271 }
272 }
273 }
274
275
276 /*************************************************************************
277 |* void SwFmt::Modify( const SfxPoolItem* pOldValue, const SfxPoolItem* pNewValue )
278 |*
279 |* Beschreibung Dokument 1.14
280 |* Ersterstellung JP 22.11.90
281 |* Letzte Aenderung JP 05.08.94
282 *************************************************************************/
283
284
Modify(const SfxPoolItem * pOldValue,const SfxPoolItem * pNewValue)285 void SwFmt::Modify( const SfxPoolItem* pOldValue, const SfxPoolItem* pNewValue )
286 {
287 sal_Bool bWeiter = sal_True; // sal_True = Propagierung an die Abhaengigen
288
289 sal_uInt16 nWhich = pOldValue ? pOldValue->Which() :
290 pNewValue ? pNewValue->Which() : 0 ;
291 switch( nWhich )
292 {
293 case 0: break; // Which-Id von 0 ???
294
295 case RES_OBJECTDYING :
296 {
297 // ist das sterbende Object das "Parent"-Format von diesen Format,
298 // dann haengt sich dieses Format an den Parent vom Parent
299 SwFmt * pFmt = (SwFmt *) ((SwPtrMsgPoolItem *)pNewValue)->pObject;
300
301 // nicht umhaengen wenn dieses das oberste Format ist !!
302 if( GetRegisteredIn() && GetRegisteredIn() == pFmt )
303 {
304 if( pFmt->GetRegisteredIn() )
305 {
306 // wenn Parent, dann im neuen Parent wieder anmelden
307 pFmt->DerivedFrom()->Add( this );
308 aSet.SetParent( &DerivedFrom()->aSet );
309 }
310 else
311 {
312 // sonst auf jeden Fall beim sterbenden abmelden
313 DerivedFrom()->Remove( this );
314 aSet.SetParent( 0 );
315 }
316 }
317 } // OBJECTDYING
318 break;
319
320 case RES_ATTRSET_CHG:
321 if( ((SwAttrSetChg*)pOldValue)->GetTheChgdSet() != &aSet )
322 {
323 //nur die weiter geben, die hier nicht gesetzt sind !!
324 SwAttrSetChg aOld( *(SwAttrSetChg*)pOldValue );
325 SwAttrSetChg aNew( *(SwAttrSetChg*)pNewValue );
326
327 aOld.GetChgSet()->Differentiate( aSet );
328 aNew.GetChgSet()->Differentiate( aSet );
329
330 if( aNew.Count() )
331 // keine mehr gesetzt, dann Ende !!
332 NotifyClients( &aOld, &aNew );
333 bWeiter = sal_False;
334 }
335 break;
336 case RES_FMT_CHG:
337 // falls mein Format Parent umgesetzt wird, dann melde ich
338 // meinen Attrset beim Neuen an.
339
340 // sein eigenes Modify ueberspringen !!
341 if( ((SwFmtChg*)pOldValue)->pChangedFmt != this &&
342 ((SwFmtChg*)pNewValue)->pChangedFmt == DerivedFrom() )
343 {
344 // den Set an den neuen Parent haengen
345 aSet.SetParent( DerivedFrom() ? &DerivedFrom()->aSet : 0 );
346 }
347 break;
348
349 case RES_RESET_FMTWRITTEN:
350 {
351 // IsWritten-Flag zuruecksetzen. Hint nur an abhanegige
352 // Formate (und keine Frames) propagieren.
353 // mba: the code does the opposite from what is written in the comment!
354 ResetWritten();
355 // mba: here we don't use the additional stuff from NotifyClients().
356 // should we?!
357 // mba: move the code that ignores this event to the clients
358 ModifyBroadcast( pOldValue, pNewValue, TYPE(SwFmt) );
359 bWeiter = sal_False;
360 }
361 break;
362
363 default:
364 {
365 // Ist das Attribut in diesem Format definiert, dann auf
366 // NICHT weiter propagieren !!
367 if( SFX_ITEM_SET == aSet.GetItemState( nWhich, sal_False ))
368 {
369 // wie finde ich heraus, ob nicht ich die Message versende ??
370 // aber wer ruft das hier ????
371 //ASSERT( sal_False, "Modify ohne Absender verschickt" );
372 //JP 11.06.96: DropCaps koennen hierher kommen
373 ASSERT( RES_PARATR_DROP == nWhich, "Modify ohne Absender verschickt" );
374 bWeiter = sal_False;
375 }
376
377 } // default
378 } // switch
379
380 if( bWeiter )
381 {
382 // laufe durch alle abhaengigen Formate
383 NotifyClients( pOldValue, pNewValue );
384 }
385
386 }
387
388
SetDerivedFrom(SwFmt * pDerFrom)389 sal_Bool SwFmt::SetDerivedFrom(SwFmt *pDerFrom)
390 {
391 if ( pDerFrom )
392 {
393 // Zyklus?
394 const SwFmt* pFmt = pDerFrom;
395 while ( pFmt != 0 )
396 {
397 if ( pFmt == this )
398 return sal_False;
399
400 pFmt=pFmt->DerivedFrom();
401 }
402 }
403 else
404 {
405 // Nichts angegeben, Dflt-Format suchen
406 pDerFrom = this;
407 while ( pDerFrom->DerivedFrom() )
408 pDerFrom = pDerFrom->DerivedFrom();
409 }
410 if ( (pDerFrom == DerivedFrom()) || (pDerFrom == this) )
411 return sal_False;
412
413 ASSERT( Which()==pDerFrom->Which()
414 || ( Which()==RES_CONDTXTFMTCOLL && pDerFrom->Which()==RES_TXTFMTCOLL)
415 || ( Which()==RES_TXTFMTCOLL && pDerFrom->Which()==RES_CONDTXTFMTCOLL)
416 || ( Which()==RES_FLYFRMFMT && pDerFrom->Which()==RES_FRMFMT ),
417 "SetDerivedFrom: Aepfel von Birnen ableiten?");
418
419 if ( IsInCache() )
420 {
421 SwFrm::GetCache().Delete( this );
422 SetInCache( sal_False );
423 }
424 SetInSwFntCache( sal_False );
425
426 pDerFrom->Add(this);
427 aSet.SetParent( &pDerFrom->aSet );
428
429 SwFmtChg aOldFmt(this);
430 SwFmtChg aNewFmt(this);
431 ModifyNotification( &aOldFmt, &aNewFmt );
432
433 return sal_True;
434 }
435
436
GetFmtAttr(sal_uInt16 nWhich,sal_Bool bInParents) const437 const SfxPoolItem& SwFmt::GetFmtAttr( sal_uInt16 nWhich, sal_Bool bInParents ) const
438 {
439 if(RES_BACKGROUND == nWhich && supportsFullDrawingLayerFillAttributeSet())
440 {
441 //UUUU FALLBACKBREAKHERE should not be used; instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST]
442 OSL_ENSURE(false, "Do no longer use SvxBrushItem, instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST] FillAttributes (simple fallback is in place and used)");
443 static SvxBrushItem aSvxBrushItem(RES_BACKGROUND);
444
445 // fill the local static SvxBrushItem from the current ItemSet so that
446 // the fill attributes [XATTR_FILL_FIRST .. XATTR_FILL_LAST] are used
447 // as good as possible to create a fallback representation and return that
448 aSvxBrushItem = getSvxBrushItemFromSourceSet(aSet, RES_BACKGROUND, bInParents);
449
450 return aSvxBrushItem;
451 }
452
453 return aSet.Get( nWhich, bInParents );
454 }
455
456
GetItemState(sal_uInt16 nWhich,sal_Bool bSrchInParent,const SfxPoolItem ** ppItem) const457 SfxItemState SwFmt::GetItemState( sal_uInt16 nWhich, sal_Bool bSrchInParent, const SfxPoolItem **ppItem ) const
458 {
459 if(RES_BACKGROUND == nWhich && supportsFullDrawingLayerFillAttributeSet())
460 {
461 //UUUU FALLBACKBREAKHERE should not be used; instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST]
462 OSL_ENSURE(false, "Do no longer use SvxBrushItem, instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST] FillAttributes (simple fallback is in place and used)");
463 const drawinglayer::attribute::SdrAllFillAttributesHelperPtr aFill = getSdrAllFillAttributesHelper();
464
465 // check if the new fill attributes are used
466 if(aFill.get() && aFill->isUsed())
467 {
468 // if yes, fill the local SvxBrushItem using the new fill attributes
469 // as good as possible to have an instance for the pointer to point
470 // to and return as state that it is set
471 static SvxBrushItem aSvxBrushItem(RES_BACKGROUND);
472
473 aSvxBrushItem = getSvxBrushItemFromSourceSet(aSet, RES_BACKGROUND, bSrchInParent);
474 if( ppItem )
475 *ppItem = &aSvxBrushItem;
476
477 return SFX_ITEM_SET;
478 }
479
480 // if not, reset pointer and return SFX_ITEM_DEFAULT to signal that
481 // the item is not set
482 if( ppItem )
483 *ppItem = NULL;
484
485 return SFX_ITEM_DEFAULT;
486 }
487
488 return aSet.GetItemState( nWhich, bSrchInParent, ppItem );
489 }
490
491
SetFmtAttr(const SfxPoolItem & rAttr)492 sal_Bool SwFmt::SetFmtAttr(const SfxPoolItem& rAttr )
493 {
494 if ( IsInCache() || IsInSwFntCache() )
495 {
496 const sal_uInt16 nWhich = rAttr.Which();
497 CheckCaching( nWhich );
498 }
499
500 sal_Bool bRet = sal_False;
501
502 //UUUU
503 if(RES_BACKGROUND == rAttr.Which() && supportsFullDrawingLayerFillAttributeSet())
504 {
505 //UUUU FALLBACKBREAKHERE should not be used; instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST]
506 OSL_ENSURE(false, "Do no longer use SvxBrushItem, instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST] FillAttributes (simple fallback is in place and used)");
507 SfxItemSet aTempSet(*aSet.GetPool(), XATTR_FILL_FIRST, XATTR_FILL_LAST, 0, 0);
508 const SvxBrushItem& rSource = static_cast< const SvxBrushItem& >(rAttr);
509
510 // fill a local ItemSet with the attributes corresponding as good as possible
511 // to the new fill properties [XATTR_FILL_FIRST .. XATTR_FILL_LAST] and set these
512 // as ItemSet
513 setSvxBrushItemAsFillAttributesToTargetSet(rSource, aTempSet);
514
515 if(IsModifyLocked())
516 {
517 if( 0 != ( bRet = (0 != aSet.Put( aTempSet ))) )
518 {
519 aSet.SetModifyAtAttr( this );
520 }
521 }
522 else
523 {
524 SwAttrSet aOld(*aSet.GetPool(), aSet.GetRanges()), aNew(*aSet.GetPool(), aSet.GetRanges());
525
526 bRet = 0 != aSet.Put_BC(aTempSet, &aOld, &aNew);
527
528 if(bRet)
529 {
530 aSet.SetModifyAtAttr(this);
531
532 SwAttrSetChg aChgOld(aSet, aOld);
533 SwAttrSetChg aChgNew(aSet, aNew);
534
535 ModifyNotification(&aChgOld, &aChgNew);
536 }
537 }
538
539 return bRet;
540 }
541
542 // wenn Modify gelockt ist, werden keine Modifies verschickt;
543 // fuer FrmFmt's immer das Modify verschicken!
544 const sal_uInt16 nFmtWhich = Which();
545 if( IsModifyLocked() || (!GetDepends() &&
546 (RES_GRFFMTCOLL == nFmtWhich ||
547 RES_TXTFMTCOLL == nFmtWhich ) ) )
548 {
549 if( 0 != ( bRet = (0 != aSet.Put( rAttr ))) )
550 aSet.SetModifyAtAttr( this );
551 if ( nFmtWhich == RES_TXTFMTCOLL && rAttr.Which() == RES_PARATR_NUMRULE )
552 {
553 TxtFmtCollFunc::CheckTxtFmtCollForDeletionOfAssignmentToOutlineStyle( this );
554 }
555 }
556 else
557 {
558 // kopiere nur das Attribut-Delta Array
559 SwAttrSet aOld( *aSet.GetPool(), aSet.GetRanges() ),
560 aNew( *aSet.GetPool(), aSet.GetRanges() );
561
562 bRet = 0 != aSet.Put_BC( rAttr, &aOld, &aNew );
563 if( bRet )
564 {
565 // einige Sonderbehandlungen fuer Attribute
566 aSet.SetModifyAtAttr( this );
567
568 SwAttrSetChg aChgOld( aSet, aOld );
569 SwAttrSetChg aChgNew( aSet, aNew );
570 ModifyNotification( &aChgOld, &aChgNew ); // alle veraenderten werden verschickt
571 }
572 }
573 return bRet;
574 }
575
576
SetFmtAttr(const SfxItemSet & rSet)577 sal_Bool SwFmt::SetFmtAttr( const SfxItemSet& rSet )
578 {
579 if( !rSet.Count() )
580 return sal_False;
581
582 if ( IsInCache() )
583 {
584 SwFrm::GetCache().Delete( this );
585 SetInCache( sal_False );
586 }
587 SetInSwFntCache( sal_False );
588
589 sal_Bool bRet = sal_False;
590
591 //UUUU Use local copy to be able to apply needed changes, e.g. call
592 // CheckForUniqueItemForLineFillNameOrIndex which is needed for NameOrIndex stuff
593 SfxItemSet aTempSet(rSet);
594
595 //UUUU Need to check for unique item for DrawingLayer items of type NameOrIndex
596 // and evtl. correct that item to ensure unique names for that type. This call may
597 // modify/correct entries inside of the given SfxItemSet
598 if(GetDoc())
599 {
600 GetDoc()->CheckForUniqueItemForLineFillNameOrIndex(aTempSet);
601 }
602
603 //UUUU FlyFrame PageStyle
604 if(supportsFullDrawingLayerFillAttributeSet())
605 {
606 const SfxPoolItem* pSource = 0;
607
608 if(SFX_ITEM_SET == aTempSet.GetItemState(RES_BACKGROUND, sal_False, &pSource))
609 {
610 //UUUU FALLBACKBREAKHERE should not be used; instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST]
611 OSL_ENSURE(false, "Do no longer use SvxBrushItem, instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST] FillAttributes (simple fallback is in place and used)");
612
613 // copy all items to be set anyways to a local ItemSet with is also prepared for the new
614 // fill attribute ranges [XATTR_FILL_FIRST .. XATTR_FILL_LAST]. Add the attributes
615 // corresponding as good as possible to the new fill properties and set the whole ItemSet
616 const SvxBrushItem& rSource(static_cast< const SvxBrushItem& >(*pSource));
617 setSvxBrushItemAsFillAttributesToTargetSet(rSource, aTempSet);
618
619 if(IsModifyLocked())
620 {
621 if( 0 != ( bRet = (0 != aSet.Put( aTempSet ))) )
622 {
623 aSet.SetModifyAtAttr( this );
624 }
625 }
626 else
627 {
628 SwAttrSet aOld(*aSet.GetPool(), aSet.GetRanges()), aNew(*aSet.GetPool(), aSet.GetRanges());
629
630 bRet = 0 != aSet.Put_BC(aTempSet, &aOld, &aNew);
631
632 if(bRet)
633 {
634 aSet.SetModifyAtAttr(this);
635
636 SwAttrSetChg aChgOld(aSet, aOld);
637 SwAttrSetChg aChgNew(aSet, aNew);
638
639 ModifyNotification(&aChgOld, &aChgNew);
640 }
641 }
642
643 return bRet;
644 }
645 }
646
647 // wenn Modify gelockt ist, werden keine Modifies verschickt;
648 // fuer FrmFmt's immer das Modify verschicken!
649 const sal_uInt16 nFmtWhich = Which();
650 if ( IsModifyLocked() ||
651 ( !GetDepends() &&
652 ( RES_GRFFMTCOLL == nFmtWhich ||
653 RES_TXTFMTCOLL == nFmtWhich ) ) )
654 {
655 if( 0 != ( bRet = (0 != aSet.Put( aTempSet ))) )
656 aSet.SetModifyAtAttr( this );
657 if ( nFmtWhich == RES_TXTFMTCOLL )
658 {
659 TxtFmtCollFunc::CheckTxtFmtCollForDeletionOfAssignmentToOutlineStyle( this );
660 }
661 }
662 else
663 {
664 SwAttrSet aOld( *aSet.GetPool(), aSet.GetRanges() ),
665 aNew( *aSet.GetPool(), aSet.GetRanges() );
666 bRet = 0 != aSet.Put_BC( aTempSet, &aOld, &aNew );
667 if( bRet )
668 {
669 // einige Sonderbehandlungen fuer Attribute
670 aSet.SetModifyAtAttr( this );
671 SwAttrSetChg aChgOld( aSet, aOld );
672 SwAttrSetChg aChgNew( aSet, aNew );
673 ModifyNotification( &aChgOld, &aChgNew ); // alle veraenderten werden verschickt
674 }
675 }
676 return bRet;
677 }
678
679 // Nimmt den Hint mit nWhich aus dem Delta-Array
680
681
ResetFmtAttr(sal_uInt16 nWhich1,sal_uInt16 nWhich2)682 sal_Bool SwFmt::ResetFmtAttr( sal_uInt16 nWhich1, sal_uInt16 nWhich2 )
683 {
684 if( !aSet.Count() )
685 return sal_False;
686
687 if( !nWhich2 || nWhich2 < nWhich1 )
688 nWhich2 = nWhich1; // dann setze auf 1. Id, nur dieses Item
689
690 if ( IsInCache() || IsInSwFntCache() )
691 {
692 for( sal_uInt16 n = nWhich1; n < nWhich2; ++n )
693 CheckCaching( n );
694 }
695
696 // wenn Modify gelockt ist, werden keine Modifies verschickt
697 if( IsModifyLocked() )
698 return 0 != (( nWhich2 == nWhich1 )
699 ? aSet.ClearItem( nWhich1 )
700 : aSet.ClearItem_BC( nWhich1, nWhich2 ));
701
702 SwAttrSet aOld( *aSet.GetPool(), aSet.GetRanges() ),
703 aNew( *aSet.GetPool(), aSet.GetRanges() );
704 sal_Bool bRet = 0 != aSet.ClearItem_BC( nWhich1, nWhich2, &aOld, &aNew );
705
706 if( bRet )
707 {
708 SwAttrSetChg aChgOld( aSet, aOld );
709 SwAttrSetChg aChgNew( aSet, aNew );
710 ModifyNotification( &aChgOld, &aChgNew ); // alle veraenderten werden verschickt
711 }
712 return bRet;
713 }
714
715
716
717 // --> OD 2007-01-24 #i73790#
718 // method renamed
ResetAllFmtAttr()719 sal_uInt16 SwFmt::ResetAllFmtAttr()
720 // <--
721 {
722 if( !aSet.Count() )
723 return 0;
724
725 if ( IsInCache() )
726 {
727 SwFrm::GetCache().Delete( this );
728 SetInCache( sal_False );
729 }
730 SetInSwFntCache( sal_False );
731
732 // wenn Modify gelockt ist, werden keine Modifies verschickt
733 if( IsModifyLocked() )
734 return aSet.ClearItem( 0 );
735
736 SwAttrSet aOld( *aSet.GetPool(), aSet.GetRanges() ),
737 aNew( *aSet.GetPool(), aSet.GetRanges() );
738 sal_Bool bRet = 0 != aSet.ClearItem_BC( 0, &aOld, &aNew );
739
740 if( bRet )
741 {
742 SwAttrSetChg aChgOld( aSet, aOld );
743 SwAttrSetChg aChgNew( aSet, aNew );
744 ModifyNotification( &aChgOld, &aChgNew ); // alle veraenderten werden verschickt
745 }
746 return aNew.Count();
747 }
748
749
750 /*************************************************************************
751 |* void SwFmt::GetInfo( const SfxPoolItem& ) const
752 |*
753 |* Beschreibung
754 |* Ersterstellung JP 18.04.94
755 |* Letzte Aenderung JP 05.08.94
756 *************************************************************************/
757
758
GetInfo(SfxPoolItem & rInfo) const759 sal_Bool SwFmt::GetInfo( SfxPoolItem& rInfo ) const
760 {
761 sal_Bool bRet = SwModify::GetInfo( rInfo );
762 return bRet;
763 }
764
765
DelDiffs(const SfxItemSet & rSet)766 void SwFmt::DelDiffs( const SfxItemSet& rSet )
767 {
768 if( !aSet.Count() )
769 return;
770
771 if ( IsInCache() )
772 {
773 SwFrm::GetCache().Delete( this );
774 SetInCache( sal_False );
775 }
776 SetInSwFntCache( sal_False );
777
778 // wenn Modify gelockt ist, werden keine Modifies verschickt
779 if( IsModifyLocked() )
780 {
781 aSet.Intersect( rSet );
782 return;
783 }
784
785 SwAttrSet aOld( *aSet.GetPool(), aSet.GetRanges() ),
786 aNew( *aSet.GetPool(), aSet.GetRanges() );
787 sal_Bool bRet = 0 != aSet.Intersect_BC( rSet, &aOld, &aNew );
788
789 if( bRet )
790 {
791 SwAttrSetChg aChgOld( aSet, aOld );
792 SwAttrSetChg aChgNew( aSet, aNew );
793 ModifyNotification( &aChgOld, &aChgNew ); // alle veraenderten werden verschickt
794 }
795 }
796
797 /** SwFmt::IsBackgroundTransparent - for feature #99657#
798
799 OD 22.08.2002
800 Virtual method to determine, if background of format is transparent.
801 Default implementation returns false. Thus, subclasses have to overload
802 method, if the specific subclass can have a transparent background.
803
804 @author OD
805
806 @return false, default implementation
807 */
IsBackgroundTransparent() const808 sal_Bool SwFmt::IsBackgroundTransparent() const
809 {
810 return sal_False;
811 }
812
813 /** SwFmt::IsShadowTransparent - for feature #99657#
814
815 OD 22.08.2002
816 Virtual method to determine, if shadow of format is transparent.
817 Default implementation returns false. Thus, subclasses have to overload
818 method, if the specific subclass can have a transparent shadow.
819
820 @author OD
821
822 @return false, default implementation
823 */
IsShadowTransparent() const824 sal_Bool SwFmt::IsShadowTransparent() const
825 {
826 return sal_False;
827 }
828
829 /*
830 * Document Interface Access
831 */
getIDocumentSettingAccess() const832 const IDocumentSettingAccess* SwFmt::getIDocumentSettingAccess() const { return GetDoc(); }
getIDocumentDrawModelAccess() const833 const IDocumentDrawModelAccess* SwFmt::getIDocumentDrawModelAccess() const { return GetDoc(); }
getIDocumentDrawModelAccess()834 IDocumentDrawModelAccess* SwFmt::getIDocumentDrawModelAccess() { return GetDoc(); }
getIDocumentLayoutAccess() const835 const IDocumentLayoutAccess* SwFmt::getIDocumentLayoutAccess() const { return GetDoc(); }
getIDocumentLayoutAccess()836 IDocumentLayoutAccess* SwFmt::getIDocumentLayoutAccess() { return GetDoc(); }
getIDocumentTimerAccess()837 IDocumentTimerAccess* SwFmt::getIDocumentTimerAccess() { return GetDoc(); }
getIDocumentFieldsAccess()838 IDocumentFieldsAccess* SwFmt::getIDocumentFieldsAccess() { return GetDoc(); }
getIDocumentChartDataProviderAccess()839 IDocumentChartDataProviderAccess* SwFmt::getIDocumentChartDataProviderAccess() { return GetDoc(); }
840
841 //UUUU
GetBackground(sal_Bool bInP) const842 const SvxBrushItem& SwFmt::GetBackground(sal_Bool bInP) const
843 {
844 //UUUU FlyFrame PageStyle
845 if(supportsFullDrawingLayerFillAttributeSet())
846 {
847 //UUUU FALLBACKBREAKHERE should not be used; instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST]
848 OSL_ENSURE(false, "Do no longer use SvxBrushItem, instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST] FillAttributes (simple fallback is in place and used)");
849 static SvxBrushItem aSvxBrushItem(RES_BACKGROUND);
850
851 // fill the local static SvxBrushItem from the current ItemSet so that
852 // the fill attributes [XATTR_FILL_FIRST .. XATTR_FILL_LAST] are used
853 // as good as possible to create a fallback representation and return that
854 aSvxBrushItem = getSvxBrushItemFromSourceSet(aSet, RES_BACKGROUND, bInP);
855
856 return aSvxBrushItem;
857 }
858
859 return aSet.GetBackground(bInP);
860 }
861
862 //UUUU
supportsFullDrawingLayerFillAttributeSet() const863 bool SwFmt::supportsFullDrawingLayerFillAttributeSet() const
864 {
865 // base definition - probably not completely correct, e.g. for Table FillStyles
866 //UUUU FlyFrame PageStyle
867 return (RES_FLYFRMFMT == Which() || RES_FRMFMT == Which());
868 }
869
870 //UUUU
getSdrAllFillAttributesHelper() const871 drawinglayer::attribute::SdrAllFillAttributesHelperPtr SwFmt::getSdrAllFillAttributesHelper() const
872 {
873 return drawinglayer::attribute::SdrAllFillAttributesHelperPtr();
874 }
875
876 // eof
877