1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
32 #include <tools/debug.hxx>
33 #include <usr/ustring.hxx>
37 using namespace com::sun::star
;
39 //------------------------------------------------------------------------
41 SV_IMPL_PTRARR( XResultListenerArr_Impl
, XResultListenerPtr
);
43 //SMART_UNO_IMPLEMENTATION( ScAddInResult, UsrObject );
45 //------------------------------------------------------------------------
47 ScAddInResult::ScAddInResult(const String
& rStr
) :
51 aTimer
.SetTimeout( 1000 );
52 aTimer
.SetTimeoutHdl( LINK( this, ScAddInResult
, TimeoutHdl
) );
56 void ScAddInResult::NewValue()
61 if ( TRUE
/* nTickCount % 4 */ )
65 rtl::OUString aUStr
= StringToOUString( aRet
, CHARSET_SYSTEM
);
70 // sheet::ResultEvent aEvent( (UsrObject*)this, aAny );
71 sheet::ResultEvent
aEvent( (cppu::OWeakObject
*)this, aAny
);
73 for ( USHORT n
=0; n
<aListeners
.Count(); n
++ )
74 (*aListeners
[n
])->modified( aEvent
);
77 IMPL_LINK_INLINE_START( ScAddInResult
, TimeoutHdl
, Timer
*, pT
)
83 IMPL_LINK_INLINE_END( ScAddInResult
, TimeoutHdl
, Timer
*, pT
)
85 ScAddInResult::~ScAddInResult()
91 void SAL_CALL
ScAddInResult::addResultListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::sheet::XResultListener
>& aListener
) throw(::com::sun::star::uno::RuntimeException
)
93 uno::Reference
<sheet::XResultListener
> *pObj
= new uno::Reference
<sheet::XResultListener
>( aListener
);
94 aListeners
.Insert( pObj
, aListeners
.Count() );
96 if ( aListeners
.Count() == 1 )
98 acquire(); // one Ref for all listeners
104 void SAL_CALL
ScAddInResult::removeResultListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::sheet::XResultListener
>& aListener
) throw(::com::sun::star::uno::RuntimeException
)
108 USHORT nCount
= aListeners
.Count();
109 for ( USHORT n
=nCount
; n
--; )
111 uno::Reference
<sheet::XResultListener
> *pObj
= aListeners
[n
];
112 if ( *pObj
== aListener
)
114 aListeners
.DeleteAndDestroy( n
);
116 if ( aListeners
.Count() == 0 )
118 nTickCount
= 0; //! Test
120 release(); // release listener Ref
130 //------------------------------------------------------------------------