[Libreoffice-commits] core.git: Branch 'libreoffice-6-4' - chart2/qa oox/source

Balazs Varga (via logerrit) logerrit at kemper.freedesktop.org
Tue Apr 28 12:57:28 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 d1466728e243b706d4fae2c5eeef2ee867ec4a89
Author:     Balazs Varga <balazs.varga991 at gmail.com>
AuthorDate: Wed Apr 22 14:41:49 2020 +0200
Commit:     Xisco Faulí <xiscofauli at libreoffice.org>
CommitDate: Tue Apr 28 14:56:57 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>
    (cherry picked from commit e0da00d655ecca5986eea3812a8a670c6adbc40f)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93007
    Reviewed-by: Xisco Faulí <xiscofauli at libreoffice.org>

diff --git a/chart2/qa/extras/chart2import.cxx b/chart2/qa/extras/chart2import.cxx
index e637c3272d33..a2b77a851002 100644
--- a/chart2/qa/extras/chart2import.cxx
+++ b/chart2/qa/extras/chart2import.cxx
@@ -88,6 +88,7 @@ public:
     // void testTextCanOverlapXLSX(); // TODO : temporarily disabled.
     void testTextBreakXLSX();
     void testNumberFormatsXLSX();
+    void testNumberFormatsDOCX();
 
     void testTransparentBackground(OUString const & filename);
 
@@ -200,6 +201,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);
@@ -1267,6 +1269,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 1a3936ecb2c9..02479b80ec46 100644
--- a/oox/source/drawingml/chart/seriesconverter.cxx
+++ b/oox/source/drawingml/chart/seriesconverter.cxx
@@ -22,6 +22,7 @@
 #include <com/sun/star/chart/DataLabelPlacement.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>
@@ -371,6 +372,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