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 : using ::com::sun::star::beans::PropertyChangeEvent;
31 : using ::com::sun::star::uno::RuntimeException;
32 : using ::com::sun::star::lang::EventObject;
33 : using ::com::sun::star::uno::Reference;
34 : using ::com::sun::star::beans::XPropertyChangeListener;
35 : using ::com::sun::star::uno::XInterface;
36 : using ::com::sun::star::lang::DisposedException;
37 : using ::com::sun::star::lang::NullPointerException;
38 :
39 :
40 : //= PropertyEventTranslation
41 :
42 :
43 0 : PropertyEventTranslation::PropertyEventTranslation( const Reference< XPropertyChangeListener >& _rxDelegator,
44 : const Reference< XInterface >& _rxTranslatedEventSource )
45 : :m_xDelegator( _rxDelegator )
46 0 : ,m_xTranslatedEventSource( _rxTranslatedEventSource )
47 : {
48 0 : if ( !m_xDelegator.is() )
49 0 : throw NullPointerException();
50 0 : }
51 :
52 :
53 0 : void SAL_CALL PropertyEventTranslation::propertyChange( const PropertyChangeEvent& evt ) throw (RuntimeException, std::exception)
54 : {
55 0 : if ( !m_xDelegator.is() )
56 0 : throw DisposedException();
57 :
58 0 : if ( !m_xTranslatedEventSource.is() )
59 0 : m_xDelegator->propertyChange( evt );
60 : else
61 : {
62 0 : PropertyChangeEvent aTranslatedEvent( evt );
63 0 : aTranslatedEvent.Source = m_xTranslatedEventSource;
64 0 : m_xDelegator->propertyChange( aTranslatedEvent );
65 : }
66 0 : }
67 :
68 :
69 0 : void SAL_CALL PropertyEventTranslation::disposing( const EventObject& Source ) throw (RuntimeException, std::exception)
70 : {
71 0 : if ( !m_xDelegator.is() )
72 0 : throw DisposedException();
73 :
74 0 : if ( !m_xTranslatedEventSource.is() )
75 0 : m_xDelegator->disposing( Source );
76 : else
77 : {
78 0 : EventObject aTranslatedEvent( Source );
79 0 : aTranslatedEvent.Source = m_xTranslatedEventSource;
80 0 : m_xDelegator->disposing( aTranslatedEvent );
81 : }
82 :
83 0 : m_xDelegator.clear();
84 0 : m_xTranslatedEventSource.clear();
85 0 : }
86 :
87 :
88 : } // namespace pcr
89 :
90 :
91 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|