sc/inc/dputil.hxx | 4 ++-- sc/qa/unit/pivottable_filters_test.cxx | 3 ++- sc/source/filter/excel/xepivotxml.cxx | 8 ++++++-- 3 files changed, 10 insertions(+), 5 deletions(-)
New commits: commit 7d73c3b82c795b0fa13507054786f1a4a03fafa7 Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Mon Apr 22 12:16:38 2019 +0300 Commit: Mike Kaganski <mike.kagan...@collabora.com> CommitDate: Mon Apr 22 16:03:38 2019 +0200 tdf#124881: Provide a non-empty name for pivot table's data field Otherwise, the empty string is used by Excel, so the field arrives unnamed, disappearing from pivot table's cells upon refresh, etc. Change-Id: I2e0f9fad2d766829f2b06425bec24ff182e3a869 Reviewed-on: https://gerrit.libreoffice.org/71065 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/71067 Tested-by: Mike Kaganski <mike.kagan...@collabora.com> diff --git a/sc/inc/dputil.hxx b/sc/inc/dputil.hxx index 6d76441da6f9..76cfd2ced7c9 100644 --- a/sc/inc/dputil.hxx +++ b/sc/inc/dputil.hxx @@ -49,9 +49,9 @@ public: double fValue, const ScDPNumGroupInfo* pInfo, sal_Int32 nDatePart, SvNumberFormatter* pFormatter); - static OUString getDisplayedMeasureName(const OUString& rName, ScSubTotalFunc eFunc); + SC_DLLPUBLIC static OUString getDisplayedMeasureName(const OUString& rName, ScSubTotalFunc eFunc); - static ScSubTotalFunc toSubTotalFunc(ScGeneralFunction eGenFunc); + SC_DLLPUBLIC static ScSubTotalFunc toSubTotalFunc(ScGeneralFunction eGenFunc); }; #endif diff --git a/sc/qa/unit/pivottable_filters_test.cxx b/sc/qa/unit/pivottable_filters_test.cxx index bd44a8fc4282..42d3d87a6e57 100644 --- a/sc/qa/unit/pivottable_filters_test.cxx +++ b/sc/qa/unit/pivottable_filters_test.cxx @@ -2480,7 +2480,8 @@ void ScPivotTableFiltersTest::testTdf124651() 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", ""); + // tdf#124881: this shouldn't be an empty string + assertXPath(pDoc, "/x:pivotTableDefinition/x:dataFields/x:dataField", "name", "Sum - num"); } void ScPivotTableFiltersTest::testTdf124736() diff --git a/sc/source/filter/excel/xepivotxml.cxx b/sc/source/filter/excel/xepivotxml.cxx index 5c3ff71da8a2..332c2ff2d8e3 100644 --- a/sc/source/filter/excel/xepivotxml.cxx +++ b/sc/source/filter/excel/xepivotxml.cxx @@ -1136,8 +1136,12 @@ void XclExpXmlPivotTables::SavePivotTableXml( XclExpXmlStream& rStrm, const ScDP const 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 ? XclXmlUtils::ToOString(*pName) : ""; + // dataField element. + // tdf#124881: try to create a meaningful name; don't use empty string. + const OString sName = XclXmlUtils::ToOString( + pName ? *pName + : ScDPUtil::getDisplayedMeasureName( + rDim.GetName(), ScDPUtil::toSubTotalFunc(rDim.GetFunction()))); auto pItemAttList = sax_fastparser::FastSerializerHelper::createAttrList(); pItemAttList->add(XML_name, sName); pItemAttList->add(XML_fld, OString::number(nDimIdx)); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits