LibreOffice Module comphelper (master)  1
SelectionMultiplex.cxx
Go to the documentation of this file.
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 
22 #include <com/sun/star/view/XSelectionSupplier.hpp>
23 
24 namespace comphelper
25 {
26 
27 
28 using namespace ::com::sun::star::uno;
29 using namespace ::com::sun::star::lang;
30 using namespace ::com::sun::star::view;
31 
33 {
34 }
35 
36 
37 void OSelectionChangeListener::_disposing(const EventObject&)
38 {
39  // nothing to do here
40 }
41 
42 
43 OSelectionChangeMultiplexer::OSelectionChangeMultiplexer(OSelectionChangeListener* _pListener, const Reference< XSelectionSupplier>& _rxSet)
44  :m_xSet(_rxSet)
45  ,m_pListener(_pListener)
46  ,m_nLockCount(0)
47 {
48  osl_atomic_increment(&m_refCount);
49  {
50  Reference< XSelectionChangeListener> xPreventDelete(this);
51  m_xSet->addSelectionChangeListener(xPreventDelete);
52  }
53  osl_atomic_decrement(&m_refCount);
54 }
55 
56 
58 {
59 }
60 
61 
63 {
64  ++m_nLockCount;
65 }
66 
67 
69 {
70  --m_nLockCount;
71 }
72 
73 
74 // XEventListener
75 
76 void SAL_CALL OSelectionChangeMultiplexer::disposing( const EventObject& _rSource)
77 {
78  if (m_pListener)
79  {
80  // tell the listener
81  if (!locked())
82  m_pListener->_disposing(_rSource);
83  }
84 
85  m_pListener = nullptr;
86 
87  m_xSet = nullptr;
88 }
89 
90 // XSelectionChangeListener
91 
92 void SAL_CALL OSelectionChangeMultiplexer::selectionChanged( const EventObject& _rEvent )
93 {
94  if (m_pListener && !locked())
96 }
97 
98 }
99 
100 
101 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Reference< css::view::XSelectionSupplier > m_xSet
virtual void _disposing(const css::lang::EventObject &_rSource)
OSelectionChangeMultiplexer(const OSelectionChangeMultiplexer &)=delete
simple listener adapter for selections
virtual void _selectionChanged(const css::lang::EventObject &aEvent)=0
sal_Int32 locked() const
get the lock count
virtual void SAL_CALL disposing(const css::lang::EventObject &Source) override
virtual void SAL_CALL selectionChanged(const css::lang::EventObject &aEvent) override