[Libreoffice-commits] core.git: sc/qa sc/source
Mike Kaganski (via logerrit)
logerrit at kemper.freedesktop.org
Thu Apr 11 06:26:39 UTC 2019
sc/qa/unit/data/ods/tdf124651_simplePivotTable.ods |binary
sc/qa/unit/pivottable_filters_test.cxx | 15 +++++++++++++++
sc/source/filter/excel/xepivotxml.cxx | 7 +++++--
3 files changed, 20 insertions(+), 2 deletions(-)
New commits:
commit 577b95f4d0cc1cf8836ff35fc30189c64fefb508
Author: Mike Kaganski <mike.kaganski at collabora.com>
AuthorDate: Wed Apr 10 15:18:07 2019 +0300
Commit: Mike Kaganski <mike.kaganski at collabora.com>
CommitDate: Thu Apr 11 08:26:18 2019 +0200
tdf#124651: always write "name" attribute to dataField element
Despite being optional as per ECMA-376-1:2016, Excel 2016 seems to
require the presence of "name" attribute in dataField element of
pivot table definition, so make sure to write at least empty string
there.
Change-Id: Iaab5674f86b7dd0b267776678e11af47086635d7
Reviewed-on: https://gerrit.libreoffice.org/70522
Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>
Tested-by: Mike Kaganski <mike.kaganski at collabora.com>
diff --git a/sc/qa/unit/data/ods/tdf124651_simplePivotTable.ods b/sc/qa/unit/data/ods/tdf124651_simplePivotTable.ods
new file mode 100644
index 000000000000..05fd5fec838f
Binary files /dev/null and b/sc/qa/unit/data/ods/tdf124651_simplePivotTable.ods differ
diff --git a/sc/qa/unit/pivottable_filters_test.cxx b/sc/qa/unit/pivottable_filters_test.cxx
index 739af618ec7d..d5b1afd64701 100644
--- a/sc/qa/unit/pivottable_filters_test.cxx
+++ b/sc/qa/unit/pivottable_filters_test.cxx
@@ -85,6 +85,7 @@ public:
void testTdf112106();
void testTdf123923();
void testTdf123939();
+ void testTdf124651();
CPPUNIT_TEST_SUITE(ScPivotTableFiltersTest);
@@ -127,6 +128,7 @@ public:
CPPUNIT_TEST(testTdf112106);
CPPUNIT_TEST(testTdf123923);
CPPUNIT_TEST(testTdf123939);
+ CPPUNIT_TEST(testTdf124651);
CPPUNIT_TEST_SUITE_END();
@@ -2430,6 +2432,19 @@ void ScPivotTableFiltersTest::testTdf123939()
"containsMixedTypes", "1");
}
+void ScPivotTableFiltersTest::testTdf124651()
+{
+ ScDocShellRef xDocSh = loadDoc("tdf124651_simplePivotTable.", FORMAT_ODS);
+ CPPUNIT_ASSERT(xDocSh.is());
+
+ xmlDocPtr pDoc = XPathHelper::parseExport2(*this, *xDocSh, m_xSFactory,
+ "xl/pivotTables/pivotTable1.xml", FORMAT_XLSX);
+ CPPUNIT_ASSERT(pDoc);
+ // We have to export name attribute, even though it's optional according to ECMA-376 standard,
+ // because Excel (at least 2016) seems to require it.
+ assertXPath(pDoc, "/x:pivotTableDefinition/x:dataFields/x:dataField", "name", "");
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(ScPivotTableFiltersTest);
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sc/source/filter/excel/xepivotxml.cxx b/sc/source/filter/excel/xepivotxml.cxx
index 1a47e2cfeb5b..69c98d13c55b 100644
--- a/sc/source/filter/excel/xepivotxml.cxx
+++ b/sc/source/filter/excel/xepivotxml.cxx
@@ -947,9 +947,12 @@ void XclExpXmlPivotTables::SavePivotTableXml( XclExpXmlStream& rStrm, const ScDP
assert(aCachedDims[nDimIdx]); // the loop above should have screened for NULL's.
const ScDPSaveDimension& rDim = *rDataField.mpDim;
const boost::optional<OUString> & pName = rDim.GetLayoutName();
+ // tdf#124651: despite being optional in CT_DataField according to ECMA-376 Part 1,
+ // Excel (at least 2016) seems to insist on the presence of "name" attribute in
+ // dataField element, even if empty
+ const OString sName = pName ? pName->toUtf8() : "";
pPivotStrm->write("<")->writeId(XML_dataField);
- if (pName)
- rStrm.WriteAttributes(XML_name, pName->toUtf8(), FSEND);
+ rStrm.WriteAttributes(XML_name, sName, FSEND);
rStrm.WriteAttributes(XML_fld, OString::number(nDimIdx).getStr(), FSEND);
More information about the Libreoffice-commits
mailing list