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

Tamás Zolnai tamas.zolnai at collabora.com
Sat Oct 7 15:31:57 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                         |    5 +--
 3 files changed, 19 insertions(+), 2 deletions(-)

New commits:
commit fe6ea004872c86c4a2e5849c7c9e75905711d6f3
Author: Tamás Zolnai <tamas.zolnai at collabora.com>
Date:   Sat Oct 7 17:01:49 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
    
    Change-Id: Ic6f4110da3d83f4bbf5284e1b772e9e31b250bf1
    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>

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 21837ff11152..72fe254d850c 100644
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -227,6 +227,7 @@ public:
     void testPivotTableRowColPageFieldFilterXLSX();
     void testPivotTableErrorItemFilterXLSX();
     void testPivotTableOutlineModeXLSX();
+    void testPivotTableDuplicatedMemberFilterXLSX();
 
     CPPUNIT_TEST_SUITE(ScExportTest);
     CPPUNIT_TEST(test);
@@ -348,6 +349,7 @@ public:
     CPPUNIT_TEST(testPivotTableRowColPageFieldFilterXLSX);
     CPPUNIT_TEST(testPivotTableErrorItemFilterXLSX);
     CPPUNIT_TEST(testPivotTableOutlineModeXLSX);
+    CPPUNIT_TEST(testPivotTableDuplicatedMemberFilterXLSX);
 
     CPPUNIT_TEST_SUITE_END();
 
@@ -5270,6 +5272,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 6f9f7106f997..b89ea058c2e4 100644
--- a/sc/source/filter/excel/xepivotxml.cxx
+++ b/sc/source/filter/excel/xepivotxml.cxx
@@ -781,8 +781,9 @@ void XclExpXmlPivotTables::SavePivotTableXml( XclExpXmlStream& rStrm, const ScDP
                 if (sFormattedName == rMember.maName)
                 {
                     size_t nCachePos = it - iCacheFieldItems_begin;
-                    aMemberSequence.emplace_back(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