LibreOffice Module sfx2 (master) 1
SelectionChangeHandler.hxx
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 */
10
11#pragma once
12
14
15#include <com/sun/star/frame/XController.hpp>
16#include <com/sun/star/view/XSelectionSupplier.hpp>
17
19#include <utility>
20
23
30{
31private:
32 css::uno::Reference<css::frame::XController> mxController;
34
35public:
36 SelectionChangeHandler(css::uno::Reference<css::frame::XController> xController,
37 DevelopmentToolDockingWindow* pDockingWindow)
39 , mpDockingWindow(pDockingWindow)
40 {
41 css::uno::Reference<css::view::XSelectionSupplier> xSupplier(mxController,
42 css::uno::UNO_QUERY);
43 xSupplier->addSelectionChangeListener(this);
44 }
45
47
48 virtual void SAL_CALL selectionChanged(const css::lang::EventObject& /*rEvent*/) override
49 {
50 css::uno::Reference<css::view::XSelectionSupplier> xSupplier(mxController,
51 css::uno::UNO_QUERY);
52 if (xSupplier.is())
53 {
54 css::uno::Any aAny = xSupplier->getSelection();
55 auto xInterface = aAny.get<css::uno::Reference<css::uno::XInterface>>();
56 mpDockingWindow->selectionChanged(xInterface);
57 }
58 }
59
61 {
62 css::uno::Reference<css::view::XSelectionSupplier> xSupplier(mxController,
63 css::uno::UNO_QUERY);
64 xSupplier->removeSelectionChangeListener(this);
65 }
66
67 virtual void SAL_CALL disposing(const css::lang::EventObject& /*rEvent*/) override {}
69
70private:
73};
74
75/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
comphelper::WeakComponentImplHelper< css::view::XSelectionChangeListener > SelectionChangeHandlerInterfaceBase
Development tool main docking window.
Selection change handler to listen to document selection changes.
SelectionChangeHandler(const SelectionChangeHandler &)=delete
virtual void SAL_CALL disposing(const css::lang::EventObject &) override
virtual void SAL_CALL selectionChanged(const css::lang::EventObject &) override
VclPtr< DevelopmentToolDockingWindow > mpDockingWindow
css::uno::Reference< css::frame::XController > mxController
SelectionChangeHandler(css::uno::Reference< css::frame::XController > xController, DevelopmentToolDockingWindow *pDockingWindow)
SelectionChangeHandler & operator=(const SelectionChangeHandler &)=delete
void disposeAndClear()
virtual void disposing(std::unique_lock< std::mutex > &)
Reference< XController > xController