summaryrefslogtreecommitdiff
path: root/sc/source/filter/xml/xmldpimp.cxx
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@collabora.com>2014-03-09 18:40:13 -0400
committerKohei Yoshida <kohei.yoshida@collabora.com>2014-03-09 18:44:07 -0400
commit057d269c5d1faf45c4c935b2f8120c45e646de65 (patch)
tree0ca033abb984f1f991da5e7edbae9f982c0169c3 /sc/source/filter/xml/xmldpimp.cxx
parent93e4276addbaaf574e07f7f1a993c653c536645d (diff)
fdo#75960: Process pivot tables after named ranges are all set.
Especially for those pivot tables that reference named ranges as their data sources, it's critical that we process them after named ranges are set. Else things would start to fail. Change-Id: I4bf8aa1a844aae3953f2dfbeba0e4d2542a7e53f
Diffstat (limited to 'sc/source/filter/xml/xmldpimp.cxx')
-rw-r--r--sc/source/filter/xml/xmldpimp.cxx45
1 files changed, 13 insertions, 32 deletions
diff --git a/sc/source/filter/xml/xmldpimp.cxx b/sc/source/filter/xml/xmldpimp.cxx
index f9763333bbd0..72cefa2096d2 100644
--- a/sc/source/filter/xml/xmldpimp.cxx
+++ b/sc/source/filter/xml/xmldpimp.cxx
@@ -32,6 +32,8 @@
#include "rangeutl.hxx"
#include "dpoutputgeometry.hxx"
+#include "pivotsource.hxx"
+
#include <xmloff/xmltkmap.hxx>
#include <xmloff/nmspmap.hxx>
#include <xmloff/xmltoken.hxx>
@@ -477,6 +479,9 @@ void ScXMLDataPilotTableContext::EndElement()
pDPObject->SetTag(sApplicationData);
pDPObject->SetOutRange(aTargetRangeAddress);
pDPObject->SetHeaderLayout(bHeaderGridLayout);
+
+ sc::PivotTableSources& rPivotSources = GetScImport().GetPivotTableSources();
+
switch (nSourceType)
{
case SQL :
@@ -486,7 +491,7 @@ void ScXMLDataPilotTableContext::EndElement()
aImportDesc.aObject = sSourceObject;
aImportDesc.nType = sheet::DataImportMode_SQL;
aImportDesc.bNative = bIsNative;
- pDPObject->SetImportDesc(aImportDesc);
+ rPivotSources.appendDBSource(pDPObject, aImportDesc);
}
break;
case TABLE :
@@ -495,7 +500,7 @@ void ScXMLDataPilotTableContext::EndElement()
aImportDesc.aDBName = sDatabaseName;
aImportDesc.aObject = sSourceObject;
aImportDesc.nType = sheet::DataImportMode_TABLE;
- pDPObject->SetImportDesc(aImportDesc);
+ rPivotSources.appendDBSource(pDPObject, aImportDesc);
}
break;
case QUERY :
@@ -504,14 +509,14 @@ void ScXMLDataPilotTableContext::EndElement()
aImportDesc.aDBName = sDatabaseName;
aImportDesc.aObject = sSourceObject;
aImportDesc.nType = sheet::DataImportMode_QUERY;
- pDPObject->SetImportDesc(aImportDesc);
+ rPivotSources.appendDBSource(pDPObject, aImportDesc);
}
break;
case SERVICE :
{
- ScDPServiceDesc aServiceDesk(sServiceName, sServiceSourceName, sServiceSourceObject,
+ ScDPServiceDesc aServiceDesc(sServiceName, sServiceSourceName, sServiceSourceObject,
sServiceUsername, sServicePassword);
- pDPObject->SetServiceData(aServiceDesk);
+ rPivotSources.appendServiceSource(pDPObject, aServiceDesc);
}
break;
case CELLRANGE :
@@ -525,12 +530,14 @@ void ScXMLDataPilotTableContext::EndElement()
else
aSheetDesc.SetSourceRange(aSourceCellRangeAddress);
aSheetDesc.SetQueryParam(aSourceQueryParam);
- pDPObject->SetSheetDesc(aSheetDesc);
+ rPivotSources.appendSheetSource(pDPObject, aSheetDesc);
}
}
break;
}
+ rPivotSources.appendSelectedPages(pDPObject, maSelectedPages);
+
pDPSave->SetRowGrand(maRowGrandTotal.mbVisible);
pDPSave->SetColumnGrand(maColGrandTotal.mbVisible);
if (!maRowGrandTotal.maDisplayName.isEmpty())
@@ -553,36 +560,10 @@ 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)
{