sc/qa/unit/data/xlsx/pivottable_tabular_mode.xlsx |binary sc/qa/unit/subsequent_export-test.cxx | 20 +++++++ sc/source/filter/excel/xepivotxml.cxx | 57 ++++++++++++++++------ 3 files changed, 64 insertions(+), 13 deletions(-)
New commits: commit 24a673cd37ad8f63ad69904ef076ccfbdc59129d Author: Tamás Zolnai <tamas.zol...@collabora.com> Date: Fri Oct 27 22:03:32 2017 +0200 tdf#113159: Pivot table: tabular mode is converted to oultine mode ... after RT XLSX in Calc Reviewed-on: https://gerrit.libreoffice.org/43537 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Tamás Zolnai <tamas.zol...@collabora.com> (cherry picked from commit 8cf0b4b4cd748094889a6a9ac6883dd457113b74) Change-Id: I9725ca55aed973133db1d5fe47463575148e00b8 Reviewed-on: https://gerrit.libreoffice.org/43971 Reviewed-by: Andras Timar <andras.ti...@collabora.com> Tested-by: Andras Timar <andras.ti...@collabora.com> diff --git a/sc/qa/unit/data/xlsx/pivottable_tabular_mode.xlsx b/sc/qa/unit/data/xlsx/pivottable_tabular_mode.xlsx new file mode 100755 index 000000000000..0bcfe1742d95 Binary files /dev/null and b/sc/qa/unit/data/xlsx/pivottable_tabular_mode.xlsx differ diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx index dbf92510144a..4b6370ba64c8 100644 --- a/sc/qa/unit/subsequent_export-test.cxx +++ b/sc/qa/unit/subsequent_export-test.cxx @@ -216,6 +216,7 @@ public: void testPivotTableErrorItemFilterXLSX(); void testPivotTableOutlineModeXLSX(); void testPivotTableDuplicatedMemberFilterXLSX(); + void testPivotTableTabularModeXLSX(); CPPUNIT_TEST_SUITE(ScExportTest); CPPUNIT_TEST(test); @@ -332,6 +333,7 @@ public: CPPUNIT_TEST(testPivotTableErrorItemFilterXLSX); CPPUNIT_TEST(testPivotTableOutlineModeXLSX); CPPUNIT_TEST(testPivotTableDuplicatedMemberFilterXLSX); + CPPUNIT_TEST(testPivotTableTabularModeXLSX); CPPUNIT_TEST_SUITE_END(); @@ -5191,6 +5193,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 d567c8e1e87b..9c33b8277977 100644 --- a/sc/source/filter/excel/xepivotxml.cxx +++ b/sc/source/filter/excel/xepivotxml.cxx @@ -19,6 +19,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> @@ -614,7 +615,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; @@ -657,6 +658,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(); @@ -674,8 +677,8 @@ void XclExpXmlPivotTables::SavePivotTableXml( XclExpXmlStream& rStrm, const ScDP XML_useAutoFormatting, XclXmlUtils::ToPsz10(false), XML_itemPrintTitles, XclXmlUtils::ToPsz10(true), XML_indent, XclXmlUtils::ToPsz10(false), - XML_outline, XclXmlUtils::ToPsz10(true), - XML_outlineData, XclXmlUtils::ToPsz10(true), + XML_outline, XclXmlUtils::ToPsz10(!bTabularMode), + XML_outlineData, XclXmlUtils::ToPsz10(!bTabularMode), XML_compact, XclXmlUtils::ToPsz10(false), XML_compactData, XclXmlUtils::ToPsz10(false), FSEND); @@ -732,26 +735,52 @@ 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 = static_cast<sheet::DataPilotFieldOrientation>(pDim->GetOrientation()); if (eOrient == sheet::DataPilotFieldOrientation_HIDDEN) { - pPivotStrm->singleElement(XML_pivotField, - XML_showAll, XclXmlUtils::ToPsz10(false), - XML_compact, XclXmlUtils::ToPsz10(false), - FSEND); + if(bDimInTabularMode) + { + pPivotStrm->singleElement(XML_pivotField, + XML_showAll, XclXmlUtils::ToPsz10(false), + XML_compact, XclXmlUtils::ToPsz10(false), + XML_outline, XclXmlUtils::ToPsz10(false), + FSEND); + } + else + { + pPivotStrm->singleElement(XML_pivotField, + XML_showAll, XclXmlUtils::ToPsz10(false), + XML_compact, XclXmlUtils::ToPsz10(false), + FSEND); + } continue; } if (eOrient == sheet::DataPilotFieldOrientation_DATA) { - pPivotStrm->singleElement(XML_pivotField, - XML_dataField, XclXmlUtils::ToPsz10(true), - XML_showAll, XclXmlUtils::ToPsz10(false), - XML_compact, XclXmlUtils::ToPsz10(false), - FSEND); - + if(bDimInTabularMode) + { + pPivotStrm->singleElement(XML_pivotField, + XML_dataField, XclXmlUtils::ToPsz10(true), + XML_showAll, XclXmlUtils::ToPsz10(false), + XML_compact, XclXmlUtils::ToPsz10(false), + XML_outline, XclXmlUtils::ToPsz10(false), + FSEND); + } + else + { + pPivotStrm->singleElement(XML_pivotField, + XML_dataField, XclXmlUtils::ToPsz10(true), + XML_showAll, XclXmlUtils::ToPsz10(false), + XML_compact, XclXmlUtils::ToPsz10(false), + FSEND); + } continue; } @@ -820,6 +849,8 @@ void XclExpXmlPivotTables::SavePivotTableXml( XclExpXmlStream& rStrm, const ScDP pAttList->add(XML_defaultSubtotal, XclXmlUtils::ToPsz10(false)); pAttList->add( XML_compact, XclXmlUtils::ToPsz10(false)); + if(bDimInTabularMode) + pAttList->add( XML_outline, XclXmlUtils::ToPsz10(false)); sax_fastparser::XFastAttributeListRef xAttributeList(pAttList); pPivotStrm->startElement(XML_pivotField, xAttributeList);
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits