summaryrefslogtreecommitdiff
path: root/sc/source
diff options
context:
space:
mode:
authorKohei Yoshida <kyoshida@novell.com>2010-12-09 20:58:11 -0500
committerKohei Yoshida <kyoshida@novell.com>2010-12-09 20:58:11 -0500
commit2fc70e11172ea6ae3747f35ed5a6e01723956bf1 (patch)
tree0cfc1206ef6fbe3bc7014f72690d6d9f21c0f5d2 /sc/source
parenta4c8eab127f5c8fa8bb85c536060d264f7ce69be (diff)
Don't allow client code to call clear() directly, it leaks memory.
Call RemoveAll() instead. Better yet, I've removed clear() call as it's safer this way.
Diffstat (limited to 'sc/source')
-rw-r--r--sc/source/core/data/document.cxx4
-rw-r--r--sc/source/core/data/markdata.cxx4
-rw-r--r--sc/source/core/tool/rangelst.cxx31
-rw-r--r--sc/source/filter/excel/xiformula.cxx2
-rw-r--r--sc/source/filter/excel/xihelper.cxx2
-rw-r--r--sc/source/filter/excel/xistyle.cxx2
-rw-r--r--sc/source/filter/html/htmlpars.cxx4
-rw-r--r--sc/source/ui/miscdlgs/acredlin.cxx2
-rw-r--r--sc/source/ui/miscdlgs/anyrefdg.cxx2
-rw-r--r--sc/source/ui/unoobj/cellsuno.cxx6
-rw-r--r--sc/source/ui/vba/vbaeventshelper.cxx2
11 files changed, 35 insertions, 26 deletions
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 70918ed2e10f..9b76b2104206 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -1679,7 +1679,7 @@ void ScDocument::CopyTabToClip(SCCOL nCol1, SCROW nRow1,
ScClipParam& rClipParam = pClipDoc->GetClipParam();
pClipDoc->aDocName = aDocName;
- rClipParam.maRanges.clear();
+ rClipParam.maRanges.RemoveAll();
rClipParam.maRanges.Append(ScRange(nCol1, nRow1, 0, nCol2, nRow2, 0));
pClipDoc->ResetClip( this, nTab );
@@ -2467,7 +2467,7 @@ void ScDocument::SetClipArea( const ScRange& rArea, BOOL bCut )
if (bIsClip)
{
ScClipParam& rClipParam = GetClipParam();
- rClipParam.maRanges.clear();
+ rClipParam.maRanges.RemoveAll();
rClipParam.maRanges.Append(rArea);
rClipParam.mbCutMode = bCut;
}
diff --git a/sc/source/core/data/markdata.cxx b/sc/source/core/data/markdata.cxx
index d0a8c910de96..8e1bbf29381c 100644
--- a/sc/source/core/data/markdata.cxx
+++ b/sc/source/core/data/markdata.cxx
@@ -369,7 +369,7 @@ void ScMarkData::FillRangeListWithMarks( ScRangeList* pList, BOOL bClear ) const
return;
if (bClear)
- pList->clear();
+ pList->RemoveAll();
//! bei mehreren selektierten Tabellen mehrere Ranges eintragen !!!
@@ -406,7 +406,7 @@ void ScMarkData::ExtendRangeListTables( ScRangeList* pList ) const
return;
ScRangeList aOldList(*pList);
- pList->clear(); //! oder die vorhandenen unten weglassen
+ pList->RemoveAll(); //! oder die vorhandenen unten weglassen
for (SCTAB nTab=0; nTab<=MAXTAB; nTab++)
if (bTabMarked[nTab])
diff --git a/sc/source/core/tool/rangelst.cxx b/sc/source/core/tool/rangelst.cxx
index 168fbd07bae9..eebfafc473dd 100644
--- a/sc/source/core/tool/rangelst.cxx
+++ b/sc/source/core/tool/rangelst.cxx
@@ -47,15 +47,13 @@
using ::std::vector;
using ::std::advance;
using ::std::find_if;
+using ::std::for_each;
// === ScRangeList ====================================================
ScRangeList::~ScRangeList()
{
- std::vector<ScRangePtr>::iterator itr = maRanges.begin(), itrEnd = maRanges.end();
- for (; itr != itrEnd; ++itr)
- delete *itr;
- clear();
+ RemoveAll();
}
USHORT ScRangeList::Parse( const String& rStr, ScDocument* pDoc, USHORT nMask,
@@ -331,7 +329,7 @@ ScRangeList::ScRangeList( const ScRangeList& rList ) :
ScRangeList& ScRangeList::operator=(const ScRangeList& rList)
{
- clear();
+ RemoveAll();
for ( size_t j = 0, nListCount = rList.maRanges.size(); j < nListCount; j++ )
Append( *rList[ j ] );
return *this;
@@ -384,6 +382,24 @@ ScRange* ScRangeList::Remove(size_t nPos)
return p;
}
+namespace {
+
+struct DeleteObject : public ::std::unary_function<void, ScRange*>
+{
+ void operator() (ScRange* p)
+ {
+ delete p;
+ }
+};
+
+}
+
+void ScRangeList::RemoveAll()
+{
+ for_each(maRanges.begin(), maRanges.end(), DeleteObject());
+ maRanges.clear();
+}
+
bool ScRangeList::empty() const
{
return maRanges.empty();
@@ -439,11 +455,6 @@ void ScRangeList::push_back(ScRange* p)
maRanges.push_back(p);
}
-void ScRangeList::clear()
-{
- maRanges.clear();
-}
-
// === ScRangePairList ====================================================
ScRangePairList::~ScRangePairList()
diff --git a/sc/source/filter/excel/xiformula.cxx b/sc/source/filter/excel/xiformula.cxx
index 9a6343d3fb9c..c9927ff570fd 100644
--- a/sc/source/filter/excel/xiformula.cxx
+++ b/sc/source/filter/excel/xiformula.cxx
@@ -67,7 +67,7 @@ void XclImpFmlaCompImpl::CreateRangeList(
ScRangeList& rScRanges, XclFormulaType /*eType*/,
const XclTokenArray& rXclTokArr, XclImpStream& /*rStrm*/ )
{
- rScRanges.clear();
+ rScRanges.RemoveAll();
//! evil hack, using old formula import :-)
if( !rXclTokArr.Empty() )
diff --git a/sc/source/filter/excel/xihelper.cxx b/sc/source/filter/excel/xihelper.cxx
index f01213e76e14..bb17cc656add 100644
--- a/sc/source/filter/excel/xihelper.cxx
+++ b/sc/source/filter/excel/xihelper.cxx
@@ -140,7 +140,7 @@ bool XclImpAddressConverter::ConvertRange( ScRange& rScRange,
void XclImpAddressConverter::ConvertRangeList( ScRangeList& rScRanges,
const XclRangeList& rXclRanges, SCTAB nScTab, bool bWarn )
{
- rScRanges.clear();
+ rScRanges.RemoveAll();
for( XclRangeList::const_iterator aIt = rXclRanges.begin(), aEnd = rXclRanges.end(); aIt != aEnd; ++aIt )
{
ScRange aScRange( ScAddress::UNINITIALIZED );
diff --git a/sc/source/filter/excel/xistyle.cxx b/sc/source/filter/excel/xistyle.cxx
index e459ed1ddd6b..71838b0d14ae 100644
--- a/sc/source/filter/excel/xistyle.cxx
+++ b/sc/source/filter/excel/xistyle.cxx
@@ -1763,7 +1763,7 @@ void XclImpXFRangeBuffer::Initialize()
{
maColumns.clear();
maHyperlinks.clear();
- maMergeList.clear();
+ maMergeList.RemoveAll();
}
void XclImpXFRangeBuffer::SetXF( const ScAddress& rScPos, sal_uInt16 nXFIndex, XclImpXFInsertMode eMode )
diff --git a/sc/source/filter/html/htmlpars.cxx b/sc/source/filter/html/htmlpars.cxx
index 7b4cc2b9819b..5e03a9d61bb6 100644
--- a/sc/source/filter/html/htmlpars.cxx
+++ b/sc/source/filter/html/htmlpars.cxx
@@ -397,9 +397,7 @@ void ScHTMLLayoutParser::SkipLocked( ScEEParseEntry* pE, BOOL bJoin )
void ScHTMLLayoutParser::Adjust()
{
- for (size_t i = 0, n = xLockedList->size(); i < n; ++i)
- delete xLockedList->at(i);
- xLockedList->clear();
+ xLockedList->RemoveAll();
ScHTMLAdjustStack aStack;
ScHTMLAdjustStackEntry* pS;
diff --git a/sc/source/ui/miscdlgs/acredlin.cxx b/sc/source/ui/miscdlgs/acredlin.cxx
index 776e2a21efcd..53bf79768763 100644
--- a/sc/source/ui/miscdlgs/acredlin.cxx
+++ b/sc/source/ui/miscdlgs/acredlin.cxx
@@ -1023,7 +1023,7 @@ IMPL_LINK( ScAcceptChgDlg, FilterHandle, SvxTPFilter*, pRef )
if(pRef!=NULL)
{
ClearView();
- aRangeList.clear();
+ aRangeList.RemoveAll();
aRangeList.Parse(pTPFilter->GetRange(),pDoc);
UpdateView();
}
diff --git a/sc/source/ui/miscdlgs/anyrefdg.cxx b/sc/source/ui/miscdlgs/anyrefdg.cxx
index 7b0bd2ca0ca1..2c9c032f17d9 100644
--- a/sc/source/ui/miscdlgs/anyrefdg.cxx
+++ b/sc/source/ui/miscdlgs/anyrefdg.cxx
@@ -161,7 +161,7 @@ void ScFormulaReferenceHelper::ShowSimpleReference( const XubString& rStr )
bool ScFormulaReferenceHelper::ParseWithNames( ScRangeList& rRanges, const String& rStr, ScDocument* pDoc )
{
bool bError = false;
- rRanges.clear();
+ rRanges.RemoveAll();
ScAddress::Details aDetails(pDoc->GetAddressConvention(), 0, 0);
ScRangeUtil aRangeUtil;
diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx
index 906134b5eab6..ddce9f984952 100644
--- a/sc/source/ui/unoobj/cellsuno.cxx
+++ b/sc/source/ui/unoobj/cellsuno.cxx
@@ -1643,7 +1643,7 @@ void ScCellRangesBase::InitInsertRange(ScDocShell* pDocSh, const ScRange& rR)
ScRange aCellRange(rR);
aCellRange.Justify();
- aRanges.clear();
+ aRanges.RemoveAll();
aRanges.Append( aCellRange );
pDocShell->GetDocument()->AddUnoObject(*this);
@@ -1666,7 +1666,7 @@ void ScCellRangesBase::SetNewRange(const ScRange& rNew)
ScRange aCellRange(rNew);
aCellRange.Justify();
- aRanges.clear();
+ aRanges.RemoveAll();
aRanges.Append( aCellRange );
RefChanged();
}
@@ -4563,7 +4563,7 @@ void SAL_CALL ScCellRangesObj::removeByName( const rtl::OUString& aName )
for (USHORT n=0; n<nCount && !bValid; n++)
if (aNamedEntries[n]->GetName() == aNameStr)
{
- aDiff.clear();
+ aDiff.RemoveAll();
aDiff.Append( aNamedEntries[n]->GetRange() );
bValid = TRUE;
}
diff --git a/sc/source/ui/vba/vbaeventshelper.cxx b/sc/source/ui/vba/vbaeventshelper.cxx
index f99b32016c8e..7cbcc8592721 100644
--- a/sc/source/ui/vba/vbaeventshelper.cxx
+++ b/sc/source/ui/vba/vbaeventshelper.cxx
@@ -680,7 +680,7 @@ bool ScVbaEventsHelper::isSelectionChanged( const uno::Sequence< uno::Any >& rAr
maOldSelection = pNewCellRanges->GetRangeList();
return bChanged;
}
- maOldSelection.clear();
+ maOldSelection.RemoveAll();
return true;
}