LibreOffice Module svx (master)
1
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
: maSelectionChangeCallback(rSelectionChangeCallback),
37
mxController(rxController),
38
meDefaultContext(eDefaultContext),
39
mbIsConnected(false)
40
{
41
}
42
43
44
SelectionChangeHandler::~SelectionChangeHandler
()
45
{
46
}
47
48
49
void
SAL_CALL
SelectionChangeHandler::selectionChanged
(
const
lang::EventObject&)
50
{
51
if
(maSelectionChangeCallback)
52
{
53
const
vcl::EnumContext::Context
eContext (
54
vcl::EnumContext::GetContextEnum
(maSelectionChangeCallback()));
55
ContextChangeEventMultiplexer::NotifyContextChange
(
56
mxController
,
57
eContext==
vcl::EnumContext::Context::Unknown
58
? meDefaultContext
59
: eContext);
60
}
61
}
62
63
64
void
SAL_CALL
SelectionChangeHandler::disposing
(
const
lang::EventObject&)
65
{
66
}
67
68
69
void
SelectionChangeHandler::disposing
(std::unique_lock<std::mutex>&)
70
{
71
if
(mbIsConnected)
72
Disconnect
();
73
}
74
75
76
void
SelectionChangeHandler::Connect()
77
{
78
uno::Reference<view::XSelectionSupplier> xSupplier (
mxController
, uno::UNO_QUERY);
79
if
(xSupplier.is())
80
{
81
mbIsConnected =
true
;
82
xSupplier->addSelectionChangeListener(
this
);
83
}
84
}
85
86
87
void
SelectionChangeHandler::Disconnect()
88
{
89
uno::Reference<view::XSelectionSupplier> xSupplier (
mxController
, uno::UNO_QUERY);
90
if
(xSupplier.is())
91
{
92
mbIsConnected =
false
;
93
xSupplier->removeSelectionChangeListener(
this
);
94
}
95
}
96
97
98
}
// end of namespace svx::sidebar
99
100
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
ContextChangeEventMultiplexer.hxx
EnumContext.hxx
ODBC3SQLFunctionId::Disconnect
@ Disconnect
SelectionChangeHandler.hxx
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
SelectionChangeHandler::disposing
virtual void SAL_CALL disposing(const css::lang::EventObject &) override
SelectionChangeHandler::selectionChanged
virtual void SAL_CALL selectionChanged(const css::lang::EventObject &) override
SelectionChangeHandler::~SelectionChangeHandler
~SelectionChangeHandler()
SelectionChangeHandler::mxController
css::uno::Reference< css::frame::XController > mxController
svx::sidebar::SelectionChangeHandler::SelectionChangeHandler
SelectionChangeHandler(const std::function< OUString()> &rSelectionChangeCallback, const css::uno::Reference< css::frame::XController > &rxController, const vcl::EnumContext::Context eDefaultContext)
vcl::EnumContext::Context
Context
vcl::EnumContext::Context::Unknown
@ Unknown
vcl::EnumContext::GetContextEnum
static Context GetContextEnum(const OUString &rsContextName)
svx::sidebar
Generated on Tue Jun 28 2022 21:18:24 for LibreOffice Module svx (master) by
1.9.3