xref: /aoo41x/main/forms/source/helper/resettable.cxx (revision 24acc546)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_forms.hxx"
26 
27 #include "resettable.hxx"
28 
29 /** === begin UNO includes === **/
30 /** === end UNO includes === **/
31 
32 #include <cppuhelper/weak.hxx>
33 
34 //........................................................................
35 namespace frm
36 {
37 //........................................................................
38 
39 	/** === begin UNO using === **/
40 	using ::com::sun::star::uno::Reference;
41 	using ::com::sun::star::uno::XInterface;
42 	using ::com::sun::star::uno::UNO_QUERY;
43 	using ::com::sun::star::uno::UNO_QUERY_THROW;
44 	using ::com::sun::star::uno::UNO_SET_THROW;
45 	using ::com::sun::star::uno::Exception;
46 	using ::com::sun::star::uno::RuntimeException;
47 	using ::com::sun::star::uno::Any;
48 	using ::com::sun::star::uno::makeAny;
49 	using ::com::sun::star::uno::Sequence;
50 	using ::com::sun::star::uno::Type;
51     using ::com::sun::star::form::XResetListener;
52     using ::com::sun::star::lang::EventObject;
53 	/** === end UNO using === **/
54 
55 	//====================================================================
56 	//= ResetHelper
57 	//====================================================================
58 	//--------------------------------------------------------------------
addResetListener(const Reference<XResetListener> & _listener)59     void ResetHelper::addResetListener( const Reference< XResetListener >& _listener )
60     {
61 	    m_aResetListeners.addInterface( _listener );
62     }
63 
64 	//--------------------------------------------------------------------
removeResetListener(const Reference<XResetListener> & _listener)65     void ResetHelper::removeResetListener( const Reference< XResetListener >& _listener )
66     {
67 	    m_aResetListeners.removeInterface( _listener );
68     }
69 
70 	//--------------------------------------------------------------------
approveReset()71     bool ResetHelper::approveReset()
72     {
73         ::cppu::OInterfaceIteratorHelper aIter( m_aResetListeners );
74         EventObject aResetEvent( m_rParent );
75 
76         sal_Bool bContinue = sal_True;
77         while ( aIter.hasMoreElements() && bContinue )
78             bContinue = static_cast< XResetListener* >( aIter.next() )->approveReset( aResetEvent );
79 
80         return bContinue;
81     }
82 
83 	//--------------------------------------------------------------------
notifyResetted()84     void ResetHelper::notifyResetted()
85     {
86         EventObject aResetEvent( m_rParent );
87         m_aResetListeners.notifyEach( &XResetListener::resetted, aResetEvent );
88     }
89 
90 	//--------------------------------------------------------------------
disposing()91     void ResetHelper::disposing()
92     {
93         EventObject aEvent( m_rParent );
94         m_aResetListeners.disposeAndClear( aEvent );
95     }
96 
97 //........................................................................
98 } // namespace frm
99 //........................................................................
100