diff options
-rw-r--r-- | sc/qa/unit/subsequent_export-test2.cxx | 6 | ||||
-rw-r--r-- | sc/source/filter/excel/xeescher.cxx | 5 |
2 files changed, 10 insertions, 1 deletions
diff --git a/sc/qa/unit/subsequent_export-test2.cxx b/sc/qa/unit/subsequent_export-test2.cxx index 0a44090734ab..74e795709b0e 100644 --- a/sc/qa/unit/subsequent_export-test2.cxx +++ b/sc/qa/unit/subsequent_export-test2.cxx @@ -2367,6 +2367,12 @@ void ScExportTest2::testButtonFormControlXlsxExport() assertXPathContent(pDoc, "//x:anchor/x:from/xdr:row", "3"); assertXPathContent(pDoc, "//x:anchor/x:to/xdr:col", "3"); assertXPathContent(pDoc, "//x:anchor/x:to/xdr:row", "7"); + + // Also make sure that an empty macro attribute is not written. + // Without the fix in place, this test would have failed with: + // - XPath '//x:controlPr' unexpected 'macro' attribute + // i.e. macro in an xlsx file was not omitted, which is considered invalid by Excel. + assertXPathNoAttribute(pDoc, "//x:controlPr", "macro"); } void ScExportTest2::testInvalidNamedRange() diff --git a/sc/source/filter/excel/xeescher.cxx b/sc/source/filter/excel/xeescher.cxx index eafc30de8b0a..2f92384c25b4 100644 --- a/sc/source/filter/excel/xeescher.cxx +++ b/sc/source/filter/excel/xeescher.cxx @@ -1481,9 +1481,12 @@ void XclExpTbxControlObj::SaveSheetXml(XclExpXmlStream& rStrm, const OUString& a rWorksheet->startElement(XML_control, XML_shapeId, OString::number(mnShapeId).getStr(), FSNS(XML_r, XML_id), aIdFormControlPr, XML_name, msCtrlName); + OString aMacroName = GetMacroName().toUtf8(); + // Omit the macro attribute if it would be empty. + const char* pMacroName = aMacroName.isEmpty() ? nullptr : aMacroName.getStr(); rWorksheet->startElement(XML_controlPr, XML_defaultSize, "0", XML_print, mbPrint ? "true" : "false", XML_autoFill, "0", XML_autoPict, - "0", XML_macro, GetMacroName()); + "0", XML_macro, pMacroName); rWorksheet->startElement(XML_anchor, XML_moveWithCells, "true", XML_sizeWithCells, "false"); |