xref: /trunk/main/sw/source/core/attr/format.cxx (revision 26ea3662d86be9f95232e6ac21c3a47954d21453)
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             *ppItem = &aSvxBrushItem;
475 
476             return SFX_ITEM_SET;
477         }
478 
479         // if not, reset pointer and return SFX_ITEM_DEFAULT to signal that
480         // the item is not set
481         *ppItem = 0;
482 
483         return SFX_ITEM_DEFAULT;
484     }
485 
486     return aSet.GetItemState( nWhich, bSrchInParent, ppItem );
487 }
488 
489 
490 sal_Bool SwFmt::SetFmtAttr(const SfxPoolItem& rAttr )
491 {
492     if ( IsInCache() || IsInSwFntCache() )
493     {
494         const sal_uInt16 nWhich = rAttr.Which();
495         CheckCaching( nWhich );
496     }
497 
498     sal_Bool bRet = sal_False;
499 
500     //UUUU
501     if(RES_BACKGROUND == rAttr.Which() && (RES_FLYFRMFMT == Which() || RES_FRMFMT == Which()))
502     {
503         //UUUU FALLBACKBREAKHERE should not be used; instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST]
504         OSL_ENSURE(false, "Do no longer use SvxBrushItem, instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST] FillAttributes (simple fallback is in place and used)");
505         SfxItemSet aTempSet(*aSet.GetPool(), XATTR_FILL_FIRST, XATTR_FILL_LAST, 0, 0);
506         const SvxBrushItem& rSource = static_cast< const SvxBrushItem& >(rAttr);
507 
508         // fill a local ItemSet with the attributes corresponding as good as possible
509         // to the new fill properties [XATTR_FILL_FIRST .. XATTR_FILL_LAST] and set these
510         // as ItemSet
511         setSvxBrushItemAsFillAttributesToTargetSet(rSource, aTempSet);
512 
513         if(IsModifyLocked())
514         {
515             if( 0 != ( bRet = (0 != aSet.Put( aTempSet ))) )
516             {
517                 aSet.SetModifyAtAttr( this );
518             }
519         }
520         else
521         {
522             SwAttrSet aOld(*aSet.GetPool(), aSet.GetRanges()), aNew(*aSet.GetPool(), aSet.GetRanges());
523 
524             bRet = 0 != aSet.Put_BC(aTempSet, &aOld, &aNew);
525 
526             if(bRet)
527             {
528                 aSet.SetModifyAtAttr(this);
529 
530                 SwAttrSetChg aChgOld(aSet, aOld);
531                 SwAttrSetChg aChgNew(aSet, aNew);
532 
533                 ModifyNotification(&aChgOld, &aChgNew);
534             }
535         }
536 
537         return bRet;
538     }
539 
540     // wenn Modify gelockt ist, werden keine Modifies verschickt;
541     // fuer FrmFmt's immer das Modify verschicken!
542     const sal_uInt16 nFmtWhich = Which();
543     if( IsModifyLocked() || (!GetDepends() &&
544         (RES_GRFFMTCOLL == nFmtWhich  ||
545          RES_TXTFMTCOLL == nFmtWhich ) ) )
546     {
547         if( 0 != ( bRet = (0 != aSet.Put( rAttr ))) )
548             aSet.SetModifyAtAttr( this );
549         // --> OD 2006-11-22 #i71574#
550         if ( nFmtWhich == RES_TXTFMTCOLL && rAttr.Which() == RES_PARATR_NUMRULE )
551         {
552             TxtFmtCollFunc::CheckTxtFmtCollForDeletionOfAssignmentToOutlineStyle( this );
553         }
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 
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(RES_FLYFRMFMT == Which() || RES_FRMFMT == Which())
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         // --> OD 2006-11-22 #i71574#
658         if ( nFmtWhich == RES_TXTFMTCOLL )
659         {
660             TxtFmtCollFunc::CheckTxtFmtCollForDeletionOfAssignmentToOutlineStyle( this );
661         }
662         // <--
663     }
664     else
665     {
666         SwAttrSet aOld( *aSet.GetPool(), aSet.GetRanges() ),
667                     aNew( *aSet.GetPool(), aSet.GetRanges() );
668         bRet = 0 != aSet.Put_BC( aTempSet, &aOld, &aNew );
669         if( bRet )
670         {
671             // einige Sonderbehandlungen fuer Attribute
672             aSet.SetModifyAtAttr( this );
673             SwAttrSetChg aChgOld( aSet, aOld );
674             SwAttrSetChg aChgNew( aSet, aNew );
675             ModifyNotification( &aChgOld, &aChgNew );       // alle veraenderten werden verschickt
676         }
677     }
678     return bRet;
679 }
680 
681 // Nimmt den Hint mit nWhich aus dem Delta-Array
682 
683 
684 sal_Bool SwFmt::ResetFmtAttr( sal_uInt16 nWhich1, sal_uInt16 nWhich2 )
685 {
686     if( !aSet.Count() )
687         return sal_False;
688 
689     if( !nWhich2 || nWhich2 < nWhich1 )
690         nWhich2 = nWhich1;      // dann setze auf 1. Id, nur dieses Item
691 
692     if ( IsInCache() || IsInSwFntCache() )
693     {
694         for( sal_uInt16 n = nWhich1; n < nWhich2; ++n )
695             CheckCaching( n );
696     }
697 
698     // wenn Modify gelockt ist, werden keine Modifies verschickt
699     if( IsModifyLocked() )
700         return 0 != (( nWhich2 == nWhich1 )
701                 ? aSet.ClearItem( nWhich1 )
702                 : aSet.ClearItem_BC( nWhich1, nWhich2 ));
703 
704     SwAttrSet aOld( *aSet.GetPool(), aSet.GetRanges() ),
705                 aNew( *aSet.GetPool(), aSet.GetRanges() );
706     sal_Bool bRet = 0 != aSet.ClearItem_BC( nWhich1, nWhich2, &aOld, &aNew );
707 
708     if( bRet )
709     {
710         SwAttrSetChg aChgOld( aSet, aOld );
711         SwAttrSetChg aChgNew( aSet, aNew );
712         ModifyNotification( &aChgOld, &aChgNew );       // alle veraenderten werden verschickt
713     }
714     return bRet;
715 }
716 
717 
718 
719 // --> OD 2007-01-24 #i73790#
720 // method renamed
721 sal_uInt16 SwFmt::ResetAllFmtAttr()
722 // <--
723 {
724     if( !aSet.Count() )
725         return 0;
726 
727     if ( IsInCache() )
728     {
729         SwFrm::GetCache().Delete( this );
730         SetInCache( sal_False );
731     }
732     SetInSwFntCache( sal_False );
733 
734     // wenn Modify gelockt ist, werden keine Modifies verschickt
735     if( IsModifyLocked() )
736         return aSet.ClearItem( 0 );
737 
738     SwAttrSet aOld( *aSet.GetPool(), aSet.GetRanges() ),
739                 aNew( *aSet.GetPool(), aSet.GetRanges() );
740     sal_Bool bRet = 0 != aSet.ClearItem_BC( 0, &aOld, &aNew );
741 
742     if( bRet )
743     {
744         SwAttrSetChg aChgOld( aSet, aOld );
745         SwAttrSetChg aChgNew( aSet, aNew );
746         ModifyNotification( &aChgOld, &aChgNew );       // alle veraenderten werden verschickt
747     }
748     return aNew.Count();
749 }
750 
751 
752 /*************************************************************************
753 |*    void SwFmt::GetInfo( const SfxPoolItem& ) const
754 |*
755 |*    Beschreibung
756 |*    Ersterstellung    JP 18.04.94
757 |*    Letzte Aenderung  JP 05.08.94
758 *************************************************************************/
759 
760 
761 sal_Bool SwFmt::GetInfo( SfxPoolItem& rInfo ) const
762 {
763     sal_Bool bRet = SwModify::GetInfo( rInfo );
764     return bRet;
765 }
766 
767 
768 void SwFmt::DelDiffs( const SfxItemSet& rSet )
769 {
770     if( !aSet.Count() )
771         return;
772 
773     if ( IsInCache() )
774     {
775         SwFrm::GetCache().Delete( this );
776         SetInCache( sal_False );
777     }
778     SetInSwFntCache( sal_False );
779 
780     // wenn Modify gelockt ist, werden keine Modifies verschickt
781     if( IsModifyLocked() )
782     {
783         aSet.Intersect( rSet );
784         return;
785     }
786 
787     SwAttrSet aOld( *aSet.GetPool(), aSet.GetRanges() ),
788                 aNew( *aSet.GetPool(), aSet.GetRanges() );
789     sal_Bool bRet = 0 != aSet.Intersect_BC( rSet, &aOld, &aNew );
790 
791     if( bRet )
792     {
793         SwAttrSetChg aChgOld( aSet, aOld );
794         SwAttrSetChg aChgNew( aSet, aNew );
795         ModifyNotification( &aChgOld, &aChgNew );       // alle veraenderten werden verschickt
796     }
797 }
798 
799 /** SwFmt::IsBackgroundTransparent - for feature #99657#
800 
801     OD 22.08.2002
802     Virtual method to determine, if background of format is transparent.
803     Default implementation returns false. Thus, subclasses have to overload
804     method, if the specific subclass can have a transparent background.
805 
806     @author OD
807 
808     @return false, default implementation
809 */
810 sal_Bool SwFmt::IsBackgroundTransparent() const
811 {
812     return sal_False;
813 }
814 
815 /** SwFmt::IsShadowTransparent - for feature #99657#
816 
817     OD 22.08.2002
818     Virtual method to determine, if shadow of format is transparent.
819     Default implementation returns false. Thus, subclasses have to overload
820     method, if the specific subclass can have a transparent shadow.
821 
822     @author OD
823 
824     @return false, default implementation
825 */
826 sal_Bool SwFmt::IsShadowTransparent() const
827 {
828     return sal_False;
829 }
830 
831 /*
832  * Document Interface Access
833  */
834 const IDocumentSettingAccess* SwFmt::getIDocumentSettingAccess() const { return GetDoc(); }
835 const IDocumentDrawModelAccess* SwFmt::getIDocumentDrawModelAccess() const { return GetDoc(); }
836 IDocumentDrawModelAccess* SwFmt::getIDocumentDrawModelAccess() { return GetDoc(); }
837 const IDocumentLayoutAccess* SwFmt::getIDocumentLayoutAccess() const { return GetDoc(); }
838 IDocumentLayoutAccess* SwFmt::getIDocumentLayoutAccess() { return GetDoc(); }
839 IDocumentTimerAccess* SwFmt::getIDocumentTimerAccess() { return GetDoc(); }
840 IDocumentFieldsAccess* SwFmt::getIDocumentFieldsAccess() { return GetDoc(); }
841 IDocumentChartDataProviderAccess* SwFmt::getIDocumentChartDataProviderAccess() { return GetDoc(); }
842 
843 //UUUU
844 const SvxBrushItem& SwFmt::GetBackground(sal_Bool bInP) const
845 {
846     //UUUU   FlyFrame              PageStyle
847     if(RES_FLYFRMFMT == Which() || RES_FRMFMT == Which())
848     {
849         //UUUU FALLBACKBREAKHERE should not be used; instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST]
850         OSL_ENSURE(false, "Do no longer use SvxBrushItem, instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST] FillAttributes (simple fallback is in place and used)");
851         static SvxBrushItem aSvxBrushItem(RES_BACKGROUND);
852 
853         // fill the local static SvxBrushItem from the current ItemSet so that
854         // the fill attributes [XATTR_FILL_FIRST .. XATTR_FILL_LAST] are used
855         // as good as possible to create a fallback representation and return that
856         aSvxBrushItem = getSvxBrushItemFromSourceSet(aSet, RES_BACKGROUND, bInP);
857 
858         return aSvxBrushItem;
859     }
860 
861     return aSet.GetBackground(bInP);
862 }
863 
864 //UUUU
865 drawinglayer::attribute::SdrAllFillAttributesHelperPtr SwFmt::getSdrAllFillAttributesHelper() const
866 {
867     return drawinglayer::attribute::SdrAllFillAttributesHelperPtr();
868 }
869 
870 // eof
871