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 | |
parent | b3977983e9f662392426f581516d86d7034ad0fd (diff) |
fdo#66969: Add test to ensure we import page field's visibility correctly.
Change-Id: I407b1f552ce089c0ff1d6bdadc1cc618fb713646
-rw-r--r-- | sc/inc/document.hxx | 2 | ||||
-rw-r--r-- | sc/inc/dpobject.hxx | 4 | ||||
-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 |
4 files changed, 73 insertions, 3 deletions
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx index 7a00c1d358a9..47ff391a3e6c 100644 --- a/sc/inc/document.hxx +++ b/sc/inc/document.hxx @@ -531,7 +531,7 @@ public: bool HasPivotTable() const; SC_DLLPUBLIC ScDPCollection* GetDPCollection(); SC_DLLPUBLIC const ScDPCollection* GetDPCollection() const; - ScDPObject* GetDPAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab) const; + SC_DLLPUBLIC ScDPObject* GetDPAtCursor(SCCOL nCol, SCROW nRow, SCTAB nTab) const; ScDPObject* GetDPAtBlock( const ScRange& rBlock ) const; SC_DLLPUBLIC ScChartCollection* GetChartCollection() const; diff --git a/sc/inc/dpobject.hxx b/sc/inc/dpobject.hxx index 803a05ebedcb..6c0a64dd3b0e 100644 --- a/sc/inc/dpobject.hxx +++ b/sc/inc/dpobject.hxx @@ -282,7 +282,7 @@ public: SheetCaches(ScDocument* pDoc); bool hasCache(const ScRange& rRange) const; const ScDPCache* getCache(const ScRange& rRange, const ScDPDimensionSaveData* pDimData); - size_t size() const; + SC_DLLPUBLIC size_t size() const; void updateReference( UpdateRefMode eMode, const ScRange& r, SCsCOL nDx, SCsROW nDy, SCsTAB nDz); @@ -397,7 +397,7 @@ public: void FreeTable(ScDPObject* pDPObj); SC_DLLPUBLIC bool InsertNewTable(ScDPObject* pDPObj); - SheetCaches& GetSheetCaches(); + SC_DLLPUBLIC SheetCaches& GetSheetCaches(); NameCaches& GetNameCaches(); DBCaches& GetDBCaches(); 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); |