summaryrefslogtreecommitdiff
path: root/chart2/source
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2015-08-20 00:13:19 +0200
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2015-08-20 00:14:51 +0200
commitacd818d9735a6fa4e38016b16ba7efc880058714 (patch)
treef50a4bf48a18fdd38491c0483e29bc0f5516cfcd /chart2/source
parentcf7db8226240ca7f425cf649e164767988c80001 (diff)
update the color button when we select an object
Change-Id: Ib45a02248819c35844ef83435c33ab1c82f5c4dc
Diffstat (limited to 'chart2/source')
-rw-r--r--chart2/source/controller/sidebar/ChartAreaPanel.cxx14
-rw-r--r--chart2/source/controller/sidebar/ChartColorWrapper.cxx25
-rw-r--r--chart2/source/controller/sidebar/ChartColorWrapper.hxx12
3 files changed, 43 insertions, 8 deletions
diff --git a/chart2/source/controller/sidebar/ChartAreaPanel.cxx b/chart2/source/controller/sidebar/ChartAreaPanel.cxx
index dbf9a6837b6b..6377e64fb356 100644
--- a/chart2/source/controller/sidebar/ChartAreaPanel.cxx
+++ b/chart2/source/controller/sidebar/ChartAreaPanel.cxx
@@ -25,6 +25,13 @@ namespace chart { namespace sidebar {
namespace {
+SvxColorToolBoxControl* getColorToolBoxControl(sfx2::sidebar::SidebarToolBox* pToolBoxColor)
+{
+ css::uno::Reference<css::frame::XToolbarController> xController = pToolBoxColor->GetFirstController();
+ SvxColorToolBoxControl* pToolBoxColorControl = dynamic_cast<SvxColorToolBoxControl*>(xController.get());
+ return pToolBoxColorControl;
+}
+
OUString getCID(css::uno::Reference<css::frame::XModel> xModel)
{
css::uno::Reference<css::frame::XController> xController(xModel->getCurrentController());
@@ -240,7 +247,7 @@ ChartAreaPanel::ChartAreaPanel(vcl::Window* pParent,
mxSelectionListener(new ChartSidebarSelectionListener(this)),
mbUpdate(true),
mbModelValid(true),
- maFillColorWrapper(mxModel)
+ maFillColorWrapper(mxModel, getColorToolBoxControl(mpToolBoxColor.get()))
{
std::vector<ObjectType> aAcceptedTypes { OBJECTTYPE_PAGE, OBJECTTYPE_DIAGRAM, OBJECTTYPE_DATA_SERIES, OBJECTTYPE_TITLE, OBJECTTYPE_LEGEND};
mxSelectionListener->setAcceptedTypes(aAcceptedTypes);
@@ -273,8 +280,7 @@ 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());
+ SvxColorToolBoxControl* pToolBoxColor = getColorToolBoxControl(mpToolBoxColor.get());
pToolBoxColor->setColorSelectFunction(maFillColorWrapper);
updateData();
@@ -427,6 +433,8 @@ void ChartAreaPanel::updateData()
xPropSet->getPropertyValue("FillTransparenceGradientName") >>= aFillFloatTransparenceName;
XFillFloatTransparenceItem aFillFloatTransparenceItem = getXTransparencyGradientForName(mxModel, aFillFloatTransparenceName);
updateFillFloatTransparence(false, true, &aFillFloatTransparenceItem);
+
+ maFillColorWrapper.updateData();
}
void ChartAreaPanel::modelInvalid()
diff --git a/chart2/source/controller/sidebar/ChartColorWrapper.cxx b/chart2/source/controller/sidebar/ChartColorWrapper.cxx
index d8a8f870f28f..beeb85df3c72 100644
--- a/chart2/source/controller/sidebar/ChartColorWrapper.cxx
+++ b/chart2/source/controller/sidebar/ChartColorWrapper.cxx
@@ -11,6 +11,10 @@
#include "ChartController.hxx"
+#include <editeng/colritem.hxx>
+#include <svx/tbcontrl.hxx>
+#include <svx/svxids.hrc>
+
namespace chart { namespace sidebar {
namespace {
@@ -56,13 +60,15 @@ css::uno::Reference<css::beans::XPropertySet> getPropSet(
}
ChartColorWrapper::ChartColorWrapper(
- css::uno::Reference<css::frame::XModel> xModel):
+ css::uno::Reference<css::frame::XModel> xModel,
+ SvxColorToolBoxControl* pControl):
mxModel(xModel),
+ mpControl(pControl),
maPropertyName("FillColor")
{
}
-void ChartColorWrapper::operator()(const OUString& rCommand, const Color& rColor)
+void ChartColorWrapper::operator()(const OUString& , const Color& rColor)
{
css::uno::Reference<css::beans::XPropertySet> xPropSet = getPropSet(mxModel);
assert(xPropSet.is());
@@ -75,6 +81,21 @@ void ChartColorWrapper::updateModel(css::uno::Reference<css::frame::XModel> xMod
mxModel = xModel;
}
+void ChartColorWrapper::updateData()
+{
+ css::uno::Reference<css::beans::XPropertySet> xPropSet = getPropSet(mxModel);
+ if (!xPropSet.is())
+ return;
+
+ css::uno::Any aAny = xPropSet->getPropertyValue(maPropertyName);
+ sal_uInt32 nColor = 0;
+ aAny >>= nColor;
+ Color aColor(nColor);
+
+ SvxColorItem aItem(aColor, SID_ATTR_FILL_COLOR);
+ mpControl->StateChanged(SID_ATTR_FILL_COLOR, SfxItemState::SET, &aItem);
+}
+
} }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/controller/sidebar/ChartColorWrapper.hxx b/chart2/source/controller/sidebar/ChartColorWrapper.hxx
index adbe9ef0d05f..b0f90710e138 100644
--- a/chart2/source/controller/sidebar/ChartColorWrapper.hxx
+++ b/chart2/source/controller/sidebar/ChartColorWrapper.hxx
@@ -13,6 +13,8 @@
#include <com/sun/star/frame/XFramesSupplier.hpp>
#include <tools/color.hxx>
+class SvxColorToolBoxControl;
+
namespace chart { namespace sidebar {
class ChartColorWrapper
@@ -20,17 +22,21 @@ class ChartColorWrapper
private:
public:
- ChartColorWrapper(css::uno::Reference<css::frame::XModel> xModel);
+ ChartColorWrapper(css::uno::Reference<css::frame::XModel> xModel,
+ SvxColorToolBoxControl* pControl);
void operator()(const OUString& rCommand, const Color& rColor);
void updateModel(css::uno::Reference<css::frame::XModel> xModel);
+
+ void updateData();
+
private:
- // not the chart frame
- // you need to get the chart frame through getActiveFrame
css::uno::Reference<css::frame::XModel> mxModel;
+ SvxColorToolBoxControl* mpControl;
+
OUString maPropertyName;
};