From 71c6ee42d3311b31896e5a408d8f83f4e5d7726e Mon Sep 17 00:00:00 2001 From: Markus Mohrhard Date: Thu, 16 Jul 2015 20:17:37 +0200 Subject: first parts in data series panel Change-Id: Ia25460e6f57ff6d3c44bae1ddb33a36845ffcdd2 --- .../source/controller/sidebar/ChartSeriesPanel.cxx | 80 ++++++++++++++++++++++ .../source/controller/sidebar/ChartSeriesPanel.hxx | 6 ++ 2 files changed, 86 insertions(+) (limited to 'chart2') diff --git a/chart2/source/controller/sidebar/ChartSeriesPanel.cxx b/chart2/source/controller/sidebar/ChartSeriesPanel.cxx index 732aefc9c014..1d214254cdf9 100644 --- a/chart2/source/controller/sidebar/ChartSeriesPanel.cxx +++ b/chart2/source/controller/sidebar/ChartSeriesPanel.cxx @@ -21,6 +21,8 @@ #include #include +#include + #include "ChartSeriesPanel.hxx" #include "ChartController.hxx" #include @@ -35,6 +37,7 @@ #include #include "ChartModel.hxx" +#include "DataSeriesHelper.hxx" using namespace css; using namespace css::uno; @@ -42,6 +45,35 @@ using ::sfx2::sidebar::Theme; namespace chart { namespace sidebar { +namespace { + +bool isDataLabelVisible(css::uno::Reference xModel, const OUString& rCID) +{ + css::uno::Reference< css::chart2::XDataSeries > xSeries( + ObjectIdentifier::getDataSeriesForCID(rCID, xModel), uno::UNO_QUERY ); + + if (!xSeries.is()) + return false; + + return DataSeriesHelper::hasDataLabelsAtSeries(xSeries); +} + +void setDataLabelVisible(css::uno::Reference xModel, const OUString& rCID, bool bVisible) +{ + css::uno::Reference< css::chart2::XDataSeries > xSeries( + ObjectIdentifier::getDataSeriesForCID(rCID, xModel), uno::UNO_QUERY ); + + if (!xSeries.is()) + return; + + if (bVisible) + DataSeriesHelper::insertDataLabelsToSeriesAndAllPoints(xSeries); + else + DataSeriesHelper::deleteDataLabelsFromSeriesAndAllPoints(xSeries); +} + +} + ChartSeriesPanel::ChartSeriesPanel( vcl::Window* pParent, const css::uno::Reference& rxFrame, @@ -53,6 +85,11 @@ ChartSeriesPanel::ChartSeriesPanel( mpBindings(pBindings), mxModel(pController->getModel()) { + get(mpCBLabel, "checkbutton_label"); + get(mpCBTrendline, "checkbutton_trendline"); + get(mpCBXError, "checkbutton_x_error"); + get(mpCBYError, "checkbutton_y_error"); + Initialize(); } @@ -69,11 +106,32 @@ void ChartSeriesPanel::dispose() void ChartSeriesPanel::Initialize() { + updateData(); + + Link<> aLink = LINK(this, ChartSeriesPanel, CheckBoxHdl); + mpCBLabel->SetClickHdl(aLink); + mpCBTrendline->SetClickHdl(aLink); + mpCBXError->SetClickHdl(aLink); + mpCBYError->SetClickHdl(aLink); } void ChartSeriesPanel::updateData() { + css::uno::Reference xController(mxModel->getCurrentController()); + css::uno::Reference xSelectionSupplier(xController, css::uno::UNO_QUERY); + if (!xSelectionSupplier.is()) + return; + + uno::Any aAny = xSelectionSupplier->getSelection(); + assert(aAny.hasValue()); + OUString aCID; + aAny >>= aCID; +#ifdef DBG_UTIL + ObjectType eType = ObjectIdentifier::getObjectType(aCID); + assert(eType == OBJECTTYPE_DATA_SERIES); +#endif SolarMutexGuard aGuard; + mpCBLabel->Check(isDataLabelVisible(mxModel, aCID)); } VclPtr ChartSeriesPanel::Create ( @@ -124,6 +182,28 @@ void ChartSeriesPanel::modelInvalid() } +IMPL_LINK(ChartSeriesPanel, CheckBoxHdl, CheckBox*, pCheckBox) +{ + bool bChecked = pCheckBox->IsChecked(); + css::uno::Reference xController(mxModel->getCurrentController()); + css::uno::Reference xSelectionSupplier(xController, css::uno::UNO_QUERY); + if (!xSelectionSupplier.is()) + return 0; + + uno::Any aAny = xSelectionSupplier->getSelection(); + assert(aAny.hasValue()); + OUString aCID; + aAny >>= aCID; +#ifdef DBG_UTIL + ObjectType eType = ObjectIdentifier::getObjectType(aCID); + assert(eType == OBJECTTYPE_DATA_SERIES); +#endif + if (pCheckBox == mpCBLabel.get()) + setDataLabelVisible(mxModel, aCID, bChecked); + + return 0; +} + }} // end of namespace ::chart::sidebar /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/controller/sidebar/ChartSeriesPanel.hxx b/chart2/source/controller/sidebar/ChartSeriesPanel.hxx index 6fa61e351a76..f38aa9e53a4d 100644 --- a/chart2/source/controller/sidebar/ChartSeriesPanel.hxx +++ b/chart2/source/controller/sidebar/ChartSeriesPanel.hxx @@ -72,6 +72,10 @@ public: private: //ui controls + VclPtr mpCBLabel; + VclPtr mpCBTrendline; + VclPtr mpCBXError; + VclPtr mpCBYError; css::uno::Reference mxFrame; ::sfx2::sidebar::EnumContext maContext; @@ -81,6 +85,8 @@ private: css::uno::Reference mxListener; void Initialize(); + + DECL_LINK(CheckBoxHdl, CheckBox*); }; } } // end of namespace ::chart::sidebar -- cgit