sc/qa/unit/data/ods/tdf121612.ods     |binary
 sc/qa/unit/subsequent_export-test.cxx |   19 +++++++++++++++++++
 sc/source/filter/excel/xepivotxml.cxx |   11 +++++++++--
 3 files changed, 28 insertions(+), 2 deletions(-)

New commits:
commit 41d514ecd43ae9ec673071bfa1d79e788b8f935b
Author:     Vasily Melenchuk <vasily.melenc...@cib.de>
AuthorDate: Thu Nov 22 11:30:29 2018 +0300
Commit:     Thorsten Behrens <thorsten.behr...@cib.de>
CommitDate: Thu Nov 29 22:26:44 2018 +0100

    tdf#121612: update pivot caches during saving to XLSX
    
    Cache was empty so pivot table was not exported completely
    and pivot table filter were missing.
    
    Change-Id: Ib0b9e98a5588159c5c7de1e2e5d2bdcbfe986d8d
    Reviewed-on: https://gerrit.libreoffice.org/63785
    Tested-by: Jenkins
    Reviewed-by: Katarina Behrens <katarina.behr...@cib.de>
    Reviewed-by: Thorsten Behrens <thorsten.behr...@cib.de>
    Reviewed-on: https://gerrit.libreoffice.org/64264
    Tested-by: Thorsten Behrens <thorsten.behr...@cib.de>

diff --git a/sc/qa/unit/data/ods/tdf121612.ods 
b/sc/qa/unit/data/ods/tdf121612.ods
new file mode 100644
index 000000000000..6afc4e0c931c
Binary files /dev/null and b/sc/qa/unit/data/ods/tdf121612.ods differ
diff --git a/sc/qa/unit/subsequent_export-test.cxx 
b/sc/qa/unit/subsequent_export-test.cxx
index 4e90034a5f99..74b521a02c9a 100644
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -176,6 +176,7 @@ public:
     void testHeaderImage();
 
     void testTdf88657();
+    void testTdf121612();
 
     CPPUNIT_TEST_SUITE(ScExportTest);
     CPPUNIT_TEST(test);
@@ -258,6 +259,7 @@ public:
     CPPUNIT_TEST(testHeaderImage);
 
     CPPUNIT_TEST(testTdf88657);
+    CPPUNIT_TEST(testTdf121612);
 
     CPPUNIT_TEST_SUITE_END();
 
@@ -3708,6 +3710,23 @@ void ScExportTest::testConditionalFormatRangeListXLSX()
     assertXPath(pDoc, "//x:conditionalFormatting", "sqref", "F4 F10");
 }
 
+void ScExportTest::testTdf121612()
+{
+    ScDocShellRef xDocSh = loadDoc("tdf121612.", FORMAT_ODS);
+    CPPUNIT_ASSERT(xDocSh.is());
+    xDocSh = saveAndReload(xDocSh.get(), FORMAT_XLSX);
+
+    ScDocument& rDoc = xDocSh->GetDocument();
+
+    // There should be a pivot table
+    CPPUNIT_ASSERT(rDoc.HasPivotTable());
+
+    // DP collection is not lost after export and has one entry
+    ScDPCollection* pDPColl = rDoc.GetDPCollection();
+    CPPUNIT_ASSERT(pDPColl);
+    CPPUNIT_ASSERT_EQUAL(size_t(1), pDPColl->GetCount());
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(ScExportTest);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sc/source/filter/excel/xepivotxml.cxx 
b/sc/source/filter/excel/xepivotxml.cxx
index 1b340812cc3f..28114c67c103 100644
--- a/sc/source/filter/excel/xepivotxml.cxx
+++ b/sc/source/filter/excel/xepivotxml.cxx
@@ -296,15 +296,22 @@ XclExpXmlPivotTableManager::XclExpXmlPivotTableManager( 
const XclExpRoot& rRoot
 
 void XclExpXmlPivotTableManager::Initialize()
 {
-    const ScDocument& rDoc = GetDoc();
+    ScDocument& rDoc = GetDoc();
     if (!rDoc.HasPivotTable())
         // No pivot table to export.
         return;
 
-    const ScDPCollection* pDPColl = rDoc.GetDPCollection();
+    ScDPCollection* pDPColl = rDoc.GetDPCollection();
     if (!pDPColl)
         return;
 
+    // Update caches from DPObject
+    for (size_t i = 0; i < pDPColl->GetCount(); ++i)
+    {
+        ScDPObject& rDPObj = (*pDPColl)[i];
+        rDPObj.SyncAllDimensionMembers();
+    }
+
     // Go through the caches first.
 
     std::vector<XclExpXmlPivotCaches::Entry> aCaches;
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to