summaryrefslogtreecommitdiff
path: root/chart2
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2015-08-19 23:43:39 +0200
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2015-08-20 00:14:51 +0200
commitcf7db8226240ca7f425cf649e164767988c80001 (patch)
tree69b6b2c983ea7f417d58c862636c9d510ff8d9b1 /chart2
parent6038ba92be0a4c821ffa29ed0512905e4b3cd8f8 (diff)
handle new color picker correctly in chart sidebar
This implements the basics for that and implements it in the AreaPanel. Change-Id: I6d9e5012bbcc2c953d478a09a839f35f2ef64c5b
Diffstat (limited to 'chart2')
-rw-r--r--chart2/Library_chartcontroller.mk1
-rw-r--r--chart2/source/controller/sidebar/ChartAreaPanel.cxx9
-rw-r--r--chart2/source/controller/sidebar/ChartAreaPanel.hxx3
-rw-r--r--chart2/source/controller/sidebar/ChartColorWrapper.cxx80
-rw-r--r--chart2/source/controller/sidebar/ChartColorWrapper.hxx41
5 files changed, 133 insertions, 1 deletions
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 <svx/xflftrit.hxx>
#include <svx/unomid.hxx>
+#include <svx/tbcontrl.hxx>
+
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<ObjectType> 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<css::frame::XToolbarController> xController = mpToolBoxColor->GetFirstController();
+ SvxColorToolBoxControl* pToolBoxColor = dynamic_cast<SvxColorToolBoxControl*>(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<css::frame::XModel> xModel)
+{
+ css::uno::Reference<css::frame::XController> xController(xModel->getCurrentController());
+ css::uno::Reference<css::view::XSelectionSupplier> 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<css::beans::XPropertySet> getPropSet(
+ css::uno::Reference<css::frame::XModel> xModel)
+{
+ OUString aCID = getCID(xModel);
+ css::uno::Reference<css::beans::XPropertySet> xPropSet =
+ ObjectIdentifier::getObjectPropertySet(aCID, xModel);
+
+ ObjectType eType = ObjectIdentifier::getObjectType(aCID);
+ if (eType == OBJECTTYPE_DIAGRAM)
+ {
+ css::uno::Reference<css::chart2::XDiagram> xDiagram(
+ xPropSet, css::uno::UNO_QUERY);
+ if (!xDiagram.is())
+ return xPropSet;
+
+ xPropSet.set(xDiagram->getWall());
+ }
+
+ return xPropSet;
+}
+
+}
+
+ChartColorWrapper::ChartColorWrapper(
+ css::uno::Reference<css::frame::XModel> xModel):
+ mxModel(xModel),
+ maPropertyName("FillColor")
+{
+}
+
+void ChartColorWrapper::operator()(const OUString& rCommand, const Color& rColor)
+{
+ css::uno::Reference<css::beans::XPropertySet> xPropSet = getPropSet(mxModel);
+ assert(xPropSet.is());
+
+ xPropSet->setPropertyValue(maPropertyName, css::uno::makeAny(rColor.GetColor()));
+}
+
+void ChartColorWrapper::updateModel(css::uno::Reference<css::frame::XModel> 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 <com/sun/star/frame/XFramesSupplier.hpp>
+#include <tools/color.hxx>
+
+namespace chart { namespace sidebar {
+
+class ChartColorWrapper
+{
+private:
+
+public:
+ ChartColorWrapper(css::uno::Reference<css::frame::XModel> xModel);
+
+ void operator()(const OUString& rCommand, const Color& rColor);
+
+ void updateModel(css::uno::Reference<css::frame::XModel> xModel);
+private:
+
+ // not the chart frame
+ // you need to get the chart frame through getActiveFrame
+ css::uno::Reference<css::frame::XModel> mxModel;
+
+ OUString maPropertyName;
+};
+
+} }
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */