sc/inc/dpsave.hxx | 4 +- sc/qa/unit/data/xls/pivottable_empty_item.xls |binary sc/qa/unit/subsequent_export-test.cxx | 39 ++++++++++++++++++++++++++ sc/source/filter/excel/xipivot.cxx | 8 ++++- 4 files changed, 48 insertions(+), 3 deletions(-)
New commits: commit d44c7ffda598d4d4e8a3963133735a771ba3fe30 Author: Tamás Zolnai <tamas.zol...@collabora.com> Date: Tue Sep 12 00:30:37 2017 +0200 tdf#112337: Pivot table: empty / blank item is not imported from XLS Change-Id: I7ed9e5cacdf6df80b2f100d040cbbeda33b085d3 Reviewed-on: https://gerrit.libreoffice.org/42181 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Tamás Zolnai <tamas.zol...@collabora.com> diff --git a/sc/inc/dpsave.hxx b/sc/inc/dpsave.hxx index 2fa247c76802..6564b9b34f30 100644 --- a/sc/inc/dpsave.hxx +++ b/sc/inc/dpsave.hxx @@ -327,11 +327,11 @@ public: bool GetRowGrand() const { return bool(nRowGrandMode); } - void SetIgnoreEmptyRows( bool bSet ); + SC_DLLPUBLIC void SetIgnoreEmptyRows( bool bSet ); bool GetIgnoreEmptyRows() const { return bool(nIgnoreEmptyMode); } - void SetRepeatIfEmpty( bool bSet ); + SC_DLLPUBLIC void SetRepeatIfEmpty( bool bSet ); bool GetRepeatIfEmpty() const { return bool(nRepeatEmptyMode); } diff --git a/sc/qa/unit/data/xls/pivottable_empty_item.xls b/sc/qa/unit/data/xls/pivottable_empty_item.xls new file mode 100755 index 000000000000..c340c06a9f9d Binary files /dev/null and b/sc/qa/unit/data/xls/pivottable_empty_item.xls differ diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx index 537043c7b0c2..afe46cdd2947 100644 --- a/sc/qa/unit/subsequent_export-test.cxx +++ b/sc/qa/unit/subsequent_export-test.cxx @@ -216,6 +216,7 @@ public: void testPivotTableDateFieldFilter(); void testPivotTableBoolFieldFilter(); void testPivotTableRowColPageFieldFilter(); + void testPivotTableEmptyItem(); CPPUNIT_TEST_SUITE(ScExportTest); CPPUNIT_TEST(test); @@ -326,6 +327,7 @@ public: CPPUNIT_TEST(testPivotTableDateFieldFilter); CPPUNIT_TEST(testPivotTableBoolFieldFilter); CPPUNIT_TEST(testPivotTableRowColPageFieldFilter); + CPPUNIT_TEST(testPivotTableEmptyItem); CPPUNIT_TEST_SUITE_END(); @@ -4699,6 +4701,43 @@ void ScExportTest::testPivotTableRowColPageFieldFilter() xDocSh->DoClose(); } +void ScExportTest::testPivotTableEmptyItem() +{ + ScDocShellRef xDocSh = loadDoc("pivottable_empty_item.", FORMAT_XLS); + CPPUNIT_ASSERT_MESSAGE("Failed to load file", xDocSh.is()); + ScDocument& rDoc = xDocSh->GetDocument(); + ScDPCollection* pDPs = rDoc.GetDPCollection(); + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), pDPs->GetCount()); + + // Reload and check filtering of row dimensions + xDocSh = saveAndReload( &(*xDocSh), FORMAT_XLS); + CPPUNIT_ASSERT_MESSAGE("Failed to load file", xDocSh.is()); + ScDocument& rLoadedDoc = xDocSh->GetDocument(); + pDPs = rLoadedDoc.GetDPCollection(); + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), pDPs->GetCount()); + const ScDPObject* pDPObj = &(*pDPs)[0]; + CPPUNIT_ASSERT(pDPObj); + ScDPSaveData* pSaveData = pDPObj->GetSaveData(); + CPPUNIT_ASSERT(pSaveData); + + ScDPSaveDimension* pSaveDim = pSaveData->GetExistingDimensionByName("Category"); + CPPUNIT_ASSERT(pSaveDim); + + const ScDPSaveDimension::MemberList& rMembers = pSaveDim->GetMembers(); + CPPUNIT_ASSERT_EQUAL(size_t(3), rMembers.size()); + ScDPSaveMember* pMember = pSaveDim->GetExistingMemberByName("Fruit"); + CPPUNIT_ASSERT(pMember); + CPPUNIT_ASSERT(pMember->HasIsVisible() && pMember->GetIsVisible()); + pMember = pSaveDim->GetExistingMemberByName("Vegetables"); + CPPUNIT_ASSERT(pMember); + CPPUNIT_ASSERT(pMember->HasIsVisible() && !pMember->GetIsVisible()); + pMember = pSaveDim->GetExistingMemberByName(""); + CPPUNIT_ASSERT(pMember); + CPPUNIT_ASSERT(pMember->HasIsVisible() && !pMember->GetIsVisible()); + + xDocSh->DoClose(); +} + CPPUNIT_TEST_SUITE_REGISTRATION(ScExportTest); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sc/source/filter/excel/xipivot.cxx b/sc/source/filter/excel/xipivot.cxx index d045eccb4041..ae68e9fe016c 100644 --- a/sc/source/filter/excel/xipivot.cxx +++ b/sc/source/filter/excel/xipivot.cxx @@ -920,7 +920,11 @@ void XclImpPTItem::ConvertItem( ScDPSaveDimension& rSaveDim, ScDPObject* pObj, c { sItemName = pObj->GetFormattedString(rSaveDim.GetName(), rRoot.GetDoubleFromDateTime(*pCacheItem->GetDateTime())); } - else // EXC_PCITEM_EMPTY || EXC_PCITEM_INVALID + else if (pCacheItem->GetType() == EXC_PCITEM_EMPTY) + { + // sItemName is an empty string + } + else // EXC_PCITEM_INVALID return; // Find member and set properties @@ -1392,6 +1396,8 @@ void XclImpPivotTable::Convert() aSaveData.SetColumnGrand( ::get_flag( maPTInfo.mnFlags, EXC_SXVIEW_COLGRAND ) ); aSaveData.SetFilterButton( false ); aSaveData.SetDrillDown( ::get_flag( maPTExtInfo.mnFlags, EXC_SXEX_DRILLDOWN ) ); + aSaveData.SetIgnoreEmptyRows( false ); + aSaveData.SetRepeatIfEmpty( false ); // *** fields ***
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits