sc/source/filter/excel/xelink.cxx |   15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

New commits:
commit 0361f8620cc0c6bdc27d6f4daa9593650a755e5a
Author:     Balazs Varga <balazs.varga...@gmail.com>
AuthorDate: Tue Oct 19 16:51:08 2021 +0200
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Tue Oct 19 20:58:09 2021 +0200

    fix crash of OOXML export of deleted, empty range names
    
    since...
    
    commit 12ee423c7549ddd2b86dfc3fc6fed2c617dcca7f
    Date:   Mon Sep 13 12:17:37 2021 +0200
    
        tdf#144397 tdf#144636 XLSX: cache external named ranges and their 
formulas
    
    Change-Id: Ib5591d2a680cb58d248cf4e8fa4a4cbe777002f5
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123822
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caol...@redhat.com>

diff --git a/sc/source/filter/excel/xelink.cxx 
b/sc/source/filter/excel/xelink.cxx
index 593f26695779..c2224dacacdb 100644
--- a/sc/source/filter/excel/xelink.cxx
+++ b/sc/source/filter/excel/xelink.cxx
@@ -1066,12 +1066,21 @@ void XclExpExtName::SaveXml(XclExpXmlStream& rStrm)
 
     /* TODO: mpArray contains external references. It doesn't cause any 
problems, but it's enough
     to export it without the external document identifier. */
-    OUString aFormula = XclXmlUtils::ToOUString(GetCompileFormulaContext(), 
ScAddress(0, 0, 0), mpArray.get());
-
-    pExternalLink->startElement(XML_definedName,
+    if (mpArray->GetLen())
+    {
+        const OUString aFormula = 
XclXmlUtils::ToOUString(GetCompileFormulaContext(), ScAddress(0, 0, 0), 
mpArray.get());
+        pExternalLink->startElement(XML_definedName,
             XML_name, maName.toUtf8(),
             XML_refersTo, aFormula.toUtf8(),
             XML_sheetId, nullptr);
+    }
+    else
+    {
+        pExternalLink->startElement(XML_definedName,
+            XML_name, maName.toUtf8(),
+            XML_refersTo, nullptr,
+            XML_sheetId, nullptr);
+    }
 
     pExternalLink->endElement(XML_definedName);
 }

Reply via email to