From cf7db8226240ca7f425cf649e164767988c80001 Mon Sep 17 00:00:00 2001 From: Markus Mohrhard Date: Wed, 19 Aug 2015 23:43:39 +0200 Subject: handle new color picker correctly in chart sidebar This implements the basics for that and implements it in the AreaPanel. Change-Id: I6d9e5012bbcc2c953d478a09a839f35f2ef64c5b --- chart2/Library_chartcontroller.mk | 1 + .../source/controller/sidebar/ChartAreaPanel.cxx | 9 ++- .../source/controller/sidebar/ChartAreaPanel.hxx | 3 + .../controller/sidebar/ChartColorWrapper.cxx | 80 ++++++++++++++++++++++ .../controller/sidebar/ChartColorWrapper.hxx | 41 +++++++++++ 5 files changed, 133 insertions(+), 1 deletion(-) create mode 100644 chart2/source/controller/sidebar/ChartColorWrapper.cxx create mode 100644 chart2/source/controller/sidebar/ChartColorWrapper.hxx (limited to 'chart2') diff --git a/chart2/Library_chartcontroller.mk b/chart2/Library_chartcontroller.mk index e06edd176ba1..9f8b65f8045f 100644 --- a/chart2/Library_chartcontroller.mk +++ b/chart2/Library_chartcontroller.mk @@ -191,6 +191,7 @@ $(eval $(call gb_Library_add_exception_objects,chartcontroller,\ chart2/source/controller/sidebar/Chart2PanelFactory \ chart2/source/controller/sidebar/ChartAreaPanel \ chart2/source/controller/sidebar/ChartAxisPanel \ + chart2/source/controller/sidebar/ChartColorWrapper \ chart2/source/controller/sidebar/ChartElementsPanel \ chart2/source/controller/sidebar/ChartErrorBarPanel \ chart2/source/controller/sidebar/ChartLinePanel \ diff --git a/chart2/source/controller/sidebar/ChartAreaPanel.cxx b/chart2/source/controller/sidebar/ChartAreaPanel.cxx index 3230e7c32534..dbf9a6837b6b 100644 --- a/chart2/source/controller/sidebar/ChartAreaPanel.cxx +++ b/chart2/source/controller/sidebar/ChartAreaPanel.cxx @@ -19,6 +19,8 @@ #include #include +#include + namespace chart { namespace sidebar { namespace { @@ -237,7 +239,8 @@ ChartAreaPanel::ChartAreaPanel(vcl::Window* pParent, mxListener(new ChartSidebarModifyListener(this)), mxSelectionListener(new ChartSidebarSelectionListener(this)), mbUpdate(true), - mbModelValid(true) + mbModelValid(true), + maFillColorWrapper(mxModel) { std::vector aAcceptedTypes { OBJECTTYPE_PAGE, OBJECTTYPE_DIAGRAM, OBJECTTYPE_DATA_SERIES, OBJECTTYPE_TITLE, OBJECTTYPE_LEGEND}; mxSelectionListener->setAcceptedTypes(aAcceptedTypes); @@ -270,6 +273,10 @@ void ChartAreaPanel::Initialize() if (xSelectionSupplier.is()) xSelectionSupplier->addSelectionChangeListener(mxSelectionListener.get()); + css::uno::Reference xController = mpToolBoxColor->GetFirstController(); + SvxColorToolBoxControl* pToolBoxColor = dynamic_cast(xController.get()); + pToolBoxColor->setColorSelectFunction(maFillColorWrapper); + updateData(); } diff --git a/chart2/source/controller/sidebar/ChartAreaPanel.hxx b/chart2/source/controller/sidebar/ChartAreaPanel.hxx index 48df2ace78c7..aa66339d975c 100644 --- a/chart2/source/controller/sidebar/ChartAreaPanel.hxx +++ b/chart2/source/controller/sidebar/ChartAreaPanel.hxx @@ -30,6 +30,7 @@ #include "ChartSidebarModifyListener.hxx" #include "ChartSidebarSelectionListener.hxx" +#include "ChartColorWrapper.hxx" class XFillFloatTransparenceItem; class XFillTransparenceItem; @@ -92,6 +93,8 @@ private: bool mbUpdate; bool mbModelValid; + + ChartColorWrapper maFillColorWrapper; }; } } // end of namespace svx::sidebar diff --git a/chart2/source/controller/sidebar/ChartColorWrapper.cxx b/chart2/source/controller/sidebar/ChartColorWrapper.cxx new file mode 100644 index 000000000000..d8a8f870f28f --- /dev/null +++ b/chart2/source/controller/sidebar/ChartColorWrapper.cxx @@ -0,0 +1,80 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include "ChartColorWrapper.hxx" + +#include "ChartController.hxx" + +namespace chart { namespace sidebar { + +namespace { + +OUString getCID(css::uno::Reference xModel) +{ + css::uno::Reference xController(xModel->getCurrentController()); + css::uno::Reference xSelectionSupplier(xController, css::uno::UNO_QUERY); + if (!xSelectionSupplier.is()) + return OUString(); + + css::uno::Any aAny = xSelectionSupplier->getSelection(); + if (!aAny.hasValue()) + return OUString(); + + OUString aCID; + aAny >>= aCID; + + return aCID; +} + +css::uno::Reference getPropSet( + css::uno::Reference xModel) +{ + OUString aCID = getCID(xModel); + css::uno::Reference xPropSet = + ObjectIdentifier::getObjectPropertySet(aCID, xModel); + + ObjectType eType = ObjectIdentifier::getObjectType(aCID); + if (eType == OBJECTTYPE_DIAGRAM) + { + css::uno::Reference xDiagram( + xPropSet, css::uno::UNO_QUERY); + if (!xDiagram.is()) + return xPropSet; + + xPropSet.set(xDiagram->getWall()); + } + + return xPropSet; +} + +} + +ChartColorWrapper::ChartColorWrapper( + css::uno::Reference xModel): + mxModel(xModel), + maPropertyName("FillColor") +{ +} + +void ChartColorWrapper::operator()(const OUString& rCommand, const Color& rColor) +{ + css::uno::Reference xPropSet = getPropSet(mxModel); + assert(xPropSet.is()); + + xPropSet->setPropertyValue(maPropertyName, css::uno::makeAny(rColor.GetColor())); +} + +void ChartColorWrapper::updateModel(css::uno::Reference xModel) +{ + mxModel = xModel; +} + +} } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/controller/sidebar/ChartColorWrapper.hxx b/chart2/source/controller/sidebar/ChartColorWrapper.hxx new file mode 100644 index 000000000000..adbe9ef0d05f --- /dev/null +++ b/chart2/source/controller/sidebar/ChartColorWrapper.hxx @@ -0,0 +1,41 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef INCLUDED_CHART2_SOURCE_CONTROLLER_SIDEBAR_CHARTCOLORWRAPPER_HXX +#define INCLUDED_CHART2_SOURCE_CONTROLLER_SIDEBAR_CHARTCOLORWRAPPER_HXX + +#include +#include + +namespace chart { namespace sidebar { + +class ChartColorWrapper +{ +private: + +public: + ChartColorWrapper(css::uno::Reference xModel); + + void operator()(const OUString& rCommand, const Color& rColor); + + void updateModel(css::uno::Reference xModel); +private: + + // not the chart frame + // you need to get the chart frame through getActiveFrame + css::uno::Reference mxModel; + + OUString maPropertyName; +}; + +} } + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit