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

Balazs Varga (via logerrit) logerrit at kemper.freedesktop.org
Fri Apr 24 14:00:17 UTC 2020


 chart2/qa/extras/chart2import.cxx              |   24 ++++++++++++++++++++++++
 chart2/qa/extras/data/docx/tdf132174.docx      |binary
 oox/source/drawingml/chart/seriesconverter.cxx |    4 ++++
 3 files changed, 28 insertions(+)

New commits:
commit e0da00d655ecca5986eea3812a8a670c6adbc40f
Author:     Balazs Varga <balazs.varga991 at gmail.com>
AuthorDate: Wed Apr 22 14:41:49 2020 +0200
Commit:     László Németh <nemeth at numbertext.org>
CommitDate: Fri Apr 24 15:59:41 2020 +0200

    tdf#132174 Chart DOCX import: fix label number format
    
    The inner data table of charts has no own cell number format,
    unlike the MSO embedded XLSX, so we always have to set the link
    number format to false, if we have an inner data table.
    
    Regression from commit: 9c1063ba13028244346528e307d5563d6faf949d
    (tdf#129173 tdf#129175 Fix number format of data labels)
    
    Change-Id: I5e7865cb8c19fc6fae5b68305c7dc302516c0ad4
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92695
    Tested-by: Jenkins
    Tested-by: László Németh <nemeth at numbertext.org>
    Reviewed-by: Tünde Tóth <tundeth at gmail.com>
    Reviewed-by: László Németh <nemeth at numbertext.org>

diff --git a/chart2/qa/extras/chart2import.cxx b/chart2/qa/extras/chart2import.cxx
index 4a7ccb373685..844d7208bac0 100644
--- a/chart2/qa/extras/chart2import.cxx
+++ b/chart2/qa/extras/chart2import.cxx
@@ -90,6 +90,7 @@ public:
     // void testTextCanOverlapXLSX(); // TODO : temporarily disabled.
     void testTextBreakXLSX();
     void testNumberFormatsXLSX();
+    void testNumberFormatsDOCX();
 
     void testTransparentBackground(OUString const & filename);
 
@@ -204,6 +205,7 @@ public:
     // CPPUNIT_TEST(testTextCanOverlapXLSX); // TODO : temporarily disabled.
     CPPUNIT_TEST(testTextBreakXLSX);
     CPPUNIT_TEST(testNumberFormatsXLSX);
+    CPPUNIT_TEST(testNumberFormatsDOCX);
     CPPUNIT_TEST(testAutoTitleDelDefaultValue2007XLSX);
     CPPUNIT_TEST(testAutoTitleDelDefaultValue2013XLSX);
     CPPUNIT_TEST(testDispBlanksAsDefaultValue2007XLSX);
@@ -1284,6 +1286,28 @@ void Chart2ImportTest::testNumberFormatsXLSX()
     CPPUNIT_ASSERT_MESSAGE("\"LinkNumberFormatToSource\" should be set to true.", bSuccess && bLinkNumberFormatToSource);
 }
 
+void Chart2ImportTest::testNumberFormatsDOCX()
+{
+    load("/chart2/qa/extras/data/docx/", "tdf132174.docx");
+    uno::Reference< chart2::XChartDocument > xChartDoc(getChartDocFromWriter(0), uno::UNO_QUERY);
+    CPPUNIT_ASSERT(xChartDoc.is());
+
+    css::uno::Reference<chart2::XDiagram> xDiagram(xChartDoc->getFirstDiagram(), UNO_SET_THROW);
+    Reference<chart2::XDataSeries> xDataSeries = getDataSeriesFromDoc(xChartDoc, 0);
+    uno::Reference<beans::XPropertySet> xPropertySet(xDataSeries, uno::UNO_QUERY_THROW);
+    CPPUNIT_ASSERT(xPropertySet.is());
+
+    sal_Int32 nNumberFormat;
+    bool bLinkNumberFormatToSource = true;
+    const sal_Int32 nChartDataNumberFormat = getNumberFormat(xChartDoc, "0%");
+    xPropertySet->getPropertyValue(CHART_UNONAME_NUMFMT) >>= nNumberFormat;
+    CPPUNIT_ASSERT_EQUAL(nChartDataNumberFormat, nNumberFormat);
+    xPropertySet->getPropertyValue(CHART_UNONAME_LINK_TO_SRC_NUMFMT) >>= bLinkNumberFormatToSource;
+    // LinkNumberFormatToSource should be set to false even if the OOXML contain a true value,
+    // because the inner data table of charts have no own number format!
+    CPPUNIT_ASSERT_MESSAGE("\"LinkNumberFormatToSource\" should be set to false.", !bLinkNumberFormatToSource);
+}
+
 void Chart2ImportTest::testAutoTitleDelDefaultValue2007XLSX()
 {
     load("/chart2/qa/extras/data/xlsx/", "autotitledel_2007.xlsx");
diff --git a/chart2/qa/extras/data/docx/tdf132174.docx b/chart2/qa/extras/data/docx/tdf132174.docx
new file mode 100644
index 000000000000..4f43695784fb
Binary files /dev/null and b/chart2/qa/extras/data/docx/tdf132174.docx differ
diff --git a/oox/source/drawingml/chart/seriesconverter.cxx b/oox/source/drawingml/chart/seriesconverter.cxx
index 01e004f45c59..b12f4416100b 100644
--- a/oox/source/drawingml/chart/seriesconverter.cxx
+++ b/oox/source/drawingml/chart/seriesconverter.cxx
@@ -23,6 +23,7 @@
 #include <com/sun/star/chart2/RelativePosition.hpp>
 #include <com/sun/star/chart/ErrorBarStyle.hpp>
 #include <com/sun/star/chart2/DataPointLabel.hpp>
+#include <com/sun/star/chart2/XChartDocument.hpp>
 #include <com/sun/star/chart2/XDataPointCustomLabelField.hpp>
 #include <com/sun/star/chart2/DataPointCustomLabelField.hpp>
 #include <com/sun/star/chart2/DataPointCustomLabelFieldType.hpp>
@@ -323,6 +324,9 @@ void DataLabelsConverter::convertFromModel( const Reference< XDataSeries >& rxDa
     if( !mrModel.mbDeleted )
     {
         bool bMSO2007Doc = getFilter().isMSO2007Document();
+        // tdf#132174: the inner data table has no own cell number format.
+        if( getChartDocument()->hasInternalDataProvider() )
+            mrModel.maNumberFormat.mbSourceLinked = false;
         lclConvertLabelFormatting( aPropSet, getFormatter(), mrModel, rTypeGroup, true, bMSO2007Doc );
 
         if (mrModel.mxShapeProp)


More information about the Libreoffice-commits mailing list