[Libreoffice-commits] core.git: sc/qa sc/source
Miklos Vajna (via logerrit)
logerrit at kemper.freedesktop.org
Thu Jul 8 09:07:06 UTC 2021
sc/qa/unit/subsequent_export-test2.cxx | 6 ++++++
sc/source/filter/excel/xeescher.cxx | 5 ++++-
2 files changed, 10 insertions(+), 1 deletion(-)
New commits:
commit d67085cd86dc1e74941c8337d1eba39981117977
Author: Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Thu Jul 8 10:15:29 2021 +0200
Commit: Miklos Vajna <vmiklos at collabora.com>
CommitDate: Thu Jul 8 11:06:31 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.
Change-Id: I2dbc4d837bd585674e013eb3ce6b898f12498c4d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118600
Reviewed-by: Miklos Vajna <vmiklos at collabora.com>
Tested-by: Jenkins
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");
More information about the Libreoffice-commits
mailing list