[Libreoffice-commits] core.git: Branch 'feature/chart-sidebar' - 6 commits - chart2/source

Markus Mohrhard markus.mohrhard at googlemail.com
Wed Jul 15 12:32:15 PDT 2015


Rebased ref, commits from common ancestor:
commit 56a09babc97594bde29f32bc8ca101c554028dca
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Wed Jul 15 21:28:07 2015 +0200

    adapt code to last round of discussions
    
    Change-Id: Id0d2bae2a232f80ebe46cb55602c15c57b074e87

diff --git a/chart2/source/controller/sidebar/ChartElementsPanel.cxx b/chart2/source/controller/sidebar/ChartElementsPanel.cxx
index 5705f33..ae67a8d 100644
--- a/chart2/source/controller/sidebar/ChartElementsPanel.cxx
+++ b/chart2/source/controller/sidebar/ChartElementsPanel.cxx
@@ -271,8 +271,6 @@ ChartElementsPanel::ChartElementsPanel(
     get(mpCBLegend,  "checkbutton_legend");
     get(mpCBGridVertical,  "checkbutton_gridline_vertical");
     get(mpCBGridHorizontal,  "checkbutton_gridline_horizontal");
-    get(mpCBShowLabel,  "checkbutton_label");
-    get(mpCBTrendline,  "checkbutton_trendline");
 
     Initialize();
 }
@@ -302,8 +300,6 @@ void ChartElementsPanel::dispose()
     mpCBLegend.clear();
     mpCBGridVertical.clear();
     mpCBGridHorizontal.clear();
-    mpCBShowLabel.clear();
-    mpCBTrendline.clear();
 
     PanelLayout::dispose();
 }
diff --git a/chart2/source/controller/sidebar/ChartElementsPanel.hxx b/chart2/source/controller/sidebar/ChartElementsPanel.hxx
index dd68f79..316eb5d 100644
--- a/chart2/source/controller/sidebar/ChartElementsPanel.hxx
+++ b/chart2/source/controller/sidebar/ChartElementsPanel.hxx
@@ -87,8 +87,6 @@ private:
     VclPtr<CheckBox> mpCBLegend;
     VclPtr<CheckBox> mpCBGridVertical;
     VclPtr<CheckBox> mpCBGridHorizontal;
-    VclPtr<CheckBox> mpCBShowLabel;
-    VclPtr<CheckBox> mpCBTrendline;
 
     css::uno::Reference<css::frame::XFrame> mxFrame;
     ::sfx2::sidebar::EnumContext            maContext;
commit 3790ef5a3adfc67af8f593a2c505f90fb3e8c9ac
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Wed Jul 15 21:26:05 2015 +0200

    handle change to grid line checkboxes
    
    Change-Id: Ib39dc1669dfefe82eaefff1608de4fe1d4ef5832

diff --git a/chart2/source/controller/sidebar/ChartElementsPanel.cxx b/chart2/source/controller/sidebar/ChartElementsPanel.cxx
index 9d28ab2..5705f33 100644
--- a/chart2/source/controller/sidebar/ChartElementsPanel.cxx
+++ b/chart2/source/controller/sidebar/ChartElementsPanel.cxx
@@ -183,6 +183,26 @@ bool isGridVisible(css::uno::Reference<css::frame::XModel> xModel, GridType eTyp
     return false;
 }
 
+void setGridVisible(css::uno::Reference<css::frame::XModel> xModel, GridType eType, bool bVisible)
+{
+    Reference< chart2::XDiagram > xDiagram(ChartModelHelper::findDiagram(xModel));
+    if(xDiagram.is())
+    {
+        sal_Int32 nDimensionIndex = 0;
+        if (eType == GridType::HOR_MAJOR || eType == GridType::HOR_MINOR)
+            nDimensionIndex = 1;
+        sal_Int32 nCooSysIndex = 0;
+
+        bool bMajor = (eType == GridType::HOR_MAJOR || eType == GridType::VERT_MAJOR);
+
+        if (bVisible)
+            AxisHelper::showGrid(nDimensionIndex, nCooSysIndex, bMajor,
+                    xDiagram, comphelper::getProcessComponentContext());
+        else
+            AxisHelper::hideGrid(nDimensionIndex, nCooSysIndex, bMajor, xDiagram);
+    }
+}
+
 bool isAxisVisible(css::uno::Reference<css::frame::XModel> xModel, AxisType eType)
 {
     Reference< chart2::XDiagram > xDiagram(ChartModelHelper::findDiagram(xModel));
@@ -423,6 +443,10 @@ IMPL_LINK(ChartElementsPanel, CheckBoxHdl, CheckBox*, pCheckBox)
         setTitleVisible(mxModel, TitleHelper::SECONDARY_Y_AXIS_TITLE, bChecked);
     else if (pCheckBox == mpCBLegend.get())
         setLegendVisible(mxModel, bChecked);
+    else if (pCheckBox == mpCBGridVertical.get())
+        setGridVisible(mxModel, GridType::VERT_MAJOR, bChecked);
+    else if (pCheckBox == mpCBGridHorizontal.get())
+        setGridVisible(mxModel, GridType::HOR_MAJOR, bChecked);
 
     return 0;
 }
commit d6dbb3813909e418b103bd40c4ec452481e61575
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Wed Jul 15 21:15:15 2015 +0200

    handle changes to legend checkbox
    
    Change-Id: I3901ce4f7664eb7b8eca50014f5916fd6ccb0854

diff --git a/chart2/source/controller/sidebar/ChartElementsPanel.cxx b/chart2/source/controller/sidebar/ChartElementsPanel.cxx
index 23fdfaf..9d28ab2 100644
--- a/chart2/source/controller/sidebar/ChartElementsPanel.cxx
+++ b/chart2/source/controller/sidebar/ChartElementsPanel.cxx
@@ -136,6 +136,18 @@ bool isLegendVisible(css::uno::Reference<css::frame::XModel> xModel)
     return false;
 }
 
+void setLegendVisible(css::uno::Reference<css::frame::XModel> xModel, bool bVisible)
+{
+    ChartModel* pModel = getChartModel(xModel);
+    if (!pModel)
+        return;
+
+    if (bVisible)
+        LegendHelper::showLegend(*pModel, comphelper::getProcessComponentContext());
+    else
+        LegendHelper::hideLegend(*pModel);
+}
+
 bool isTitleVisisble(css::uno::Reference<css::frame::XModel> xModel, TitleHelper::eTitleType eTitle)
 {
     return TitleHelper::getTitle(eTitle, xModel).is();
@@ -409,6 +421,8 @@ IMPL_LINK(ChartElementsPanel, CheckBoxHdl, CheckBox*, pCheckBox)
         setAxisVisible(mxModel, AxisType::Y_SECOND, bChecked);
     else if (pCheckBox == mpCB2ndYAxisTitle.get())
         setTitleVisible(mxModel, TitleHelper::SECONDARY_Y_AXIS_TITLE, bChecked);
+    else if (pCheckBox == mpCBLegend.get())
+        setLegendVisible(mxModel, bChecked);
 
     return 0;
 }
commit 11ce839791e72060496075416188ce34fc25c3eb
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Wed Jul 15 18:34:37 2015 +0200

    also react to title checkboxes
    
    This needs to improved when tdf#92768 has been implemented. Also we need
    to rethink the default strings.
    
    Change-Id: I74b9bdf0caeaf314f103aa7b13dad3215e828423

diff --git a/chart2/source/controller/sidebar/ChartElementsPanel.cxx b/chart2/source/controller/sidebar/ChartElementsPanel.cxx
index f232918..23fdfaf 100644
--- a/chart2/source/controller/sidebar/ChartElementsPanel.cxx
+++ b/chart2/source/controller/sidebar/ChartElementsPanel.cxx
@@ -141,6 +141,18 @@ bool isTitleVisisble(css::uno::Reference<css::frame::XModel> xModel, TitleHelper
     return TitleHelper::getTitle(eTitle, xModel).is();
 }
 
+void setTitleVisible(css::uno::Reference<css::frame::XModel> xModel, TitleHelper::eTitleType eTitle, bool bVisible)
+{
+    if (bVisible)
+    {
+        TitleHelper::createTitle(eTitle, "Title", xModel, comphelper::getProcessComponentContext());
+    }
+    else
+    {
+        TitleHelper::removeTitle(eTitle, xModel);
+    }
+}
+
 bool isGridVisible(css::uno::Reference<css::frame::XModel> xModel, GridType eType)
 {
     Reference< chart2::XDiagram > xDiagram(ChartModelHelper::findDiagram(xModel));
@@ -374,16 +386,29 @@ IMPL_LINK(ChartElementsPanel, CheckBoxHdl, CheckBox*, pCheckBox)
 {
     bool bChecked = pCheckBox->IsChecked();
     if (pCheckBox == mpCBTitle.get())
-    {
-    }
+        setTitleVisible(mxModel, TitleHelper::MAIN_TITLE, bChecked);
+    else if (pCheckBox == mpCBSubtitle.get())
+        setTitleVisible(mxModel, TitleHelper::SUB_TITLE, bChecked);
     else if (pCheckBox == mpCBXAxis.get())
         setAxisVisible(mxModel, AxisType::X_MAIN, bChecked);
+    else if (pCheckBox == mpCBXAxisTitle.get())
+        setTitleVisible(mxModel, TitleHelper::X_AXIS_TITLE, bChecked);
     else if (pCheckBox == mpCBYAxis.get())
         setAxisVisible(mxModel, AxisType::Y_MAIN, bChecked);
+    else if (pCheckBox == mpCBYAxisTitle.get())
+        setTitleVisible(mxModel, TitleHelper::Y_AXIS_TITLE, bChecked);
+    else if (pCheckBox == mpCBZAxis.get())
+        setAxisVisible(mxModel, AxisType::Z_MAIN, bChecked);
+    else if (pCheckBox == mpCBZAxisTitle.get())
+        setTitleVisible(mxModel, TitleHelper::Z_AXIS_TITLE, bChecked);
     else if (pCheckBox == mpCB2ndXAxis.get())
         setAxisVisible(mxModel, AxisType::X_SECOND, bChecked);
+    else if (pCheckBox == mpCB2ndXAxisTitle.get())
+        setTitleVisible(mxModel, TitleHelper::SECONDARY_X_AXIS_TITLE, bChecked);
     else if (pCheckBox == mpCB2ndYAxis.get())
         setAxisVisible(mxModel, AxisType::Y_SECOND, bChecked);
+    else if (pCheckBox == mpCB2ndYAxisTitle.get())
+        setTitleVisible(mxModel, TitleHelper::SECONDARY_Y_AXIS_TITLE, bChecked);
 
     return 0;
 }
commit 4a4076ba90b1d4b95e9389b2028d2b6adb5f18f6
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Wed Jul 15 18:07:52 2015 +0200

    disable Z axis boxes for non-3D charts
    
    Change-Id: I0a651dbed939be572e06e3389fa024cafc214854

diff --git a/chart2/source/controller/sidebar/ChartElementsPanel.cxx b/chart2/source/controller/sidebar/ChartElementsPanel.cxx
index d73ffaa5..f232918 100644
--- a/chart2/source/controller/sidebar/ChartElementsPanel.cxx
+++ b/chart2/source/controller/sidebar/ChartElementsPanel.cxx
@@ -37,6 +37,7 @@
 #include "TitleHelper.hxx"
 #include "ChartModelHelper.hxx"
 #include "AxisHelper.hxx"
+#include "DiagramHelper.hxx"
 
 #include "ChartModel.hxx"
 
@@ -289,6 +290,8 @@ void ChartElementsPanel::Initialize()
 
 void ChartElementsPanel::updateData()
 {
+    Reference< chart2::XDiagram > xDiagram(ChartModelHelper::findDiagram(mxModel));
+    sal_Int32 nDimension = DiagramHelper::getDimension(xDiagram);
     SolarMutexGuard aGuard;
 
     mpCBLegend->Check(isLegendVisible(mxModel));
@@ -306,6 +309,12 @@ void ChartElementsPanel::updateData()
     mpCBZAxis->Check(isAxisVisible(mxModel, AxisType::Z_MAIN));
     mpCB2ndXAxis->Check(isAxisVisible(mxModel, AxisType::X_SECOND));
     mpCB2ndYAxis->Check(isAxisVisible(mxModel, AxisType::Y_SECOND));
+
+    if (nDimension != 3)
+    {
+        mpCBZAxis->Disable();
+        mpCBZAxisTitle->Disable();
+    }
 }
 
 VclPtr<vcl::Window> ChartElementsPanel::Create (
commit 9aab317e8df7b01e66624601d6c22dc2b8bfbdaa
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Wed Jul 15 17:44:56 2015 +0200

    react to changing the checkboxes: axis
    
    Change-Id: Ic1296b9035dce00837b8e8d24cc63e1d9bda0b88

diff --git a/chart2/source/controller/sidebar/ChartElementsPanel.cxx b/chart2/source/controller/sidebar/ChartElementsPanel.cxx
index 11039e8..d73ffaa5 100644
--- a/chart2/source/controller/sidebar/ChartElementsPanel.cxx
+++ b/chart2/source/controller/sidebar/ChartElementsPanel.cxx
@@ -31,6 +31,7 @@
 #include <vcl/toolbox.hxx>
 #include <svl/intitem.hxx>
 #include <svl/stritem.hxx>
+#include <comphelper/processfactory.hxx>
 
 #include "LegendHelper.hxx"
 #include "TitleHelper.hxx"
@@ -174,7 +175,26 @@ bool isAxisVisible(css::uno::Reference<css::frame::XModel> xModel, AxisType eTyp
         return bHasAxis;
     }
     return false;
+}
+
+void setAxisVisible(css::uno::Reference<css::frame::XModel> xModel, AxisType eType, bool bVisible)
+{
+    Reference< chart2::XDiagram > xDiagram(ChartModelHelper::findDiagram(xModel));
+    if(xDiagram.is())
+    {
+        sal_Int32 nDimensionIndex = 0;
+        if (eType == AxisType::Y_MAIN || eType == AxisType::Y_SECOND)
+            nDimensionIndex = 1;
+        else if (eType == AxisType::Z_MAIN)
+            nDimensionIndex = 2;
+
+        bool bMajor = !(eType == AxisType::X_SECOND || eType == AxisType::Y_SECOND);
 
+        if (bVisible)
+            AxisHelper::showAxis(nDimensionIndex, bMajor, xDiagram, comphelper::getProcessComponentContext());
+        else
+            AxisHelper::hideAxis(nDimensionIndex, bMajor, xDiagram);
+    }
 }
 
 }
@@ -248,6 +268,23 @@ void ChartElementsPanel::Initialize()
     css::uno::Reference<css::util::XModifyBroadcaster> xBroadcaster(mxModel, css::uno::UNO_QUERY_THROW);
     xBroadcaster->addModifyListener(mxListener);
     updateData();
+
+    Link<> aLink = LINK(this, ChartElementsPanel, CheckBoxHdl);
+    mpCBTitle->SetClickHdl(aLink);
+    mpCBSubtitle->SetClickHdl(aLink);
+    mpCBXAxis->SetClickHdl(aLink);
+    mpCBXAxisTitle->SetClickHdl(aLink);
+    mpCBYAxis->SetClickHdl(aLink);
+    mpCBYAxisTitle->SetClickHdl(aLink);
+    mpCBZAxis->SetClickHdl(aLink);
+    mpCBZAxisTitle->SetClickHdl(aLink);
+    mpCB2ndXAxis->SetClickHdl(aLink);
+    mpCB2ndXAxisTitle->SetClickHdl(aLink);
+    mpCB2ndYAxis->SetClickHdl(aLink);
+    mpCB2ndYAxisTitle->SetClickHdl(aLink);
+    mpCBLegend->SetClickHdl(aLink);
+    mpCBGridVertical->SetClickHdl(aLink);
+    mpCBGridHorizontal->SetClickHdl(aLink);
 }
 
 void ChartElementsPanel::updateData()
@@ -324,6 +361,24 @@ void ChartElementsPanel::modelInvalid()
 
 }
 
+IMPL_LINK(ChartElementsPanel, CheckBoxHdl, CheckBox*, pCheckBox)
+{
+    bool bChecked = pCheckBox->IsChecked();
+    if (pCheckBox == mpCBTitle.get())
+    {
+    }
+    else if (pCheckBox == mpCBXAxis.get())
+        setAxisVisible(mxModel, AxisType::X_MAIN, bChecked);
+    else if (pCheckBox == mpCBYAxis.get())
+        setAxisVisible(mxModel, AxisType::Y_MAIN, bChecked);
+    else if (pCheckBox == mpCB2ndXAxis.get())
+        setAxisVisible(mxModel, AxisType::X_SECOND, bChecked);
+    else if (pCheckBox == mpCB2ndYAxis.get())
+        setAxisVisible(mxModel, AxisType::Y_SECOND, bChecked);
+
+    return 0;
+}
+
 }} // end of namespace ::chart::sidebar
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/controller/sidebar/ChartElementsPanel.hxx b/chart2/source/controller/sidebar/ChartElementsPanel.hxx
index 297f157..dd68f79 100644
--- a/chart2/source/controller/sidebar/ChartElementsPanel.hxx
+++ b/chart2/source/controller/sidebar/ChartElementsPanel.hxx
@@ -98,6 +98,8 @@ private:
     css::uno::Reference<css::util::XModifyListener> mxListener;
 
     void Initialize();
+
+    DECL_LINK(CheckBoxHdl, CheckBox*);
 };
 
 } } // end of namespace ::chart::sidebar


More information about the Libreoffice-commits mailing list