chart2/source/model/main/DataTable.cxx                 |   27 ++--
 chart2/source/view/axes/VAxisBase.cxx                  |    3 
 chart2/source/view/axes/VAxisBase.hxx                  |    5 
 chart2/source/view/axes/VCartesianAxis.cxx             |    6 -
 chart2/source/view/axes/VCartesianAxis.hxx             |    3 
 chart2/source/view/axes/VCartesianCoordinateSystem.cxx |    2 
 chart2/source/view/inc/DataTableView.hxx               |   11 +
 chart2/source/view/main/DataTableView.cxx              |   94 +++++++++++++----
 8 files changed, 110 insertions(+), 41 deletions(-)

New commits:
commit f22122c8d5ca38fb0aaa682083a455040ccf3f92
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Fri May 20 23:55:45 2022 +0900
Commit:     Tomaž Vajngerl <qui...@gmail.com>
CommitDate: Thu Aug 18 08:51:28 2022 +0200

    chart2: apply line props. to borders when rendering a data table
    
    This sets the color, line width, line style to the borders of
    the table when rendering the data table. We also need the
    ChartModel inside DataTableView, so we can access the needed
    line dashes.
    
    Change-Id: Id3bef23b75e88517d6569ad87a716f178ed64343
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137158
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <qui...@gmail.com>
    (cherry picked from commit 6c24f112ad86df77f2de27a31742bca01ed56bdf)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138440
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>

diff --git a/chart2/source/view/axes/VAxisBase.cxx 
b/chart2/source/view/axes/VAxisBase.cxx
index 880c10568e6f..209fc508f624 100644
--- a/chart2/source/view/axes/VAxisBase.cxx
+++ b/chart2/source/view/axes/VAxisBase.cxx
@@ -246,7 +246,8 @@ void VAxisBase::updateUnscaledValuesAtTicks( TickIter& 
rIter )
 }
 
 void 
VAxisBase::createDataTableView(std::vector<std::unique_ptr<VSeriesPlotter>>& 
/*rSeriesPlotterList*/,
-                                    
uno::Reference<util::XNumberFormatsSupplier> const& /*xNumberFormatsSupplier*/)
+                                    
uno::Reference<util::XNumberFormatsSupplier> const& /*xNumberFormatsSupplier*/,
+                                    uno::Reference<chart2::XChartDocument> 
const& /*xChartDoc*/)
 {
 }
 
diff --git a/chart2/source/view/axes/VAxisBase.hxx 
b/chart2/source/view/axes/VAxisBase.hxx
index b65de0d4c954..6992ff05fd89 100644
--- a/chart2/source/view/axes/VAxisBase.hxx
+++ b/chart2/source/view/axes/VAxisBase.hxx
@@ -18,6 +18,7 @@
  */
 #pragma once
 
+#include <com/sun/star/chart2/XChartDocument.hpp>
 #include "VAxisOrGridBase.hxx"
 #include "VAxisProperties.hxx"
 #include "Tickmarks.hxx"
@@ -29,6 +30,7 @@ namespace chart
 
 class VSeriesPlotter;
 class DataTableView;
+class ChartModel;
 
 class VAxisBase : public VAxisOrGridBase
 {
@@ -63,7 +65,8 @@ public:
     void setExtraLinePositionAtOtherAxis( double fCrossingAt );
 
     virtual void 
createDataTableView(std::vector<std::unique_ptr<VSeriesPlotter>>& 
rSeriesPlotterList,
-                                     
css::uno::Reference<css::util::XNumberFormatsSupplier> const& 
xNumberFormatsSupplier);
+                                     
css::uno::Reference<css::util::XNumberFormatsSupplier> const& 
xNumberFormatsSupplier,
+                                     
css::uno::Reference<css::chart2::XChartDocument> const& xChartDoc);
 
     std::shared_ptr<DataTableView> getDataTableView() { return 
m_pDataTableView; }
 
diff --git a/chart2/source/view/axes/VCartesianAxis.cxx 
b/chart2/source/view/axes/VCartesianAxis.cxx
index 641269b6b367..0a731bf086d2 100644
--- a/chart2/source/view/axes/VCartesianAxis.cxx
+++ b/chart2/source/view/axes/VCartesianAxis.cxx
@@ -37,6 +37,7 @@
 #include <svx/unoshtxt.hxx>
 #include <VSeriesPlotter.hxx>
 #include <DataTableView.hxx>
+#include <ChartModel.hxx>
 
 #include <basegfx/polygon/b2dpolygon.hxx>
 #include <basegfx/polygon/b2dpolypolygon.hxx>
@@ -2007,11 +2008,12 @@ void VCartesianAxis::createShapes()
 }
 
 void 
VCartesianAxis::createDataTableView(std::vector<std::unique_ptr<VSeriesPlotter>>&
 rSeriesPlotterList,
-                                         
Reference<util::XNumberFormatsSupplier> const& xNumberFormatsSupplier)
+                                         
uno::Reference<util::XNumberFormatsSupplier> const& xNumberFormatsSupplier,
+                                         
uno::Reference<chart2::XChartDocument> const& xChartDoc)
 {
     if (m_aAxisProperties.m_bDisplayDataTable)
     {
-        m_pDataTableView.reset(new 
DataTableView(m_aAxisProperties.m_xDataTableModel));
+        m_pDataTableView.reset(new DataTableView(xChartDoc, 
m_aAxisProperties.m_xDataTableModel));
         m_pDataTableView->initializeValues(rSeriesPlotterList);
         m_xNumberFormatsSupplier = xNumberFormatsSupplier;
     }
diff --git a/chart2/source/view/axes/VCartesianAxis.hxx 
b/chart2/source/view/axes/VCartesianAxis.hxx
index eb70e5d3c3a5..1027e4fc2188 100644
--- a/chart2/source/view/axes/VCartesianAxis.hxx
+++ b/chart2/source/view/axes/VCartesianAxis.hxx
@@ -100,7 +100,8 @@ public:
     };
 
     void createDataTableView(std::vector<std::unique_ptr<VSeriesPlotter>>& 
rSeriesPlotterList,
-                             
css::uno::Reference<css::util::XNumberFormatsSupplier> const& 
xNumberFormatsSupplier) override;
+                             
css::uno::Reference<css::util::XNumberFormatsSupplier> const& 
xNumberFormatsSupplier,
+                             css::uno::Reference<css::chart2::XChartDocument> 
const& xChartDoc) override;
 private: //methods
     /**
      * Go through all tick label positions and decide which labels to display
diff --git a/chart2/source/view/axes/VCartesianCoordinateSystem.cxx 
b/chart2/source/view/axes/VCartesianCoordinateSystem.cxx
index d3c71361f27c..53eac1515e0c 100644
--- a/chart2/source/view/axes/VCartesianCoordinateSystem.cxx
+++ b/chart2/source/view/axes/VCartesianCoordinateSystem.cxx
@@ -167,7 +167,7 @@ void VCartesianCoordinateSystem::createVAxisList(
             apVAxis->set3DWallPositions( m_eLeftWallPos, m_eBackWallPos, 
m_eBottomPos );
 
             
apVAxis->initAxisLabelProperties(rFontReferenceSize,rMaximumSpaceForLabels);
-            apVAxis->createDataTableView(rSeriesPlotterList, 
xNumberFormatsSupplier);
+            apVAxis->createDataTableView(rSeriesPlotterList, 
xNumberFormatsSupplier, xChartDoc);
         }
     }
 }
diff --git a/chart2/source/view/inc/DataTableView.hxx 
b/chart2/source/view/inc/DataTableView.hxx
index fb7fe83929f9..e7130d54bc68 100644
--- a/chart2/source/view/inc/DataTableView.hxx
+++ b/chart2/source/view/inc/DataTableView.hxx
@@ -12,7 +12,9 @@
 #include <svx/unodraw/SvxTableShape.hxx>
 #include <com/sun/star/drawing/XShapes.hpp>
 #include <com/sun/star/awt/Rectangle.hpp>
+#include <com/sun/star/chart2/XChartDocument.hpp>
 #include <DataTable.hxx>
+#include "VLineProperties.hxx"
 
 namespace chart
 {
@@ -20,16 +22,23 @@ class VSeriesPlotter;
 
 class DataTableView final
 {
+private:
+    css::uno::Reference<css::chart2::XChartDocument> m_xChartModel;
     css::uno::Reference<css::drawing::XShapes> m_xTarget;
     rtl::Reference<SvxTableShape> m_xTableShape;
     rtl::Reference<DataTable> m_xDataTableModel;
+    VLineProperties m_aLineProperties;
 
     std::vector<OUString> m_aDataSeriesNames;
     std::vector<OUString> m_aXValues;
     std::vector<std::vector<OUString>> m_pDataSeriesValues;
 
+    void setCellDefaults(css::uno::Reference<css::beans::XPropertySet>& 
xPropertySet, bool bLeft,
+                         bool bTop, bool bRight, bool bBottom);
+
 public:
-    DataTableView(rtl::Reference<DataTable> const& rDataTableModel);
+    DataTableView(css::uno::Reference<css::chart2::XChartDocument> const& 
xChartDoc,
+                  rtl::Reference<DataTable> const& rDataTableModel);
     void initializeShapes(const css::uno::Reference<css::drawing::XShapes>& 
xTarget);
     void initializeValues(std::vector<std::unique_ptr<VSeriesPlotter>>& 
rSeriesPlotterList);
     void createShapes(basegfx::B2DVector const& rStart, basegfx::B2DVector 
const& rEnd,
diff --git a/chart2/source/view/main/DataTableView.cxx 
b/chart2/source/view/main/DataTableView.cxx
index 2928458397c0..729f034038d8 100644
--- a/chart2/source/view/main/DataTableView.cxx
+++ b/chart2/source/view/main/DataTableView.cxx
@@ -12,6 +12,7 @@
 #include <VSeriesPlotter.hxx>
 #include <ShapeFactory.hxx>
 #include <ExplicitCategoriesProvider.hxx>
+#include <ChartModel.hxx>
 
 #include <svx/svdotable.hxx>
 
@@ -19,10 +20,14 @@
 #include <com/sun/star/table/BorderLine.hpp>
 #include <com/sun/star/table/BorderLine2.hpp>
 #include <com/sun/star/table/TableBorder.hpp>
+#include <com/sun/star/table/BorderLineStyle.hpp>
 #include <com/sun/star/style/ParagraphAdjust.hpp>
 #include <com/sun/star/drawing/TextHorizontalAdjust.hpp>
 #include <com/sun/star/drawing/TextVerticalAdjust.hpp>
+#include <com/sun/star/drawing/LineDash.hpp>
+#include <com/sun/star/drawing/LineStyle.hpp>
 #include <com/sun/star/util/XBroadcaster.hpp>
+#include <com/sun/star/container/XNameContainer.hpp>
 
 #include <o3tl/unit_conversion.hxx>
 
@@ -30,15 +35,18 @@ using namespace css;
 
 namespace chart
 {
-DataTableView::DataTableView(rtl::Reference<DataTable> const& rDataTableModel)
-    : m_xDataTableModel(rDataTableModel)
+DataTableView::DataTableView(css::uno::Reference<css::chart2::XChartDocument> 
const& xChartDoc,
+                             rtl::Reference<DataTable> const& rDataTableModel)
+    : m_xChartModel(xChartDoc)
+    , m_xDataTableModel(rDataTableModel)
 {
+    uno::Reference<beans::XPropertySet> xProp(m_xDataTableModel);
+    m_aLineProperties.initFromPropertySet(xProp);
 }
 
 namespace
 {
-void setCellDefaults(uno::Reference<beans::XPropertySet>& xPropertySet, bool 
bLeft, bool bTop,
-                     bool bRight, bool bBottom)
+void setTopCell(uno::Reference<beans::XPropertySet>& xPropertySet)
 {
     xPropertySet->setPropertyValue("FillColor", uno::makeAny(Color(0xFFFFFF)));
     xPropertySet->setPropertyValue("TextVerticalAdjust",
@@ -46,34 +54,80 @@ void setCellDefaults(uno::Reference<beans::XPropertySet>& 
xPropertySet, bool bLe
     xPropertySet->setPropertyValue("ParaAdjust", 
uno::makeAny(style::ParagraphAdjust_CENTER));
 
     table::BorderLine2 aBorderLine;
-    aBorderLine.LineWidth = o3tl::convert(0.5, o3tl::Length::pt, 
o3tl::Length::mm100);
+    aBorderLine.LineWidth = 0;
     aBorderLine.Color = 0x000000;
 
-    if (bLeft)
-        xPropertySet->setPropertyValue("LeftBorder", 
uno::makeAny(aBorderLine));
-    if (bTop)
-        xPropertySet->setPropertyValue("TopBorder", uno::makeAny(aBorderLine));
-    if (bRight)
-        xPropertySet->setPropertyValue("RightBorder", 
uno::makeAny(aBorderLine));
-    if (bBottom)
-        xPropertySet->setPropertyValue("BottomBorder", 
uno::makeAny(aBorderLine));
+    xPropertySet->setPropertyValue("TopBorder", uno::makeAny(aBorderLine));
+    xPropertySet->setPropertyValue("LeftBorder", uno::makeAny(aBorderLine));
+}
 }
 
-void setTopCell(uno::Reference<beans::XPropertySet>& xPropertySet)
+void DataTableView::setCellDefaults(uno::Reference<beans::XPropertySet>& 
xPropertySet, bool bLeft,
+                                    bool bTop, bool bRight, bool bBottom)
 {
     xPropertySet->setPropertyValue("FillColor", uno::makeAny(Color(0xFFFFFF)));
     xPropertySet->setPropertyValue("TextVerticalAdjust",
                                    
uno::makeAny(drawing::TextVerticalAdjust_TOP));
     xPropertySet->setPropertyValue("ParaAdjust", 
uno::makeAny(style::ParagraphAdjust_CENTER));
 
-    table::BorderLine2 aBorderLine;
-    aBorderLine.LineWidth = 0;
-    aBorderLine.Color = 0x000000;
+    drawing::LineStyle eStyle = drawing::LineStyle_NONE;
+    m_aLineProperties.LineStyle >>= eStyle;
 
-    xPropertySet->setPropertyValue("TopBorder", uno::makeAny(aBorderLine));
-    xPropertySet->setPropertyValue("LeftBorder", uno::makeAny(aBorderLine));
-}
+    if (eStyle != drawing::LineStyle_NONE)
+    {
+        table::BorderLine2 aBorderLine;
+
+        sal_Int32 nWidth = 0;
+        m_aLineProperties.Width >>= nWidth;
+        aBorderLine.LineWidth = o3tl::convert(nWidth, o3tl::Length::mm100, 
o3tl::Length::twip);
+
+        sal_Int32 nColor = 0;
+        m_aLineProperties.Color >>= nColor;
+        aBorderLine.Color = nColor;
+
+        aBorderLine.LineStyle = table::BorderLineStyle::SOLID;
+
+        if (eStyle == drawing::LineStyle_DASH)
+        {
+            OUString aDashName;
+            m_aLineProperties.DashName >>= aDashName;
+            uno::Reference<lang::XMultiServiceFactory> xFactory(m_xChartModel, 
uno::UNO_QUERY);
+            if (!aDashName.isEmpty() && xFactory.is())
+            {
+                uno::Reference<container::XNameContainer> xDashTable(
+                    
xFactory->createInstance("com.sun.star.drawing.DashTable"), uno::UNO_QUERY);
+                if (xDashTable.is() && xDashTable->hasByName(aDashName))
+                {
+                    drawing::LineDash aLineDash;
+                    xDashTable->getByName(aDashName) >>= aLineDash;
+
+                    if (aLineDash.Dots == 0 && aLineDash.Dashes == 0)
+                        aBorderLine.LineStyle = table::BorderLineStyle::SOLID;
+                    else if (aLineDash.Dots == 1 && aLineDash.Dashes == 0)
+                        aBorderLine.LineStyle = table::BorderLineStyle::DOTTED;
+                    else if (aLineDash.Dots == 0 && aLineDash.Dashes == 1)
+                        aBorderLine.LineStyle = table::BorderLineStyle::DASHED;
+                    else if (aLineDash.Dots == 1 && aLineDash.Dashes == 1)
+                        aBorderLine.LineStyle = 
table::BorderLineStyle::DASH_DOT;
+                    else if (aLineDash.Dots == 2 && aLineDash.Dashes == 1)
+                        aBorderLine.LineStyle = 
table::BorderLineStyle::DASH_DOT_DOT;
+                    else
+                        aBorderLine.LineStyle = table::BorderLineStyle::DASHED;
+                }
+            }
+        }
+
+        if (bLeft)
+            xPropertySet->setPropertyValue("LeftBorder", 
uno::makeAny(aBorderLine));
+        if (bTop)
+            xPropertySet->setPropertyValue("TopBorder", 
uno::makeAny(aBorderLine));
+        if (bRight)
+            xPropertySet->setPropertyValue("RightBorder", 
uno::makeAny(aBorderLine));
+        if (bBottom)
+            xPropertySet->setPropertyValue("BottomBorder", 
uno::makeAny(aBorderLine));
+    }
 }
+
 void DataTableView::createShapes(basegfx::B2DVector const& rStart, 
basegfx::B2DVector const& rEnd,
                                  sal_Int32 nColumnWidth)
 {
commit 0dfd9d29f8cecf494a74fa149673fefd39acdc44
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Fri May 20 18:39:34 2022 +0900
Commit:     Tomaž Vajngerl <qui...@gmail.com>
CommitDate: Thu Aug 18 08:51:14 2022 +0200

    chart2: better readable DataTable properties definition
    
    Change-Id: Ib9cadee39f58b73782e6a3268d86b688183de1fb
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137157
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <qui...@gmail.com>
    (cherry picked from commit 14553d280ad76c3436d394e900002c63de7b6e51)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138439
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>

diff --git a/chart2/source/model/main/DataTable.cxx 
b/chart2/source/model/main/DataTable.cxx
index c1bc742df82c..aa2d27a6a619 100644
--- a/chart2/source/model/main/DataTable.cxx
+++ b/chart2/source/model/main/DataTable.cxx
@@ -34,20 +34,19 @@ enum
     DataTableProperty_Keys,
 };
 
-void lcl_AddPropertiesToVector(std::vector<beans::Property>& rOutProperties)
-{
-    rOutProperties.emplace_back(
-        "HBorder", DataTableProperty_HorizontalBorder, 
cppu::UnoType<bool>::get(),
-        beans::PropertyAttribute::BOUND | 
beans::PropertyAttribute::MAYBEDEFAULT);
-    rOutProperties.emplace_back(
-        "VBorder", DataTableProperty_VerticalBorder, 
cppu::UnoType<bool>::get(),
-        beans::PropertyAttribute::BOUND | 
beans::PropertyAttribute::MAYBEDEFAULT);
-    rOutProperties.emplace_back("Outline", DataTableProperty_Outilne, 
cppu::UnoType<bool>::get(),
-                                beans::PropertyAttribute::BOUND
-                                    | beans::PropertyAttribute::MAYBEDEFAULT);
-    rOutProperties.emplace_back("Keys", DataTableProperty_Keys, 
cppu::UnoType<bool>::get(),
-                                beans::PropertyAttribute::BOUND
-                                    | beans::PropertyAttribute::MAYBEDEFAULT);
+void lcl_AddPropertiesToVector(std::vector<beans::Property>& rProps)
+{
+    auto const nBound = beans::PropertyAttribute::BOUND;
+    auto const nMaybeDefault = beans::PropertyAttribute::MAYBEDEFAULT;
+
+    rProps.emplace_back("HBorder", DataTableProperty_HorizontalBorder, 
cppu::UnoType<bool>::get(),
+                        nBound | nMaybeDefault);
+    rProps.emplace_back("VBorder", DataTableProperty_VerticalBorder, 
cppu::UnoType<bool>::get(),
+                        nBound | nMaybeDefault);
+    rProps.emplace_back("Outline", DataTableProperty_Outilne, 
cppu::UnoType<bool>::get(),
+                        nBound | nMaybeDefault);
+    rProps.emplace_back("Keys", DataTableProperty_Keys, 
cppu::UnoType<bool>::get(),
+                        nBound | nMaybeDefault);
 }
 
 struct StaticDataTableDefaults_Initializer

Reply via email to