vcl: allow for overriding the default PDF rendering resolution
[LibreOffice.git] / chart2 / source / controller / sidebar / ChartSidebarSelectionListener.cxx
blobe7d74c656a55311ce6926369ecc7bf015cf7e99d
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 {
18 namespace sidebar {
20 ChartSidebarSelectionListenerParent::~ChartSidebarSelectionListenerParent()
24 ChartSidebarSelectionListener::ChartSidebarSelectionListener(
25 ChartSidebarSelectionListenerParent* pParent):
26 mpParent(pParent)
30 ChartSidebarSelectionListener::ChartSidebarSelectionListener(
31 ChartSidebarSelectionListenerParent* pParent,
32 ObjectType eType):
33 mpParent(pParent)
35 maTypes.push_back(eType);
38 ChartSidebarSelectionListener::~ChartSidebarSelectionListener()
42 void ChartSidebarSelectionListener::selectionChanged(const css::lang::EventObject& rEvent)
44 if (!mpParent)
45 return;
47 bool bCorrectObjectSelected = false;
49 css::uno::Reference<css::frame::XController> xController(rEvent.Source, css::uno::UNO_QUERY);
50 if (xController.is())
52 css::uno::Reference<css::view::XSelectionSupplier> xSelectionSupplier(xController, css::uno::UNO_QUERY);
53 if (xSelectionSupplier.is())
55 css::uno::Any aAny = xSelectionSupplier->getSelection();
56 if (aAny.hasValue())
58 OUString aCID;
59 aAny >>= aCID;
60 ObjectType eType = ObjectIdentifier::getObjectType(aCID);
61 bCorrectObjectSelected = std::any_of(maTypes.begin(), maTypes.end(),
62 [eType](const ObjectType& eTypeInVector) { return eType == eTypeInVector; });
67 mpParent->selectionChanged(bCorrectObjectSelected);
70 void ChartSidebarSelectionListener::disposing(const css::lang::EventObject& /*rEvent*/)
72 if (!mpParent)
73 return;
75 mpParent = nullptr;
78 void ChartSidebarSelectionListener::setAcceptedTypes(const std::vector<ObjectType>& aTypes)
80 maTypes = aTypes;
83 } }
85 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */