[Libreoffice-commits] core.git: 2 commits - sc/inc sc/source sc/workben
Michael Stahl
mstahl at redhat.com
Fri Nov 13 11:33:12 PST 2015
sc/inc/pch/precompiled_sc.hxx | 1
sc/inc/pch/precompiled_scfilt.hxx | 1
sc/inc/queryparam.hxx | 7 +-
sc/source/core/data/dpsave.cxx | 6 +-
sc/source/core/data/sortparam.cxx | 2
sc/source/core/data/table3.cxx | 4 -
sc/source/core/tool/queryparam.cxx | 95 ++++++++++++++++++++-----------------
sc/workben/result.cxx | 20 +++----
sc/workben/result.hxx | 7 +-
9 files changed, 76 insertions(+), 67 deletions(-)
New commits:
commit f3e148bda1b46dc6626f27198de757e82b73f6a7
Author: Michael Stahl <mstahl at redhat.com>
Date: Fri Nov 13 18:41:45 2015 +0100
sc: replace that boost::ptr_vector<Reference<T>*> abomination
This looks like dead code anyway? Evidently it didnt' compile like that.
Change-Id: Id6500c18d66c6932b24c15b653d992c449e260c4
diff --git a/sc/workben/result.cxx b/sc/workben/result.cxx
index 122c2c8..0548630 100644
--- a/sc/workben/result.cxx
+++ b/sc/workben/result.cxx
@@ -23,7 +23,6 @@
using namespace com::sun::star;
-SV_IMPL_PTRARR( XResultListenerArr_Impl, css::uno::Reference< css::sheet::XResultListener >* );
ScAddInResult::ScAddInResult(const String& rStr) :
aArg( rStr ),
@@ -46,8 +45,8 @@ void ScAddInResult::NewValue()
sheet::ResultEvent aEvent( (cppu::OWeakObject*)this, aAny );
- for ( sal_uInt16 n=0; n<aListeners.Count(); n++ )
- (*aListeners[n])->modified( aEvent );
+ for (size_t n = 0; n < m_Listeners.size(); ++n)
+ m_Listeners[n]->modified( aEvent );
}
IMPL_LINK_TYPED( ScAddInResult, TimeoutHdl, Timer*, pT, void )
@@ -64,10 +63,9 @@ ScAddInResult::~ScAddInResult()
void SAL_CALL ScAddInResult::addResultListener( const css::uno::Reference< css::sheet::XResultListener >& aListener ) throw(css::uno::RuntimeException)
{
- uno::Reference<sheet::XResultListener> *pObj = new uno::Reference<sheet::XResultListener>( aListener );
- aListeners.Insert( pObj, aListeners.Count() );
+ m_Listeners.push_back(uno::Reference<sheet::XResultListener>(aListener));
- if ( aListeners.Count() == 1 )
+ if (m_Listeners.size() == 1)
{
acquire(); // one Ref for all listeners
@@ -79,15 +77,13 @@ void SAL_CALL ScAddInResult::removeResultListener( const css::uno::Reference< cs
{
acquire();
- sal_uInt16 nCount = aListeners.Count();
- for ( sal_uInt16 n=nCount; n--; )
+ for (size_t n = m_Listeners.size(); --n; )
{
- uno::Reference<sheet::XResultListener> *pObj = aListeners[n];
- if ( *pObj == aListener )
+ if (m_Listeners[n] == aListener)
{
- aListeners.DeleteAndDestroy( n );
+ m_Listeners.erase(m_Listeners.begin() + n);
- if ( aListeners.Count() == 0 )
+ if (m_Listeners.empty())
{
nTickCount = 0; //! Test
diff --git a/sc/workben/result.hxx b/sc/workben/result.hxx
index e0f796a..140a6d1 100644
--- a/sc/workben/result.hxx
+++ b/sc/workben/result.hxx
@@ -22,20 +22,21 @@
#include <vcl/timer.hxx>
#include <rtl/ustring.hxx>
-#include <boost/ptr_container/ptr_vector.hpp>
#include <com/sun/star/sheet/XVolatileResult.hpp>
#include <cppuhelper/implbase.hxx>
-typedef boost::ptr_vector<css::uno::Reference< css::sheet::XResultListener >*> XResultListenerArr_Impl;
+#include <vector>
+
+typedef std::vector<css::uno::Reference<css::sheet::XResultListener>> XResultListenerArr_Impl;
class ScAddInResult : public cppu::WeakImplHelper< css::sheet::XVolatileResult>
{
private:
String aArg;
long nTickCount;
- XResultListenerArr_Impl aListeners;
+ XResultListenerArr_Impl m_Listeners;
Timer aTimer;
DECL_LINK( TimeoutHdl, Timer* );
commit c0f489818595e50ed7cf01dfabc26c095617b44c
Author: Michael Stahl <mstahl at redhat.com>
Date: Fri Nov 13 18:32:51 2015 +0100
sc: replace boost::ptr_vector with std::vector<std::unique_ptr>
Change-Id: I59831588fb7bc7e907fbffb24ddfe068552b6492
diff --git a/sc/inc/pch/precompiled_sc.hxx b/sc/inc/pch/precompiled_sc.hxx
index 4a02554..1adfbfa 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 468b070..4fb99bc 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 3c96260..c174863 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 935aa9c..82d810c 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 7c246cb..0f7c158 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 d01f2f2..ee76080 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 c4e416f..6a90ba2 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;
}
More information about the Libreoffice-commits
mailing list