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

Tamás Zolnai tamas.zolnai at collabora.com
Fri Oct 7 19:08:26 UTC 2016


 sc/qa/unit/data/xlsx/pivot-table/shared-nested-dategroup.xlsx |binary
 sc/qa/unit/subsequent_filters-test.cxx                        |   45 ++++++++++
 sc/source/ui/unoobj/dapiuno.cxx                               |    2 
 3 files changed, 46 insertions(+), 1 deletion(-)

New commits:
commit 9d19634c8e719a80674ca4b3dfc3c7e49f049e5b
Author: Tamás Zolnai <tamas.zolnai at collabora.com>
Date:   Sat Oct 8 03:45:50 2016 +0200

    Pivot tables: Fix XLSX import of nested date groups
    
    Same fix which was added for other kind of groups:
    f697d7aa5c26f9fcfd717b76a4827a5bcb38325e
    
    Change-Id: Ic35602ce32cc35933edebc6256e85b2a2a691b77

diff --git a/sc/qa/unit/data/xlsx/pivot-table/shared-nested-dategroup.xlsx b/sc/qa/unit/data/xlsx/pivot-table/shared-nested-dategroup.xlsx
new file mode 100644
index 0000000..4dfb55d
Binary files /dev/null and b/sc/qa/unit/data/xlsx/pivot-table/shared-nested-dategroup.xlsx differ
diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx
index 4d4136c..6339166 100644
--- a/sc/qa/unit/subsequent_filters-test.cxx
+++ b/sc/qa/unit/subsequent_filters-test.cxx
@@ -202,6 +202,7 @@ public:
     void testGetPivotDataXLS();
     void testPivotTableSharedGroupXLSX();
     void testPivotTableSharedDateGroupXLSX();
+    void testPivotTableSharedNestedDateGroupXLSX();
     void testPivotTableSharedNumGroupXLSX();
 
     void testFormulaDependency();
@@ -311,6 +312,7 @@ public:
     CPPUNIT_TEST(testGetPivotDataXLS);
     CPPUNIT_TEST(testPivotTableSharedGroupXLSX);
     CPPUNIT_TEST(testPivotTableSharedDateGroupXLSX);
+    CPPUNIT_TEST(testPivotTableSharedNestedDateGroupXLSX);
     CPPUNIT_TEST(testPivotTableSharedNumGroupXLSX);
     CPPUNIT_TEST(testRowHeightODS);
     CPPUNIT_TEST(testFormulaDependency);
@@ -2146,6 +2148,49 @@ void ScFiltersTest::testPivotTableSharedDateGroupXLSX()
     xDocSh->DoClose();
 }
 
+void ScFiltersTest::testPivotTableSharedNestedDateGroupXLSX()
+{
+    ScDocShellRef xDocSh = loadDoc("pivot-table/shared-nested-dategroup.", FORMAT_XLSX);
+    CPPUNIT_ASSERT_MESSAGE("Failed to load file", xDocSh.Is());
+    ScDocument& rDoc = xDocSh->GetDocument();
+
+    // Check whether right date groups are imported for both tables
+    // First table
+    CPPUNIT_ASSERT_EQUAL(OUString("Years"), rDoc.GetString(ScAddress(0,3,1)));
+    CPPUNIT_ASSERT_EQUAL(OUString("1965"), rDoc.GetString(ScAddress(0,4,1)));
+    CPPUNIT_ASSERT_EQUAL(OUString("1989"), rDoc.GetString(ScAddress(0,11,1)));
+    CPPUNIT_ASSERT_EQUAL(OUString("2000"), rDoc.GetString(ScAddress(0,18,1)));
+    CPPUNIT_ASSERT_EQUAL(OUString("2004"), rDoc.GetString(ScAddress(0,21,1)));
+    // TODO: check why this fails with the empty string
+    //CPPUNIT_ASSERT_EQUAL(OUString("2007"), rDoc.GetString(ScAddress(0,32,1)));
+    CPPUNIT_ASSERT_EQUAL(OUString("Quarters"), rDoc.GetString(ScAddress(1,3,1)));
+
+    // Second table
+    CPPUNIT_ASSERT_EQUAL(OUString("Years"), rDoc.GetString(ScAddress(6,3,1)));
+    CPPUNIT_ASSERT_EQUAL(OUString("1965"), rDoc.GetString(ScAddress(6,4,1)));
+    CPPUNIT_ASSERT_EQUAL(OUString("1989"), rDoc.GetString(ScAddress(6,11,1)));
+    CPPUNIT_ASSERT_EQUAL(OUString("2000"), rDoc.GetString(ScAddress(6,18,1)));
+    CPPUNIT_ASSERT_EQUAL(OUString("2004"), rDoc.GetString(ScAddress(6,21,1)));
+    // TODO: check why this fails with the empty string
+    //CPPUNIT_ASSERT_EQUAL(OUString("2007"), rDoc.GetString(ScAddress(6,31,1)));
+    CPPUNIT_ASSERT_EQUAL(OUString("Quarters"), rDoc.GetString(ScAddress(7,3,1)));
+
+    // There should be exactly 2 pivot tables and 1 cache.
+    ScDPCollection* pDPs = rDoc.GetDPCollection();
+    CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), pDPs->GetCount());
+
+    ScDPCollection::SheetCaches& rSheetCaches = pDPs->GetSheetCaches();
+    CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), rSheetCaches.size());
+
+    const ScDPCache* pCache = rSheetCaches.getExistingCache(ScRange(0,0,0,9,24,0));
+    CPPUNIT_ASSERT_MESSAGE("Pivot cache is expected for A1:J25 on the first sheet.", pCache);
+    CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(10), pCache->GetFieldCount());
+    // Two new group field is created
+    CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), pCache->GetGroupFieldCount());
+
+    xDocSh->DoClose();
+}
+
 void ScFiltersTest::testPivotTableSharedNumGroupXLSX()
 {
     ScDocShellRef xDocSh = loadDoc("pivot-table/shared-numgroup.", FORMAT_XLSX);
diff --git a/sc/source/ui/unoobj/dapiuno.cxx b/sc/source/ui/unoobj/dapiuno.cxx
index 677a6ae..834c3d6 100644
--- a/sc/source/ui/unoobj/dapiuno.cxx
+++ b/sc/source/ui/unoobj/dapiuno.cxx
@@ -2788,7 +2788,7 @@ Reference < XDataPilotField > SAL_CALL ScDataPilotFieldObj::createDateGroup( con
 
         // apply changes
         pDPObj->SetSaveData( aSaveData );
-        SetDPObject( pDPObj );
+        ScDBDocFunc(*GetDocShell()).RefreshPivotTableGroups(pDPObj);
     }
 
     // return the UNO object of the new dimension, after writing back saved data


More information about the Libreoffice-commits mailing list