sc/inc/dputil.hxx | 4 ++-- sc/qa/unit/pivottable_filters_test.cxx | 3 ++- sc/source/filter/excel/xepivotxml.cxx | 11 +++++++---- 3 files changed, 11 insertions(+), 7 deletions(-)
New commits: commit 5c07424ea9ca514a4c42a615adf7faa7b8372a05 Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Mon Apr 22 12:16:38 2019 +0300 Commit: Mike Kaganski <mike.kagan...@collabora.com> CommitDate: Wed Jun 19 11:46:01 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/74344 Tested-by: Mike Kaganski <mike.kagan...@collabora.com> diff --git a/sc/inc/dputil.hxx b/sc/inc/dputil.hxx index 735843b84578..742c69da0e6a 100644 --- a/sc/inc/dputil.hxx +++ b/sc/inc/dputil.hxx @@ -47,9 +47,9 @@ public: double fValue, const ScDPNumGroupInfo* pInfo, sal_Int32 nDatePart, const 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 b0868a5db88f..17d5b32c3a2a 100644 --- a/sc/qa/unit/pivottable_filters_test.cxx +++ b/sc/qa/unit/pivottable_filters_test.cxx @@ -2474,7 +2474,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 cfa173cca627..e3b39e0dafe9 100644 --- a/sc/source/filter/excel/xepivotxml.cxx +++ b/sc/source/filter/excel/xepivotxml.cxx @@ -1130,13 +1130,16 @@ void XclExpXmlPivotTables::SavePivotTableXml( XclExpXmlStream& rStrm, const ScDP long nDimIdx = it->mnPos; assert(aCachedDims[nDimIdx]); // the loop above should have screened for NULL's. const ScDPSaveDimension& rDim = *it->mpDim; - const boost::optional<OUString> & pName = rDim.GetLayoutName(); + 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() : ""; + // dataField element. + // tdf#124881: try to create a meaningful name; don't use empty string. + if (!pName) + pName = ScDPUtil::getDisplayedMeasureName( + rDim.GetName(), ScDPUtil::toSubTotalFunc(rDim.GetFunction())); auto pItemAttList = sax_fastparser::FastSerializerHelper::createAttrList(); - pItemAttList->add(XML_name, sName); + pItemAttList->add(XML_name, pName->toUtf8()); pItemAttList->add(XML_fld, OString::number(nDimIdx)); const char* pSubtotal = toOOXMLSubtotalType(rDim.GetFunction()); if (pSubtotal) _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits