[Libreoffice-commits] core.git: sc/inc sc/qa

Kohei Yoshida kohei.yoshida at collabora.com
Tue Dec 10 17:54:09 PST 2013


 sc/inc/document.hxx                                         |    2 
 sc/inc/dpobject.hxx                                         |    4 
 sc/qa/unit/data/ods/pivot-table-shared-cache-with-group.ods |binary
 sc/qa/unit/subsequent_filters-test.cxx                      |   70 ++++++++++++
 4 files changed, 73 insertions(+), 3 deletions(-)

New commits:
commit e8fff12af2c0bc3172c3db830b5f6a59869e5be0
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Tue Dec 10 20:53:44 2013 -0500

    fdo#66969: Add test to ensure we import page field's visibility correctly.
    
    Change-Id: I407b1f552ce089c0ff1d6bdadc1cc618fb713646

diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 7a00c1d..47ff391 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 803a05e..6c0a64d 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
new file mode 100644
index 0000000..b1ec981
Binary files /dev/null and b/sc/qa/unit/data/ods/pivot-table-shared-cache-with-group.ods differ
diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx
index a05b161..69633e6 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);


More information about the Libreoffice-commits mailing list