xref: /aoo41x/main/forms/source/helper/resettable.cxx (revision cdf0e10c)
1 /*************************************************************************
2  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3  *
4  * Copyright 2000, 2010 Oracle and/or its affiliates.
5  *
6  * OpenOffice.org - a multi-platform office productivity suite
7  *
8  * This file is part of OpenOffice.org.
9  *
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.
13  *
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).
19  *
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  *
25 ************************************************************************/
26 
27 // MARKER(update_precomp.py): autogen include statement, do not remove
28 #include "precompiled_forms.hxx"
29 
30 #include "resettable.hxx"
31 
32 /** === begin UNO includes === **/
33 /** === end UNO includes === **/
34 
35 #include <cppuhelper/weak.hxx>
36 
37 //........................................................................
38 namespace frm
39 {
40 //........................................................................
41 
42 	/** === begin UNO using === **/
43 	using ::com::sun::star::uno::Reference;
44 	using ::com::sun::star::uno::XInterface;
45 	using ::com::sun::star::uno::UNO_QUERY;
46 	using ::com::sun::star::uno::UNO_QUERY_THROW;
47 	using ::com::sun::star::uno::UNO_SET_THROW;
48 	using ::com::sun::star::uno::Exception;
49 	using ::com::sun::star::uno::RuntimeException;
50 	using ::com::sun::star::uno::Any;
51 	using ::com::sun::star::uno::makeAny;
52 	using ::com::sun::star::uno::Sequence;
53 	using ::com::sun::star::uno::Type;
54     using ::com::sun::star::form::XResetListener;
55     using ::com::sun::star::lang::EventObject;
56 	/** === end UNO using === **/
57 
58 	//====================================================================
59 	//= ResetHelper
60 	//====================================================================
61 	//--------------------------------------------------------------------
62     void ResetHelper::addResetListener( const Reference< XResetListener >& _listener )
63     {
64 	    m_aResetListeners.addInterface( _listener );
65     }
66 
67 	//--------------------------------------------------------------------
68     void ResetHelper::removeResetListener( const Reference< XResetListener >& _listener )
69     {
70 	    m_aResetListeners.removeInterface( _listener );
71     }
72 
73 	//--------------------------------------------------------------------
74     bool ResetHelper::approveReset()
75     {
76         ::cppu::OInterfaceIteratorHelper aIter( m_aResetListeners );
77         EventObject aResetEvent( m_rParent );
78 
79         sal_Bool bContinue = sal_True;
80         while ( aIter.hasMoreElements() && bContinue )
81             bContinue = static_cast< XResetListener* >( aIter.next() )->approveReset( aResetEvent );
82 
83         return bContinue;
84     }
85 
86 	//--------------------------------------------------------------------
87     void ResetHelper::notifyResetted()
88     {
89         EventObject aResetEvent( m_rParent );
90         m_aResetListeners.notifyEach( &XResetListener::resetted, aResetEvent );
91     }
92 
93 	//--------------------------------------------------------------------
94     void ResetHelper::disposing()
95     {
96         EventObject aEvent( m_rParent );
97         m_aResetListeners.disposeAndClear( aEvent );
98     }
99 
100 //........................................................................
101 } // namespace frm
102 //........................................................................
103