[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.0' - sc/qa sc/source
Mike Kaganski (via logerrit)
logerrit at kemper.freedesktop.org
Thu May 2 18:18:42 UTC 2019
sc/qa/unit/data/ods/pivottable_fieldInRowsAndData.ods |binary
sc/qa/unit/pivottable_filters_test.cxx | 19 ++++++++++++++++++
sc/source/filter/excel/xepivotxml.cxx | 16 +++++++++++++++
3 files changed, 35 insertions(+)
New commits:
commit 5afa630cf781143c8ff3228a28657bb412d2c0a9
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: Thu May 2 20:17:41 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/71696
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 065ad71b4e55..30969db5f039 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();
@@ -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();
diff --git a/sc/source/filter/excel/xepivotxml.cxx b/sc/source/filter/excel/xepivotxml.cxx
index e0a6bc84870c..752d971cfd25 100644
--- a/sc/source/filter/excel/xepivotxml.cxx
+++ b/sc/source/filter/excel/xepivotxml.cxx
@@ -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();
More information about the Libreoffice-commits
mailing list