LibreOffice Module svx (master)
1
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
svx
source
sidebar
SelectionChangeHandler.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
#include <
svx/sidebar/SelectionChangeHandler.hxx
>
20
#include <
svx/sidebar/ContextChangeEventMultiplexer.hxx
>
21
22
#include <com/sun/star/view/XSelectionSupplier.hpp>
23
24
#include <
vcl/EnumContext.hxx
>
25
26
27
using namespace
css
;
28
using namespace
css::uno
;
29
30
namespace
svx::sidebar
{
31
32
SelectionChangeHandler::SelectionChangeHandler
(
33
const
std::function<OUString()>& rSelectionChangeCallback,
34
const
Reference<css::frame::XController>& rxController,
35
const
vcl::EnumContext::Context
eDefaultContext)
36
:
SelectionChangeHandlerInterfaceBase
(
m_aMutex
),
37
maSelectionChangeCallback(rSelectionChangeCallback),
38
mxController(rxController),
39
meDefaultContext(eDefaultContext),
40
mbIsConnected(false)
41
{
42
}
43
44
45
SelectionChangeHandler::~SelectionChangeHandler
()
46
{
47
}
48
49
50
void
SAL_CALL
SelectionChangeHandler::selectionChanged
(
const
lang::EventObject&)
51
{
52
if
(
maSelectionChangeCallback
)
53
{
54
const
vcl::EnumContext::Context
eContext (
55
vcl::EnumContext::GetContextEnum
(
maSelectionChangeCallback
()));
56
ContextChangeEventMultiplexer::NotifyContextChange
(
57
mxController
,
58
eContext==
vcl::EnumContext::Context::Unknown
59
?
meDefaultContext
60
: eContext);
61
}
62
}
63
64
65
void
SAL_CALL
SelectionChangeHandler::disposing
(
const
lang::EventObject&)
66
{
67
}
68
69
70
void
SAL_CALL
SelectionChangeHandler::disposing
()
71
{
72
if
(
mbIsConnected
)
73
Disconnect
();
74
}
75
76
77
void
SelectionChangeHandler::Connect
()
78
{
79
uno::Reference<view::XSelectionSupplier> xSupplier (
mxController
, uno::UNO_QUERY);
80
if
(xSupplier.is())
81
{
82
mbIsConnected
=
true
;
83
xSupplier->addSelectionChangeListener(
this
);
84
}
85
}
86
87
88
void
SelectionChangeHandler::Disconnect
()
89
{
90
uno::Reference<view::XSelectionSupplier> xSupplier (
mxController
, uno::UNO_QUERY);
91
if
(xSupplier.is())
92
{
93
mbIsConnected
=
false
;
94
xSupplier->removeSelectionChangeListener(
this
);
95
}
96
}
97
98
99
}
// end of namespace svx::sidebar
100
101
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
svx::sidebar::SelectionChangeHandler::mxController
css::uno::Reference< css::frame::XController > mxController
Definition:
SelectionChangeHandler.hxx:66
svx::sidebar::SelectionChangeHandler::disposing
virtual void SAL_CALL disposing() override
Definition:
SelectionChangeHandler.cxx:70
svx::sidebar::SelectionChangeHandler::mbIsConnected
bool mbIsConnected
Definition:
SelectionChangeHandler.hxx:68
m_aMutex
osl::Mutex m_aMutex
SelectionChangeHandler::SelectionChangeHandler
SelectionChangeHandler(const css::uno::Reference< css::frame::XController > &rxController, DevelopmentToolDockingWindow *pDockingWindow)
svx::sidebar::SelectionChangeHandler::meDefaultContext
const vcl::EnumContext::Context meDefaultContext
Definition:
SelectionChangeHandler.hxx:67
vcl::EnumContext::GetContextEnum
static Context GetContextEnum(const OUString &rsContextName)
uno
vcl::EnumContext::Context
Context
ContextChangeEventMultiplexer::NotifyContextChange
static void NotifyContextChange(const css::uno::Reference< css::frame::XController > &rxController, const vcl::EnumContext::Context eContext)
Notify the activation of a context.
Definition:
ContextChangeEventMultiplexer.cxx:35
EnumContext.hxx
SelectionChangeHandler.hxx
svx::sidebar::SelectionChangeHandler::Disconnect
void Disconnect()
Definition:
SelectionChangeHandler.cxx:88
svx::sidebar::SelectionChangeHandler::selectionChanged
virtual void SAL_CALL selectionChanged(const css::lang::EventObject &rEvent) override
SelectionChangeHandlerInterfaceBase
cppu::WeakComponentImplHelper< css::view::XSelectionChangeListener > SelectionChangeHandlerInterfaceBase
svx::sidebar::SelectionChangeHandler::~SelectionChangeHandler
virtual ~SelectionChangeHandler() override
Definition:
SelectionChangeHandler.cxx:45
ContextChangeEventMultiplexer.hxx
svx::sidebar::SelectionChangeHandler::maSelectionChangeCallback
const std::function< OUString()> maSelectionChangeCallback
Definition:
SelectionChangeHandler.hxx:65
vcl::EnumContext::Context::Unknown
svx::sidebar
css
svx::sidebar::SelectionChangeHandler::Connect
void Connect()
Definition:
SelectionChangeHandler.cxx:77
Generated on Sat Feb 27 2021 02:35:58 for LibreOffice Module svx (master) by
1.8.10