1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: result.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
35 #include <tools/debug.hxx>
36 #include <usr/ustring.hxx>
40 using namespace com::sun::star
;
42 //------------------------------------------------------------------------
44 SV_IMPL_PTRARR( XResultListenerArr_Impl
, XResultListenerPtr
);
46 //SMART_UNO_IMPLEMENTATION( ScAddInResult, UsrObject );
48 //------------------------------------------------------------------------
50 ScAddInResult::ScAddInResult(const String
& rStr
) :
54 aTimer
.SetTimeout( 1000 );
55 aTimer
.SetTimeoutHdl( LINK( this, ScAddInResult
, TimeoutHdl
) );
59 void ScAddInResult::NewValue()
64 if ( TRUE
/* nTickCount % 4 */ )
68 rtl::OUString aUStr
= StringToOUString( aRet
, CHARSET_SYSTEM
);
73 // sheet::ResultEvent aEvent( (UsrObject*)this, aAny );
74 sheet::ResultEvent
aEvent( (cppu::OWeakObject
*)this, aAny
);
76 for ( USHORT n
=0; n
<aListeners
.Count(); n
++ )
77 (*aListeners
[n
])->modified( aEvent
);
80 IMPL_LINK_INLINE_START( ScAddInResult
, TimeoutHdl
, Timer
*, pT
)
86 IMPL_LINK_INLINE_END( ScAddInResult
, TimeoutHdl
, Timer
*, pT
)
88 ScAddInResult::~ScAddInResult()
94 void SAL_CALL
ScAddInResult::addResultListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::sheet::XResultListener
>& aListener
) throw(::com::sun::star::uno::RuntimeException
)
96 uno::Reference
<sheet::XResultListener
> *pObj
= new uno::Reference
<sheet::XResultListener
>( aListener
);
97 aListeners
.Insert( pObj
, aListeners
.Count() );
99 if ( aListeners
.Count() == 1 )
101 acquire(); // one Ref for all listeners
107 void SAL_CALL
ScAddInResult::removeResultListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::sheet::XResultListener
>& aListener
) throw(::com::sun::star::uno::RuntimeException
)
111 USHORT nCount
= aListeners
.Count();
112 for ( USHORT n
=nCount
; n
--; )
114 uno::Reference
<sheet::XResultListener
> *pObj
= aListeners
[n
];
115 if ( *pObj
== aListener
)
117 aListeners
.DeleteAndDestroy( n
);
119 if ( aListeners
.Count() == 0 )
121 nTickCount
= 0; //! Test
123 release(); // release listener Ref
133 //------------------------------------------------------------------------