diff options
author | Tamás Zolnai <tamas.zolnai@collabora.com> | 2017-09-30 16:35:40 +0200 |
---|---|---|
committer | Tamás Zolnai <tamas.zolnai@collabora.com> | 2017-09-30 20:24:20 +0200 |
commit | 625653c8d119e720fb93b0c9f6f50d1eb625b179 (patch) | |
tree | 8915a667ae91270259ee2c9540c0259d13beb59c /sc/qa | |
parent | c3609f107b16eb888edf284f4637be6cb09234eb (diff) |
tdf#107711:Pivot table: filtering of non-string fields is not exported to XLSX
Same issue what we have in case of XLS filter. We need to have
the right string representation of pivot field items.
Change-Id: Ifb686ad268c61b03c7dcccc66f65e6f8247eab4f
Reviewed-on: https://gerrit.libreoffice.org/42956
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Tamás Zolnai <tamas.zolnai@collabora.com>
Diffstat (limited to 'sc/qa')
-rwxr-xr-x | sc/qa/unit/data/xlsx/pivottable_bool_field_filter.xlsx | bin | 0 -> 16583 bytes | |||
-rwxr-xr-x | sc/qa/unit/data/xlsx/pivottable_date_field_filter.xlsx | bin | 0 -> 16402 bytes | |||
-rwxr-xr-x | sc/qa/unit/data/xlsx/pivottable_double_field_filter.xlsx | bin | 0 -> 18252 bytes | |||
-rwxr-xr-x | sc/qa/unit/data/xlsx/pivottable_rowcolpage_field_filter.xlsx | bin | 0 -> 15511 bytes | |||
-rwxr-xr-x | sc/qa/unit/data/xlsx/pivottable_string_field_filter.xlsx | bin | 0 -> 15330 bytes | |||
-rw-r--r-- | sc/qa/unit/subsequent_export-test.cxx | 341 |
6 files changed, 341 insertions, 0 deletions
diff --git a/sc/qa/unit/data/xlsx/pivottable_bool_field_filter.xlsx b/sc/qa/unit/data/xlsx/pivottable_bool_field_filter.xlsx Binary files differnew file mode 100755 index 000000000000..8fcdb1bec102 --- /dev/null +++ b/sc/qa/unit/data/xlsx/pivottable_bool_field_filter.xlsx diff --git a/sc/qa/unit/data/xlsx/pivottable_date_field_filter.xlsx b/sc/qa/unit/data/xlsx/pivottable_date_field_filter.xlsx Binary files differnew file mode 100755 index 000000000000..316f201a5043 --- /dev/null +++ b/sc/qa/unit/data/xlsx/pivottable_date_field_filter.xlsx diff --git a/sc/qa/unit/data/xlsx/pivottable_double_field_filter.xlsx b/sc/qa/unit/data/xlsx/pivottable_double_field_filter.xlsx Binary files differnew file mode 100755 index 000000000000..f2d3597b273c --- /dev/null +++ b/sc/qa/unit/data/xlsx/pivottable_double_field_filter.xlsx diff --git a/sc/qa/unit/data/xlsx/pivottable_rowcolpage_field_filter.xlsx b/sc/qa/unit/data/xlsx/pivottable_rowcolpage_field_filter.xlsx Binary files differnew file mode 100755 index 000000000000..4aaa32794519 --- /dev/null +++ b/sc/qa/unit/data/xlsx/pivottable_rowcolpage_field_filter.xlsx diff --git a/sc/qa/unit/data/xlsx/pivottable_string_field_filter.xlsx b/sc/qa/unit/data/xlsx/pivottable_string_field_filter.xlsx Binary files differnew file mode 100755 index 000000000000..3bb6a77bcb79 --- /dev/null +++ b/sc/qa/unit/data/xlsx/pivottable_string_field_filter.xlsx diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx index aad799b90285..544d3623fce1 100644 --- a/sc/qa/unit/subsequent_export-test.cxx +++ b/sc/qa/unit/subsequent_export-test.cxx @@ -220,6 +220,11 @@ public: void testPivotTableEmptyItem(); void testPivotTablePageFieldFilter(); void testPivotTableFirstHeaderRowXLSX(); + void testPivotTableDoubleFieldFilterXLSX(); + void testPivotTableStringFieldFilterXLSX(); + void testPivotTableDateFieldFilterXLSX(); + void testPivotTableBoolFieldFilterXLSX(); + void testPivotTableRowColPageFieldFilterXLSX(); CPPUNIT_TEST_SUITE(ScExportTest); CPPUNIT_TEST(test); @@ -334,6 +339,11 @@ public: CPPUNIT_TEST(testPivotTableEmptyItem); CPPUNIT_TEST(testPivotTablePageFieldFilter); CPPUNIT_TEST(testPivotTableFirstHeaderRowXLSX); + CPPUNIT_TEST(testPivotTableDoubleFieldFilterXLSX); + CPPUNIT_TEST(testPivotTableStringFieldFilterXLSX); + CPPUNIT_TEST(testPivotTableDateFieldFilterXLSX); + CPPUNIT_TEST(testPivotTableBoolFieldFilterXLSX); + CPPUNIT_TEST(testPivotTableRowColPageFieldFilterXLSX); CPPUNIT_TEST_SUITE_END(); @@ -4878,6 +4888,337 @@ void ScExportTest::testPivotTableFirstHeaderRowXLSX() assertXPath(pTable, "/x:pivotTableDefinition/x:location", "firstHeaderRow", "1"); } +void ScExportTest::testPivotTableDoubleFieldFilterXLSX() +{ + ScDocShellRef xDocSh = loadDoc("pivottable_double_field_filter.", FORMAT_XLSX); + CPPUNIT_ASSERT_MESSAGE("Failed to load file", xDocSh.is()); + ScDocument& rDoc = xDocSh->GetDocument(); + ScDPCollection* pDPs = rDoc.GetDPCollection(); + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(3), pDPs->GetCount()); + + // Reload and check filtering of row dimensions + xDocSh = saveAndReload( &(*xDocSh), FORMAT_XLSX); + CPPUNIT_ASSERT_MESSAGE("Failed to load file", xDocSh.is()); + ScDocument& rLoadedDoc = xDocSh->GetDocument(); + pDPs = rLoadedDoc.GetDPCollection(); + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(3), pDPs->GetCount()); + + // Field with general formatting + { + const ScDPObject* pDPObj = &(*pDPs)[0]; + CPPUNIT_ASSERT(pDPObj); + ScDPSaveData* pSaveData = pDPObj->GetSaveData(); + CPPUNIT_ASSERT(pSaveData); + ScDPSaveDimension* pSaveDim = pSaveData->GetExistingDimensionByName("Double field1"); + CPPUNIT_ASSERT(pSaveDim); + + const ScDPSaveDimension::MemberList& rMembers = pSaveDim->GetMembers(); + CPPUNIT_ASSERT_EQUAL(size_t(3), rMembers.size()); + auto aIter = rMembers.begin(); + ScDPSaveMember* pMember = *aIter; // "1" + CPPUNIT_ASSERT(pMember); + CPPUNIT_ASSERT(pMember->HasIsVisible() && !pMember->GetIsVisible()); + ++aIter; + pMember = *aIter; // "2" + CPPUNIT_ASSERT(pMember); + CPPUNIT_ASSERT(pMember->HasIsVisible() && pMember->GetIsVisible()); + ++aIter; + pMember = *aIter; // "3" + CPPUNIT_ASSERT(pMember); + CPPUNIT_ASSERT(pMember->HasIsVisible() && pMember->GetIsVisible()); + } + + // Number formatting + { + const ScDPObject* pDPObj = &(*pDPs)[1]; + CPPUNIT_ASSERT(pDPObj); + ScDPSaveData* pSaveData = pDPObj->GetSaveData(); + CPPUNIT_ASSERT(pSaveData); + ScDPSaveDimension* pSaveDim = pSaveData->GetExistingDimensionByName("Double field2"); + CPPUNIT_ASSERT(pSaveDim); + + const ScDPSaveDimension::MemberList& rMembers = pSaveDim->GetMembers(); + CPPUNIT_ASSERT_EQUAL(size_t(3), rMembers.size()); + auto aIter = rMembers.begin(); + ScDPSaveMember* pMember = *aIter; // "1.00" + CPPUNIT_ASSERT(pMember); + CPPUNIT_ASSERT(pMember->HasIsVisible() && pMember->GetIsVisible()); + ++aIter; + pMember = *aIter; // "2.00" + CPPUNIT_ASSERT(pMember); + CPPUNIT_ASSERT(pMember->HasIsVisible() && !pMember->GetIsVisible()); + ++aIter; + pMember = *aIter; // "3.00" + CPPUNIT_ASSERT(pMember); + CPPUNIT_ASSERT(pMember->HasIsVisible() && !pMember->GetIsVisible()); + } + + // With thousand separator + { + const ScDPObject* pDPObj = &(*pDPs)[2]; + CPPUNIT_ASSERT(pDPObj); + ScDPSaveData* pSaveData = pDPObj->GetSaveData(); + CPPUNIT_ASSERT(pSaveData); + ScDPSaveDimension* pSaveDim = pSaveData->GetExistingDimensionByName("Double field3"); + CPPUNIT_ASSERT(pSaveDim); + + const ScDPSaveDimension::MemberList& rMembers = pSaveDim->GetMembers(); + CPPUNIT_ASSERT_EQUAL(size_t(3), rMembers.size()); + auto aIter = rMembers.begin(); + ScDPSaveMember* pMember = *aIter; // "10,000.00" + CPPUNIT_ASSERT(pMember); + CPPUNIT_ASSERT(pMember->HasIsVisible() && pMember->GetIsVisible()); + ++aIter; + pMember = *aIter; // "20,000.00" + CPPUNIT_ASSERT(pMember); + CPPUNIT_ASSERT(pMember->HasIsVisible() && !pMember->GetIsVisible()); + ++aIter; + pMember = *aIter; // "30,000.00" + CPPUNIT_ASSERT(pMember); + CPPUNIT_ASSERT(pMember->HasIsVisible() && pMember->GetIsVisible()); + } + + xDocSh->DoClose(); +} + +void ScExportTest::testPivotTableStringFieldFilterXLSX() +{ + ScDocShellRef xDocSh = loadDoc("pivottable_string_field_filter.", FORMAT_XLSX); + CPPUNIT_ASSERT_MESSAGE("Failed to load file", xDocSh.is()); + ScDocument& rDoc = xDocSh->GetDocument(); + ScDPCollection* pDPs = rDoc.GetDPCollection(); + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), pDPs->GetCount()); + + // Reload and check filtering of row dimensions + xDocSh = saveAndReload( &(*xDocSh), FORMAT_XLSX); + CPPUNIT_ASSERT_MESSAGE("Failed to load file", xDocSh.is()); + ScDocument& rLoadedDoc = xDocSh->GetDocument(); + pDPs = rLoadedDoc.GetDPCollection(); + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), pDPs->GetCount()); + + const ScDPObject* pDPObj = &(*pDPs)[0]; + CPPUNIT_ASSERT(pDPObj); + ScDPSaveData* pSaveData = pDPObj->GetSaveData(); + CPPUNIT_ASSERT(pSaveData); + ScDPSaveDimension* pSaveDim = pSaveData->GetExistingDimensionByName("Country"); + CPPUNIT_ASSERT(pSaveDim); + + const ScDPSaveDimension::MemberList& rMembers = pSaveDim->GetMembers(); + CPPUNIT_ASSERT_EQUAL(size_t(2), rMembers.size()); + ScDPSaveMember* pMember = pSaveDim->GetExistingMemberByName("United Kingdom"); + CPPUNIT_ASSERT(pMember); + CPPUNIT_ASSERT(pMember->HasIsVisible() && !pMember->GetIsVisible()); + pMember = pSaveDim->GetExistingMemberByName("United States"); + CPPUNIT_ASSERT(pMember); + CPPUNIT_ASSERT(pMember->HasIsVisible() && pMember->GetIsVisible()); + + xDocSh->DoClose(); +} + + +void ScExportTest::testPivotTableDateFieldFilterXLSX() +{ + ScDocShellRef xDocSh = loadDoc("pivottable_date_field_filter.", FORMAT_XLSX); + CPPUNIT_ASSERT_MESSAGE("Failed to load file", xDocSh.is()); + ScDocument& rDoc = xDocSh->GetDocument(); + ScDPCollection* pDPs = rDoc.GetDPCollection(); + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), pDPs->GetCount()); + + // Reload and check filtering of row dimensions + xDocSh = saveAndReload( &(*xDocSh), FORMAT_XLSX); + CPPUNIT_ASSERT_MESSAGE("Failed to load file", xDocSh.is()); + ScDocument& rLoadedDoc = xDocSh->GetDocument(); + pDPs = rLoadedDoc.GetDPCollection(); + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), pDPs->GetCount()); + const ScDPObject* pDPObj = &(*pDPs)[0]; + CPPUNIT_ASSERT(pDPObj); + ScDPSaveData* pSaveData = pDPObj->GetSaveData(); + CPPUNIT_ASSERT(pSaveData); + + { + ScDPSaveDimension* pSaveDim = pSaveData->GetExistingDimensionByName("Date"); + CPPUNIT_ASSERT(pSaveDim); + + const ScDPSaveDimension::MemberList& rMembers = pSaveDim->GetMembers(); + //CPPUNIT_ASSERT_EQUAL(size_t(3), rMembers.size()); + auto aIter = rMembers.begin(); + ScDPSaveMember* pMember = *aIter; // "2016. január 7." + CPPUNIT_ASSERT(pMember); + CPPUNIT_ASSERT(pMember->HasIsVisible() && pMember->GetIsVisible()); + ++aIter; + pMember = *aIter; // "2016. január 8." + CPPUNIT_ASSERT(pMember); + CPPUNIT_ASSERT(pMember->HasIsVisible() && !pMember->GetIsVisible()); + } + + { + ScDPSaveDimension* pSaveDim = pSaveData->GetExistingDimensionByName("Date2"); + CPPUNIT_ASSERT(pSaveDim); + + const ScDPSaveDimension::MemberList& rMembers = pSaveDim->GetMembers(); + CPPUNIT_ASSERT_EQUAL(size_t(3), rMembers.size()); + auto aIter = rMembers.begin(); + ScDPSaveMember* pMember = *aIter; // "2016-01-07" + CPPUNIT_ASSERT(pMember); + CPPUNIT_ASSERT(pMember->HasIsVisible() && pMember->GetIsVisible()); + ++aIter; + pMember = *aIter; // "2016-01-08" + CPPUNIT_ASSERT(pMember); + CPPUNIT_ASSERT(pMember->HasIsVisible() && !pMember->GetIsVisible()); + } + + { + ScDPSaveDimension* pSaveDim = pSaveData->GetExistingDimensionByName("Date3"); + CPPUNIT_ASSERT(pSaveDim); + + const ScDPSaveDimension::MemberList& rMembers = pSaveDim->GetMembers(); + CPPUNIT_ASSERT_EQUAL(size_t(3), rMembers.size()); + auto aIter = rMembers.begin(); + ScDPSaveMember* pMember = *aIter; // "2016. 1. 7. 0:00" + CPPUNIT_ASSERT(pMember); + CPPUNIT_ASSERT(pMember->HasIsVisible() && !pMember->GetIsVisible()); + ++aIter; + pMember = *aIter; // "2016. 1. 8. 0:00" + CPPUNIT_ASSERT(pMember); + CPPUNIT_ASSERT(pMember->HasIsVisible() && pMember->GetIsVisible()); + } + + xDocSh->DoClose(); +} + +void ScExportTest::testPivotTableBoolFieldFilterXLSX() +{ + ScDocShellRef xDocSh = loadDoc("pivottable_bool_field_filter.", FORMAT_XLSX); + CPPUNIT_ASSERT_MESSAGE("Failed to load file", xDocSh.is()); + ScDocument& rDoc = xDocSh->GetDocument(); + ScDPCollection* pDPs = rDoc.GetDPCollection(); + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), pDPs->GetCount()); + + // Reload and check filtering of row dimensions + xDocSh = saveAndReload( &(*xDocSh), FORMAT_XLSX); + CPPUNIT_ASSERT_MESSAGE("Failed to load file", xDocSh.is()); + ScDocument& rLoadedDoc = xDocSh->GetDocument(); + pDPs = rLoadedDoc.GetDPCollection(); + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), pDPs->GetCount()); + const ScDPObject* pDPObj = &(*pDPs)[0]; + CPPUNIT_ASSERT(pDPObj); + ScDPSaveData* pSaveData = pDPObj->GetSaveData(); + CPPUNIT_ASSERT(pSaveData); + + ScDPSaveDimension* pSaveDim = pSaveData->GetExistingDimensionByName("Bool field"); + CPPUNIT_ASSERT(pSaveDim); + + const ScDPSaveDimension::MemberList& rMembers = pSaveDim->GetMembers(); + CPPUNIT_ASSERT_EQUAL(size_t(2), rMembers.size()); + ScDPSaveMember* pMember = pSaveDim->GetExistingMemberByName("0"); + CPPUNIT_ASSERT(pMember); + CPPUNIT_ASSERT(pMember->HasIsVisible() && !pMember->GetIsVisible()); + pMember = pSaveDim->GetExistingMemberByName("1"); + CPPUNIT_ASSERT(pMember); + CPPUNIT_ASSERT(pMember->HasIsVisible() && pMember->GetIsVisible()); + + xDocSh->DoClose(); +} + +void ScExportTest::testPivotTableRowColPageFieldFilterXLSX() +{ + ScDocShellRef xDocSh = loadDoc("pivottable_rowcolpage_field_filter.", FORMAT_XLSX); + CPPUNIT_ASSERT_MESSAGE("Failed to load file", xDocSh.is()); + ScDocument& rDoc = xDocSh->GetDocument(); + ScDPCollection* pDPs = rDoc.GetDPCollection(); + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), pDPs->GetCount()); + + // Reload and check filtering of row dimensions + xDocSh = saveAndReload( &(*xDocSh), FORMAT_XLSX); + CPPUNIT_ASSERT_MESSAGE("Failed to load file", xDocSh.is()); + ScDocument& rLoadedDoc = xDocSh->GetDocument(); + pDPs = rLoadedDoc.GetDPCollection(); + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), pDPs->GetCount()); + const ScDPObject* pDPObj = &(*pDPs)[0]; + CPPUNIT_ASSERT(pDPObj); + ScDPSaveData* pSaveData = pDPObj->GetSaveData(); + CPPUNIT_ASSERT(pSaveData); + + // Row field + { + ScDPSaveDimension* pSaveDim = pSaveData->GetExistingDimensionByName("Order ID"); + CPPUNIT_ASSERT(pSaveDim); + CPPUNIT_ASSERT_EQUAL(sheet::DataPilotFieldOrientation_ROW, pSaveDim->GetOrientation()); + + const ScDPSaveDimension::MemberList& rMembers = pSaveDim->GetMembers(); + CPPUNIT_ASSERT_EQUAL(size_t(3), rMembers.size()); + ScDPSaveMember* pMember = pSaveDim->GetExistingMemberByName("1"); + CPPUNIT_ASSERT(pMember); + CPPUNIT_ASSERT(pMember->HasIsVisible() && pMember->GetIsVisible()); + pMember = pSaveDim->GetExistingMemberByName("2"); + CPPUNIT_ASSERT(pMember); + CPPUNIT_ASSERT(pMember->HasIsVisible() && pMember->GetIsVisible()); + pMember = pSaveDim->GetExistingMemberByName("3"); + CPPUNIT_ASSERT(pMember); + CPPUNIT_ASSERT(pMember->HasIsVisible() && !pMember->GetIsVisible()); + } + + // Column field + { + ScDPSaveDimension* pSaveDim = pSaveData->GetExistingDimensionByName("Double2 field"); + CPPUNIT_ASSERT(pSaveDim); + CPPUNIT_ASSERT_EQUAL(sheet::DataPilotFieldOrientation_COLUMN, pSaveDim->GetOrientation()); + + const ScDPSaveDimension::MemberList& rMembers = pSaveDim->GetMembers(); + CPPUNIT_ASSERT_EQUAL(size_t(3), rMembers.size()); + ScDPSaveMember* pMember = pSaveDim->GetExistingMemberByName("2"); + CPPUNIT_ASSERT(pMember); + CPPUNIT_ASSERT(pMember->HasIsVisible() && pMember->GetIsVisible()); + pMember = pSaveDim->GetExistingMemberByName("3"); + CPPUNIT_ASSERT(pMember); + CPPUNIT_ASSERT(pMember->HasIsVisible() && pMember->GetIsVisible()); + pMember = pSaveDim->GetExistingMemberByName("4"); + CPPUNIT_ASSERT(pMember); + CPPUNIT_ASSERT(pMember->HasIsVisible() && !pMember->GetIsVisible()); + } + + // Page field + { + ScDPSaveDimension* pSaveDim = pSaveData->GetExistingDimensionByName("Double3 field"); + CPPUNIT_ASSERT(pSaveDim); + CPPUNIT_ASSERT_EQUAL(sheet::DataPilotFieldOrientation_PAGE, pSaveDim->GetOrientation()); + + const ScDPSaveDimension::MemberList& rMembers = pSaveDim->GetMembers(); + CPPUNIT_ASSERT_EQUAL(size_t(3), rMembers.size()); + ScDPSaveMember* pMember = pSaveDim->GetExistingMemberByName("5"); + CPPUNIT_ASSERT(pMember); + CPPUNIT_ASSERT(pMember->HasIsVisible() && pMember->GetIsVisible()); + pMember = pSaveDim->GetExistingMemberByName("6"); + CPPUNIT_ASSERT(pMember); + CPPUNIT_ASSERT(pMember->HasIsVisible() && !pMember->GetIsVisible()); + pMember = pSaveDim->GetExistingMemberByName("7"); + CPPUNIT_ASSERT(pMember); + CPPUNIT_ASSERT(pMember->HasIsVisible() && pMember->GetIsVisible()); + } + + // Hidden field + /* TODO + { + ScDPSaveDimension* pSaveDim = pSaveData->GetExistingDimensionByName("Double4 field"); + CPPUNIT_ASSERT(pSaveDim); + CPPUNIT_ASSERT_EQUAL(sheet::DataPilotFieldOrientation_HIDDEN, pSaveDim->GetOrientation()); + + const ScDPSaveDimension::MemberList& rMembers = pSaveDim->GetMembers(); + CPPUNIT_ASSERT_EQUAL(size_t(3), rMembers.size()); + ScDPSaveMember* pMember = pSaveDim->GetExistingMemberByName("8"); + CPPUNIT_ASSERT(pMember); + CPPUNIT_ASSERT(pMember->HasIsVisible() && !pMember->GetIsVisible()); + pMember = pSaveDim->GetExistingMemberByName("9"); + CPPUNIT_ASSERT(pMember); + CPPUNIT_ASSERT(pMember->HasIsVisible() && pMember->GetIsVisible()); + pMember = pSaveDim->GetExistingMemberByName("10"); + CPPUNIT_ASSERT(pMember); + CPPUNIT_ASSERT(pMember->HasIsVisible() && pMember->GetIsVisible()); + }*/ + + xDocSh->DoClose(); +} + CPPUNIT_TEST_SUITE_REGISTRATION(ScExportTest); CPPUNIT_PLUGIN_IMPLEMENT(); |