summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2015-11-13 09:06:37 +0200
committerNoel Grandin <noel@peralex.com>2015-11-13 10:54:19 +0200
commitf3ba19b37f212a5839a91223f77d501d79e2c4b5 (patch)
tree781293199c66dc10d433f1cd4ed256857c45c778 /sc
parentc2defd97cb60439fc25970c903e66fbecad148e5 (diff)
sc: boost::ptr_vector->std::vector<std::unique_ptr>
Change-Id: I7bf6fad1ed2d0f8e9a42293e0ceec7fc3b59963f
Diffstat (limited to 'sc')
-rw-r--r--sc/inc/dpcache.hxx2
-rw-r--r--sc/source/core/data/dpcache.cxx61
2 files changed, 32 insertions, 31 deletions
diff --git a/sc/inc/dpcache.hxx b/sc/inc/dpcache.hxx
index 155c969363b0..7226be9fd6cd 100644
--- a/sc/inc/dpcache.hxx
+++ b/sc/inc/dpcache.hxx
@@ -110,7 +110,7 @@ private:
*/
mutable ScDPObjectSet maRefObjects;
- typedef boost::ptr_vector<Field> FieldsType;
+ typedef std::vector< std::unique_ptr<Field> > FieldsType;
typedef boost::ptr_vector<GroupItems> GroupFieldsType;
FieldsType maFields;
diff --git a/sc/source/core/data/dpcache.cxx b/sc/source/core/data/dpcache.cxx
index bd04f8e8bf2b..cf4a1a44a708 100644
--- a/sc/source/core/data/dpcache.cxx
+++ b/sc/source/core/data/dpcache.cxx
@@ -34,6 +34,7 @@
#include <unotools/textsearch.hxx>
#include <unotools/localedatawrapper.hxx>
#include <svl/zforlist.hxx>
+#include <o3tl/make_unique.hxx>
#if DEBUG_PIVOT_TABLE
#include <com/sun/star/sheet/DataPilotFieldGroupBy.hpp>
@@ -333,7 +334,7 @@ bool ScDPCache::InitFromDoc(ScDocument* pDoc, const ScRange& rRange)
maFields.reserve(mnColumnCount);
for (size_t i = 0; i < static_cast<size_t>(mnColumnCount); ++i)
- maFields.push_back(new Field);
+ maFields.push_back(o3tl::make_unique<Field>());
maLabelNames.reserve(mnColumnCount+1);
@@ -341,7 +342,7 @@ bool ScDPCache::InitFromDoc(ScDocument* pDoc, const ScRange& rRange)
for (sal_uInt16 nCol = nStartCol; nCol <= nEndCol; ++nCol)
{
AddLabel(createLabelString(pDoc, nCol, nStartRow, nDocTab));
- Field& rField = maFields[nCol-nStartCol];
+ Field& rField = *maFields[nCol-nStartCol].get();
std::vector<Bucket> aBuckets;
aBuckets.reserve(nEndRow-nStartRow); // skip the topmost label cell.
@@ -391,7 +392,7 @@ bool ScDPCache::InitFromDataBase(DBConnector& rDB)
maFields.clear();
maFields.reserve(mnColumnCount);
for (size_t i = 0; i < static_cast<size_t>(mnColumnCount); ++i)
- maFields.push_back(new Field);
+ maFields.push_back(o3tl::make_unique<Field>());
// Get column titles and types.
maLabelNames.clear();
@@ -411,7 +412,7 @@ bool ScDPCache::InitFromDataBase(DBConnector& rDB)
continue;
aBuckets.clear();
- Field& rField = maFields[nCol];
+ Field& rField = *maFields[nCol].get();
SCROW nRow = 0;
do
{
@@ -436,7 +437,7 @@ bool ScDPCache::InitFromDataBase(DBConnector& rDB)
rDB.finish();
if (!maFields.empty())
- mnRowCount = maFields[0].maData.size();
+ mnRowCount = maFields[0]->maData.size();
PostInit();
return true;
@@ -670,7 +671,7 @@ const ScDPCache::GroupItems* ScDPCache::GetGroupItems(long nDim) const
long nSourceCount = static_cast<long>(maFields.size());
if (nDim < nSourceCount)
- return maFields[nDim].mpGroup.get();
+ return maFields[nDim]->mpGroup.get();
nDim -= nSourceCount;
if (nDim < static_cast<long>(maGroupFields.size()))
@@ -717,7 +718,7 @@ void ScDPCache::PostInit()
typedef mdds::flat_segment_tree<SCROW, bool>::const_reverse_iterator itr_type;
itr_type it = maEmptyRows.rbegin();
OSL_ENSURE(it != maEmptyRows.rend(), "corrupt flat_segment_tree instance!");
- mnDataSize = maFields[0].maData.size();
+ mnDataSize = maFields[0]->maData.size();
++it; // Skip the first position.
OSL_ENSURE(it != maEmptyRows.rend(), "buggy version of flat_segment_tree is used.");
if (it->second)
@@ -770,7 +771,7 @@ SCROW ScDPCache::GetItemDataId(sal_uInt16 nDim, SCROW nRow, bool bRepeatIfEmpty)
{
OSL_ENSURE(nDim < mnColumnCount, "ScDPTableDataCache::GetItemDataId ");
- const Field& rField = maFields[nDim];
+ const Field& rField = *maFields[nDim].get();
if (static_cast<size_t>(nRow) >= rField.maData.size())
{
// nRow is in the trailing empty rows area.
@@ -802,7 +803,7 @@ const ScDPItemData* ScDPCache::GetItemDataById(long nDim, SCROW nId) const
if (nDimPos < nSourceCount)
{
// source field.
- const Field& rField = maFields[nDimPos];
+ const Field& rField = *maFields[nDimPos].get();
if (nItemId < rField.maItems.size())
return &rField.maItems[nItemId];
@@ -855,13 +856,13 @@ const ScDPCache::IndexArrayType* ScDPCache::GetFieldIndexArray( size_t nDim ) co
if (nDim >= maFields.size())
return nullptr;
- return &maFields[nDim].maData;
+ return &maFields[nDim]->maData;
}
const ScDPCache::ScDPItemDataVec& ScDPCache::GetDimMemberValues(SCCOL nDim) const
{
OSL_ENSURE( nDim>=0 && nDim < mnColumnCount ," nDim < mnColumnCount ");
- return maFields.at(nDim).maItems;
+ return maFields.at(nDim)->maItems;
}
sal_uLong ScDPCache::GetNumberFormat( long nDim ) const
@@ -871,7 +872,7 @@ sal_uLong ScDPCache::GetNumberFormat( long nDim ) const
// TODO: Find a way to determine the dominant number format in presence of
// multiple number formats in the same field.
- return maFields[nDim].mnNumFormat;
+ return maFields[nDim]->mnNumFormat;
}
bool ScDPCache::IsDateDimension( long nDim ) const
@@ -883,14 +884,14 @@ bool ScDPCache::IsDateDimension( long nDim ) const
if (!pFormatter)
return false;
- short eType = pFormatter->GetType(maFields[nDim].mnNumFormat);
+ short eType = pFormatter->GetType(maFields[nDim]->mnNumFormat);
return (eType == css::util::NumberFormat::DATE) || (eType == css::util::NumberFormat::DATETIME);
}
long ScDPCache::GetDimMemberCount(long nDim) const
{
OSL_ENSURE( nDim>=0 && nDim < mnColumnCount ," ScDPTableDataCache::GetDimMemberCount : out of bound ");
- return maFields[nDim].maItems.size();
+ return maFields[nDim]->maItems.size();
}
SCCOL ScDPCache::GetDimensionIndex(const OUString& sName) const
@@ -943,18 +944,18 @@ SCROW ScDPCache::GetIdByItemData(long nDim, const ScDPItemData& rItem) const
if (nDim < mnColumnCount)
{
// source field.
- const ScDPItemDataVec& rItems = maFields[nDim].maItems;
+ const ScDPItemDataVec& rItems = maFields[nDim]->maItems;
for (size_t i = 0, n = rItems.size(); i < n; ++i)
{
if (rItems[i] == rItem)
return i;
}
- if (!maFields[nDim].mpGroup)
+ if (!maFields[nDim]->mpGroup)
return -1;
// grouped source field.
- const ScDPItemDataVec& rGI = maFields[nDim].mpGroup->maItems;
+ const ScDPItemDataVec& rGI = maFields[nDim]->mpGroup->maItems;
for (size_t i = 0, n = rGI.size(); i < n; ++i)
{
if (rGI[i] == rItem)
@@ -1040,7 +1041,7 @@ void ScDPCache::ResetGroupItems(long nDim, const ScDPNumGroupInfo& rNumInfo, sal
long nSourceCount = static_cast<long>(maFields.size());
if (nDim < nSourceCount)
{
- maFields.at(nDim).mpGroup.reset(new GroupItems(rNumInfo, nGroupType));
+ maFields.at(nDim)->mpGroup.reset(new GroupItems(rNumInfo, nGroupType));
return;
}
@@ -1062,9 +1063,9 @@ SCROW ScDPCache::SetGroupItem(long nDim, const ScDPItemData& rData)
long nSourceCount = static_cast<long>(maFields.size());
if (nDim < nSourceCount)
{
- GroupItems& rGI = *maFields.at(nDim).mpGroup;
+ GroupItems& rGI = *maFields.at(nDim)->mpGroup;
rGI.maItems.push_back(rData);
- SCROW nId = maFields[nDim].maItems.size() + rGI.maItems.size() - 1;
+ SCROW nId = maFields[nDim]->maItems.size() + rGI.maItems.size() - 1;
return nId;
}
@@ -1087,11 +1088,11 @@ void ScDPCache::GetGroupDimMemberIds(long nDim, std::vector<SCROW>& rIds) const
long nSourceCount = static_cast<long>(maFields.size());
if (nDim < nSourceCount)
{
- if (!maFields.at(nDim).mpGroup)
+ if (!maFields.at(nDim)->mpGroup)
return;
- size_t nOffset = maFields[nDim].maItems.size();
- const ScDPItemDataVec& rGI = maFields[nDim].mpGroup->maItems;
+ size_t nOffset = maFields[nDim]->maItems.size();
+ const ScDPItemDataVec& rGI = maFields[nDim]->mpGroup->maItems;
for (size_t i = 0, n = rGI.size(); i < n; ++i)
rIds.push_back(static_cast<SCROW>(i + nOffset));
@@ -1109,11 +1110,11 @@ void ScDPCache::GetGroupDimMemberIds(long nDim, std::vector<SCROW>& rIds) const
namespace {
-struct ClearGroupItems : std::unary_function<ScDPCache::Field, void>
+struct ClearGroupItems : std::unary_function<std::unique_ptr<ScDPCache::Field>, void>
{
- void operator() (ScDPCache::Field& r) const
+ void operator() (std::unique_ptr<ScDPCache::Field>& r) const
{
- r.mpGroup.reset();
+ r->mpGroup.reset();
}
};
@@ -1133,10 +1134,10 @@ const ScDPNumGroupInfo* ScDPCache::GetNumGroupInfo(long nDim) const
long nSourceCount = static_cast<long>(maFields.size());
if (nDim < nSourceCount)
{
- if (!maFields.at(nDim).mpGroup)
+ if (!maFields.at(nDim)->mpGroup)
return nullptr;
- return &maFields[nDim].mpGroup->maInfo;
+ return &maFields[nDim]->mpGroup->maInfo;
}
nDim -= nSourceCount;
@@ -1154,10 +1155,10 @@ sal_Int32 ScDPCache::GetGroupType(long nDim) const
long nSourceCount = static_cast<long>(maFields.size());
if (nDim < nSourceCount)
{
- if (!maFields.at(nDim).mpGroup)
+ if (!maFields.at(nDim)->mpGroup)
return 0;
- return maFields[nDim].mpGroup->mnGroupType;
+ return maFields[nDim]->mpGroup->mnGroupType;
}
nDim -= nSourceCount;