1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_COMPHELPER_SELECTIONMULTIPLEX_HXX
21 #define INCLUDED_COMPHELPER_SELECTIONMULTIPLEX_HXX
23 #include <com/sun/star/view/XSelectionChangeListener.hpp>
24 #include <com/sun/star/view/XSelectionSupplier.hpp>
25 #include <cppuhelper/implbase.hxx>
26 #include <comphelper/comphelperdllapi.h>
29 //= selection helper classes
36 class OSelectionChangeMultiplexer
;
39 //= OSelectionChangeListener
41 /// simple listener adapter for selections
42 class COMPHELPER_DLLPUBLIC OSelectionChangeListener
44 friend class OSelectionChangeMultiplexer
;
46 OSelectionChangeMultiplexer
* m_pAdapter
;
47 ::osl::Mutex
& m_rMutex
;
50 OSelectionChangeListener(::osl::Mutex
& _rMutex
)
51 : m_pAdapter(nullptr), m_rMutex(_rMutex
) { }
52 virtual ~OSelectionChangeListener();
54 virtual void _selectionChanged( const css::lang::EventObject
& aEvent
) throw (css::uno::RuntimeException
) = 0;
55 virtual void _disposing(const css::lang::EventObject
& _rSource
)
56 throw (css::uno::RuntimeException
, std::exception
);
59 // pseudo-private. Making it private now could break compatibility
60 void setAdapter( OSelectionChangeMultiplexer
* _pAdapter
);
64 //= OSelectionChangeMultiplexer
66 /// multiplexer for selection changes
67 class COMPHELPER_DLLPUBLIC OSelectionChangeMultiplexer
:public cppu::WeakImplHelper
< css::view::XSelectionChangeListener
>
69 friend class OSelectionChangeListener
;
70 css::uno::Reference
< css::view::XSelectionSupplier
> m_xSet
;
71 OSelectionChangeListener
* m_pListener
;
72 sal_Int32 m_nLockCount
;
74 OSelectionChangeMultiplexer(const OSelectionChangeMultiplexer
&) = delete;
75 OSelectionChangeMultiplexer
& operator=(const OSelectionChangeMultiplexer
&) = delete;
77 virtual ~OSelectionChangeMultiplexer() override
;
79 OSelectionChangeMultiplexer(OSelectionChangeListener
* _pListener
, const css::uno::Reference
< css::view::XSelectionSupplier
>& _rxSet
);
82 virtual void SAL_CALL
disposing( const css::lang::EventObject
& Source
) throw( css::uno::RuntimeException
, std::exception
) override
;
84 // XSelectionChangeListener
85 virtual void SAL_CALL
selectionChanged( const css::lang::EventObject
& aEvent
) throw (css::uno::RuntimeException
, std::exception
) override
;
89 /// incremental unlock
91 /// get the lock count
92 sal_Int32
locked() const { return m_nLockCount
; }
96 } // namespace comphelper
99 #endif // INCLUDED_COMPHELPER_SELECTIONMULTIPLEX_HXX
101 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */