diff options
author | Kohei Yoshida <kohei.yoshida@collabora.com> | 2013-12-10 12:50:48 -0500 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@collabora.com> | 2013-12-10 18:45:32 -0500 |
commit | a0fd13c0651acf0e620a58eca248b3a12ea43632 (patch) | |
tree | e5e5b74cc05b5d2f4f72594170532934fd723d97 | |
parent | a3880da7f1d799c7c7735528efdf6fee8c5a4f4e (diff) |
fdo#66969: Set selected page name after building all dimension members.
Because the new implementation relies on the visiblity flag of the
dimension members, they need to exist before setting currently selected
page, which is still used in documents generated by the older version of
LibreOffice.
Change-Id: I6cec5fd3d2165f714fc01b596d3761890d87a4ff
(cherry picked from commit 2e1b90a4272defb917b23e2e360e171114d6fa4d)
-rw-r--r-- | sc/source/filter/xml/xmldpimp.cxx | 33 | ||||
-rw-r--r-- | sc/source/filter/xml/xmldpimp.hxx | 7 |
2 files changed, 39 insertions, 1 deletions
diff --git a/sc/source/filter/xml/xmldpimp.cxx b/sc/source/filter/xml/xmldpimp.cxx index 271873321d9c..88750ddb0bf0 100644 --- a/sc/source/filter/xml/xmldpimp.cxx +++ b/sc/source/filter/xml/xmldpimp.cxx @@ -412,6 +412,11 @@ void ScXMLDataPilotTableContext::SetButtons() pDPObject->RefreshAfterLoad(); } +void ScXMLDataPilotTableContext::SetSelectedPage( const OUString& rDimName, const OUString& rSelected ) +{ + maSelectedPages.insert(SelectedPagesType::value_type(rDimName, rSelected)); +} + void ScXMLDataPilotTableContext::AddDimension(ScDPSaveDimension* pDim) { if (pDPSave) @@ -548,10 +553,36 @@ void ScXMLDataPilotTableContext::EndElement() if ( pDPCollection->GetByName(pDPObject->GetName()) ) pDPObject->SetName( OUString() ); // ignore the invalid name, create a new name in AfterXMLLoading + ProcessSelectedPages(); + pDPCollection->InsertNewTable(pDPObject); SetButtons(); } +void ScXMLDataPilotTableContext::ProcessSelectedPages() +{ + // Set selected pages after building all dimension members. + if (!pDPObject) + return; + + pDPObject->BuildAllDimensionMembers(); + ScDPSaveData* pSaveData = pDPObject->GetSaveData(); + if (!pSaveData) + return; + + SelectedPagesType::const_iterator it = maSelectedPages.begin(), itEnd = maSelectedPages.end(); + for (; it != itEnd; ++it) + { + const OUString& rDimName = it->first; + const OUString& rSelected = it->second; + ScDPSaveDimension* pDim = pSaveData->GetExistingDimensionByName(rDimName); + if (!pDim) + continue; + + pDim->SetCurrentPage(&rSelected); + } +} + void ScXMLDataPilotTableContext::SetGrandTotal( XMLTokenEnum eOrientation, bool bVisible, const OUString& rDisplayName) { @@ -1111,7 +1142,7 @@ void ScXMLDataPilotFieldContext::EndElement() pDim->SetOrientation(nOrientation); if (bSelectedPage) { - pDim->SetCurrentPage(&sSelectedPage); + pDataPilotTable->SetSelectedPage(pDim->GetName(), sSelectedPage); } pDataPilotTable->AddDimension(pDim); if (bIsGroupField) diff --git a/sc/source/filter/xml/xmldpimp.hxx b/sc/source/filter/xml/xmldpimp.hxx index 1aa851dc1a1e..32f878dee541 100644 --- a/sc/source/filter/xml/xmldpimp.hxx +++ b/sc/source/filter/xml/xmldpimp.hxx @@ -71,6 +71,8 @@ public: class ScXMLDataPilotTableContext : public SvXMLImportContext { + typedef boost::unordered_map<OUString, OUString, OUStringHash> SelectedPagesType; + struct GrandTotalItem { OUString maDisplayName; @@ -114,9 +116,13 @@ class ScXMLDataPilotTableContext : public SvXMLImportContext bool bDrillDown:1; bool bHeaderGridLayout:1; + SelectedPagesType maSelectedPages; + const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } + void ProcessSelectedPages(); + public: ScXMLDataPilotTableContext( ScXMLImport& rImport, sal_uInt16 nPrfx, @@ -151,6 +157,7 @@ public: void AddGroupDim(const ScDPSaveNumGroupDimension& aNumGroupDim); void AddGroupDim(const ScDPSaveGroupDimension& aGroupDim); void SetButtons(); + void SetSelectedPage( const OUString& rDimName, const OUString& rSelected ); }; class ScXMLDPSourceSQLContext : public SvXMLImportContext |