sc/qa/unit/pivottable_filters_test.cxx | 22 ++++++++++++++++++++++ sc/source/filter/oox/pivottablebuffer.cxx | 3 +++ sc/source/ui/unoobj/dapiuno.cxx | 8 ++++++++ 3 files changed, 33 insertions(+)
New commits: commit cdf7363d2fc371f16153365ed607e611bf1556db Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Mon Apr 22 14:56:07 2019 +0300 Commit: Mike Kaganski <mike.kagan...@collabora.com> CommitDate: Mon Apr 22 18:02:03 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. Reviewed-on: https://gerrit.libreoffice.org/71068 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> (cherry picked from commit 7f6a6664a1f3a37a97d02d5f0894300aff0d8db5) Change-Id: I5357601b26e6635ab132ff6a1294645995aff97e Reviewed-on: https://gerrit.libreoffice.org/71070 Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> 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 42d3d87a6e57..3684497ca39a 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(); @@ -2614,6 +2616,26 @@ void ScPivotTableFiltersTest::testTdf124810() } } +void ScPivotTableFiltersTest::testTdf124883() +{ + ScDocShellRef xDocSh = loadDoc("pivot-table/two-data-fields.", FORMAT_XLSX); + CPPUNIT_ASSERT(xDocSh.is()); + + std::shared_ptr<utl::TempFile> pXPathFile + = ScBootstrapFixture::exportTo(xDocSh.get(), FORMAT_XLSX); + xDocSh->DoClose(); + + xmlDocPtr pTable + = XPathHelper::parseExport(pXPathFile, m_xSFactory, "xl/pivotTables/pivotTable1.xml"); + 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 fa54a0e59330..a3b47b4b3a11 100644 --- a/sc/source/filter/oox/pivottablebuffer.cxx +++ b/sc/source/filter/oox/pivottablebuffer.cxx @@ -572,6 +572,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 5522e9555970..857cc8c36f04 100644 --- a/sc/source/ui/unoobj/dapiuno.cxx +++ b/sc/source/ui/unoobj/dapiuno.cxx @@ -1922,6 +1922,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 ) @@ -2011,6 +2017,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