1 /*************************************************************************
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * Copyright 2009 by Sun Microsystems, Inc.
6 * OpenOffice.org - a multi-platform office productivity suite
8 * This file is part of OpenOffice.org.
10 * OpenOffice.org is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU Lesser General Public License version 3
12 * only, as published by the Free Software Foundation.
14 * OpenOffice.org is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU Lesser General Public License version 3 for more details
18 * (a copy is included in the LICENSE file that accompanied this code).
20 * You should have received a copy of the GNU Lesser General Public License
21 * version 3 along with OpenOffice.org. If not, see
22 * <http://www.openoffice.org/license.html>
23 * for a copy of the LGPLv3 License.
24 ************************************************************************/
26 // MARKER(update_precomp.py): autogen include statement, do not remove
27 #include "precompiled_forms.hxx"
29 #include "resettable.hxx"
31 /** === begin UNO includes === **/
32 /** === end UNO includes === **/
34 #include <cppuhelper/weak.hxx>
36 //........................................................................
39 //........................................................................
41 /** === begin UNO using === **/
42 using ::com::sun::star::uno::Reference
;
43 using ::com::sun::star::uno::XInterface
;
44 using ::com::sun::star::uno::UNO_QUERY
;
45 using ::com::sun::star::uno::UNO_QUERY_THROW
;
46 using ::com::sun::star::uno::UNO_SET_THROW
;
47 using ::com::sun::star::uno::Exception
;
48 using ::com::sun::star::uno::RuntimeException
;
49 using ::com::sun::star::uno::Any
;
50 using ::com::sun::star::uno::makeAny
;
51 using ::com::sun::star::uno::Sequence
;
52 using ::com::sun::star::uno::Type
;
53 using ::com::sun::star::form::XResetListener
;
54 using ::com::sun::star::lang::EventObject
;
55 /** === end UNO using === **/
57 //====================================================================
59 //====================================================================
60 //--------------------------------------------------------------------
61 void ResetHelper::addResetListener( const Reference
< XResetListener
>& _listener
)
63 m_aResetListeners
.addInterface( _listener
);
66 //--------------------------------------------------------------------
67 void ResetHelper::removeResetListener( const Reference
< XResetListener
>& _listener
)
69 m_aResetListeners
.removeInterface( _listener
);
72 //--------------------------------------------------------------------
73 bool ResetHelper::approveReset()
75 ::cppu::OInterfaceIteratorHelper
aIter( m_aResetListeners
);
76 EventObject
aResetEvent( m_rParent
);
78 sal_Bool bContinue
= sal_True
;
79 while ( aIter
.hasMoreElements() && bContinue
)
80 bContinue
= static_cast< XResetListener
* >( aIter
.next() )->approveReset( aResetEvent
);
85 //--------------------------------------------------------------------
86 void ResetHelper::notifyResetted()
88 EventObject
aResetEvent( m_rParent
);
89 m_aResetListeners
.notifyEach( &XResetListener::resetted
, aResetEvent
);
92 //--------------------------------------------------------------------
93 void ResetHelper::disposing()
95 EventObject
aEvent( m_rParent
);
96 m_aResetListeners
.disposeAndClear( aEvent
);
99 //........................................................................
101 //........................................................................