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

Mike Kaganski (via logerrit) logerrit at kemper.freedesktop.org
Mon Apr 22 13:57:06 UTC 2019


 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 7f6a6664a1f3a37a97d02d5f0894300aff0d8db5
Author:     Mike Kaganski <mike.kaganski at collabora.com>
AuthorDate: Mon Apr 22 14:56:07 2019 +0300
Commit:     Mike Kaganski <mike.kaganski at collabora.com>
CommitDate: Mon Apr 22 15:56:31 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.kaganski at collabora.com>

diff --git a/sc/qa/unit/pivottable_filters_test.cxx b/sc/qa/unit/pivottable_filters_test.cxx
index 9682b2a10131..222772b48866 100644
--- a/sc/qa/unit/pivottable_filters_test.cxx
+++ b/sc/qa/unit/pivottable_filters_test.cxx
@@ -90,6 +90,7 @@ public:
     void testTdf124736();
     void tesTtdf124772NumFmt();
     void testTdf124810();
+    void testTdf124883();
 
     CPPUNIT_TEST_SUITE(ScPivotTableFiltersTest);
 
@@ -137,6 +138,7 @@ public:
     CPPUNIT_TEST(testTdf124736);
     CPPUNIT_TEST(tesTtdf124772NumFmt);
     CPPUNIT_TEST(testTdf124810);
+    CPPUNIT_TEST(testTdf124883);
 
     CPPUNIT_TEST_SUITE_END();
 
@@ -2613,6 +2615,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 772637feb674..8af348942bcd 100644
--- a/sc/source/filter/oox/pivottablebuffer.cxx
+++ b/sc/source/filter/oox/pivottablebuffer.cxx
@@ -577,6 +577,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 ab921ea659b5..0f3fa929ef4a 100644
--- a/sc/source/ui/unoobj/dapiuno.cxx
+++ b/sc/source/ui/unoobj/dapiuno.cxx
@@ -1910,6 +1910,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 )
@@ -1999,6 +2005,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;
 }


More information about the Libreoffice-commits mailing list