summaryrefslogtreecommitdiff
path: root/sc/source/filter/excel
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2019-04-22 12:16:38 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2019-04-22 12:14:17 +0200
commite913727c7ee3af0bb4031c6829abfb3373306492 (patch)
tree5be769dd66d759fc4cef98b62080d38244f30676 /sc/source/filter/excel
parentff6dea46d8ccedf3ead6066c007b0362f8c4691d (diff)
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.kaganski@collabora.com>
Diffstat (limited to 'sc/source/filter/excel')
-rw-r--r--sc/source/filter/excel/xepivotxml.cxx11
1 files changed, 7 insertions, 4 deletions
diff --git a/sc/source/filter/excel/xepivotxml.cxx b/sc/source/filter/excel/xepivotxml.cxx
index ca7faa1bccff..75cb94dd2baa 100644
--- a/sc/source/filter/excel/xepivotxml.cxx
+++ b/sc/source/filter/excel/xepivotxml.cxx
@@ -1078,13 +1078,16 @@ void XclExpXmlPivotTables::SavePivotTableXml( XclExpXmlStream& rStrm, const ScDP
long nDimIdx = rDataField.mnPos;
assert(aCachedDims[nDimIdx]); // the loop above should have screened for NULL's.
const ScDPSaveDimension& rDim = *rDataField.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)