Update ooo320-m1
[ooovba.git] / extensions / source / propctrlr / propeventtranslation.cxx
blob0766ebdaca0cd5361c39d7ca28ae9809a6ff3277
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: propeventtranslation.cxx,v $
10 * $Revision: 1.4 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_extensions.hxx"
33 #include "propeventtranslation.hxx"
35 /** === begin UNO includes === **/
36 #include <com/sun/star/lang/DisposedException.hpp>
37 #include <com/sun/star/lang/NullPointerException.hpp>
38 /** === end UNO includes === **/
40 //........................................................................
41 namespace pcr
43 //........................................................................
45 /** === begin UNO using === **/
46 using ::com::sun::star::beans::PropertyChangeEvent;
47 using ::com::sun::star::uno::RuntimeException;
48 using ::com::sun::star::lang::EventObject;
49 using ::com::sun::star::uno::Reference;
50 using ::com::sun::star::beans::XPropertyChangeListener;
51 using ::com::sun::star::uno::XInterface;
52 using ::com::sun::star::beans::PropertyChangeEvent;
53 using ::com::sun::star::lang::DisposedException;
54 using ::com::sun::star::lang::NullPointerException;
55 /** === end UNO using === **/
57 //====================================================================
58 //= PropertyEventTranslation
59 //====================================================================
60 //--------------------------------------------------------------------
61 PropertyEventTranslation::PropertyEventTranslation( const Reference< XPropertyChangeListener >& _rxDelegator,
62 const Reference< XInterface >& _rxTranslatedEventSource )
63 :m_xDelegator( _rxDelegator )
64 ,m_xTranslatedEventSource( _rxTranslatedEventSource )
66 if ( !m_xDelegator.is() )
67 throw NullPointerException();
70 //--------------------------------------------------------------------
71 void SAL_CALL PropertyEventTranslation::propertyChange( const PropertyChangeEvent& evt ) throw (RuntimeException)
73 if ( !m_xDelegator.is() )
74 throw DisposedException();
76 if ( !m_xTranslatedEventSource.is() )
77 m_xDelegator->propertyChange( evt );
78 else
80 PropertyChangeEvent aTranslatedEvent( evt );
81 aTranslatedEvent.Source = m_xTranslatedEventSource;
82 m_xDelegator->propertyChange( aTranslatedEvent );
86 //--------------------------------------------------------------------
87 void SAL_CALL PropertyEventTranslation::disposing( const EventObject& Source ) throw (RuntimeException)
89 if ( !m_xDelegator.is() )
90 throw DisposedException();
92 if ( !m_xTranslatedEventSource.is() )
93 m_xDelegator->disposing( Source );
94 else
96 EventObject aTranslatedEvent( Source );
97 aTranslatedEvent.Source = m_xTranslatedEventSource;
98 m_xDelegator->disposing( aTranslatedEvent );
101 m_xDelegator.clear();
102 m_xTranslatedEventSource.clear();
105 //........................................................................
106 } // namespace pcr
107 //........................................................................