diff options
author | Balazs Varga <balazs.varga991@gmail.com> | 2020-09-15 16:50:45 +0200 |
---|---|---|
committer | László Németh <nemeth@numbertext.org> | 2020-09-22 11:24:42 +0200 |
commit | e4d3ad9fe640e71cf3bb4c969b75ebc17ce8e335 (patch) | |
tree | f3d66c9b142d5f10d6f2bc34009a76a65b52c550 /chart2 | |
parent | 16e6f8ebe40aceec71466deb7b6b91c4eeb62007 (diff) |
tdf#136650 DOCX pie chart import: fix percentage
Follow-up of commit e0da00d655ecca5986eea3812a8a670c6adbc40f
(tdf#132174 Chart DOCX import: fix label number format).
Change-Id: Ie0b2fe6305d7696de6dddc1f17d078fc2e749e4e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102753
Tested-by: László Németh <nemeth@numbertext.org>
Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'chart2')
-rw-r--r-- | chart2/qa/extras/chart2import.cxx | 55 | ||||
-rw-r--r-- | chart2/qa/extras/data/docx/tdf136650.docx | bin | 0 -> 25543 bytes |
2 files changed, 39 insertions, 16 deletions
diff --git a/chart2/qa/extras/chart2import.cxx b/chart2/qa/extras/chart2import.cxx index 651d2b829e06..fe0a2c48231e 100644 --- a/chart2/qa/extras/chart2import.cxx +++ b/chart2/qa/extras/chart2import.cxx @@ -1303,23 +1303,46 @@ void Chart2ImportTest::testNumberFormatsXLSX() 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()); + { + 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 original 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); + } - 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); + load("/chart2/qa/extras/data/docx/", "tdf136650.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); + CPPUNIT_ASSERT(xDataSeries.is()); + Reference<beans::XPropertySet> xPropertySet(xDataSeries->getDataPointByIndex(1), uno::UNO_SET_THROW); + + 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 original OOXML file 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::testPercentageNumberFormatsDOCX() diff --git a/chart2/qa/extras/data/docx/tdf136650.docx b/chart2/qa/extras/data/docx/tdf136650.docx Binary files differnew file mode 100644 index 000000000000..cd095ec63110 --- /dev/null +++ b/chart2/qa/extras/data/docx/tdf136650.docx |