chart2/qa/extras/chart2import2.cxx                                |   24 
++++++++++
 chart2/qa/extras/data/ods/tdf166428_Low_High_StockChart_LO248.ods |binary
 xmloff/source/chart/SchXMLChartContext.cxx                        |    7 +-
 3 files changed, 27 insertions(+), 4 deletions(-)

New commits:
commit e93180fd98fa6adca27beafb8fc5352f8ba140b0
Author:     Regina Henschel <rb.hensc...@t-online.de>
AuthorDate: Wed Jun 11 20:39:20 2025 +0200
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Mon Jun 16 11:47:10 2025 +0200

    tdf#166428 accept stock charts with only low and high series
    
    A stock chart may consist of only series 'Low' and 'High' in UI. But
    the method MergeSeriesForStockChart() expects three series. The third
    one is for a series 'Close'. That corresponds to ODF. For this third
    series, LO writes a series without chart:values-cell-range-address. That
    is allowed in ODF.
    
    mbAllRangeAddressesAvailable is set to 'false' on import, because of
    this dummy series. Thus MergeSeriesForStockChart() was not executed.
    LO 24.8 has used as fallback, to generate the chart from the range
    stored in msChartAddress. This member gets its value from attribute
    table:cell-range-address of the chart:plot-area element.
    
    This attribute was already deprecated for long time and is now removed
    in ODF 1.4. Therefore the fallback does not work any longer for documents
    saved in ODF 1.4, which is the default for LO 25.x. Loading such chart in
    LO 25.x had lost all series.
    
    Fortunately it is not necessary to skip MergeSeriesForStockChart() if
    there is an empty series. The method can already handle it itself. The
    fallback would have not been necessary in LO 24.8.
    
    The patch changes the procedure so, that MergeSeriesForStockChart is
    called even if mbAllRangeAddressesAvailable is false. I don't know
    whether the fallback is used for other chart types in documents
    producted by older LO or OOo versions. Thus I have not changed the
    else-branch.
    
    Change-Id: I2f059cb1778cf84161cf08b35c27ef50a66aefe3
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/186386
    Reviewed-by: Regina Henschel <rb.hensc...@t-online.de>
    Tested-by: Jenkins
    (cherry picked from commit af99860d42c672c3c47aab5e3b55f0bb52df4b4e)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/186409
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/chart2/qa/extras/chart2import2.cxx 
b/chart2/qa/extras/chart2import2.cxx
index bb5f7ecb1947..cdfe94093e4b 100644
--- a/chart2/qa/extras/chart2import2.cxx
+++ b/chart2/qa/extras/chart2import2.cxx
@@ -934,6 +934,30 @@ CPPUNIT_TEST_FIXTURE(Chart2ImportTest2, testAngleUnits)
     }
 }
 
+CPPUNIT_TEST_FIXTURE(Chart2ImportTest2, testTdf166428)
+{
+    // The file was generated in ODF 1.3 by LO 24.8
+    loadFromFile(u"ods/tdf166428_Low_High_StockChart_LO248.ods");
+
+    // The attribute table:cell-range-address does not exist in ODF 1.4. and 
therefore may not be
+    // be written.
+    saveAndReload(u"calc8"_ustr);
+    xmlDocUniquePtr pXmlDoc = parseExport(u"Object 1/content.xml"_ustr);
+    assertXPathNoAttribute(pXmlDoc,
+                           
"/office:document-content/office:body/office:chart/chart:chart/"
+                           "chart:plot-area",
+                           "table:cell-range-address");
+
+    uno::Reference<chart2::XChartDocument> xChartDoc = getChartDocFromSheet(0);
+    CPPUNIT_ASSERT(xChartDoc.is());
+
+    // Without applied fix, the series were not merged to one stock chart 
serie and therefore
+    // only role "values-y" existed.
+    Reference<chart2::data::XDataSequence> xDataSeq
+        = getDataSequenceFromDocByRole(xChartDoc, u"values-min");
+    CPPUNIT_ASSERT(xDataSeq.is());
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/qa/extras/data/ods/tdf166428_Low_High_StockChart_LO248.ods 
b/chart2/qa/extras/data/ods/tdf166428_Low_High_StockChart_LO248.ods
new file mode 100644
index 000000000000..12c5993d422f
Binary files /dev/null and 
b/chart2/qa/extras/data/ods/tdf166428_Low_High_StockChart_LO248.ods differ
diff --git a/xmloff/source/chart/SchXMLChartContext.cxx 
b/xmloff/source/chart/SchXMLChartContext.cxx
index fbf06985cc93..297939f7e9f7 100644
--- a/xmloff/source/chart/SchXMLChartContext.cxx
+++ b/xmloff/source/chart/SchXMLChartContext.cxx
@@ -814,13 +814,12 @@ void SchXMLChartContext::endFastElement(sal_Int32 )
         msChartAddress = "all";
 
     bool bSwitchRangesFromOuterToInternalIfNecessary = false;
-    if( !bHasOwnData && mbAllRangeAddressesAvailable )
+    if(!bHasOwnData && mbIsStockChart)
     {
         // special handling for stock chart (merge series together)
-        if( mbIsStockChart )
-            MergeSeriesForStockChart();
+        MergeSeriesForStockChart();
     }
-    else if( !msChartAddress.isEmpty() )
+    else if((bHasOwnData || !mbAllRangeAddressesAvailable) && 
!msChartAddress.isEmpty())
     {
         //own data or only rectangular range available
 

Reply via email to