xref: /trunk/main/sw/source/core/attr/format.cxx (revision a893be29343ee97512d484e6e8fefa91df2b44cb)
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 //UUUU
34 #include <unobrushitemhelper.hxx>
35 #include <svx/xdef.hxx>
36 #include <frmatr.hxx>
37 
38 TYPEINIT1( SwFmt, SwClient );   //rtti fuer SwFmt
39 
40 /*************************************************************************
41 |*    SwFmt::SwFmt
42 *************************************************************************/
43 
44 
45 SwFmt::SwFmt( SwAttrPool& rPool, const sal_Char* pFmtNm,
46             const sal_uInt16* pWhichRanges, SwFmt *pDrvdFrm, sal_uInt16 nFmtWhich )
47     : SwModify( pDrvdFrm ),
48     aSet( rPool, pWhichRanges ),
49     nWhichId( nFmtWhich ),
50     nFmtId( 0 ),
51     nPoolFmtId( USHRT_MAX ),
52     nPoolHelpId( USHRT_MAX ),
53     nPoolHlpFileId( UCHAR_MAX )
54 {
55     aFmtName.AssignAscii( pFmtNm );
56     bWritten = bFmtInDTOR = bAutoUpdateFmt = sal_False; // LAYER_IMPL
57     bAutoFmt = sal_True;
58 
59     if( pDrvdFrm )
60         aSet.SetParent( &pDrvdFrm->aSet );
61 }
62 
63 
64 SwFmt::SwFmt( SwAttrPool& rPool, const String &rFmtNm,
65             const sal_uInt16* pWhichRanges, SwFmt *pDrvdFrm, sal_uInt16 nFmtWhich )
66     : SwModify( pDrvdFrm ),
67     aFmtName( rFmtNm ),
68     aSet( rPool, pWhichRanges ),
69     nWhichId( nFmtWhich ),
70     nFmtId( 0 ),
71     nPoolFmtId( USHRT_MAX ),
72     nPoolHelpId( USHRT_MAX ),
73     nPoolHlpFileId( UCHAR_MAX )
74 {
75     bWritten = bFmtInDTOR = bAutoUpdateFmt = sal_False; // LAYER_IMPL
76     bAutoFmt = sal_True;
77 
78     if( pDrvdFrm )
79         aSet.SetParent( &pDrvdFrm->aSet );
80 }
81 
82 
83 SwFmt::SwFmt( const SwFmt& rFmt )
84     : SwModify( rFmt.DerivedFrom() ),
85     aFmtName( rFmt.aFmtName ),
86     aSet( rFmt.aSet ),
87     nWhichId( rFmt.nWhichId ),
88     nFmtId( 0 ),
89     nPoolFmtId( rFmt.GetPoolFmtId() ),
90     nPoolHelpId( rFmt.GetPoolHelpId() ),
91     nPoolHlpFileId( rFmt.GetPoolHlpFileId() )
92 {
93     bWritten = bFmtInDTOR = sal_False; // LAYER_IMPL
94     bAutoFmt = rFmt.bAutoFmt;
95     bAutoUpdateFmt = rFmt.bAutoUpdateFmt;
96 
97     if( rFmt.DerivedFrom() )
98         aSet.SetParent( &rFmt.DerivedFrom()->aSet );
99     // einige Sonderbehandlungen fuer Attribute
100     aSet.SetModifyAtAttr( this );
101 }
102 
103 /*************************************************************************
104 |*    SwFmt &SwFmt::operator=(const SwFmt& aFmt)
105 |*
106 |*    Beschreibung      Dokument 1.14
107 |*    Ersterstellung    JP 22.11.90
108 |*    Letzte Aenderung  JP 05.08.94
109 *************************************************************************/
110 
111 
112 SwFmt &SwFmt::operator=(const SwFmt& rFmt)
113 {
114     nWhichId = rFmt.nWhichId;
115     nPoolFmtId = rFmt.GetPoolFmtId();
116     nPoolHelpId = rFmt.GetPoolHelpId();
117     nPoolHlpFileId = rFmt.GetPoolHlpFileId();
118 
119     if ( IsInCache() )
120     {
121         SwFrm::GetCache().Delete( this );
122         SetInCache( sal_False );
123     }
124     SetInSwFntCache( sal_False );
125 
126     // kopiere nur das Attribut-Delta Array
127     SwAttrSet aOld( *aSet.GetPool(), aSet.GetRanges() ),
128                 aNew( *aSet.GetPool(), aSet.GetRanges() );
129     aSet.Intersect_BC( rFmt.aSet, &aOld, &aNew );
130     aSet.Put_BC( rFmt.aSet, &aOld, &aNew );
131 
132     // einige Sonderbehandlungen fuer Attribute
133     aSet.SetModifyAtAttr( this );
134 
135     // PoolItem-Attr erzeugen fuers Modify !!!
136     if( aOld.Count() )
137     {
138         SwAttrSetChg aChgOld( aSet, aOld );
139         SwAttrSetChg aChgNew( aSet, aNew );
140         ModifyNotification( &aChgOld, &aChgNew );        // alle veraenderten werden verschickt
141     }
142 
143     if( GetRegisteredIn() != rFmt.GetRegisteredIn() )
144     {
145         if( GetRegisteredIn() )
146             GetRegisteredInNonConst()->Remove(this);
147         if(rFmt.GetRegisteredIn())
148         {
149             const_cast<SwFmt&>(rFmt).GetRegisteredInNonConst()->Add(this);
150             aSet.SetParent( &rFmt.aSet );
151         }
152         else
153             aSet.SetParent( 0 );
154     }
155     bAutoFmt = rFmt.bAutoFmt;
156     bAutoUpdateFmt = rFmt.bAutoUpdateFmt;
157     return *this;
158 }
159 
160 void SwFmt::SetName( const String& rNewName, sal_Bool bBroadcast )
161 {
162     ASSERT(!IsDefault(), "SetName: Defaultformat" );
163     if( bBroadcast )
164     {
165         SwStringMsgPoolItem aOld( RES_NAME_CHANGED, aFmtName );
166         SwStringMsgPoolItem aNew( RES_NAME_CHANGED, rNewName );
167         aFmtName = rNewName;
168         ModifyNotification( &aOld, &aNew );
169     }
170     else
171     {
172         aFmtName = rNewName;
173     }
174 }
175 
176 /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
177  * diese Funktion wird in jedem Copy-Ctor gerufen, damit die
178  * Attribute kopiert werden. Diese koennen erst kopiert werden,
179  * wenn die abgeleitet Klasse existiert, denn beim Setzen der
180  * Attribute wird die Which()-Methode gerufen, die hier in der
181  * Basis-Klasse auf 0 defaultet ist.
182  *
183  * Zusatz: JP 8.4.1994
184  *  Wird ueber Dokumentgrenzen kopiert, so muss das neue Dokument
185  *  mit angeben werden, in dem this steht. Z.Z. ist das fuers
186  *  DropCaps wichtig, dieses haelt Daten, die tief kopiert werden
187  *  muessen !!
188  * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
189 
190 
191 void SwFmt::CopyAttrs( const SwFmt& rFmt, sal_Bool bReplace )
192 {
193     // kopiere nur das Attribut-Delta Array
194 
195     if ( IsInCache() )
196     {
197         SwFrm::GetCache().Delete( this );
198         SetInCache( sal_False );
199     }
200     SetInSwFntCache( sal_False );
201 
202     // Sonderbehandlung fuer einige Attribute
203     SwAttrSet* pChgSet = (SwAttrSet*)&rFmt.aSet;
204 
205     if( !bReplace )     // nur die neu, die nicht gesetzt sind ??
206     {
207         if( pChgSet == (SwAttrSet*)&rFmt.aSet )     // Set hier kopieren
208             pChgSet = new SwAttrSet( rFmt.aSet );
209         pChgSet->Differentiate( aSet );
210     }
211 
212     // kopiere nur das Attribut-Delta Array
213     if( pChgSet->GetPool() != aSet.GetPool() )
214         pChgSet->CopyToModify( *this );
215     else
216     {
217         SwAttrSet aOld( *aSet.GetPool(), aSet.GetRanges() ),
218                   aNew( *aSet.GetPool(), aSet.GetRanges() );
219 
220         if ( 0 != aSet.Put_BC( *pChgSet, &aOld, &aNew ) )
221         {
222             // einige Sonderbehandlungen fuer Attribute
223             aSet.SetModifyAtAttr( this );
224 
225             SwAttrSetChg aChgOld( aSet, aOld );
226             SwAttrSetChg aChgNew( aSet, aNew );
227             ModifyNotification( &aChgOld, &aChgNew );       // alle veraenderten werden verschickt
228         }
229     }
230 
231     if( pChgSet != (SwAttrSet*)&rFmt.aSet )     // Set hier angelegt ?
232         delete pChgSet;
233 }
234 
235 /*************************************************************************
236 |*    SwFmt::~SwFmt()
237 |*
238 |*    Beschreibung      Dokument 1.14
239 |*    Ersterstellung    JP 22.11.90
240 |*    Letzte Aenderung  JP 14.02.91
241 *************************************************************************/
242 
243 
244 SwFmt::~SwFmt()
245 {
246     /* das passiert bei der ObjectDying Message */
247     /* alle Abhaengigen auf DerivedFrom umhaengen */
248     if( GetDepends() )
249     {
250         ASSERT(DerivedFrom(), "SwFmt::~SwFmt: Def Abhaengige!" );
251 
252         bFmtInDTOR = sal_True;
253 
254         SwFmt *pParentFmt = DerivedFrom();
255         if (!pParentFmt)        // see #112405#
256         {
257             DBG_ERROR( "~SwFmt: parent format missing" );
258         }
259         else
260         {
261             while( GetDepends() && pParentFmt)
262             {
263                 SwFmtChg aOldFmt(this);
264                 SwFmtChg aNewFmt(pParentFmt);
265                 SwClient * pDepend = (SwClient*)GetDepends();
266                 pParentFmt->Add(pDepend);
267                 pDepend->ModifyNotification(&aOldFmt, &aNewFmt);
268             }
269         }
270     }
271 }
272 
273 
274 /*************************************************************************
275 |*    void SwFmt::Modify( const SfxPoolItem* pOldValue, const SfxPoolItem* pNewValue )
276 |*
277 |*    Beschreibung      Dokument 1.14
278 |*    Ersterstellung    JP 22.11.90
279 |*    Letzte Aenderung  JP 05.08.94
280 *************************************************************************/
281 
282 
283 void SwFmt::Modify( const SfxPoolItem* pOldValue, const SfxPoolItem* pNewValue )
284 {
285     sal_Bool bWeiter = sal_True;    // sal_True = Propagierung an die Abhaengigen
286 
287     sal_uInt16 nWhich = pOldValue ? pOldValue->Which() :
288                     pNewValue ? pNewValue->Which() : 0 ;
289     switch( nWhich )
290     {
291     case 0:     break;          // Which-Id von 0 ???
292 
293     case RES_OBJECTDYING :
294         {
295             // ist das sterbende Object das "Parent"-Format von diesen Format,
296             // dann haengt sich dieses Format an den Parent vom Parent
297             SwFmt * pFmt = (SwFmt *) ((SwPtrMsgPoolItem *)pNewValue)->pObject;
298 
299             // nicht umhaengen wenn dieses das oberste Format ist !!
300             if( GetRegisteredIn() && GetRegisteredIn() == pFmt )
301             {
302                 if( pFmt->GetRegisteredIn() )
303                 {
304                     // wenn Parent, dann im neuen Parent wieder anmelden
305                     pFmt->DerivedFrom()->Add( this );
306                     aSet.SetParent( &DerivedFrom()->aSet );
307                 }
308                 else
309                 {
310                     // sonst auf jeden Fall beim sterbenden abmelden
311                     DerivedFrom()->Remove( this );
312                     aSet.SetParent( 0 );
313                 }
314             }
315         } // OBJECTDYING
316         break;
317 
318     case RES_ATTRSET_CHG:
319         if( ((SwAttrSetChg*)pOldValue)->GetTheChgdSet() != &aSet )
320         {
321             //nur die weiter geben, die hier nicht gesetzt sind !!
322             SwAttrSetChg aOld( *(SwAttrSetChg*)pOldValue );
323             SwAttrSetChg aNew( *(SwAttrSetChg*)pNewValue );
324 
325             aOld.GetChgSet()->Differentiate( aSet );
326             aNew.GetChgSet()->Differentiate( aSet );
327 
328             if( aNew.Count() )
329                 // keine mehr gesetzt, dann Ende !!
330             NotifyClients( &aOld, &aNew );
331             bWeiter = sal_False;
332         }
333         break;
334     case RES_FMT_CHG:
335         // falls mein Format Parent umgesetzt wird, dann melde ich
336         // meinen Attrset beim Neuen an.
337 
338         // sein eigenes Modify ueberspringen !!
339         if( ((SwFmtChg*)pOldValue)->pChangedFmt != this &&
340             ((SwFmtChg*)pNewValue)->pChangedFmt == DerivedFrom() )
341         {
342             // den Set an den neuen Parent haengen
343             aSet.SetParent( DerivedFrom() ? &DerivedFrom()->aSet : 0 );
344         }
345         break;
346 
347     case RES_RESET_FMTWRITTEN:
348         {
349             // IsWritten-Flag zuruecksetzen. Hint nur an abhanegige
350             // Formate (und keine Frames) propagieren.
351             // mba: the code does the opposite from what is written in the comment!
352             ResetWritten();
353             // mba: here we don't use the additional stuff from NotifyClients().
354             // should we?!
355             // mba: move the code that ignores this event to the clients
356             ModifyBroadcast( pOldValue, pNewValue, TYPE(SwFmt) );
357             bWeiter = sal_False;
358         }
359         break;
360 
361     default:
362         {
363             // Ist das Attribut in diesem Format definiert, dann auf
364             // NICHT weiter propagieren !!
365             if( SFX_ITEM_SET == aSet.GetItemState( nWhich, sal_False ))
366             {
367 // wie finde ich heraus, ob nicht ich die Message versende ??
368 // aber wer ruft das hier ????
369 //ASSERT( sal_False, "Modify ohne Absender verschickt" );
370 //JP 11.06.96: DropCaps koennen hierher kommen
371 ASSERT( RES_PARATR_DROP == nWhich, "Modify ohne Absender verschickt" );
372                 bWeiter = sal_False;
373             }
374 
375         } // default
376     } // switch
377 
378     if( bWeiter )
379     {
380         // laufe durch alle abhaengigen Formate
381         NotifyClients( pOldValue, pNewValue );
382     }
383 
384 }
385 
386 
387 sal_Bool SwFmt::SetDerivedFrom(SwFmt *pDerFrom)
388 {
389     if ( pDerFrom )
390     {
391         // Zyklus?
392         const SwFmt* pFmt = pDerFrom;
393         while ( pFmt != 0 )
394         {
395             if ( pFmt == this )
396                 return sal_False;
397 
398             pFmt=pFmt->DerivedFrom();
399         }
400     }
401     else
402     {
403         // Nichts angegeben, Dflt-Format suchen
404         pDerFrom = this;
405         while ( pDerFrom->DerivedFrom() )
406             pDerFrom = pDerFrom->DerivedFrom();
407     }
408     if ( (pDerFrom == DerivedFrom()) || (pDerFrom == this) )
409         return sal_False;
410 
411     ASSERT( Which()==pDerFrom->Which()
412             || ( Which()==RES_CONDTXTFMTCOLL && pDerFrom->Which()==RES_TXTFMTCOLL)
413             || ( Which()==RES_TXTFMTCOLL && pDerFrom->Which()==RES_CONDTXTFMTCOLL)
414             || ( Which()==RES_FLYFRMFMT && pDerFrom->Which()==RES_FRMFMT ),
415             "SetDerivedFrom: Aepfel von Birnen ableiten?");
416 
417     if ( IsInCache() )
418     {
419         SwFrm::GetCache().Delete( this );
420         SetInCache( sal_False );
421     }
422     SetInSwFntCache( sal_False );
423 
424     pDerFrom->Add(this);
425     aSet.SetParent( &pDerFrom->aSet );
426 
427     SwFmtChg aOldFmt(this);
428     SwFmtChg aNewFmt(this);
429     ModifyNotification( &aOldFmt, &aNewFmt );
430 
431     return sal_True;
432 }
433 
434 
435 const SfxPoolItem& SwFmt::GetFmtAttr( sal_uInt16 nWhich, sal_Bool bInParents ) const
436 {
437     if(RES_BACKGROUND == nWhich && RES_FLYFRMFMT == Which())
438     {
439         //UUUU FALLBACKBREAKHERE should not be used; instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST]
440         OSL_ENSURE(false, "Do no longer use SvxBrushItem, instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST] FillAttributes (simple fallback is in place and used)");
441         static SvxBrushItem aSvxBrushItem(RES_BACKGROUND);
442 
443         // fill the local static SvxBrushItem from the current ItemSet so that
444         // the fill attributes [XATTR_FILL_FIRST .. XATTR_FILL_LAST] are used
445         // as good as possible to create a fallback representation and return that
446         aSvxBrushItem = getSvxBrushItemFromSourceSet(aSet, bInParents);
447 
448         return aSvxBrushItem;
449     }
450 
451     return aSet.Get( nWhich, bInParents );
452 }
453 
454 
455 SfxItemState SwFmt::GetItemState( sal_uInt16 nWhich, sal_Bool bSrchInParent, const SfxPoolItem **ppItem ) const
456 {
457     if(RES_BACKGROUND == nWhich && RES_FLYFRMFMT == Which())
458     {
459         //UUUU FALLBACKBREAKHERE should not be used; instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST]
460         OSL_ENSURE(false, "Do no longer use SvxBrushItem, instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST] FillAttributes (simple fallback is in place and used)");
461         const FillAttributesPtr aFill = getFillAttributes();
462 
463         // check if the new fill attributes are used
464         if(aFill.get() && aFill->isUsed())
465         {
466             // if yes, fill the local SvxBrushItem using the new fill attributes
467             // as good as possible to have an instance for the pointer to point
468             // to and return as state that it is set
469             static SvxBrushItem aSvxBrushItem(RES_BACKGROUND);
470 
471             aSvxBrushItem = getSvxBrushItemFromSourceSet(aSet, bSrchInParent);
472             *ppItem = &aSvxBrushItem;
473 
474             return SFX_ITEM_SET;
475         }
476 
477         // if not, reset pointer and return SFX_ITEM_DEFAULT to signal that
478         // the item is not set
479         *ppItem = 0;
480 
481         return SFX_ITEM_DEFAULT;
482     }
483 
484     return aSet.GetItemState( nWhich, bSrchInParent, ppItem );
485 }
486 
487 
488 sal_Bool SwFmt::SetFmtAttr(const SfxPoolItem& rAttr )
489 {
490     if ( IsInCache() || IsInSwFntCache() )
491     {
492         const sal_uInt16 nWhich = rAttr.Which();
493         CheckCaching( nWhich );
494     }
495 
496     sal_Bool bRet = sal_False;
497 
498     //UUUU
499     if(RES_BACKGROUND == rAttr.Which() && RES_FLYFRMFMT == Which())
500     {
501         //UUUU FALLBACKBREAKHERE should not be used; instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST]
502         OSL_ENSURE(false, "Do no longer use SvxBrushItem, instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST] FillAttributes (simple fallback is in place and used)");
503         SfxItemSet aTempSet(*aSet.GetPool(), XATTR_FILL_FIRST, XATTR_FILL_LAST, 0, 0);
504         const SvxBrushItem& rSource = static_cast< const SvxBrushItem& >(rAttr);
505 
506         // fill a local ItemSet with the attributes corresponding as good as possible
507         // to the new fill properties [XATTR_FILL_FIRST .. XATTR_FILL_LAST] and set these
508         // as ItemSet
509         setSvxBrushItemAsFillAttributesToTargetSet(rSource, aTempSet);
510 
511         if(IsModifyLocked())
512         {
513             if( 0 != ( bRet = (0 != aSet.Put( aTempSet ))) )
514             {
515                 aSet.SetModifyAtAttr( this );
516             }
517         }
518         else
519         {
520             SwAttrSet aOld(*aSet.GetPool(), aSet.GetRanges()), aNew(*aSet.GetPool(), aSet.GetRanges());
521 
522             bRet = 0 != aSet.Put_BC(aTempSet, &aOld, &aNew);
523 
524             if(bRet)
525             {
526                 aSet.SetModifyAtAttr(this);
527 
528                 SwAttrSetChg aChgOld(aSet, aOld);
529                 SwAttrSetChg aChgNew(aSet, aNew);
530 
531                 ModifyNotification(&aChgOld, &aChgNew);
532             }
533         }
534 
535         return bRet;
536     }
537 
538     // wenn Modify gelockt ist, werden keine Modifies verschickt;
539     // fuer FrmFmt's immer das Modify verschicken!
540     const sal_uInt16 nFmtWhich = Which();
541     if( IsModifyLocked() || (!GetDepends() &&
542         (RES_GRFFMTCOLL == nFmtWhich  ||
543          RES_TXTFMTCOLL == nFmtWhich ) ) )
544     {
545         if( 0 != ( bRet = (0 != aSet.Put( rAttr ))) )
546             aSet.SetModifyAtAttr( this );
547         // --> OD 2006-11-22 #i71574#
548         if ( nFmtWhich == RES_TXTFMTCOLL && rAttr.Which() == RES_PARATR_NUMRULE )
549         {
550             TxtFmtCollFunc::CheckTxtFmtCollForDeletionOfAssignmentToOutlineStyle( this );
551         }
552         // <--
553     }
554     else
555     {
556         // kopiere nur das Attribut-Delta Array
557         SwAttrSet aOld( *aSet.GetPool(), aSet.GetRanges() ),
558                     aNew( *aSet.GetPool(), aSet.GetRanges() );
559 
560         bRet = 0 != aSet.Put_BC( rAttr, &aOld, &aNew );
561         if( bRet )
562         {
563             // einige Sonderbehandlungen fuer Attribute
564             aSet.SetModifyAtAttr( this );
565 
566             SwAttrSetChg aChgOld( aSet, aOld );
567             SwAttrSetChg aChgNew( aSet, aNew );
568             ModifyNotification( &aChgOld, &aChgNew );       // alle veraenderten werden verschickt
569         }
570     }
571     return bRet;
572 }
573 
574 
575 sal_Bool SwFmt::SetFmtAttr( const SfxItemSet& rSet )
576 {
577     if( !rSet.Count() )
578         return sal_False;
579 
580     if ( IsInCache() )
581     {
582         SwFrm::GetCache().Delete( this );
583         SetInCache( sal_False );
584     }
585     SetInSwFntCache( sal_False );
586 
587     sal_Bool bRet = sal_False;
588 
589     //UUUU Usel local copy to be able to apply needed changes, e.g. call
590     // CheckForUniqueItemForLineFillNameOrIndex which is needed for NameOrIndex stuff
591     SfxItemSet aTempSet(rSet);
592 
593     //UUUU Need to check for unique item for DrawingLayer items of type NameOrIndex
594     // and evtl. correct that item to ensure unique names for that type. This call may
595     // modify/correct entries inside of the given SfxItemSet
596     if(GetDoc())
597     {
598         GetDoc()->CheckForUniqueItemForLineFillNameOrIndex(aTempSet);
599     }
600 
601     //UUUU
602     if(RES_FLYFRMFMT == Which())
603     {
604         const SfxPoolItem* pSource = 0;
605 
606         if(SFX_ITEM_SET == aTempSet.GetItemState(RES_BACKGROUND, sal_False, &pSource))
607         {
608             //UUUU FALLBACKBREAKHERE should not be used; instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST]
609             OSL_ENSURE(false, "Do no longer use SvxBrushItem, instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST] FillAttributes (simple fallback is in place and used)");
610 
611             // copy all items to be set anyways to a local ItemSet with is also prepared for the new
612             // fill attribute ranges [XATTR_FILL_FIRST .. XATTR_FILL_LAST]. Add the attributes
613             // corresponding as good as possible to the new fill properties and set the whole ItemSet
614             const SvxBrushItem& rSource(static_cast< const SvxBrushItem& >(*pSource));
615             setSvxBrushItemAsFillAttributesToTargetSet(rSource, aTempSet);
616 
617             if(IsModifyLocked())
618             {
619                 if( 0 != ( bRet = (0 != aSet.Put( aTempSet ))) )
620                 {
621                     aSet.SetModifyAtAttr( this );
622                 }
623             }
624             else
625             {
626                 SwAttrSet aOld(*aSet.GetPool(), aSet.GetRanges()), aNew(*aSet.GetPool(), aSet.GetRanges());
627 
628                 bRet = 0 != aSet.Put_BC(aTempSet, &aOld, &aNew);
629 
630                 if(bRet)
631                 {
632                     aSet.SetModifyAtAttr(this);
633 
634                     SwAttrSetChg aChgOld(aSet, aOld);
635                     SwAttrSetChg aChgNew(aSet, aNew);
636 
637                     ModifyNotification(&aChgOld, &aChgNew);
638                 }
639             }
640 
641             return bRet;
642         }
643     }
644 
645     // wenn Modify gelockt ist, werden keine Modifies verschickt;
646     // fuer FrmFmt's immer das Modify verschicken!
647     const sal_uInt16 nFmtWhich = Which();
648     if ( IsModifyLocked() ||
649          ( !GetDepends() &&
650            ( RES_GRFFMTCOLL == nFmtWhich ||
651              RES_TXTFMTCOLL == nFmtWhich ) ) )
652     {
653         if( 0 != ( bRet = (0 != aSet.Put( aTempSet ))) )
654             aSet.SetModifyAtAttr( this );
655         // --> OD 2006-11-22 #i71574#
656         if ( nFmtWhich == RES_TXTFMTCOLL )
657         {
658             TxtFmtCollFunc::CheckTxtFmtCollForDeletionOfAssignmentToOutlineStyle( this );
659         }
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 
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
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 
759 sal_Bool SwFmt::GetInfo( SfxPoolItem& rInfo ) const
760 {
761     sal_Bool bRet = SwModify::GetInfo( rInfo );
762     return bRet;
763 }
764 
765 
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 */
808 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 */
824 sal_Bool SwFmt::IsShadowTransparent() const
825 {
826     return sal_False;
827 }
828 
829 /*
830  * Document Interface Access
831  */
832 const IDocumentSettingAccess* SwFmt::getIDocumentSettingAccess() const { return GetDoc(); }
833 const IDocumentDrawModelAccess* SwFmt::getIDocumentDrawModelAccess() const { return GetDoc(); }
834 IDocumentDrawModelAccess* SwFmt::getIDocumentDrawModelAccess() { return GetDoc(); }
835 const IDocumentLayoutAccess* SwFmt::getIDocumentLayoutAccess() const { return GetDoc(); }
836 IDocumentLayoutAccess* SwFmt::getIDocumentLayoutAccess() { return GetDoc(); }
837 IDocumentTimerAccess* SwFmt::getIDocumentTimerAccess() { return GetDoc(); }
838 IDocumentFieldsAccess* SwFmt::getIDocumentFieldsAccess() { return GetDoc(); }
839 IDocumentChartDataProviderAccess* SwFmt::getIDocumentChartDataProviderAccess() { return GetDoc(); }
840 
841 //UUUU
842 const SvxBrushItem& SwFmt::GetBackground(sal_Bool bInP) const
843 {
844     if(RES_FLYFRMFMT == Which())
845     {
846         //UUUU FALLBACKBREAKHERE should not be used; instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST]
847         OSL_ENSURE(false, "Do no longer use SvxBrushItem, instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST] FillAttributes (simple fallback is in place and used)");
848         static SvxBrushItem aSvxBrushItem(RES_BACKGROUND);
849 
850         // fill the local static SvxBrushItem from the current ItemSet so that
851         // the fill attributes [XATTR_FILL_FIRST .. XATTR_FILL_LAST] are used
852         // as good as possible to create a fallback representation and return that
853         aSvxBrushItem = getSvxBrushItemFromSourceSet(aSet, bInP);
854 
855         return aSvxBrushItem;
856     }
857 
858     return aSet.GetBackground(bInP);
859 }
860 
861 //UUUU
862 FillAttributesPtr SwFmt::getFillAttributes() const
863 {
864     // FALLBACKBREAKHERE return empty pointer
865     OSL_ENSURE(false, "getFillAttributes() call only valid for RES_FLYFRMFMT currently (!)");
866 
867     return FillAttributesPtr();
868 }
869 
870 // eof
871