handle some of the property changes correctly in area panel

Change-Id: I107245f52504c6dc059554346e00402534cf6243
This commit is contained in:
Markus Mohrhard
2015-07-21 15:03:48 +02:00
parent 3d32e9f81b
commit ab0c81c097
2 changed files with 91 additions and 16 deletions

View File

@@ -13,6 +13,32 @@
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();
assert(aAny.hasValue());
OUString aCID;
aAny >>= aCID;
return aCID;
}
css::uno::Reference<css::beans::XPropertySet> getPropSet(
css::uno::Reference<css::frame::XModel> xModel)
{
OUString aCID = getCID(xModel);
return ObjectIdentifier::getObjectPropertySet(aCID, xModel);
}
}
VclPtr<vcl::Window> ChartAreaPanel::Create(
vcl::Window* pParent,
const css::uno::Reference<css::frame::XFrame>& rxFrame,
@@ -29,8 +55,10 @@ VclPtr<vcl::Window> ChartAreaPanel::Create(
ChartAreaPanel::ChartAreaPanel(vcl::Window* pParent,
const css::uno::Reference<css::frame::XFrame>& 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<css::util::XModifyBroadcaster> xBroadcaster(mxModel, css::uno::UNO_QUERY_THROW);
xBroadcaster->removeModifyListener(mxListener);
}
void ChartAreaPanel::Initialize()
{
css::uno::Reference<css::util::XModifyBroadcaster> 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<css::beans::XPropertySet> 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<css::beans::XPropertySet> 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<css::beans::XPropertySet> 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<css::beans::XPropertySet> 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<css::beans::XPropertySet> 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()
{
}

View File

@@ -27,6 +27,8 @@
#include <svx/sidebar/AreaPropertyPanelBase.hxx>
#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<vcl::Window> 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<css::frame::XModel> mxModel;
css::uno::Reference<css::util::XModifyListener> mxListener;
void Initialize();
};
} } // end of namespace svx::sidebar