sc/qa/unit/data/xlsx/pivottable_error_item_filter.xlsx |binary sc/qa/unit/subsequent_export-test.cxx | 32 +++++++++++++++++ sc/source/filter/excel/xepivotxml.cxx | 3 + sc/source/filter/inc/pivotcachebuffer.hxx | 2 - sc/source/filter/oox/pivotcachebuffer.cxx | 8 ++-- sc/source/filter/oox/pivotcachefragment.cxx | 2 - 6 files changed, 40 insertions(+), 7 deletions(-)
New commits: commit 06104d00f01ce68e3e78f739d7a6bea110baf31b Author: Tamás Zolnai <tamas.zol...@collabora.com> Date: Thu Oct 5 15:13:46 2017 +0200 tdf#112893: Pivot table: filtering of error item is not imported ... from XLSX Reviewed-on: https://gerrit.libreoffice.org/43166 Reviewed-by: Tamás Zolnai <tamas.zol...@collabora.com> Tested-by: Tamás Zolnai <tamas.zol...@collabora.com> (cherry picked from commit 9fa34e9f2cebe2cfc551668f2a67ddcb799d3fb8) Change-Id: Ib155852e5f0718f41e02596d1042513286c6d845 Reviewed-on: https://gerrit.libreoffice.org/43216 Reviewed-by: Andras Timar <andras.ti...@collabora.com> Tested-by: Andras Timar <andras.ti...@collabora.com> diff --git a/sc/qa/unit/data/xlsx/pivottable_error_item_filter.xlsx b/sc/qa/unit/data/xlsx/pivottable_error_item_filter.xlsx new file mode 100755 index 000000000000..19d9b3c01b4d Binary files /dev/null and b/sc/qa/unit/data/xlsx/pivottable_error_item_filter.xlsx differ diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx index 680bb5b3eac4..f9ac660b5321 100644 --- a/sc/qa/unit/subsequent_export-test.cxx +++ b/sc/qa/unit/subsequent_export-test.cxx @@ -213,6 +213,7 @@ public: void testPivotTableDateFieldFilterXLSX(); void testPivotTableBoolFieldFilterXLSX(); void testPivotTableRowColPageFieldFilterXLSX(); + void testPivotTableErrorItemFilterXLSX(); CPPUNIT_TEST_SUITE(ScExportTest); CPPUNIT_TEST(test); @@ -326,6 +327,7 @@ public: CPPUNIT_TEST(testPivotTableDateFieldFilterXLSX); CPPUNIT_TEST(testPivotTableBoolFieldFilterXLSX); CPPUNIT_TEST(testPivotTableRowColPageFieldFilterXLSX); + CPPUNIT_TEST(testPivotTableErrorItemFilterXLSX); CPPUNIT_TEST_SUITE_END(); @@ -5124,6 +5126,36 @@ void ScExportTest::testPivotTableRowColPageFieldFilterXLSX() xDocSh->DoClose(); } +void ScExportTest::testPivotTableErrorItemFilterXLSX() +{ + ScDocShellRef xDocSh = loadDoc("pivottable_error_item_filter.", FORMAT_XLSX); + 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 whether filtering is preserved + xDocSh = saveAndReload( &(*xDocSh), FORMAT_XLSX); + 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("b"); + CPPUNIT_ASSERT(pSaveDim); + const ScDPSaveDimension::MemberList& rMembers = pSaveDim->GetMembers(); + CPPUNIT_ASSERT_EQUAL(size_t(4), rMembers.size()); + ScDPSaveMember* pMember = pSaveDim->GetExistingMemberByName("#DIV/0!"); + 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/xepivotxml.cxx b/sc/source/filter/excel/xepivotxml.cxx index a7bbbe543e9b..f29d312b0020 100644 --- a/sc/source/filter/excel/xepivotxml.cxx +++ b/sc/source/filter/excel/xepivotxml.cxx @@ -292,7 +292,8 @@ void XclExpXmlPivotCaches::SavePivotCacheXml( XclExpXmlStream& rStrm, const Entr std::set<ScDPItemData::Type> aDPTypesWithoutBlank = aDPTypes; aDPTypesWithoutBlank.erase(ScDPItemData::Empty); - bool isContainsString = aDPTypesWithoutBlank.find(ScDPItemData::String) != aDPTypesWithoutBlank.end(); + bool isContainsString = aDPTypesWithoutBlank.find(ScDPItemData::String) != aDPTypesWithoutBlank.end() || + aDPTypesWithoutBlank.find(ScDPItemData::Error) != aDPTypesWithoutBlank.end(); bool isContainsBlank = aDPTypes.find(ScDPItemData::Empty) != aDPTypeEnd; bool isContainsNumber = !isContainsDate && aDPTypesWithoutBlank.find(ScDPItemData::Value) != aDPTypesWithoutBlank.end(); bool isContainsNonDate = !(isContainsDate && aDPTypesWithoutBlank.size() <= 1); diff --git a/sc/source/filter/inc/pivotcachebuffer.hxx b/sc/source/filter/inc/pivotcachebuffer.hxx index 0d775961abd3..38af4631f6a4 100644 --- a/sc/source/filter/inc/pivotcachebuffer.hxx +++ b/sc/source/filter/inc/pivotcachebuffer.hxx @@ -58,7 +58,7 @@ public: /** Reads the boolean value from a pivot cache item. */ void readBool( const AttributeList& rAttribs ); /** Reads the error code value from a pivot cache item. */ - void readError( const AttributeList& rAttribs, const UnitConverter& rUnitConverter ); + void readError( const AttributeList& rAttribs ); /** Reads the index of a shared item. */ void readIndex( const AttributeList& rAttribs ); diff --git a/sc/source/filter/oox/pivotcachebuffer.cxx b/sc/source/filter/oox/pivotcachebuffer.cxx index fd34f353b12e..7206b14b3ee1 100644 --- a/sc/source/filter/oox/pivotcachebuffer.cxx +++ b/sc/source/filter/oox/pivotcachebuffer.cxx @@ -158,9 +158,9 @@ void PivotCacheItem::readBool( const AttributeList& rAttribs ) mnType = XML_b; } -void PivotCacheItem::readError( const AttributeList& rAttribs, const UnitConverter& rUnitConverter ) +void PivotCacheItem::readError( const AttributeList& rAttribs ) { - maValue <<= static_cast< sal_Int32 >( rUnitConverter.calcBiffErrorCode( rAttribs.getXString( XML_v, OUString() ) ) ); + maValue <<= rAttribs.getXString( XML_v, OUString() ); mnType = XML_e; } @@ -246,7 +246,7 @@ OUString PivotCacheItem::getFormattedName(const ScDPSaveDimension& rSaveDim, ScD case XML_i: return pObj->GetFormattedString(rSaveDim.GetName(), static_cast<double>(maValue.get< sal_Int32 >())); case XML_b: return pObj->GetFormattedString(rSaveDim.GetName(), static_cast<double>(maValue.get< bool >())); case XML_d: return pObj->GetFormattedString(rSaveDim.GetName(), ::DateTime(maValue.get< css::util::DateTime >()) - rNullDate); - case XML_e: return OUString(); // !TODO + case XML_e: return maValue.get< OUString >(); // !TODO } OSL_FAIL( "PivotCacheItem::getFormattedName - invalid data type" ); return OUString(); @@ -267,7 +267,7 @@ void PivotCacheItemList::importItem( sal_Int32 nElement, const AttributeList& rA case XLS_TOKEN( n ): rItem.readNumeric( rAttribs ); break; case XLS_TOKEN( d ): rItem.readDate( rAttribs ); break; case XLS_TOKEN( b ): rItem.readBool( rAttribs ); break; - case XLS_TOKEN( e ): rItem.readError( rAttribs, getUnitConverter() ); break; + case XLS_TOKEN( e ): rItem.readError( rAttribs ); break; default: OSL_FAIL( "PivotCacheItemList::importItem - unknown element type" ); } } diff --git a/sc/source/filter/oox/pivotcachefragment.cxx b/sc/source/filter/oox/pivotcachefragment.cxx index 4f9c7a3a15ee..5d4db39d2988 100644 --- a/sc/source/filter/oox/pivotcachefragment.cxx +++ b/sc/source/filter/oox/pivotcachefragment.cxx @@ -243,7 +243,7 @@ ContextHandlerRef PivotCacheRecordsFragment::onCreateContext( sal_Int32 nElement case XLS_TOKEN( n ): aItem.readNumeric( rAttribs ); break; case XLS_TOKEN( d ): aItem.readDate( rAttribs ); break; case XLS_TOKEN( b ): aItem.readBool( rAttribs ); break; - case XLS_TOKEN( e ): aItem.readError( rAttribs, getUnitConverter() ); break; + case XLS_TOKEN( e ): aItem.readError( rAttribs ); break; case XLS_TOKEN( x ): aItem.readIndex( rAttribs ); break; default: OSL_FAIL( "OoxPivotCacheRecordsFragment::onCreateContext - unexpected element" ); }
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits