Rebased ref, commits from common ancestor:
commit 4e005b051c361ab27064a3905710d944810cdc44
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Fri Jul 1 22:00:38 2022 +0200
Commit:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
CommitDate: Fri Jul 1 22:26:38 2022 +0200

    chart2: InsertDataTableDialog for inserting/removing the data table
    
    Change-Id: Ie3c033c587b150723e7aa39cd5ddf5774104db9a

diff --git a/chart2/Library_chartcontroller.mk 
b/chart2/Library_chartcontroller.mk
index 4bc8c7497915..cc25cdd907ae 100644
--- a/chart2/Library_chartcontroller.mk
+++ b/chart2/Library_chartcontroller.mk
@@ -109,6 +109,7 @@ $(eval $(call 
gb_Library_add_exception_objects,chartcontroller,\
     chart2/source/controller/dialogs/dlg_DataSource \
     chart2/source/controller/dialogs/dlg_InsertAxis_Grid \
     chart2/source/controller/dialogs/dlg_InsertDataLabel \
+    chart2/source/controller/dialogs/dlg_InsertDataTable \
     chart2/source/controller/dialogs/dlg_InsertErrorBars \
     chart2/source/controller/dialogs/dlg_InsertLegend \
     chart2/source/controller/dialogs/dlg_InsertTitle \
@@ -122,6 +123,7 @@ $(eval $(call 
gb_Library_add_exception_objects,chartcontroller,\
     chart2/source/controller/dialogs/RangeSelectionListener \
     chart2/source/controller/dialogs/res_BarGeometry \
     chart2/source/controller/dialogs/res_DataLabel \
+    chart2/source/controller/dialogs/res_DataTableProperties \
     chart2/source/controller/dialogs/res_ErrorBar \
     chart2/source/controller/dialogs/res_LegendPosition \
     chart2/source/controller/dialogs/res_Titles \
diff --git a/chart2/UIConfig_chart2.mk b/chart2/UIConfig_chart2.mk
index 59af510c5845..274efd02638f 100644
--- a/chart2/UIConfig_chart2.mk
+++ b/chart2/UIConfig_chart2.mk
@@ -44,7 +44,9 @@ $(eval $(call gb_UIConfig_add_uifiles,modules/schart,\
        chart2/uiconfig/ui/combobox \
        chart2/uiconfig/ui/datarangedialog \
        chart2/uiconfig/ui/dlg_DataLabel \
+       chart2/uiconfig/ui/dlg_InsertDataTable \
        chart2/uiconfig/ui/dlg_InsertErrorBars \
+       chart2/uiconfig/ui/dlg_InsertLegend \
        chart2/uiconfig/ui/imagefragment \
        chart2/uiconfig/ui/insertaxisdlg \
        chart2/uiconfig/ui/insertgriddlg \
@@ -58,7 +60,6 @@ $(eval $(call gb_UIConfig_add_uifiles,modules/schart,\
        chart2/uiconfig/ui/smoothlinesdlg \
        chart2/uiconfig/ui/steppedlinesdlg \
        chart2/uiconfig/ui/titlerotationtabpage \
-       chart2/uiconfig/ui/dlg_InsertLegend \
        chart2/uiconfig/ui/tp_3D_SceneAppearance \
        chart2/uiconfig/ui/tp_3D_SceneGeometry \
        chart2/uiconfig/ui/tp_3D_SceneIllumination \
diff --git a/chart2/source/controller/dialogs/dlg_InsertDataTable.cxx 
b/chart2/source/controller/dialogs/dlg_InsertDataTable.cxx
new file mode 100644
index 000000000000..4b5e928db057
--- /dev/null
+++ b/chart2/source/controller/dialogs/dlg_InsertDataTable.cxx
@@ -0,0 +1,61 @@
+/* -*- 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 <dlg_InsertDataTable.hxx>
+
+namespace chart
+{
+InsertDataTableDialog::InsertDataTableDialog(weld::Window* pWindow)
+    : GenericDialogController(pWindow, 
"modules/schart/ui/dlg_InsertDataTable.ui",
+                              "InsertDataTableDialog")
+    , m_aDataTablePropertiesResources(*m_xBuilder)
+    , m_xCbShowDataTable(m_xBuilder->weld_check_button("showDataTable"))
+{
+    m_xCbShowDataTable->connect_toggled(LINK(this, InsertDataTableDialog, 
ShowDataTableToggle));
+    init(m_aData);
+}
+
+IMPL_LINK_NOARG(InsertDataTableDialog, ShowDataTableToggle, weld::Toggleable&, 
void)
+{
+    changeEnabled();
+}
+
+void InsertDataTableDialog::changeEnabled()
+{
+    bool bEnable = m_xCbShowDataTable->get_active();
+    m_aDataTablePropertiesResources.setChecksSensitive(bEnable);
+    m_aData.mbShow = bEnable;
+}
+
+void InsertDataTableDialog::init(DataTableDialogData const& rData)
+{
+    m_aData = rData;
+    
m_aDataTablePropertiesResources.setHorizontalBorder(m_aData.mbHorizontalBorders);
+    
m_aDataTablePropertiesResources.setVerticalBorder(m_aData.mbVerticalBorders);
+    m_aDataTablePropertiesResources.setOutline(m_aData.mbOutline);
+    m_aDataTablePropertiesResources.setKeys(m_aData.mbKeys);
+    m_xCbShowDataTable->set_active(m_aData.mbShow);
+    changeEnabled();
+}
+
+DataTableDialogData& InsertDataTableDialog::getDataTableDialogData()
+{
+    m_aData.mbShow = m_xCbShowDataTable->get_active();
+
+    m_aData.mbHorizontalBorders = 
m_aDataTablePropertiesResources.getHorizontalBorder();
+    m_aData.mbVerticalBorders = 
m_aDataTablePropertiesResources.getVerticalBorder();
+    m_aData.mbOutline = m_aDataTablePropertiesResources.getOutline();
+    m_aData.mbKeys = m_aDataTablePropertiesResources.getKeys();
+
+    return m_aData;
+}
+
+} //namespace chart
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/controller/dialogs/res_DataTableProperties.cxx 
b/chart2/source/controller/dialogs/res_DataTableProperties.cxx
new file mode 100644
index 000000000000..bf87b3e6b9e3
--- /dev/null
+++ b/chart2/source/controller/dialogs/res_DataTableProperties.cxx
@@ -0,0 +1,111 @@
+/* -*- 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 <res_DataTableProperties.hxx>
+
+#include <chartview/ChartSfxItemIds.hxx>
+#include <svl/eitem.hxx>
+
+using namespace css;
+
+namespace chart
+{
+DataTablePropertiesResources::DataTablePropertiesResources(weld::Builder& 
rBuilder)
+    : m_xCbHorizontalBorder(rBuilder.weld_check_button("horizontalBorderCB"))
+    , m_xCbVerticalBorder(rBuilder.weld_check_button("verticalBorderCB"))
+    , m_xCbOutilne(rBuilder.weld_check_button("outlineCB"))
+    , m_xCbKeys(rBuilder.weld_check_button("keysCB"))
+{
+}
+
+void DataTablePropertiesResources::setChecksSensitive(bool bSensitive)
+{
+    m_xCbHorizontalBorder->set_sensitive(bSensitive);
+    m_xCbVerticalBorder->set_sensitive(bSensitive);
+    m_xCbOutilne->set_sensitive(bSensitive);
+    m_xCbKeys->set_sensitive(bSensitive);
+}
+
+void DataTablePropertiesResources::initFromItemSet(const SfxItemSet& rInAttrs)
+{
+    const SfxPoolItem* pPoolItem = nullptr;
+    SfxItemState aState;
+
+    aState = rInAttrs.GetItemState(SCHATTR_DATA_TABLE_HORIZONTAL_BORDER, 
false, &pPoolItem);
+    if (aState == SfxItemState::DONTCARE)
+    {
+        m_xCbHorizontalBorder->set_state(TRISTATE_INDET);
+    }
+    else
+    {
+        if (aState == SfxItemState::SET)
+            m_xCbHorizontalBorder->set_active(
+                static_cast<const SfxBoolItem*>(pPoolItem)->GetValue());
+    }
+
+    aState = rInAttrs.GetItemState(SCHATTR_DATA_TABLE_VERTICAL_BORDER, false, 
&pPoolItem);
+    if (aState == SfxItemState::DONTCARE)
+    {
+        m_xCbVerticalBorder->set_state(TRISTATE_INDET);
+    }
+    else
+    {
+        if (aState == SfxItemState::SET)
+            m_xCbVerticalBorder->set_active(static_cast<const 
SfxBoolItem*>(pPoolItem)->GetValue());
+    }
+
+    aState = rInAttrs.GetItemState(SCHATTR_DATA_TABLE_OUTLINE, false, 
&pPoolItem);
+    if (aState == SfxItemState::DONTCARE)
+    {
+        m_xCbOutilne->set_state(TRISTATE_INDET);
+    }
+    else
+    {
+        if (aState == SfxItemState::SET)
+            m_xCbOutilne->set_active(static_cast<const 
SfxBoolItem*>(pPoolItem)->GetValue());
+    }
+
+    aState = rInAttrs.GetItemState(SCHATTR_DATA_TABLE_KEYS, false, &pPoolItem);
+    if (aState == SfxItemState::DONTCARE)
+    {
+        m_xCbKeys->set_state(TRISTATE_INDET);
+    }
+    else
+    {
+        if (aState == SfxItemState::SET)
+            m_xCbKeys->set_active(static_cast<const 
SfxBoolItem*>(pPoolItem)->GetValue());
+    }
+}
+
+bool DataTablePropertiesResources::writeToItemSet(SfxItemSet& rOutAttrs) const
+{
+    if (m_xCbHorizontalBorder->get_state() != TRISTATE_INDET)
+    {
+        rOutAttrs.Put(
+            SfxBoolItem(SCHATTR_DATA_TABLE_HORIZONTAL_BORDER, 
m_xCbHorizontalBorder->get_active()));
+    }
+    if (m_xCbVerticalBorder->get_state() != TRISTATE_INDET)
+    {
+        rOutAttrs.Put(
+            SfxBoolItem(SCHATTR_DATA_TABLE_VERTICAL_BORDER, 
m_xCbVerticalBorder->get_active()));
+    }
+    if (m_xCbOutilne->get_state() != TRISTATE_INDET)
+    {
+        rOutAttrs.Put(SfxBoolItem(SCHATTR_DATA_TABLE_OUTLINE, 
m_xCbOutilne->get_active()));
+    }
+    if (m_xCbKeys->get_state() != TRISTATE_INDET)
+    {
+        rOutAttrs.Put(SfxBoolItem(SCHATTR_DATA_TABLE_KEYS, 
m_xCbKeys->get_active()));
+    }
+    return true;
+}
+
+} //namespace chart
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/controller/dialogs/tp_DataTable.cxx 
b/chart2/source/controller/dialogs/tp_DataTable.cxx
index d7bed5a53900..e6982b4a5067 100644
--- a/chart2/source/controller/dialogs/tp_DataTable.cxx
+++ b/chart2/source/controller/dialogs/tp_DataTable.cxx
@@ -9,19 +9,13 @@
 
 #include "tp_DataTable.hxx"
 
-#include <chartview/ChartSfxItemIds.hxx>
-#include <svl/eitem.hxx>
-
 namespace chart
 {
 DataTableTabPage::DataTableTabPage(weld::Container* pPage, 
weld::DialogController* pController,
                                    const SfxItemSet& rInAttrs)
     : SfxTabPage(pPage, pController, "modules/schart/ui/tp_DataTable.ui", 
"DataTableTabPage",
                  &rInAttrs)
-    , 
m_xCbHorizontalBorder(m_xBuilder->weld_check_button("horizontalBorderCB"))
-    , m_xCbVerticalBorder(m_xBuilder->weld_check_button("verticalBorderCB"))
-    , m_xCbOutilne(m_xBuilder->weld_check_button("outlineCB"))
-    , m_xCbKeys(m_xBuilder->weld_check_button("keysCB"))
+    , m_aDataTablePropertiesResources(*m_xBuilder)
 {
 }
 
@@ -34,78 +28,14 @@ std::unique_ptr<SfxTabPage> 
DataTableTabPage::Create(weld::Container* pPage,
     return std::make_unique<DataTableTabPage>(pPage, pController, *rAttrs);
 }
 
-bool DataTableTabPage::FillItemSet(SfxItemSet* rOutAttrs)
+bool DataTableTabPage::FillItemSet(SfxItemSet* pOutAttrs)
 {
-    if (m_xCbHorizontalBorder->get_state() != TRISTATE_INDET)
-    {
-        rOutAttrs->Put(
-            SfxBoolItem(SCHATTR_DATA_TABLE_HORIZONTAL_BORDER, 
m_xCbHorizontalBorder->get_active()));
-    }
-    if (m_xCbVerticalBorder->get_state() != TRISTATE_INDET)
-    {
-        rOutAttrs->Put(
-            SfxBoolItem(SCHATTR_DATA_TABLE_VERTICAL_BORDER, 
m_xCbVerticalBorder->get_active()));
-    }
-    if (m_xCbOutilne->get_state() != TRISTATE_INDET)
-    {
-        rOutAttrs->Put(SfxBoolItem(SCHATTR_DATA_TABLE_OUTLINE, 
m_xCbOutilne->get_active()));
-    }
-    if (m_xCbKeys->get_state() != TRISTATE_INDET)
-    {
-        rOutAttrs->Put(SfxBoolItem(SCHATTR_DATA_TABLE_KEYS, 
m_xCbKeys->get_active()));
-    }
-    return true;
+    return m_aDataTablePropertiesResources.writeToItemSet(*pOutAttrs);
 }
 
 void DataTableTabPage::Reset(const SfxItemSet* pInAttrs)
 {
-    const SfxPoolItem* pPoolItem = nullptr;
-    SfxItemState aState;
-
-    aState = pInAttrs->GetItemState(SCHATTR_DATA_TABLE_HORIZONTAL_BORDER, 
false, &pPoolItem);
-    if (aState == SfxItemState::DONTCARE)
-    {
-        m_xCbHorizontalBorder->set_state(TRISTATE_INDET);
-    }
-    else
-    {
-        if (aState == SfxItemState::SET)
-            m_xCbHorizontalBorder->set_active(
-                static_cast<const SfxBoolItem*>(pPoolItem)->GetValue());
-    }
-
-    aState = pInAttrs->GetItemState(SCHATTR_DATA_TABLE_VERTICAL_BORDER, false, 
&pPoolItem);
-    if (aState == SfxItemState::DONTCARE)
-    {
-        m_xCbVerticalBorder->set_state(TRISTATE_INDET);
-    }
-    else
-    {
-        if (aState == SfxItemState::SET)
-            m_xCbVerticalBorder->set_active(static_cast<const 
SfxBoolItem*>(pPoolItem)->GetValue());
-    }
-
-    aState = pInAttrs->GetItemState(SCHATTR_DATA_TABLE_OUTLINE, false, 
&pPoolItem);
-    if (aState == SfxItemState::DONTCARE)
-    {
-        m_xCbOutilne->set_state(TRISTATE_INDET);
-    }
-    else
-    {
-        if (aState == SfxItemState::SET)
-            m_xCbOutilne->set_active(static_cast<const 
SfxBoolItem*>(pPoolItem)->GetValue());
-    }
-
-    aState = pInAttrs->GetItemState(SCHATTR_DATA_TABLE_KEYS, false, 
&pPoolItem);
-    if (aState == SfxItemState::DONTCARE)
-    {
-        m_xCbKeys->set_state(TRISTATE_INDET);
-    }
-    else
-    {
-        if (aState == SfxItemState::SET)
-            m_xCbKeys->set_active(static_cast<const 
SfxBoolItem*>(pPoolItem)->GetValue());
-    }
+    m_aDataTablePropertiesResources.initFromItemSet(*pInAttrs);
 }
 
 } //namespace chart
diff --git a/chart2/source/controller/dialogs/tp_DataTable.hxx 
b/chart2/source/controller/dialogs/tp_DataTable.hxx
index 11bcfb9203e1..a4ef6d6cf436 100644
--- a/chart2/source/controller/dialogs/tp_DataTable.hxx
+++ b/chart2/source/controller/dialogs/tp_DataTable.hxx
@@ -10,21 +10,14 @@
 #pragma once
 
 #include <sfx2/tabdlg.hxx>
-
-namespace weld
-{
-class CheckButton;
-}
+#include <res_DataTableProperties.hxx>
 
 namespace chart
 {
 class DataTableTabPage : public SfxTabPage
 {
 private:
-    std::unique_ptr<weld::CheckButton> m_xCbHorizontalBorder;
-    std::unique_ptr<weld::CheckButton> m_xCbVerticalBorder;
-    std::unique_ptr<weld::CheckButton> m_xCbOutilne;
-    std::unique_ptr<weld::CheckButton> m_xCbKeys;
+    DataTablePropertiesResources m_aDataTablePropertiesResources;
 
 public:
     DataTableTabPage(weld::Container* pPage, weld::DialogController* 
pController,
diff --git a/chart2/source/controller/inc/dlg_InsertDataTable.hxx 
b/chart2/source/controller/inc/dlg_InsertDataTable.hxx
new file mode 100644
index 000000000000..5dda9c3444bc
--- /dev/null
+++ b/chart2/source/controller/inc/dlg_InsertDataTable.hxx
@@ -0,0 +1,47 @@
+/* -*- 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/.
+ */
+
+#pragma once
+
+#include <vcl/weld.hxx>
+#include <res_DataTableProperties.hxx>
+
+namespace chart
+{
+struct DataTableDialogData
+{
+    bool mbShow = true;
+    bool mbHorizontalBorders = false;
+    bool mbVerticalBorders = false;
+    bool mbOutline = false;
+    bool mbKeys = false;
+};
+
+class InsertDataTableDialog final : public weld::GenericDialogController
+{
+private:
+    DataTablePropertiesResources m_aDataTablePropertiesResources;
+    std::unique_ptr<weld::CheckButton> m_xCbShowDataTable;
+
+    DataTableDialogData m_aData;
+
+    DECL_LINK(ShowDataTableToggle, weld::Toggleable&, void);
+
+    void changeEnabled();
+
+public:
+    InsertDataTableDialog(weld::Window* pParent);
+
+    void init(DataTableDialogData const& rData);
+    DataTableDialogData& getDataTableDialogData();
+};
+
+} //namespace chart
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/controller/inc/res_DataTableProperties.hxx 
b/chart2/source/controller/inc/res_DataTableProperties.hxx
new file mode 100644
index 000000000000..299934cb0211
--- /dev/null
+++ b/chart2/source/controller/inc/res_DataTableProperties.hxx
@@ -0,0 +1,47 @@
+/* -*- 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/.
+ */
+
+#pragma once
+
+#include <svl/itemset.hxx>
+#include <vcl/weld.hxx>
+
+namespace chart
+{
+class DataTablePropertiesResources final
+{
+private:
+    std::unique_ptr<weld::CheckButton> m_xCbHorizontalBorder;
+    std::unique_ptr<weld::CheckButton> m_xCbVerticalBorder;
+    std::unique_ptr<weld::CheckButton> m_xCbOutilne;
+    std::unique_ptr<weld::CheckButton> m_xCbKeys;
+
+public:
+    DataTablePropertiesResources(weld::Builder& rBuilder);
+
+    void initFromItemSet(SfxItemSet const& rInAttrs);
+    bool writeToItemSet(SfxItemSet& rOutAttrs) const;
+    void setChecksSensitive(bool bSensitive);
+
+    bool getHorizontalBorder() { return m_xCbHorizontalBorder->get_active(); }
+    void setHorizontalBorder(bool bActive) { 
m_xCbHorizontalBorder->set_active(bActive); }
+
+    bool getVerticalBorder() { return m_xCbVerticalBorder->get_active(); }
+    void setVerticalBorder(bool bActive) { 
m_xCbVerticalBorder->set_active(bActive); }
+
+    bool getOutline() { return m_xCbOutilne->get_active(); }
+    void setOutline(bool bActive) { m_xCbOutilne->set_active(bActive); }
+
+    bool getKeys() { return m_xCbKeys->get_active(); }
+    void setKeys(bool bActive) { m_xCbKeys->set_active(bActive); }
+};
+
+} //namespace chart
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/controller/main/ChartController_Insert.cxx 
b/chart2/source/controller/main/ChartController_Insert.cxx
index 46d00eedb89c..b1b0598d5070 100644
--- a/chart2/source/controller/main/ChartController_Insert.cxx
+++ b/chart2/source/controller/main/ChartController_Insert.cxx
@@ -25,6 +25,7 @@
 #include <dlg_InsertLegend.hxx>
 #include <dlg_InsertErrorBars.hxx>
 #include <dlg_InsertTitle.hxx>
+#include <dlg_InsertDataTable.hxx>
 #include <dlg_ObjectProperties.hxx>
 
 #include <Axis.hxx>
@@ -57,6 +58,7 @@
 
 #include <com/sun/star/chart2/XRegressionCurve.hpp>
 #include <com/sun/star/chart/ErrorBarStyle.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
 #include <svx/ActionDescriptionProvider.hxx>
 
 #include <tools/diagnose_ex.h>
@@ -158,18 +160,66 @@ void ChartController::executeDispatch_InsertGrid()
 
 void ChartController::executeDispatch_OpenInsertDataTableDialog()
 {
-    rtl::Reference<Diagram> xDiagram = getFirstDiagram();
     SolarMutexGuard aGuard;
-    if (xDiagram->getDataTable().is())
+    rtl::Reference<Diagram> xDiagram = getFirstDiagram();
+
+    InsertDataTableDialog aDialog(GetChartFrame());
     {
-        xDiagram->setDataTable(uno::Reference<chart2::XDataTable>());
+        // init values
+        DataTableDialogData aData;
+        auto xDataTable = xDiagram->getDataTable();
+        aData.mbShow = xDataTable.is();
+        if (xDataTable.is())
+        {
+            uno::Reference<beans::XPropertySet> xProperties(xDataTable, 
uno::UNO_QUERY);
+
+            uno::Any aAny = xProperties->getPropertyValue("HBorder");
+            if (aAny.has<bool>())
+                aData.mbHorizontalBorders = aAny.get<bool>();
+
+            aAny = xProperties->getPropertyValue("VBorder");
+            if (aAny.has<bool>())
+                aData.mbVerticalBorders = aAny.get<bool>();
+
+            aAny = xProperties->getPropertyValue("Outline");
+            if (aAny.has<bool>())
+                aData.mbOutline = aAny.get<bool>();
+
+            aAny = xProperties->getPropertyValue("Keys");
+            if (aAny.has<bool>())
+                aData.mbKeys = aAny.get<bool>();
+        }
+        aDialog.init(aData);
     }
-    else
+
+    // show the dialog
+    if (aDialog.run() == RET_OK)
     {
-        uno::Reference<chart2::XDataTable> xDataTable(new DataTable);
-        if (xDataTable.is())
+        auto& rDialogData = aDialog.getDataTableDialogData();
+
+        auto xDataTable = xDiagram->getDataTable();
+        if (!rDialogData.mbShow && xDataTable.is())
+        {
+            xDiagram->setDataTable(uno::Reference<chart2::XDataTable>());
+        }
+        else if (rDialogData.mbShow && !xDataTable.is())
+        {
+            uno::Reference<chart2::XDataTable> xNewDataTable(new DataTable);
+            if (xNewDataTable.is())
+            {
+                xDiagram->setDataTable(xNewDataTable);
+            }
+        }
+
+        // Set the properties
+        xDataTable = xDiagram->getDataTable();
+        if (rDialogData.mbShow && xDataTable.is())
         {
-            xDiagram->setDataTable(xDataTable);
+            uno::Reference<beans::XPropertySet> xProperties(xDataTable, 
uno::UNO_QUERY);
+            xProperties->setPropertyValue("HBorder" , 
uno::Any(rDialogData.mbHorizontalBorders));
+            xProperties->setPropertyValue("VBorder" , 
uno::Any(rDialogData.mbVerticalBorders));
+            xProperties->setPropertyValue("Outline" , 
uno::Any(rDialogData.mbOutline));
+            xProperties->setPropertyValue("Keys" , 
uno::Any(rDialogData.mbKeys));
         }
     }
 }
diff --git a/chart2/uiconfig/ui/dlg_InsertDataTable.ui 
b/chart2/uiconfig/ui/dlg_InsertDataTable.ui
new file mode 100644
index 000000000000..77a4ca4a3618
--- /dev/null
+++ b/chart2/uiconfig/ui/dlg_InsertDataTable.ui
@@ -0,0 +1,215 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.38.2 -->
+<interface domain="chart">
+  <requires lib="gtk+" version="3.20"/>
+  <object class="GtkDialog" id="InsertDataTableDialog">
+    <property name="can-focus">False</property>
+    <property name="border-width">6</property>
+    <property name="title" translatable="yes" 
context="dlg_InsertLegend|dlg_InsertLegend">Data Table</property>
+    <property name="modal">True</property>
+    <property name="default-width">0</property>
+    <property name="default-height">0</property>
+    <property name="type-hint">dialog</property>
+    <child internal-child="vbox">
+      <object class="GtkBox" id="dialog-vbox1">
+        <property name="can-focus">False</property>
+        <property name="orientation">vertical</property>
+        <property name="spacing">12</property>
+        <child internal-child="action_area">
+          <object class="GtkButtonBox" id="dialog-action_area1">
+            <property name="can-focus">False</property>
+            <property name="layout-style">end</property>
+            <child>
+              <object class="GtkButton" id="ok">
+                <property name="label" translatable="yes" 
context="stock">_OK</property>
+                <property name="visible">True</property>
+                <property name="can-focus">True</property>
+                <property name="can-default">True</property>
+                <property name="has-default">True</property>
+                <property name="receives-default">True</property>
+                <property name="use-underline">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkButton" id="cancel">
+                <property name="label" translatable="yes" 
context="stock">_Cancel</property>
+                <property name="visible">True</property>
+                <property name="can-focus">True</property>
+                <property name="receives-default">True</property>
+                <property name="use-underline">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkButton" id="help">
+                <property name="label" translatable="yes" 
context="stock">_Help</property>
+                <property name="visible">True</property>
+                <property name="can-focus">True</property>
+                <property name="receives-default">True</property>
+                <property name="margin-end">6</property>
+                <property name="use-underline">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">2</property>
+                <property name="secondary">True</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="pack-type">end</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkBox" id="dlg_LegendPosition">
+            <property name="visible">True</property>
+            <property name="can-focus">False</property>
+            <property name="border-width">6</property>
+            <property name="orientation">vertical</property>
+            <property name="spacing">12</property>
+            <child>
+              <object class="GtkCheckButton" id="showDataTable">
+                <property name="label" translatable="yes" 
context="tp_DataTable|horizontalBorderCB">Show Data Table</property>
+                <property name="visible">True</property>
+                <property name="can-focus">True</property>
+                <property name="receives-default">False</property>
+                <property name="halign">start</property>
+                <property name="use-underline">True</property>
+                <property name="draw-indicator">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkFrame" id="frame2">
+                <property name="visible">True</property>
+                <property name="can-focus">False</property>
+                <property name="hexpand">True</property>
+                <property name="vexpand">True</property>
+                <property name="label-xalign">0</property>
+                <property name="shadow-type">none</property>
+                <child>
+                  <object class="GtkBox" id="box4">
+                    <property name="visible">True</property>
+                    <property name="can-focus">False</property>
+                    <property name="margin-start">12</property>
+                    <property name="margin-top">6</property>
+                    <property name="hexpand">True</property>
+                    <property name="vexpand">True</property>
+                    <property name="orientation">vertical</property>
+                    <property name="spacing">6</property>
+                    <child>
+                      <object class="GtkCheckButton" id="horizontalBorderCB">
+                        <property name="label" translatable="yes" 
context="tp_DataTable|horizontalBorderCB">Show Horizontal Border</property>
+                        <property name="visible">True</property>
+                        <property name="can-focus">True</property>
+                        <property name="receives-default">False</property>
+                        <property name="halign">start</property>
+                        <property name="use-underline">True</property>
+                        <property name="draw-indicator">True</property>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">True</property>
+                        <property name="position">0</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkCheckButton" id="verticalBorderCB">
+                        <property name="label" translatable="yes" 
context="tp_DataTable|verticalBorderCB">Show Vertical Border</property>
+                        <property name="visible">True</property>
+                        <property name="can-focus">True</property>
+                        <property name="receives-default">False</property>
+                        <property name="halign">start</property>
+                        <property name="use-underline">True</property>
+                        <property name="draw-indicator">True</property>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">True</property>
+                        <property name="position">1</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkCheckButton" id="outlineCB">
+                        <property name="label" translatable="yes" 
context="tp_DataTable|outlineCB">Show Outline</property>
+                        <property name="visible">True</property>
+                        <property name="can-focus">True</property>
+                        <property name="receives-default">False</property>
+                        <property name="halign">start</property>
+                        <property name="use-underline">True</property>
+                        <property name="draw-indicator">True</property>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">True</property>
+                        <property name="position">2</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkCheckButton" id="keysCB">
+                        <property name="label" translatable="yes" 
context="tp_DataTable|keysCB">Show Keys</property>
+                        <property name="visible">True</property>
+                        <property name="can-focus">True</property>
+                        <property name="receives-default">False</property>
+                        <property name="halign">start</property>
+                        <property name="use-underline">True</property>
+                        <property name="draw-indicator">True</property>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">True</property>
+                        <property name="position">3</property>
+                      </packing>
+                    </child>
+                  </object>
+                </child>
+                <child type="label">
+                  <object class="GtkLabel" id="dataTablePropertiesLabel">
+                    <property name="visible">True</property>
+                    <property name="can-focus">False</property>
+                    <property name="label" translatable="yes" 
context="tp_axisLabel|textflowL">Data Table Properties</property>
+                    <attributes>
+                      <attribute name="weight" value="bold"/>
+                    </attributes>
+                  </object>
+                </child>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="position">1</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+    <action-widgets>
+      <action-widget response="-5">ok</action-widget>
+      <action-widget response="-6">cancel</action-widget>
+      <action-widget response="-11">help</action-widget>
+    </action-widgets>
+  </object>
+</interface>
commit b5b6f9409d17d1f7b02aa2d33db9925085c70130
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Thu Jun 30 23:43:52 2022 +0200
Commit:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
CommitDate: Fri Jul 1 22:26:37 2022 +0200

    chart2: add some data table default properties
    
    Change-Id: I4fac46ac2a119275bcdaa6ebc8b7382ad6fb5684

diff --git a/chart2/source/model/main/DataTable.cxx 
b/chart2/source/model/main/DataTable.cxx
index 0620ce5ccaba..c67fab5c1740 100644
--- a/chart2/source/model/main/DataTable.cxx
+++ b/chart2/source/model/main/DataTable.cxx
@@ -70,6 +70,14 @@ private:
                                                          true);
         ::chart::PropertyHelper::setPropertyValueDefault(aMap, 
DataTableProperty_Outilne, true);
         ::chart::PropertyHelper::setPropertyValueDefault(aMap, 
DataTableProperty_Keys, false);
+
+        float fDefaultCharHeight = 10.0;
+        ::chart::PropertyHelper::setPropertyValue(
+            aMap, ::chart::CharacterProperties::PROP_CHAR_CHAR_HEIGHT, 
fDefaultCharHeight);
+        ::chart::PropertyHelper::setPropertyValue(
+            aMap, ::chart::CharacterProperties::PROP_CHAR_ASIAN_CHAR_HEIGHT, 
fDefaultCharHeight);
+        ::chart::PropertyHelper::setPropertyValue(
+            aMap, ::chart::CharacterProperties::PROP_CHAR_COMPLEX_CHAR_HEIGHT, 
fDefaultCharHeight);
     }
 };
 
commit c99dcb208ac0f621abcacc14a358d7c775c8d05d
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Thu Jun 30 23:34:19 2022 +0200
Commit:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
CommitDate: Fri Jul 1 22:24:47 2022 +0200

    chart2: add "InsertMenuDataTable" action to menu
    
    Change-Id: Ib60a2b061966eb61834480b63dc0653410a43a14

diff --git a/chart2/source/controller/inc/ChartController.hxx 
b/chart2/source/controller/inc/ChartController.hxx
index 505b109fdcc7..f0f53c8b8990 100644
--- a/chart2/source/controller/inc/ChartController.hxx
+++ b/chart2/source/controller/inc/ChartController.hxx
@@ -440,6 +440,7 @@ private:
     void executeDispatch_OpenLegendDialog();
     void executeDispatch_InsertAxes();
     void executeDispatch_InsertGrid();
+    void executeDispatch_OpenInsertDataTableDialog();
 
     void executeDispatch_InsertMenu_DataLabels();
     void executeDispatch_InsertMenu_Trendlines();
diff --git a/chart2/source/controller/main/ChartController.cxx 
b/chart2/source/controller/main/ChartController.cxx
index a4bd7a3972cc..79b29bb63c52 100644
--- a/chart2/source/controller/main/ChartController.cxx
+++ b/chart2/source/controller/main/ChartController.cxx
@@ -1169,6 +1169,8 @@ void SAL_CALL ChartController::dispatch(
         this->executeDispatch_InsertErrorBars(false);
     else if( aCommand == "InsertMenuYErrorBars" )
         this->executeDispatch_InsertErrorBars(true);
+    else if( aCommand == "InsertMenuDataTable" )
+        this->executeDispatch_OpenInsertDataTableDialog();
     else if( aCommand == "InsertSymbol" )
          this->executeDispatch_InsertSpecialCharacter();
     else if( aCommand == "InsertTrendline" )
@@ -1631,6 +1633,7 @@ const o3tl::sorted_vector< OUString >& 
ChartController::impl_getAvailableCommand
         "DeleteTrendline",    "DeleteMeanValue",      
"DeleteTrendlineEquation",
         "DeleteXErrorBars",   "DeleteYErrorBars",
         "DeleteDataLabels",   "DeleteDataLabel",
+        "InsertMenuDataTable",
         //format objects
         "FormatSelection",     "TransformDialog",
         "DiagramType",        "View3D",
diff --git a/chart2/source/controller/main/ChartController_Insert.cxx 
b/chart2/source/controller/main/ChartController_Insert.cxx
index 4f39f1068cdb..46d00eedb89c 100644
--- a/chart2/source/controller/main/ChartController_Insert.cxx
+++ b/chart2/source/controller/main/ChartController_Insert.cxx
@@ -52,6 +52,7 @@
 #include <ObjectNameProvider.hxx>
 #include <Legend.hxx>
 #include <LegendHelper.hxx>
+#include <DataTable.hxx>
 #include <RegressionCurveModel.hxx>
 
 #include <com/sun/star/chart2/XRegressionCurve.hpp>
@@ -155,6 +156,24 @@ void ChartController::executeDispatch_InsertGrid()
     }
 }
 
+void ChartController::executeDispatch_OpenInsertDataTableDialog()
+{
+    rtl::Reference<Diagram> xDiagram = getFirstDiagram();
+    SolarMutexGuard aGuard;
+    if (xDiagram->getDataTable().is())
+    {
+        xDiagram->setDataTable(uno::Reference<chart2::XDataTable>());
+    }
+    else
+    {
+        uno::Reference<chart2::XDataTable> xDataTable(new DataTable);
+        if (xDataTable.is())
+        {
+            xDiagram->setDataTable(xDataTable);
+        }
+    }
+}
+
 void ChartController::executeDispatch_InsertTitles()
 {
     UndoGuard aUndoGuard(
diff --git a/chart2/source/controller/main/ControllerCommandDispatch.cxx 
b/chart2/source/controller/main/ControllerCommandDispatch.cxx
index e5035b4f053c..828d862f4306 100644
--- a/chart2/source/controller/main/ControllerCommandDispatch.cxx
+++ b/chart2/source/controller/main/ControllerCommandDispatch.cxx
@@ -584,6 +584,7 @@ void ControllerCommandDispatch::updateCommandAvailability()
     m_aCommandAvailability[ ".uno:InsertMenuXErrorBars" ] = bIsWritable && 
m_apModelState->bSupportsStatistics;
     m_aCommandAvailability[ ".uno:InsertMenuYErrorBars" ] = bIsWritable && 
m_apModelState->bSupportsStatistics;
     m_aCommandAvailability[ ".uno:InsertSymbol" ] = bIsWritable && 
bControllerStateIsValid && m_apControllerState->bIsTextObject;
+    m_aCommandAvailability[ ".uno:InsertMenuDataTable" ] = bIsWritable;
 
     // format objects
     bool bFormatObjectAvailable = bIsWritable && bControllerStateIsValid && 
m_apControllerState->bIsFormateableObjectSelected;
diff --git a/chart2/uiconfig/menubar/menubar.xml 
b/chart2/uiconfig/menubar/menubar.xml
index 354ebbc1903a..a48cd77d47de 100644
--- a/chart2/uiconfig/menubar/menubar.xml
+++ b/chart2/uiconfig/menubar/menubar.xml
@@ -56,6 +56,7 @@
         <menu:menuitem menu:id=".uno:InsertMenuLegend"/>
         <menu:menuitem menu:id=".uno:InsertMenuAxes"/>
         <menu:menuitem menu:id=".uno:InsertMenuGrids"/>
+        <menu:menuitem menu:id=".uno:InsertMenuDataTable"/>
       <menu:menuseparator/>
         <menu:menuitem menu:id=".uno:InsertMenuDataLabels"/>
         <menu:menuitem menu:id=".uno:InsertMenuTrendlines"/>
diff --git a/officecfg/registry/data/org/openoffice/Office/UI/ChartCommands.xcu 
b/officecfg/registry/data/org/openoffice/Office/UI/ChartCommands.xcu
index d3a54a052c8e..cb4a5dc728d0 100644
--- a/officecfg/registry/data/org/openoffice/Office/UI/ChartCommands.xcu
+++ b/officecfg/registry/data/org/openoffice/Office/UI/ChartCommands.xcu
@@ -64,6 +64,11 @@
           <value xml:lang="en-US">Y Error ~Bars...</value>
         </prop>
       </node>
+      <node oor:name=".uno:InsertMenuDataTable" oor:op="replace">
+        <prop oor:name="Label" oor:type="xs:string">
+          <value xml:lang="en-US">Data Table...</value>
+        </prop>
+      </node>
       <!--  Menu - Format -->
       <node oor:name=".uno:FormatSelection" oor:op="replace">
         <prop oor:name="Label" oor:type="xs:string">

Reply via email to