Hi
Note that I did not use boost::ptr_vector because that would have meant
switching to using references everywhere, and the existing logic makes
use of NULL values, so I left that for a future patch.
Code is contributed under MPL+/LGPL+/GPL+
Regards, Noel Grandin
Disclaimer: http://www.peralex.com/disclaimer.html
diff --git a/sc/inc/dptabres.hxx b/sc/inc/dptabres.hxx
index 6864e14..da1581d 100644
--- a/sc/inc/dptabres.hxx
+++ b/sc/inc/dptabres.hxx
@@ -221,8 +221,6 @@ public:
// results for a hierarchy dimension
//
-#define SC_DP_RES_GROW 16
-
class ScDPResultDimension;
class ScDPDataDimension;
class ScDPDataMember;
@@ -494,10 +492,7 @@ public:
ScDPDataDimension* GetChildDimension() { return pChildDimension; }
};
-//! replace PtrArr with 32-bit array ????
-
-typedef ScDPDataMember* ScDPDataMemberPtr;
-SV_DECL_PTRARR_DEL(ScDPDataMembers, ScDPDataMemberPtr, SC_DP_RES_GROW)
+typedef std::vector<ScDPDataMember*> ScDPDataMembers;
// result dimension contains only members
@@ -646,7 +641,8 @@ public:
void DumpState( const ScDPResultDimension* pRefDim, ScDocument* pDoc,
ScAddress& rPos ) const;
long GetMemberCount() const;
- ScDPDataMember* GetMember(long n) const;
+ const ScDPDataMember* GetMember(long n) const;
+ ScDPDataMember* GetMember(long n);
};
// ----------------------------------------------------------------------------
diff --git a/sc/source/core/data/dptabres.cxx b/sc/source/core/data/dptabres.cxx
index 15fd87b..c892cea 100644
--- a/sc/source/core/data/dptabres.cxx
+++ b/sc/source/core/data/dptabres.cxx
@@ -67,10 +67,6 @@ using ::rtl::OUString;
// -----------------------------------------------------------------------
-SV_IMPL_PTRARR( ScDPDataMembers, ScDPDataMemberPtr );
-
-// -----------------------------------------------------------------------
-
static sal_uInt16 nFuncStrIds[12] = // passend zum enum ScSubTotalFunc
{
0, // SUBTOTAL_FUNC_NONE
@@ -243,8 +239,8 @@ sal_Bool ScDPRowMembersOrder::operator()( sal_Int32 nIndex1, sal_Int32 nIndex2 )
sal_Bool ScDPColMembersOrder::operator()( sal_Int32 nIndex1, sal_Int32 nIndex2 ) const
{
- ScDPDataMember* pDataMember1 = rDimension.GetMember(nIndex1);
- ScDPDataMember* pDataMember2 = rDimension.GetMember(nIndex2);
+ const ScDPDataMember* pDataMember1 = rDimension.GetMember(nIndex1);
+ const ScDPDataMember* pDataMember2 = rDimension.GetMember(nIndex2);
sal_Bool bHide1 = pDataMember1 && !pDataMember1->IsVisible();
sal_Bool bHide2 = pDataMember2 && !pDataMember2->IsVisible();
if ( bHide1 || bHide2 )
@@ -2314,7 +2310,7 @@ void ScDPDataMember::UpdateRunningTotals( const ScDPResultMember* pRefMember,
sal_Bool bRefDimInCol = ( nRefOrient ==
sheet::DataPilotFieldOrientation_COLUMN );
sal_Bool bRefDimInRow = ( nRefOrient ==
sheet::DataPilotFieldOrientation_ROW );
- const ScDPResultDimension* pSelectDim = NULL;
+ ScDPResultDimension* pSelectDim = NULL;
long nRowPos = 0;
long nColPos = 0;
@@ -3297,7 +3293,7 @@ ScDPDataMember* ScDPResultDimension::GetRowReferenceMember( const
ScDPRelativePo
const long* pNextColIndex = pColIndexes;
while ( *pNextColIndex >= 0 && pColMember )
{
- const ScDPDataDimension* pColChild = pColMember->GetChildDimension();
+ ScDPDataDimension* pColChild = pColMember->GetChildDimension();
if ( pColChild && *pNextColIndex < pColChild->GetMemberCount() )
pColMember = pColChild->GetMember( *pNextColIndex );
else
@@ -3349,7 +3345,7 @@ ScDPDataMember* ScDPResultDimension::GetColReferenceMember( const
ScDPRelativePo
long nColSkipped = 0;
while ( *pNextColIndex >= 0 && pColMember && nColSkipped < nRefDimPos )
{
- const ScDPDataDimension* pColChild = pColMember->GetChildDimension();
+ ScDPDataDimension* pColChild = pColMember->GetChildDimension();
if ( pColChild && *pNextColIndex < pColChild->GetMemberCount() )
pColMember = pColChild->GetMember( *pNextColIndex );
else
@@ -3363,7 +3359,7 @@ ScDPDataMember* ScDPResultDimension::GetColReferenceMember( const
ScDPRelativePo
if ( pColMember )
{
- const ScDPDataDimension* pReferenceDim = pColMember->GetChildDimension();
+ ScDPDataDimension* pReferenceDim = pColMember->GetChildDimension();
if ( pReferenceDim )
{
long nReferenceCount = pReferenceDim->GetMemberCount();
@@ -3404,7 +3400,7 @@ ScDPDataMember* ScDPResultDimension::GetColReferenceMember( const
ScDPRelativePo
const long* pNextColIndex = pColIndexes + nRefDimPos + 1;
while ( *pNextColIndex >= 0 && pColMember )
{
- const ScDPDataDimension* pColChild = pColMember->GetChildDimension();
+ ScDPDataDimension* pColChild = pColMember->GetChildDimension();
if ( pColChild && *pNextColIndex < pColChild->GetMemberCount() )
pColMember = pColChild->GetMember( *pNextColIndex );
else
@@ -3504,6 +3500,8 @@ ScDPDataDimension::ScDPDataDimension( const ScDPResultData* pData ) :
ScDPDataDimension::~ScDPDataDimension()
{
+ for (ScDPDataMembers::iterator it = aMembers.begin(); it != aMembers.end(); ++it)
+ delete *it;
}
void ScDPDataDimension::InitFrom( const ScDPResultDimension* pDim )
@@ -3522,7 +3520,7 @@ void ScDPDataDimension::InitFrom( const ScDPResultDimension* pDim )
const ScDPResultMember* pResMem = pDim->GetMember(i);
ScDPDataMember* pNew = new ScDPDataMember( pResultData, pResMem );
- aMembers.Insert( pNew, aMembers.Count() );
+ aMembers.push_back( pNew);
if ( !pResultData->IsLateInit() )
{
@@ -3541,7 +3539,7 @@ void ScDPDataDimension::ProcessData( const vector< SCROW >& aDataMembers,
const
{
// the ScDPItemData array must contain enough entries for all dimensions - this isn't checked
- long nCount = aMembers.Count();
+ long nCount = aMembers.size();
for (long i=0; i<nCount; i++)
{
ScDPDataMember* pMember = aMembers[(sal_uInt16)i];
@@ -3575,7 +3573,7 @@ void ScDPDataDimension::FillDataRow( const ScDPResultDimension* pRefDim,
long nMemberMeasure = nMeasure;
long nMemberCol = nCol;
- long nCount = aMembers.Count();
+ long nCount = aMembers.size();
for (long i=0; i<nCount; i++)
{
long nSorted = rMemberOrder.empty() ? i : rMemberOrder[i];
@@ -3607,7 +3605,7 @@ void ScDPDataDimension::UpdateDataRow( const ScDPResultDimension* pRefDim,
OSL_ENSURE( pRefDim == pResultDimension, "wrong dim" );
long nMemberMeasure = nMeasure;
- long nCount = aMembers.Count();
+ long nCount = aMembers.size();
for (long i=0; i<nCount; i++)
{
long nMemberPos = i;
@@ -3628,7 +3626,7 @@ void ScDPDataDimension::UpdateDataRow( const ScDPResultDimension* pRefDim,
void ScDPDataDimension::SortMembers( ScDPResultDimension* pRefDim )
{
- long nCount = aMembers.Count();
+ long nCount = aMembers.size();
if ( pRefDim->IsSortByData() )
{
@@ -3664,7 +3662,7 @@ void ScDPDataDimension::SortMembers( ScDPResultDimension* pRefDim )
void ScDPDataDimension::DoAutoShow( ScDPResultDimension* pRefDim )
{
- long nCount = aMembers.Count();
+ long nCount = aMembers.size();
// handle children first, before changing the visible state
@@ -3678,7 +3676,7 @@ void ScDPDataDimension::DoAutoShow( ScDPResultDimension* pRefDim )
ScDPResultMember* pRefMember = pRefDim->GetMember(i);
if ( pRefMember->IsVisible() ) //! here or in ScDPDataMember ???
{
- ScDPDataMember* pDataMember = aMembers[(sal_uInt16)i];
+ ScDPDataMember* pDataMember = aMembers[i];
pDataMember->DoAutoShow( pRefMember );
}
}
@@ -3699,7 +3697,7 @@ void ScDPDataDimension::DoAutoShow( ScDPResultDimension* pRefDim )
// look for equal values to the last included one
long nIncluded = pRefDim->GetAutoCount();
- ScDPDataMember* pDataMember1 = aMembers[(sal_uInt16)aAutoOrder[nIncluded - 1]];
+ ScDPDataMember* pDataMember1 = aMembers[aAutoOrder[nIncluded - 1]];
if ( !pDataMember1->IsVisible() )
pDataMember1 = NULL;
sal_Bool bContinue = sal_True;
@@ -3708,7 +3706,7 @@ void ScDPDataDimension::DoAutoShow( ScDPResultDimension* pRefDim )
bContinue = false;
if ( nIncluded < nCount )
{
- ScDPDataMember* pDataMember2 = aMembers[(sal_uInt16)aAutoOrder[nIncluded]];
+ ScDPDataMember* pDataMember2 = aMembers[aAutoOrder[nIncluded]];
if ( !pDataMember2->IsVisible() )
pDataMember2 = NULL;
@@ -3732,13 +3730,13 @@ void ScDPDataDimension::DoAutoShow( ScDPResultDimension* pRefDim )
void ScDPDataDimension::ResetResults()
{
- long nCount = aMembers.Count();
+ long nCount = aMembers.size();
for (long i=0; i<nCount; i++)
{
// sort order doesn't matter
long nMemberPos = bIsDataLayout ? 0 : i;
- ScDPDataMember* pDataMember = aMembers[(sal_uInt16)nMemberPos];
+ ScDPDataMember* pDataMember = aMembers[nMemberPos];
pDataMember->ResetResults();
}
}
@@ -3761,7 +3759,7 @@ void ScDPDataDimension::UpdateRunningTotals( const ScDPResultDimension*
pRefDim,
OSL_ENSURE( pRefDim == pResultDimension, "wrong dim" );
long nMemberMeasure = nMeasure;
- long nCount = aMembers.Count();
+ long nCount = aMembers.size();
for (long i=0; i<nCount; i++)
{
const ScMemberSortOrder& rMemberOrder = pRefDim->GetMemberOrder();
@@ -3784,7 +3782,7 @@ void ScDPDataDimension::UpdateRunningTotals( const ScDPResultDimension*
pRefDim,
else
rRunning.AddColIndex( i, nSorted );
- ScDPDataMember* pDataMember = aMembers[(sal_uInt16)nMemberPos];
+ ScDPDataMember* pDataMember = aMembers[nMemberPos];
pDataMember->UpdateRunningTotals( pRefMember, nMemberMeasure,
bIsSubTotalRow, rSubState, rRunning, rTotals,
rRowParent );
@@ -3800,11 +3798,11 @@ void ScDPDataDimension::DumpState( const ScDPResultDimension* pRefDim,
ScDocumen
SCROW nStartRow = rPos.Row();
- long nCount = bIsDataLayout ? 1 : aMembers.Count();
+ long nCount = bIsDataLayout ? 1 : aMembers.size();
for (long i=0; i<nCount; i++)
{
const ScDPResultMember* pRefMember = pRefDim->GetMember(i);
- const ScDPDataMember* pDataMember = aMembers[(sal_uInt16)i];
+ const ScDPDataMember* pDataMember = aMembers[i];
pDataMember->DumpState( pRefMember, pDoc, rPos );
}
@@ -3813,12 +3811,17 @@ void ScDPDataDimension::DumpState( const ScDPResultDimension* pRefDim,
ScDocumen
long ScDPDataDimension::GetMemberCount() const
{
- return aMembers.Count();
+ return aMembers.size();
+}
+
+const ScDPDataMember* ScDPDataDimension::GetMember(long n) const
+{
+ return aMembers[n];
}
-ScDPDataMember* ScDPDataDimension::GetMember(long n) const
+ScDPDataMember* ScDPDataDimension::GetMember(long n)
{
- return aMembers[(sal_uInt16)n];
+ return aMembers[n];
}
// ----------------------------------------------------------------------------
Context
- [PATCH] convert dptabres.cxx in SC module from SV_DECL_PTRARR_DEL to std::vector · Noel Grandin
Privacy Policy |
Impressum (Legal Info) |
Copyright information: Unless otherwise specified, all text and images
on this website are licensed under the
Creative Commons Attribution-Share Alike 3.0 License.
This does not include the source code of LibreOffice, which is
licensed under the Mozilla Public License (
MPLv2).
"LibreOffice" and "The Document Foundation" are
registered trademarks of their corresponding registered owners or are
in actual use as trademarks in one or more countries. Their respective
logos and icons are also subject to international copyright laws. Use
thereof is explained in our
trademark policy.