diff options
author | Dennis Francis <dennis.francis@collabora.com> | 2019-04-05 22:04:13 +0530 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2019-04-08 17:55:31 +0200 |
commit | 97af58093978d8e6b9d90eedcc59141304e7200e (patch) | |
tree | 6d197b84068b5ca7e096cd60b22e1ed61b4721da /sc/source/filter/excel | |
parent | ea3a1b075154a665d30aaac6513812ceb839f64b (diff) |
tdf#123421 : xlsx export : Don't write data field entry...
under colFields tag if there is only one data-field.
<colFields count=[*]>
<field x="-2"/> <--- -2 indicates data field.
</colFields>
Excel 2013/2016 seems to crash at the presence of '<field x="-2"/>'
in colFields when there is only one data-field.
Additionally, call GetOutputRangeByType(sheet::DataPilotOutputRangeType::TABLE)
on all ScDPObject's in non-const mode, so that the internal
pOuput member of ScDPObject is populated. Otherwise the
const GetOutputRangeByType(sheet::DataPilotOutputRangeType::TABLE)
call always return an invalid range.
This also adds 2 unit tests :-
1. To check the presence of <field x="-2"/> in colFields tag
if there are more than one data-fields.
2. To ensure the absence of <field x="-2"/> in colFields tag
if there is only one data-field.
Change-Id: I8f470bd1ab883f73586f04a3fcc30e3fbf948c4a
Reviewed-on: https://gerrit.libreoffice.org/70316
Tested-by: Jenkins
Reviewed-by: Andras Timar <andras.timar@collabora.com>
Diffstat (limited to 'sc/source/filter/excel')
-rw-r--r-- | sc/source/filter/excel/xepivotxml.cxx | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/sc/source/filter/excel/xepivotxml.cxx b/sc/source/filter/excel/xepivotxml.cxx index 30d4fa7a8424..1a47e2cfeb5b 100644 --- a/sc/source/filter/excel/xepivotxml.cxx +++ b/sc/source/filter/excel/xepivotxml.cxx @@ -426,6 +426,7 @@ void XclExpXmlPivotTableManager::Initialize() { ScDPObject& rDPObj = (*pDPColl)[i]; rDPObj.SyncAllDimensionMembers(); + (void)rDPObj.GetOutputRangeByType(sheet::DataPilotOutputRangeType::TABLE); } // Go through the caches first. @@ -606,6 +607,7 @@ void XclExpXmlPivotTables::SavePivotTableXml( XclExpXmlStream& rStrm, const ScDP std::vector<long> aPageFields; std::vector<DataField> aDataFields; + long nDataDimCount = rSaveData.GetDataDimensionCount(); // Use dimensions in the save data to get their correct ordering. // Dimension order here is significant as they specify the order of // appearance in each axis. @@ -637,6 +639,8 @@ void XclExpXmlPivotTables::SavePivotTableXml( XclExpXmlStream& rStrm, const ScDP switch (eOrient) { case sheet::DataPilotFieldOrientation_COLUMN: + if (nPos == -2 && nDataDimCount <= 1) + break; aColFields.push_back(nPos); break; case sheet::DataPilotFieldOrientation_ROW: @@ -684,15 +688,16 @@ void XclExpXmlPivotTables::SavePivotTableXml( XclExpXmlStream& rStrm, const ScDP sal_Int32 nFirstDataRow = 2; sal_Int32 nFirstDataCol = 1; ScRange aResRange = rDPObj.GetOutputRangeByType(sheet::DataPilotOutputRangeType::RESULT); + + if (!aOutRange.IsValid()) + aOutRange = rDPObj.GetOutRange(); + if (aOutRange.IsValid() && aResRange.IsValid()) { nFirstDataRow = aResRange.aStart.Row() - aOutRange.aStart.Row(); nFirstDataCol = aResRange.aStart.Col() - aOutRange.aStart.Col(); } - if (!aOutRange.IsValid()) - aOutRange = rDPObj.GetOutRange(); - pPivotStrm->write("<")->writeId(XML_location); rStrm.WriteAttributes(XML_ref, XclXmlUtils::ToOString(aOutRange), |