summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@collabora.com>2013-12-10 12:50:48 -0500
committerKohei Yoshida <kohei.yoshida@collabora.com>2013-12-10 18:44:11 -0500
commit2e1b90a4272defb917b23e2e360e171114d6fa4d (patch)
treee9a515a378147730c293b48cf65909554a710cd3
parent8f6e3118f57276a458b82482b0d277dee327413e (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
-rw-r--r--sc/source/filter/xml/xmldpimp.cxx33
-rw-r--r--sc/source/filter/xml/xmldpimp.hxx7
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