diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2019-04-22 14:56:07 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2019-04-22 18:02:03 +0200 |
commit | cdf7363d2fc371f16153365ed607e611bf1556db (patch) | |
tree | 1b16807c3ab5ec6260a8af7c091438a61a62c131 /sc | |
parent | 7d73c3b82c795b0fa13507054786f1a4a03fafa7 (diff) |
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.kaganski@collabora.com>
(cherry picked from commit 7f6a6664a1f3a37a97d02d5f0894300aff0d8db5)
Change-Id: I5357601b26e6635ab132ff6a1294645995aff97e
Reviewed-on: https://gerrit.libreoffice.org/71070
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Tested-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/qa/unit/pivottable_filters_test.cxx | 22 | ||||
-rw-r--r-- | sc/source/filter/oox/pivottablebuffer.cxx | 3 | ||||
-rw-r--r-- | sc/source/ui/unoobj/dapiuno.cxx | 8 |
3 files changed, 33 insertions, 0 deletions
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; } |