diff options
author | Tamás Zolnai <tamas.zolnai@collabora.com> | 2017-10-19 10:43:31 +0200 |
---|---|---|
committer | Tamás Zolnai <tamas.zolnai@collabora.com> | 2017-10-19 14:39:50 +0200 |
commit | 8cf0b4b4cd748094889a6a9ac6883dd457113b74 (patch) | |
tree | e8a552c0e2bdc44a3d414d2d602fa07b061d64e4 /sc | |
parent | c79da868c0b02b1b1333c3b805899bb4ce867f6a (diff) |
tdf#113159: Pivot table: tabular mode is converted to oultine mode
... after RT XLSX in Calc
Change-Id: I9725ca55aed973133db1d5fe47463575148e00b8
Reviewed-on: https://gerrit.libreoffice.org/43537
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Tamás Zolnai <tamas.zolnai@collabora.com>
Diffstat (limited to 'sc')
-rwxr-xr-x | sc/qa/unit/data/xlsx/pivottable_tabular_mode.xlsx | bin | 0 -> 17373 bytes | |||
-rw-r--r-- | sc/qa/unit/subsequent_export-test.cxx | 20 | ||||
-rw-r--r-- | sc/source/filter/excel/xepivotxml.cxx | 57 |
3 files changed, 64 insertions, 13 deletions
diff --git a/sc/qa/unit/data/xlsx/pivottable_tabular_mode.xlsx b/sc/qa/unit/data/xlsx/pivottable_tabular_mode.xlsx Binary files differnew file mode 100755 index 000000000000..0bcfe1742d95 --- /dev/null +++ b/sc/qa/unit/data/xlsx/pivottable_tabular_mode.xlsx diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx index 72fe254d850c..ee8e33433bab 100644 --- a/sc/qa/unit/subsequent_export-test.cxx +++ b/sc/qa/unit/subsequent_export-test.cxx @@ -228,6 +228,7 @@ public: void testPivotTableErrorItemFilterXLSX(); void testPivotTableOutlineModeXLSX(); void testPivotTableDuplicatedMemberFilterXLSX(); + void testPivotTableTabularModeXLSX(); CPPUNIT_TEST_SUITE(ScExportTest); CPPUNIT_TEST(test); @@ -350,6 +351,7 @@ public: CPPUNIT_TEST(testPivotTableErrorItemFilterXLSX); CPPUNIT_TEST(testPivotTableOutlineModeXLSX); CPPUNIT_TEST(testPivotTableDuplicatedMemberFilterXLSX); + CPPUNIT_TEST(testPivotTableTabularModeXLSX); CPPUNIT_TEST_SUITE_END(); @@ -5286,6 +5288,24 @@ void ScExportTest::testPivotTableDuplicatedMemberFilterXLSX() assertXPath(pTable, "/x:pivotTableDefinition/x:pivotFields/x:pivotField[5]/x:items", "count", "21"); } +void ScExportTest::testPivotTableTabularModeXLSX() +{ + ScDocShellRef xShell = loadDoc("pivottable_tabular_mode.", FORMAT_XLSX); + CPPUNIT_ASSERT(xShell.is()); + + std::shared_ptr<utl::TempFile> pXPathFile = ScBootstrapFixture::exportTo(&(*xShell), FORMAT_XLSX); + xmlDocPtr pTable = XPathHelper::parseExport(pXPathFile, m_xSFactory, "xl/pivotTables/pivotTable1.xml"); + CPPUNIT_ASSERT(pTable); + + // In tabular mode both outline and compact flag should be false + assertXPath(pTable, "/x:pivotTableDefinition", "outline", "0"); + assertXPath(pTable, "/x:pivotTableDefinition", "outlineData", "0"); + assertXPath(pTable, "/x:pivotTableDefinition", "compact", "0"); + assertXPath(pTable, "/x:pivotTableDefinition", "compactData", "0"); + assertXPath(pTable, "/x:pivotTableDefinition/x:pivotFields/x:pivotField[1]", "compact", "0"); + assertXPath(pTable, "/x:pivotTableDefinition/x:pivotFields/x:pivotField[1]", "outline", "0"); +} + CPPUNIT_TEST_SUITE_REGISTRATION(ScExportTest); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sc/source/filter/excel/xepivotxml.cxx b/sc/source/filter/excel/xepivotxml.cxx index 99510d85835a..b5eacfad9bf3 100644 --- a/sc/source/filter/excel/xepivotxml.cxx +++ b/sc/source/filter/excel/xepivotxml.cxx @@ -20,6 +20,7 @@ #include <sax/tools/converter.hxx> #include <com/sun/star/sheet/DataPilotFieldOrientation.hpp> +#include <com/sun/star/sheet/DataPilotFieldLayoutMode.hpp> #include <com/sun/star/sheet/DataPilotOutputRangeType.hpp> #include <com/sun/star/sheet/GeneralFunction.hpp> @@ -613,7 +614,7 @@ void XclExpXmlPivotTables::SavePivotTableXml( XclExpXmlStream& rStrm, const ScDP // Dimension order here is significant as they specify the order of // appearance in each axis. const ScDPSaveData::DimsType& rDims = rSaveData.GetDimensions(); - + bool bTabularMode = false; for (const auto & i : rDims) { const ScDPSaveDimension& rDim = *i; @@ -655,6 +656,8 @@ void XclExpXmlPivotTables::SavePivotTableXml( XclExpXmlStream& rStrm, const ScDP default: ; } + if(rDim.GetLayoutInfo()) + bTabularMode |= (rDim.GetLayoutInfo()->LayoutMode == sheet::DataPilotFieldLayoutMode::TABULAR_LAYOUT); } sax_fastparser::FSHelperPtr& pPivotStrm = rStrm.GetCurrentStream(); @@ -672,8 +675,8 @@ void XclExpXmlPivotTables::SavePivotTableXml( XclExpXmlStream& rStrm, const ScDP XML_useAutoFormatting, ToPsz10(false), XML_itemPrintTitles, ToPsz10(true), XML_indent, ToPsz10(false), - XML_outline, ToPsz10(true), - XML_outlineData, ToPsz10(true), + XML_outline, ToPsz10(!bTabularMode), + XML_outlineData, ToPsz10(!bTabularMode), XML_compact, ToPsz10(false), XML_compactData, ToPsz10(false), FSEND); @@ -730,25 +733,51 @@ void XclExpXmlPivotTables::SavePivotTableXml( XclExpXmlStream& rStrm, const ScDP continue; } + bool bDimInTabularMode = false; + if(pDim->GetLayoutInfo()) + bDimInTabularMode |= (pDim->GetLayoutInfo()->LayoutMode == sheet::DataPilotFieldLayoutMode::TABULAR_LAYOUT); + sheet::DataPilotFieldOrientation eOrient = pDim->GetOrientation(); if (eOrient == sheet::DataPilotFieldOrientation_HIDDEN) { - pPivotStrm->singleElement(XML_pivotField, - XML_showAll, ToPsz10(false), - XML_compact, ToPsz10(false), - FSEND); + if(bDimInTabularMode) + { + pPivotStrm->singleElement(XML_pivotField, + XML_showAll, ToPsz10(false), + XML_compact, ToPsz10(false), + XML_outline, ToPsz10(false), + FSEND); + } + else + { + pPivotStrm->singleElement(XML_pivotField, + XML_showAll, ToPsz10(false), + XML_compact, ToPsz10(false), + FSEND); + } continue; } if (eOrient == sheet::DataPilotFieldOrientation_DATA) { - pPivotStrm->singleElement(XML_pivotField, - XML_dataField, ToPsz10(true), - XML_showAll, ToPsz10(false), - XML_compact, ToPsz10(false), - FSEND); - + if(bDimInTabularMode) + { + pPivotStrm->singleElement(XML_pivotField, + XML_dataField, ToPsz10(true), + XML_showAll, ToPsz10(false), + XML_compact, ToPsz10(false), + XML_outline, ToPsz10(false), + FSEND); + } + else + { + pPivotStrm->singleElement(XML_pivotField, + XML_dataField, ToPsz10(true), + XML_showAll, ToPsz10(false), + XML_compact, ToPsz10(false), + FSEND); + } continue; } @@ -817,6 +846,8 @@ void XclExpXmlPivotTables::SavePivotTableXml( XclExpXmlStream& rStrm, const ScDP pAttList->add(XML_defaultSubtotal, ToPsz10(false)); pAttList->add( XML_compact, ToPsz10(false)); + if(bDimInTabularMode) + pAttList->add( XML_outline, ToPsz10(false)); sax_fastparser::XFastAttributeListRef xAttributeList(pAttList); pPivotStrm->startElement(XML_pivotField, xAttributeList); |