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

Tamás Zolnai tamas.zolnai at collabora.com
Thu Oct 5 15:55:44 UTC 2017


 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 9fa34e9f2cebe2cfc551668f2a67ddcb799d3fb8
Author: Tamás Zolnai <tamas.zolnai at collabora.com>
Date:   Thu Oct 5 15:13:46 2017 +0200

    tdf#112893: Pivot table: filtering of error item is not imported
    
    ... from XLSX
    
    Change-Id: Ib155852e5f0718f41e02596d1042513286c6d845
    Reviewed-on: https://gerrit.libreoffice.org/43166
    Reviewed-by: Tamás Zolnai <tamas.zolnai at collabora.com>
    Tested-by: Tamás Zolnai <tamas.zolnai at 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 04aada980beb..d0596bdf06ef 100644
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -225,6 +225,7 @@ public:
     void testPivotTableDateFieldFilterXLSX();
     void testPivotTableBoolFieldFilterXLSX();
     void testPivotTableRowColPageFieldFilterXLSX();
+    void testPivotTableErrorItemFilterXLSX();
 
     CPPUNIT_TEST_SUITE(ScExportTest);
     CPPUNIT_TEST(test);
@@ -344,6 +345,7 @@ public:
     CPPUNIT_TEST(testPivotTableDateFieldFilterXLSX);
     CPPUNIT_TEST(testPivotTableBoolFieldFilterXLSX);
     CPPUNIT_TEST(testPivotTableRowColPageFieldFilterXLSX);
+    CPPUNIT_TEST(testPivotTableErrorItemFilterXLSX);
 
     CPPUNIT_TEST_SUITE_END();
 
@@ -5219,6 +5221,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 4f15b1bfcb41..270066f76126 100644
--- a/sc/source/filter/excel/xepivotxml.cxx
+++ b/sc/source/filter/excel/xepivotxml.cxx
@@ -290,7 +290,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 b0755936b8b1..e0c8f65d441a 100644
--- a/sc/source/filter/inc/pivotcachebuffer.hxx
+++ b/sc/source/filter/inc/pivotcachebuffer.hxx
@@ -57,7 +57,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 1da8b0c1cfed..5e38a8825ff5 100644
--- a/sc/source/filter/oox/pivotcachebuffer.cxx
+++ b/sc/source/filter/oox/pivotcachebuffer.cxx
@@ -155,9 +155,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;
 }
 
@@ -243,7 +243,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(), maValue.get< css::util::DateTime >() - rNullDate);
-        case XML_e: return OUString();                                                              // !TODO
+        case XML_e: return maValue.get< OUString >();
     }
     OSL_FAIL( "PivotCacheItem::getFormattedName - invalid data type" );
     return OUString();
@@ -264,7 +264,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 caa7021dfa91..3aabaa8f5040 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" );
             }


More information about the Libreoffice-commits mailing list