summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2015-11-13 18:32:51 +0100
committerMichael Stahl <mstahl@redhat.com>2015-11-13 20:31:17 +0100
commitc0f489818595e50ed7cf01dfabc26c095617b44c (patch)
tree63eedea39f46120959e88995f103aa2846ece786
parent6f6056d9cf388f9a5a2b340e4091810910f2eb26 (diff)
sc: replace boost::ptr_vector with std::vector<std::unique_ptr>
Change-Id: I59831588fb7bc7e907fbffb24ddfe068552b6492
-rw-r--r--sc/inc/pch/precompiled_sc.hxx1
-rw-r--r--sc/inc/pch/precompiled_scfilt.hxx1
-rw-r--r--sc/inc/queryparam.hxx7
-rw-r--r--sc/source/core/data/dpsave.cxx6
-rw-r--r--sc/source/core/data/sortparam.cxx2
-rw-r--r--sc/source/core/data/table3.cxx4
-rw-r--r--sc/source/core/tool/queryparam.cxx95
7 files changed, 64 insertions, 52 deletions
diff --git a/sc/inc/pch/precompiled_sc.hxx b/sc/inc/pch/precompiled_sc.hxx
index 4a02554536b8..1adfbfad3ae1 100644
--- a/sc/inc/pch/precompiled_sc.hxx
+++ b/sc/inc/pch/precompiled_sc.hxx
@@ -40,7 +40,6 @@
#include <boost/math/special_functions/log1p.hpp>
#include <boost/noncopyable.hpp>
#include <boost/ptr_container/ptr_map.hpp>
-#include <boost/ptr_container/ptr_vector.hpp>
#include <memory>
#include <cassert>
#include <climits>
diff --git a/sc/inc/pch/precompiled_scfilt.hxx b/sc/inc/pch/precompiled_scfilt.hxx
index 468b070dcd96..4fb99bc3e3d1 100644
--- a/sc/inc/pch/precompiled_scfilt.hxx
+++ b/sc/inc/pch/precompiled_scfilt.hxx
@@ -21,7 +21,6 @@
#include <boost/bind.hpp>
#include <boost/checked_delete.hpp>
#include <boost/noncopyable.hpp>
-#include <boost/ptr_container/ptr_vector.hpp>
#include <memory>
#include <cassert>
#include <com/sun/star/awt/DeviceInfo.hpp>
diff --git a/sc/inc/queryparam.hxx b/sc/inc/queryparam.hxx
index 3c96260c1322..c1748637c30b 100644
--- a/sc/inc/queryparam.hxx
+++ b/sc/inc/queryparam.hxx
@@ -23,7 +23,8 @@
#include "global.hxx"
#include "types.hxx"
-#include <boost/ptr_container/ptr_vector.hpp>
+#include <memory>
+#include <vector>
class SvNumberFormatter;
@@ -61,7 +62,7 @@ struct ScQueryParamBase
SvNumberFormatter* pFormatter );
protected:
- typedef boost::ptr_vector<ScQueryEntry> EntriesType;
+ typedef std::vector<std::unique_ptr<ScQueryEntry>> EntriesType;
public:
typedef EntriesType::const_iterator const_iterator;
@@ -73,7 +74,7 @@ protected:
ScQueryParamBase();
ScQueryParamBase(const ScQueryParamBase& r);
- EntriesType maEntries;
+ EntriesType m_Entries;
};
struct ScQueryParamTable
diff --git a/sc/source/core/data/dpsave.cxx b/sc/source/core/data/dpsave.cxx
index 935aa9cad71f..82d810c60056 100644
--- a/sc/source/core/data/dpsave.cxx
+++ b/sc/source/core/data/dpsave.cxx
@@ -1085,9 +1085,9 @@ void ScDPSaveData::SetPosition( ScDPSaveDimension* pDim, long nNew )
{
if (pDim == it->get())
{
- // Tell ptr_vector to give up ownership of this element. Don't
- // delete this instance as it is re-inserted into the container
- // later.
+ // Tell vector<unique_ptr> to give up ownership of this element.
+ // Don't delete this instance as it is re-inserted into the
+ // container later.
it->release();
m_DimList.erase(it);
break;
diff --git a/sc/source/core/data/sortparam.cxx b/sc/source/core/data/sortparam.cxx
index 7c246cb00c39..0f7c158e6cb1 100644
--- a/sc/source/core/data/sortparam.cxx
+++ b/sc/source/core/data/sortparam.cxx
@@ -25,6 +25,8 @@
#include <osl/diagnose.h>
+#include <algorithm>
+
ScSortParam::ScSortParam()
{
Clear();
diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx
index d01f2f2b67a4..ee760802ac38 100644
--- a/sc/source/core/data/table3.cxx
+++ b/sc/source/core/data/table3.cxx
@@ -2620,9 +2620,9 @@ bool ScTable::ValidQuery(
long nPos = -1;
QueryEvaluator aEval(*pDocument, *this, rParam, pbTestEqualCondition);
ScQueryParam::const_iterator it, itBeg = rParam.begin(), itEnd = rParam.end();
- for (it = itBeg; it != itEnd && it->bDoQuery; ++it)
+ for (it = itBeg; it != itEnd && (*it)->bDoQuery; ++it)
{
- const ScQueryEntry& rEntry = *it;
+ const ScQueryEntry& rEntry = **it;
SCCOL nCol = static_cast<SCCOL>(rEntry.nField);
// We can only handle one single direct query passed as a known pCell,
diff --git a/sc/source/core/tool/queryparam.cxx b/sc/source/core/tool/queryparam.cxx
index c4e416fbd515..6a90ba2b6cac 100644
--- a/sc/source/core/tool/queryparam.cxx
+++ b/sc/source/core/tool/queryparam.cxx
@@ -23,8 +23,11 @@
#include <svl/sharedstringpool.hxx>
#include <svl/zforlist.hxx>
+#include <o3tl/make_unique.hxx>
#include <osl/diagnose.h>
+#include <algorithm>
+
namespace {
const size_t MAXQUERY = 8;
@@ -34,17 +37,17 @@ class FindByField : public std::unary_function<ScQueryEntry, bool>
SCCOLROW mnField;
public:
explicit FindByField(SCCOLROW nField) : mnField(nField) {}
- bool operator() (const ScQueryEntry& rEntry) const
+ bool operator() (const std::unique_ptr<ScQueryEntry>& rpEntry) const
{
- return rEntry.bDoQuery && rEntry.nField == mnField;
+ return rpEntry->bDoQuery && rpEntry->nField == mnField;
}
};
struct FindUnused : public std::unary_function<ScQueryEntry, bool>
{
- bool operator() (const ScQueryEntry& rEntry) const
+ bool operator() (const std::unique_ptr<ScQueryEntry>& rpEntry) const
{
- return !rEntry.bDoQuery;
+ return !rpEntry->bDoQuery;
}
};
@@ -52,12 +55,12 @@ struct FindUnused : public std::unary_function<ScQueryEntry, bool>
ScQueryParamBase::const_iterator ScQueryParamBase::begin() const
{
- return maEntries.begin();
+ return m_Entries.begin();
}
ScQueryParamBase::const_iterator ScQueryParamBase::end() const
{
- return maEntries.end();
+ return m_Entries.end();
}
ScQueryParamBase::ScQueryParamBase() :
@@ -70,14 +73,17 @@ ScQueryParamBase::ScQueryParamBase() :
mbRangeLookup(false)
{
for (size_t i = 0; i < MAXQUERY; ++i)
- maEntries.push_back(new ScQueryEntry);
+ m_Entries.push_back(o3tl::make_unique<ScQueryEntry>());
}
-ScQueryParamBase::ScQueryParamBase(const ScQueryParamBase& r) :
- bHasHeader(r.bHasHeader), bByRow(r.bByRow), bInplace(r.bInplace), bCaseSens(r.bCaseSens),
- bRegExp(r.bRegExp), bDuplicate(r.bDuplicate), mbRangeLookup(r.mbRangeLookup),
- maEntries(r.maEntries)
+ScQueryParamBase::ScQueryParamBase(const ScQueryParamBase& r)
+ : bHasHeader(r.bHasHeader), bByRow(r.bByRow), bInplace(r.bInplace), bCaseSens(r.bCaseSens)
+ , bRegExp(r.bRegExp), bDuplicate(r.bDuplicate), mbRangeLookup(r.mbRangeLookup)
{
+ for (auto const& it : r.m_Entries)
+ {
+ m_Entries.push_back(o3tl::make_unique<ScQueryEntry>(*it));
+ }
}
ScQueryParamBase::~ScQueryParamBase()
@@ -91,43 +97,43 @@ bool ScQueryParamBase::IsValidFieldIndex() const
SCSIZE ScQueryParamBase::GetEntryCount() const
{
- return maEntries.size();
+ return m_Entries.size();
}
const ScQueryEntry& ScQueryParamBase::GetEntry(SCSIZE n) const
{
- return maEntries[n];
+ return *m_Entries[n];
}
ScQueryEntry& ScQueryParamBase::GetEntry(SCSIZE n)
{
- return maEntries[n];
+ return *m_Entries[n];
}
ScQueryEntry& ScQueryParamBase::AppendEntry()
{
// Find the first unused entry.
EntriesType::iterator itr = std::find_if(
- maEntries.begin(), maEntries.end(), FindUnused());
+ m_Entries.begin(), m_Entries.end(), FindUnused());
- if (itr != maEntries.end())
+ if (itr != m_Entries.end())
// Found!
- return *itr;
+ return **itr;
// Add a new entry to the end.
- maEntries.push_back(new ScQueryEntry);
- return maEntries.back();
+ m_Entries.push_back(o3tl::make_unique<ScQueryEntry>());
+ return *m_Entries.back();
}
ScQueryEntry* ScQueryParamBase::FindEntryByField(SCCOLROW nField, bool bNew)
{
EntriesType::iterator itr = std::find_if(
- maEntries.begin(), maEntries.end(), FindByField(nField));
+ m_Entries.begin(), m_Entries.end(), FindByField(nField));
- if (itr != maEntries.end())
+ if (itr != m_Entries.end())
{
// existing entry found!
- return &(*itr);
+ return (*itr).get();
}
if (!bNew)
@@ -140,15 +146,15 @@ ScQueryEntry* ScQueryParamBase::FindEntryByField(SCCOLROW nField, bool bNew)
void ScQueryParamBase::RemoveEntryByField(SCCOLROW nField)
{
EntriesType::iterator itr = std::find_if(
- maEntries.begin(), maEntries.end(), FindByField(nField));
+ m_Entries.begin(), m_Entries.end(), FindByField(nField));
- if (itr != maEntries.end())
+ if (itr != m_Entries.end())
{
- maEntries.erase(itr);
- if (maEntries.size() < MAXQUERY)
+ m_Entries.erase(itr);
+ if (m_Entries.size() < MAXQUERY)
// Make sure that we have at least MAXQUERY number of entries at
// all times.
- maEntries.push_back(new ScQueryEntry);
+ m_Entries.push_back(o3tl::make_unique<ScQueryEntry>());
}
}
@@ -157,17 +163,17 @@ void ScQueryParamBase::Resize(size_t nNew)
if (nNew < MAXQUERY)
nNew = MAXQUERY; // never less than MAXQUERY
- if (nNew < maEntries.size())
+ if (nNew < m_Entries.size())
{
- size_t n = maEntries.size() - nNew;
+ size_t n = m_Entries.size() - nNew;
for (size_t i = 0; i < n; ++i)
- maEntries.pop_back();
+ m_Entries.pop_back();
}
- else if (nNew > maEntries.size())
+ else if (nNew > m_Entries.size())
{
- size_t n = nNew - maEntries.size();
+ size_t n = nNew - m_Entries.size();
for (size_t i = 0; i < n; ++i)
- maEntries.push_back(new ScQueryEntry);
+ m_Entries.push_back(o3tl::make_unique<ScQueryEntry>());
}
}
@@ -175,7 +181,7 @@ void ScQueryParamBase::FillInExcelSyntax(
svl::SharedStringPool& rPool, const OUString& rStr, SCSIZE nIndex, SvNumberFormatter* pFormatter )
{
const OUString aCellStr = rStr;
- if (nIndex >= maEntries.size())
+ if (nIndex >= m_Entries.size())
Resize(nIndex+1);
ScQueryEntry& rEntry = GetEntry(nIndex);
@@ -297,9 +303,10 @@ void ScQueryParam::Clear()
bHasHeader = bCaseSens = bRegExp = false;
bInplace = bByRow = bDuplicate = true;
- boost::ptr_vector<ScQueryEntry>::iterator itr = maEntries.begin(), itrEnd = maEntries.end();
- for (; itr != itrEnd; ++itr)
+ for (auto & itr : m_Entries)
+ {
itr->Clear();
+ }
ClearDestParams();
}
@@ -330,7 +337,11 @@ ScQueryParam& ScQueryParam::operator=( const ScQueryParam& r )
bByRow = r.bByRow;
bDestPers = r.bDestPers;
- maEntries = r.maEntries.clone();
+ m_Entries.clear();
+ for (auto const& it : r.m_Entries)
+ {
+ m_Entries.push_back(o3tl::make_unique<ScQueryEntry>(*it));
+ }
return *this;
}
@@ -345,8 +356,8 @@ bool ScQueryParam::operator==( const ScQueryParam& rOther ) const
SCSIZE nEntryCount = GetEntryCount();
SCSIZE nOtherEntryCount = rOther.GetEntryCount();
- while ( nUsed<nEntryCount && maEntries[nUsed].bDoQuery ) ++nUsed;
- while ( nOtherUsed<nOtherEntryCount && rOther.maEntries[nOtherUsed].bDoQuery )
+ while (nUsed<nEntryCount && m_Entries[nUsed]->bDoQuery) ++nUsed;
+ while (nOtherUsed<nOtherEntryCount && rOther.m_Entries[nOtherUsed]->bDoQuery)
++nOtherUsed;
if ( (nUsed == nOtherUsed)
@@ -368,7 +379,7 @@ bool ScQueryParam::operator==( const ScQueryParam& rOther ) const
{
bEqual = true;
for ( SCSIZE i=0; i<nUsed && bEqual; i++ )
- bEqual = maEntries[i] == rOther.maEntries[i];
+ bEqual = *m_Entries[i] == *rOther.m_Entries[i];
}
return bEqual;
}
@@ -386,9 +397,9 @@ void ScQueryParam::MoveToDest()
nCol2 = sal::static_int_cast<SCCOL>( nCol2 + nDifX );
nRow2 = sal::static_int_cast<SCROW>( nRow2 + nDifY );
nTab = sal::static_int_cast<SCTAB>( nTab + nDifZ );
- size_t n = maEntries.size();
+ size_t n = m_Entries.size();
for (size_t i=0; i<n; i++)
- maEntries[i].nField += nDifX;
+ m_Entries[i]->nField += nDifX;
bInplace = true;
}