Files
ElyOffice/patches/libreoffice/0032-oox-scatter-x-values-as-numbers.patch
T
ZacharyZhang-NY b7fca0146d Ely Office: six offline-first desktop apps in Rust and GPUI
ElyDoc, ElyTable, ElyShow (LibreOfficeKit), ElyPDF (MuPDF), ElyTree (Git),
ElyMark (Milkdown and CodeMirror in CEF). ElyMail and ElyAgent follow.
2026-10-08 21:20:08 -04:00

29 lines
1.2 KiB
Diff

oox: a scatter's numeric X values export as numbers
A scatter chart whose X values come from its categories wrote them as
a string reference (strRef) to PPTX. PowerPoint and LibreOffice read
string X values as point indices, so X became 1, 2, 3 after a round
trip. When every category is a number, write a numRef instead.
diff --git a/oox/source/export/chartexport.cxx b/oox/source/export/chartexport.cxx
index 3947280..03f3d78 100644
--- a/oox/source/export/chartexport.cxx
+++ b/oox/source/export/chartexport.cxx
@@ -4066,6 +4066,16 @@ void ChartExport::exportSeriesCategory( const Reference< chart2::data::XDataSequ
if (aNumberFormatString.isEmpty())
bWriteDateCategories = false;
}
+ // Numeric X values stay numbers.
+ if (nValueType == XML_xVal)
+ {
+ const std::vector<double> aX = lcl_getAllValuesFromSequence(xValueSeq);
+ if (!aX.empty() && std::none_of(aX.begin(), aX.end(), [](double f) { return std::isnan(f); }))
+ {
+ bWriteDateCategories = true;
+ aNumberFormatString = u"General"_ustr;
+ }
+ }
pFS->startElement(FSNS(XML_c, bWriteDateCategories ? XML_numRef : XML_strRef));