[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.2' - sc/qa sc/source
Mike Kaganski (via logerrit)
logerrit at kemper.freedesktop.org
Wed Jun 19 14:11:09 UTC 2019
sc/qa/unit/data/ods/pivottable_fieldInRowsAndData.ods |binary
sc/qa/unit/pivottable_filters_test.cxx | 15 +++++++++++++++
sc/source/filter/excel/xepivotxml.cxx | 16 ++++++++++++++++
3 files changed, 31 insertions(+)
New commits:
commit 71e8190e20c4563c2c40d6974bfd9850bca23372
Author: Mike Kaganski <mike.kaganski at collabora.com>
AuthorDate: Thu May 2 19:44:47 2019 +0300
Commit: Mike Kaganski <mike.kaganski at collabora.com>
CommitDate: Wed Jun 19 16:10:33 2019 +0200
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: Mike Kaganski <mike.kaganski at collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/74357
Tested-by: Mike Kaganski <mike.kaganski at collabora.com>
diff --git a/sc/qa/unit/data/ods/pivottable_fieldInRowsAndData.ods b/sc/qa/unit/data/ods/pivottable_fieldInRowsAndData.ods
new file mode 100644
index 000000000000..cbb773857605
Binary files /dev/null and b/sc/qa/unit/data/ods/pivottable_fieldInRowsAndData.ods differ
diff --git a/sc/qa/unit/pivottable_filters_test.cxx b/sc/qa/unit/pivottable_filters_test.cxx
index 7fd27759f9e2..0a9494e9e496 100644
--- a/sc/qa/unit/pivottable_filters_test.cxx
+++ b/sc/qa/unit/pivottable_filters_test.cxx
@@ -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();
@@ -2673,6 +2675,19 @@ 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());
+
+ xmlDocPtr pDoc = XPathHelper::parseExport2(*this, *xDocSh, m_xSFactory,
+ "xl/pivotTables/pivotTable1.xml", FORMAT_XLSX);
+ 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();
diff --git a/sc/source/filter/excel/xepivotxml.cxx b/sc/source/filter/excel/xepivotxml.cxx
index 280cb1a82a2b..86ba16214100 100644
--- a/sc/source/filter/excel/xepivotxml.cxx
+++ b/sc/source/filter/excel/xepivotxml.cxx
@@ -1009,8 +1009,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();
More information about the Libreoffice-commits
mailing list