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_extensions.hxx" 26 #include "propeventtranslation.hxx" 27 28 /** === begin UNO includes === **/ 29 #include <com/sun/star/lang/DisposedException.hpp> 30 #include <com/sun/star/lang/NullPointerException.hpp> 31 /** === end UNO includes === **/ 32 33 //........................................................................ 34 namespace pcr 35 { 36 //........................................................................ 37 38 /** === begin UNO using === **/ 39 using ::com::sun::star::beans::PropertyChangeEvent; 40 using ::com::sun::star::uno::RuntimeException; 41 using ::com::sun::star::lang::EventObject; 42 using ::com::sun::star::uno::Reference; 43 using ::com::sun::star::beans::XPropertyChangeListener; 44 using ::com::sun::star::uno::XInterface; 45 using ::com::sun::star::beans::PropertyChangeEvent; 46 using ::com::sun::star::lang::DisposedException; 47 using ::com::sun::star::lang::NullPointerException; 48 /** === end UNO using === **/ 49 50 //==================================================================== 51 //= PropertyEventTranslation 52 //==================================================================== 53 //-------------------------------------------------------------------- PropertyEventTranslation(const Reference<XPropertyChangeListener> & _rxDelegator,const Reference<XInterface> & _rxTranslatedEventSource)54 PropertyEventTranslation::PropertyEventTranslation( const Reference< XPropertyChangeListener >& _rxDelegator, 55 const Reference< XInterface >& _rxTranslatedEventSource ) 56 :m_xDelegator( _rxDelegator ) 57 ,m_xTranslatedEventSource( _rxTranslatedEventSource ) 58 { 59 if ( !m_xDelegator.is() ) 60 throw NullPointerException(); 61 } 62 63 //-------------------------------------------------------------------- propertyChange(const PropertyChangeEvent & evt)64 void SAL_CALL PropertyEventTranslation::propertyChange( const PropertyChangeEvent& evt ) throw (RuntimeException) 65 { 66 if ( !m_xDelegator.is() ) 67 throw DisposedException(); 68 69 if ( !m_xTranslatedEventSource.is() ) 70 m_xDelegator->propertyChange( evt ); 71 else 72 { 73 PropertyChangeEvent aTranslatedEvent( evt ); 74 aTranslatedEvent.Source = m_xTranslatedEventSource; 75 m_xDelegator->propertyChange( aTranslatedEvent ); 76 } 77 } 78 79 //-------------------------------------------------------------------- disposing(const EventObject & Source)80 void SAL_CALL PropertyEventTranslation::disposing( const EventObject& Source ) throw (RuntimeException) 81 { 82 if ( !m_xDelegator.is() ) 83 throw DisposedException(); 84 85 if ( !m_xTranslatedEventSource.is() ) 86 m_xDelegator->disposing( Source ); 87 else 88 { 89 EventObject aTranslatedEvent( Source ); 90 aTranslatedEvent.Source = m_xTranslatedEventSource; 91 m_xDelegator->disposing( aTranslatedEvent ); 92 } 93 94 m_xDelegator.clear(); 95 m_xTranslatedEventSource.clear(); 96 } 97 98 //........................................................................ 99 } // namespace pcr 100 //........................................................................ 101 102