summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorBalazs Varga <balazs.varga991@gmail.com>2019-11-14 15:02:35 +0100
committerLászló Németh <nemeth@numbertext.org>2019-11-22 08:03:55 +0100
commitc0cd2d4e0fa70d6eaf3cd3929bc0ad4786e9f4ed (patch)
treecd0372ee71feadf2f0438e3f2bd502b994e890db /oox
parent3cccdabf19a99fd3f657985c1822436d7679df2b (diff)
tdf#123774 OOXML chart export: keep digits of percentages of data points
by exporting PercentageNumberFormat, checking the "Label" format directly and taking the respective number format based on that. Note: also fix the "LinkNumberFormatToSource" property. If we create a pie chart with data labels and set the "Show value as number" or "Show value as percentage" and check on/off "Source format", this move is not set the property in the XPropertySet. Because of this, it fixes also the export of correct value of "link-data-style-to-source" property into ODS files. But this patch doesn't fix the export of old ODS files to OOXML, because they contain wrong (always true) "link-data-style-to-source" value. Change-Id: I4098a245dec5bf35cde20c9ccb79aca726230118 Reviewed-on: https://gerrit.libreoffice.org/82703 Reviewed-by: László Németh <nemeth@numbertext.org> Tested-by: László Németh <nemeth@numbertext.org> (cherry picked from commit a59eb39c6ec01ae2a9d8ddbb61a9c27f527c9caa) Reviewed-on: https://gerrit.libreoffice.org/83410
Diffstat (limited to 'oox')
-rw-r--r--oox/source/export/chartexport.cxx14
1 files changed, 12 insertions, 2 deletions
diff --git a/oox/source/export/chartexport.cxx b/oox/source/export/chartexport.cxx
index aeb2c8012674..7f0f948a4d85 100644
--- a/oox/source/export/chartexport.cxx
+++ b/oox/source/export/chartexport.cxx
@@ -3264,7 +3264,12 @@ void ChartExport::exportDataLabels(
if (GetProperty(xPropSet, "LinkNumberFormatToSource"))
mAny >>= bLinkedNumFmt;
- if (GetProperty(xPropSet, "NumberFormat") || GetProperty(xPropSet, "PercentageNumberFormat"))
+ chart2::DataPointLabel aLabel;
+ bool bLabelIsNumberFormat = true;
+ if( xPropSet->getPropertyValue("Label") >>= aLabel )
+ bLabelIsNumberFormat = aLabel.ShowNumber;
+
+ if (GetProperty(xPropSet, bLabelIsNumberFormat ? OUString("NumberFormat") : OUString("PercentageNumberFormat")))
{
sal_Int32 nKey = 0;
mAny >>= nKey;
@@ -3337,7 +3342,12 @@ void ChartExport::exportDataLabels(
pFS->startElement(FSNS(XML_c, XML_dLbl));
pFS->singleElement(FSNS(XML_c, XML_idx), XML_val, OString::number(nIdx));
- if (GetProperty(xLabelPropSet, "NumberFormat") || GetProperty(xLabelPropSet, "PercentageNumberFormat"))
+ if( xLabelPropSet->getPropertyValue("Label") >>= aLabel )
+ bLabelIsNumberFormat = aLabel.ShowNumber;
+ else
+ bLabelIsNumberFormat = true;
+
+ if (GetProperty(xLabelPropSet, bLabelIsNumberFormat ? OUString("NumberFormat") : OUString("PercentageNumberFormat")))
{
sal_Int32 nKey = 0;
mAny >>= nKey;