diff options
-rw-r--r-- | sc/inc/colorscale.hxx | 11 | ||||
-rw-r--r-- | sc/qa/unit/ucalc.cxx | 7 | ||||
-rw-r--r-- | sc/source/core/data/colorscale.cxx | 57 | ||||
-rw-r--r-- | sc/source/core/data/fillinfo.cxx | 2 | ||||
-rw-r--r-- | sc/source/filter/excel/xecontent.cxx | 3 | ||||
-rw-r--r-- | sc/source/filter/excel/xeextlst.cxx | 2 | ||||
-rw-r--r-- | sc/source/filter/oox/condformatbuffer.cxx | 2 | ||||
-rw-r--r-- | sc/source/filter/xml/xmlcondformat.cxx | 2 | ||||
-rw-r--r-- | sc/source/filter/xml/xmlexprt.cxx | 3 | ||||
-rw-r--r-- | sc/source/ui/condformat/condformatdlgentry.cxx | 7 | ||||
-rw-r--r-- | sc/source/ui/unoobj/condformatuno.cxx | 8 |
11 files changed, 62 insertions, 42 deletions
diff --git a/sc/inc/colorscale.hxx b/sc/inc/colorscale.hxx index 43a19982981d..a8d9f1f5f225 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 169f03dada59..356222868e4d 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 c346f73b19f4..74e4e334c362 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 e0e2623bc7c0..cd1d41270eda 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 f98c3cac40aa..d94bf88db4e3 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 79bf5236c418..ec6e8dfe8182 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 79ba6eab2522..c8cdc4a51266 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 28744a53208d..2d6884bb68a8 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 d71b4b3651a0..e06e29fc2137 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 4c995bf905f6..b6318a2a43eb 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 2626c74c52ab..e561ddfa1158 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() |