[Libreoffice-commits] core.git: chart2/source

Markus Mohrhard markus.mohrhard at googlemail.com
Sat Oct 3 07:22:31 PDT 2015


 chart2/source/controller/sidebar/ChartElementsPanel.cxx |   64 +++++++++++++++-
 chart2/source/controller/sidebar/ChartElementsPanel.hxx |    2 
 2 files changed, 65 insertions(+), 1 deletion(-)

New commits:
commit d7748842e96536daeb0c638c6f8d01d99b9a3e08
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Sat Oct 3 16:21:06 2015 +0200

    hide grid and axes options in chart elements if not supported, tdf#94297
    
    Change-Id: I358340bd1b17f0e2eb5a119a60b623e489044dd3

diff --git a/chart2/source/controller/sidebar/ChartElementsPanel.cxx b/chart2/source/controller/sidebar/ChartElementsPanel.cxx
index 6f0d25f..b22570a 100644
--- a/chart2/source/controller/sidebar/ChartElementsPanel.cxx
+++ b/chart2/source/controller/sidebar/ChartElementsPanel.cxx
@@ -22,6 +22,8 @@
 #include <sfx2/sidebar/ControlFactory.hxx>
 #include <com/sun/star/chart2/LegendPosition.hpp>
 #include <com/sun/star/chart/ChartLegendExpansion.hpp>
+#include <com/sun/star/chart2/XChartTypeContainer.hpp>
+#include <com/sun/star/chart2/XCoordinateSystemContainer.hpp>
 
 #include "ChartElementsPanel.hxx"
 #include "ChartController.hxx"
@@ -40,6 +42,7 @@
 #include "ChartModelHelper.hxx"
 #include "AxisHelper.hxx"
 #include "DiagramHelper.hxx"
+#include "ChartTypeHelper.hxx"
 
 #include "ChartModel.hxx"
 
@@ -297,6 +300,9 @@ ChartElementsPanel::ChartElementsPanel(
     get(mpCBGridVerticalMinor,  "checkbutton_gridline_vertical_minor");
     get(mpCBGridHorizontalMinor,  "checkbutton_gridline_horizontal_minor");
 
+    get(mpLBAxis, "label_axes");
+    get(mpLBGrid, "label_gri");
+
     get(mpLBLegendPosition, "comboboxtext_legend");
     get(mpBoxLegend, "box_legend");
 
@@ -316,7 +322,6 @@ ChartElementsPanel::~ChartElementsPanel()
 
 void ChartElementsPanel::dispose()
 {
-
     css::uno::Reference<css::util::XModifyBroadcaster> xBroadcaster(mxModel, css::uno::UNO_QUERY_THROW);
     xBroadcaster->removeModifyListener(mxListener);
     mpCBTitle.clear();
@@ -340,6 +345,9 @@ void ChartElementsPanel::dispose()
     mpLBLegendPosition.clear();
     mpBoxLegend.clear();
 
+    mpLBAxis.clear();
+    mpLBGrid.clear();
+
     mpTextTitle.clear();
     mpTextSubTitle.clear();
 
@@ -374,6 +382,26 @@ void ChartElementsPanel::Initialize()
     mpLBLegendPosition->SetSelectHdl(LINK(this, ChartElementsPanel, LegendPosHdl));
 }
 
+namespace {
+
+css::uno::Reference<css::chart2::XChartType> getChartType(css::uno::Reference<css::frame::XModel> xModel)
+{
+    css::uno::Reference<css::chart2::XChartDocument> xChartDoc(xModel, css::uno::UNO_QUERY_THROW);
+    css::uno::Reference<chart2::XDiagram > xDiagram = xChartDoc->getFirstDiagram();
+
+    css::uno::Reference<css::chart2::XCoordinateSystemContainer > xCooSysContainer( xDiagram, css::uno::UNO_QUERY_THROW );
+
+    css::uno::Sequence<css::uno::Reference<css::chart2::XCoordinateSystem>> xCooSysSequence(xCooSysContainer->getCoordinateSystems());
+
+    css::uno::Reference<css::chart2::XChartTypeContainer> xChartTypeContainer(xCooSysSequence[0], css::uno::UNO_QUERY_THROW);
+
+    css::uno::Sequence<css::uno::Reference<css::chart2::XChartType>> xChartTypeSequence(xChartTypeContainer->getChartTypes());
+
+    return xChartTypeSequence[0];
+}
+
+}
+
 void ChartElementsPanel::updateData()
 {
     if (!mbModelValid)
@@ -401,6 +429,40 @@ void ChartElementsPanel::updateData()
     mpCB2ndXAxis->Check(isAxisVisible(mxModel, AxisType::X_SECOND));
     mpCB2ndYAxis->Check(isAxisVisible(mxModel, AxisType::Y_SECOND));
 
+
+    bool bSupportsMainAxis = ChartTypeHelper::isSupportingMainAxis(
+            getChartType(mxModel), 0, 0);
+    if (bSupportsMainAxis)
+    {
+        mpCBXAxis->Show();
+        mpCBYAxis->Show();
+        mpCBZAxis->Show();
+        mpCBXAxisTitle->Show();
+        mpCBYAxisTitle->Show();
+        mpCBZAxisTitle->Show();
+        mpCBGridVerticalMajor->Show();
+        mpCBGridVerticalMinor->Show();
+        mpCBGridHorizontalMajor->Show();
+        mpCBGridHorizontalMinor->Show();
+        mpLBAxis->Show();
+        mpLBGrid->Show();
+    }
+    else
+    {
+        mpCBXAxis->Hide();
+        mpCBYAxis->Hide();
+        mpCBZAxis->Hide();
+        mpCBXAxisTitle->Hide();
+        mpCBYAxisTitle->Hide();
+        mpCBZAxisTitle->Hide();
+        mpCBGridVerticalMajor->Hide();
+        mpCBGridVerticalMinor->Hide();
+        mpCBGridHorizontalMajor->Hide();
+        mpCBGridHorizontalMinor->Hide();
+        mpLBAxis->Hide();
+        mpLBGrid->Hide();
+    }
+
     if (nDimension == 3)
     {
         mpCBZAxis->Enable();
diff --git a/chart2/source/controller/sidebar/ChartElementsPanel.hxx b/chart2/source/controller/sidebar/ChartElementsPanel.hxx
index 39d78d9..952c64a 100644
--- a/chart2/source/controller/sidebar/ChartElementsPanel.hxx
+++ b/chart2/source/controller/sidebar/ChartElementsPanel.hxx
@@ -92,6 +92,8 @@ private:
     VclPtr<CheckBox> mpCBGridHorizontalMinor;
     VclPtr<FixedText> mpTextTitle;
     VclPtr<FixedText> mpTextSubTitle;
+    VclPtr<FixedText> mpLBAxis;
+    VclPtr<FixedText> mpLBGrid;
 
     VclPtr<ListBox> mpLBLegendPosition;
     VclPtr<VclHBox> mpBoxLegend;


More information about the Libreoffice-commits mailing list