[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.2' - sc/qa sc/source
Mike Kaganski (via logerrit)
logerrit at kemper.freedesktop.org
Wed Jun 19 05:09:19 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 8c800d3cc9541a28e665707bda0bf68d81a3269b
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: Wed Jun 19 07:08:45 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>
Reviewed-on: https://gerrit.libreoffice.org/74327
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 a476e0d7b450..2c3448b78cfc 100644
--- a/sc/qa/unit/pivottable_filters_test.cxx
+++ b/sc/qa/unit/pivottable_filters_test.cxx
@@ -89,6 +89,7 @@ public:
void testTdf112106();
void testTdf123923();
void testTdf123939();
+ void testTdf124651();
CPPUNIT_TEST_SUITE(ScPivotTableFiltersTest);
@@ -132,6 +133,7 @@ public:
CPPUNIT_TEST(testTdf112106);
CPPUNIT_TEST(testTdf123923);
CPPUNIT_TEST(testTdf123939);
+ CPPUNIT_TEST(testTdf124651);
CPPUNIT_TEST_SUITE_END();
@@ -2443,6 +2445,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 41fa2161f9c2..5538bd8770b1 100644
--- a/sc/source/filter/excel/xepivotxml.cxx
+++ b/sc/source/filter/excel/xepivotxml.cxx
@@ -968,9 +968,12 @@ void XclExpXmlPivotTables::SavePivotTableXml( XclExpXmlStream& rStrm, const ScDP
assert(aCachedDims[nDimIdx]); // the loop above should have screened for NULL's.
const ScDPSaveDimension& rDim = *it->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, XclXmlUtils::ToOString(*pName), FSEND);
+ rStrm.WriteAttributes(XML_name, sName, FSEND);
rStrm.WriteAttributes(XML_fld, OString::number(nDimIdx).getStr(), FSEND);
More information about the Libreoffice-commits
mailing list