1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
24 #include <usr/ustring.hxx>
28 using namespace com::sun::star
;
30 //------------------------------------------------------------------------
32 SV_IMPL_PTRARR( XResultListenerArr_Impl
, XResultListenerPtr
);
34 //------------------------------------------------------------------------
36 ScAddInResult::ScAddInResult(const String
& rStr
) :
40 aTimer
.SetTimeout( 1000 );
41 aTimer
.SetTimeoutHdl( LINK( this, ScAddInResult
, TimeoutHdl
) );
45 void ScAddInResult::NewValue()
52 OUString aUStr
= StringToOUString( aRet
, CHARSET_SYSTEM
);
55 sheet::ResultEvent
aEvent( (cppu::OWeakObject
*)this, aAny
);
57 for ( sal_uInt16 n
=0; n
<aListeners
.Count(); n
++ )
58 (*aListeners
[n
])->modified( aEvent
);
61 IMPL_LINK_INLINE_START( ScAddInResult
, TimeoutHdl
, Timer
*, pT
)
67 IMPL_LINK_INLINE_END( ScAddInResult
, TimeoutHdl
, Timer
*, pT
)
69 ScAddInResult::~ScAddInResult()
75 void SAL_CALL
ScAddInResult::addResultListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::sheet::XResultListener
>& aListener
) throw(::com::sun::star::uno::RuntimeException
)
77 uno::Reference
<sheet::XResultListener
> *pObj
= new uno::Reference
<sheet::XResultListener
>( aListener
);
78 aListeners
.Insert( pObj
, aListeners
.Count() );
80 if ( aListeners
.Count() == 1 )
82 acquire(); // one Ref for all listeners
88 void SAL_CALL
ScAddInResult::removeResultListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::sheet::XResultListener
>& aListener
) throw(::com::sun::star::uno::RuntimeException
)
92 sal_uInt16 nCount
= aListeners
.Count();
93 for ( sal_uInt16 n
=nCount
; n
--; )
95 uno::Reference
<sheet::XResultListener
> *pObj
= aListeners
[n
];
96 if ( *pObj
== aListener
)
98 aListeners
.DeleteAndDestroy( n
);
100 if ( aListeners
.Count() == 0 )
102 nTickCount
= 0; //! Test
104 release(); // release listener Ref
114 //------------------------------------------------------------------------
118 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */