Kaydet (Commit) 8cf0b4b4 authored tarafından Tamás Zolnai's avatar Tamás Zolnai

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/43537Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarTamás Zolnai <tamas.zolnai@collabora.com>
üst c79da868
...@@ -228,6 +228,7 @@ public: ...@@ -228,6 +228,7 @@ public:
void testPivotTableErrorItemFilterXLSX(); void testPivotTableErrorItemFilterXLSX();
void testPivotTableOutlineModeXLSX(); void testPivotTableOutlineModeXLSX();
void testPivotTableDuplicatedMemberFilterXLSX(); void testPivotTableDuplicatedMemberFilterXLSX();
void testPivotTableTabularModeXLSX();
CPPUNIT_TEST_SUITE(ScExportTest); CPPUNIT_TEST_SUITE(ScExportTest);
CPPUNIT_TEST(test); CPPUNIT_TEST(test);
...@@ -350,6 +351,7 @@ public: ...@@ -350,6 +351,7 @@ public:
CPPUNIT_TEST(testPivotTableErrorItemFilterXLSX); CPPUNIT_TEST(testPivotTableErrorItemFilterXLSX);
CPPUNIT_TEST(testPivotTableOutlineModeXLSX); CPPUNIT_TEST(testPivotTableOutlineModeXLSX);
CPPUNIT_TEST(testPivotTableDuplicatedMemberFilterXLSX); CPPUNIT_TEST(testPivotTableDuplicatedMemberFilterXLSX);
CPPUNIT_TEST(testPivotTableTabularModeXLSX);
CPPUNIT_TEST_SUITE_END(); CPPUNIT_TEST_SUITE_END();
...@@ -5286,6 +5288,24 @@ void ScExportTest::testPivotTableDuplicatedMemberFilterXLSX() ...@@ -5286,6 +5288,24 @@ void ScExportTest::testPivotTableDuplicatedMemberFilterXLSX()
assertXPath(pTable, "/x:pivotTableDefinition/x:pivotFields/x:pivotField[5]/x:items", "count", "21"); 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_TEST_SUITE_REGISTRATION(ScExportTest);
CPPUNIT_PLUGIN_IMPLEMENT(); CPPUNIT_PLUGIN_IMPLEMENT();
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include <sax/tools/converter.hxx> #include <sax/tools/converter.hxx>
#include <com/sun/star/sheet/DataPilotFieldOrientation.hpp> #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/DataPilotOutputRangeType.hpp>
#include <com/sun/star/sheet/GeneralFunction.hpp> #include <com/sun/star/sheet/GeneralFunction.hpp>
...@@ -613,7 +614,7 @@ void XclExpXmlPivotTables::SavePivotTableXml( XclExpXmlStream& rStrm, const ScDP ...@@ -613,7 +614,7 @@ void XclExpXmlPivotTables::SavePivotTableXml( XclExpXmlStream& rStrm, const ScDP
// Dimension order here is significant as they specify the order of // Dimension order here is significant as they specify the order of
// appearance in each axis. // appearance in each axis.
const ScDPSaveData::DimsType& rDims = rSaveData.GetDimensions(); const ScDPSaveData::DimsType& rDims = rSaveData.GetDimensions();
bool bTabularMode = false;
for (const auto & i : rDims) for (const auto & i : rDims)
{ {
const ScDPSaveDimension& rDim = *i; const ScDPSaveDimension& rDim = *i;
...@@ -655,6 +656,8 @@ void XclExpXmlPivotTables::SavePivotTableXml( XclExpXmlStream& rStrm, const ScDP ...@@ -655,6 +656,8 @@ void XclExpXmlPivotTables::SavePivotTableXml( XclExpXmlStream& rStrm, const ScDP
default: default:
; ;
} }
if(rDim.GetLayoutInfo())
bTabularMode |= (rDim.GetLayoutInfo()->LayoutMode == sheet::DataPilotFieldLayoutMode::TABULAR_LAYOUT);
} }
sax_fastparser::FSHelperPtr& pPivotStrm = rStrm.GetCurrentStream(); sax_fastparser::FSHelperPtr& pPivotStrm = rStrm.GetCurrentStream();
...@@ -672,8 +675,8 @@ void XclExpXmlPivotTables::SavePivotTableXml( XclExpXmlStream& rStrm, const ScDP ...@@ -672,8 +675,8 @@ void XclExpXmlPivotTables::SavePivotTableXml( XclExpXmlStream& rStrm, const ScDP
XML_useAutoFormatting, ToPsz10(false), XML_useAutoFormatting, ToPsz10(false),
XML_itemPrintTitles, ToPsz10(true), XML_itemPrintTitles, ToPsz10(true),
XML_indent, ToPsz10(false), XML_indent, ToPsz10(false),
XML_outline, ToPsz10(true), XML_outline, ToPsz10(!bTabularMode),
XML_outlineData, ToPsz10(true), XML_outlineData, ToPsz10(!bTabularMode),
XML_compact, ToPsz10(false), XML_compact, ToPsz10(false),
XML_compactData, ToPsz10(false), XML_compactData, ToPsz10(false),
FSEND); FSEND);
...@@ -730,25 +733,51 @@ void XclExpXmlPivotTables::SavePivotTableXml( XclExpXmlStream& rStrm, const ScDP ...@@ -730,25 +733,51 @@ void XclExpXmlPivotTables::SavePivotTableXml( XclExpXmlStream& rStrm, const ScDP
continue; continue;
} }
bool bDimInTabularMode = false;
if(pDim->GetLayoutInfo())
bDimInTabularMode |= (pDim->GetLayoutInfo()->LayoutMode == sheet::DataPilotFieldLayoutMode::TABULAR_LAYOUT);
sheet::DataPilotFieldOrientation eOrient = pDim->GetOrientation(); sheet::DataPilotFieldOrientation eOrient = pDim->GetOrientation();
if (eOrient == sheet::DataPilotFieldOrientation_HIDDEN) if (eOrient == sheet::DataPilotFieldOrientation_HIDDEN)
{ {
pPivotStrm->singleElement(XML_pivotField, if(bDimInTabularMode)
XML_showAll, ToPsz10(false), {
XML_compact, ToPsz10(false), pPivotStrm->singleElement(XML_pivotField,
FSEND); 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; continue;
} }
if (eOrient == sheet::DataPilotFieldOrientation_DATA) if (eOrient == sheet::DataPilotFieldOrientation_DATA)
{ {
pPivotStrm->singleElement(XML_pivotField, if(bDimInTabularMode)
XML_dataField, ToPsz10(true), {
XML_showAll, ToPsz10(false), pPivotStrm->singleElement(XML_pivotField,
XML_compact, ToPsz10(false), XML_dataField, ToPsz10(true),
FSEND); 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; continue;
} }
...@@ -817,6 +846,8 @@ void XclExpXmlPivotTables::SavePivotTableXml( XclExpXmlStream& rStrm, const ScDP ...@@ -817,6 +846,8 @@ void XclExpXmlPivotTables::SavePivotTableXml( XclExpXmlStream& rStrm, const ScDP
pAttList->add(XML_defaultSubtotal, ToPsz10(false)); pAttList->add(XML_defaultSubtotal, ToPsz10(false));
pAttList->add( XML_compact, ToPsz10(false)); pAttList->add( XML_compact, ToPsz10(false));
if(bDimInTabularMode)
pAttList->add( XML_outline, ToPsz10(false));
sax_fastparser::XFastAttributeListRef xAttributeList(pAttList); sax_fastparser::XFastAttributeListRef xAttributeList(pAttList);
pPivotStrm->startElement(XML_pivotField, xAttributeList); pPivotStrm->startElement(XML_pivotField, xAttributeList);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment