[Libreoffice-commits] core.git: 4 commits - sc/inc sc/qa sc/source
Michael Stahl
mstahl at redhat.com
Mon Nov 9 03:05:46 PST 2015
sc/inc/chartarr.hxx | 8 ++-
sc/inc/colorscale.hxx | 11 +++-
sc/inc/formulagroup.hxx | 10 ++--
sc/qa/unit/ucalc.cxx | 7 +--
sc/source/core/data/colorscale.cxx | 57 +++++++++++++++----------
sc/source/core/data/column2.cxx | 33 ++++++++------
sc/source/core/data/fillinfo.cxx | 2
sc/source/core/tool/chartarr.cxx | 34 +++++++++-----
sc/source/core/tool/formulagroup.cxx | 13 +++--
sc/source/filter/excel/xecontent.cxx | 3 -
sc/source/filter/excel/xeextlst.cxx | 2
sc/source/filter/oox/condformatbuffer.cxx | 2
sc/source/filter/xml/xmlcondformat.cxx | 2
sc/source/filter/xml/xmlexprt.cxx | 3 -
sc/source/ui/condformat/condformatdlgentry.cxx | 7 +--
sc/source/ui/unoobj/condformatuno.cxx | 8 +--
16 files changed, 119 insertions(+), 83 deletions(-)
New commits:
commit 8e36027e2768b4d9d7c8beff864a557c450184ca
Author: Michael Stahl <mstahl at redhat.com>
Date: Sat Nov 7 00:20:26 2015 +0100
sc: replace boost::ptr_vector with std::vector<std::unique_ptr>
Change-Id: Id80f6d6be9f5cb15448ea00299b8e371ccd812ee
diff --git a/sc/inc/colorscale.hxx b/sc/inc/colorscale.hxx
index 43a1998..a8d9f1f 100644
--- a/sc/inc/colorscale.hxx
+++ b/sc/inc/colorscale.hxx
@@ -10,7 +10,6 @@
#ifndef INCLUDED_SC_INC_COLORSCALE_HXX
#define INCLUDED_SC_INC_COLORSCALE_HXX
-#include <boost/ptr_container/ptr_vector.hpp>
#include <formula/grammar.hxx>
#include <tools/color.hxx>
#include "rangelst.hxx"
@@ -334,7 +333,8 @@ struct ScIconSetFormatData
* Specifies whether the icons should be shown in reverse order
*/
bool mbReverse;
- boost::ptr_vector<ScColorScaleEntry> maEntries;
+ typedef std::vector<std::unique_ptr<ScColorScaleEntry>> Entries_t;
+ Entries_t m_Entries;
bool mbCustom;
// the std::pair points to exactly one image
// std..pair::second == -1 means no image
@@ -346,6 +346,9 @@ struct ScIconSetFormatData
mbReverse(false),
mbCustom(false)
{}
+
+ ScIconSetFormatData(ScIconSetFormatData const&);
+ ScIconSetFormatData& operator=(ScIconSetFormatData const&) = delete; //TODO?
};
class SC_DLLPUBLIC ScIconSetFormat : public ScColorFormat
@@ -374,8 +377,8 @@ public:
static ScIconSetMap* getIconSetMap();
static BitmapEx& getBitmap( ScIconSetType eType, sal_Int32 nIndex );
- typedef boost::ptr_vector<ScColorScaleEntry>::iterator iterator;
- typedef boost::ptr_vector<ScColorScaleEntry>::const_iterator const_iterator;
+ typedef ScIconSetFormatData::Entries_t::iterator iterator;
+ typedef ScIconSetFormatData::Entries_t::const_iterator const_iterator;
iterator begin();
const_iterator begin() const;
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 169f03d..3562228 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -70,6 +70,7 @@
#include <formula/IFunctionDescription.hxx>
+#include <o3tl/make_unique.hxx>
#include <basegfx/polygon/b2dpolygon.hxx>
#include <editeng/boxitem.hxx>
#include <editeng/brushitem.hxx>
@@ -5946,9 +5947,9 @@ void Test::testIconSet()
ScIconSetFormat* pEntry = new ScIconSetFormat(m_pDoc);
ScIconSetFormatData* pData = new ScIconSetFormatData;
- pData->maEntries.push_back(new ScColorScaleEntry(0, COL_BLUE));
- pData->maEntries.push_back(new ScColorScaleEntry(1, COL_GREEN));
- pData->maEntries.push_back(new ScColorScaleEntry(2, COL_RED));
+ pData->m_Entries.push_back(o3tl::make_unique<ScColorScaleEntry>(0, COL_BLUE));
+ pData->m_Entries.push_back(o3tl::make_unique<ScColorScaleEntry>(1, COL_GREEN));
+ pData->m_Entries.push_back(o3tl::make_unique<ScColorScaleEntry>(2, COL_RED));
pEntry->SetIconSetData(pData);
m_pDoc->AddCondFormatData(pFormat->GetRange(), 0, 1);
diff --git a/sc/source/core/data/colorscale.cxx b/sc/source/core/data/colorscale.cxx
index c346f73..74e4e33 100644
--- a/sc/source/core/data/colorscale.cxx
+++ b/sc/source/core/data/colorscale.cxx
@@ -17,6 +17,7 @@
#include "refupdatecontext.hxx"
#include <formula/token.hxx>
+#include <o3tl/make_unique.hxx>
#include <algorithm>
@@ -925,6 +926,20 @@ void ScDataBarFormat::EnsureSize()
}
}
+ScIconSetFormatData::ScIconSetFormatData(ScIconSetFormatData const& rOther)
+ : eIconSetType(rOther.eIconSetType)
+ , mbShowValue(rOther.mbShowValue)
+ , mbReverse(rOther.mbReverse)
+ , mbCustom(rOther.mbCustom)
+ , maCustomVector(rOther.maCustomVector)
+{
+ m_Entries.reserve(rOther.m_Entries.size());
+ for (auto const& it : rOther.m_Entries)
+ {
+ m_Entries.push_back(o3tl::make_unique<ScColorScaleEntry>(*it));
+ }
+}
+
ScIconSetFormat::ScIconSetFormat(ScDocument* pDoc):
ScColorFormat(pDoc),
mpFormatData(new ScIconSetFormatData)
@@ -973,7 +988,7 @@ ScIconSetInfo* ScIconSetFormat::GetIconSetInfo(const ScAddress& rAddr) const
// now we have for sure a value
double nVal = mpDoc->GetValue(rAddr);
- if (mpFormatData->maEntries.size() < 2)
+ if (mpFormatData->m_Entries.size() < 2)
return NULL;
double nMin = GetMinValue();
@@ -1002,7 +1017,7 @@ ScIconSetInfo* ScIconSetFormat::GetIconSetInfo(const ScAddress& rAddr) const
if(mpFormatData->mbReverse)
{
- sal_Int32 nMaxIndex = mpFormatData->maEntries.size() - 1;
+ sal_Int32 nMaxIndex = mpFormatData->m_Entries.size() - 1;
nIndex = nMaxIndex - nIndex;
}
@@ -1038,7 +1053,7 @@ void ScIconSetFormat::UpdateReference( sc::RefUpdateContext& rCxt )
{
for(iterator itr = begin(); itr != end(); ++itr)
{
- itr->UpdateReference(rCxt);
+ (*itr)->UpdateReference(rCxt);
}
}
@@ -1046,7 +1061,7 @@ void ScIconSetFormat::UpdateInsertTab( sc::RefUpdateInsertTabContext& rCxt )
{
for(iterator itr = begin(); itr != end(); ++itr)
{
- itr->UpdateInsertTab(rCxt);
+ (*itr)->UpdateInsertTab(rCxt);
}
}
@@ -1054,7 +1069,7 @@ void ScIconSetFormat::UpdateDeleteTab( sc::RefUpdateDeleteTabContext& rCxt )
{
for(iterator itr = begin(); itr != end(); ++itr)
{
- itr->UpdateDeleteTab(rCxt);
+ (*itr)->UpdateDeleteTab(rCxt);
}
}
@@ -1062,7 +1077,7 @@ void ScIconSetFormat::UpdateMoveTab( sc::RefUpdateMoveTabContext& rCxt )
{
for(iterator itr = begin(); itr != end(); ++itr)
{
- itr->UpdateMoveTab(rCxt);
+ (*itr)->UpdateMoveTab(rCxt);
}
}
@@ -1070,7 +1085,7 @@ bool ScIconSetFormat::NeedsRepaint() const
{
for(const_iterator itr = begin(); itr != end(); ++itr)
{
- if(itr->NeedsRepaint())
+ if ((*itr)->NeedsRepaint())
return true;
}
@@ -1079,30 +1094,30 @@ bool ScIconSetFormat::NeedsRepaint() const
ScIconSetFormat::iterator ScIconSetFormat::begin()
{
- return mpFormatData->maEntries.begin();
+ return mpFormatData->m_Entries.begin();
}
ScIconSetFormat::const_iterator ScIconSetFormat::begin() const
{
- return mpFormatData->maEntries.begin();
+ return mpFormatData->m_Entries.begin();
}
ScIconSetFormat::iterator ScIconSetFormat::end()
{
- return mpFormatData->maEntries.end();
+ return mpFormatData->m_Entries.end();
}
ScIconSetFormat::const_iterator ScIconSetFormat::end() const
{
- return mpFormatData->maEntries.end();
+ return mpFormatData->m_Entries.end();
}
double ScIconSetFormat::GetMinValue() const
{
const_iterator itr = begin();
- if(itr->GetType() == COLORSCALE_VALUE || itr->GetType() == COLORSCALE_FORMULA)
- return itr->GetValue();
+ if ((*itr)->GetType() == COLORSCALE_VALUE || (*itr)->GetType() == COLORSCALE_FORMULA)
+ return (*itr)->GetValue();
else
{
return getMinValue();
@@ -1111,10 +1126,10 @@ double ScIconSetFormat::GetMinValue() const
double ScIconSetFormat::GetMaxValue() const
{
- boost::ptr_vector<ScColorScaleEntry>::const_reverse_iterator itr = mpFormatData->maEntries.rbegin();
+ auto const itr = mpFormatData->m_Entries.rbegin();
- if(itr->GetType() == COLORSCALE_VALUE || itr->GetType() == COLORSCALE_FORMULA)
- return itr->GetValue();
+ if ((*itr)->GetType() == COLORSCALE_VALUE || (*itr)->GetType() == COLORSCALE_FORMULA)
+ return (*itr)->GetValue();
else
{
return getMaxValue();
@@ -1123,10 +1138,10 @@ double ScIconSetFormat::GetMaxValue() const
double ScIconSetFormat::CalcValue(double nMin, double nMax, ScIconSetFormat::const_iterator& itr) const
{
- switch(itr->GetType())
+ switch ((*itr)->GetType())
{
case COLORSCALE_PERCENT:
- return nMin + (nMax-nMin)*(itr->GetValue()/100);
+ return nMin + (nMax-nMin)*((*itr)->GetValue()/100);
case COLORSCALE_MIN:
return nMin;
case COLORSCALE_MAX:
@@ -1138,7 +1153,7 @@ double ScIconSetFormat::CalcValue(double nMin, double nMax, ScIconSetFormat::con
return rValues[0];
else
{
- double fPercentile = itr->GetValue()/100.0;
+ double fPercentile = (*itr)->GetValue()/100.0;
return GetPercentile(rValues, fPercentile);
}
}
@@ -1147,7 +1162,7 @@ double ScIconSetFormat::CalcValue(double nMin, double nMax, ScIconSetFormat::con
break;
}
- return itr->GetValue();
+ return (*itr)->GetValue();
}
namespace {
@@ -1187,7 +1202,7 @@ ScIconSetMap* ScIconSetFormat::getIconSetMap()
size_t ScIconSetFormat::size() const
{
- return mpFormatData->maEntries.size();
+ return mpFormatData->m_Entries.size();
}
diff --git a/sc/source/core/data/fillinfo.cxx b/sc/source/core/data/fillinfo.cxx
index e0e2623..cd1d412 100644
--- a/sc/source/core/data/fillinfo.cxx
+++ b/sc/source/core/data/fillinfo.cxx
@@ -42,6 +42,8 @@
#include "cellvalue.hxx"
#include "mtvcellfunc.hxx"
+#include <boost/ptr_container/ptr_vector.hpp>
+
const sal_uInt16 ROWINFO_MAX = 1024;
enum FillInfoLinePos
diff --git a/sc/source/filter/excel/xecontent.cxx b/sc/source/filter/excel/xecontent.cxx
index f98c3ca..d94bf88 100644
--- a/sc/source/filter/excel/xecontent.cxx
+++ b/sc/source/filter/excel/xecontent.cxx
@@ -1387,8 +1387,7 @@ XclExpIconSet::XclExpIconSet( const XclExpRoot& rRoot, const ScIconSetFormat& rF
{
const ScRange* pRange = rFormat.GetRange().front();
ScAddress aAddr = pRange->aStart;
- for(ScIconSetFormat::const_iterator itr = rFormat.begin();
- itr != rFormat.end(); ++itr)
+ for (auto const& itr : rFormat)
{
// exact position is not important, we allow only absolute refs
diff --git a/sc/source/filter/excel/xeextlst.cxx b/sc/source/filter/excel/xeextlst.cxx
index 79bf523..ec6e8df 100644
--- a/sc/source/filter/excel/xeextlst.cxx
+++ b/sc/source/filter/excel/xeextlst.cxx
@@ -217,7 +217,7 @@ XclExpExtIconSet::XclExpExtIconSet(const XclExpRoot& rRoot, const ScIconSetForma
XclExpRoot(rRoot)
{
const ScIconSetFormatData& rData = *rFormat.GetIconSetData();
- for (auto itr = rData.maEntries.begin(); itr != rData.maEntries.end(); ++itr)
+ for (auto const& itr : rData.m_Entries)
{
maCfvos.AppendNewRecord(new XclExpExtCfvo(*this, *itr, rPos, false));
}
diff --git a/sc/source/filter/oox/condformatbuffer.cxx b/sc/source/filter/oox/condformatbuffer.cxx
index 79ba6ea..c8cdc4a 100644
--- a/sc/source/filter/oox/condformatbuffer.cxx
+++ b/sc/source/filter/oox/condformatbuffer.cxx
@@ -406,7 +406,7 @@ void IconSetRule::SetData( ScIconSetFormat* pFormat, ScDocument* pDoc, const ScA
for(size_t i = 0; i < maEntries.size(); ++i)
{
ScColorScaleEntry* pModelEntry = ConvertToModel( maEntries[i], pDoc, rPos );
- mxFormatData->maEntries.push_back(pModelEntry);
+ mxFormatData->m_Entries.push_back(std::unique_ptr<ScColorScaleEntry>(pModelEntry));
}
mxFormatData->eIconSetType = getType(maIconSetType);
diff --git a/sc/source/filter/xml/xmlcondformat.cxx b/sc/source/filter/xml/xmlcondformat.cxx
index 28744a5..2d6884b 100644
--- a/sc/source/filter/xml/xmlcondformat.cxx
+++ b/sc/source/filter/xml/xmlcondformat.cxx
@@ -390,7 +390,7 @@ SvXMLImportContext* ScXMLIconSetFormatContext::CreateChildContext( sal_uInt16 nP
{
ScColorScaleEntry* pEntry(0);
pContext = new ScXMLFormattingEntryContext( GetScImport(), nPrefix, rLocalName, xAttrList, pEntry );
- mpFormatData->maEntries.push_back(pEntry);
+ mpFormatData->m_Entries.push_back(std::unique_ptr<ScColorScaleEntry>(pEntry));
}
break;
default:
diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx
index d71b4b3..e06e29f 100644
--- a/sc/source/filter/xml/xmlexprt.cxx
+++ b/sc/source/filter/xml/xmlexprt.cxx
@@ -4400,8 +4400,7 @@ void ScXMLExport::ExportConditionalFormat(SCTAB nTab)
SvXMLElementExport aElementColorScale(*this, XML_NAMESPACE_CALC_EXT, XML_ICON_SET, true, true);
if(!mrIconSet.GetIconSetData()->mbShowValue)
AddAttribute(XML_NAMESPACE_CALC_EXT, XML_SHOW_VALUE, XML_FALSE);
- for(ScIconSetFormat::const_iterator it = mrIconSet.begin();
- it != mrIconSet.end(); ++it)
+ for (auto const& it : mrIconSet)
{
if(it->GetType() == COLORSCALE_FORMULA)
{
diff --git a/sc/source/ui/condformat/condformatdlgentry.cxx b/sc/source/ui/condformat/condformatdlgentry.cxx
index 4c995bf..b6318a2 100644
--- a/sc/source/ui/condformat/condformatdlgentry.cxx
+++ b/sc/source/ui/condformat/condformatdlgentry.cxx
@@ -1523,10 +1523,11 @@ ScIconSetFrmtEntry::ScIconSetFrmtEntry( vcl::Window* pParent, ScDocument* pDoc,
sal_Int32 nType = static_cast<sal_Int32>(eType);
maLbIconSetType->SelectEntryPos(nType);
- for(size_t i = 0, n = pIconSetFormatData->maEntries.size();
+ for (size_t i = 0, n = pIconSetFormatData->m_Entries.size();
i < n; ++i)
{
- maEntries.push_back( VclPtr<ScIconSetFrmtDataEntry>::Create( this, eType, pDoc, i, &pIconSetFormatData->maEntries[i] ) );
+ maEntries.push_back( VclPtr<ScIconSetFrmtDataEntry>::Create(
+ this, eType, pDoc, i, pIconSetFormatData->m_Entries[i].get()));
Point aPos = maEntries[0]->GetPosPixel();
aPos.Y() += maEntries[0]->GetSizePixel().Height() * i * 1.2;
maEntries[i]->SetPosPixel( aPos );
@@ -1625,7 +1626,7 @@ ScFormatEntry* ScIconSetFrmtEntry::GetEntry() const
for(ScIconSetFrmtDataEntriesType::const_iterator itr = maEntries.begin(),
itrEnd = maEntries.end(); itr != itrEnd; ++itr)
{
- pData->maEntries.push_back((*itr)->CreateEntry(mpDoc, maPos));
+ pData->m_Entries.push_back(std::unique_ptr<ScColorScaleEntry>((*itr)->CreateEntry(mpDoc, maPos)));
}
pFormat->SetIconSetData(pData);
diff --git a/sc/source/ui/unoobj/condformatuno.cxx b/sc/source/ui/unoobj/condformatuno.cxx
index 2626c74..e561ddf 100644
--- a/sc/source/ui/unoobj/condformatuno.cxx
+++ b/sc/source/ui/unoobj/condformatuno.cxx
@@ -1596,7 +1596,7 @@ void setIconSetEntry(ScIconSetFormat* pFormat, uno::Reference<sheet::XIconSetEnt
if (!bFound)
throw lang::IllegalArgumentException();
- pData->maEntries[nPos].SetType(eType);
+ pData->m_Entries[nPos]->SetType(eType);
switch (eType)
{
case COLORSCALE_FORMULA:
@@ -1605,7 +1605,7 @@ void setIconSetEntry(ScIconSetFormat* pFormat, uno::Reference<sheet::XIconSetEnt
default:
{
double nVal = xEntry->getFormula().toDouble();
- pData->maEntries[nPos].SetValue(nVal);
+ pData->m_Entries[nPos]->SetValue(nVal);
}
break;
}
@@ -1786,10 +1786,10 @@ ScIconSetEntryObj::~ScIconSetEntryObj()
ScColorScaleEntry* ScIconSetEntryObj::getCoreObject()
{
ScIconSetFormat* pFormat = mxParent->getCoreObject();
- if (pFormat->GetIconSetData()->maEntries.size() <= mnPos)
+ if (pFormat->GetIconSetData()->m_Entries.size() <= mnPos)
throw lang::IllegalArgumentException();
- return &pFormat->GetIconSetData()->maEntries[mnPos];
+ return pFormat->GetIconSetData()->m_Entries[mnPos].get();
}
sal_Int32 ScIconSetEntryObj::getType()
commit a3e410a043f42e70836ca564a5cccdd12664b457
Author: Michael Stahl <mstahl at redhat.com>
Date: Fri Nov 6 23:50:59 2015 +0100
sc: replace boost::ptr_vector with std::vector<std::unique_ptr>
Change-Id: Ic1a44ef591e0d23bbd6574b232370b2888335ebf
diff --git a/sc/inc/chartarr.hxx b/sc/inc/chartarr.hxx
index 0a60e40..0cd54ed 100644
--- a/sc/inc/chartarr.hxx
+++ b/sc/inc/chartarr.hxx
@@ -23,7 +23,8 @@
#include "rangelst.hxx"
#include "chartpos.hxx"
-#include <boost/ptr_container/ptr_vector.hpp>
+#include <memory>
+#include <vector>
class ScDocument;
@@ -90,8 +91,9 @@ public:
class ScChartCollection
{
- typedef ::boost::ptr_vector<ScChartArray> DataType;
- DataType maData;
+ typedef ::std::vector<std::unique_ptr<ScChartArray>> DataType;
+ DataType m_Data;
+
public:
ScChartCollection();
ScChartCollection(const ScChartCollection& rColl);
diff --git a/sc/source/core/tool/chartarr.cxx b/sc/source/core/tool/chartarr.cxx
index 0a9076c..edfa4ed 100644
--- a/sc/source/core/tool/chartarr.cxx
+++ b/sc/source/core/tool/chartarr.cxx
@@ -29,6 +29,9 @@
#include "formulacell.hxx"
#include "docoptio.hxx"
+#include <comphelper/stl_types.hxx>
+#include <o3tl/make_unique.hxx>
+
#include <vector>
using ::std::vector;
@@ -419,46 +422,51 @@ ScMemChart* ScChartArray::CreateMemChartMulti()
}
ScChartCollection::ScChartCollection() {}
-ScChartCollection::ScChartCollection(const ScChartCollection& r) :
- maData(r.maData) {}
+ScChartCollection::ScChartCollection(const ScChartCollection& r)
+{
+ for (auto const& it : r.m_Data)
+ {
+ m_Data.push_back(o3tl::make_unique<ScChartArray>(*it));
+ }
+}
void ScChartCollection::push_back(ScChartArray* p)
{
- maData.push_back(p);
+ m_Data.push_back(std::unique_ptr<ScChartArray>(p));
}
void ScChartCollection::clear()
{
- maData.clear();
+ m_Data.clear();
}
size_t ScChartCollection::size() const
{
- return maData.size();
+ return m_Data.size();
}
bool ScChartCollection::empty() const
{
- return maData.empty();
+ return m_Data.empty();
}
ScChartArray* ScChartCollection::operator[](size_t nIndex)
{
- if (maData.size() <= nIndex)
- return NULL;
- return &maData[nIndex];
+ if (m_Data.size() <= nIndex)
+ return nullptr;
+ return m_Data[nIndex].get();
}
const ScChartArray* ScChartCollection::operator[](size_t nIndex) const
{
- if (maData.size() <= nIndex)
- return NULL;
- return &maData[nIndex];
+ if (m_Data.size() <= nIndex)
+ return nullptr;
+ return m_Data[nIndex].get();
}
bool ScChartCollection::operator==(const ScChartCollection& rCmp) const
{
- return maData == rCmp.maData;
+ return ::comphelper::ContainerUniquePtrEquals(m_Data, rCmp.m_Data);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 3b49489707447cca30c7bcb54e9bfc6ffc9ab2e1
Author: Michael Stahl <mstahl at redhat.com>
Date: Fri Nov 6 23:44:31 2015 +0100
sc: replace boost::ptr_vector with std::vector<std::unique_ptr>
Change-Id: I1929d105d46c373c40d1f53e7d933435118737d4
diff --git a/sc/inc/formulagroup.hxx b/sc/inc/formulagroup.hxx
index 15c2a60..2e18cce 100644
--- a/sc/inc/formulagroup.hxx
+++ b/sc/inc/formulagroup.hxx
@@ -28,7 +28,6 @@
#include <unordered_map>
#include <vector>
#include <boost/noncopyable.hpp>
-#include <boost/ptr_container/ptr_vector.hpp>
class ScDocument;
class ScTokenArray;
@@ -59,7 +58,7 @@ struct FormulaGroupContext : boost::noncopyable
typedef std::vector<double, DoubleAllocType> NumArrayType;
typedef std::vector<rtl_uString*> StrArrayType;
typedef std::vector<std::unique_ptr<NumArrayType>> NumArrayStoreType;
- typedef boost::ptr_vector<StrArrayType> StrArrayStoreType;
+ typedef std::vector<std::unique_ptr<StrArrayType>> StrArrayStoreType;
struct ColKey
{
@@ -89,7 +88,7 @@ struct FormulaGroupContext : boost::noncopyable
typedef std::unordered_map<ColKey, ColArray, ColKey::Hash> ColArraysType;
NumArrayStoreType m_NumArrays; /// manage life cycle of numeric arrays.
- StrArrayStoreType maStrArrays; /// manage life cycle of string arrays.
+ StrArrayStoreType m_StrArrays; /// manage life cycle of string arrays.
ColArraysType maColArrays; /// keep track of longest array for each column.
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index e6983d9..cb1f145 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -2504,9 +2504,9 @@ copyFirstFormulaBlock(
{
if (!pStrArray)
{
- rCxt.maStrArrays.push_back(
- new sc::FormulaGroupContext::StrArrayType(nArrayLen, NULL));
- pStrArray = &rCxt.maStrArrays.back();
+ rCxt.m_StrArrays.push_back(
+ o3tl::make_unique<sc::FormulaGroupContext::StrArrayType>(nArrayLen, nullptr));
+ pStrArray = rCxt.m_StrArrays.back().get();
}
(*pStrArray)[nPos] = aRes.maString.getDataIgnoreCase();
@@ -2602,8 +2602,9 @@ formula::VectorRefArray ScColumn::FetchVectorRefArray( SCROW nRow1, SCROW nRow2
case sc::element_type_string:
case sc::element_type_edittext:
{
- rCxt.maStrArrays.push_back(new sc::FormulaGroupContext::StrArrayType(nRow2+1, NULL));
- sc::FormulaGroupContext::StrArrayType& rArray = rCxt.maStrArrays.back();
+ rCxt.m_StrArrays.push_back(
+ o3tl::make_unique<sc::FormulaGroupContext::StrArrayType>(nRow2+1, nullptr));
+ sc::FormulaGroupContext::StrArrayType& rArray = *rCxt.m_StrArrays.back();
pColArray = rCxt.setCachedColArray(nTab, nCol, NULL, &rArray);
if (!pColArray)
// Failed to insert a new cached column array.
diff --git a/sc/source/core/tool/formulagroup.cxx b/sc/source/core/tool/formulagroup.cxx
index 835ed2a..8506fb7 100644
--- a/sc/source/core/tool/formulagroup.cxx
+++ b/sc/source/core/tool/formulagroup.cxx
@@ -112,9 +112,9 @@ void FormulaGroupContext::ensureStrArray( ColArray& rColArray, size_t nArrayLen
if (rColArray.mpStrArray)
return;
- maStrArrays.push_back(
- new sc::FormulaGroupContext::StrArrayType(nArrayLen, NULL));
- rColArray.mpStrArray = &maStrArrays.back();
+ m_StrArrays.push_back(
+ o3tl::make_unique<sc::FormulaGroupContext::StrArrayType>(nArrayLen, nullptr));
+ rColArray.mpStrArray = m_StrArrays.back().get();
}
void FormulaGroupContext::ensureNumArray( ColArray& rColArray, size_t nArrayLen )
commit 5fd6aa03c8b3964ba7ccc1cbe4d4421a500fce72
Author: Michael Stahl <mstahl at redhat.com>
Date: Fri Nov 6 23:38:35 2015 +0100
sc: replace boost::ptr_vector with std::vector<std::unique_ptr>
Change-Id: I74440dd6d7904fe9e6a59f7ff757f202d2718b07
diff --git a/sc/inc/formulagroup.hxx b/sc/inc/formulagroup.hxx
index 384ea0a..15c2a60 100644
--- a/sc/inc/formulagroup.hxx
+++ b/sc/inc/formulagroup.hxx
@@ -23,6 +23,7 @@
#endif
#include <svl/sharedstringpool.hxx>
+#include <memory>
#include <set>
#include <unordered_map>
#include <vector>
@@ -57,7 +58,7 @@ struct FormulaGroupContext : boost::noncopyable
typedef AlignedAllocator<double,256> DoubleAllocType;
typedef std::vector<double, DoubleAllocType> NumArrayType;
typedef std::vector<rtl_uString*> StrArrayType;
- typedef boost::ptr_vector<NumArrayType> NumArrayStoreType;
+ typedef std::vector<std::unique_ptr<NumArrayType>> NumArrayStoreType;
typedef boost::ptr_vector<StrArrayType> StrArrayStoreType;
struct ColKey
@@ -87,7 +88,7 @@ struct FormulaGroupContext : boost::noncopyable
typedef std::unordered_map<ColKey, ColArray, ColKey::Hash> ColArraysType;
- NumArrayStoreType maNumArrays; /// manage life cycle of numeric arrays.
+ NumArrayStoreType m_NumArrays; /// manage life cycle of numeric arrays.
StrArrayStoreType maStrArrays; /// manage life cycle of string arrays.
ColArraysType maColArrays; /// keep track of longest array for each column.
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index de6598c..e6983d9 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -47,8 +47,6 @@
#include "scmatrix.hxx"
#include <rowheightcontext.hxx>
-#include <math.h>
-
#include <editeng/eeitem.hxx>
#include <svx/algitem.hxx>
@@ -67,9 +65,13 @@
#include <formula/errorcodes.hxx>
#include <formula/vectortoken.hxx>
+#include <o3tl/make_unique.hxx>
+
#include <algorithm>
#include <memory>
+#include <math.h>
+
// factor from font size to optimal cell height (text width)
#define SC_ROT_BREAK_FACTOR 6
@@ -2491,9 +2493,9 @@ copyFirstFormulaBlock(
{
if (!pNumArray)
{
- rCxt.maNumArrays.push_back(
- new sc::FormulaGroupContext::NumArrayType(nArrayLen, fNan));
- pNumArray = &rCxt.maNumArrays.back();
+ rCxt.m_NumArrays.push_back(
+ o3tl::make_unique<sc::FormulaGroupContext::NumArrayType>(nArrayLen, fNan));
+ pNumArray = rCxt.m_NumArrays.back().get();
}
(*pNumArray)[nPos] = aRes.mfValue;
@@ -2575,8 +2577,9 @@ formula::VectorRefArray ScColumn::FetchVectorRefArray( SCROW nRow1, SCROW nRow2
// Allocate a new array and copy the values to it.
sc::numeric_block::const_iterator it = sc::numeric_block::begin(*itBlk->data);
sc::numeric_block::const_iterator itEnd = sc::numeric_block::end(*itBlk->data);
- rCxt.maNumArrays.push_back(new sc::FormulaGroupContext::NumArrayType(it, itEnd));
- sc::FormulaGroupContext::NumArrayType& rArray = rCxt.maNumArrays.back();
+ rCxt.m_NumArrays.push_back(
+ o3tl::make_unique<sc::FormulaGroupContext::NumArrayType>(it, itEnd));
+ sc::FormulaGroupContext::NumArrayType& rArray = *rCxt.m_NumArrays.back();
rArray.resize(nRow2+1, fNan); // allocate to the requested length.
pColArray = rCxt.setCachedColArray(nTab, nCol, &rArray, NULL);
@@ -2671,8 +2674,9 @@ formula::VectorRefArray ScColumn::FetchVectorRefArray( SCROW nRow1, SCROW nRow2
case sc::element_type_empty:
{
// Fill the whole length with NaN's.
- rCxt.maNumArrays.push_back(new sc::FormulaGroupContext::NumArrayType(nRow2+1, fNan));
- sc::FormulaGroupContext::NumArrayType& rArray = rCxt.maNumArrays.back();
+ rCxt.m_NumArrays.push_back(
+ o3tl::make_unique<sc::FormulaGroupContext::NumArrayType>(nRow2+1, fNan));
+ sc::FormulaGroupContext::NumArrayType& rArray = *rCxt.m_NumArrays.back();
pColArray = rCxt.setCachedColArray(nTab, nCol, &rArray, NULL);
if (!pColArray)
// Failed to insert a new cached column array.
diff --git a/sc/source/core/tool/formulagroup.cxx b/sc/source/core/tool/formulagroup.cxx
index 1e73276..835ed2a 100644
--- a/sc/source/core/tool/formulagroup.cxx
+++ b/sc/source/core/tool/formulagroup.cxx
@@ -24,6 +24,7 @@
#if HAVE_FEATURE_OPENCL
#include <opencl/platforminfo.hxx>
#endif
+#include <o3tl/make_unique.hxx>
#include <rtl/bootstrap.hxx>
#include <cstdio>
@@ -124,9 +125,9 @@ void FormulaGroupContext::ensureNumArray( ColArray& rColArray, size_t nArrayLen
double fNan;
rtl::math::setNan(&fNan);
- maNumArrays.push_back(
- new sc::FormulaGroupContext::NumArrayType(nArrayLen, fNan));
- rColArray.mpNumArray = &maNumArrays.back();
+ m_NumArrays.push_back(
+ o3tl::make_unique<sc::FormulaGroupContext::NumArrayType>(nArrayLen, fNan));
+ rColArray.mpNumArray = m_NumArrays.back().get();
}
FormulaGroupContext::FormulaGroupContext()
More information about the Libreoffice-commits
mailing list