chart2/qa/extras/chart2export3.cxx |    2 +-
 oox/source/export/chartexport.cxx  |    7 +++++--
 2 files changed, 6 insertions(+), 3 deletions(-)

New commits:
commit 0e016e3efbce8a6ef5d91e5ccf96f46d0b1a32cb
Author:     Justin Luth <justin.l...@collabora.com>
AuthorDate: Mon Jan 8 13:52:03 2024 -0500
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Wed Jan 10 14:21:09 2024 +0100

    tdf#137691 chart2 export: preserve NumberFormat of DataSeries
    
    make CppunitTest_chart2_export3 CPPUNIT_TEST_NAME=tdf137691
    
    tdf116163.pptx is a good example if you look at the DataTable.
    Prior to this patch, the DataTable lost the number formatting.
    
    TODO:
    /chart2/qa/extras/data/docx/testSeriesIdxOrder.docx
    is exporting General in this case, which was unexpected.
    It appears to be an import problem though, not an export one.
    
    TODO:
    The fixme in testPPTXPercentageNumberFormats
    is still needed. Page 2's axis should LinkToSource
    and ignore the specified style.
    (It too is an example of this export patch working good.)
    
    Change-Id: I28730ba49ac2929bbc1c3be50f0d4819a5a205dc
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161806
    Tested-by: Jenkins
    Reviewed-by: Justin Luth <jl...@mail.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161846
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/chart2/qa/extras/chart2export3.cxx 
b/chart2/qa/extras/chart2export3.cxx
index 70bcc8fdfb18..838da77191b7 100644
--- a/chart2/qa/extras/chart2export3.cxx
+++ b/chart2/qa/extras/chart2export3.cxx
@@ -668,7 +668,7 @@ CPPUNIT_TEST_FIXTURE(Chart2ExportTest3, tdf137691)
 {
     // given a doc where the banana negative data formats as ($123) and the 
pineapple data as $(123)
     loadFromFile(u"pptx/tdf137691_dataTable.pptx");
-    // saveAndReload("Impress MS PowerPoint 2007 XML"); // Always exports as 
key 0 (General)
+    saveAndReload("Impress MS PowerPoint 2007 XML");
 
     Reference<chart2::XChartDocument> xChartDoc(getChartDocFromDrawImpress(0, 
0), uno::UNO_QUERY);
 
diff --git a/oox/source/export/chartexport.cxx 
b/oox/source/export/chartexport.cxx
index 0265c2b7db8d..7de4cee0c4c0 100644
--- a/oox/source/export/chartexport.cxx
+++ b/oox/source/export/chartexport.cxx
@@ -2958,8 +2958,11 @@ void ChartExport::exportSeriesValues( const Reference< 
chart2::data::XDataSequen
     sal_Int32 ptCount = aValues.size();
     pFS->startElement(FSNS(XML_c, XML_numCache));
     pFS->startElement(FSNS(XML_c, XML_formatCode));
-    // TODO: what format code?
-    pFS->writeEscaped( "General" );
+    OUString sNumberFormatString("General");
+    const sal_Int32 nKey = xValueSeq->getNumberFormatKeyByIndex(-1);
+    if (nKey > 0)
+        sNumberFormatString = getNumberFormatCode(nKey);
+    pFS->writeEscaped(sNumberFormatString);
     pFS->endElement( FSNS( XML_c, XML_formatCode ) );
     pFS->singleElement(FSNS(XML_c, XML_ptCount), XML_val, 
OString::number(ptCount));
 

Reply via email to