[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.3' - sc/qa sc/source

Tamás Zolnai tamas.zolnai at collabora.com
Sun Oct 15 21:25:50 UTC 2017


 sc/qa/unit/data/xlsx/pivottable_duplicated_member_filter.xlsx |binary
 sc/qa/unit/subsequent_export-test.cxx                         |   16 ++++++++++
 sc/source/filter/excel/xepivotxml.cxx                         |    6 ++-
 3 files changed, 20 insertions(+), 2 deletions(-)

New commits:
commit d5f2f72aa58ed968e327403665e97ac3d6f97be8
Author: Tamás Zolnai <tamas.zolnai at collabora.com>
Date:   Sat Oct 7 17:38:51 2017 +0200

    tdf#109016: Avoid to write the same pivot item member more times
    
    It seems it's allowed to have the same member name in a pivot
    table. We need to handle this in the filtering code.
    Regression from:
    625653c8d119e720fb93b0c9f6f50d1eb625b179
    
    Reviewed-on: https://gerrit.libreoffice.org/43230
    Reviewed-by: Tamás Zolnai <tamas.zolnai at collabora.com>
    Tested-by: Tamás Zolnai <tamas.zolnai at collabora.com>
    (cherry picked from commit fe6ea004872c86c4a2e5849c7c9e75905711d6f3)
    
    Change-Id: Ic6f4110da3d83f4bbf5284e1b772e9e31b250bf1
    Reviewed-on: https://gerrit.libreoffice.org/43233
    Reviewed-by: Andras Timar <andras.timar at collabora.com>
    Tested-by: Andras Timar <andras.timar at collabora.com>

diff --git a/sc/qa/unit/data/xlsx/pivottable_duplicated_member_filter.xlsx b/sc/qa/unit/data/xlsx/pivottable_duplicated_member_filter.xlsx
new file mode 100755
index 000000000000..21291a45ef96
Binary files /dev/null and b/sc/qa/unit/data/xlsx/pivottable_duplicated_member_filter.xlsx differ
diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx
index ac0f2960abd3..dbf92510144a 100644
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -215,6 +215,7 @@ public:
     void testPivotTableRowColPageFieldFilterXLSX();
     void testPivotTableErrorItemFilterXLSX();
     void testPivotTableOutlineModeXLSX();
+    void testPivotTableDuplicatedMemberFilterXLSX();
 
     CPPUNIT_TEST_SUITE(ScExportTest);
     CPPUNIT_TEST(test);
@@ -330,6 +331,7 @@ public:
     CPPUNIT_TEST(testPivotTableRowColPageFieldFilterXLSX);
     CPPUNIT_TEST(testPivotTableErrorItemFilterXLSX);
     CPPUNIT_TEST(testPivotTableOutlineModeXLSX);
+    CPPUNIT_TEST(testPivotTableDuplicatedMemberFilterXLSX);
 
     CPPUNIT_TEST_SUITE_END();
 
@@ -5175,6 +5177,20 @@ void ScExportTest::testPivotTableOutlineModeXLSX()
     assertXPath(pTable, "/x:pivotTableDefinition/x:pivotFields/x:pivotField[1]", "compact", "0");
 }
 
+void ScExportTest::testPivotTableDuplicatedMemberFilterXLSX()
+{
+    ScDocShellRef xShell = loadDoc("pivottable_duplicated_member_filter.", FORMAT_XLSX);
+    CPPUNIT_ASSERT(xShell.Is());
+
+    std::shared_ptr<utl::TempFile> pXPathFile = ScBootstrapFixture::exportTo(&(*xShell), FORMAT_XLSX);
+    xmlDocPtr pTable = XPathHelper::parseExport(pXPathFile, m_xSFactory, "xl/pivotTables/pivotTable1.xml");
+    CPPUNIT_ASSERT(pTable);
+
+    // Check whether page field has the right number of items
+    assertXPath(pTable, "/x:pivotTableDefinition/x:pivotFields/x:pivotField[5]", "axis", "axisPage");
+    assertXPath(pTable, "/x:pivotTableDefinition/x:pivotFields/x:pivotField[5]/x:items", "count", "21");
+}
+
 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 362e629482df..d567c8e1e87b 100644
--- a/sc/source/filter/excel/xepivotxml.cxx
+++ b/sc/source/filter/excel/xepivotxml.cxx
@@ -784,8 +784,10 @@ void XclExpXmlPivotTables::SavePivotTableXml( XclExpXmlStream& rStrm, const ScDP
                 if (sFormattedName == rMember.maName)
                 {
                     size_t nCachePos = it - iCacheFieldItems_begin;
-                    aMemberSequence.push_back(std::make_pair(nCachePos, !rMember.mbVisible));
-                    aUsedCachePositions.insert(nCachePos);
+                    auto aInserted = aUsedCachePositions.insert(nCachePos);
+                    if (aInserted.second)
+                        aMemberSequence.push_back(std::make_pair(nCachePos, !rMember.mbVisible));
+                    break;
                 }
             }
         }


More information about the Libreoffice-commits mailing list