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 e7f8df2636abb605b4f930fb9351474370730f58 Author: Tamás Zolnai <tamas.zol...@collabora.com> Date: Wed Sep 13 07:22:06 2017 +0200 tdf#112337: Pivot table: empty / blank item is not imported from XLS Reviewed-on: https://gerrit.libreoffice.org/42181 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Tamás Zolnai <tamas.zol...@collabora.com> (cherry picked from commit d44c7ffda598d4d4e8a3963133735a771ba3fe30) Change-Id: I7ed9e5cacdf6df80b2f100d040cbbeda33b085d3 Reviewed-on: https://gerrit.libreoffice.org/42224 Reviewed-by: Andras Timar <andras.ti...@collabora.com> Tested-by: Andras Timar <andras.ti...@collabora.com> diff --git a/sc/inc/dpsave.hxx b/sc/inc/dpsave.hxx index 663bcb2d724d..8062ff240fd3 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 2e0ecc0f1cd5..45ee28ce26cb 100644 --- a/sc/qa/unit/subsequent_export-test.cxx +++ b/sc/qa/unit/subsequent_export-test.cxx @@ -204,6 +204,7 @@ public: void testPivotTableDateFieldFilter(); void testPivotTableBoolFieldFilter(); void testPivotTableRowColPageFieldFilter(); + void testPivotTableEmptyItem(); CPPUNIT_TEST_SUITE(ScExportTest); CPPUNIT_TEST(test); @@ -308,6 +309,7 @@ public: CPPUNIT_TEST(testPivotTableDateFieldFilter); CPPUNIT_TEST(testPivotTableBoolFieldFilter); CPPUNIT_TEST(testPivotTableRowColPageFieldFilter); + CPPUNIT_TEST(testPivotTableEmptyItem); CPPUNIT_TEST_SUITE_END(); @@ -4604,6 +4606,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 0d933ffe3596..33b4cebff789 100644 --- a/sc/source/filter/excel/xipivot.cxx +++ b/sc/source/filter/excel/xipivot.cxx @@ -921,7 +921,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 @@ -1393,6 +1397,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