1efeef26fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3efeef26fSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4efeef26fSAndrew Rist * or more contributor license agreements. See the NOTICE file
5efeef26fSAndrew Rist * distributed with this work for additional information
6efeef26fSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7efeef26fSAndrew Rist * to you under the Apache License, Version 2.0 (the
8efeef26fSAndrew Rist * "License"); you may not use this file except in compliance
9efeef26fSAndrew Rist * with the License. You may obtain a copy of the License at
10cdf0e10cSrcweir *
11efeef26fSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir *
13efeef26fSAndrew Rist * Unless required by applicable law or agreed to in writing,
14efeef26fSAndrew Rist * software distributed under the License is distributed on an
15efeef26fSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16efeef26fSAndrew Rist * KIND, either express or implied. See the License for the
17efeef26fSAndrew Rist * specific language governing permissions and limitations
18efeef26fSAndrew Rist * under the License.
19cdf0e10cSrcweir *
20efeef26fSAndrew Rist *************************************************************/
21efeef26fSAndrew Rist
22efeef26fSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sw.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir
28cdf0e10cSrcweir #include <hintids.hxx> // fuer RES_..
29cdf0e10cSrcweir #include <frame.hxx> // fuer AttrCache
30cdf0e10cSrcweir #include <format.hxx>
31cdf0e10cSrcweir #include <hints.hxx> // fuer SwFmtChg
32cdf0e10cSrcweir #include <doc.hxx>
33cdf0e10cSrcweir #include <paratr.hxx> // fuer SwParaFmt - SwHyphenBug
34cdf0e10cSrcweir #include <swcache.hxx>
35cdf0e10cSrcweir #include <fmtcolfunc.hxx>
36cdf0e10cSrcweir
37cdf0e10cSrcweir TYPEINIT1( SwFmt, SwClient ); //rtti fuer SwFmt
38cdf0e10cSrcweir
39cdf0e10cSrcweir /*************************************************************************
40cdf0e10cSrcweir |* SwFmt::SwFmt
41cdf0e10cSrcweir *************************************************************************/
42cdf0e10cSrcweir
43cdf0e10cSrcweir
SwFmt(SwAttrPool & rPool,const sal_Char * pFmtNm,const sal_uInt16 * pWhichRanges,SwFmt * pDrvdFrm,sal_uInt16 nFmtWhich)44cdf0e10cSrcweir SwFmt::SwFmt( SwAttrPool& rPool, const sal_Char* pFmtNm,
45cdf0e10cSrcweir const sal_uInt16* pWhichRanges, SwFmt *pDrvdFrm, sal_uInt16 nFmtWhich )
46cdf0e10cSrcweir : SwModify( pDrvdFrm ),
47cdf0e10cSrcweir aSet( rPool, pWhichRanges ),
48cdf0e10cSrcweir nWhichId( nFmtWhich ),
49cdf0e10cSrcweir nFmtId( 0 ),
50cdf0e10cSrcweir nPoolFmtId( USHRT_MAX ),
51cdf0e10cSrcweir nPoolHelpId( USHRT_MAX ),
52cdf0e10cSrcweir nPoolHlpFileId( UCHAR_MAX )
53cdf0e10cSrcweir {
54cdf0e10cSrcweir aFmtName.AssignAscii( pFmtNm );
55cdf0e10cSrcweir bWritten = bFmtInDTOR = bAutoUpdateFmt = sal_False; // LAYER_IMPL
56cdf0e10cSrcweir bAutoFmt = sal_True;
57cdf0e10cSrcweir
58cdf0e10cSrcweir if( pDrvdFrm )
59cdf0e10cSrcweir aSet.SetParent( &pDrvdFrm->aSet );
60cdf0e10cSrcweir }
61cdf0e10cSrcweir
62cdf0e10cSrcweir
SwFmt(SwAttrPool & rPool,const String & rFmtNm,const sal_uInt16 * pWhichRanges,SwFmt * pDrvdFrm,sal_uInt16 nFmtWhich)63cdf0e10cSrcweir SwFmt::SwFmt( SwAttrPool& rPool, const String &rFmtNm,
64cdf0e10cSrcweir const sal_uInt16* pWhichRanges, SwFmt *pDrvdFrm, sal_uInt16 nFmtWhich )
65cdf0e10cSrcweir : SwModify( pDrvdFrm ),
66cdf0e10cSrcweir aFmtName( rFmtNm ),
67cdf0e10cSrcweir aSet( rPool, pWhichRanges ),
68cdf0e10cSrcweir nWhichId( nFmtWhich ),
69cdf0e10cSrcweir nFmtId( 0 ),
70cdf0e10cSrcweir nPoolFmtId( USHRT_MAX ),
71cdf0e10cSrcweir nPoolHelpId( USHRT_MAX ),
72cdf0e10cSrcweir nPoolHlpFileId( UCHAR_MAX )
73cdf0e10cSrcweir {
74cdf0e10cSrcweir bWritten = bFmtInDTOR = bAutoUpdateFmt = sal_False; // LAYER_IMPL
75cdf0e10cSrcweir bAutoFmt = sal_True;
76cdf0e10cSrcweir
77cdf0e10cSrcweir if( pDrvdFrm )
78cdf0e10cSrcweir aSet.SetParent( &pDrvdFrm->aSet );
79cdf0e10cSrcweir }
80cdf0e10cSrcweir
81cdf0e10cSrcweir
SwFmt(const SwFmt & rFmt)82cdf0e10cSrcweir SwFmt::SwFmt( const SwFmt& rFmt )
83cdf0e10cSrcweir : SwModify( rFmt.DerivedFrom() ),
84cdf0e10cSrcweir aFmtName( rFmt.aFmtName ),
85cdf0e10cSrcweir aSet( rFmt.aSet ),
86cdf0e10cSrcweir nWhichId( rFmt.nWhichId ),
87cdf0e10cSrcweir nFmtId( 0 ),
88cdf0e10cSrcweir nPoolFmtId( rFmt.GetPoolFmtId() ),
89cdf0e10cSrcweir nPoolHelpId( rFmt.GetPoolHelpId() ),
90cdf0e10cSrcweir nPoolHlpFileId( rFmt.GetPoolHlpFileId() )
91cdf0e10cSrcweir {
92cdf0e10cSrcweir bWritten = bFmtInDTOR = sal_False; // LAYER_IMPL
93cdf0e10cSrcweir bAutoFmt = rFmt.bAutoFmt;
94cdf0e10cSrcweir bAutoUpdateFmt = rFmt.bAutoUpdateFmt;
95cdf0e10cSrcweir
96cdf0e10cSrcweir if( rFmt.DerivedFrom() )
97cdf0e10cSrcweir aSet.SetParent( &rFmt.DerivedFrom()->aSet );
98cdf0e10cSrcweir // einige Sonderbehandlungen fuer Attribute
99cdf0e10cSrcweir aSet.SetModifyAtAttr( this );
100cdf0e10cSrcweir }
101cdf0e10cSrcweir
102cdf0e10cSrcweir /*************************************************************************
103cdf0e10cSrcweir |* SwFmt &SwFmt::operator=(const SwFmt& aFmt)
104cdf0e10cSrcweir |*
105cdf0e10cSrcweir |* Beschreibung Dokument 1.14
106cdf0e10cSrcweir |* Ersterstellung JP 22.11.90
107cdf0e10cSrcweir |* Letzte Aenderung JP 05.08.94
108cdf0e10cSrcweir *************************************************************************/
109cdf0e10cSrcweir
110cdf0e10cSrcweir
operator =(const SwFmt & rFmt)111cdf0e10cSrcweir SwFmt &SwFmt::operator=(const SwFmt& rFmt)
112cdf0e10cSrcweir {
113cdf0e10cSrcweir nWhichId = rFmt.nWhichId;
114cdf0e10cSrcweir nPoolFmtId = rFmt.GetPoolFmtId();
115cdf0e10cSrcweir nPoolHelpId = rFmt.GetPoolHelpId();
116cdf0e10cSrcweir nPoolHlpFileId = rFmt.GetPoolHlpFileId();
117cdf0e10cSrcweir
118cdf0e10cSrcweir if ( IsInCache() )
119cdf0e10cSrcweir {
120cdf0e10cSrcweir SwFrm::GetCache().Delete( this );
121cdf0e10cSrcweir SetInCache( sal_False );
122cdf0e10cSrcweir }
123cdf0e10cSrcweir SetInSwFntCache( sal_False );
124cdf0e10cSrcweir
125cdf0e10cSrcweir // kopiere nur das Attribut-Delta Array
126cdf0e10cSrcweir SwAttrSet aOld( *aSet.GetPool(), aSet.GetRanges() ),
127cdf0e10cSrcweir aNew( *aSet.GetPool(), aSet.GetRanges() );
128cdf0e10cSrcweir aSet.Intersect_BC( rFmt.aSet, &aOld, &aNew );
129cdf0e10cSrcweir aSet.Put_BC( rFmt.aSet, &aOld, &aNew );
130cdf0e10cSrcweir
131cdf0e10cSrcweir // einige Sonderbehandlungen fuer Attribute
132cdf0e10cSrcweir aSet.SetModifyAtAttr( this );
133cdf0e10cSrcweir
134cdf0e10cSrcweir // PoolItem-Attr erzeugen fuers Modify !!!
135cdf0e10cSrcweir if( aOld.Count() )
136cdf0e10cSrcweir {
137cdf0e10cSrcweir SwAttrSetChg aChgOld( aSet, aOld );
138cdf0e10cSrcweir SwAttrSetChg aChgNew( aSet, aNew );
139cdf0e10cSrcweir ModifyNotification( &aChgOld, &aChgNew ); // alle veraenderten werden verschickt
140cdf0e10cSrcweir }
141cdf0e10cSrcweir
142cdf0e10cSrcweir if( GetRegisteredIn() != rFmt.GetRegisteredIn() )
143cdf0e10cSrcweir {
144cdf0e10cSrcweir if( GetRegisteredIn() )
145cdf0e10cSrcweir GetRegisteredInNonConst()->Remove(this);
146cdf0e10cSrcweir if(rFmt.GetRegisteredIn())
147cdf0e10cSrcweir {
148cdf0e10cSrcweir const_cast<SwFmt&>(rFmt).GetRegisteredInNonConst()->Add(this);
149cdf0e10cSrcweir aSet.SetParent( &rFmt.aSet );
150cdf0e10cSrcweir }
151cdf0e10cSrcweir else
152cdf0e10cSrcweir aSet.SetParent( 0 );
153cdf0e10cSrcweir }
154cdf0e10cSrcweir bAutoFmt = rFmt.bAutoFmt;
155cdf0e10cSrcweir bAutoUpdateFmt = rFmt.bAutoUpdateFmt;
156cdf0e10cSrcweir return *this;
157cdf0e10cSrcweir }
158cdf0e10cSrcweir
SetName(const String & rNewName,sal_Bool bBroadcast)159cdf0e10cSrcweir void SwFmt::SetName( const String& rNewName, sal_Bool bBroadcast )
160cdf0e10cSrcweir {
161cdf0e10cSrcweir ASSERT(!IsDefault(), "SetName: Defaultformat" );
162cdf0e10cSrcweir if( bBroadcast )
163cdf0e10cSrcweir {
164cdf0e10cSrcweir SwStringMsgPoolItem aOld( RES_NAME_CHANGED, aFmtName );
165cdf0e10cSrcweir SwStringMsgPoolItem aNew( RES_NAME_CHANGED, rNewName );
166cdf0e10cSrcweir aFmtName = rNewName;
167cdf0e10cSrcweir ModifyNotification( &aOld, &aNew );
168cdf0e10cSrcweir }
169cdf0e10cSrcweir else
170cdf0e10cSrcweir {
171cdf0e10cSrcweir aFmtName = rNewName;
172cdf0e10cSrcweir }
173cdf0e10cSrcweir }
174cdf0e10cSrcweir
175cdf0e10cSrcweir /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
176cdf0e10cSrcweir * diese Funktion wird in jedem Copy-Ctor gerufen, damit die
177cdf0e10cSrcweir * Attribute kopiert werden. Diese koennen erst kopiert werden,
178cdf0e10cSrcweir * wenn die abgeleitet Klasse existiert, denn beim Setzen der
179cdf0e10cSrcweir * Attribute wird die Which()-Methode gerufen, die hier in der
180cdf0e10cSrcweir * Basis-Klasse auf 0 defaultet ist.
181cdf0e10cSrcweir *
182cdf0e10cSrcweir * Zusatz: JP 8.4.1994
183cdf0e10cSrcweir * Wird ueber Dokumentgrenzen kopiert, so muss das neue Dokument
184cdf0e10cSrcweir * mit angeben werden, in dem this steht. Z.Z. ist das fuers
185cdf0e10cSrcweir * DropCaps wichtig, dieses haelt Daten, die tief kopiert werden
186cdf0e10cSrcweir * muessen !!
187cdf0e10cSrcweir * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
188cdf0e10cSrcweir
189cdf0e10cSrcweir
CopyAttrs(const SwFmt & rFmt,sal_Bool bReplace)190cdf0e10cSrcweir void SwFmt::CopyAttrs( const SwFmt& rFmt, sal_Bool bReplace )
191cdf0e10cSrcweir {
192cdf0e10cSrcweir // kopiere nur das Attribut-Delta Array
193cdf0e10cSrcweir
194cdf0e10cSrcweir if ( IsInCache() )
195cdf0e10cSrcweir {
196cdf0e10cSrcweir SwFrm::GetCache().Delete( this );
197cdf0e10cSrcweir SetInCache( sal_False );
198cdf0e10cSrcweir }
199cdf0e10cSrcweir SetInSwFntCache( sal_False );
200cdf0e10cSrcweir
201cdf0e10cSrcweir // Sonderbehandlung fuer einige Attribute
202cdf0e10cSrcweir SwAttrSet* pChgSet = (SwAttrSet*)&rFmt.aSet;
203cdf0e10cSrcweir
204cdf0e10cSrcweir if( !bReplace ) // nur die neu, die nicht gesetzt sind ??
205cdf0e10cSrcweir {
206cdf0e10cSrcweir if( pChgSet == (SwAttrSet*)&rFmt.aSet ) // Set hier kopieren
207cdf0e10cSrcweir pChgSet = new SwAttrSet( rFmt.aSet );
208cdf0e10cSrcweir pChgSet->Differentiate( aSet );
209cdf0e10cSrcweir }
210cdf0e10cSrcweir
211cdf0e10cSrcweir // kopiere nur das Attribut-Delta Array
212cdf0e10cSrcweir if( pChgSet->GetPool() != aSet.GetPool() )
213cdf0e10cSrcweir pChgSet->CopyToModify( *this );
214cdf0e10cSrcweir else
215cdf0e10cSrcweir {
216cdf0e10cSrcweir SwAttrSet aOld( *aSet.GetPool(), aSet.GetRanges() ),
217cdf0e10cSrcweir aNew( *aSet.GetPool(), aSet.GetRanges() );
218cdf0e10cSrcweir
219cdf0e10cSrcweir if ( 0 != aSet.Put_BC( *pChgSet, &aOld, &aNew ) )
220cdf0e10cSrcweir {
221cdf0e10cSrcweir // einige Sonderbehandlungen fuer Attribute
222cdf0e10cSrcweir aSet.SetModifyAtAttr( this );
223cdf0e10cSrcweir
224cdf0e10cSrcweir SwAttrSetChg aChgOld( aSet, aOld );
225cdf0e10cSrcweir SwAttrSetChg aChgNew( aSet, aNew );
226cdf0e10cSrcweir ModifyNotification( &aChgOld, &aChgNew ); // alle veraenderten werden verschickt
227cdf0e10cSrcweir }
228cdf0e10cSrcweir }
229cdf0e10cSrcweir
230cdf0e10cSrcweir if( pChgSet != (SwAttrSet*)&rFmt.aSet ) // Set hier angelegt ?
231cdf0e10cSrcweir delete pChgSet;
232cdf0e10cSrcweir }
233cdf0e10cSrcweir
234cdf0e10cSrcweir /*************************************************************************
235cdf0e10cSrcweir |* SwFmt::~SwFmt()
236cdf0e10cSrcweir |*
237cdf0e10cSrcweir |* Beschreibung Dokument 1.14
238cdf0e10cSrcweir |* Ersterstellung JP 22.11.90
239cdf0e10cSrcweir |* Letzte Aenderung JP 14.02.91
240cdf0e10cSrcweir *************************************************************************/
241cdf0e10cSrcweir
242cdf0e10cSrcweir
~SwFmt()243cdf0e10cSrcweir SwFmt::~SwFmt()
244cdf0e10cSrcweir {
245cdf0e10cSrcweir /* das passiert bei der ObjectDying Message */
246cdf0e10cSrcweir /* alle Abhaengigen auf DerivedFrom umhaengen */
247cdf0e10cSrcweir if( GetDepends() )
248cdf0e10cSrcweir {
249cdf0e10cSrcweir ASSERT(DerivedFrom(), "SwFmt::~SwFmt: Def Abhaengige!" );
250cdf0e10cSrcweir
251cdf0e10cSrcweir bFmtInDTOR = sal_True;
252cdf0e10cSrcweir
253cdf0e10cSrcweir SwFmt *pParentFmt = DerivedFrom();
254cdf0e10cSrcweir if (!pParentFmt) // see #112405#
255cdf0e10cSrcweir {
256cdf0e10cSrcweir DBG_ERROR( "~SwFmt: parent format missing" );
257cdf0e10cSrcweir }
258cdf0e10cSrcweir else
259cdf0e10cSrcweir {
260*ca62e2c2SSteve Yin while( GetDepends() && pParentFmt)
261cdf0e10cSrcweir {
262cdf0e10cSrcweir SwFmtChg aOldFmt(this);
263cdf0e10cSrcweir SwFmtChg aNewFmt(pParentFmt);
264cdf0e10cSrcweir SwClient * pDepend = (SwClient*)GetDepends();
265cdf0e10cSrcweir pParentFmt->Add(pDepend);
266cdf0e10cSrcweir pDepend->ModifyNotification(&aOldFmt, &aNewFmt);
267cdf0e10cSrcweir }
268cdf0e10cSrcweir }
269cdf0e10cSrcweir }
270cdf0e10cSrcweir }
271cdf0e10cSrcweir
272cdf0e10cSrcweir
273cdf0e10cSrcweir /*************************************************************************
274cdf0e10cSrcweir |* void SwFmt::Modify( const SfxPoolItem* pOldValue, const SfxPoolItem* pNewValue )
275cdf0e10cSrcweir |*
276cdf0e10cSrcweir |* Beschreibung Dokument 1.14
277cdf0e10cSrcweir |* Ersterstellung JP 22.11.90
278cdf0e10cSrcweir |* Letzte Aenderung JP 05.08.94
279cdf0e10cSrcweir *************************************************************************/
280cdf0e10cSrcweir
281cdf0e10cSrcweir
Modify(const SfxPoolItem * pOldValue,const SfxPoolItem * pNewValue)282cdf0e10cSrcweir void SwFmt::Modify( const SfxPoolItem* pOldValue, const SfxPoolItem* pNewValue )
283cdf0e10cSrcweir {
284cdf0e10cSrcweir sal_Bool bWeiter = sal_True; // sal_True = Propagierung an die Abhaengigen
285cdf0e10cSrcweir
286cdf0e10cSrcweir sal_uInt16 nWhich = pOldValue ? pOldValue->Which() :
287cdf0e10cSrcweir pNewValue ? pNewValue->Which() : 0 ;
288cdf0e10cSrcweir switch( nWhich )
289cdf0e10cSrcweir {
290cdf0e10cSrcweir case 0: break; // Which-Id von 0 ???
291cdf0e10cSrcweir
292cdf0e10cSrcweir case RES_OBJECTDYING :
293cdf0e10cSrcweir {
294cdf0e10cSrcweir // ist das sterbende Object das "Parent"-Format von diesen Format,
295cdf0e10cSrcweir // dann haengt sich dieses Format an den Parent vom Parent
296cdf0e10cSrcweir SwFmt * pFmt = (SwFmt *) ((SwPtrMsgPoolItem *)pNewValue)->pObject;
297cdf0e10cSrcweir
298cdf0e10cSrcweir // nicht umhaengen wenn dieses das oberste Format ist !!
299cdf0e10cSrcweir if( GetRegisteredIn() && GetRegisteredIn() == pFmt )
300cdf0e10cSrcweir {
301cdf0e10cSrcweir if( pFmt->GetRegisteredIn() )
302cdf0e10cSrcweir {
303cdf0e10cSrcweir // wenn Parent, dann im neuen Parent wieder anmelden
304cdf0e10cSrcweir pFmt->DerivedFrom()->Add( this );
305cdf0e10cSrcweir aSet.SetParent( &DerivedFrom()->aSet );
306cdf0e10cSrcweir }
307cdf0e10cSrcweir else
308cdf0e10cSrcweir {
309cdf0e10cSrcweir // sonst auf jeden Fall beim sterbenden abmelden
310cdf0e10cSrcweir DerivedFrom()->Remove( this );
311cdf0e10cSrcweir aSet.SetParent( 0 );
312cdf0e10cSrcweir }
313cdf0e10cSrcweir }
314cdf0e10cSrcweir } // OBJECTDYING
315cdf0e10cSrcweir break;
316cdf0e10cSrcweir
317cdf0e10cSrcweir case RES_ATTRSET_CHG:
318cdf0e10cSrcweir if( ((SwAttrSetChg*)pOldValue)->GetTheChgdSet() != &aSet )
319cdf0e10cSrcweir {
320cdf0e10cSrcweir //nur die weiter geben, die hier nicht gesetzt sind !!
321cdf0e10cSrcweir SwAttrSetChg aOld( *(SwAttrSetChg*)pOldValue );
322cdf0e10cSrcweir SwAttrSetChg aNew( *(SwAttrSetChg*)pNewValue );
323cdf0e10cSrcweir
324cdf0e10cSrcweir aOld.GetChgSet()->Differentiate( aSet );
325cdf0e10cSrcweir aNew.GetChgSet()->Differentiate( aSet );
326cdf0e10cSrcweir
327cdf0e10cSrcweir if( aNew.Count() )
328cdf0e10cSrcweir // keine mehr gesetzt, dann Ende !!
329cdf0e10cSrcweir NotifyClients( &aOld, &aNew );
330cdf0e10cSrcweir bWeiter = sal_False;
331cdf0e10cSrcweir }
332cdf0e10cSrcweir break;
333cdf0e10cSrcweir case RES_FMT_CHG:
334cdf0e10cSrcweir // falls mein Format Parent umgesetzt wird, dann melde ich
335cdf0e10cSrcweir // meinen Attrset beim Neuen an.
336cdf0e10cSrcweir
337cdf0e10cSrcweir // sein eigenes Modify ueberspringen !!
338cdf0e10cSrcweir if( ((SwFmtChg*)pOldValue)->pChangedFmt != this &&
339cdf0e10cSrcweir ((SwFmtChg*)pNewValue)->pChangedFmt == DerivedFrom() )
340cdf0e10cSrcweir {
341cdf0e10cSrcweir // den Set an den neuen Parent haengen
342cdf0e10cSrcweir aSet.SetParent( DerivedFrom() ? &DerivedFrom()->aSet : 0 );
343cdf0e10cSrcweir }
344cdf0e10cSrcweir break;
345cdf0e10cSrcweir
346cdf0e10cSrcweir case RES_RESET_FMTWRITTEN:
347cdf0e10cSrcweir {
348cdf0e10cSrcweir // IsWritten-Flag zuruecksetzen. Hint nur an abhanegige
349cdf0e10cSrcweir // Formate (und keine Frames) propagieren.
350cdf0e10cSrcweir // mba: the code does the opposite from what is written in the comment!
351cdf0e10cSrcweir ResetWritten();
352cdf0e10cSrcweir // mba: here we don't use the additional stuff from NotifyClients().
353cdf0e10cSrcweir // should we?!
354cdf0e10cSrcweir // mba: move the code that ignores this event to the clients
355cdf0e10cSrcweir ModifyBroadcast( pOldValue, pNewValue, TYPE(SwFmt) );
356cdf0e10cSrcweir bWeiter = sal_False;
357cdf0e10cSrcweir }
358cdf0e10cSrcweir break;
359cdf0e10cSrcweir
360cdf0e10cSrcweir default:
361cdf0e10cSrcweir {
362cdf0e10cSrcweir // Ist das Attribut in diesem Format definiert, dann auf
363cdf0e10cSrcweir // NICHT weiter propagieren !!
364cdf0e10cSrcweir if( SFX_ITEM_SET == aSet.GetItemState( nWhich, sal_False ))
365cdf0e10cSrcweir {
366cdf0e10cSrcweir // wie finde ich heraus, ob nicht ich die Message versende ??
367cdf0e10cSrcweir // aber wer ruft das hier ????
368cdf0e10cSrcweir //ASSERT( sal_False, "Modify ohne Absender verschickt" );
369cdf0e10cSrcweir //JP 11.06.96: DropCaps koennen hierher kommen
370cdf0e10cSrcweir ASSERT( RES_PARATR_DROP == nWhich, "Modify ohne Absender verschickt" );
371cdf0e10cSrcweir bWeiter = sal_False;
372cdf0e10cSrcweir }
373cdf0e10cSrcweir
374cdf0e10cSrcweir } // default
375cdf0e10cSrcweir } // switch
376cdf0e10cSrcweir
377cdf0e10cSrcweir if( bWeiter )
378cdf0e10cSrcweir {
379cdf0e10cSrcweir // laufe durch alle abhaengigen Formate
380cdf0e10cSrcweir NotifyClients( pOldValue, pNewValue );
381cdf0e10cSrcweir }
382cdf0e10cSrcweir
383cdf0e10cSrcweir }
384cdf0e10cSrcweir
385cdf0e10cSrcweir
SetDerivedFrom(SwFmt * pDerFrom)386cdf0e10cSrcweir sal_Bool SwFmt::SetDerivedFrom(SwFmt *pDerFrom)
387cdf0e10cSrcweir {
388cdf0e10cSrcweir if ( pDerFrom )
389cdf0e10cSrcweir {
390cdf0e10cSrcweir // Zyklus?
391cdf0e10cSrcweir const SwFmt* pFmt = pDerFrom;
392cdf0e10cSrcweir while ( pFmt != 0 )
393cdf0e10cSrcweir {
394cdf0e10cSrcweir if ( pFmt == this )
395cdf0e10cSrcweir return sal_False;
396cdf0e10cSrcweir
397cdf0e10cSrcweir pFmt=pFmt->DerivedFrom();
398cdf0e10cSrcweir }
399cdf0e10cSrcweir }
400cdf0e10cSrcweir else
401cdf0e10cSrcweir {
402cdf0e10cSrcweir // Nichts angegeben, Dflt-Format suchen
403cdf0e10cSrcweir pDerFrom = this;
404cdf0e10cSrcweir while ( pDerFrom->DerivedFrom() )
405cdf0e10cSrcweir pDerFrom = pDerFrom->DerivedFrom();
406cdf0e10cSrcweir }
407cdf0e10cSrcweir if ( (pDerFrom == DerivedFrom()) || (pDerFrom == this) )
408cdf0e10cSrcweir return sal_False;
409cdf0e10cSrcweir
410cdf0e10cSrcweir ASSERT( Which()==pDerFrom->Which()
411cdf0e10cSrcweir || ( Which()==RES_CONDTXTFMTCOLL && pDerFrom->Which()==RES_TXTFMTCOLL)
412cdf0e10cSrcweir || ( Which()==RES_TXTFMTCOLL && pDerFrom->Which()==RES_CONDTXTFMTCOLL)
413cdf0e10cSrcweir || ( Which()==RES_FLYFRMFMT && pDerFrom->Which()==RES_FRMFMT ),
414cdf0e10cSrcweir "SetDerivedFrom: Aepfel von Birnen ableiten?");
415cdf0e10cSrcweir
416cdf0e10cSrcweir if ( IsInCache() )
417cdf0e10cSrcweir {
418cdf0e10cSrcweir SwFrm::GetCache().Delete( this );
419cdf0e10cSrcweir SetInCache( sal_False );
420cdf0e10cSrcweir }
421cdf0e10cSrcweir SetInSwFntCache( sal_False );
422cdf0e10cSrcweir
423cdf0e10cSrcweir pDerFrom->Add(this);
424cdf0e10cSrcweir aSet.SetParent( &pDerFrom->aSet );
425cdf0e10cSrcweir
426cdf0e10cSrcweir SwFmtChg aOldFmt(this);
427cdf0e10cSrcweir SwFmtChg aNewFmt(this);
428cdf0e10cSrcweir ModifyNotification( &aOldFmt, &aNewFmt );
429cdf0e10cSrcweir
430cdf0e10cSrcweir return sal_True;
431cdf0e10cSrcweir }
432cdf0e10cSrcweir
433cdf0e10cSrcweir
SetFmtAttr(const SfxPoolItem & rAttr)434cdf0e10cSrcweir sal_Bool SwFmt::SetFmtAttr(const SfxPoolItem& rAttr )
435cdf0e10cSrcweir {
436cdf0e10cSrcweir if ( IsInCache() || IsInSwFntCache() )
437cdf0e10cSrcweir {
438cdf0e10cSrcweir const sal_uInt16 nWhich = rAttr.Which();
439cdf0e10cSrcweir CheckCaching( nWhich );
440cdf0e10cSrcweir }
441cdf0e10cSrcweir
442cdf0e10cSrcweir // wenn Modify gelockt ist, werden keine Modifies verschickt;
443cdf0e10cSrcweir // fuer FrmFmt's immer das Modify verschicken!
444cdf0e10cSrcweir sal_Bool bRet = sal_False;
445cdf0e10cSrcweir const sal_uInt16 nFmtWhich = Which();
446cdf0e10cSrcweir if( IsModifyLocked() || (!GetDepends() &&
447cdf0e10cSrcweir (RES_GRFFMTCOLL == nFmtWhich ||
448cdf0e10cSrcweir RES_TXTFMTCOLL == nFmtWhich ) ) )
449cdf0e10cSrcweir {
450cdf0e10cSrcweir if( 0 != ( bRet = (0 != aSet.Put( rAttr ))) )
451cdf0e10cSrcweir aSet.SetModifyAtAttr( this );
452cdf0e10cSrcweir if ( nFmtWhich == RES_TXTFMTCOLL && rAttr.Which() == RES_PARATR_NUMRULE )
453cdf0e10cSrcweir {
454cdf0e10cSrcweir TxtFmtCollFunc::CheckTxtFmtCollForDeletionOfAssignmentToOutlineStyle( this );
455cdf0e10cSrcweir }
456cdf0e10cSrcweir }
457cdf0e10cSrcweir else
458cdf0e10cSrcweir {
459cdf0e10cSrcweir // kopiere nur das Attribut-Delta Array
460cdf0e10cSrcweir SwAttrSet aOld( *aSet.GetPool(), aSet.GetRanges() ),
461cdf0e10cSrcweir aNew( *aSet.GetPool(), aSet.GetRanges() );
462cdf0e10cSrcweir
463cdf0e10cSrcweir bRet = 0 != aSet.Put_BC( rAttr, &aOld, &aNew );
464cdf0e10cSrcweir if( bRet )
465cdf0e10cSrcweir {
466cdf0e10cSrcweir // einige Sonderbehandlungen fuer Attribute
467cdf0e10cSrcweir aSet.SetModifyAtAttr( this );
468cdf0e10cSrcweir
469cdf0e10cSrcweir SwAttrSetChg aChgOld( aSet, aOld );
470cdf0e10cSrcweir SwAttrSetChg aChgNew( aSet, aNew );
471cdf0e10cSrcweir ModifyNotification( &aChgOld, &aChgNew ); // alle veraenderten werden verschickt
472cdf0e10cSrcweir }
473cdf0e10cSrcweir }
474cdf0e10cSrcweir return bRet;
475cdf0e10cSrcweir }
476cdf0e10cSrcweir
477cdf0e10cSrcweir
SetFmtAttr(const SfxItemSet & rSet)478cdf0e10cSrcweir sal_Bool SwFmt::SetFmtAttr( const SfxItemSet& rSet )
479cdf0e10cSrcweir {
480cdf0e10cSrcweir if( !rSet.Count() )
481cdf0e10cSrcweir return sal_False;
482cdf0e10cSrcweir
483cdf0e10cSrcweir if ( IsInCache() )
484cdf0e10cSrcweir {
485cdf0e10cSrcweir SwFrm::GetCache().Delete( this );
486cdf0e10cSrcweir SetInCache( sal_False );
487cdf0e10cSrcweir }
488cdf0e10cSrcweir SetInSwFntCache( sal_False );
489cdf0e10cSrcweir
490cdf0e10cSrcweir // wenn Modify gelockt ist, werden keine Modifies verschickt;
491cdf0e10cSrcweir // fuer FrmFmt's immer das Modify verschicken!
492cdf0e10cSrcweir sal_Bool bRet = sal_False;
493cdf0e10cSrcweir const sal_uInt16 nFmtWhich = Which();
494cdf0e10cSrcweir if ( IsModifyLocked() ||
495cdf0e10cSrcweir ( !GetDepends() &&
496cdf0e10cSrcweir ( RES_GRFFMTCOLL == nFmtWhich ||
497cdf0e10cSrcweir RES_TXTFMTCOLL == nFmtWhich ) ) )
498cdf0e10cSrcweir {
499cdf0e10cSrcweir if( 0 != ( bRet = (0 != aSet.Put( rSet ))) )
500cdf0e10cSrcweir aSet.SetModifyAtAttr( this );
501cdf0e10cSrcweir if ( nFmtWhich == RES_TXTFMTCOLL )
502cdf0e10cSrcweir {
503cdf0e10cSrcweir TxtFmtCollFunc::CheckTxtFmtCollForDeletionOfAssignmentToOutlineStyle( this );
504cdf0e10cSrcweir }
505cdf0e10cSrcweir }
506cdf0e10cSrcweir else
507cdf0e10cSrcweir {
508cdf0e10cSrcweir SwAttrSet aOld( *aSet.GetPool(), aSet.GetRanges() ),
509cdf0e10cSrcweir aNew( *aSet.GetPool(), aSet.GetRanges() );
510cdf0e10cSrcweir bRet = 0 != aSet.Put_BC( rSet, &aOld, &aNew );
511cdf0e10cSrcweir if( bRet )
512cdf0e10cSrcweir {
513cdf0e10cSrcweir // einige Sonderbehandlungen fuer Attribute
514cdf0e10cSrcweir aSet.SetModifyAtAttr( this );
515cdf0e10cSrcweir SwAttrSetChg aChgOld( aSet, aOld );
516cdf0e10cSrcweir SwAttrSetChg aChgNew( aSet, aNew );
517cdf0e10cSrcweir ModifyNotification( &aChgOld, &aChgNew ); // alle veraenderten werden verschickt
518cdf0e10cSrcweir }
519cdf0e10cSrcweir }
520cdf0e10cSrcweir return bRet;
521cdf0e10cSrcweir }
522cdf0e10cSrcweir
523cdf0e10cSrcweir // Nimmt den Hint mit nWhich aus dem Delta-Array
524cdf0e10cSrcweir
525cdf0e10cSrcweir
ResetFmtAttr(sal_uInt16 nWhich1,sal_uInt16 nWhich2)526cdf0e10cSrcweir sal_Bool SwFmt::ResetFmtAttr( sal_uInt16 nWhich1, sal_uInt16 nWhich2 )
527cdf0e10cSrcweir {
528cdf0e10cSrcweir if( !aSet.Count() )
529cdf0e10cSrcweir return sal_False;
530cdf0e10cSrcweir
531cdf0e10cSrcweir if( !nWhich2 || nWhich2 < nWhich1 )
532cdf0e10cSrcweir nWhich2 = nWhich1; // dann setze auf 1. Id, nur dieses Item
533cdf0e10cSrcweir
534cdf0e10cSrcweir if ( IsInCache() || IsInSwFntCache() )
535cdf0e10cSrcweir {
536cdf0e10cSrcweir for( sal_uInt16 n = nWhich1; n < nWhich2; ++n )
537cdf0e10cSrcweir CheckCaching( n );
538cdf0e10cSrcweir }
539cdf0e10cSrcweir
540cdf0e10cSrcweir // wenn Modify gelockt ist, werden keine Modifies verschickt
541cdf0e10cSrcweir if( IsModifyLocked() )
542cdf0e10cSrcweir return 0 != (( nWhich2 == nWhich1 )
543cdf0e10cSrcweir ? aSet.ClearItem( nWhich1 )
544cdf0e10cSrcweir : aSet.ClearItem_BC( nWhich1, nWhich2 ));
545cdf0e10cSrcweir
546cdf0e10cSrcweir SwAttrSet aOld( *aSet.GetPool(), aSet.GetRanges() ),
547cdf0e10cSrcweir aNew( *aSet.GetPool(), aSet.GetRanges() );
548cdf0e10cSrcweir sal_Bool bRet = 0 != aSet.ClearItem_BC( nWhich1, nWhich2, &aOld, &aNew );
549cdf0e10cSrcweir
550cdf0e10cSrcweir if( bRet )
551cdf0e10cSrcweir {
552cdf0e10cSrcweir SwAttrSetChg aChgOld( aSet, aOld );
553cdf0e10cSrcweir SwAttrSetChg aChgNew( aSet, aNew );
554cdf0e10cSrcweir ModifyNotification( &aChgOld, &aChgNew ); // alle veraenderten werden verschickt
555cdf0e10cSrcweir }
556cdf0e10cSrcweir return bRet;
557cdf0e10cSrcweir }
558cdf0e10cSrcweir
559cdf0e10cSrcweir
560cdf0e10cSrcweir
561cdf0e10cSrcweir // --> OD 2007-01-24 #i73790#
562cdf0e10cSrcweir // method renamed
ResetAllFmtAttr()563cdf0e10cSrcweir sal_uInt16 SwFmt::ResetAllFmtAttr()
564cdf0e10cSrcweir // <--
565cdf0e10cSrcweir {
566cdf0e10cSrcweir if( !aSet.Count() )
567cdf0e10cSrcweir return 0;
568cdf0e10cSrcweir
569cdf0e10cSrcweir if ( IsInCache() )
570cdf0e10cSrcweir {
571cdf0e10cSrcweir SwFrm::GetCache().Delete( this );
572cdf0e10cSrcweir SetInCache( sal_False );
573cdf0e10cSrcweir }
574cdf0e10cSrcweir SetInSwFntCache( sal_False );
575cdf0e10cSrcweir
576cdf0e10cSrcweir // wenn Modify gelockt ist, werden keine Modifies verschickt
577cdf0e10cSrcweir if( IsModifyLocked() )
578cdf0e10cSrcweir return aSet.ClearItem( 0 );
579cdf0e10cSrcweir
580cdf0e10cSrcweir SwAttrSet aOld( *aSet.GetPool(), aSet.GetRanges() ),
581cdf0e10cSrcweir aNew( *aSet.GetPool(), aSet.GetRanges() );
582cdf0e10cSrcweir sal_Bool bRet = 0 != aSet.ClearItem_BC( 0, &aOld, &aNew );
583cdf0e10cSrcweir
584cdf0e10cSrcweir if( bRet )
585cdf0e10cSrcweir {
586cdf0e10cSrcweir SwAttrSetChg aChgOld( aSet, aOld );
587cdf0e10cSrcweir SwAttrSetChg aChgNew( aSet, aNew );
588cdf0e10cSrcweir ModifyNotification( &aChgOld, &aChgNew ); // alle veraenderten werden verschickt
589cdf0e10cSrcweir }
590cdf0e10cSrcweir return aNew.Count();
591cdf0e10cSrcweir }
592cdf0e10cSrcweir
593cdf0e10cSrcweir
594cdf0e10cSrcweir /*************************************************************************
595cdf0e10cSrcweir |* void SwFmt::GetInfo( const SfxPoolItem& ) const
596cdf0e10cSrcweir |*
597cdf0e10cSrcweir |* Beschreibung
598cdf0e10cSrcweir |* Ersterstellung JP 18.04.94
599cdf0e10cSrcweir |* Letzte Aenderung JP 05.08.94
600cdf0e10cSrcweir *************************************************************************/
601cdf0e10cSrcweir
602cdf0e10cSrcweir
GetInfo(SfxPoolItem & rInfo) const603cdf0e10cSrcweir sal_Bool SwFmt::GetInfo( SfxPoolItem& rInfo ) const
604cdf0e10cSrcweir {
605cdf0e10cSrcweir sal_Bool bRet = SwModify::GetInfo( rInfo );
606cdf0e10cSrcweir return bRet;
607cdf0e10cSrcweir }
608cdf0e10cSrcweir
609cdf0e10cSrcweir
DelDiffs(const SfxItemSet & rSet)610cdf0e10cSrcweir void SwFmt::DelDiffs( const SfxItemSet& rSet )
611cdf0e10cSrcweir {
612cdf0e10cSrcweir if( !aSet.Count() )
613cdf0e10cSrcweir return;
614cdf0e10cSrcweir
615cdf0e10cSrcweir if ( IsInCache() )
616cdf0e10cSrcweir {
617cdf0e10cSrcweir SwFrm::GetCache().Delete( this );
618cdf0e10cSrcweir SetInCache( sal_False );
619cdf0e10cSrcweir }
620cdf0e10cSrcweir SetInSwFntCache( sal_False );
621cdf0e10cSrcweir
622cdf0e10cSrcweir // wenn Modify gelockt ist, werden keine Modifies verschickt
623cdf0e10cSrcweir if( IsModifyLocked() )
624cdf0e10cSrcweir {
625cdf0e10cSrcweir aSet.Intersect( rSet );
626cdf0e10cSrcweir return;
627cdf0e10cSrcweir }
628cdf0e10cSrcweir
629cdf0e10cSrcweir SwAttrSet aOld( *aSet.GetPool(), aSet.GetRanges() ),
630cdf0e10cSrcweir aNew( *aSet.GetPool(), aSet.GetRanges() );
631cdf0e10cSrcweir sal_Bool bRet = 0 != aSet.Intersect_BC( rSet, &aOld, &aNew );
632cdf0e10cSrcweir
633cdf0e10cSrcweir if( bRet )
634cdf0e10cSrcweir {
635cdf0e10cSrcweir SwAttrSetChg aChgOld( aSet, aOld );
636cdf0e10cSrcweir SwAttrSetChg aChgNew( aSet, aNew );
637cdf0e10cSrcweir ModifyNotification( &aChgOld, &aChgNew ); // alle veraenderten werden verschickt
638cdf0e10cSrcweir }
639cdf0e10cSrcweir }
640cdf0e10cSrcweir
641cdf0e10cSrcweir /** SwFmt::IsBackgroundTransparent - for feature #99657#
642cdf0e10cSrcweir
643cdf0e10cSrcweir OD 22.08.2002
644cdf0e10cSrcweir Virtual method to determine, if background of format is transparent.
645cdf0e10cSrcweir Default implementation returns false. Thus, subclasses have to overload
646cdf0e10cSrcweir method, if the specific subclass can have a transparent background.
647cdf0e10cSrcweir
648cdf0e10cSrcweir @author OD
649cdf0e10cSrcweir
650cdf0e10cSrcweir @return false, default implementation
651cdf0e10cSrcweir */
IsBackgroundTransparent() const652cdf0e10cSrcweir sal_Bool SwFmt::IsBackgroundTransparent() const
653cdf0e10cSrcweir {
654cdf0e10cSrcweir return sal_False;
655cdf0e10cSrcweir }
656cdf0e10cSrcweir
657cdf0e10cSrcweir /** SwFmt::IsShadowTransparent - for feature #99657#
658cdf0e10cSrcweir
659cdf0e10cSrcweir OD 22.08.2002
660cdf0e10cSrcweir Virtual method to determine, if shadow of format is transparent.
661cdf0e10cSrcweir Default implementation returns false. Thus, subclasses have to overload
662cdf0e10cSrcweir method, if the specific subclass can have a transparent shadow.
663cdf0e10cSrcweir
664cdf0e10cSrcweir @author OD
665cdf0e10cSrcweir
666cdf0e10cSrcweir @return false, default implementation
667cdf0e10cSrcweir */
IsShadowTransparent() const668cdf0e10cSrcweir sal_Bool SwFmt::IsShadowTransparent() const
669cdf0e10cSrcweir {
670cdf0e10cSrcweir return sal_False;
671cdf0e10cSrcweir }
672cdf0e10cSrcweir
673cdf0e10cSrcweir /*
674cdf0e10cSrcweir * Document Interface Access
675cdf0e10cSrcweir */
getIDocumentSettingAccess() const676cdf0e10cSrcweir const IDocumentSettingAccess* SwFmt::getIDocumentSettingAccess() const { return GetDoc(); }
getIDocumentDrawModelAccess() const677cdf0e10cSrcweir const IDocumentDrawModelAccess* SwFmt::getIDocumentDrawModelAccess() const { return GetDoc(); }
getIDocumentDrawModelAccess()678cdf0e10cSrcweir IDocumentDrawModelAccess* SwFmt::getIDocumentDrawModelAccess() { return GetDoc(); }
getIDocumentLayoutAccess() const679cdf0e10cSrcweir const IDocumentLayoutAccess* SwFmt::getIDocumentLayoutAccess() const { return GetDoc(); }
getIDocumentLayoutAccess()680cdf0e10cSrcweir IDocumentLayoutAccess* SwFmt::getIDocumentLayoutAccess() { return GetDoc(); }
getIDocumentTimerAccess()681cdf0e10cSrcweir IDocumentTimerAccess* SwFmt::getIDocumentTimerAccess() { return GetDoc(); }
getIDocumentFieldsAccess()682cdf0e10cSrcweir IDocumentFieldsAccess* SwFmt::getIDocumentFieldsAccess() { return GetDoc(); }
getIDocumentChartDataProviderAccess()683cdf0e10cSrcweir IDocumentChartDataProviderAccess* SwFmt::getIDocumentChartDataProviderAccess() { return GetDoc(); }
684cdf0e10cSrcweir
685