diff options
author | Kohei Yoshida <kohei.yoshida@suse.com> | 2011-11-15 01:31:34 -0500 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@suse.com> | 2011-11-15 02:02:52 -0500 |
commit | 35054d3f6213c11546200820c706c8a1527ec605 (patch) | |
tree | efcbff3fff68d2f308b156a2227dddf6f3e2cf80 /sc | |
parent | 13e09805f5058b6fcf700f566ea7935474dd9310 (diff) |
Replaced heap array with std::vector.
Diffstat (limited to 'sc')
-rw-r--r-- | sc/inc/dptabres.hxx | 4 | ||||
-rw-r--r-- | sc/source/core/data/dptabres.cxx | 18 | ||||
-rw-r--r-- | sc/source/core/data/dptabsrc.cxx | 11 |
3 files changed, 15 insertions, 18 deletions
diff --git a/sc/inc/dptabres.hxx b/sc/inc/dptabres.hxx index aedb6f77c8a7..b8a2414a90c7 100644 --- a/sc/inc/dptabres.hxx +++ b/sc/inc/dptabres.hxx @@ -299,7 +299,7 @@ private: ScSubTotalFunc* pMeasFuncs; ::com::sun::star::sheet::DataPilotFieldReference* pMeasRefs; sal_uInt16* pMeasRefOrient; - String* pMeasNames; + std::vector<String> maMeasureNames; bool bLateInit:1; bool bDataAtCol:1; bool bDataAtRow:1; @@ -312,7 +312,7 @@ public: void SetMeasureData( long nCount, const ScSubTotalFunc* pFunctions, const ::com::sun::star::sheet::DataPilotFieldReference* pRefs, - const sal_uInt16* pRefOrient, const String* pNames ); + const sal_uInt16* pRefOrient, std::vector<String>& rNames ); void SetDataLayoutOrientation( sal_uInt16 nOrient ); void SetLateInit( bool bSet ); diff --git a/sc/source/core/data/dptabres.cxx b/sc/source/core/data/dptabres.cxx index 3f18da1ea2e9..b7c5e0a0bc76 100644 --- a/sc/source/core/data/dptabres.cxx +++ b/sc/source/core/data/dptabres.cxx @@ -767,7 +767,6 @@ ScDPResultData::ScDPResultData( ScDPSource* pSrc ) : //! Ref pMeasFuncs( NULL ), pMeasRefs( NULL ), pMeasRefOrient( NULL ), - pMeasNames( NULL ), bLateInit( false ), bDataAtCol( false ), bDataAtRow( false ) @@ -781,32 +780,30 @@ ScDPResultData::~ScDPResultData() delete[] pMeasFuncs; delete[] pMeasRefs; delete[] pMeasRefOrient; - delete[] pMeasNames; lcl_ResizePointVector( mpDimMembers , 0 ); } void ScDPResultData::SetMeasureData( long nCount, const ScSubTotalFunc* pFunctions, const sheet::DataPilotFieldReference* pRefs, const sal_uInt16* pRefOrient, - const String* pNames ) + std::vector<String>& rNames ) { delete[] pMeasFuncs; delete[] pMeasRefs; delete[] pMeasRefOrient; - delete[] pMeasNames; if ( nCount ) { + OSL_ASSERT(nCount == static_cast<long>(rNames.size())); nMeasCount = nCount; pMeasFuncs = new ScSubTotalFunc[nCount]; pMeasRefs = new sheet::DataPilotFieldReference[nCount]; pMeasRefOrient = new sal_uInt16[nCount]; - pMeasNames = new String[nCount]; + maMeasureNames.swap(rNames); for (long i=0; i<nCount; i++) { pMeasFuncs[i] = pFunctions[i]; pMeasRefs[i] = pRefs[i]; pMeasRefOrient[i] = pRefOrient[i]; - pMeasNames[i] = pNames[i]; } } else @@ -818,8 +815,9 @@ void ScDPResultData::SetMeasureData( long nCount, const ScSubTotalFunc* pFunctio pMeasRefs = new sheet::DataPilotFieldReference[1]; // default ctor is ok pMeasRefOrient = new sal_uInt16[1]; pMeasRefOrient[0] = sheet::DataPilotFieldOrientation_HIDDEN; - pMeasNames = new String[1]; - pMeasNames[0] = ScGlobal::GetRscString( STR_EMPTYDATA ); + std::vector<String> aMeasureName; + aMeasureName.push_back(ScGlobal::GetRscString(STR_EMPTYDATA)); + maMeasureNames.swap(aMeasureName); } } @@ -881,7 +879,7 @@ String ScDPResultData::GetMeasureString(long nMeasure, bool bForce, ScSubTotalFu } else { - OSL_ENSURE( pMeasNames && nMeasure < nMeasCount, "bumm" ); + OSL_ENSURE( nMeasure < nMeasCount, "bumm" ); ScDPDimension* pDataDim = pSource->GetDataDimension(nMeasure); if (pDataDim) { @@ -898,7 +896,7 @@ String ScDPResultData::GetMeasureString(long nMeasure, bool bForce, ScSubTotalFu aRet += ScGlobal::GetRscString(nId); // function name aRet.AppendAscii(RTL_CONSTASCII_STRINGPARAM( " - " )); } - aRet += pMeasNames[nMeasure]; // field name + aRet += maMeasureNames[nMeasure]; // field name return aRet; } diff --git a/sc/source/core/data/dptabsrc.cxx b/sc/source/core/data/dptabsrc.cxx index 545109a9cfa4..008ea39a8271 100644 --- a/sc/source/core/data/dptabsrc.cxx +++ b/sc/source/core/data/dptabsrc.cxx @@ -792,13 +792,13 @@ void ScDPSource::CreateRes_Impl() // TODO: Aggreate pDataNames, pDataRefValues, nDataRefOrient, and // eDataFunctions into a structure and use vector instead of static // or pointer arrays. - String* pDataNames = NULL; + vector<String> aDataNames; sheet::DataPilotFieldReference* pDataRefValues = NULL; ScSubTotalFunc eDataFunctions[SC_DAPI_MAXFIELDS]; sal_uInt16 nDataRefOrient[SC_DAPI_MAXFIELDS]; if (nDataDimCount) { - pDataNames = new String[nDataDimCount]; + aDataNames.resize(nDataDimCount); pDataRefValues = new sheet::DataPilotFieldReference[nDataDimCount]; } @@ -849,12 +849,12 @@ void ScDPSource::CreateRes_Impl() } } - pDataNames[i] = String( pDim->getName() ); //! label? + aDataNames[i] = pDim->getName(); // asterisk is added to duplicated dimension names by ScDPSaveData::WriteToSource //! modify user visible strings as in ScDPResultData::GetMeasureString instead! - pDataNames[i].EraseTrailingChars('*'); + aDataNames[i].EraseTrailingChars('*'); //! if the name is overridden by user, a flag must be set //! so the user defined name replaces the function string and field name. @@ -869,11 +869,10 @@ void ScDPSource::CreateRes_Impl() } pResData = new ScDPResultData( this ); - pResData->SetMeasureData( nDataDimCount, eDataFunctions, pDataRefValues, nDataRefOrient, pDataNames ); + pResData->SetMeasureData( nDataDimCount, eDataFunctions, pDataRefValues, nDataRefOrient, aDataNames ); pResData->SetDataLayoutOrientation(nDataOrient); pResData->SetLateInit( bLateInit ); - delete[] pDataNames; delete[] pDataRefValues; bool bHasAutoShow = false; |