sc/qa/unit/helper/shared_test_impl.hxx | 10 ++--- sc/source/core/data/colorscale.cxx | 38 +++++++++---------- sc/source/core/data/conditio.cxx | 66 ++++++++++++++++----------------- 3 files changed, 57 insertions(+), 57 deletions(-)
New commits: commit 489dbb311dc8645765885a432cc8bf42543a2867 Author: Noel Grandin <[email protected]> Date: Mon Aug 31 13:39:16 2015 +0200 fix dubious usage of [0] instead of proper dereferencing introduced in commit 4aed1c6f384ab372b1c03f607445f92f0181f822 "replace boost::ptr_vector with std::vector<std::unique_ptr>" Change-Id: Id16921f212128d34835a4c0b9facd18cb264da62 diff --git a/sc/qa/unit/helper/shared_test_impl.hxx b/sc/qa/unit/helper/shared_test_impl.hxx index 956fc9f..7a92c4e 100644 --- a/sc/qa/unit/helper/shared_test_impl.hxx +++ b/sc/qa/unit/helper/shared_test_impl.hxx @@ -103,10 +103,10 @@ void testColorScale2Entry_Impl(ScDocument& rDoc) CPPUNIT_ASSERT_EQUAL(size_t(2), pColFormat->size()); ScColorScaleEntries::const_iterator format_itr = pColFormat->begin(); - CPPUNIT_ASSERT_EQUAL(aData2Entry[i].eLowerType, format_itr[0]->GetType()); + CPPUNIT_ASSERT_EQUAL(aData2Entry[i].eLowerType, (*format_itr)->GetType()); ++format_itr; CPPUNIT_ASSERT(format_itr != pColFormat->end()); - CPPUNIT_ASSERT_EQUAL(aData2Entry[i].eUpperType, format_itr[0]->GetType()); + CPPUNIT_ASSERT_EQUAL(aData2Entry[i].eUpperType, (*format_itr)->GetType()); } } @@ -142,13 +142,13 @@ void testColorScale3Entry_Impl(ScDocument& rDoc) CPPUNIT_ASSERT_EQUAL(size_t(3), pColFormat->size()); ScColorScaleEntries::const_iterator format_itr = pColFormat->begin(); - CPPUNIT_ASSERT_EQUAL(aData3Entry[i].eLowerType, format_itr[0]->GetType()); + CPPUNIT_ASSERT_EQUAL(aData3Entry[i].eLowerType, (*format_itr)->GetType()); ++format_itr; CPPUNIT_ASSERT(format_itr != pColFormat->end()); - CPPUNIT_ASSERT_EQUAL(aData3Entry[i].eMiddleType, format_itr[0]->GetType()); + CPPUNIT_ASSERT_EQUAL(aData3Entry[i].eMiddleType, (*format_itr)->GetType()); ++format_itr; CPPUNIT_ASSERT(format_itr != pColFormat->end()); - CPPUNIT_ASSERT_EQUAL(aData3Entry[i].eUpperType, format_itr[0]->GetType()); + CPPUNIT_ASSERT_EQUAL(aData3Entry[i].eUpperType, (*format_itr)->GetType()); } } diff --git a/sc/source/core/data/colorscale.cxx b/sc/source/core/data/colorscale.cxx index 5c6c54c..897737e 100644 --- a/sc/source/core/data/colorscale.cxx +++ b/sc/source/core/data/colorscale.cxx @@ -310,7 +310,7 @@ ScColorScaleFormat::ScColorScaleFormat(ScDocument* pDoc, const ScColorScaleForma { for(ScColorScaleEntries::const_iterator itr = rFormat.begin(); itr != rFormat.end(); ++itr) { - maColorScales.push_back(std::unique_ptr<ScColorScaleEntry>(new ScColorScaleEntry(pDoc, *itr[0]))); + maColorScales.push_back(std::unique_ptr<ScColorScaleEntry>(new ScColorScaleEntry(pDoc, **itr))); } } @@ -342,8 +342,8 @@ double ScColorScaleFormat::GetMinValue() const { ScColorScaleEntries::const_iterator itr = maColorScales.begin(); - if(itr[0]->GetType() == COLORSCALE_VALUE || itr[0]->GetType() == COLORSCALE_FORMULA) - return itr[0]->GetValue(); + if((*itr)->GetType() == COLORSCALE_VALUE || (*itr)->GetType() == COLORSCALE_FORMULA) + return (*itr)->GetValue(); else { return getMinValue(); @@ -354,8 +354,8 @@ double ScColorScaleFormat::GetMaxValue() const { ScColorScaleEntries::const_reverse_iterator itr = maColorScales.rbegin(); - if(itr[0]->GetType() == COLORSCALE_VALUE || itr[0]->GetType() == COLORSCALE_FORMULA) - return itr[0]->GetValue(); + if((*itr)->GetType() == COLORSCALE_VALUE || (*itr)->GetType() == COLORSCALE_FORMULA) + return (*itr)->GetValue(); else { return getMaxValue(); @@ -501,10 +501,10 @@ double GetPercentile( const std::vector<double>& rArray, double fPercentile ) double ScColorScaleFormat::CalcValue(double nMin, double nMax, ScColorScaleEntries::const_iterator& itr) const { - switch(itr[0]->GetType()) + switch((*itr)->GetType()) { case COLORSCALE_PERCENT: - return nMin + (nMax-nMin)*(itr[0]->GetValue()/100); + return nMin + (nMax-nMin)*((*itr)->GetValue()/100); case COLORSCALE_MIN: return nMin; case COLORSCALE_MAX: @@ -516,7 +516,7 @@ double ScColorScaleFormat::CalcValue(double nMin, double nMax, ScColorScaleEntri return rValues[0]; else { - double fPercentile = itr[0]->GetValue()/100.0; + double fPercentile = (*itr)->GetValue()/100.0; return GetPercentile(rValues, fPercentile); } } @@ -525,7 +525,7 @@ double ScColorScaleFormat::CalcValue(double nMin, double nMax, ScColorScaleEntri break; } - return itr[0]->GetValue(); + return (*itr)->GetValue(); } Color* ScColorScaleFormat::GetColor( const ScAddress& rAddr ) const @@ -557,17 +557,17 @@ Color* ScColorScaleFormat::GetColor( const ScAddress& rAddr ) const ScColorScaleEntries::const_iterator itr = begin(); double nValMin = CalcValue(nMin, nMax, itr); - Color rColMin = itr[0]->GetColor(); + Color rColMin = (*itr)->GetColor(); ++itr; double nValMax = CalcValue(nMin, nMax, itr); - Color rColMax = itr[0]->GetColor(); + Color rColMax = (*itr)->GetColor(); ++itr; while(itr != end() && nVal > nValMax) { rColMin = rColMax; nValMin = nValMax; - rColMax = itr[0]->GetColor(); + rColMax = (*itr)->GetColor(); nValMax = CalcValue(nMin, nMax, itr); ++itr; } @@ -580,25 +580,25 @@ Color* ScColorScaleFormat::GetColor( const ScAddress& rAddr ) const void ScColorScaleFormat::UpdateReference( sc::RefUpdateContext& rCxt ) { for(ScColorScaleEntries::iterator itr = begin(); itr != end(); ++itr) - itr[0]->UpdateReference(rCxt); + (*itr)->UpdateReference(rCxt); } void ScColorScaleFormat::UpdateInsertTab( sc::RefUpdateInsertTabContext& rCxt ) { for (ScColorScaleEntries::iterator it = begin(); it != end(); ++it) - it[0]->UpdateInsertTab(rCxt); + (*it)->UpdateInsertTab(rCxt); } void ScColorScaleFormat::UpdateDeleteTab( sc::RefUpdateDeleteTabContext& rCxt ) { for (ScColorScaleEntries::iterator it = begin(); it != end(); ++it) - it[0]->UpdateDeleteTab(rCxt); + (*it)->UpdateDeleteTab(rCxt); } void ScColorScaleFormat::UpdateMoveTab( sc::RefUpdateMoveTabContext& rCxt ) { for (ScColorScaleEntries::iterator it = begin(); it != end(); ++it) - it[0]->UpdateMoveTab(rCxt); + (*it)->UpdateMoveTab(rCxt); } bool ScColorScaleFormat::NeedsRepaint() const @@ -606,7 +606,7 @@ bool ScColorScaleFormat::NeedsRepaint() const for(ScColorScaleEntries::const_iterator itr = begin(), itrEnd = end(); itr != itrEnd; ++itr) { - if(itr[0]->NeedsRepaint()) + if((*itr)->NeedsRepaint()) return true; } return false; @@ -644,7 +644,7 @@ ScColorScaleEntry* ScColorScaleFormat::GetEntry(size_t nPos) if (maColorScales.size() <= nPos) return NULL; - return &maColorScales[nPos].get()[0]; + return maColorScales[nPos].get(); } const ScColorScaleEntry* ScColorScaleFormat::GetEntry(size_t nPos) const @@ -652,7 +652,7 @@ const ScColorScaleEntry* ScColorScaleFormat::GetEntry(size_t nPos) const if (maColorScales.size() <= nPos) return NULL; - return &maColorScales[nPos].get()[0]; + return maColorScales[nPos].get(); } size_t ScColorScaleFormat::size() const diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx index 3aeaef2..1926118 100644 --- a/sc/source/core/data/conditio.cxx +++ b/sc/source/core/data/conditio.cxx @@ -1816,7 +1816,7 @@ ScConditionalFormat* ScConditionalFormat::Clone(ScDocument* pNewDoc) const for (CondFormatContainer::const_iterator itr = maEntries.begin(); itr != maEntries.end(); ++itr) { - ScFormatEntry* pNewEntry = itr[0]->Clone(pNewDoc); + ScFormatEntry* pNewEntry = (*itr)->Clone(pNewDoc); pNew->maEntries.push_back( std::unique_ptr<ScFormatEntry>(pNewEntry) ); pNewEntry->SetParent(pNew); } @@ -1879,7 +1879,7 @@ ScConditionalFormat::~ScConditionalFormat() const ScFormatEntry* ScConditionalFormat::GetEntry( sal_uInt16 nPos ) const { if ( nPos < size() ) - return &maEntries[nPos].get()[0]; + return maEntries[nPos].get(); else return NULL; } @@ -1888,15 +1888,15 @@ const OUString& ScConditionalFormat::GetCellStyle( ScRefCellValue& rCell, const { for (CondFormatContainer::const_iterator itr = maEntries.begin(); itr != maEntries.end(); ++itr) { - if(itr[0]->GetType() == condformat::CONDITION) + if((*itr)->GetType() == condformat::CONDITION) { - const ScCondFormatEntry& rEntry = static_cast<const ScCondFormatEntry&>(*itr[0]); + const ScCondFormatEntry& rEntry = static_cast<const ScCondFormatEntry&>(**itr); if (rEntry.IsCellValid(rCell, rPos)) return rEntry.GetStyle(); } - else if(itr[0]->GetType() == condformat::DATE) + else if((*itr)->GetType() == condformat::DATE) { - const ScCondDateFormatEntry& rEntry = static_cast<const ScCondDateFormatEntry&>(*itr[0]); + const ScCondDateFormatEntry& rEntry = static_cast<const ScCondDateFormatEntry&>(**itr); if (rEntry.IsValid( rPos )) return rEntry.GetStyleName(); } @@ -1910,30 +1910,30 @@ ScCondFormatData ScConditionalFormat::GetData( ScRefCellValue& rCell, const ScAd ScCondFormatData aData; for(CondFormatContainer::const_iterator itr = maEntries.begin(); itr != maEntries.end(); ++itr) { - if(itr[0]->GetType() == condformat::CONDITION && aData.aStyleName.isEmpty()) + if((*itr)->GetType() == condformat::CONDITION && aData.aStyleName.isEmpty()) { - const ScCondFormatEntry& rEntry = static_cast<const ScCondFormatEntry&>(*itr[0]); + const ScCondFormatEntry& rEntry = static_cast<const ScCondFormatEntry&>(**itr); if (rEntry.IsCellValid(rCell, rPos)) aData.aStyleName = rEntry.GetStyle(); } - else if(itr[0]->GetType() == condformat::COLORSCALE && !aData.pColorScale) + else if((*itr)->GetType() == condformat::COLORSCALE && !aData.pColorScale) { - const ScColorScaleFormat& rEntry = static_cast<const ScColorScaleFormat&>(*itr[0]); + const ScColorScaleFormat& rEntry = static_cast<const ScColorScaleFormat&>(**itr); aData.pColorScale = rEntry.GetColor(rPos); } - else if(itr[0]->GetType() == condformat::DATABAR && !aData.pDataBar) + else if((*itr)->GetType() == condformat::DATABAR && !aData.pDataBar) { - const ScDataBarFormat& rEntry = static_cast<const ScDataBarFormat&>(*itr[0]); + const ScDataBarFormat& rEntry = static_cast<const ScDataBarFormat&>(**itr); aData.pDataBar = rEntry.GetDataBarInfo(rPos); } - else if(itr[0]->GetType() == condformat::ICONSET && !aData.pIconSet) + else if((*itr)->GetType() == condformat::ICONSET && !aData.pIconSet) { - const ScIconSetFormat& rEntry = static_cast<const ScIconSetFormat&>(*itr[0]); + const ScIconSetFormat& rEntry = static_cast<const ScIconSetFormat&>(**itr); aData.pIconSet = rEntry.GetIconSetInfo(rPos); } - else if(itr[0]->GetType() == condformat::DATE && aData.aStyleName.isEmpty()) + else if((*itr)->GetType() == condformat::DATE && aData.aStyleName.isEmpty()) { - const ScCondDateFormatEntry& rEntry = static_cast<const ScCondDateFormatEntry&>(*itr[0]); + const ScCondDateFormatEntry& rEntry = static_cast<const ScCondDateFormatEntry&>(**itr); if ( rEntry.IsValid( rPos ) ) aData.aStyleName = rEntry.GetStyleName(); } @@ -1958,21 +1958,21 @@ void ScConditionalFormat::DoRepaint( const ScRange* pModified ) void ScConditionalFormat::CompileAll() { for(CondFormatContainer::iterator itr = maEntries.begin(); itr != maEntries.end(); ++itr) - if(itr[0]->GetType() == condformat::CONDITION) - static_cast<ScCondFormatEntry&>(*itr[0]).CompileAll(); + if((*itr)->GetType() == condformat::CONDITION) + static_cast<ScCondFormatEntry&>(**itr).CompileAll(); } void ScConditionalFormat::CompileXML() { for(CondFormatContainer::iterator itr = maEntries.begin(); itr != maEntries.end(); ++itr) - if(itr[0]->GetType() == condformat::CONDITION) - static_cast<ScCondFormatEntry&>(*itr[0]).CompileXML(); + if((*itr)->GetType() == condformat::CONDITION) + static_cast<ScCondFormatEntry&>(**itr).CompileXML(); } void ScConditionalFormat::UpdateReference( sc::RefUpdateContext& rCxt, bool bCopyAsMove ) { for(CondFormatContainer::iterator itr = maEntries.begin(); itr != maEntries.end(); ++itr) - itr[0]->UpdateReference(rCxt); + (*itr)->UpdateReference(rCxt); if (rCxt.meMode == URM_COPY && bCopyAsMove) maRanges.UpdateReference(URM_MOVE, pDoc, rCxt.maRange, rCxt.mnColDelta, rCxt.mnRowDelta, rCxt.mnTabDelta); @@ -2007,7 +2007,7 @@ void ScConditionalFormat::UpdateInsertTab( sc::RefUpdateInsertTabContext& rCxt ) } for (CondFormatContainer::iterator it = maEntries.begin(); it != maEntries.end(); ++it) - it[0]->UpdateInsertTab(rCxt); + (*it)->UpdateInsertTab(rCxt); } void ScConditionalFormat::UpdateDeleteTab( sc::RefUpdateDeleteTabContext& rCxt ) @@ -2036,7 +2036,7 @@ void ScConditionalFormat::UpdateDeleteTab( sc::RefUpdateDeleteTabContext& rCxt ) } for (CondFormatContainer::iterator it = maEntries.begin(); it != maEntries.end(); ++it) - it[0]->UpdateDeleteTab(rCxt); + (*it)->UpdateDeleteTab(rCxt); } void ScConditionalFormat::UpdateMoveTab( sc::RefUpdateMoveTabContext& rCxt ) @@ -2073,7 +2073,7 @@ void ScConditionalFormat::UpdateMoveTab( sc::RefUpdateMoveTabContext& rCxt ) } for (CondFormatContainer::iterator it = maEntries.begin(); it != maEntries.end(); ++it) - it[0]->UpdateMoveTab(rCxt); + (*it)->UpdateMoveTab(rCxt); } void ScConditionalFormat::DeleteArea( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 ) @@ -2088,9 +2088,9 @@ void ScConditionalFormat::DeleteArea( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCR void ScConditionalFormat::RenameCellStyle(const OUString& rOld, const OUString& rNew) { for(CondFormatContainer::iterator itr = maEntries.begin(); itr != maEntries.end(); ++itr) - if(itr[0]->GetType() == condformat::CONDITION) + if((*itr)->GetType() == condformat::CONDITION) { - ScCondFormatEntry& rFormat = static_cast<ScCondFormatEntry&>(*itr[0]); + ScCondFormatEntry& rFormat = static_cast<ScCondFormatEntry&>(**itr); if(rFormat.GetStyle() == rOld) rFormat.UpdateStyleName( rNew ); } @@ -2100,17 +2100,17 @@ void ScConditionalFormat::SourceChanged( const ScAddress& rAddr ) { for(CondFormatContainer::iterator itr = maEntries.begin(); itr != maEntries.end(); ++itr) { - condformat::ScFormatEntryType eEntryType = itr[0]->GetType(); + condformat::ScFormatEntryType eEntryType = (*itr)->GetType(); if( eEntryType == condformat::CONDITION) { - ScCondFormatEntry& rFormat = static_cast<ScCondFormatEntry&>(*itr[0]); + ScCondFormatEntry& rFormat = static_cast<ScCondFormatEntry&>(**itr); rFormat.SourceChanged( rAddr ); } else if( eEntryType == condformat::COLORSCALE || eEntryType == condformat::DATABAR || eEntryType == condformat::ICONSET ) { - ScColorFormat& rFormat = static_cast<ScColorFormat&>(*itr[0]); + ScColorFormat& rFormat = static_cast<ScColorFormat&>(**itr); if(rFormat.NeedsRepaint()) { // we need to repaint the whole range anyway @@ -2125,9 +2125,9 @@ bool ScConditionalFormat::MarkUsedExternalReferences() const { bool bAllMarked = false; for(CondFormatContainer::const_iterator itr = maEntries.begin(); itr != maEntries.end() && !bAllMarked; ++itr) - if(itr[0]->GetType() == condformat::CONDITION) + if((*itr)->GetType() == condformat::CONDITION) { - const ScCondFormatEntry& rFormat = static_cast<const ScCondFormatEntry&>(*itr[0]); + const ScCondFormatEntry& rFormat = static_cast<const ScCondFormatEntry&>(**itr); bAllMarked = rFormat.MarkUsedExternalReferences(); } @@ -2138,7 +2138,7 @@ void ScConditionalFormat::startRendering() { for(CondFormatContainer::iterator itr = maEntries.begin(); itr != maEntries.end(); ++itr) { - itr[0]->startRendering(); + (*itr)->startRendering(); } } @@ -2146,7 +2146,7 @@ void ScConditionalFormat::endRendering() { for(CondFormatContainer::iterator itr = maEntries.begin(); itr != maEntries.end(); ++itr) { - itr[0]->endRendering(); + (*itr)->endRendering(); } } _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
