oox/source/export/chartexport.cxx | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-)
New commits: commit f10eb0f12eab9cdf1772ea2a1169e5dfce5212f9 Author: Aron Budea <[email protected]> AuthorDate: Mon Jan 19 02:32:00 2026 +1030 Commit: Aron Budea <[email protected]> CommitDate: Tue Jan 20 09:39:24 2026 +0100 oox: Limit export of dLblPos attr in pie charts to valid values Based on [MS-OI29500]. This also fixes PPTX export of fdo56877-2.odp, which seems to have bogus content in Object 1/content.xml: <style:chart-properties chart:solid-type="cuboid" chart:label-position="left"/> It used to export as this invalid attribute: <c:dLblPos val="l"/> Change-Id: I710db739b36c469d300273ae016e3d5686b8c578 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/197525 Reviewed-by: Aron Budea <[email protected]> Tested-by: Jenkins diff --git a/oox/source/export/chartexport.cxx b/oox/source/export/chartexport.cxx index 4c3c1349fa13..bda05a4b68c9 100644 --- a/oox/source/export/chartexport.cxx +++ b/oox/source/export/chartexport.cxx @@ -5229,7 +5229,11 @@ void ChartExport::writeLabelProperties( if (xPropSet->getPropertyValue(u"LabelPlacement"_ustr) >>= nLabelPlacement) { if (!rLabelParam.maAllowedValues.count(nLabelPlacement)) + { + SAL_WARN("oox", "this label placement not allowed in OOXML for current chart type: " + + OString::number(nLabelPlacement)); nLabelPlacement = rLabelParam.meDefault; + } pFS->singleElement(FSNS(XML_c, XML_dLblPos), XML_val, toOOXMLPlacement(nLabelPlacement)); } } @@ -5293,6 +5297,8 @@ void ChartExport::exportDataLabels( // We must not export label placement property when the chart type doesn't // support this option in MS Office, else MS Office would think the file // is corrupt & refuse to open it. + // For allowed values see 2.1.1456 Part 1 Section 21.2.2.48, + // dLblPos (Data Label Position) in [MS-OI29500]. const chart::TypeGroupInfo& rInfo = chart::GetTypeGroupInfo(static_cast<chart::TypeId>(eChartType)); LabelPlacementParam aParam(!mbIs3DChart, rInfo.mnDefLabelPos); @@ -5302,8 +5308,16 @@ void ChartExport::exportDataLabels( if(getChartType() == chart::TYPEID_DOUGHNUT) aParam.mbExport = false; else - // All pie charts support label placement. - aParam.mbExport = true; + { + // All pie charts support label placement. + aParam.mbExport = true; + aParam.maAllowedValues.clear(); + aParam.maAllowedValues.insert(css::chart::DataLabelPlacement::OUTSIDE); + aParam.maAllowedValues.insert(css::chart::DataLabelPlacement::INSIDE); + aParam.maAllowedValues.insert(css::chart::DataLabelPlacement::CENTER); + aParam.maAllowedValues.insert(css::chart::DataLabelPlacement::AVOID_OVERLAP); + aParam.meDefault = css::chart::DataLabelPlacement::AVOID_OVERLAP; + } break; case chart::TYPEID_AREA: case chart::TYPEID_RADARLINE:
