2015-07-20 23:46:27 +02:00
|
|
|
/* -*- 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 "ChartAreaPanel.hxx"
|
|
|
|
|
|
|
|
#include "ChartController.hxx"
|
|
|
|
|
2015-07-23 00:44:48 +02:00
|
|
|
#include <svx/xfltrit.hxx>
|
|
|
|
#include <svx/xflftrit.hxx>
|
|
|
|
|
2015-07-20 23:46:27 +02:00
|
|
|
namespace chart { namespace sidebar {
|
|
|
|
|
2015-07-21 15:03:48 +02:00
|
|
|
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();
|
2015-07-21 19:01:06 +02:00
|
|
|
if (!aAny.hasValue())
|
|
|
|
return OUString();
|
|
|
|
|
2015-07-21 15:03:48 +02:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2015-07-24 00:52:42 +02:00
|
|
|
class PreventUpdate
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
PreventUpdate(bool& bUpdate):
|
|
|
|
mbUpdate(bUpdate)
|
|
|
|
{
|
|
|
|
mbUpdate = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
~PreventUpdate()
|
|
|
|
{
|
|
|
|
mbUpdate = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
bool& mbUpdate;
|
|
|
|
};
|
|
|
|
|
2015-07-21 15:03:48 +02:00
|
|
|
}
|
|
|
|
|
2015-07-20 23:46:27 +02:00
|
|
|
VclPtr<vcl::Window> ChartAreaPanel::Create(
|
|
|
|
vcl::Window* pParent,
|
|
|
|
const css::uno::Reference<css::frame::XFrame>& rxFrame,
|
|
|
|
ChartController* pController)
|
|
|
|
{
|
|
|
|
if (pParent == NULL)
|
|
|
|
throw css::lang::IllegalArgumentException("no parent Window given to ChartAxisPanel::Create", NULL, 0);
|
|
|
|
if (!rxFrame.is())
|
|
|
|
throw css::lang::IllegalArgumentException("no XFrame given to ChartAxisPanel::Create", NULL, 1);
|
|
|
|
|
|
|
|
return VclPtr<ChartAreaPanel>::Create(
|
|
|
|
pParent, rxFrame, pController);
|
|
|
|
}
|
|
|
|
|
|
|
|
ChartAreaPanel::ChartAreaPanel(vcl::Window* pParent,
|
|
|
|
const css::uno::Reference<css::frame::XFrame>& rxFrame,
|
2015-07-21 15:03:48 +02:00
|
|
|
ChartController* pController):
|
|
|
|
svx::sidebar::AreaPropertyPanelBase(pParent, rxFrame),
|
|
|
|
mxModel(pController->getModel()),
|
2015-07-23 16:47:49 +02:00
|
|
|
mxListener(new ChartSidebarModifyListener(this)),
|
2015-07-24 00:52:42 +02:00
|
|
|
mxSelectionListener(new ChartSidebarSelectionListener(this)),
|
|
|
|
mbUpdate(true)
|
2015-07-20 23:46:27 +02:00
|
|
|
{
|
2015-07-23 21:00:37 +02:00
|
|
|
Initialize();
|
2015-07-20 23:46:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
ChartAreaPanel::~ChartAreaPanel()
|
|
|
|
{
|
|
|
|
disposeOnce();
|
|
|
|
}
|
|
|
|
|
2015-07-21 15:03:48 +02:00
|
|
|
void ChartAreaPanel::dispose()
|
2015-07-20 23:46:27 +02:00
|
|
|
{
|
2015-07-21 15:03:48 +02:00
|
|
|
css::uno::Reference<css::util::XModifyBroadcaster> xBroadcaster(mxModel, css::uno::UNO_QUERY_THROW);
|
|
|
|
xBroadcaster->removeModifyListener(mxListener);
|
2015-07-21 19:00:37 +02:00
|
|
|
|
2015-07-23 16:47:49 +02:00
|
|
|
css::uno::Reference<css::view::XSelectionSupplier> xSelectionSupplier(mxModel->getCurrentController(), css::uno::UNO_QUERY);
|
|
|
|
if (xSelectionSupplier.is())
|
|
|
|
xSelectionSupplier->removeSelectionChangeListener(mxSelectionListener);
|
|
|
|
|
2015-07-21 19:00:37 +02:00
|
|
|
AreaPropertyPanelBase::dispose();
|
2015-07-21 15:03:48 +02:00
|
|
|
}
|
2015-07-20 23:46:27 +02:00
|
|
|
|
2015-07-21 15:03:48 +02:00
|
|
|
void ChartAreaPanel::Initialize()
|
|
|
|
{
|
|
|
|
css::uno::Reference<css::util::XModifyBroadcaster> xBroadcaster(mxModel, css::uno::UNO_QUERY_THROW);
|
|
|
|
xBroadcaster->addModifyListener(mxListener);
|
2015-07-23 16:47:49 +02:00
|
|
|
|
|
|
|
css::uno::Reference<css::view::XSelectionSupplier> xSelectionSupplier(mxModel->getCurrentController(), css::uno::UNO_QUERY);
|
|
|
|
if (xSelectionSupplier.is())
|
|
|
|
xSelectionSupplier->addSelectionChangeListener(mxSelectionListener);
|
2015-07-20 23:46:27 +02:00
|
|
|
}
|
|
|
|
|
2015-07-23 00:44:48 +02:00
|
|
|
void ChartAreaPanel::setFillTransparence(const XFillTransparenceItem& rItem)
|
2015-07-20 23:46:27 +02:00
|
|
|
{
|
2015-07-24 00:52:42 +02:00
|
|
|
PreventUpdate aProtector(mbUpdate);
|
2015-07-23 00:44:48 +02:00
|
|
|
css::uno::Reference<css::beans::XPropertySet> xPropSet = getPropSet(mxModel);
|
|
|
|
if (!xPropSet.is())
|
|
|
|
return;
|
2015-07-20 23:46:27 +02:00
|
|
|
|
2015-07-23 00:44:48 +02:00
|
|
|
xPropSet->setPropertyValue("Transparency", css::uno::makeAny(rItem.GetValue()));
|
2015-07-20 23:46:27 +02:00
|
|
|
}
|
|
|
|
|
2015-07-23 00:44:48 +02:00
|
|
|
void ChartAreaPanel::setFillFloatTransparence(
|
|
|
|
const XFillFloatTransparenceItem& rItem)
|
2015-07-20 23:46:27 +02:00
|
|
|
{
|
2015-07-24 00:52:42 +02:00
|
|
|
PreventUpdate aProtector(mbUpdate);
|
2015-07-23 00:44:48 +02:00
|
|
|
css::uno::Reference<css::beans::XPropertySet> xPropSet = getPropSet(mxModel);
|
|
|
|
if (!xPropSet.is())
|
|
|
|
return;
|
2015-07-20 23:46:27 +02:00
|
|
|
|
2015-07-23 00:44:48 +02:00
|
|
|
xPropSet->setPropertyValue("TransparencyGradientName", css::uno::makeAny(rItem.GetValue()));
|
2015-07-20 23:46:27 +02:00
|
|
|
}
|
|
|
|
|
2015-07-21 15:03:48 +02:00
|
|
|
void ChartAreaPanel::setFillStyle(const XFillStyleItem& rItem)
|
2015-07-20 23:46:27 +02:00
|
|
|
{
|
2015-07-24 00:52:42 +02:00
|
|
|
PreventUpdate aProtector(mbUpdate);
|
2015-07-21 15:03:48 +02:00
|
|
|
css::uno::Reference<css::beans::XPropertySet> xPropSet = getPropSet(mxModel);
|
2015-07-21 19:01:06 +02:00
|
|
|
if (!xPropSet.is())
|
|
|
|
return;
|
|
|
|
|
2015-07-21 15:03:48 +02:00
|
|
|
xPropSet->setPropertyValue("FillStyle", css::uno::makeAny(rItem.GetValue()));
|
2015-07-20 23:46:27 +02:00
|
|
|
}
|
|
|
|
|
2015-07-21 15:03:48 +02:00
|
|
|
void ChartAreaPanel::setFillStyleAndColor(const XFillStyleItem* pStyleItem,
|
|
|
|
const XFillColorItem& rColorItem)
|
2015-07-20 23:46:27 +02:00
|
|
|
{
|
2015-07-21 15:03:48 +02:00
|
|
|
css::uno::Reference<css::beans::XPropertySet> xPropSet = getPropSet(mxModel);
|
2015-07-21 19:01:06 +02:00
|
|
|
if (!xPropSet.is())
|
|
|
|
return;
|
|
|
|
|
2015-07-21 15:03:48 +02:00
|
|
|
if (pStyleItem)
|
|
|
|
xPropSet->setPropertyValue("FillStyle", css::uno::makeAny(pStyleItem->GetValue()));
|
|
|
|
xPropSet->setPropertyValue("Color", css::uno::makeAny(rColorItem.GetValue()));
|
|
|
|
}
|
2015-07-20 23:46:27 +02:00
|
|
|
|
2015-07-21 15:03:48 +02:00
|
|
|
void ChartAreaPanel::setFillStyleAndGradient(const XFillStyleItem* pStyleItem,
|
|
|
|
const XFillGradientItem& rGradientItem)
|
|
|
|
{
|
2015-07-24 00:52:42 +02:00
|
|
|
PreventUpdate aProtector(mbUpdate);
|
2015-07-21 15:03:48 +02:00
|
|
|
css::uno::Reference<css::beans::XPropertySet> xPropSet = getPropSet(mxModel);
|
2015-07-21 19:01:06 +02:00
|
|
|
if (!xPropSet.is())
|
|
|
|
return;
|
|
|
|
|
2015-07-21 15:03:48 +02:00
|
|
|
if (pStyleItem)
|
|
|
|
xPropSet->setPropertyValue("FillStyle", css::uno::makeAny(pStyleItem->GetValue()));
|
|
|
|
xPropSet->setPropertyValue("GradientName", css::uno::makeAny(rGradientItem.GetValue()));
|
2015-07-20 23:46:27 +02:00
|
|
|
}
|
|
|
|
|
2015-07-21 15:03:48 +02:00
|
|
|
void ChartAreaPanel::setFillStyleAndHatch(const XFillStyleItem* pStyleItem,
|
|
|
|
const XFillHatchItem& rHatchItem)
|
2015-07-20 23:46:27 +02:00
|
|
|
{
|
2015-07-24 00:52:42 +02:00
|
|
|
PreventUpdate aProtector(mbUpdate);
|
2015-07-21 15:03:48 +02:00
|
|
|
css::uno::Reference<css::beans::XPropertySet> xPropSet = getPropSet(mxModel);
|
2015-07-21 19:01:06 +02:00
|
|
|
if (!xPropSet.is())
|
|
|
|
return;
|
|
|
|
|
2015-07-21 15:03:48 +02:00
|
|
|
if (pStyleItem)
|
|
|
|
xPropSet->setPropertyValue("FillStyle", css::uno::makeAny(pStyleItem->GetValue()));
|
|
|
|
xPropSet->setPropertyValue("HatchName", css::uno::makeAny(rHatchItem.GetValue()));
|
|
|
|
}
|
2015-07-20 23:46:27 +02:00
|
|
|
|
2015-07-21 15:03:48 +02:00
|
|
|
void ChartAreaPanel::setFillStyleAndBitmap(const XFillStyleItem* pStyleItem,
|
|
|
|
const XFillBitmapItem& rBitmapItem)
|
|
|
|
{
|
2015-07-24 00:52:42 +02:00
|
|
|
PreventUpdate aProtector(mbUpdate);
|
2015-07-21 15:03:48 +02:00
|
|
|
css::uno::Reference<css::beans::XPropertySet> xPropSet = getPropSet(mxModel);
|
2015-07-21 19:01:06 +02:00
|
|
|
if (!xPropSet.is())
|
|
|
|
return;
|
|
|
|
|
2015-07-21 15:03:48 +02:00
|
|
|
if (pStyleItem)
|
|
|
|
xPropSet->setPropertyValue("FillStyle", css::uno::makeAny(pStyleItem->GetValue()));
|
|
|
|
xPropSet->setPropertyValue("FillBitmapName", css::uno::makeAny(rBitmapItem.GetValue()));
|
2015-07-20 23:46:27 +02:00
|
|
|
}
|
|
|
|
|
2015-07-21 15:03:48 +02:00
|
|
|
void ChartAreaPanel::updateData()
|
2015-07-20 23:46:27 +02:00
|
|
|
{
|
2015-07-24 00:52:42 +02:00
|
|
|
if (!mbUpdate)
|
|
|
|
return;
|
|
|
|
|
2015-07-23 21:00:37 +02:00
|
|
|
css::uno::Reference<css::beans::XPropertySet> xPropSet = getPropSet(mxModel);
|
|
|
|
if (!xPropSet.is())
|
|
|
|
return;
|
|
|
|
|
|
|
|
css::drawing::FillStyle eFillStyle = css::drawing::FillStyle_SOLID;
|
|
|
|
xPropSet->getPropertyValue("FillStyle") >>= eFillStyle;
|
|
|
|
XFillStyleItem aFillStyleItem(eFillStyle);
|
|
|
|
updateFillStyle(false, true, &aFillStyleItem);
|
|
|
|
|
|
|
|
sal_uInt16 nFillTransparence = 0;
|
|
|
|
xPropSet->getPropertyValue("Transparency") >>= nFillTransparence;
|
|
|
|
SfxUInt16Item aTransparenceItem(0, nFillTransparence);
|
|
|
|
updateFillTransparence(false, true, &aTransparenceItem);
|
2015-07-21 15:03:48 +02:00
|
|
|
}
|
2015-07-20 23:46:27 +02:00
|
|
|
|
2015-07-21 15:03:48 +02:00
|
|
|
void ChartAreaPanel::modelInvalid()
|
|
|
|
{
|
2015-07-20 23:46:27 +02:00
|
|
|
}
|
|
|
|
|
2015-07-23 16:47:49 +02:00
|
|
|
void ChartAreaPanel::selectionChanged(bool bCorrectType)
|
|
|
|
{
|
|
|
|
if (bCorrectType)
|
|
|
|
updateData();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ChartAreaPanel::SelectionInvalid()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2015-07-23 01:20:45 +02:00
|
|
|
void ChartAreaPanel::updateModel(
|
|
|
|
css::uno::Reference<css::frame::XModel> xModel)
|
|
|
|
{
|
|
|
|
css::uno::Reference<css::util::XModifyBroadcaster> xBroadcaster(mxModel, css::uno::UNO_QUERY_THROW);
|
|
|
|
xBroadcaster->removeModifyListener(mxListener);
|
|
|
|
|
|
|
|
mxModel = xModel;
|
|
|
|
|
|
|
|
css::uno::Reference<css::util::XModifyBroadcaster> xBroadcasterNew(mxModel, css::uno::UNO_QUERY_THROW);
|
|
|
|
xBroadcasterNew->addModifyListener(mxListener);
|
2015-07-23 16:47:49 +02:00
|
|
|
|
|
|
|
css::uno::Reference<css::view::XSelectionSupplier> xSelectionSupplier(mxModel->getCurrentController(), css::uno::UNO_QUERY);
|
|
|
|
if (xSelectionSupplier.is())
|
|
|
|
xSelectionSupplier->addSelectionChangeListener(mxSelectionListener);
|
2015-07-23 01:20:45 +02:00
|
|
|
}
|
|
|
|
|
2015-07-20 23:46:27 +02:00
|
|
|
|
|
|
|
} }
|
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|