Shared commonly used STL function objects & remove memory leak.
This commit is contained in:
parent
ed36b5d3c3
commit
448ec432f4
5 changed files with 52 additions and 27 deletions
42
sc/inc/stlalgorithm.hxx
Normal file
42
sc/inc/stlalgorithm.hxx
Normal file
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* Version: MPL 1.1 / GPLv3+ / LGPLv3+
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Kohei Yoshida <kyoshida@novell.com> (Novell, Inc.)
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010 the
|
||||
* Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 3 or later (the "GPLv3+"), or
|
||||
* the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
|
||||
* in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
|
||||
* instead of those above.
|
||||
*/
|
||||
|
||||
#ifndef __SC_STLALGORITHM_HXX__
|
||||
#define __SC_STLALGORITHM_HXX__
|
||||
|
||||
#include <functional>
|
||||
|
||||
template<typename T>
|
||||
struct ScDeleteObjectByPtr : public ::std::unary_function<T*, void>
|
||||
{
|
||||
void operator() (T* p)
|
||||
{
|
||||
delete p;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
|
@ -42,6 +42,7 @@
|
|||
#include "refupdat.hxx"
|
||||
#include "rechead.hxx"
|
||||
#include "compiler.hxx"
|
||||
#include "stlalgorithm.hxx"
|
||||
|
||||
using ::std::vector;
|
||||
using ::std::advance;
|
||||
|
@ -92,15 +93,6 @@ private:
|
|||
vector<ScRange*>& mrRanges;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct DeleteObject : public ::std::unary_function<void, T*>
|
||||
{
|
||||
void operator() (T* p)
|
||||
{
|
||||
delete p;
|
||||
}
|
||||
};
|
||||
|
||||
class CountCells : public ::std::unary_function<void, const ScRange*>
|
||||
{
|
||||
public:
|
||||
|
@ -470,7 +462,7 @@ ScRange* ScRangeList::Remove(size_t nPos)
|
|||
|
||||
void ScRangeList::RemoveAll()
|
||||
{
|
||||
for_each(maRanges.begin(), maRanges.end(), DeleteObject<ScRange>());
|
||||
for_each(maRanges.begin(), maRanges.end(), ScDeleteObjectByPtr<ScRange>());
|
||||
maRanges.clear();
|
||||
}
|
||||
|
||||
|
@ -523,7 +515,7 @@ void ScRangeList::push_back(ScRange* p)
|
|||
|
||||
ScRangePairList::~ScRangePairList()
|
||||
{
|
||||
for_each( maPairs.begin(), maPairs.end(), DeleteObject<ScRangePair>() );
|
||||
for_each( maPairs.begin(), maPairs.end(), ScDeleteObjectByPtr<ScRangePair>() );
|
||||
maPairs.clear();
|
||||
}
|
||||
|
||||
|
|
|
@ -151,7 +151,6 @@ private:
|
|||
bool mbOldCursorValid; // "virtuelle" Cursorpos. bei zusammengefassten
|
||||
|
||||
ScViewDataTable();
|
||||
~ScViewDataTable();
|
||||
|
||||
void WriteUserDataSequence(
|
||||
com::sun::star::uno::Sequence <com::sun::star::beans::PropertyValue>& rSettings,
|
||||
|
@ -160,6 +159,8 @@ private:
|
|||
void ReadUserDataSequence(
|
||||
const com::sun::star::uno::Sequence <com::sun::star::beans::PropertyValue>& rSettings,
|
||||
ScViewData& rViewData, SCTAB nTab, bool& rHasZoom);
|
||||
public:
|
||||
~ScViewDataTable();
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
#include "compiler.hxx"
|
||||
#include "reftokenhelper.hxx"
|
||||
#include "chartlis.hxx"
|
||||
#include "stlalgorithm.hxx"
|
||||
|
||||
#include <sfx2/objsh.hxx>
|
||||
#include <tools/table.hxx>
|
||||
|
@ -156,20 +157,6 @@ uno::Reference< sheet::XSpreadsheetDocument > lcl_GetSpreadSheetDocument( ScDocu
|
|||
return uno::Reference< sheet::XSpreadsheetDocument >( lcl_GetXModel( pDoc ), uno::UNO_QUERY );
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
|
||||
namespace {
|
||||
|
||||
struct DeleteInstance : public unary_function<FormulaToken*, void>
|
||||
{
|
||||
void operator() (FormulaToken* p) const
|
||||
{
|
||||
delete p;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
struct TokenTable
|
||||
{
|
||||
SCROW mnRowCount;
|
||||
|
@ -184,7 +171,7 @@ struct TokenTable
|
|||
}
|
||||
void clear()
|
||||
{
|
||||
::std::for_each(maTokens.begin(), maTokens.end(), DeleteInstance());
|
||||
::std::for_each(maTokens.begin(), maTokens.end(), ScDeleteObjectByPtr<FormulaToken>());
|
||||
}
|
||||
|
||||
void push_back( FormulaToken* pToken )
|
||||
|
|
|
@ -64,6 +64,7 @@
|
|||
#include "unonames.hxx"
|
||||
#include "inputopt.hxx"
|
||||
#include "viewutil.hxx"
|
||||
#include "stlalgorithm.hxx"
|
||||
#include <xmloff/xmluconv.hxx>
|
||||
#include "ViewSettingsSequenceDefines.hxx"
|
||||
#include <rtl/ustrbuf.hxx>
|
||||
|
@ -435,6 +436,8 @@ ScViewData::~ScViewData()
|
|||
{
|
||||
KillEditView();
|
||||
delete pOptions;
|
||||
::std::for_each(
|
||||
maTabData.begin(), maTabData.end(), ScDeleteObjectByPtr<ScViewDataTable>());
|
||||
}
|
||||
|
||||
void ScViewData::UpdateCurrentTab()
|
||||
|
|
Loading…
Reference in a new issue