bump product version to 4.1.6.2
[LibreOffice.git] / svx / source / sidebar / SelectionChangeHandler.cxx
blobb6f6d9b68728e99e5f7563fb94fa6c808a566254
1 /*
2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 #include "svx/sidebar/SelectionChangeHandler.hxx"
19 #include "svx/sidebar/SelectionAnalyzer.hxx"
20 #include "svx/sidebar/ContextChangeEventMultiplexer.hxx"
21 #include "svx/svdmrkv.hxx"
23 #include <sfx2/sidebar/EnumContext.hxx>
24 #include <sfx2/shell.hxx>
27 using namespace css;
28 using namespace cssu;
30 using namespace sfx2::sidebar;
32 namespace svx { namespace sidebar {
34 SelectionChangeHandler::SelectionChangeHandler (
35 const boost::function<rtl::OUString(void)>& rSelectionChangeCallback,
36 const Reference<frame::XController>& rxController,
37 const EnumContext::Context eDefaultContext)
38 : SelectionChangeHandlerInterfaceBase(m_aMutex),
39 maSelectionChangeCallback(rSelectionChangeCallback),
40 mxController(rxController),
41 meDefaultContext(eDefaultContext),
42 mbIsConnected(false)
49 SelectionChangeHandler::~SelectionChangeHandler (void)
56 void SAL_CALL SelectionChangeHandler::selectionChanged (const lang::EventObject&)
57 throw (uno::RuntimeException)
59 if (maSelectionChangeCallback)
61 const EnumContext::Context eContext (
62 EnumContext::GetContextEnum(maSelectionChangeCallback()));
63 ContextChangeEventMultiplexer::NotifyContextChange(
64 mxController,
65 eContext==EnumContext::Context_Unknown
66 ? meDefaultContext
67 : eContext);
74 void SAL_CALL SelectionChangeHandler::disposing (const lang::EventObject&)
75 throw (uno::RuntimeException)
82 void SAL_CALL SelectionChangeHandler::disposing (void)
83 throw (uno::RuntimeException)
85 if (mbIsConnected)
86 Disconnect();
92 void SelectionChangeHandler::Connect (void)
94 uno::Reference<view::XSelectionSupplier> xSupplier (mxController, uno::UNO_QUERY);
95 if (xSupplier.is())
97 mbIsConnected = true;
98 xSupplier->addSelectionChangeListener(this);
105 void SelectionChangeHandler::Disconnect (void)
107 uno::Reference<view::XSelectionSupplier> xSupplier (mxController, uno::UNO_QUERY);
108 if (xSupplier.is())
110 mbIsConnected = false;
111 xSupplier->removeSelectionChangeListener(this);
116 } } // end of namespace svx::sidebar