Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*
3 : : * This file is part of the LibreOffice project.
4 : : *
5 : : * This Source Code Form is subject to the terms of the Mozilla Public
6 : : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : : *
9 : : * This file incorporates work covered by the following license notice:
10 : : *
11 : : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : : * contributor license agreements. See the NOTICE file distributed
13 : : * with this work for additional information regarding copyright
14 : : * ownership. The ASF licenses this file to you under the Apache
15 : : * License, Version 2.0 (the "License"); you may not use this file
16 : : * except in compliance with the License. You may obtain a copy of
17 : : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : : */
19 : :
20 : : #include "propeventtranslation.hxx"
21 : :
22 : : #include <com/sun/star/lang/DisposedException.hpp>
23 : : #include <com/sun/star/lang/NullPointerException.hpp>
24 : :
25 : : //........................................................................
26 : : namespace pcr
27 : : {
28 : : //........................................................................
29 : :
30 : : /** === begin UNO using === **/
31 : : using ::com::sun::star::beans::PropertyChangeEvent;
32 : : using ::com::sun::star::uno::RuntimeException;
33 : : using ::com::sun::star::lang::EventObject;
34 : : using ::com::sun::star::uno::Reference;
35 : : using ::com::sun::star::beans::XPropertyChangeListener;
36 : : using ::com::sun::star::uno::XInterface;
37 : : using ::com::sun::star::beans::PropertyChangeEvent;
38 : : using ::com::sun::star::lang::DisposedException;
39 : : using ::com::sun::star::lang::NullPointerException;
40 : : /** === end UNO using === **/
41 : :
42 : : //====================================================================
43 : : //= PropertyEventTranslation
44 : : //====================================================================
45 : : //--------------------------------------------------------------------
46 : 0 : PropertyEventTranslation::PropertyEventTranslation( const Reference< XPropertyChangeListener >& _rxDelegator,
47 : : const Reference< XInterface >& _rxTranslatedEventSource )
48 : : :m_xDelegator( _rxDelegator )
49 : 0 : ,m_xTranslatedEventSource( _rxTranslatedEventSource )
50 : : {
51 : 0 : if ( !m_xDelegator.is() )
52 : 0 : throw NullPointerException();
53 : 0 : }
54 : :
55 : : //--------------------------------------------------------------------
56 : 0 : void SAL_CALL PropertyEventTranslation::propertyChange( const PropertyChangeEvent& evt ) throw (RuntimeException)
57 : : {
58 : 0 : if ( !m_xDelegator.is() )
59 : 0 : throw DisposedException();
60 : :
61 : 0 : if ( !m_xTranslatedEventSource.is() )
62 : 0 : m_xDelegator->propertyChange( evt );
63 : : else
64 : : {
65 : 0 : PropertyChangeEvent aTranslatedEvent( evt );
66 : 0 : aTranslatedEvent.Source = m_xTranslatedEventSource;
67 : 0 : m_xDelegator->propertyChange( aTranslatedEvent );
68 : : }
69 : 0 : }
70 : :
71 : : //--------------------------------------------------------------------
72 : 0 : void SAL_CALL PropertyEventTranslation::disposing( const EventObject& Source ) throw (RuntimeException)
73 : : {
74 : 0 : if ( !m_xDelegator.is() )
75 : 0 : throw DisposedException();
76 : :
77 : 0 : if ( !m_xTranslatedEventSource.is() )
78 : 0 : m_xDelegator->disposing( Source );
79 : : else
80 : : {
81 : 0 : EventObject aTranslatedEvent( Source );
82 : 0 : aTranslatedEvent.Source = m_xTranslatedEventSource;
83 : 0 : m_xDelegator->disposing( aTranslatedEvent );
84 : : }
85 : :
86 : 0 : m_xDelegator.clear();
87 : 0 : m_xTranslatedEventSource.clear();
88 : 0 : }
89 : :
90 : : //........................................................................
91 : : } // namespace pcr
92 : : //........................................................................
93 : :
94 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|