Kaydet (Commit) ad241543 authored tarafından Mike Kaganski's avatar Mike Kaganski Kaydeden (comit) Andras Timar

tdf#125086: Write dataField attribute for fields that also appear in Data

Change-Id: Id9f8f07bfdb1060f0c3d7ed6f8526a6bfdd84eb4
Reviewed-on: https://gerrit.libreoffice.org/71687
Tested-by: Jenkins
Reviewed-by: 's avatarMike Kaganski <mike.kaganski@collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/71696Tested-by: 's avatarMike Kaganski <mike.kaganski@collabora.com>
üst d93eb86b
......@@ -96,6 +96,7 @@ public:
void testTdf124883();
void testTdf125046();
void testTdf125055();
void testTdf125086();
CPPUNIT_TEST_SUITE(ScPivotTableFiltersTest);
......@@ -146,6 +147,7 @@ public:
CPPUNIT_TEST(testTdf124883);
CPPUNIT_TEST(testTdf125046);
CPPUNIT_TEST(testTdf125055);
CPPUNIT_TEST(testTdf125086);
CPPUNIT_TEST_SUITE_END();
......@@ -2696,6 +2698,23 @@ void ScPivotTableFiltersTest::testTdf125055()
pDoc, "/x:pivotCacheDefinition/x:cacheFields/x:cacheField[2]/x:sharedItems", "m"));
}
void ScPivotTableFiltersTest::testTdf125086()
{
ScDocShellRef xDocSh = loadDoc("pivottable_fieldInRowsAndData.", FORMAT_ODS);
CPPUNIT_ASSERT(xDocSh.is());
std::shared_ptr<utl::TempFile> pXPathFile
= ScBootstrapFixture::exportTo(xDocSh.get(), FORMAT_XLSX);
xDocSh->DoClose();
xmlDocPtr pDoc
= XPathHelper::parseExport(pXPathFile, m_xSFactory, "xl/pivotTables/pivotTable1.xml");
CPPUNIT_ASSERT(pDoc);
assertXPath(pDoc, "/x:pivotTableDefinition/x:pivotFields/x:pivotField[2]", "axis", "axisRow");
// "dataField" attribute was not written for this "axisRow" field
assertXPath(pDoc, "/x:pivotTableDefinition/x:pivotFields/x:pivotField[2]", "dataField", "1");
}
CPPUNIT_TEST_SUITE_REGISTRATION(ScPivotTableFiltersTest);
CPPUNIT_PLUGIN_IMPLEMENT();
......
......@@ -1012,8 +1012,24 @@ void XclExpXmlPivotTables::SavePivotTableXml( XclExpXmlStream& rStrm, const ScDP
aMemberSequence.emplace_back(nItem, true);
}
// tdf#125086: check if this field *also* appears in Data region
bool bAppearsInData = false;
{
OUString aSrcName = ScDPUtil::getSourceDimensionName(pDim->GetName());
const auto it = std::find_if(
aDataFields.begin(), aDataFields.end(), [&aSrcName](const DataField& rDataField) {
OUString aThisName
= ScDPUtil::getSourceDimensionName(rDataField.mpDim->GetName());
return aThisName == aSrcName;
});
if (it != aDataFields.end())
bAppearsInData = true;
}
auto pAttList = sax_fastparser::FastSerializerHelper::createAttrList();
pAttList->add(XML_axis, toOOXMLAxisType(eOrient));
if (bAppearsInData)
pAttList->add(XML_dataField, ToPsz10(true));
pAttList->add(XML_showAll, ToPsz10(false));
long nSubTotalCount = pDim->GetSubTotalsCount();
......
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