summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTamás Zolnai <tamas.zolnai@collabora.com>2016-10-08 03:45:50 +0200
committerTamás Zolnai <tamas.zolnai@collabora.com>2016-10-08 04:52:03 +0200
commit9d19634c8e719a80674ca4b3dfc3c7e49f049e5b (patch)
tree7597abdac9bbbb4c029c072ad5f7fb2d8a5982b7
parent21d8c021b3b0a8cdb946daf9116be64a497fdb91 (diff)
Pivot tables: Fix XLSX import of nested date groups
Same fix which was added for other kind of groups: f697d7aa5c26f9fcfd717b76a4827a5bcb38325e Change-Id: Ic35602ce32cc35933edebc6256e85b2a2a691b77
-rw-r--r--sc/qa/unit/data/xlsx/pivot-table/shared-nested-dategroup.xlsxbin0 -> 19160 bytes
-rw-r--r--sc/qa/unit/subsequent_filters-test.cxx45
-rw-r--r--sc/source/ui/unoobj/dapiuno.cxx2
3 files changed, 46 insertions, 1 deletions
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 000000000000..4dfb55d3cc5b
--- /dev/null
+++ b/sc/qa/unit/data/xlsx/pivot-table/shared-nested-dategroup.xlsx
Binary files differ
diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx
index 4d4136cf5a20..6339166b1012 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 677a6ae83b4b..834c3d6931f9 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