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