diff options
author | Balazs Varga <balazs.varga991@gmail.com> | 2020-03-16 15:44:06 +0100 |
---|---|---|
committer | László Németh <nemeth@numbertext.org> | 2020-03-20 11:44:46 +0100 |
commit | 9f3623ce21a89e026128f85b4a09a40757754090 (patch) | |
tree | cd54e4019676dc88b3849f1f86cff133b03d72ae | |
parent | 3b250f0c009476cfe7d35ebd1d8220ceac440791 (diff) |
tdf#131398 OOXML chart import: fix number format of pie chart labels
Remove percentage format detection heuristics, which converted the
plain number format with percentage style to percentage format based
on the formatted string, resulting bad pie chart labels.
Change-Id: I642394d04fd6e6a5439bd53207e08e75de5b3029
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90570
Tested-by: László Németh <nemeth@numbertext.org>
Reviewed-by: László Németh <nemeth@numbertext.org>
-rw-r--r-- | chart2/qa/extras/chart2import.cxx | 14 | ||||
-rw-r--r-- | chart2/qa/extras/data/xlsx/tdfPieNumFormat.xlsx | bin | 0 -> 13917 bytes | |||
-rw-r--r-- | oox/source/drawingml/chart/seriesconverter.cxx | 7 |
3 files changed, 14 insertions, 7 deletions
diff --git a/chart2/qa/extras/chart2import.cxx b/chart2/qa/extras/chart2import.cxx index 68a142090805..4a7ccb373685 100644 --- a/chart2/qa/extras/chart2import.cxx +++ b/chart2/qa/extras/chart2import.cxx @@ -61,6 +61,7 @@ public: */ void testPPTXHiddenDataSeries(); void testPPTXPercentageNumberFormats(); + void testPieChartLabelsNumFormat(); void testPPTXStackedNonStackedYAxis(); void testPPTChartSeries(); void testODPChartSeries(); @@ -175,6 +176,7 @@ public: CPPUNIT_TEST(testPPTXSparseChartSeries); CPPUNIT_TEST(testPPTXHiddenDataSeries); CPPUNIT_TEST(testPPTXPercentageNumberFormats); + CPPUNIT_TEST(testPieChartLabelsNumFormat); CPPUNIT_TEST(testPPTXStackedNonStackedYAxis); CPPUNIT_TEST(testODPChartSeries); CPPUNIT_TEST(testBnc864396); @@ -710,6 +712,18 @@ void Chart2ImportTest::testPPTXPercentageNumberFormats() CPPUNIT_ASSERT_MESSAGE("Y axis should be a percent format.", (nType & util::NumberFormat::PERCENT)); } +void Chart2ImportTest::testPieChartLabelsNumFormat() +{ + load("/chart2/qa/extras/data/xlsx/", "tdfPieNumFormat.xlsx"); + uno::Reference< chart::XChartDocument > xChartDoc(getChartCompFromSheet(0, mxComponent), UNO_QUERY_THROW); + CPPUNIT_ASSERT(xChartDoc.is()); + // test data point labels format + Reference<beans::XPropertySet> xDataPointPropSet(xChartDoc->getDiagram()->getDataPointProperties(0, 0), uno::UNO_SET_THROW); + chart2::DataPointLabel aLabel; + xDataPointPropSet->getPropertyValue("Label") >>= aLabel; + CPPUNIT_ASSERT_EQUAL(sal_True, aLabel.ShowNumber); +} + void Chart2ImportTest::testPPTXStackedNonStackedYAxis() { load("/chart2/qa/extras/data/pptx/", "stacked-non-stacked-mix-y-axis.pptx"); diff --git a/chart2/qa/extras/data/xlsx/tdfPieNumFormat.xlsx b/chart2/qa/extras/data/xlsx/tdfPieNumFormat.xlsx Binary files differnew file mode 100644 index 000000000000..0835cb33325b --- /dev/null +++ b/chart2/qa/extras/data/xlsx/tdfPieNumFormat.xlsx diff --git a/oox/source/drawingml/chart/seriesconverter.cxx b/oox/source/drawingml/chart/seriesconverter.cxx index 6ade0b4cfd07..f063019b8327 100644 --- a/oox/source/drawingml/chart/seriesconverter.cxx +++ b/oox/source/drawingml/chart/seriesconverter.cxx @@ -124,13 +124,6 @@ void lclConvertLabelFormatting( PropertySet& rPropSet, ObjectFormatter& rFormatt bool bShowValue = !rDataLabel.mbDeleted && rDataLabel.mobShowVal.get( !bMSO2007Doc ); bool bShowPercent = !rDataLabel.mbDeleted && rDataLabel.mobShowPercent.get( !bMSO2007Doc ) && (rTypeInfo.meTypeCategory == TYPECATEGORY_PIE); - if( bShowValue && - !bShowPercent && rTypeInfo.meTypeCategory == TYPECATEGORY_PIE && - rDataLabel.maNumberFormat.maFormatCode.indexOf('%') >= 0 ) - { - bShowValue = false; - bShowPercent = true; - } bool bShowCateg = !rDataLabel.mbDeleted && rDataLabel.mobShowCatName.get( !bMSO2007Doc ); bool bShowSymbol = !rDataLabel.mbDeleted && rDataLabel.mobShowLegendKey.get( !bMSO2007Doc ); |