xref: /aoo41x/main/sfx2/source/appl/linksrc.cxx (revision d119d52d)
1*d119d52dSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*d119d52dSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*d119d52dSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*d119d52dSAndrew Rist  * distributed with this work for additional information
6*d119d52dSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*d119d52dSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*d119d52dSAndrew Rist  * "License"); you may not use this file except in compliance
9*d119d52dSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*d119d52dSAndrew Rist  *
11*d119d52dSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*d119d52dSAndrew Rist  *
13*d119d52dSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*d119d52dSAndrew Rist  * software distributed under the License is distributed on an
15*d119d52dSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*d119d52dSAndrew Rist  * KIND, either express or implied.  See the License for the
17*d119d52dSAndrew Rist  * specific language governing permissions and limitations
18*d119d52dSAndrew Rist  * under the License.
19*d119d52dSAndrew Rist  *
20*d119d52dSAndrew Rist  *************************************************************/
21*d119d52dSAndrew Rist 
22*d119d52dSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sfx2.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <sfx2/linksrc.hxx>
28cdf0e10cSrcweir #include <sfx2/lnkbase.hxx>
29cdf0e10cSrcweir //#include <sot/exchange.hxx>
30cdf0e10cSrcweir #include <com/sun/star/uno/Any.hxx>
31cdf0e10cSrcweir #include <com/sun/star/uno/Sequence.hxx>
32cdf0e10cSrcweir 
33cdf0e10cSrcweir #include <tools/debug.hxx>
34cdf0e10cSrcweir #include <vcl/timer.hxx>
35cdf0e10cSrcweir #include <svl/svarray.hxx>
36cdf0e10cSrcweir 
37cdf0e10cSrcweir 
38cdf0e10cSrcweir using namespace ::com::sun::star::uno;
39cdf0e10cSrcweir 
40cdf0e10cSrcweir namespace sfx2
41cdf0e10cSrcweir {
42cdf0e10cSrcweir 
43cdf0e10cSrcweir TYPEINIT0( SvLinkSource )
44cdf0e10cSrcweir 
45cdf0e10cSrcweir /************** class SvLinkSourceTimer *********************************/
46cdf0e10cSrcweir class SvLinkSourceTimer : public Timer
47cdf0e10cSrcweir {
48cdf0e10cSrcweir 	SvLinkSource *  pOwner;
49cdf0e10cSrcweir 	virtual void    Timeout();
50cdf0e10cSrcweir public:
51cdf0e10cSrcweir 			SvLinkSourceTimer( SvLinkSource * pOwn );
52cdf0e10cSrcweir };
53cdf0e10cSrcweir 
SvLinkSourceTimer(SvLinkSource * pOwn)54cdf0e10cSrcweir SvLinkSourceTimer::SvLinkSourceTimer( SvLinkSource * pOwn )
55cdf0e10cSrcweir 	: pOwner( pOwn )
56cdf0e10cSrcweir {
57cdf0e10cSrcweir }
58cdf0e10cSrcweir 
Timeout()59cdf0e10cSrcweir void SvLinkSourceTimer::Timeout()
60cdf0e10cSrcweir {
61cdf0e10cSrcweir 	// sicher gegen zerstoeren im Handler
62cdf0e10cSrcweir 	SvLinkSourceRef aAdv( pOwner );
63cdf0e10cSrcweir 	pOwner->SendDataChanged();
64cdf0e10cSrcweir }
65cdf0e10cSrcweir 
StartTimer(SvLinkSourceTimer ** ppTimer,SvLinkSource * pOwner,sal_uIntPtr nTimeout)66cdf0e10cSrcweir static void StartTimer( SvLinkSourceTimer ** ppTimer, SvLinkSource * pOwner,
67cdf0e10cSrcweir 						sal_uIntPtr nTimeout )
68cdf0e10cSrcweir {
69cdf0e10cSrcweir 	if( !*ppTimer )
70cdf0e10cSrcweir 	{
71cdf0e10cSrcweir 		*ppTimer = new SvLinkSourceTimer( pOwner );
72cdf0e10cSrcweir 		(*ppTimer)->SetTimeout( nTimeout );
73cdf0e10cSrcweir 		(*ppTimer)->Start();
74cdf0e10cSrcweir 	}
75cdf0e10cSrcweir }
76cdf0e10cSrcweir 
77cdf0e10cSrcweir 
78cdf0e10cSrcweir struct SvLinkSource_Entry_Impl
79cdf0e10cSrcweir {
80cdf0e10cSrcweir 	SvBaseLinkRef		xSink;
81cdf0e10cSrcweir 	String				aDataMimeType;
82cdf0e10cSrcweir 	sal_uInt16				nAdviseModes;
83cdf0e10cSrcweir 	sal_Bool 				bIsDataSink;
84cdf0e10cSrcweir 
SvLinkSource_Entry_Implsfx2::SvLinkSource_Entry_Impl85cdf0e10cSrcweir 	SvLinkSource_Entry_Impl( SvBaseLink* pLink, const String& rMimeType,
86cdf0e10cSrcweir 								sal_uInt16 nAdvMode )
87cdf0e10cSrcweir 		: xSink( pLink ), aDataMimeType( rMimeType ),
88cdf0e10cSrcweir 			nAdviseModes( nAdvMode ), bIsDataSink( sal_True )
89cdf0e10cSrcweir 	{}
90cdf0e10cSrcweir 
SvLinkSource_Entry_Implsfx2::SvLinkSource_Entry_Impl91cdf0e10cSrcweir 	SvLinkSource_Entry_Impl( SvBaseLink* pLink )
92cdf0e10cSrcweir 		: xSink( pLink ), nAdviseModes( 0 ), bIsDataSink( sal_False )
93cdf0e10cSrcweir 	{}
94cdf0e10cSrcweir 
95cdf0e10cSrcweir 	~SvLinkSource_Entry_Impl();
96cdf0e10cSrcweir };
97cdf0e10cSrcweir 
~SvLinkSource_Entry_Impl()98cdf0e10cSrcweir SvLinkSource_Entry_Impl::~SvLinkSource_Entry_Impl()
99cdf0e10cSrcweir {
100cdf0e10cSrcweir }
101cdf0e10cSrcweir 
102cdf0e10cSrcweir typedef SvLinkSource_Entry_Impl* SvLinkSource_Entry_ImplPtr;
103cdf0e10cSrcweir SV_DECL_PTRARR_DEL( SvLinkSource_Array_Impl, SvLinkSource_Entry_ImplPtr, 4, 4 )
104cdf0e10cSrcweir SV_IMPL_PTRARR( SvLinkSource_Array_Impl, SvLinkSource_Entry_ImplPtr );
105cdf0e10cSrcweir 
106cdf0e10cSrcweir class SvLinkSource_EntryIter_Impl
107cdf0e10cSrcweir {
108cdf0e10cSrcweir 	SvLinkSource_Array_Impl aArr;
109cdf0e10cSrcweir 	const SvLinkSource_Array_Impl& rOrigArr;
110cdf0e10cSrcweir 	sal_uInt16 nPos;
111cdf0e10cSrcweir public:
112cdf0e10cSrcweir 	SvLinkSource_EntryIter_Impl( const SvLinkSource_Array_Impl& rArr );
113cdf0e10cSrcweir 	~SvLinkSource_EntryIter_Impl();
Curr()114cdf0e10cSrcweir 	SvLinkSource_Entry_Impl* Curr()
115cdf0e10cSrcweir 							{ return nPos < aArr.Count() ? aArr[ nPos ] : 0; }
116cdf0e10cSrcweir 	SvLinkSource_Entry_Impl* Next();
117cdf0e10cSrcweir 	sal_Bool IsValidCurrValue( SvLinkSource_Entry_Impl* pEntry );
118cdf0e10cSrcweir };
119cdf0e10cSrcweir 
SvLinkSource_EntryIter_Impl(const SvLinkSource_Array_Impl & rArr)120cdf0e10cSrcweir SvLinkSource_EntryIter_Impl::SvLinkSource_EntryIter_Impl(
121cdf0e10cSrcweir 		const SvLinkSource_Array_Impl& rArr )
122cdf0e10cSrcweir 	: rOrigArr( rArr ), nPos( 0 )
123cdf0e10cSrcweir {
124cdf0e10cSrcweir 	aArr.Insert( &rArr, 0 );
125cdf0e10cSrcweir }
~SvLinkSource_EntryIter_Impl()126cdf0e10cSrcweir SvLinkSource_EntryIter_Impl::~SvLinkSource_EntryIter_Impl()
127cdf0e10cSrcweir {
128cdf0e10cSrcweir 	aArr.Remove( 0, aArr.Count() );
129cdf0e10cSrcweir }
130cdf0e10cSrcweir 
IsValidCurrValue(SvLinkSource_Entry_Impl * pEntry)131cdf0e10cSrcweir sal_Bool SvLinkSource_EntryIter_Impl::IsValidCurrValue( SvLinkSource_Entry_Impl* pEntry )
132cdf0e10cSrcweir {
133cdf0e10cSrcweir 	return ( nPos < aArr.Count() && aArr[nPos] == pEntry && USHRT_MAX != rOrigArr.GetPos( pEntry ) );
134cdf0e10cSrcweir }
135cdf0e10cSrcweir 
Next()136cdf0e10cSrcweir SvLinkSource_Entry_Impl* SvLinkSource_EntryIter_Impl::Next()
137cdf0e10cSrcweir {
138cdf0e10cSrcweir 	SvLinkSource_Entry_ImplPtr pRet = 0;
139cdf0e10cSrcweir 	if( nPos + 1 < aArr.Count() )
140cdf0e10cSrcweir 	{
141cdf0e10cSrcweir 		++nPos;
142cdf0e10cSrcweir 		if( rOrigArr.Count() == aArr.Count() &&
143cdf0e10cSrcweir 			rOrigArr[ nPos ] == aArr[ nPos ] )
144cdf0e10cSrcweir 			pRet = aArr[ nPos ];
145cdf0e10cSrcweir 		else
146cdf0e10cSrcweir 		{
147cdf0e10cSrcweir 			// then we must search the current (or the next) in the orig
148cdf0e10cSrcweir 			do {
149cdf0e10cSrcweir 				pRet = aArr[ nPos ];
150cdf0e10cSrcweir 				if( USHRT_MAX != rOrigArr.GetPos( pRet ))
151cdf0e10cSrcweir 					break;
152cdf0e10cSrcweir 				pRet = 0;
153cdf0e10cSrcweir 				++nPos;
154cdf0e10cSrcweir 			} while( nPos < aArr.Count() );
155cdf0e10cSrcweir 
156cdf0e10cSrcweir 			if( nPos >= aArr.Count() )
157cdf0e10cSrcweir 				pRet = 0;
158cdf0e10cSrcweir 		}
159cdf0e10cSrcweir 	}
160cdf0e10cSrcweir 	return pRet;
161cdf0e10cSrcweir }
162cdf0e10cSrcweir 
163cdf0e10cSrcweir struct SvLinkSource_Impl
164cdf0e10cSrcweir {
165cdf0e10cSrcweir 	SvLinkSource_Array_Impl aArr;
166cdf0e10cSrcweir 	String				aDataMimeType;
167cdf0e10cSrcweir 	SvLinkSourceTimer *	pTimer;
168cdf0e10cSrcweir 	sal_uIntPtr				nTimeout;
169cdf0e10cSrcweir     com::sun::star::uno::Reference<com::sun::star::io::XInputStream>
170cdf0e10cSrcweir     m_xInputStreamToLoadFrom;
171cdf0e10cSrcweir     sal_Bool m_bIsReadOnly;
172cdf0e10cSrcweir 
SvLinkSource_Implsfx2::SvLinkSource_Impl173cdf0e10cSrcweir 	SvLinkSource_Impl() : pTimer( 0 ), nTimeout( 3000 ) {}
174cdf0e10cSrcweir 	~SvLinkSource_Impl();
175cdf0e10cSrcweir 
176cdf0e10cSrcweir 	void Closed();
177cdf0e10cSrcweir };
178cdf0e10cSrcweir 
~SvLinkSource_Impl()179cdf0e10cSrcweir SvLinkSource_Impl::~SvLinkSource_Impl()
180cdf0e10cSrcweir {
181cdf0e10cSrcweir 	delete pTimer;
182cdf0e10cSrcweir }
183cdf0e10cSrcweir 
SvLinkSource()184cdf0e10cSrcweir SvLinkSource::SvLinkSource()
185cdf0e10cSrcweir  	: pImpl( new SvLinkSource_Impl )
186cdf0e10cSrcweir {
187cdf0e10cSrcweir }
188cdf0e10cSrcweir 
~SvLinkSource()189cdf0e10cSrcweir SvLinkSource::~SvLinkSource()
190cdf0e10cSrcweir {
191cdf0e10cSrcweir 	delete pImpl;
192cdf0e10cSrcweir }
193cdf0e10cSrcweir 
194cdf0e10cSrcweir 
getStreamToLoadFrom()195cdf0e10cSrcweir SvLinkSource::StreamToLoadFrom SvLinkSource::getStreamToLoadFrom()
196cdf0e10cSrcweir {
197cdf0e10cSrcweir     return StreamToLoadFrom(
198cdf0e10cSrcweir         pImpl->m_xInputStreamToLoadFrom,
199cdf0e10cSrcweir         pImpl->m_bIsReadOnly);
200cdf0e10cSrcweir }
201cdf0e10cSrcweir 
setStreamToLoadFrom(const com::sun::star::uno::Reference<com::sun::star::io::XInputStream> & xInputStream,sal_Bool bIsReadOnly)202cdf0e10cSrcweir void SvLinkSource::setStreamToLoadFrom(const com::sun::star::uno::Reference<com::sun::star::io::XInputStream>& xInputStream,sal_Bool bIsReadOnly )
203cdf0e10cSrcweir {
204cdf0e10cSrcweir     pImpl->m_xInputStreamToLoadFrom = xInputStream;
205cdf0e10cSrcweir     pImpl->m_bIsReadOnly = bIsReadOnly;
206cdf0e10cSrcweir }
207cdf0e10cSrcweir 
208cdf0e10cSrcweir // --> OD 2008-06-18 #i88291#
clearStreamToLoadFrom()209cdf0e10cSrcweir void SvLinkSource::clearStreamToLoadFrom()
210cdf0e10cSrcweir {
211cdf0e10cSrcweir     pImpl->m_xInputStreamToLoadFrom.clear();
212cdf0e10cSrcweir }
213cdf0e10cSrcweir // <--
214cdf0e10cSrcweir 
Closed()215cdf0e10cSrcweir void  SvLinkSource::Closed()
216cdf0e10cSrcweir {
217cdf0e10cSrcweir 	SvLinkSource_EntryIter_Impl aIter( pImpl->aArr );
218cdf0e10cSrcweir 	for( SvLinkSource_Entry_Impl* p = aIter.Curr(); p; p = aIter.Next() )
219cdf0e10cSrcweir 		if( !p->bIsDataSink )
220cdf0e10cSrcweir 			p->xSink->Closed();
221cdf0e10cSrcweir }
222cdf0e10cSrcweir 
GetUpdateTimeout() const223cdf0e10cSrcweir sal_uIntPtr SvLinkSource::GetUpdateTimeout() const
224cdf0e10cSrcweir {
225cdf0e10cSrcweir 	return pImpl->nTimeout;
226cdf0e10cSrcweir }
227cdf0e10cSrcweir 
SetUpdateTimeout(sal_uIntPtr nTimeout)228cdf0e10cSrcweir void SvLinkSource::SetUpdateTimeout( sal_uIntPtr nTimeout )
229cdf0e10cSrcweir {
230cdf0e10cSrcweir 	pImpl->nTimeout = nTimeout;
231cdf0e10cSrcweir 	if( pImpl->pTimer )
232cdf0e10cSrcweir 		pImpl->pTimer->SetTimeout( nTimeout );
233cdf0e10cSrcweir }
234cdf0e10cSrcweir 
SendDataChanged()235cdf0e10cSrcweir void SvLinkSource::SendDataChanged()
236cdf0e10cSrcweir {
237cdf0e10cSrcweir 	SvLinkSource_EntryIter_Impl aIter( pImpl->aArr );
238cdf0e10cSrcweir 	for( SvLinkSource_Entry_ImplPtr p = aIter.Curr(); p; p = aIter.Next() )
239cdf0e10cSrcweir 	{
240cdf0e10cSrcweir 		if( p->bIsDataSink )
241cdf0e10cSrcweir 		{
242cdf0e10cSrcweir 			String sDataMimeType( pImpl->aDataMimeType );
243cdf0e10cSrcweir 			if( !sDataMimeType.Len() )
244cdf0e10cSrcweir 				sDataMimeType = p->aDataMimeType;
245cdf0e10cSrcweir 
246cdf0e10cSrcweir 			Any aVal;
247cdf0e10cSrcweir 			if( ( p->nAdviseModes & ADVISEMODE_NODATA ) ||
248cdf0e10cSrcweir 				GetData( aVal, sDataMimeType, sal_True ) )
249cdf0e10cSrcweir 			{
250cdf0e10cSrcweir 				p->xSink->DataChanged( sDataMimeType, aVal );
251cdf0e10cSrcweir 
252cdf0e10cSrcweir 				if ( !aIter.IsValidCurrValue( p ) )
253cdf0e10cSrcweir 					continue;
254cdf0e10cSrcweir 
255cdf0e10cSrcweir 				if( p->nAdviseModes & ADVISEMODE_ONLYONCE )
256cdf0e10cSrcweir 				{
257cdf0e10cSrcweir 					sal_uInt16 nFndPos = pImpl->aArr.GetPos( p );
258cdf0e10cSrcweir 					if( USHRT_MAX != nFndPos )
259cdf0e10cSrcweir 						pImpl->aArr.DeleteAndDestroy( nFndPos );
260cdf0e10cSrcweir 				}
261cdf0e10cSrcweir 
262cdf0e10cSrcweir 			}
263cdf0e10cSrcweir 		}
264cdf0e10cSrcweir 	}
265cdf0e10cSrcweir 	if( pImpl->pTimer )
266cdf0e10cSrcweir 	{
267cdf0e10cSrcweir 		delete pImpl->pTimer;
268cdf0e10cSrcweir 		pImpl->pTimer = NULL;
269cdf0e10cSrcweir 	}
270cdf0e10cSrcweir 	pImpl->aDataMimeType.Erase();
271cdf0e10cSrcweir }
272cdf0e10cSrcweir 
NotifyDataChanged()273cdf0e10cSrcweir void SvLinkSource::NotifyDataChanged()
274cdf0e10cSrcweir {
275cdf0e10cSrcweir 	if( pImpl->nTimeout )
276cdf0e10cSrcweir 		StartTimer( &pImpl->pTimer, this, pImpl->nTimeout ); // Timeout neu
277cdf0e10cSrcweir 	else
278cdf0e10cSrcweir 	{
279cdf0e10cSrcweir 		SvLinkSource_EntryIter_Impl aIter( pImpl->aArr );
280cdf0e10cSrcweir 		for( SvLinkSource_Entry_ImplPtr p = aIter.Curr(); p; p = aIter.Next() )
281cdf0e10cSrcweir 			if( p->bIsDataSink )
282cdf0e10cSrcweir 			{
283cdf0e10cSrcweir 				Any aVal;
284cdf0e10cSrcweir 				if( ( p->nAdviseModes & ADVISEMODE_NODATA ) ||
285cdf0e10cSrcweir 					GetData( aVal, p->aDataMimeType, sal_True ) )
286cdf0e10cSrcweir 				{
287cdf0e10cSrcweir 					p->xSink->DataChanged( p->aDataMimeType, aVal );
288cdf0e10cSrcweir 
289cdf0e10cSrcweir 					if ( !aIter.IsValidCurrValue( p ) )
290cdf0e10cSrcweir 						continue;
291cdf0e10cSrcweir 
292cdf0e10cSrcweir 					if( p->nAdviseModes & ADVISEMODE_ONLYONCE )
293cdf0e10cSrcweir 					{
294cdf0e10cSrcweir 						sal_uInt16 nFndPos = pImpl->aArr.GetPos( p );
295cdf0e10cSrcweir 						if( USHRT_MAX != nFndPos )
296cdf0e10cSrcweir 							pImpl->aArr.DeleteAndDestroy( nFndPos );
297cdf0e10cSrcweir 					}
298cdf0e10cSrcweir 				}
299cdf0e10cSrcweir 			}
300cdf0e10cSrcweir 
301cdf0e10cSrcweir 			if( pImpl->pTimer )
302cdf0e10cSrcweir 			{
303cdf0e10cSrcweir 				delete pImpl->pTimer;
304cdf0e10cSrcweir 				pImpl->pTimer = NULL;
305cdf0e10cSrcweir 			}
306cdf0e10cSrcweir 	}
307cdf0e10cSrcweir }
308cdf0e10cSrcweir 
309cdf0e10cSrcweir // notify the sink, the mime type is not
310cdf0e10cSrcweir // a selection criterion
DataChanged(const String & rMimeType,const::com::sun::star::uno::Any & rVal)311cdf0e10cSrcweir void SvLinkSource::DataChanged( const String & rMimeType,
312cdf0e10cSrcweir 								const ::com::sun::star::uno::Any & rVal )
313cdf0e10cSrcweir {
314cdf0e10cSrcweir 	if( pImpl->nTimeout && !rVal.hasValue() )
315cdf0e10cSrcweir 	{   // nur wenn keine Daten mitgegeben wurden
316cdf0e10cSrcweir 		// fire all data to the sink, independent of the requested format
317cdf0e10cSrcweir 		pImpl->aDataMimeType = rMimeType;
318cdf0e10cSrcweir 		StartTimer( &pImpl->pTimer, this, pImpl->nTimeout ); // Timeout neu
319cdf0e10cSrcweir 	}
320cdf0e10cSrcweir 	else
321cdf0e10cSrcweir 	{
322cdf0e10cSrcweir 		SvLinkSource_EntryIter_Impl aIter( pImpl->aArr );
323cdf0e10cSrcweir 		for( SvLinkSource_Entry_ImplPtr p = aIter.Curr(); p; p = aIter.Next() )
324cdf0e10cSrcweir 		{
325cdf0e10cSrcweir 			if( p->bIsDataSink )
326cdf0e10cSrcweir 			{
327cdf0e10cSrcweir 				p->xSink->DataChanged( rMimeType, rVal );
328cdf0e10cSrcweir 
329cdf0e10cSrcweir 				if ( !aIter.IsValidCurrValue( p ) )
330cdf0e10cSrcweir 					continue;
331cdf0e10cSrcweir 
332cdf0e10cSrcweir 				if( p->nAdviseModes & ADVISEMODE_ONLYONCE )
333cdf0e10cSrcweir 				{
334cdf0e10cSrcweir 					sal_uInt16 nFndPos = pImpl->aArr.GetPos( p );
335cdf0e10cSrcweir 					if( USHRT_MAX != nFndPos )
336cdf0e10cSrcweir 						pImpl->aArr.DeleteAndDestroy( nFndPos );
337cdf0e10cSrcweir 				}
338cdf0e10cSrcweir 			}
339cdf0e10cSrcweir 		}
340cdf0e10cSrcweir 
341cdf0e10cSrcweir 		if( pImpl->pTimer )
342cdf0e10cSrcweir 		{
343cdf0e10cSrcweir 			delete pImpl->pTimer;
344cdf0e10cSrcweir 			pImpl->pTimer = NULL;
345cdf0e10cSrcweir 		}
346cdf0e10cSrcweir 	}
347cdf0e10cSrcweir }
348cdf0e10cSrcweir 
349cdf0e10cSrcweir 
350cdf0e10cSrcweir // only one link is correct
AddDataAdvise(SvBaseLink * pLink,const String & rMimeType,sal_uInt16 nAdviseModes)351cdf0e10cSrcweir void SvLinkSource::AddDataAdvise( SvBaseLink * pLink, const String& rMimeType,
352cdf0e10cSrcweir 									sal_uInt16 nAdviseModes )
353cdf0e10cSrcweir {
354cdf0e10cSrcweir 	SvLinkSource_Entry_ImplPtr pNew = new SvLinkSource_Entry_Impl(
355cdf0e10cSrcweir 					pLink, rMimeType, nAdviseModes );
356cdf0e10cSrcweir 	pImpl->aArr.Insert( pNew, pImpl->aArr.Count() );
357cdf0e10cSrcweir }
358cdf0e10cSrcweir 
RemoveAllDataAdvise(SvBaseLink * pLink)359cdf0e10cSrcweir void SvLinkSource::RemoveAllDataAdvise( SvBaseLink * pLink )
360cdf0e10cSrcweir {
361cdf0e10cSrcweir 	SvLinkSource_EntryIter_Impl aIter( pImpl->aArr );
362cdf0e10cSrcweir 	for( SvLinkSource_Entry_ImplPtr p = aIter.Curr(); p; p = aIter.Next() )
363cdf0e10cSrcweir 		if( p->bIsDataSink && &p->xSink == pLink )
364cdf0e10cSrcweir 		{
365cdf0e10cSrcweir 			sal_uInt16 nFndPos = pImpl->aArr.GetPos( p );
366cdf0e10cSrcweir 			if( USHRT_MAX != nFndPos )
367cdf0e10cSrcweir 				pImpl->aArr.DeleteAndDestroy( nFndPos );
368cdf0e10cSrcweir 		}
369cdf0e10cSrcweir }
370cdf0e10cSrcweir 
371cdf0e10cSrcweir // only one link is correct
AddConnectAdvise(SvBaseLink * pLink)372cdf0e10cSrcweir void SvLinkSource::AddConnectAdvise( SvBaseLink * pLink )
373cdf0e10cSrcweir {
374cdf0e10cSrcweir 	SvLinkSource_Entry_ImplPtr pNew = new SvLinkSource_Entry_Impl( pLink );
375cdf0e10cSrcweir 	pImpl->aArr.Insert( pNew, pImpl->aArr.Count() );
376cdf0e10cSrcweir }
377cdf0e10cSrcweir 
RemoveConnectAdvise(SvBaseLink * pLink)378cdf0e10cSrcweir void SvLinkSource::RemoveConnectAdvise( SvBaseLink * pLink )
379cdf0e10cSrcweir {
380cdf0e10cSrcweir 	SvLinkSource_EntryIter_Impl aIter( pImpl->aArr );
381cdf0e10cSrcweir 	for( SvLinkSource_Entry_ImplPtr p = aIter.Curr(); p; p = aIter.Next() )
382cdf0e10cSrcweir 		if( !p->bIsDataSink && &p->xSink == pLink )
383cdf0e10cSrcweir 		{
384cdf0e10cSrcweir 			sal_uInt16 nFndPos = pImpl->aArr.GetPos( p );
385cdf0e10cSrcweir 			if( USHRT_MAX != nFndPos )
386cdf0e10cSrcweir 				pImpl->aArr.DeleteAndDestroy( nFndPos );
387cdf0e10cSrcweir 		}
388cdf0e10cSrcweir }
389cdf0e10cSrcweir 
HasDataLinks(const SvBaseLink * pLink) const390cdf0e10cSrcweir sal_Bool SvLinkSource::HasDataLinks( const SvBaseLink* pLink ) const
391cdf0e10cSrcweir {
392cdf0e10cSrcweir 	sal_Bool bRet = sal_False;
393cdf0e10cSrcweir 	const SvLinkSource_Entry_Impl* p;
394cdf0e10cSrcweir 	for( sal_uInt16 n = 0, nEnd = pImpl->aArr.Count(); n < nEnd; ++n )
395cdf0e10cSrcweir 		if( ( p = pImpl->aArr[ n ] )->bIsDataSink &&
396cdf0e10cSrcweir 			( !pLink || &p->xSink == pLink ) )
397cdf0e10cSrcweir 		{
398cdf0e10cSrcweir 			bRet = sal_True;
399cdf0e10cSrcweir 			break;
400cdf0e10cSrcweir 		}
401cdf0e10cSrcweir 	return bRet;
402cdf0e10cSrcweir }
403cdf0e10cSrcweir 
404cdf0e10cSrcweir // sal_True => waitinmg for data
IsPending() const405cdf0e10cSrcweir sal_Bool SvLinkSource::IsPending() const
406cdf0e10cSrcweir {
407cdf0e10cSrcweir 	return sal_False;
408cdf0e10cSrcweir }
409cdf0e10cSrcweir 
410cdf0e10cSrcweir // sal_True => data complete loaded
IsDataComplete() const411cdf0e10cSrcweir sal_Bool SvLinkSource::IsDataComplete() const
412cdf0e10cSrcweir {
413cdf0e10cSrcweir 	return sal_True;
414cdf0e10cSrcweir }
415cdf0e10cSrcweir 
Connect(SvBaseLink *)416cdf0e10cSrcweir sal_Bool SvLinkSource::Connect( SvBaseLink* )
417cdf0e10cSrcweir {
418cdf0e10cSrcweir 	return sal_True;
419cdf0e10cSrcweir }
420cdf0e10cSrcweir 
GetData(::com::sun::star::uno::Any &,const String &,sal_Bool)421cdf0e10cSrcweir sal_Bool SvLinkSource::GetData( ::com::sun::star::uno::Any &, const String &, sal_Bool )
422cdf0e10cSrcweir {
423cdf0e10cSrcweir 	return sal_False;
424cdf0e10cSrcweir }
425cdf0e10cSrcweir 
Edit(Window *,SvBaseLink *,const Link &)426cdf0e10cSrcweir void SvLinkSource::Edit( Window *, SvBaseLink *, const Link& )
427cdf0e10cSrcweir {
428cdf0e10cSrcweir }
429cdf0e10cSrcweir 
430cdf0e10cSrcweir }
431cdf0e10cSrcweir 
432