summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sc/inc/rangelst.hxx4
-rw-r--r--sc/source/core/tool/rangelst.cxx30
-rw-r--r--sc/source/filter/excel/xehelper.cxx2
-rw-r--r--sc/source/ui/miscdlgs/crnrdlg.cxx3
-rw-r--r--sc/source/ui/unoobj/nameuno.cxx6
5 files changed, 17 insertions, 28 deletions
diff --git a/sc/inc/rangelst.hxx b/sc/inc/rangelst.hxx
index 18eb33da90a6..3fe510c1d361 100644
--- a/sc/inc/rangelst.hxx
+++ b/sc/inc/rangelst.hxx
@@ -75,7 +75,7 @@ public:
ScRangeList GetIntersectedRange(const ScRange& rRange) const;
- ScRange* Remove(size_t nPos);
+ void Remove(size_t nPos);
void RemoveAll();
ScRange Combine() const;
@@ -123,7 +123,7 @@ public:
ScRangePair** CreateNameSortedArray( size_t& nCount, ScDocument* ) const;
void Remove(size_t nPos);
- ScRangePair* Remove(ScRangePair* pAdr);
+ void Remove(ScRangePair* pAdr);
size_t size() const;
ScRangePair* operator[](size_t idx);
diff --git a/sc/source/core/tool/rangelst.cxx b/sc/source/core/tool/rangelst.cxx
index 208135232e31..8c40bf4fbe97 100644
--- a/sc/source/core/tool/rangelst.cxx
+++ b/sc/source/core/tool/rangelst.cxx
@@ -330,7 +330,6 @@ void ScRangeList::Join( const ScRange& r, bool bIsInList )
{ // innerhalb der Liste Range loeschen
Remove(nOldPos);
i--;
- delete pOver;
pOver = nullptr;
if ( nOldPos )
nOldPos--; // Seek richtig aufsetzen
@@ -948,8 +947,7 @@ bool ScRangeList::DeleteArea( SCCOL nCol1, SCROW nRow1, SCTAB nTab1,
{
if(FindRangeIn< ScRange >(aRange)(maRanges[i]))
{
- ScRange* pRange = Remove(i);
- delete pRange;
+ Remove(i);
bChanged = true;
}
else
@@ -1079,17 +1077,16 @@ size_t ScRangeList::GetCellCount() const
return for_each(maRanges.begin(), maRanges.end(), func).getCellCount();
}
-ScRange* ScRangeList::Remove(size_t nPos)
+void ScRangeList::Remove(size_t nPos)
{
if (maRanges.size() <= nPos)
// Out-of-bound condition. Bail out.
- return nullptr;
+ return;
iterator itr = maRanges.begin();
advance(itr, nPos);
- ScRange* p = *itr;
+ delete *itr;
maRanges.erase(itr);
- return p;
}
void ScRangeList::RemoveAll()
@@ -1237,24 +1234,25 @@ void ScRangePairList::Remove(size_t nPos)
vector<ScRangePair*>::iterator itr = maPairs.begin();
advance(itr, nPos);
+ delete *itr;
maPairs.erase(itr);
}
-ScRangePair* ScRangePairList::Remove( ScRangePair* Adr)
+void ScRangePairList::Remove( ScRangePair* Adr)
{
- ScRangePair* p = nullptr;
-
- if (Adr == nullptr) return nullptr;
+ if (Adr == nullptr)
+ return;
- for ( vector<ScRangePair*>::iterator itr = maPairs.begin(); itr < maPairs.end(); ++itr )
+ for ( vector<ScRangePair*>::iterator itr = maPairs.begin(); itr != maPairs.end(); ++itr )
{
- if ( Adr == (p = *itr) )
+ if (Adr == *itr)
{
+ delete *itr;
maPairs.erase( itr );
- break;
+ return;
}
}
- return p;
+ assert(false);
}
ScRangePair* ScRangePairList::operator [](size_t idx)
@@ -1323,7 +1321,6 @@ void ScRangePairList::DeleteOnTab( SCTAB nTab )
if ( aRange.aStart.Tab() == nTab && aRange.aEnd.Tab() == nTab )
{
Remove( nPos );
- delete pR;
nListCount = maPairs.size();
}
else
@@ -1544,7 +1541,6 @@ void ScRangePairList::Join( const ScRangePair& r, bool bIsInList )
{ // innerhalb der Liste RangePair loeschen
Remove( nOldPos );
i--;
- delete pOver;
pOver = nullptr;
if ( nOldPos )
nOldPos--; // Seek richtig aufsetzen
diff --git a/sc/source/filter/excel/xehelper.cxx b/sc/source/filter/excel/xehelper.cxx
index ba13ae29371f..22d3ebb77173 100644
--- a/sc/source/filter/excel/xehelper.cxx
+++ b/sc/source/filter/excel/xehelper.cxx
@@ -252,7 +252,7 @@ void XclExpAddressConverter::ValidateRangeList( ScRangeList& rScRanges, bool bWa
{
ScRange* pScRange = rScRanges[ --nRange ];
if( !CheckRange( *pScRange, bWarn ) )
- delete rScRanges.Remove(nRange);
+ rScRanges.Remove(nRange);
}
}
diff --git a/sc/source/ui/miscdlgs/crnrdlg.cxx b/sc/source/ui/miscdlgs/crnrdlg.cxx
index d8c3beed7662..953f10563084 100644
--- a/sc/source/ui/miscdlgs/crnrdlg.cxx
+++ b/sc/source/ui/miscdlgs/crnrdlg.cxx
@@ -539,12 +539,10 @@ IMPL_LINK_NOARG(ScColRowNameRangesDlg, AddBtnHdl, Button*, void)
if ( ( pPair = xColNameRanges->Find( theCurArea ) ) != nullptr )
{
xColNameRanges->Remove( pPair );
- delete pPair;
}
if ( ( pPair = xRowNameRanges->Find( theCurArea ) ) != nullptr )
{
xRowNameRanges->Remove( pPair );
- delete pPair;
}
if ( pBtnColHead->IsChecked() )
xColNameRanges->Join( ScRangePair( theCurArea, theCurData ) );
@@ -605,7 +603,6 @@ IMPL_LINK_NOARG(ScColRowNameRangesDlg, RemoveBtnHdl, Button*, void)
xColNameRanges->Remove( pPair );
else
xRowNameRanges->Remove( pPair );
- delete pPair;
UpdateNames();
const sal_Int32 nCnt = pLbRange->GetEntryCount();
diff --git a/sc/source/ui/unoobj/nameuno.cxx b/sc/source/ui/unoobj/nameuno.cxx
index a8f31d101c41..b71f9f56925f 100644
--- a/sc/source/ui/unoobj/nameuno.cxx
+++ b/sc/source/ui/unoobj/nameuno.cxx
@@ -975,15 +975,12 @@ void ScLabelRangeObj::Modify_Impl( const ScRange* pLabel, const ScRange* pData )
ScRangePair* pEntry = xNewList->Find( aRange );
if (pEntry)
{
- xNewList->Remove( pEntry ); // only removed from list, not deleted
-
if ( pLabel )
pEntry->GetRange(0) = *pLabel;
if ( pData )
pEntry->GetRange(1) = *pData;
- xNewList->Join( *pEntry );
- delete pEntry;
+ xNewList->Join( *pEntry, true );
if (bColumn)
rDoc.GetColNameRangesRef() = xNewList;
@@ -1139,7 +1136,6 @@ void SAL_CALL ScLabelRangesObj::removeByIndex( sal_Int32 nIndex )
if (pEntry)
{
xNewList->Remove( pEntry );
- delete pEntry;
if (bColumn)
rDoc.GetColNameRangesRef() = xNewList;