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