kbrown / rpms / libreoffice

Forked from rpms/libreoffice 2 years ago
Clone

Blame SOURCES/0057-fdo-66969-Set-selected-page-name-after-building-all-.patch

f0633d
From 5618ac8ccddbff67b4b27a9c08f97d3bf2bcec3f Mon Sep 17 00:00:00 2001
f0633d
From: Kohei Yoshida <kohei.yoshida@collabora.com>
f0633d
Date: Tue, 10 Dec 2013 12:50:48 -0500
f0633d
Subject: [PATCH 057/109] fdo#66969: Set selected page name after building all
f0633d
 dimension members.
f0633d
f0633d
Because the new implementation relies on the visiblity flag of the
f0633d
dimension members, they need to exist before setting currently selected
f0633d
page, which is still used in documents generated by the older version of
f0633d
LibreOffice.
f0633d
f0633d
Change-Id: I6cec5fd3d2165f714fc01b596d3761890d87a4ff
f0633d
(cherry picked from commit 2e1b90a4272defb917b23e2e360e171114d6fa4d)
f0633d
Reviewed-on: https://gerrit.libreoffice.org/7027
f0633d
Reviewed-by: Eike Rathke <erack@redhat.com>
f0633d
Tested-by: Eike Rathke <erack@redhat.com>
f0633d
---
f0633d
 sc/source/filter/xml/xmldpimp.cxx | 33 ++++++++++++++++++++++++++++++++-
f0633d
 sc/source/filter/xml/xmldpimp.hxx |  7 +++++++
f0633d
 2 files changed, 39 insertions(+), 1 deletion(-)
f0633d
f0633d
diff --git a/sc/source/filter/xml/xmldpimp.cxx b/sc/source/filter/xml/xmldpimp.cxx
f0633d
index 83f58f7..825060c 100644
f0633d
--- a/sc/source/filter/xml/xmldpimp.cxx
f0633d
+++ b/sc/source/filter/xml/xmldpimp.cxx
f0633d
@@ -412,6 +412,11 @@ void ScXMLDataPilotTableContext::SetButtons()
f0633d
         pDPObject->RefreshAfterLoad();
f0633d
 }
f0633d
 
f0633d
+void ScXMLDataPilotTableContext::SetSelectedPage( const OUString& rDimName, const OUString& rSelected )
f0633d
+{
f0633d
+    maSelectedPages.insert(SelectedPagesType::value_type(rDimName, rSelected));
f0633d
+}
f0633d
+
f0633d
 void ScXMLDataPilotTableContext::AddDimension(ScDPSaveDimension* pDim)
f0633d
 {
f0633d
     if (pDPSave)
f0633d
@@ -548,10 +553,36 @@ void ScXMLDataPilotTableContext::EndElement()
f0633d
     if ( pDPCollection->GetByName(pDPObject->GetName()) )
f0633d
         pDPObject->SetName( String() );     // ignore the invalid name, create a new name in AfterXMLLoading
f0633d
 
f0633d
+    ProcessSelectedPages();
f0633d
+
f0633d
     pDPCollection->InsertNewTable(pDPObject);
f0633d
     SetButtons();
f0633d
 }
f0633d
 
f0633d
+void ScXMLDataPilotTableContext::ProcessSelectedPages()
f0633d
+{
f0633d
+    // Set selected pages after building all dimension members.
f0633d
+    if (!pDPObject)
f0633d
+        return;
f0633d
+
f0633d
+    pDPObject->BuildAllDimensionMembers();
f0633d
+    ScDPSaveData* pSaveData = pDPObject->GetSaveData();
f0633d
+    if (!pSaveData)
f0633d
+        return;
f0633d
+
f0633d
+    SelectedPagesType::const_iterator it = maSelectedPages.begin(), itEnd = maSelectedPages.end();
f0633d
+    for (; it != itEnd; ++it)
f0633d
+    {
f0633d
+        const OUString& rDimName = it->first;
f0633d
+        const OUString& rSelected = it->second;
f0633d
+        ScDPSaveDimension* pDim = pSaveData->GetExistingDimensionByName(rDimName);
f0633d
+        if (!pDim)
f0633d
+            continue;
f0633d
+
f0633d
+        pDim->SetCurrentPage(&rSelected);
f0633d
+    }
f0633d
+}
f0633d
+
f0633d
 void ScXMLDataPilotTableContext::SetGrandTotal(
f0633d
     XMLTokenEnum eOrientation, bool bVisible, const OUString& rDisplayName)
f0633d
 {
f0633d
@@ -1111,7 +1142,7 @@ void ScXMLDataPilotFieldContext::EndElement()
f0633d
         pDim->SetOrientation(nOrientation);
f0633d
         if (bSelectedPage)
f0633d
         {
f0633d
-            pDim->SetCurrentPage(&sSelectedPage);
f0633d
+            pDataPilotTable->SetSelectedPage(pDim->GetName(), sSelectedPage);
f0633d
         }
f0633d
         pDataPilotTable->AddDimension(pDim);
f0633d
         if (bIsGroupField)
f0633d
diff --git a/sc/source/filter/xml/xmldpimp.hxx b/sc/source/filter/xml/xmldpimp.hxx
f0633d
index 1aa851d..32f878d 100644
f0633d
--- a/sc/source/filter/xml/xmldpimp.hxx
f0633d
+++ b/sc/source/filter/xml/xmldpimp.hxx
f0633d
@@ -71,6 +71,8 @@ public:
f0633d
 
f0633d
 class ScXMLDataPilotTableContext : public SvXMLImportContext
f0633d
 {
f0633d
+    typedef boost::unordered_map<OUString, OUString, OUStringHash> SelectedPagesType;
f0633d
+
f0633d
     struct GrandTotalItem
f0633d
     {
f0633d
         OUString maDisplayName;
f0633d
@@ -114,9 +116,13 @@ class ScXMLDataPilotTableContext : public SvXMLImportContext
f0633d
     bool            bDrillDown:1;
f0633d
     bool            bHeaderGridLayout:1;
f0633d
 
f0633d
+    SelectedPagesType maSelectedPages;
f0633d
+
f0633d
     const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); }
f0633d
     ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); }
f0633d
 
f0633d
+    void ProcessSelectedPages();
f0633d
+
f0633d
 public:
f0633d
 
f0633d
     ScXMLDataPilotTableContext( ScXMLImport& rImport, sal_uInt16 nPrfx,
f0633d
@@ -151,6 +157,7 @@ public:
f0633d
     void AddGroupDim(const ScDPSaveNumGroupDimension& aNumGroupDim);
f0633d
     void AddGroupDim(const ScDPSaveGroupDimension& aGroupDim);
f0633d
     void SetButtons();
f0633d
+    void SetSelectedPage( const OUString& rDimName, const OUString& rSelected );
f0633d
 };
f0633d
 
f0633d
 class ScXMLDPSourceSQLContext : public SvXMLImportContext
f0633d
-- 
f0633d
1.8.4.2
f0633d