tdf#120397 - odf export fix missing texts in text box control
[LibreOffice.git] / chart2 / source / controller / sidebar / ChartSidebarSelectionListener.cxx
blobc3757a3b877ac81c0569f064fdba3237fcf94ed5
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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/.
8 */
10 #include "ChartSidebarSelectionListener.hxx"
12 #include <com/sun/star/view/XSelectionSupplier.hpp>
13 #include <com/sun/star/frame/XController.hpp>
15 #include <ObjectIdentifier.hxx>
17 namespace chart::sidebar {
19 ChartSidebarSelectionListenerParent::~ChartSidebarSelectionListenerParent()
23 ChartSidebarSelectionListener::ChartSidebarSelectionListener(
24 ChartSidebarSelectionListenerParent* pParent):
25 mpParent(pParent)
29 ChartSidebarSelectionListener::ChartSidebarSelectionListener(
30 ChartSidebarSelectionListenerParent* pParent,
31 ObjectType eType):
32 mpParent(pParent)
34 maTypes.push_back(eType);
37 ChartSidebarSelectionListener::~ChartSidebarSelectionListener()
41 void ChartSidebarSelectionListener::selectionChanged(const css::lang::EventObject& rEvent)
43 if (!mpParent)
44 return;
46 bool bCorrectObjectSelected = false;
48 css::uno::Reference<css::frame::XController> xController(rEvent.Source, css::uno::UNO_QUERY);
49 if (xController.is())
51 css::uno::Reference<css::view::XSelectionSupplier> xSelectionSupplier(xController, css::uno::UNO_QUERY);
52 if (xSelectionSupplier.is())
54 css::uno::Any aAny = xSelectionSupplier->getSelection();
55 if (aAny.hasValue())
57 OUString aCID;
58 aAny >>= aCID;
59 ObjectType eType = ObjectIdentifier::getObjectType(aCID);
60 bCorrectObjectSelected = std::any_of(maTypes.begin(), maTypes.end(),
61 [eType](const ObjectType& eTypeInVector) { return eType == eTypeInVector; });
66 mpParent->selectionChanged(bCorrectObjectSelected);
69 void ChartSidebarSelectionListener::disposing(const css::lang::EventObject& /*rEvent*/)
71 if (!mpParent)
72 return;
74 mpParent = nullptr;
77 void ChartSidebarSelectionListener::setAcceptedTypes(std::vector<ObjectType>&& aTypes)
79 maTypes = std::move(aTypes);
84 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */