diff --git a/chart2/source/controller/sidebar/ChartAreaPanel.cxx b/chart2/source/controller/sidebar/ChartAreaPanel.cxx index a4241c9b8cf0..3319bf5d6f6d 100644 --- a/chart2/source/controller/sidebar/ChartAreaPanel.cxx +++ b/chart2/source/controller/sidebar/ChartAreaPanel.cxx @@ -13,6 +13,32 @@ 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(); + assert(aAny.hasValue()); + OUString aCID; + aAny >>= aCID; + + return aCID; +} + +css::uno::Reference getPropSet( + css::uno::Reference xModel) +{ + OUString aCID = getCID(xModel); + return ObjectIdentifier::getObjectPropertySet(aCID, xModel); +} + +} + VclPtr ChartAreaPanel::Create( vcl::Window* pParent, const css::uno::Reference& rxFrame, @@ -29,8 +55,10 @@ VclPtr ChartAreaPanel::Create( ChartAreaPanel::ChartAreaPanel(vcl::Window* pParent, const css::uno::Reference& rxFrame, - ChartController* /*pController*/): - svx::sidebar::AreaPropertyPanelBase(pParent, rxFrame) + ChartController* pController): + svx::sidebar::AreaPropertyPanelBase(pParent, rxFrame), + mxModel(pController->getModel()), + mxListener(new ChartSidebarModifyListener(this)) { } @@ -39,6 +67,18 @@ ChartAreaPanel::~ChartAreaPanel() disposeOnce(); } +void ChartAreaPanel::dispose() +{ + css::uno::Reference xBroadcaster(mxModel, css::uno::UNO_QUERY_THROW); + xBroadcaster->removeModifyListener(mxListener); +} + +void ChartAreaPanel::Initialize() +{ + css::uno::Reference xBroadcaster(mxModel, css::uno::UNO_QUERY_THROW); + xBroadcaster->addModifyListener(mxListener); +} + void ChartAreaPanel::setFillTransparence(const XFillTransparenceItem& /*rItem*/) { @@ -49,33 +89,54 @@ void ChartAreaPanel::setFillFloatTransparence(const XFillFloatTransparenceItem& } -void ChartAreaPanel::setFillStyle(const XFillStyleItem& /*rItem*/) +void ChartAreaPanel::setFillStyle(const XFillStyleItem& rItem) { - + css::uno::Reference xPropSet = getPropSet(mxModel); + xPropSet->setPropertyValue("FillStyle", css::uno::makeAny(rItem.GetValue())); } -void ChartAreaPanel::setFillStyleAndColor(const XFillStyleItem* /*pStyleItem*/, - const XFillColorItem& /*rColorItem*/) +void ChartAreaPanel::setFillStyleAndColor(const XFillStyleItem* pStyleItem, + const XFillColorItem& rColorItem) { - + css::uno::Reference xPropSet = getPropSet(mxModel); + if (pStyleItem) + xPropSet->setPropertyValue("FillStyle", css::uno::makeAny(pStyleItem->GetValue())); + xPropSet->setPropertyValue("Color", css::uno::makeAny(rColorItem.GetValue())); } -void ChartAreaPanel::setFillStyleAndGradient(const XFillStyleItem* /*pStyleItem*/, - const XFillGradientItem& /*rGradientItem*/) +void ChartAreaPanel::setFillStyleAndGradient(const XFillStyleItem* pStyleItem, + const XFillGradientItem& rGradientItem) { - + css::uno::Reference xPropSet = getPropSet(mxModel); + if (pStyleItem) + xPropSet->setPropertyValue("FillStyle", css::uno::makeAny(pStyleItem->GetValue())); + xPropSet->setPropertyValue("GradientName", css::uno::makeAny(rGradientItem.GetValue())); } -void ChartAreaPanel::setFillStyleAndHatch(const XFillStyleItem* /*pStyleItem*/, - const XFillHatchItem& /*rHatchItem*/) +void ChartAreaPanel::setFillStyleAndHatch(const XFillStyleItem* pStyleItem, + const XFillHatchItem& rHatchItem) { - + css::uno::Reference xPropSet = getPropSet(mxModel); + if (pStyleItem) + xPropSet->setPropertyValue("FillStyle", css::uno::makeAny(pStyleItem->GetValue())); + xPropSet->setPropertyValue("HatchName", css::uno::makeAny(rHatchItem.GetValue())); } -void ChartAreaPanel::setFillStyleAndBitmap(const XFillStyleItem* /*pStyleItem*/, - const XFillBitmapItem& /*rBitmapItem*/) +void ChartAreaPanel::setFillStyleAndBitmap(const XFillStyleItem* pStyleItem, + const XFillBitmapItem& rBitmapItem) { + css::uno::Reference xPropSet = getPropSet(mxModel); + if (pStyleItem) + xPropSet->setPropertyValue("FillStyle", css::uno::makeAny(pStyleItem->GetValue())); + xPropSet->setPropertyValue("FillBitmapName", css::uno::makeAny(rBitmapItem.GetValue())); +} +void ChartAreaPanel::updateData() +{ +} + +void ChartAreaPanel::modelInvalid() +{ } diff --git a/chart2/source/controller/sidebar/ChartAreaPanel.hxx b/chart2/source/controller/sidebar/ChartAreaPanel.hxx index 4f4ac8b246bd..f5b45aed7e6e 100644 --- a/chart2/source/controller/sidebar/ChartAreaPanel.hxx +++ b/chart2/source/controller/sidebar/ChartAreaPanel.hxx @@ -27,6 +27,8 @@ #include +#include "ChartSidebarModifyListener.hxx" + class XFillFloatTransparenceItem; class XFillTransparenceItem; class XFillStyleItem; @@ -41,7 +43,8 @@ class ChartController; namespace sidebar { -class ChartAreaPanel : public svx::sidebar::AreaPropertyPanelBase +class ChartAreaPanel : public svx::sidebar::AreaPropertyPanelBase, + public ChartSidebarModifyListenerParent { public: static VclPtr Create( @@ -65,8 +68,19 @@ public: virtual void setFillStyleAndHatch(const XFillStyleItem* pStyleItem, const XFillHatchItem& rHatchItem); virtual void setFillStyleAndBitmap(const XFillStyleItem* pStyleItem, const XFillBitmapItem& rBitmapItem); + virtual void updateData() SAL_OVERRIDE; + + virtual void modelInvalid() SAL_OVERRIDE; + + virtual void dispose() SAL_OVERRIDE; + private: + css::uno::Reference mxModel; + css::uno::Reference mxListener; + + void Initialize(); + }; } } // end of namespace svx::sidebar