include/oox/export/chartexport.hxx |    7 +++----
 oox/source/export/chartexport.cxx  |   24 +++++++++++-------------
 2 files changed, 14 insertions(+), 17 deletions(-)

New commits:
commit c5b4614b927bd8056995d7d4adb07a4f0c965480
Author:     Karthik Godha <[email protected]>
AuthorDate: Mon Dec 15 16:56:58 2025 +0530
Commit:     Michael Stahl <[email protected]>
CommitDate: Wed Dec 17 16:17:53 2025 +0100

    tdf#169980: Fix ODP->PPTX export of stock chart
    
    In OOXML chart export in `c:stockChart` there are multiple `c:ser`
    elements with the same `c:idx` value.
    
    Change-Id: Id5c5983118214013a3610ae937b9893c479a0ea0
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195657
    Tested-by: Jenkins CollaboraOffice <[email protected]>
    Reviewed-by: Michael Stahl <[email protected]>

diff --git a/include/oox/export/chartexport.hxx 
b/include/oox/export/chartexport.hxx
index b4be727e5365..a4821b467434 100644
--- a/include/oox/export/chartexport.hxx
+++ b/include/oox/export/chartexport.hxx
@@ -227,10 +227,9 @@ private:
 
     void exportVaryColors(const css::uno::Reference<css::chart2::XChartType>& 
xChartType);
     void exportCandleStickSeries(
-        const css::uno::Sequence<
-            css::uno::Reference<
-                css::chart2::XDataSeries > > & aSeriesSeq,
-        bool& rPrimaryAxes );
+        const 
css::uno::Sequence<css::uno::Reference<css::chart2::XDataSeries>>& aSeriesSeq,
+        bool& rPrimaryAxes, sal_uInt32& nIdx);
+
     void exportSeriesText(
         const css::uno::Reference< css::chart2::data::XDataSequence >& 
xValueSeq, bool bIsChartex );
     void exportSeriesCategory(
diff --git a/oox/source/export/chartexport.cxx 
b/oox/source/export/chartexport.cxx
index 7111b6d3f0fd..4f72421f14e1 100644
--- a/oox/source/export/chartexport.cxx
+++ b/oox/source/export/chartexport.cxx
@@ -3240,13 +3240,15 @@ void ChartExport::exportStockChart( const Reference< 
chart2::XChartType >& xChar
         // Use a dummy data series to output needed basic chart-related XML 
even in case of empty charts
         aSplitDataSeries.push_back({});
     }
+
+    sal_uInt32 nIdx = 0;
     for (const auto& splitDataSeries : aSplitDataSeries)
     {
         pFS->startElement(FSNS(XML_c, XML_stockChart));
 
         bool bPrimaryAxes = true;
         if (splitDataSeries.hasElements())
-            exportCandleStickSeries(splitDataSeries, bPrimaryAxes);
+            exportCandleStickSeries(splitDataSeries, bPrimaryAxes, nIdx);
 
         // export stock properties
         Reference< css::chart::XStatisticDisplay > 
xStockPropProvider(mxDiagram, uno::UNO_QUERY);
@@ -3648,8 +3650,7 @@ void ChartExport::exportSeries_chartex( const 
Reference<chart2::XChartType>& xCh
 }
 
 void ChartExport::exportCandleStickSeries(
-    const Sequence< Reference< chart2::XDataSeries > > & aSeriesSeq,
-    bool& rPrimaryAxes)
+    const Sequence<Reference<chart2::XDataSeries>>& aSeriesSeq, bool& 
rPrimaryAxes, sal_uInt32& nIdx)
 {
     for( const Reference< chart2::XDataSeries >& xSeries : aSeriesSeq )
     {
@@ -3664,12 +3665,13 @@ void ChartExport::exportCandleStickSeries(
             Sequence< Reference< chart2::data::XLabeledDataSequence > > 
aSeqCnt(
                 xSource->getDataSequences());
 
-            const char* sSeries[] = 
{"values-first","values-max","values-min","values-last",nullptr};
+            const char* sSeries[] = 
{"values-first","values-max","values-min","values-last"};
 
-            for( sal_Int32 idx = 0; sSeries[idx] != nullptr ; idx++ )
+            for (const char* series : sSeries)
             {
-                Reference< chart2::data::XLabeledDataSequence > xLabeledSeq( 
lcl_getDataSequenceByRole( aSeqCnt, OUString::createFromAscii(sSeries[idx]) ) );
-                if( xLabeledSeq.is())
+                Reference<chart2::data::XLabeledDataSequence> xLabeledSeq(
+                    lcl_getDataSequenceByRole(aSeqCnt, 
OUString::createFromAscii(series)));
+                if (xLabeledSeq.is())
                 {
                     Reference< chart2::data::XDataSequence > xLabelSeq( 
xLabeledSeq->getLabel());
                     Reference< chart2::data::XDataSequence > xValueSeq( 
xLabeledSeq->getValues());
@@ -3677,12 +3679,8 @@ void ChartExport::exportCandleStickSeries(
                         FSHelperPtr pFS = GetFS();
                         pFS->startElement(FSNS(XML_c, XML_ser));
 
-                        // TODO: idx and order
-                        // idx attribute should start from 1 and not from 0.
-                        pFS->singleElement( FSNS( XML_c, XML_idx ),
-                                XML_val, OString::number(idx+1) );
-                        pFS->singleElement( FSNS( XML_c, XML_order ),
-                                XML_val, OString::number(idx+1) );
+                        pFS->singleElement(FSNS(XML_c, XML_idx), XML_val, 
OString::number(++nIdx));
+                        pFS->singleElement(FSNS(XML_c, XML_order), XML_val, 
OString::number(nIdx));
 
                         // export label
                         if( xLabelSeq.is() )

Reply via email to