diff options
author | Kohei Yoshida <kohei.yoshida@collabora.com> | 2013-12-10 20:53:44 -0500 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@collabora.com> | 2013-12-10 20:54:59 -0500 |
commit | e8fff12af2c0bc3172c3db830b5f6a59869e5be0 (patch) | |
tree | db0082406b2ea5f135b4d6b70aef58e05a4ae5b8 /sc/qa/unit | |
parent | b3977983e9f662392426f581516d86d7034ad0fd (diff) |
fdo#66969: Add test to ensure we import page field's visibility correctly.
Change-Id: I407b1f552ce089c0ff1d6bdadc1cc618fb713646
Diffstat (limited to 'sc/qa/unit')
-rw-r--r-- | sc/qa/unit/data/ods/pivot-table-shared-cache-with-group.ods | bin | 0 -> 28325 bytes | |||
-rw-r--r-- | sc/qa/unit/subsequent_filters-test.cxx | 70 |
2 files changed, 70 insertions, 0 deletions
diff --git a/sc/qa/unit/data/ods/pivot-table-shared-cache-with-group.ods b/sc/qa/unit/data/ods/pivot-table-shared-cache-with-group.ods Binary files differnew file mode 100644 index 000000000000..b1ec9819cd14 --- /dev/null +++ b/sc/qa/unit/data/ods/pivot-table-shared-cache-with-group.ods diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx index a05b161fc716..69633e67ed75 100644 --- a/sc/qa/unit/subsequent_filters-test.cxx +++ b/sc/qa/unit/subsequent_filters-test.cxx @@ -45,6 +45,7 @@ #include "editutil.hxx" #include "cellvalue.hxx" #include "attrib.hxx" +#include "dpsave.hxx" #include <com/sun/star/drawing/XDrawPageSupplier.hpp> #include <com/sun/star/drawing/XControlShape.hpp> @@ -138,6 +139,8 @@ public: void testCellAnchoredShapesODS(); void testPivotTableBasicODS(); + void testPivotTableSharedCacheGroupODS(); + void testFormulaDependency(); void testRowHeightODS(); @@ -198,6 +201,7 @@ public: CPPUNIT_TEST(testCellAnchoredShapesODS); CPPUNIT_TEST(testPivotTableBasicODS); + CPPUNIT_TEST(testPivotTableSharedCacheGroupODS); CPPUNIT_TEST(testRowHeightODS); CPPUNIT_TEST(testFormulaDependency); CPPUNIT_TEST(testRichTextContentODS); @@ -1646,6 +1650,72 @@ void ScFiltersTest::testPivotTableBasicODS() xDocSh->DoClose(); } +namespace { + +bool checkVisiblePageFieldMember( const ScDPSaveDimension::MemberList& rMembers, const OUString& rVisibleMember ) +{ + ScDPSaveDimension::MemberList::const_iterator it = rMembers.begin(), itEnd = rMembers.end(); + bool bFound = false; + for (; it != itEnd; ++it) + { + const ScDPSaveMember* pMem = *it; + if (pMem->GetName() == rVisibleMember) + { + bFound = true; + if (!pMem->GetIsVisible()) + // This member is supposed to be visible. Fail. + return false; + } + else + { + if (pMem->GetIsVisible()) + // This member is supposed to be hidden. Not good. + return false; + } + } + + return bFound; +} + +} + +void ScFiltersTest::testPivotTableSharedCacheGroupODS() +{ + ScDocShellRef xDocSh = loadDoc("pivot-table-shared-cache-with-group.", ODS); + CPPUNIT_ASSERT_MESSAGE("Failed to load file", xDocSh.Is()); + ScDocument* pDoc = xDocSh->GetDocument(); + + // Make sure that page field's visibility settings are loaded correctly. + + ScDPObject* pDPObj = pDoc->GetDPAtCursor(0, 0, 1); // A1 on 2nd sheet + CPPUNIT_ASSERT_MESSAGE("There should be a pivot table here.", pDPObj); + ScDPSaveData* pSaveData = pDPObj->GetSaveData(); + CPPUNIT_ASSERT_MESSAGE("Save data is expected.", pSaveData); + ScDPSaveDimension* pDim = pSaveData->GetExistingDimensionByName("Project Name"); + CPPUNIT_ASSERT_MESSAGE("Failed to get page field named 'Project Name'.", pDim); + const ScDPSaveDimension::MemberList* pMembers = &pDim->GetMembers(); + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(14), pMembers->size()); + CPPUNIT_ASSERT_MESSAGE("Incorrect member visibility.", checkVisiblePageFieldMember(*pMembers, "APL-01-1")); + + pDPObj = pDoc->GetDPAtCursor(0, 1, 2); // A2 on 3rd sheet + CPPUNIT_ASSERT_MESSAGE("There should be a pivot table here.", pDPObj); + pSaveData = pDPObj->GetSaveData(); + CPPUNIT_ASSERT_MESSAGE("Save data is expected.", pSaveData); + pDim = pSaveData->GetExistingDimensionByName("Project Name"); + CPPUNIT_ASSERT_MESSAGE("Failed to get page field named 'Project Name'.", pDim); + pMembers = &pDim->GetMembers(); + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(14), pMembers->size()); + CPPUNIT_ASSERT_MESSAGE("Incorrect member visibility.", checkVisiblePageFieldMember(*pMembers, "VEN-01-1")); + + // These two pivot tables shared the same data range. We should only have + // one pivot cache. + ScDPCollection* pDPs = pDoc->GetDPCollection(); + ScDPCollection::SheetCaches& rSheetCaches = pDPs->GetSheetCaches(); + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), rSheetCaches.size()); + + xDocSh->DoClose(); +} + void ScFiltersTest::testRowHeightODS() { ScDocShellRef xDocSh = loadDoc("row-height-import.", ODS); |