chart2/source/view/axes/VAxisBase.cxx                  |    3 
 chart2/source/view/axes/VAxisBase.hxx                  |    4 
 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 +++++++++++++----
 svx/CppunitTest_svx_core.mk                            |    1 
 svx/qa/unit/core.cxx                                   |   44 +++++++
 svx/qa/unit/data/GraphicObjectResolverTest.zip         |binary
 svx/source/xml/xmlgrhlp.cxx                            |    7 -
 11 files changed, 145 insertions(+), 30 deletions(-)

New commits:
commit d449da36086409e3cc440036193c4fc8a10a37a1
Author:     Tomaž Vajngerl <[email protected]>
AuthorDate: Wed Jul 20 22:01:31 2022 +0200
Commit:     Tomaž Vajngerl <[email protected]>
CommitDate: Thu Jul 21 09:01:51 2022 +0200

    tdf#123983 fix loading graphic that is in root folder + test
    
    We need to detect that the storage name is empty, so in that case
    the root storage needs to be set as the current storage.
    
    Change-Id: Ibe3287ccf1f1513a3531dcf4d540a456cca8dfb1
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137276
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <[email protected]>

diff --git a/svx/CppunitTest_svx_core.mk b/svx/CppunitTest_svx_core.mk
index aac47ba1db0c..67445767cc1d 100644
--- a/svx/CppunitTest_svx_core.mk
+++ b/svx/CppunitTest_svx_core.mk
@@ -22,6 +22,7 @@ $(eval $(call gb_CppunitTest_add_exception_objects,svx_core, \
 $(eval $(call gb_CppunitTest_use_libraries,svx_core, \
     comphelper \
     cppu \
+    cppuhelper \
     sal \
     svx \
     svxcore \
diff --git a/svx/qa/unit/core.cxx b/svx/qa/unit/core.cxx
index 7ec74da33859..27e5783e20db 100644
--- a/svx/qa/unit/core.cxx
+++ b/svx/qa/unit/core.cxx
@@ -9,11 +9,14 @@
 
 #include <test/bootstrapfixture.hxx>
 #include <unotest/macros_test.hxx>
-
+#include <com/sun/star/embed/XStorage.hpp>
 #include <com/sun/star/frame/Desktop.hpp>
 #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
 
+#include <comphelper/storagehelper.hxx>
+
 #include <svx/graphichelper.hxx>
+#include <svx/xmlgrhlp.hxx>
 #include <unotools/tempfile.hxx>
 #include <vcl/filter/PDFiumLibrary.hxx>
 
@@ -77,6 +80,45 @@ CPPUNIT_TEST_FIXTURE(Test, testChartExportToPdf)
     int nPageCount = pPdfDocument->getPageCount();
     CPPUNIT_ASSERT_GREATER(0, nPageCount);
 }
+
+CPPUNIT_TEST_FIXTURE(Test, testGraphicObjectResolver)
+{
+    OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + 
"GraphicObjectResolverTest.zip";
+    uno::Reference<embed::XStorage> xStorage
+        = 
comphelper::OStorageHelper::GetStorageOfFormatFromURL(ZIP_STORAGE_FORMAT_STRING,
 aURL,
+                                                                
embed::ElementModes::READWRITE);
+    CPPUNIT_ASSERT(xStorage.is());
+
+    rtl::Reference<SvXMLGraphicHelper> xGraphicHelper
+        = SvXMLGraphicHelper::Create(xStorage, SvXMLGraphicHelperMode::Read);
+    CPPUNIT_ASSERT(xGraphicHelper.is());
+
+    // Test name in root folder
+    {
+        uno::Reference<graphic::XGraphic> xGraphic = 
xGraphicHelper->loadGraphic("SomeImage.png");
+        CPPUNIT_ASSERT_EQUAL(true, xGraphic.is());
+    }
+
+    // Test name in sub-folder
+    {
+        uno::Reference<graphic::XGraphic> xGraphic
+            = xGraphicHelper->loadGraphic("Pictures/SomeOtherImage.png");
+        CPPUNIT_ASSERT_EQUAL(true, xGraphic.is());
+    }
+
+    // Test non-existent name
+    {
+        uno::Reference<graphic::XGraphic> xGraphic;
+        try
+        {
+            xGraphic = xGraphicHelper->loadGraphic("NoneExistent.png");
+        }
+        catch (const uno::Exception&)
+        {
+        }
+        CPPUNIT_ASSERT_EQUAL(false, xGraphic.is());
+    }
+}
 }
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/svx/qa/unit/data/GraphicObjectResolverTest.zip 
b/svx/qa/unit/data/GraphicObjectResolverTest.zip
new file mode 100644
index 000000000000..4c19bf2b01b7
Binary files /dev/null and b/svx/qa/unit/data/GraphicObjectResolverTest.zip 
differ
diff --git a/svx/source/xml/xmlgrhlp.cxx b/svx/source/xml/xmlgrhlp.cxx
index 6c5c76bfce73..6c12aa4bee2b 100644
--- a/svx/source/xml/xmlgrhlp.cxx
+++ b/svx/source/xml/xmlgrhlp.cxx
@@ -390,7 +390,7 @@ bool SvXMLGraphicHelper::ImplGetStreamNames( const 
OUString& rURLStr,
 
     if( !aURLStr.isEmpty() && aURLStr.indexOf('/')<0 ) // just one token?
     {
-        rPictureStorageName = XML_GRAPHICSTORAGE_NAME;
+        rPictureStorageName = OUString();
         rPictureStreamName = aURLStr;
     }
     else
@@ -439,7 +439,10 @@ SvxGraphicHelperStream_Impl 
SvXMLGraphicHelper::ImplGetGraphicStream( const OUSt
                                                               const OUString& 
rPictureStreamName )
 {
     SvxGraphicHelperStream_Impl aRet;
-    aRet.xStorage = ImplGetGraphicStorage( rPictureStorageName );
+    if (!rPictureStorageName.isEmpty())
+        aRet.xStorage = ImplGetGraphicStorage(rPictureStorageName);
+    else
+        aRet.xStorage = mxRootStorage;
 
     sal_Int32 nMode = embed::ElementModes::READ;
     if (SvXMLGraphicHelperMode::Write == meCreateMode)
commit 6c24f112ad86df77f2de27a31742bca01ed56bdf
Author:     Tomaž Vajngerl <[email protected]>
AuthorDate: Fri May 20 23:55:45 2022 +0900
Commit:     Tomaž Vajngerl <[email protected]>
CommitDate: Thu Jul 21 09:01:27 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 <[email protected]>

diff --git a/chart2/source/view/axes/VAxisBase.cxx 
b/chart2/source/view/axes/VAxisBase.cxx
index 95125beed1cf..7d985051a4a7 100644
--- a/chart2/source/view/axes/VAxisBase.cxx
+++ b/chart2/source/view/axes/VAxisBase.cxx
@@ -243,7 +243,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*/,
+                                    rtl::Reference<::chart::ChartModel> const& 
/*xChartDoc*/)
 {
 }
 
diff --git a/chart2/source/view/axes/VAxisBase.hxx 
b/chart2/source/view/axes/VAxisBase.hxx
index 4da1936a452b..2c4123ba951d 100644
--- a/chart2/source/view/axes/VAxisBase.hxx
+++ b/chart2/source/view/axes/VAxisBase.hxx
@@ -29,6 +29,7 @@ namespace chart
 
 class VSeriesPlotter;
 class DataTableView;
+class ChartModel;
 
 class VAxisBase : public VAxisOrGridBase
 {
@@ -63,7 +64,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,
+                                     rtl::Reference<::chart::ChartModel> 
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 096586279454..d7e78d5d2e85 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 <comphelper/scopeguard.hxx>
 
@@ -1993,11 +1994,12 @@ void VCartesianAxis::createShapes()
 }
 
 void 
VCartesianAxis::createDataTableView(std::vector<std::unique_ptr<VSeriesPlotter>>&
 rSeriesPlotterList,
-                                         
Reference<util::XNumberFormatsSupplier> const& xNumberFormatsSupplier)
+                                         
Reference<util::XNumberFormatsSupplier> const& xNumberFormatsSupplier,
+                                         rtl::Reference<::chart::ChartModel> 
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 9f396fef43b8..a9baca907bdd 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,
+                             rtl::Reference<::chart::ChartModel> 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 cd0d49188a1c..3ea42cb087a0 100644
--- a/chart2/source/view/axes/VCartesianCoordinateSystem.cxx
+++ b/chart2/source/view/axes/VCartesianCoordinateSystem.cxx
@@ -166,7 +166,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 3f4d97629035..8a0f11bed772 100644
--- a/chart2/source/view/inc/DataTableView.hxx
+++ b/chart2/source/view/inc/DataTableView.hxx
@@ -13,23 +13,32 @@
 #include <svx/unodraw/SvxTableShape.hxx>
 #include <com/sun/star/awt/Rectangle.hpp>
 #include <DataTable.hxx>
+#include "VLineProperties.hxx"
 
 namespace chart
 {
 class VSeriesPlotter;
+class ChartModel;
 
 class DataTableView final
 {
+private:
+    rtl::Reference<::chart::ChartModel> m_xChartModel;
     rtl::Reference<SvxShapeGroupAnyD> 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(rtl::Reference<::chart::ChartModel> const& xChartDoc,
+                  rtl::Reference<DataTable> const& rDataTableModel);
     void initializeShapes(const rtl::Reference<SvxShapeGroupAnyD>& 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 7b7fb60132ef..55a3b8628c50 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,48 +35,97 @@ using namespace css;
 
 namespace chart
 {
-DataTableView::DataTableView(rtl::Reference<DataTable> const& rDataTableModel)
-    : m_xDataTableModel(rDataTableModel)
+DataTableView::DataTableView(rtl::Reference<::chart::ChartModel> const& 
xChartModel,
+                             rtl::Reference<DataTable> const& rDataTableModel)
+    : m_xChartModel(xChartModel)
+    , 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::Any(Color(0xFFFFFF)));
     xPropertySet->setPropertyValue("TextVerticalAdjust", 
uno::Any(drawing::TextVerticalAdjust_TOP));
     xPropertySet->setPropertyValue("ParaAdjust", 
uno::Any(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::Any(aBorderLine));
-    if (bTop)
-        xPropertySet->setPropertyValue("TopBorder", uno::Any(aBorderLine));
-    if (bRight)
-        xPropertySet->setPropertyValue("RightBorder", uno::Any(aBorderLine));
-    if (bBottom)
-        xPropertySet->setPropertyValue("BottomBorder", uno::Any(aBorderLine));
+    xPropertySet->setPropertyValue("TopBorder", uno::Any(aBorderLine));
+    xPropertySet->setPropertyValue("LeftBorder", uno::Any(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::Any(Color(0xFFFFFF)));
     xPropertySet->setPropertyValue("TextVerticalAdjust", 
uno::Any(drawing::TextVerticalAdjust_TOP));
     xPropertySet->setPropertyValue("ParaAdjust", 
uno::Any(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::Any(aBorderLine));
-    xPropertySet->setPropertyValue("LeftBorder", uno::Any(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;
+            if (!aDashName.isEmpty() && m_xChartModel.is())
+            {
+                uno::Reference<container::XNameContainer> xDashTable(
+                    
m_xChartModel->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::Any(aBorderLine));
+        if (bTop)
+            xPropertySet->setPropertyValue("TopBorder", uno::Any(aBorderLine));
+        if (bRight)
+            xPropertySet->setPropertyValue("RightBorder", 
uno::Any(aBorderLine));
+        if (bBottom)
+            xPropertySet->setPropertyValue("BottomBorder", 
uno::Any(aBorderLine));
+    }
 }
+
 void DataTableView::createShapes(basegfx::B2DVector const& rStart, 
basegfx::B2DVector const& rEnd,
                                  sal_Int32 nColumnWidth)
 {

Reply via email to