sc/source/filter/xml/xmlexprt.cxx |   26 +++++++++++++++++---------
 sc/source/ui/unoobj/chart2uno.cxx |    3 +++
 2 files changed, 20 insertions(+), 9 deletions(-)

New commits:
commit ecf0074b1582842620ce9057a27fbe10f1812b61
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Tue Aug 2 11:52:23 2022 +0100
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Wed Aug 3 12:15:27 2022 +0200

    crashtesting: assert on export of forum-mso-en3-17256.xlsx to ods
    
    a lang::IllegalArgumentException is thrown on seeing myEB_Y_Pos
    and the xml tags become unbalanced
    
    Change-Id: I2bd65933c572d7bd1d1ade699fcef21a63a85e9f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137612
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>

diff --git a/sc/source/filter/xml/xmlexprt.cxx 
b/sc/source/filter/xml/xmlexprt.cxx
index 44abae0ee455..37b155bf937a 100644
--- a/sc/source/filter/xml/xmlexprt.cxx
+++ b/sc/source/filter/xml/xmlexprt.cxx
@@ -111,6 +111,7 @@
 #include <rtl/ustring.hxx>
 
 #include <tools/color.hxx>
+#include <tools/diagnose_ex.h>
 #include <rtl/math.hxx>
 #include <svl/numformat.hxx>
 #include <svl/zforlist.hxx>
@@ -3418,16 +3419,23 @@ void ScXMLExport::ExportShape(const uno::Reference < 
drawing::XShape >& xShape,
                                 uno::Sequence< OUString > aRepresentations(
                                     xReceiver->getUsedRangeRepresentations());
                                 rtl::Reference<SvXMLAttributeList> pAttrList;
-                                if(aRepresentations.hasElements())
+                                try
                                 {
-                                    // add the ranges used by the chart to the 
shape
-                                    // element to be able to start listening 
after
-                                    // load (when the chart is not yet loaded)
-                                    uno::Reference< 
chart2::data::XRangeXMLConversion > xRangeConverter( 
xChartDoc->getDataProvider(), uno::UNO_QUERY );
-                                    sRanges = lcl_RangeSequenceToString( 
aRepresentations, xRangeConverter );
-                                    pAttrList = new SvXMLAttributeList();
-                                    pAttrList->AddAttribute(
-                                        GetNamespaceMap().GetQNameByKey( 
XML_NAMESPACE_DRAW, GetXMLToken(XML_NOTIFY_ON_UPDATE_OF_RANGES) ), sRanges );
+                                    if (aRepresentations.hasElements())
+                                    {
+                                        // add the ranges used by the chart to 
the shape
+                                        // element to be able to start 
listening after
+                                        // load (when the chart is not yet 
loaded)
+                                        uno::Reference< 
chart2::data::XRangeXMLConversion > xRangeConverter( 
xChartDoc->getDataProvider(), uno::UNO_QUERY );
+                                        sRanges = lcl_RangeSequenceToString( 
aRepresentations, xRangeConverter );
+                                        pAttrList = new SvXMLAttributeList();
+                                        pAttrList->AddAttribute(
+                                            GetNamespaceMap().GetQNameByKey( 
XML_NAMESPACE_DRAW, GetXMLToken(XML_NOTIFY_ON_UPDATE_OF_RANGES) ), sRanges );
+                                    }
+                                }
+                                catch (const lang::IllegalArgumentException&)
+                                {
+                                    TOOLS_WARN_EXCEPTION("sc", "Exception in 
lcl_RangeSequenceToString - invalid range?");
                                 }
                                 GetShapeExport()->exportShape(xShape, 
SEF_DEFAULT, pPoint, pAttrList.get());
                             }
diff --git a/sc/source/ui/unoobj/chart2uno.cxx 
b/sc/source/ui/unoobj/chart2uno.cxx
index d2fec774e125..8cbdfd6c2b64 100644
--- a/sc/source/ui/unoobj/chart2uno.cxx
+++ b/sc/source/ui/unoobj/chart2uno.cxx
@@ -2241,7 +2241,10 @@ OUString SAL_CALL 
ScChart2DataProvider::convertRangeToXML( const OUString& sRang
     ScRefTokenHelper::compileRangeRepresentation(
         aRefTokens, sRangeRepresentation, *m_pDocument, cSep, 
m_pDocument->GetGrammar(), true);
     if (aRefTokens.empty())
+    {
+        SAL_WARN("sc", "convertRangeToXML throw IllegalArgumentException from 
input of: " << sRangeRepresentation);
         throw lang::IllegalArgumentException();
+    }
 
     Tokens2RangeStringXML converter(*m_pDocument);
     converter = ::std::for_each(aRefTokens.begin(), aRefTokens.end(), 
converter);

Reply via email to