xref: /trunk/main/sw/source/core/attr/format.cxx (revision 360147c746af828b999244f28f9cb9f00d3d41df)
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 
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 
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 
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 
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 
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 
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 
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 
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 
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 
437 const SfxPoolItem& SwFmt::GetFmtAttr( sal_uInt16 nWhich, sal_Bool bInParents ) const
438 {
439     if(RES_BACKGROUND == nWhich && (RES_FLYFRMFMT == Which() || RES_FRMFMT == Which()))
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 
457 SfxItemState SwFmt::GetItemState( sal_uInt16 nWhich, sal_Bool bSrchInParent, const SfxPoolItem **ppItem ) const
458 {
459     if(RES_BACKGROUND == nWhich && (RES_FLYFRMFMT == Which() || RES_FRMFMT == Which()))
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 
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() && (RES_FLYFRMFMT == Which() || RES_FRMFMT == Which()))
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         // --> OD 2006-11-22 #i71574#
552         if ( nFmtWhich == RES_TXTFMTCOLL && rAttr.Which() == RES_PARATR_NUMRULE )
553         {
554             TxtFmtCollFunc::CheckTxtFmtCollForDeletionOfAssignmentToOutlineStyle( this );
555         }
556         // <--
557     }
558     else
559     {
560         // kopiere nur das Attribut-Delta Array
561         SwAttrSet aOld( *aSet.GetPool(), aSet.GetRanges() ),
562                     aNew( *aSet.GetPool(), aSet.GetRanges() );
563 
564         bRet = 0 != aSet.Put_BC( rAttr, &aOld, &aNew );
565         if( bRet )
566         {
567             // einige Sonderbehandlungen fuer Attribute
568             aSet.SetModifyAtAttr( this );
569 
570             SwAttrSetChg aChgOld( aSet, aOld );
571             SwAttrSetChg aChgNew( aSet, aNew );
572             ModifyNotification( &aChgOld, &aChgNew );       // alle veraenderten werden verschickt
573         }
574     }
575     return bRet;
576 }
577 
578 
579 sal_Bool SwFmt::SetFmtAttr( const SfxItemSet& rSet )
580 {
581     if( !rSet.Count() )
582         return sal_False;
583 
584     if ( IsInCache() )
585     {
586         SwFrm::GetCache().Delete( this );
587         SetInCache( sal_False );
588     }
589     SetInSwFntCache( sal_False );
590 
591     sal_Bool bRet = sal_False;
592 
593     //UUUU Use local copy to be able to apply needed changes, e.g. call
594     // CheckForUniqueItemForLineFillNameOrIndex which is needed for NameOrIndex stuff
595     SfxItemSet aTempSet(rSet);
596 
597     //UUUU Need to check for unique item for DrawingLayer items of type NameOrIndex
598     // and evtl. correct that item to ensure unique names for that type. This call may
599     // modify/correct entries inside of the given SfxItemSet
600     if(GetDoc())
601     {
602         GetDoc()->CheckForUniqueItemForLineFillNameOrIndex(aTempSet);
603     }
604 
605     //UUUU   FlyFrame              PageStyle
606     if(RES_FLYFRMFMT == Which() || RES_FRMFMT == Which())
607     {
608         const SfxPoolItem* pSource = 0;
609 
610         if(SFX_ITEM_SET == aTempSet.GetItemState(RES_BACKGROUND, sal_False, &pSource))
611         {
612             //UUUU FALLBACKBREAKHERE should not be used; instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST]
613             OSL_ENSURE(false, "Do no longer use SvxBrushItem, instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST] FillAttributes (simple fallback is in place and used)");
614 
615             // copy all items to be set anyways to a local ItemSet with is also prepared for the new
616             // fill attribute ranges [XATTR_FILL_FIRST .. XATTR_FILL_LAST]. Add the attributes
617             // corresponding as good as possible to the new fill properties and set the whole ItemSet
618             const SvxBrushItem& rSource(static_cast< const SvxBrushItem& >(*pSource));
619             setSvxBrushItemAsFillAttributesToTargetSet(rSource, aTempSet);
620 
621             if(IsModifyLocked())
622             {
623                 if( 0 != ( bRet = (0 != aSet.Put( aTempSet ))) )
624                 {
625                     aSet.SetModifyAtAttr( this );
626                 }
627             }
628             else
629             {
630                 SwAttrSet aOld(*aSet.GetPool(), aSet.GetRanges()), aNew(*aSet.GetPool(), aSet.GetRanges());
631 
632                 bRet = 0 != aSet.Put_BC(aTempSet, &aOld, &aNew);
633 
634                 if(bRet)
635                 {
636                     aSet.SetModifyAtAttr(this);
637 
638                     SwAttrSetChg aChgOld(aSet, aOld);
639                     SwAttrSetChg aChgNew(aSet, aNew);
640 
641                     ModifyNotification(&aChgOld, &aChgNew);
642                 }
643             }
644 
645             return bRet;
646         }
647     }
648 
649     // wenn Modify gelockt ist, werden keine Modifies verschickt;
650     // fuer FrmFmt's immer das Modify verschicken!
651     const sal_uInt16 nFmtWhich = Which();
652     if ( IsModifyLocked() ||
653          ( !GetDepends() &&
654            ( RES_GRFFMTCOLL == nFmtWhich ||
655              RES_TXTFMTCOLL == nFmtWhich ) ) )
656     {
657         if( 0 != ( bRet = (0 != aSet.Put( aTempSet ))) )
658             aSet.SetModifyAtAttr( this );
659         // --> OD 2006-11-22 #i71574#
660         if ( nFmtWhich == RES_TXTFMTCOLL )
661         {
662             TxtFmtCollFunc::CheckTxtFmtCollForDeletionOfAssignmentToOutlineStyle( this );
663         }
664         // <--
665     }
666     else
667     {
668         SwAttrSet aOld( *aSet.GetPool(), aSet.GetRanges() ),
669                     aNew( *aSet.GetPool(), aSet.GetRanges() );
670         bRet = 0 != aSet.Put_BC( aTempSet, &aOld, &aNew );
671         if( bRet )
672         {
673             // einige Sonderbehandlungen fuer Attribute
674             aSet.SetModifyAtAttr( this );
675             SwAttrSetChg aChgOld( aSet, aOld );
676             SwAttrSetChg aChgNew( aSet, aNew );
677             ModifyNotification( &aChgOld, &aChgNew );       // alle veraenderten werden verschickt
678         }
679     }
680     return bRet;
681 }
682 
683 // Nimmt den Hint mit nWhich aus dem Delta-Array
684 
685 
686 sal_Bool SwFmt::ResetFmtAttr( sal_uInt16 nWhich1, sal_uInt16 nWhich2 )
687 {
688     if( !aSet.Count() )
689         return sal_False;
690 
691     if( !nWhich2 || nWhich2 < nWhich1 )
692         nWhich2 = nWhich1;      // dann setze auf 1. Id, nur dieses Item
693 
694     if ( IsInCache() || IsInSwFntCache() )
695     {
696         for( sal_uInt16 n = nWhich1; n < nWhich2; ++n )
697             CheckCaching( n );
698     }
699 
700     // wenn Modify gelockt ist, werden keine Modifies verschickt
701     if( IsModifyLocked() )
702         return 0 != (( nWhich2 == nWhich1 )
703                 ? aSet.ClearItem( nWhich1 )
704                 : aSet.ClearItem_BC( nWhich1, nWhich2 ));
705 
706     SwAttrSet aOld( *aSet.GetPool(), aSet.GetRanges() ),
707                 aNew( *aSet.GetPool(), aSet.GetRanges() );
708     sal_Bool bRet = 0 != aSet.ClearItem_BC( nWhich1, nWhich2, &aOld, &aNew );
709 
710     if( bRet )
711     {
712         SwAttrSetChg aChgOld( aSet, aOld );
713         SwAttrSetChg aChgNew( aSet, aNew );
714         ModifyNotification( &aChgOld, &aChgNew );       // alle veraenderten werden verschickt
715     }
716     return bRet;
717 }
718 
719 
720 
721 // --> OD 2007-01-24 #i73790#
722 // method renamed
723 sal_uInt16 SwFmt::ResetAllFmtAttr()
724 // <--
725 {
726     if( !aSet.Count() )
727         return 0;
728 
729     if ( IsInCache() )
730     {
731         SwFrm::GetCache().Delete( this );
732         SetInCache( sal_False );
733     }
734     SetInSwFntCache( sal_False );
735 
736     // wenn Modify gelockt ist, werden keine Modifies verschickt
737     if( IsModifyLocked() )
738         return aSet.ClearItem( 0 );
739 
740     SwAttrSet aOld( *aSet.GetPool(), aSet.GetRanges() ),
741                 aNew( *aSet.GetPool(), aSet.GetRanges() );
742     sal_Bool bRet = 0 != aSet.ClearItem_BC( 0, &aOld, &aNew );
743 
744     if( bRet )
745     {
746         SwAttrSetChg aChgOld( aSet, aOld );
747         SwAttrSetChg aChgNew( aSet, aNew );
748         ModifyNotification( &aChgOld, &aChgNew );       // alle veraenderten werden verschickt
749     }
750     return aNew.Count();
751 }
752 
753 
754 /*************************************************************************
755 |*    void SwFmt::GetInfo( const SfxPoolItem& ) const
756 |*
757 |*    Beschreibung
758 |*    Ersterstellung    JP 18.04.94
759 |*    Letzte Aenderung  JP 05.08.94
760 *************************************************************************/
761 
762 
763 sal_Bool SwFmt::GetInfo( SfxPoolItem& rInfo ) const
764 {
765     sal_Bool bRet = SwModify::GetInfo( rInfo );
766     return bRet;
767 }
768 
769 
770 void SwFmt::DelDiffs( const SfxItemSet& rSet )
771 {
772     if( !aSet.Count() )
773         return;
774 
775     if ( IsInCache() )
776     {
777         SwFrm::GetCache().Delete( this );
778         SetInCache( sal_False );
779     }
780     SetInSwFntCache( sal_False );
781 
782     // wenn Modify gelockt ist, werden keine Modifies verschickt
783     if( IsModifyLocked() )
784     {
785         aSet.Intersect( rSet );
786         return;
787     }
788 
789     SwAttrSet aOld( *aSet.GetPool(), aSet.GetRanges() ),
790                 aNew( *aSet.GetPool(), aSet.GetRanges() );
791     sal_Bool bRet = 0 != aSet.Intersect_BC( rSet, &aOld, &aNew );
792 
793     if( bRet )
794     {
795         SwAttrSetChg aChgOld( aSet, aOld );
796         SwAttrSetChg aChgNew( aSet, aNew );
797         ModifyNotification( &aChgOld, &aChgNew );       // alle veraenderten werden verschickt
798     }
799 }
800 
801 /** SwFmt::IsBackgroundTransparent - for feature #99657#
802 
803     OD 22.08.2002
804     Virtual method to determine, if background of format is transparent.
805     Default implementation returns false. Thus, subclasses have to overload
806     method, if the specific subclass can have a transparent background.
807 
808     @author OD
809 
810     @return false, default implementation
811 */
812 sal_Bool SwFmt::IsBackgroundTransparent() const
813 {
814     return sal_False;
815 }
816 
817 /** SwFmt::IsShadowTransparent - for feature #99657#
818 
819     OD 22.08.2002
820     Virtual method to determine, if shadow of format is transparent.
821     Default implementation returns false. Thus, subclasses have to overload
822     method, if the specific subclass can have a transparent shadow.
823 
824     @author OD
825 
826     @return false, default implementation
827 */
828 sal_Bool SwFmt::IsShadowTransparent() const
829 {
830     return sal_False;
831 }
832 
833 /*
834  * Document Interface Access
835  */
836 const IDocumentSettingAccess* SwFmt::getIDocumentSettingAccess() const { return GetDoc(); }
837 const IDocumentDrawModelAccess* SwFmt::getIDocumentDrawModelAccess() const { return GetDoc(); }
838 IDocumentDrawModelAccess* SwFmt::getIDocumentDrawModelAccess() { return GetDoc(); }
839 const IDocumentLayoutAccess* SwFmt::getIDocumentLayoutAccess() const { return GetDoc(); }
840 IDocumentLayoutAccess* SwFmt::getIDocumentLayoutAccess() { return GetDoc(); }
841 IDocumentTimerAccess* SwFmt::getIDocumentTimerAccess() { return GetDoc(); }
842 IDocumentFieldsAccess* SwFmt::getIDocumentFieldsAccess() { return GetDoc(); }
843 IDocumentChartDataProviderAccess* SwFmt::getIDocumentChartDataProviderAccess() { return GetDoc(); }
844 
845 //UUUU
846 const SvxBrushItem& SwFmt::GetBackground(sal_Bool bInP) const
847 {
848     //UUUU   FlyFrame              PageStyle
849     if(RES_FLYFRMFMT == Which() || RES_FRMFMT == Which())
850     {
851         //UUUU FALLBACKBREAKHERE should not be used; instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST]
852         OSL_ENSURE(false, "Do no longer use SvxBrushItem, instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST] FillAttributes (simple fallback is in place and used)");
853         static SvxBrushItem aSvxBrushItem(RES_BACKGROUND);
854 
855         // fill the local static SvxBrushItem from the current ItemSet so that
856         // the fill attributes [XATTR_FILL_FIRST .. XATTR_FILL_LAST] are used
857         // as good as possible to create a fallback representation and return that
858         aSvxBrushItem = getSvxBrushItemFromSourceSet(aSet, RES_BACKGROUND, bInP);
859 
860         return aSvxBrushItem;
861     }
862 
863     return aSet.GetBackground(bInP);
864 }
865 
866 //UUUU
867 drawinglayer::attribute::SdrAllFillAttributesHelperPtr SwFmt::getSdrAllFillAttributesHelper() const
868 {
869     return drawinglayer::attribute::SdrAllFillAttributesHelperPtr();
870 }
871 
872 // eof
873