sc/qa/unit/pivottable_filters_test.cxx    |   19 +++++++++++++++++++
 sc/source/filter/oox/pivottablebuffer.cxx |    3 +++
 sc/source/ui/unoobj/dapiuno.cxx           |    8 ++++++++
 3 files changed, 30 insertions(+)

New commits:
commit 25bc89e2d8d6ab62e5fae24ecd50f642a87a73c2
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Mon Apr 22 14:56:07 2019 +0300
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Wed Jun 19 11:55:39 2019 +0200

    tdf#124883: don't drop data field names on import
    
    The name attribute of dataField element was already read in
    PivotTable::importDataField; and then it was ignored in
    PivotTableField::convertDataField. ScDataPilotFieldObj had no
    handler for name in its ScDataPilotFieldObj::[gs]etPropertyValue,
    although it has [gs]etName for that - so this change puts pieces
    together to allow to use the imported name correctly.
    
    Change-Id: I5357601b26e6635ab132ff6a1294645995aff97e
    Reviewed-on: https://gerrit.libreoffice.org/71068
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>
    (cherry picked from commit 7f6a6664a1f3a37a97d02d5f0894300aff0d8db5)
    Reviewed-on: https://gerrit.libreoffice.org/74347
    Tested-by: Mike Kaganski <mike.kagan...@collabora.com>

diff --git a/sc/qa/unit/pivottable_filters_test.cxx 
b/sc/qa/unit/pivottable_filters_test.cxx
index 17d5b32c3a2a..5e886036aecb 100644
--- a/sc/qa/unit/pivottable_filters_test.cxx
+++ b/sc/qa/unit/pivottable_filters_test.cxx
@@ -93,6 +93,7 @@ public:
     void testTdf124736();
     void tesTtdf124772NumFmt();
     void testTdf124810();
+    void testTdf124883();
 
     CPPUNIT_TEST_SUITE(ScPivotTableFiltersTest);
 
@@ -140,6 +141,7 @@ public:
     CPPUNIT_TEST(testTdf124736);
     CPPUNIT_TEST(tesTtdf124772NumFmt);
     CPPUNIT_TEST(testTdf124810);
+    CPPUNIT_TEST(testTdf124883);
 
     CPPUNIT_TEST_SUITE_END();
 
@@ -2602,6 +2604,23 @@ void ScPivotTableFiltersTest::testTdf124810()
     }
 }
 
+void ScPivotTableFiltersTest::testTdf124883()
+{
+    ScDocShellRef xDocSh = loadDoc("pivot-table/two-data-fields.", 
FORMAT_XLSX);
+    CPPUNIT_ASSERT(xDocSh.is());
+
+    xmlDocPtr pTable = XPathHelper::parseExport2(*this, *xDocSh, m_xSFactory,
+        "xl/pivotTables/pivotTable1.xml", FORMAT_XLSX);
+    xDocSh->DoClose();
+    CPPUNIT_ASSERT(pTable);
+
+    // The field names must be kept just as they appear in original XLSX
+    assertXPath(pTable, "/x:pivotTableDefinition/x:dataFields/x:dataField[1]", 
"name",
+                "Sum of Value");
+    assertXPath(pTable, "/x:pivotTableDefinition/x:dataFields/x:dataField[2]", 
"name",
+                "Count of Value2");
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(ScPivotTableFiltersTest);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sc/source/filter/oox/pivottablebuffer.cxx 
b/sc/source/filter/oox/pivottablebuffer.cxx
index c23b0a039ee8..503ed2e6e7b4 100644
--- a/sc/source/filter/oox/pivottablebuffer.cxx
+++ b/sc/source/filter/oox/pivottablebuffer.cxx
@@ -575,6 +575,9 @@ void PivotTableField::convertDataField( const 
PTDataFieldModel& rDataField )
         // field orientation
         aPropSet.setProperty( PROP_Orientation, DataPilotFieldOrientation_DATA 
);
 
+        if (!rDataField.maName.isEmpty())
+            aPropSet.setProperty(PROP_Name, rDataField.maName);
+
         /*  Field aggregation function. Documentation is a little bit confused
             about which names to use for the count functions. The name 'count'
             means 'count all', and 'countNum' means 'count numbers'. On the
diff --git a/sc/source/ui/unoobj/dapiuno.cxx b/sc/source/ui/unoobj/dapiuno.cxx
index 3a56fb138e25..bc15fc632df2 100644
--- a/sc/source/ui/unoobj/dapiuno.cxx
+++ b/sc/source/ui/unoobj/dapiuno.cxx
@@ -1921,6 +1921,12 @@ void SAL_CALL ScDataPilotFieldObj::setPropertyValue( 
const OUString& aPropertyNa
     {
         setRepeatItemLabels(cppu::any2bool(aValue));
     }
+    else if (aPropertyName == SC_UNONAME_NAME)
+    {
+        OUString sName;
+        if (aValue >>= sName)
+            setName(sName);
+    }
 }
 
 Any SAL_CALL ScDataPilotFieldObj::getPropertyValue( const OUString& 
aPropertyName )
@@ -2010,6 +2016,8 @@ Any SAL_CALL ScDataPilotFieldObj::getPropertyValue( const 
OUString& aPropertyNam
         aRet <<= getShowEmpty();
     else if ( aPropertyName == SC_UNONAME_REPEATITEMLABELS )
         aRet <<= getRepeatItemLabels();
+    else if (aPropertyName == SC_UNONAME_NAME)
+        aRet <<= getName();
 
     return aRet;
 }
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to