include/oox/export/chartexport.hxx | 7 +++---- oox/source/export/chartexport.cxx | 24 +++++++++++------------- 2 files changed, 14 insertions(+), 17 deletions(-)
New commits: commit d4a7e5c7ada7692597f4127e43624419892b7205 Author: Karthik Godha <[email protected]> AuthorDate: Mon Dec 15 16:56:58 2025 +0530 Commit: Xisco Fauli <[email protected]> CommitDate: Thu Jan 8 12:03:01 2026 +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]> (cherry picked from commit c5b4614b927bd8056995d7d4adb07a4f0c965480) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/196543 Tested-by: Jenkins Signed-off-by: Xisco Fauli <[email protected]> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/196666 diff --git a/include/oox/export/chartexport.hxx b/include/oox/export/chartexport.hxx index 1fa895d0e9fd..59af37ea0c15 100644 --- a/include/oox/export/chartexport.hxx +++ b/include/oox/export/chartexport.hxx @@ -232,10 +232,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 cdf758ce928d..bc3561b0b4c2 100644 --- a/oox/source/export/chartexport.cxx +++ b/oox/source/export/chartexport.cxx @@ -3349,13 +3349,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); @@ -3757,8 +3759,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 ) { @@ -3773,12 +3774,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()); @@ -3786,12 +3788,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() )
