Skip to content

Commit 9f3623c

Browse files
bvarga91laszlonemeth
authored andcommitted
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 <[email protected]> Reviewed-by: László Németh <[email protected]>
1 parent 3b250f0 commit 9f3623c

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

chart2/qa/extras/chart2import.cxx

+14
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ class Chart2ImportTest : public ChartTest
6161
*/
6262
void testPPTXHiddenDataSeries();
6363
void testPPTXPercentageNumberFormats();
64+
void testPieChartLabelsNumFormat();
6465
void testPPTXStackedNonStackedYAxis();
6566
void testPPTChartSeries();
6667
void testODPChartSeries();
@@ -175,6 +176,7 @@ class Chart2ImportTest : public ChartTest
175176
CPPUNIT_TEST(testPPTXSparseChartSeries);
176177
CPPUNIT_TEST(testPPTXHiddenDataSeries);
177178
CPPUNIT_TEST(testPPTXPercentageNumberFormats);
179+
CPPUNIT_TEST(testPieChartLabelsNumFormat);
178180
CPPUNIT_TEST(testPPTXStackedNonStackedYAxis);
179181
CPPUNIT_TEST(testODPChartSeries);
180182
CPPUNIT_TEST(testBnc864396);
@@ -710,6 +712,18 @@ void Chart2ImportTest::testPPTXPercentageNumberFormats()
710712
CPPUNIT_ASSERT_MESSAGE("Y axis should be a percent format.", (nType & util::NumberFormat::PERCENT));
711713
}
712714

715+
void Chart2ImportTest::testPieChartLabelsNumFormat()
716+
{
717+
load("/chart2/qa/extras/data/xlsx/", "tdfPieNumFormat.xlsx");
718+
uno::Reference< chart::XChartDocument > xChartDoc(getChartCompFromSheet(0, mxComponent), UNO_QUERY_THROW);
719+
CPPUNIT_ASSERT(xChartDoc.is());
720+
// test data point labels format
721+
Reference<beans::XPropertySet> xDataPointPropSet(xChartDoc->getDiagram()->getDataPointProperties(0, 0), uno::UNO_SET_THROW);
722+
chart2::DataPointLabel aLabel;
723+
xDataPointPropSet->getPropertyValue("Label") >>= aLabel;
724+
CPPUNIT_ASSERT_EQUAL(sal_True, aLabel.ShowNumber);
725+
}
726+
713727
void Chart2ImportTest::testPPTXStackedNonStackedYAxis()
714728
{
715729
load("/chart2/qa/extras/data/pptx/", "stacked-non-stacked-mix-y-axis.pptx");
13.6 KB
Binary file not shown.

oox/source/drawingml/chart/seriesconverter.cxx

-7
Original file line numberDiff line numberDiff line change
@@ -124,13 +124,6 @@ void lclConvertLabelFormatting( PropertySet& rPropSet, ObjectFormatter& rFormatt
124124

125125
bool bShowValue = !rDataLabel.mbDeleted && rDataLabel.mobShowVal.get( !bMSO2007Doc );
126126
bool bShowPercent = !rDataLabel.mbDeleted && rDataLabel.mobShowPercent.get( !bMSO2007Doc ) && (rTypeInfo.meTypeCategory == TYPECATEGORY_PIE);
127-
if( bShowValue &&
128-
!bShowPercent && rTypeInfo.meTypeCategory == TYPECATEGORY_PIE &&
129-
rDataLabel.maNumberFormat.maFormatCode.indexOf('%') >= 0 )
130-
{
131-
bShowValue = false;
132-
bShowPercent = true;
133-
}
134127
bool bShowCateg = !rDataLabel.mbDeleted && rDataLabel.mobShowCatName.get( !bMSO2007Doc );
135128
bool bShowSymbol = !rDataLabel.mbDeleted && rDataLabel.mobShowLegendKey.get( !bMSO2007Doc );
136129

0 commit comments

Comments
 (0)