xref: /aoo41x/main/sw/source/core/attr/calbck.cxx (revision efeef26f)
1*efeef26fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*efeef26fSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*efeef26fSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*efeef26fSAndrew Rist  * distributed with this work for additional information
6*efeef26fSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*efeef26fSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*efeef26fSAndrew Rist  * "License"); you may not use this file except in compliance
9*efeef26fSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*efeef26fSAndrew Rist  *
11*efeef26fSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*efeef26fSAndrew Rist  *
13*efeef26fSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*efeef26fSAndrew Rist  * software distributed under the License is distributed on an
15*efeef26fSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*efeef26fSAndrew Rist  * KIND, either express or implied.  See the License for the
17*efeef26fSAndrew Rist  * specific language governing permissions and limitations
18*efeef26fSAndrew Rist  * under the License.
19*efeef26fSAndrew Rist  *
20*efeef26fSAndrew Rist  *************************************************************/
21*efeef26fSAndrew Rist 
22*efeef26fSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sw.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <hintids.hxx>		    // contains RES_.. IDs
28cdf0e10cSrcweir #include <frame.hxx>
29cdf0e10cSrcweir #include <hints.hxx>
30cdf0e10cSrcweir #include <swcache.hxx>          // mba: get rid of that dependency
31cdf0e10cSrcweir #include <swfntcch.hxx>         // mba: get rid of that dependency
32cdf0e10cSrcweir 
33cdf0e10cSrcweir static SwClientIter* pClientIters = 0;
34cdf0e10cSrcweir 
35cdf0e10cSrcweir TYPEINIT0(SwClient);
36cdf0e10cSrcweir 
37cdf0e10cSrcweir /*************************************************************************/
SwClient(SwModify * pToRegisterIn)38cdf0e10cSrcweir SwClient::SwClient(SwModify *pToRegisterIn)
39cdf0e10cSrcweir 	: pLeft( 0 ), pRight( 0 ), pRegisteredIn( 0 ), mbIsAllowedToBeRemovedInModifyCall(false)
40cdf0e10cSrcweir {
41cdf0e10cSrcweir 	if(pToRegisterIn)
42cdf0e10cSrcweir         // connect to SwModify
43cdf0e10cSrcweir 		pToRegisterIn->Add(this);
44cdf0e10cSrcweir }
45cdf0e10cSrcweir 
46cdf0e10cSrcweir /*************************************************************************/
CheckRegistration(const SfxPoolItem * pOld,const SfxPoolItem *)47cdf0e10cSrcweir void SwClient::CheckRegistration( const SfxPoolItem* pOld, const SfxPoolItem * )
48cdf0e10cSrcweir {
49cdf0e10cSrcweir     // this method only handles notification about dying SwModify objects
50cdf0e10cSrcweir 	if( (!pOld || pOld->Which() != RES_OBJECTDYING) )
51cdf0e10cSrcweir 		return;
52cdf0e10cSrcweir 
53cdf0e10cSrcweir 	const SwPtrMsgPoolItem *pDead = static_cast<const SwPtrMsgPoolItem*>(pOld);
54cdf0e10cSrcweir 	if(pDead && pDead->pObject == pRegisteredIn)
55cdf0e10cSrcweir 	{
56cdf0e10cSrcweir         // I've got a notification from the object I know
57cdf0e10cSrcweir 		SwModify *pAbove = const_cast<SwModify*>(pRegisteredIn->GetRegisteredIn());
58cdf0e10cSrcweir 		if(pAbove)
59cdf0e10cSrcweir 		{
60cdf0e10cSrcweir             // if the dying object itself was listening at an SwModify, I take over
61cdf0e10cSrcweir             // adding myself to pAbove will automatically remove me from my current pRegisteredIn
62cdf0e10cSrcweir 			pAbove->Add(this);
63cdf0e10cSrcweir 			return;
64cdf0e10cSrcweir 		}
65cdf0e10cSrcweir 
66cdf0e10cSrcweir         // destroy connection
67cdf0e10cSrcweir 		pRegisteredIn->Remove(this);
68cdf0e10cSrcweir 	}
69cdf0e10cSrcweir }
70cdf0e10cSrcweir 
Modify(const SfxPoolItem * pOldValue,const SfxPoolItem * pNewValue)71cdf0e10cSrcweir void SwClient::Modify( const SfxPoolItem *pOldValue, const SfxPoolItem *pNewValue )
72cdf0e10cSrcweir {
73cdf0e10cSrcweir     CheckRegistration( pOldValue, pNewValue );
74cdf0e10cSrcweir }
75cdf0e10cSrcweir 
SwClientNotify(const SwModify &,const SfxHint &)76cdf0e10cSrcweir void SwClient::SwClientNotify( const SwModify&, const SfxHint& )
77cdf0e10cSrcweir {
78cdf0e10cSrcweir 
79cdf0e10cSrcweir }
80cdf0e10cSrcweir 
81cdf0e10cSrcweir //*************************************************************************
~SwClient()82cdf0e10cSrcweir SwClient::~SwClient()
83cdf0e10cSrcweir {
84cdf0e10cSrcweir     DBG_ASSERT( !pRegisteredIn || pRegisteredIn->GetDepends(),"SwModify still known, but Client already disconnected!" );
85cdf0e10cSrcweir 	if( pRegisteredIn && pRegisteredIn->GetDepends() )
86cdf0e10cSrcweir         // still connected
87cdf0e10cSrcweir 		pRegisteredIn->Remove( this );
88cdf0e10cSrcweir }
89cdf0e10cSrcweir 
90cdf0e10cSrcweir 
GetInfo(SfxPoolItem &) const91cdf0e10cSrcweir sal_Bool SwClient::GetInfo( SfxPoolItem& ) const
92cdf0e10cSrcweir {
93cdf0e10cSrcweir 	return sal_True;		// und weiter
94cdf0e10cSrcweir }
95cdf0e10cSrcweir 
96cdf0e10cSrcweir 
97cdf0e10cSrcweir /*************************************************************************/
SwModify()98cdf0e10cSrcweir SwModify::SwModify()
99cdf0e10cSrcweir     : SwClient(0), pRoot(0)
100cdf0e10cSrcweir {
101cdf0e10cSrcweir     bModifyLocked = sal_False;
102cdf0e10cSrcweir     bLockClientList = sal_False;
103cdf0e10cSrcweir 	bInDocDTOR = sal_False;
104cdf0e10cSrcweir 	bInCache = sal_False;
105cdf0e10cSrcweir 	bInSwFntCache = sal_False;
106cdf0e10cSrcweir }
107cdf0e10cSrcweir 
SwModify(SwModify * pToRegisterIn)108cdf0e10cSrcweir SwModify::SwModify( SwModify *pToRegisterIn )
109cdf0e10cSrcweir 	: SwClient(pToRegisterIn), pRoot( 0 )
110cdf0e10cSrcweir {
111cdf0e10cSrcweir     bModifyLocked = sal_False;
112cdf0e10cSrcweir     bLockClientList = sal_False;
113cdf0e10cSrcweir 	bInDocDTOR = sal_False;
114cdf0e10cSrcweir 	bInCache = sal_False;
115cdf0e10cSrcweir 	bInSwFntCache = sal_False;
116cdf0e10cSrcweir }
117cdf0e10cSrcweir 
118cdf0e10cSrcweir /*************************************************************************/
~SwModify()119cdf0e10cSrcweir SwModify::~SwModify()
120cdf0e10cSrcweir {
121cdf0e10cSrcweir 	ASSERT( !IsModifyLocked(), "Modify destroyed but locked." );
122cdf0e10cSrcweir 
123cdf0e10cSrcweir 	if ( IsInCache() )
124cdf0e10cSrcweir 		SwFrm::GetCache().Delete( this );
125cdf0e10cSrcweir 
126cdf0e10cSrcweir 	if ( IsInSwFntCache() )
127cdf0e10cSrcweir 		pSwFontCache->Delete( this );
128cdf0e10cSrcweir 
129cdf0e10cSrcweir 	if( pRoot )
130cdf0e10cSrcweir 	{
131cdf0e10cSrcweir         // there are depending objects
132cdf0e10cSrcweir 		if( IsInDocDTOR() )
133cdf0e10cSrcweir 		{
134cdf0e10cSrcweir 			// if document gets destroyed anyway, just tell clients to forget me
135cdf0e10cSrcweir             // so that they don't try to get removed from my list later when they also get destroyed
136cdf0e10cSrcweir 			SwClientIter aIter( *this );
137cdf0e10cSrcweir 			SwClient* p = aIter.GoStart();
138cdf0e10cSrcweir 			while ( p )
139cdf0e10cSrcweir             {
140cdf0e10cSrcweir 				p->pRegisteredIn = 0;
1412f121198SMathias Bauer                 p = ++aIter;
142cdf0e10cSrcweir             }
143cdf0e10cSrcweir 		}
144cdf0e10cSrcweir 		else
145cdf0e10cSrcweir 		{
146cdf0e10cSrcweir 			// notify all clients that they shall remove themselves
147cdf0e10cSrcweir 			SwPtrMsgPoolItem aDyObject( RES_OBJECTDYING, this );
148cdf0e10cSrcweir 			NotifyClients( &aDyObject, &aDyObject );
149cdf0e10cSrcweir 
150cdf0e10cSrcweir             // remove all clients that have not done themselves
151cdf0e10cSrcweir             // mba: possibly a hotfix for forgotten base class calls?!
152cdf0e10cSrcweir 			while( pRoot )
153cdf0e10cSrcweir 				pRoot->CheckRegistration(&aDyObject, &aDyObject);
154cdf0e10cSrcweir 		}
155cdf0e10cSrcweir 	}
156cdf0e10cSrcweir }
157cdf0e10cSrcweir 
158cdf0e10cSrcweir /*************************************************************************/
Modify(const SfxPoolItem * pOldValue,const SfxPoolItem * pNewValue)159cdf0e10cSrcweir void SwModify::Modify( const SfxPoolItem *pOldValue, const SfxPoolItem *pNewValue )
160cdf0e10cSrcweir {
161cdf0e10cSrcweir     NotifyClients( pOldValue, pNewValue );
162cdf0e10cSrcweir }
163cdf0e10cSrcweir 
NotifyClients(const SfxPoolItem * pOldValue,const SfxPoolItem * pNewValue)164cdf0e10cSrcweir void SwModify::NotifyClients( const SfxPoolItem *pOldValue, const SfxPoolItem *pNewValue )
165cdf0e10cSrcweir {
166cdf0e10cSrcweir 	if (IsInCache() || IsInSwFntCache())
167cdf0e10cSrcweir 	{
168cdf0e10cSrcweir 		const sal_uInt16 nWhich = pOldValue ? pOldValue->Which() :
169cdf0e10cSrcweir 										pNewValue ? pNewValue->Which() : 0;
170cdf0e10cSrcweir 		CheckCaching( nWhich );
171cdf0e10cSrcweir 	}
172cdf0e10cSrcweir 
173cdf0e10cSrcweir   	if (!pRoot || IsModifyLocked())
174cdf0e10cSrcweir 		return;
175cdf0e10cSrcweir 
176cdf0e10cSrcweir 	LockModify();
177cdf0e10cSrcweir 
178cdf0e10cSrcweir     // mba: WTF?!
179cdf0e10cSrcweir 	if( !pOldValue )
180cdf0e10cSrcweir 		bLockClientList = sal_True;
181cdf0e10cSrcweir 	else
182cdf0e10cSrcweir     {
183cdf0e10cSrcweir 		// following Modifies shouldn't call an ASSERT
184cdf0e10cSrcweir 		switch( pOldValue->Which() )
185cdf0e10cSrcweir 		{
186cdf0e10cSrcweir 		case RES_OBJECTDYING:
187cdf0e10cSrcweir  		case RES_REMOVE_UNO_OBJECT:
188cdf0e10cSrcweir 			bLockClientList = ((SwPtrMsgPoolItem *)pOldValue)->pObject != this;
189cdf0e10cSrcweir 			break;
190cdf0e10cSrcweir 
191cdf0e10cSrcweir 		case RES_FOOTNOTE_DELETED:
192cdf0e10cSrcweir 		case RES_REFMARK_DELETED:
193cdf0e10cSrcweir 		case RES_TOXMARK_DELETED:
194cdf0e10cSrcweir 		case RES_FIELD_DELETED:
195cdf0e10cSrcweir 			bLockClientList = sal_False;
196cdf0e10cSrcweir 			break;
197cdf0e10cSrcweir 		default:
198cdf0e10cSrcweir 			bLockClientList = sal_True;
199cdf0e10cSrcweir 		}
200cdf0e10cSrcweir     }
201cdf0e10cSrcweir 
202cdf0e10cSrcweir     ModifyBroadcast( pOldValue, pNewValue );
203cdf0e10cSrcweir 	bLockClientList = sal_False;
204cdf0e10cSrcweir 	UnlockModify();
205cdf0e10cSrcweir }
206cdf0e10cSrcweir 
GetInfo(SfxPoolItem & rInfo) const207cdf0e10cSrcweir sal_Bool SwModify::GetInfo( SfxPoolItem& rInfo ) const
208cdf0e10cSrcweir {
209cdf0e10cSrcweir 	sal_Bool bRet = sal_True;		// bedeutet weiter zum naechsten
210cdf0e10cSrcweir 
211cdf0e10cSrcweir 	if( pRoot )
212cdf0e10cSrcweir 	{
213cdf0e10cSrcweir 		SwClientIter aIter( *(SwModify*)this );
214cdf0e10cSrcweir 
215cdf0e10cSrcweir 		SwClient* pLast = aIter.GoStart();
216cdf0e10cSrcweir 		if( pLast )
217cdf0e10cSrcweir 			while( 0 != ( bRet = pLast->GetInfo( rInfo )) &&
2182f121198SMathias Bauer 					0 != ( pLast = ++aIter ) )
219cdf0e10cSrcweir 				;
220cdf0e10cSrcweir 	}
221cdf0e10cSrcweir 
222cdf0e10cSrcweir 	return bRet;
223cdf0e10cSrcweir }
224cdf0e10cSrcweir 
225cdf0e10cSrcweir /*************************************************************************/
Add(SwClient * pDepend)226cdf0e10cSrcweir void SwModify::Add(SwClient *pDepend)
227cdf0e10cSrcweir {
228cdf0e10cSrcweir 	ASSERT( !bLockClientList, "Client inserted while in Modify" );
229cdf0e10cSrcweir 
230cdf0e10cSrcweir 	if(pDepend->pRegisteredIn != this )
231cdf0e10cSrcweir 	{
232cdf0e10cSrcweir #ifdef DBG_UTIL
233cdf0e10cSrcweir 		SwClientIter* pTmp = pClientIters;
234cdf0e10cSrcweir 		while( pTmp )
235cdf0e10cSrcweir 		{
236cdf0e10cSrcweir 			ASSERT( &pTmp->GetModify() != pRoot, "Client added to active ClientIter" );
237cdf0e10cSrcweir 			pTmp = pTmp->pNxtIter;
238cdf0e10cSrcweir 		}
239cdf0e10cSrcweir #endif
240cdf0e10cSrcweir 		// deregister new client in case it is already registered elsewhere
241cdf0e10cSrcweir 		if( pDepend->pRegisteredIn != 0 )
242cdf0e10cSrcweir 			pDepend->pRegisteredIn->Remove( pDepend );
243cdf0e10cSrcweir 
244cdf0e10cSrcweir 		if( !pRoot )
245cdf0e10cSrcweir 		{
246cdf0e10cSrcweir             // first client added
247cdf0e10cSrcweir 			pRoot = pDepend;
248cdf0e10cSrcweir 			pRoot->pLeft = 0;
249cdf0e10cSrcweir 			pRoot->pRight = 0;
250cdf0e10cSrcweir 		}
251cdf0e10cSrcweir 		else
252cdf0e10cSrcweir 		{
253cdf0e10cSrcweir 			// append client
254cdf0e10cSrcweir 			pDepend->pRight = pRoot->pRight;
255cdf0e10cSrcweir 			pRoot->pRight = pDepend;
256cdf0e10cSrcweir 			pDepend->pLeft = pRoot;
257cdf0e10cSrcweir 			if( pDepend->pRight )
258cdf0e10cSrcweir 				pDepend->pRight->pLeft = pDepend;
259cdf0e10cSrcweir 		}
260cdf0e10cSrcweir 
261cdf0e10cSrcweir         // connect client to me
262cdf0e10cSrcweir 		pDepend->pRegisteredIn = this;
263cdf0e10cSrcweir 	}
264cdf0e10cSrcweir }
265cdf0e10cSrcweir 
266cdf0e10cSrcweir /*************************************************************************/
267cdf0e10cSrcweir 
Remove(SwClient * pDepend)268cdf0e10cSrcweir SwClient* SwModify::Remove(SwClient * pDepend)
269cdf0e10cSrcweir {
270cdf0e10cSrcweir 	if ( bInDocDTOR )
271cdf0e10cSrcweir         return 0;
272cdf0e10cSrcweir 
273cdf0e10cSrcweir     ASSERT( !bLockClientList || pDepend->mbIsAllowedToBeRemovedInModifyCall, "SwClient shall be removed in Modify call!" );
274cdf0e10cSrcweir 
275cdf0e10cSrcweir 	if( pDepend->pRegisteredIn == this )
276cdf0e10cSrcweir 	{
277cdf0e10cSrcweir         // SwClient is my listener
278cdf0e10cSrcweir         // remove it from my list
279cdf0e10cSrcweir 		SwClient* pR = pDepend->pRight;
280cdf0e10cSrcweir 		SwClient* pL = pDepend->pLeft;
281cdf0e10cSrcweir 		if( pRoot == pDepend )
282cdf0e10cSrcweir 			pRoot = pL ? pL : pR;
283cdf0e10cSrcweir 
284cdf0e10cSrcweir 		if( pL )
285cdf0e10cSrcweir 			pL->pRight = pR;
286cdf0e10cSrcweir 		if( pR )
287cdf0e10cSrcweir 			pR->pLeft = pL;
288cdf0e10cSrcweir 
289cdf0e10cSrcweir 		// update ClientIters
290cdf0e10cSrcweir 		SwClientIter* pTmp = pClientIters;
291cdf0e10cSrcweir 		while( pTmp )
292cdf0e10cSrcweir 		{
293cdf0e10cSrcweir 			if( pTmp->pAct == pDepend || pTmp->pDelNext == pDepend )
294cdf0e10cSrcweir                 // if object being removed is the current or next object in an iterator, advance this iterator
295cdf0e10cSrcweir 				pTmp->pDelNext = pR;
296cdf0e10cSrcweir 			pTmp = pTmp->pNxtIter;
297cdf0e10cSrcweir 		}
298cdf0e10cSrcweir 
299cdf0e10cSrcweir 		pDepend->pLeft = 0;
300cdf0e10cSrcweir 		pDepend->pRight = 0;
301cdf0e10cSrcweir 	}
302cdf0e10cSrcweir 	else
303cdf0e10cSrcweir     {
304cdf0e10cSrcweir 		ASSERT( false, "SwModify::Remove(): pDepend nicht gefunden" );
305cdf0e10cSrcweir     }
306cdf0e10cSrcweir 
307cdf0e10cSrcweir     // disconnect client from me
308cdf0e10cSrcweir 	pDepend->pRegisteredIn = 0;
309cdf0e10cSrcweir 	return pDepend;
310cdf0e10cSrcweir }
311cdf0e10cSrcweir 
GetClientCount() const312cdf0e10cSrcweir int SwModify::GetClientCount() const
313cdf0e10cSrcweir {
314cdf0e10cSrcweir     int nRet=0;
315cdf0e10cSrcweir     SwClientIter aIter( *this );
316cdf0e10cSrcweir     SwClient *pLast = aIter.GoStart();
317cdf0e10cSrcweir     if( pLast )
318cdf0e10cSrcweir         do
319cdf0e10cSrcweir         {
320cdf0e10cSrcweir             ++nRet;
3212f121198SMathias Bauer         } while( 0 != ( pLast = ++aIter ));
322cdf0e10cSrcweir     return nRet;
323cdf0e10cSrcweir }
324cdf0e10cSrcweir 
CheckCaching(const sal_uInt16 nWhich)325cdf0e10cSrcweir void SwModify::CheckCaching( const sal_uInt16 nWhich )
326cdf0e10cSrcweir {
327cdf0e10cSrcweir     if (isCHRATR(nWhich))
328cdf0e10cSrcweir     {
329cdf0e10cSrcweir         SetInSwFntCache( sal_False );
330cdf0e10cSrcweir     }
331cdf0e10cSrcweir 	else
332cdf0e10cSrcweir 		switch ( nWhich )
333cdf0e10cSrcweir 		{
334cdf0e10cSrcweir 		case RES_OBJECTDYING:
335cdf0e10cSrcweir 		case RES_FMT_CHG:
336cdf0e10cSrcweir 		case RES_ATTRSET_CHG:
337cdf0e10cSrcweir 			SetInSwFntCache( sal_False );
338cdf0e10cSrcweir 
339cdf0e10cSrcweir 		case RES_UL_SPACE:
340cdf0e10cSrcweir 		case RES_LR_SPACE:
341cdf0e10cSrcweir 		case RES_BOX:
342cdf0e10cSrcweir 		case RES_SHADOW:
343cdf0e10cSrcweir 		case RES_FRM_SIZE:
344cdf0e10cSrcweir 		case RES_KEEP:
345cdf0e10cSrcweir 		case RES_BREAK:
346cdf0e10cSrcweir 			if ( IsInCache() )
347cdf0e10cSrcweir 			{
348cdf0e10cSrcweir 				SwFrm::GetCache().Delete( this );
349cdf0e10cSrcweir 				SetInCache( sal_False );
350cdf0e10cSrcweir 			}
351cdf0e10cSrcweir 			break;
352cdf0e10cSrcweir 		}
353cdf0e10cSrcweir }
354cdf0e10cSrcweir 
CallSwClientNotify(const SfxHint & rHint) const355cdf0e10cSrcweir void SwModify::CallSwClientNotify( const SfxHint& rHint ) const
356cdf0e10cSrcweir {
357cdf0e10cSrcweir     SwClientIter aIter(*this);
358cdf0e10cSrcweir     SwClient * pClient = aIter.GoStart();
359cdf0e10cSrcweir     while (pClient)
360cdf0e10cSrcweir     {
361cdf0e10cSrcweir         pClient->SwClientNotify( *this, rHint );
3622f121198SMathias Bauer         pClient = ++aIter;
363cdf0e10cSrcweir     }
364cdf0e10cSrcweir }
365cdf0e10cSrcweir 
ModifyBroadcast(const SfxPoolItem * pOldValue,const SfxPoolItem * pNewValue,TypeId nType)366cdf0e10cSrcweir void SwModify::ModifyBroadcast( const SfxPoolItem *pOldValue, const SfxPoolItem *pNewValue, TypeId nType )
367cdf0e10cSrcweir {
368cdf0e10cSrcweir     SwClientIter aIter(*this);
369cdf0e10cSrcweir     SwClient * pClient = aIter.First( nType );
370cdf0e10cSrcweir     while (pClient)
371cdf0e10cSrcweir     {
372cdf0e10cSrcweir         pClient->Modify( pOldValue, pNewValue );
373cdf0e10cSrcweir         pClient = aIter.Next();
374cdf0e10cSrcweir     }
375cdf0e10cSrcweir }
376cdf0e10cSrcweir 
377cdf0e10cSrcweir // ----------
378cdf0e10cSrcweir // SwDepend
379cdf0e10cSrcweir // ----------
380cdf0e10cSrcweir 
381cdf0e10cSrcweir /*************************************************************************/
382cdf0e10cSrcweir 
SwDepend(SwClient * pTellHim,SwModify * pDepend)383cdf0e10cSrcweir SwDepend::SwDepend(SwClient *pTellHim, SwModify *pDepend)
384cdf0e10cSrcweir 	: SwClient(pDepend)
385cdf0e10cSrcweir {
386cdf0e10cSrcweir 	pToTell  = pTellHim;
387cdf0e10cSrcweir }
388cdf0e10cSrcweir 
389cdf0e10cSrcweir /*************************************************************************/
390cdf0e10cSrcweir 
Modify(const SfxPoolItem * pOldValue,const SfxPoolItem * pNewValue)391cdf0e10cSrcweir void SwDepend::Modify( const SfxPoolItem* pOldValue, const SfxPoolItem *pNewValue )
392cdf0e10cSrcweir {
393cdf0e10cSrcweir 	if(pNewValue && pNewValue->Which() == RES_OBJECTDYING)
394cdf0e10cSrcweir 		CheckRegistration(pOldValue,pNewValue);
395cdf0e10cSrcweir 	else if(pToTell)
396cdf0e10cSrcweir 		pToTell->ModifyNotification(pOldValue, pNewValue);
397cdf0e10cSrcweir }
398cdf0e10cSrcweir 
SwClientNotify(const SwModify & rMod,const SfxHint & rHint)399cdf0e10cSrcweir void SwDepend::SwClientNotify( const SwModify& rMod, const SfxHint& rHint )
400cdf0e10cSrcweir {
401cdf0e10cSrcweir     if ( pToTell )
402cdf0e10cSrcweir         pToTell->SwClientNotifyCall( rMod, rHint );
403cdf0e10cSrcweir }
404cdf0e10cSrcweir 
GetInfo(SfxPoolItem & rInfo) const405cdf0e10cSrcweir sal_Bool SwDepend::GetInfo( SfxPoolItem& rInfo ) const
406cdf0e10cSrcweir {
407cdf0e10cSrcweir 	return pToTell ? pToTell->GetInfo( rInfo ) : sal_True;
408cdf0e10cSrcweir }
409cdf0e10cSrcweir 
410cdf0e10cSrcweir /********************************************************************/
411cdf0e10cSrcweir 
SwClientIter(const SwModify & rModify)412cdf0e10cSrcweir SwClientIter::SwClientIter( const SwModify& rModify )
413cdf0e10cSrcweir 	: rRoot( rModify )
414cdf0e10cSrcweir {
415cdf0e10cSrcweir 	pNxtIter = 0;
416cdf0e10cSrcweir 	if( pClientIters )
417cdf0e10cSrcweir 	{
418cdf0e10cSrcweir         // append to list of ClientIters
419cdf0e10cSrcweir 		SwClientIter* pTmp = pClientIters;
420cdf0e10cSrcweir 		while( pTmp->pNxtIter )
421cdf0e10cSrcweir 			pTmp = pTmp->pNxtIter;
422cdf0e10cSrcweir 		pTmp->pNxtIter = this;
423cdf0e10cSrcweir 	}
424cdf0e10cSrcweir 	else
425cdf0e10cSrcweir 		pClientIters = this;
426cdf0e10cSrcweir 
427cdf0e10cSrcweir 	pAct = const_cast<SwClient*>(rRoot.GetDepends());
428cdf0e10cSrcweir 	pDelNext = pAct;
429cdf0e10cSrcweir }
430cdf0e10cSrcweir 
431cdf0e10cSrcweir 
432cdf0e10cSrcweir 
~SwClientIter()433cdf0e10cSrcweir SwClientIter::~SwClientIter()
434cdf0e10cSrcweir {
435cdf0e10cSrcweir 	if( pClientIters )
436cdf0e10cSrcweir 	{
437cdf0e10cSrcweir         // reorganize list of ClientIters
438cdf0e10cSrcweir 		if( pClientIters == this )
439cdf0e10cSrcweir 			pClientIters = pNxtIter;
440cdf0e10cSrcweir 		else
441cdf0e10cSrcweir 		{
442cdf0e10cSrcweir 			SwClientIter* pTmp = pClientIters;
443cdf0e10cSrcweir 			while( pTmp->pNxtIter != this )
444cdf0e10cSrcweir 				if( 0 == ( pTmp = pTmp->pNxtIter ) )
445cdf0e10cSrcweir 				{
446cdf0e10cSrcweir 					ASSERT( this, "wo ist mein Pointer" );
447cdf0e10cSrcweir 					return ;
448cdf0e10cSrcweir 				}
449cdf0e10cSrcweir 			pTmp->pNxtIter = pNxtIter;
450cdf0e10cSrcweir 		}
451cdf0e10cSrcweir 	}
452cdf0e10cSrcweir }
453cdf0e10cSrcweir 
454cdf0e10cSrcweir 
operator ++()4552f121198SMathias Bauer SwClient* SwClientIter::operator++()
456cdf0e10cSrcweir {
457cdf0e10cSrcweir 	if( pDelNext == pAct )
458cdf0e10cSrcweir 	{
459cdf0e10cSrcweir 		pAct = pAct->pRight;
460cdf0e10cSrcweir 		pDelNext = pAct;
461cdf0e10cSrcweir 	}
462cdf0e10cSrcweir 	else
463cdf0e10cSrcweir 		pAct = pDelNext;
464cdf0e10cSrcweir 	return pAct;
465cdf0e10cSrcweir }
466cdf0e10cSrcweir 
GoStart()467cdf0e10cSrcweir SwClient* SwClientIter::GoStart()
468cdf0e10cSrcweir {
469cdf0e10cSrcweir 	pAct = const_cast<SwClient*>(rRoot.GetDepends());
470cdf0e10cSrcweir 	if( pAct )
471cdf0e10cSrcweir 		while( pAct->pLeft )
472cdf0e10cSrcweir 			pAct = pAct->pLeft;
473cdf0e10cSrcweir 	pDelNext = pAct;
474cdf0e10cSrcweir 	return pAct;
475cdf0e10cSrcweir }
476cdf0e10cSrcweir 
GoEnd()477cdf0e10cSrcweir SwClient* SwClientIter::GoEnd()
478cdf0e10cSrcweir {
479cdf0e10cSrcweir 	pAct = pDelNext;
480cdf0e10cSrcweir 	if( !pAct )
481cdf0e10cSrcweir     	pAct = const_cast<SwClient*>(rRoot.GetDepends());
482cdf0e10cSrcweir 	if( pAct )
483cdf0e10cSrcweir 		while( pAct->pRight )
484cdf0e10cSrcweir 			pAct = pAct->pRight;
485cdf0e10cSrcweir 	pDelNext = pAct;
486cdf0e10cSrcweir 	return pAct;
487cdf0e10cSrcweir }
488cdf0e10cSrcweir 
First(TypeId nType)489cdf0e10cSrcweir SwClient* SwClientIter::First( TypeId nType )
490cdf0e10cSrcweir {
491cdf0e10cSrcweir 	aSrchId = nType;
492cdf0e10cSrcweir 	GoStart();
493cdf0e10cSrcweir 	if( pAct )
494cdf0e10cSrcweir 		do {
495cdf0e10cSrcweir 			if( pAct->IsA( aSrchId ) )
496cdf0e10cSrcweir 				break;
497cdf0e10cSrcweir 
498cdf0e10cSrcweir 			if( pDelNext == pAct )
499cdf0e10cSrcweir 			{
500cdf0e10cSrcweir 				pAct = pAct->pRight;
501cdf0e10cSrcweir 				pDelNext = pAct;
502cdf0e10cSrcweir 			}
503cdf0e10cSrcweir 			else
504cdf0e10cSrcweir 				pAct = pDelNext;
505cdf0e10cSrcweir 
506cdf0e10cSrcweir 		} while( pAct );
507cdf0e10cSrcweir 	return pAct;
508cdf0e10cSrcweir }
509cdf0e10cSrcweir 
Next()510cdf0e10cSrcweir SwClient* SwClientIter::Next()
511cdf0e10cSrcweir {
512cdf0e10cSrcweir 	do {
513cdf0e10cSrcweir 		if( pDelNext == pAct )
514cdf0e10cSrcweir 		{
515cdf0e10cSrcweir 			pAct = pAct->pRight;
516cdf0e10cSrcweir 			pDelNext = pAct;
517cdf0e10cSrcweir 		}
518cdf0e10cSrcweir 		else
519cdf0e10cSrcweir 			pAct = pDelNext;
520cdf0e10cSrcweir 
521cdf0e10cSrcweir 		if( pAct && pAct->IsA( aSrchId ) )
522cdf0e10cSrcweir 			break;
523cdf0e10cSrcweir 	} while( pAct );
524cdf0e10cSrcweir 	return pAct;
525cdf0e10cSrcweir }
526cdf0e10cSrcweir 
Last(TypeId nType)527cdf0e10cSrcweir SwClient* SwClientIter::Last( TypeId nType )
528cdf0e10cSrcweir {
529cdf0e10cSrcweir 	aSrchId = nType;
530cdf0e10cSrcweir 	GoEnd();
531cdf0e10cSrcweir 	if( pAct )
532cdf0e10cSrcweir 		do {
533cdf0e10cSrcweir 			if( pAct->IsA( aSrchId ) )
534cdf0e10cSrcweir 				break;
535cdf0e10cSrcweir 
536cdf0e10cSrcweir 	        if( pDelNext == pAct )
537cdf0e10cSrcweir 		        pAct = pAct->pLeft;
538cdf0e10cSrcweir 	        else
539cdf0e10cSrcweir 		        pAct = pDelNext->pLeft;
540cdf0e10cSrcweir 	        pDelNext = pAct;
541cdf0e10cSrcweir 
542cdf0e10cSrcweir 		} while( pAct );
543cdf0e10cSrcweir 	return pAct;
544cdf0e10cSrcweir }
545cdf0e10cSrcweir 
Previous()546cdf0e10cSrcweir SwClient* SwClientIter::Previous()
547cdf0e10cSrcweir {
548cdf0e10cSrcweir 	do {
549cdf0e10cSrcweir 	    if( pDelNext == pAct )
550cdf0e10cSrcweir 		    pAct = pAct->pLeft;
551cdf0e10cSrcweir 	    else
552cdf0e10cSrcweir 		    pAct = pDelNext->pLeft;
553cdf0e10cSrcweir 	    pDelNext = pAct;
554cdf0e10cSrcweir 
555cdf0e10cSrcweir 		if( pAct && pAct->IsA( aSrchId ) )
556cdf0e10cSrcweir 			break;
557cdf0e10cSrcweir 	} while( pAct );
558cdf0e10cSrcweir 	return pAct;
559cdf0e10cSrcweir }
560cdf0e10cSrcweir 
561