sc/qa/unit/subsequent_export-test.cxx | 6 ++++++ sc/source/filter/excel/xeescher.cxx | 5 ++++- 2 files changed, 10 insertions(+), 1 deletion(-)
New commits: commit 88b9d9255b89fb21dd8ad016c1b7abd4716bdd27 Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Thu Jul 8 10:15:29 2021 +0200 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Mon Jul 12 15:46:45 2021 +0200 XSLX export, button form control: fix handling of no macros Turns out that in case there is no macro, then the attribute should be omitted, leaving it empty is not OK. Excel warns about this. (cherry picked from commit d67085cd86dc1e74941c8337d1eba39981117977) Conflicts: sc/qa/unit/subsequent_export-test2.cxx Change-Id: I2dbc4d837bd585674e013eb3ce6b898f12498c4d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118663 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Luboš Luňák <l.lu...@collabora.com> diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx index 60dff1c1a847..8b18ed93033f 100644 --- a/sc/qa/unit/subsequent_export-test.cxx +++ b/sc/qa/unit/subsequent_export-test.cxx @@ -5897,6 +5897,12 @@ void ScExportTest::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 ScExportTest::testInvalidNamedRange() diff --git a/sc/source/filter/excel/xeescher.cxx b/sc/source/filter/excel/xeescher.cxx index dc137c5e3481..c053e2b643ed 100644 --- a/sc/source/filter/excel/xeescher.cxx +++ b/sc/source/filter/excel/xeescher.cxx @@ -1490,9 +1490,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"); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits