Kaydet (Commit) 4931d3e5 authored tarafından Kohei Yoshida's avatar Kohei Yoshida

Actually we can just swap them. The originals are not used after this call.

This avoids redundant copying of vectors.

Change-Id: I1da8295774a1a39fd4df021fee1a3036134067a8
üst c669d9e6
...@@ -292,7 +292,7 @@ class ScDPResultData ...@@ -292,7 +292,7 @@ class ScDPResultData
std::vector<ScSubTotalFunc> maMeasureFuncs; std::vector<ScSubTotalFunc> maMeasureFuncs;
std::vector<com::sun::star::sheet::DataPilotFieldReference> maMeasureRefs; std::vector<com::sun::star::sheet::DataPilotFieldReference> maMeasureRefs;
std::vector<sal_uInt16> maMeasureRefOrients; std::vector<sal_uInt16> maMeasureRefOrients;
std::vector<rtl::OUString> maMeasureNames; std::vector<OUString> maMeasureNames;
bool bLateInit:1; bool bLateInit:1;
bool bDataAtCol:1; bool bDataAtCol:1;
...@@ -304,9 +304,11 @@ public: ...@@ -304,9 +304,11 @@ public:
ScDPResultData( ScDPSource& rSrc ); ScDPResultData( ScDPSource& rSrc );
~ScDPResultData(); ~ScDPResultData();
void SetMeasureData( long nCount, const ScSubTotalFunc* pFunctions, void SetMeasureData(
const ::com::sun::star::sheet::DataPilotFieldReference* pRefs, std::vector<ScSubTotalFunc>& rFunctions,
const sal_uInt16* pRefOrient, std::vector<rtl::OUString>& rNames ); std::vector<com::sun::star::sheet::DataPilotFieldReference>& rRefs,
std::vector<sal_uInt16>& rRefOrient, std::vector<OUString>& rNames );
void SetDataLayoutOrientation( sal_uInt16 nOrient ); void SetDataLayoutOrientation( sal_uInt16 nOrient );
void SetLateInit( bool bSet ); void SetLateInit( bool bSet );
......
...@@ -724,33 +724,14 @@ ScDPResultData::~ScDPResultData() ...@@ -724,33 +724,14 @@ ScDPResultData::~ScDPResultData()
std::for_each(maDimMembers.begin(), maDimMembers.end(), ScDeleteObjectByPtr<ResultMembers>()); std::for_each(maDimMembers.begin(), maDimMembers.end(), ScDeleteObjectByPtr<ResultMembers>());
} }
void ScDPResultData::SetMeasureData( long nCount, const ScSubTotalFunc* pFunctions, void ScDPResultData::SetMeasureData(
const sheet::DataPilotFieldReference* pRefs, const sal_uInt16* pRefOrient, std::vector<ScSubTotalFunc>& rFunctions, std::vector<sheet::DataPilotFieldReference>& rRefs,
std::vector<rtl::OUString>& rNames ) std::vector<sal_uInt16>& rRefOrient, std::vector<OUString>& rNames )
{ {
maMeasureFuncs.clear(); maMeasureFuncs.swap(rFunctions);
maMeasureRefs.clear(); maMeasureRefs.swap(rRefs);
maMeasureRefOrients.clear(); maMeasureRefOrients.swap(rRefOrient);
maMeasureNames.swap(rNames);
if ( nCount )
{
OSL_ASSERT(nCount == static_cast<long>(rNames.size()));
maMeasureFuncs.assign(pFunctions, pFunctions+nCount);
maMeasureRefs.assign(pRefs, pRefs+nCount);
maMeasureRefOrients.assign(pRefOrient, pRefOrient+nCount);
maMeasureNames.swap(rNames);
}
else
{
// use one dummy measure
maMeasureFuncs.push_back(SUBTOTAL_FUNC_NONE);
maMeasureRefs.push_back(sheet::DataPilotFieldReference()); // default ctor is ok
maMeasureRefOrients.push_back(sheet::DataPilotFieldOrientation_HIDDEN);
std::vector<rtl::OUString> aMeasureName;
aMeasureName.push_back(ScGlobal::GetRscString(STR_EMPTYDATA));
maMeasureNames.swap(aMeasureName);
}
} }
void ScDPResultData::SetDataLayoutOrientation( sal_uInt16 nOrient ) void ScDPResultData::SetDataLayoutOrientation( sal_uInt16 nOrient )
......
...@@ -841,16 +841,7 @@ void ScDPSource::CreateRes_Impl() ...@@ -841,16 +841,7 @@ void ScDPSource::CreateRes_Impl()
} }
pResData = new ScDPResultData(*this); pResData = new ScDPResultData(*this);
const ScSubTotalFunc* pDataFunctions = NULL; pResData->SetMeasureData(aDataFunctions, aDataRefValues, aDataRefOrient, aDataNames);
const sheet::DataPilotFieldReference* pDataRefValues = NULL;
const sal_uInt16* pDataRefOrient = NULL;
if (!maDataDims.empty())
{
pDataFunctions = &aDataFunctions[0];
pDataRefValues = &aDataRefValues[0];
pDataRefOrient = &aDataRefOrient[0];
}
pResData->SetMeasureData(maDataDims.size(), pDataFunctions, pDataRefValues, pDataRefOrient, aDataNames);
pResData->SetDataLayoutOrientation(nDataOrient); pResData->SetDataLayoutOrientation(nDataOrient);
pResData->SetLateInit( bLateInit ); pResData->SetLateInit( bLateInit );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment