Kaydet (Commit) cdf7363d authored tarafından Mike Kaganski's avatar Mike Kaganski

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: 's avatarMike Kaganski <mike.kaganski@collabora.com>
(cherry picked from commit 7f6a6664)

Change-Id: I5357601b26e6635ab132ff6a1294645995aff97e
Reviewed-on: https://gerrit.libreoffice.org/71070Reviewed-by: 's avatarMike Kaganski <mike.kaganski@collabora.com>
Tested-by: 's avatarMike Kaganski <mike.kaganski@collabora.com>
üst 7d73c3b8
......@@ -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();
......
......@@ -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
......
......@@ -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;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment