sc/inc/address.hxx | 2 sc/inc/rangelst.hxx | 42 - sc/qa/unit/helper/qahelper.cxx | 6 sc/qa/unit/mark_test.cxx | 88 +- sc/qa/unit/rangelst_test.cxx | 34 - sc/qa/unit/ucalc.cxx | 18 sc/qa/unit/ucalc_condformat.cxx | 8 sc/source/core/data/clipparam.cxx | 32 - sc/source/core/data/colorscale.cxx | 12 sc/source/core/data/column.cxx | 2 sc/source/core/data/columnspanset.cxx | 8 sc/source/core/data/conditio.cxx | 62 -- sc/source/core/data/documen3.cxx | 6 sc/source/core/data/documen5.cxx | 31 - sc/source/core/data/documen6.cxx | 2 sc/source/core/data/document.cxx | 165 ++--- sc/source/core/data/drwlayer.cxx | 10 sc/source/core/data/formulacell.cxx | 10 sc/source/core/data/markdata.cxx | 38 - sc/source/core/data/table2.cxx | 53 - sc/source/core/data/table3.cxx | 2 sc/source/core/data/table6.cxx | 37 - sc/source/core/data/tabprotection.cxx | 8 sc/source/core/tool/chartarr.cxx | 6 sc/source/core/tool/charthelper.cxx | 19 sc/source/core/tool/chartpos.cxx | 21 sc/source/core/tool/dbdata.cxx | 4 sc/source/core/tool/rangelst.cxx | 295 ++++------ sc/source/core/tool/rangeutl.cxx | 11 sc/source/core/tool/reftokenhelper.cxx | 10 sc/source/filter/excel/excform.cxx | 2 sc/source/filter/excel/excform8.cxx | 2 sc/source/filter/excel/xecontent.cxx | 34 - sc/source/filter/excel/xeextlst.cxx | 2 sc/source/filter/excel/xeformula.cxx | 2 sc/source/filter/excel/xehelper.cxx | 14 sc/source/filter/excel/xename.cxx | 8 sc/source/filter/excel/xestream.cxx | 2 sc/source/filter/excel/xicontent.cxx | 27 sc/source/filter/excel/xiescher.cxx | 8 sc/source/filter/excel/xihelper.cxx | 2 sc/source/filter/excel/xistyle.cxx | 16 sc/source/filter/html/htmlimp.cxx | 2 sc/source/filter/html/htmlpars.cxx | 14 sc/source/filter/oox/addressconverter.cxx | 8 sc/source/filter/oox/condformatbuffer.cxx | 2 sc/source/filter/oox/defnamesbuffer.cxx | 2 sc/source/filter/oox/extlstcontext.cxx | 4 sc/source/filter/oox/formulabase.cxx | 6 sc/source/filter/oox/scenariobuffer.cxx | 2 sc/source/filter/oox/sheetdatabuffer.cxx | 24 sc/source/filter/xcl97/xcl97rec.cxx | 6 sc/source/filter/xml/xmlcondformat.cxx | 4 sc/source/filter/xml/xmlsceni.cxx | 7 sc/source/filter/xml/xmlstyli.cxx | 4 sc/source/filter/xml/xmlsubti.cxx | 2 sc/source/filter/xml/xmltabi.cxx | 2 sc/source/ui/Accessibility/AccessibleCell.cxx | 2 sc/source/ui/Accessibility/AccessibleSpreadsheet.cxx | 93 +-- sc/source/ui/StatisticsDialogs/AnalysisOfVarianceDialog.cxx | 14 sc/source/ui/StatisticsDialogs/MatrixComparisonGenerator.cxx | 4 sc/source/ui/StatisticsDialogs/RandomNumberGeneratorDialog.cxx | 2 sc/source/ui/StatisticsDialogs/SamplingDialog.cxx | 4 sc/source/ui/StatisticsDialogs/StatisticsInputOutputDialog.cxx | 8 sc/source/ui/StatisticsDialogs/StatisticsTwoVariableDialog.cxx | 6 sc/source/ui/condformat/condformatdlg.cxx | 3 sc/source/ui/dialogs/searchresults.cxx | 12 sc/source/ui/docshell/arealink.cxx | 16 sc/source/ui/docshell/dbdocfun.cxx | 8 sc/source/ui/docshell/docfunc.cxx | 11 sc/source/ui/docshell/docsh3.cxx | 10 sc/source/ui/docshell/docsh4.cxx | 2 sc/source/ui/docshell/docsh5.cxx | 2 sc/source/ui/docshell/externalrefmgr.cxx | 5 sc/source/ui/docshell/tablink.cxx | 10 sc/source/ui/drawfunc/fuins2.cxx | 4 sc/source/ui/inc/AccessibleSpreadsheet.hxx | 4 sc/source/ui/inc/docsh.hxx | 3 sc/source/ui/miscdlgs/acredlin.cxx | 20 sc/source/ui/miscdlgs/anyrefdg.cxx | 22 sc/source/ui/miscdlgs/highred.cxx | 4 sc/source/ui/miscdlgs/optsolver.cxx | 2 sc/source/ui/undo/undobase.cxx | 4 sc/source/ui/undo/undoblk.cxx | 50 - sc/source/ui/undo/undocell.cxx | 2 sc/source/ui/undo/undodat.cxx | 2 sc/source/ui/unoobj/cellsuno.cxx | 215 +++---- sc/source/ui/unoobj/chart2uno.cxx | 7 sc/source/ui/unoobj/chartuno.cxx | 22 sc/source/ui/unoobj/condformatuno.cxx | 2 sc/source/ui/unoobj/cursuno.cxx | 26 sc/source/ui/unoobj/dapiuno.cxx | 9 sc/source/ui/unoobj/docuno.cxx | 27 sc/source/ui/unoobj/funcuno.cxx | 8 sc/source/ui/unoobj/viewuno.cxx | 25 sc/source/ui/vba/vbaapplication.cxx | 4 sc/source/ui/vba/vbaeventshelper.cxx | 4 sc/source/ui/vba/vbahyperlinks.cxx | 4 sc/source/ui/vba/vbanames.cxx | 2 sc/source/ui/vba/vbapagesetup.cxx | 6 sc/source/ui/vba/vbarange.cxx | 66 +- sc/source/ui/view/cellsh.cxx | 2 sc/source/ui/view/cellsh1.cxx | 19 sc/source/ui/view/cliputil.cxx | 2 sc/source/ui/view/dbfunc3.cxx | 12 sc/source/ui/view/drawvie4.cxx | 2 sc/source/ui/view/gridwin.cxx | 14 sc/source/ui/view/gridwin4.cxx | 2 sc/source/ui/view/gridwin_dbgutil.cxx | 8 sc/source/ui/view/tabview3.cxx | 6 sc/source/ui/view/tabvwshc.cxx | 62 -- sc/source/ui/view/viewdata.cxx | 3 sc/source/ui/view/viewfun2.cxx | 33 - sc/source/ui/view/viewfun3.cxx | 57 - sc/source/ui/view/viewfun4.cxx | 2 sc/source/ui/view/viewfun6.cxx | 17 sc/source/ui/view/viewfunc.cxx | 10 117 files changed, 1077 insertions(+), 1180 deletions(-)
New commits: commit 6529cd54c29c5800340530a1b8182c341fbeeafb Author: Noel Grandin <[email protected]> Date: Wed Mar 7 14:17:38 2018 +0200 don't use heap for elements in ScRangeList no need to store small objects like this out of line. Also - add move constructor and move assignment operator - drop Assign method since it now has the same signature as push_back Change-Id: I9a8647d3a11f24166a83d399a358a2bce3b2cb79 Reviewed-on: https://gerrit.libreoffice.org/50899 Tested-by: Jenkins <[email protected]> Reviewed-by: Eike Rathke <[email protected]> diff --git a/sc/inc/address.hxx b/sc/inc/address.hxx index a3c7040a21d5..ddc85469d349 100644 --- a/sc/inc/address.hxx +++ b/sc/inc/address.hxx @@ -480,7 +480,7 @@ inline bool ValidAddress( const ScAddress& rAddress ) } // ScRange -class SAL_WARN_UNUSED ScRange +class SAL_WARN_UNUSED ScRange final { public: ScAddress aStart; diff --git a/sc/inc/rangelst.hxx b/sc/inc/rangelst.hxx index 4d9fe2770815..d78c7054499d 100644 --- a/sc/inc/rangelst.hxx +++ b/sc/inc/rangelst.hxx @@ -28,20 +28,22 @@ class ScDocument; -class SC_DLLPUBLIC ScRangeList : public SvRefBase + +class SAL_WARN_UNUSED SC_DLLPUBLIC ScRangeList final : public SvRefBase { public: ScRangeList(); ScRangeList( const ScRangeList& rList ); + ScRangeList( const ScRangeList&& rList ); ScRangeList( const ScRange& rRange ); virtual ~ScRangeList() override; ScRangeList& operator=(const ScRangeList& rList); - void Append( const ScRange& rRange ); + ScRangeList& operator=(ScRangeList&& rList); - ScRefFlags Parse( const OUString&, const ScDocument*, - formula::FormulaGrammar::AddressConvention eConv = formula::FormulaGrammar::CONV_OOO, - SCTAB nDefaultTab = 0, sal_Unicode cDelimiter = 0 ); + ScRefFlags Parse( const OUString&, const ScDocument*, + formula::FormulaGrammar::AddressConvention eConv = formula::FormulaGrammar::CONV_OOO, + SCTAB nDefaultTab = 0, sal_Unicode cDelimiter = 0 ); void Format( OUString&, ScRefFlags nFlags, ScDocument*, formula::FormulaGrammar::AddressConvention eConv = formula::FormulaGrammar::CONV_OOO, @@ -56,8 +58,8 @@ public: SCTAB nDz ); - void InsertRow( SCTAB nTab, SCCOL nColStart, SCCOL nColEnd, SCROW nRowPos, SCSIZE nSize ); - void InsertCol( SCTAB nTab, SCROW nRowStart, SCROW nRowEnd, SCCOL nColPos, SCSIZE nSize ); + void InsertRow( SCTAB nTab, SCCOL nColStart, SCCOL nColEnd, SCROW nRowPos, SCSIZE nSize ); + void InsertCol( SCTAB nTab, SCROW nRowStart, SCROW nRowEnd, SCCOL nColPos, SCSIZE nSize ); /** For now this method assumes that nTab1 == nTab2 * The algorithm will be much more complicated if nTab1 != nTab2 @@ -81,23 +83,23 @@ public: ScRange Combine() const; - bool empty() const; - size_t size() const; - ScRange* operator[](size_t idx); - const ScRange* operator[](size_t idx) const; - ScRange* front(); - const ScRange* front() const; - ScRange* back(); - const ScRange* back() const; - void push_back(ScRange* p); + bool empty() const { return maRanges.empty(); } + size_t size() const { return maRanges.size(); } + ScRange& operator[](size_t idx) { return maRanges[idx]; } + const ScRange& operator[](size_t idx) const { return maRanges[idx]; } + ScRange& front() { return maRanges.front(); } + const ScRange& front() const { return maRanges.front(); } + ScRange& back() { return maRanges.back(); } + const ScRange& back() const { return maRanges.back(); } + void push_back(const ScRange & rRange); void swap( ScRangeList& r ); private: - ::std::vector<ScRange*> maRanges; + ::std::vector<ScRange> maRanges; SCROW mnMaxRowUsed; - typedef std::vector<ScRange*>::iterator iterator; - typedef std::vector<ScRange*>::const_iterator const_iterator; + typedef std::vector<ScRange>::iterator iterator; + typedef std::vector<ScRange>::const_iterator const_iterator; }; typedef tools::SvRef<ScRangeList> ScRangeListRef; @@ -110,7 +112,7 @@ inline std::basic_ostream<charT, traits> & operator <<(std::basic_ostream<charT, { if (i > 0) stream << ","; - stream << *(rRangeList[i]); + stream << rRangeList[i]; } stream << ")"; diff --git a/sc/qa/unit/helper/qahelper.cxx b/sc/qa/unit/helper/qahelper.cxx index f99d23df203e..3f7c93198312 100644 --- a/sc/qa/unit/helper/qahelper.cxx +++ b/sc/qa/unit/helper/qahelper.cxx @@ -53,7 +53,7 @@ std::ostream& operator<<(std::ostream& rStrm, const ScRangeList& rList) { rStrm << "ScRangeList: \n"; for(size_t i = 0; i < rList.size(); ++i) - rStrm << *rList[i]; + rStrm << rList[i]; return rStrm; } @@ -382,14 +382,14 @@ ScRangeList getChartRanges(ScDocument& rDoc, const SdrOle2Obj& rChartObj) ScRefFlags nRes = aRange.Parse(aRangeReps[i], &rDoc, rDoc.GetAddressConvention()); if (nRes & ScRefFlags::VALID) // This is a range address. - aRanges.Append(aRange); + aRanges.push_back(aRange); else { // Parse it as a single cell address. ScAddress aAddr; nRes = aAddr.Parse(aRangeReps[i], &rDoc, rDoc.GetAddressConvention()); CPPUNIT_ASSERT_MESSAGE("Failed to parse a range representation.", (nRes & ScRefFlags::VALID)); - aRanges.Append(aAddr); + aRanges.push_back(aAddr); } } diff --git a/sc/qa/unit/mark_test.cxx b/sc/qa/unit/mark_test.cxx index a083d482b219..0c393e934b77 100644 --- a/sc/qa/unit/mark_test.cxx +++ b/sc/qa/unit/mark_test.cxx @@ -120,10 +120,10 @@ static void lcl_GetSortedRanges( const ScRangeList& rRangeList, ScRangeList& rRa size_t nSize = rRangeList.size(); aRanges.reserve( nSize ); for ( size_t nIdx = 0; nIdx < nSize; ++nIdx ) - aRanges.push_back( *rRangeList[nIdx] ); + aRanges.push_back( rRangeList[nIdx] ); std::sort( aRanges.begin(), aRanges.end() ); for ( size_t nIdx = 0; nIdx < nSize; ++nIdx ) - rRangeListOut.Append( aRanges[nIdx] ); + rRangeListOut.push_back( aRanges[nIdx] ); } void Test::testSimpleMark( const ScRange& rRange, const ScRange& rSelectionCover, @@ -544,25 +544,25 @@ void Test::testMultiMark_FourRanges() aData.aMarks.push_back( aSingle4 ); aData.aSelectionCover = ScRange( 0, 0, 0, MAXCOL, MAXROW, 0 ); - aData.aLeftEnvelope.Append( ScRange( 9, 5, 0, 9, 10, 0 ) ); - aData.aLeftEnvelope.Append( ScRange( 24, 7, 0, 24, 15, 0 ) ); - aData.aLeftEnvelope.Append( ScRange( 34, 0, 0, 34, 19, 0 ) ); - aData.aLeftEnvelope.Append( ScRange( 34, 21, 0, 34, MAXROW, 0 ) ); - - aData.aRightEnvelope.Append( ScRange( 21, 5, 0, 21, 10, 0 ) ); - aData.aRightEnvelope.Append( ScRange( 31, 7, 0, 31, 15, 0 ) ); - aData.aRightEnvelope.Append( ScRange( 36, 0, 0, 36, 19, 0 ) ); - aData.aRightEnvelope.Append( ScRange( 36, 21, 0, 36, MAXROW, 0 ) ); - - aData.aTopEnvelope.Append( ScRange( 10, 4, 0, 20, 4, 0 ) ); - aData.aTopEnvelope.Append( ScRange( 25, 6, 0, 30, 6, 0 ) ); - aData.aTopEnvelope.Append( ScRange( 0, 19, 0, 34, 19, 0 ) ); - aData.aTopEnvelope.Append( ScRange( 36, 19, 0, MAXCOL, 19, 0 ) ); - - aData.aBottomEnvelope.Append( ScRange( 10, 11, 0, 20, 11, 0 ) ); - aData.aBottomEnvelope.Append( ScRange( 25, 16, 0, 30, 16, 0 ) ); - aData.aBottomEnvelope.Append( ScRange( 0, 21, 0, 34, 21, 0 ) ); - aData.aBottomEnvelope.Append( ScRange( 36, 21, 0, MAXCOL, 21, 0 ) ); + aData.aLeftEnvelope.push_back( ScRange( 9, 5, 0, 9, 10, 0 ) ); + aData.aLeftEnvelope.push_back( ScRange( 24, 7, 0, 24, 15, 0 ) ); + aData.aLeftEnvelope.push_back( ScRange( 34, 0, 0, 34, 19, 0 ) ); + aData.aLeftEnvelope.push_back( ScRange( 34, 21, 0, 34, MAXROW, 0 ) ); + + aData.aRightEnvelope.push_back( ScRange( 21, 5, 0, 21, 10, 0 ) ); + aData.aRightEnvelope.push_back( ScRange( 31, 7, 0, 31, 15, 0 ) ); + aData.aRightEnvelope.push_back( ScRange( 36, 0, 0, 36, 19, 0 ) ); + aData.aRightEnvelope.push_back( ScRange( 36, 21, 0, 36, MAXROW, 0 ) ); + + aData.aTopEnvelope.push_back( ScRange( 10, 4, 0, 20, 4, 0 ) ); + aData.aTopEnvelope.push_back( ScRange( 25, 6, 0, 30, 6, 0 ) ); + aData.aTopEnvelope.push_back( ScRange( 0, 19, 0, 34, 19, 0 ) ); + aData.aTopEnvelope.push_back( ScRange( 36, 19, 0, MAXCOL, 19, 0 ) ); + + aData.aBottomEnvelope.push_back( ScRange( 10, 11, 0, 20, 11, 0 ) ); + aData.aBottomEnvelope.push_back( ScRange( 25, 16, 0, 30, 16, 0 ) ); + aData.aBottomEnvelope.push_back( ScRange( 0, 21, 0, 34, 21, 0 ) ); + aData.aBottomEnvelope.push_back( ScRange( 36, 21, 0, MAXCOL, 21, 0 ) ); MarkArrayTestData aMarkArrayTestData1; aMarkArrayTestData1.nCol = 5; @@ -744,29 +744,29 @@ void Test::testMultiMark_NegativeMarking() aData.aMarks.push_back( aSingle5 ); aData.aSelectionCover = ScRange( 0, 4, 0, MAXCOL, 21, 0 ); - aData.aLeftEnvelope.Append( ScRange( 9, 8, 0, 9, 11, 0 ) ); - aData.aLeftEnvelope.Append( ScRange( 9, 13, 0, 9, 20, 0 ) ); - aData.aLeftEnvelope.Append( ScRange( 18, 10, 0, 18, 14, 0 ) ); - aData.aLeftEnvelope.Append( ScRange( 20, 5, 0, 20, 5, 0 ) ); - - aData.aRightEnvelope.Append( ScRange( 17, 5, 0, 17, 5, 0 ) ); - aData.aRightEnvelope.Append( ScRange( 15, 10, 0, 15, 14, 0 ) ); - aData.aRightEnvelope.Append( ScRange( 26, 8, 0, 26, 11, 0 ) ); - aData.aRightEnvelope.Append( ScRange( 26, 13, 0, 26, 20, 0 ) ); - - aData.aTopEnvelope.Append( ScRange( 0, 4, 0, 16, 4, 0 ) ); - aData.aTopEnvelope.Append( ScRange( 21, 4, 0, MAXCOL, 4, 0 ) ); - aData.aTopEnvelope.Append( ScRange( 10, 7, 0, 25, 7, 0 ) ); - aData.aTopEnvelope.Append( ScRange( 0, 11, 0, 9, 11, 0 ) ); - aData.aTopEnvelope.Append( ScRange( 26, 11, 0, MAXCOL, 11, 0 ) ); - aData.aTopEnvelope.Append( ScRange( 15, 14, 0, 18, 14, 0 ) ); - - aData.aBottomEnvelope.Append( ScRange( 0, 6, 0, 16, 6, 0 ) ); - aData.aBottomEnvelope.Append( ScRange( 21, 6, 0, MAXCOL, 6, 0 ) ); - aData.aBottomEnvelope.Append( ScRange( 15, 10, 0, 18, 10, 0 ) ); - aData.aBottomEnvelope.Append( ScRange( 0, 13, 0, 9, 13, 0 ) ); - aData.aBottomEnvelope.Append( ScRange( 26, 13, 0, MAXCOL, 13, 0 ) ); - aData.aBottomEnvelope.Append( ScRange( 10, 21, 0, 25, 21, 0 ) ); + aData.aLeftEnvelope.push_back( ScRange( 9, 8, 0, 9, 11, 0 ) ); + aData.aLeftEnvelope.push_back( ScRange( 9, 13, 0, 9, 20, 0 ) ); + aData.aLeftEnvelope.push_back( ScRange( 18, 10, 0, 18, 14, 0 ) ); + aData.aLeftEnvelope.push_back( ScRange( 20, 5, 0, 20, 5, 0 ) ); + + aData.aRightEnvelope.push_back( ScRange( 17, 5, 0, 17, 5, 0 ) ); + aData.aRightEnvelope.push_back( ScRange( 15, 10, 0, 15, 14, 0 ) ); + aData.aRightEnvelope.push_back( ScRange( 26, 8, 0, 26, 11, 0 ) ); + aData.aRightEnvelope.push_back( ScRange( 26, 13, 0, 26, 20, 0 ) ); + + aData.aTopEnvelope.push_back( ScRange( 0, 4, 0, 16, 4, 0 ) ); + aData.aTopEnvelope.push_back( ScRange( 21, 4, 0, MAXCOL, 4, 0 ) ); + aData.aTopEnvelope.push_back( ScRange( 10, 7, 0, 25, 7, 0 ) ); + aData.aTopEnvelope.push_back( ScRange( 0, 11, 0, 9, 11, 0 ) ); + aData.aTopEnvelope.push_back( ScRange( 26, 11, 0, MAXCOL, 11, 0 ) ); + aData.aTopEnvelope.push_back( ScRange( 15, 14, 0, 18, 14, 0 ) ); + + aData.aBottomEnvelope.push_back( ScRange( 0, 6, 0, 16, 6, 0 ) ); + aData.aBottomEnvelope.push_back( ScRange( 21, 6, 0, MAXCOL, 6, 0 ) ); + aData.aBottomEnvelope.push_back( ScRange( 15, 10, 0, 18, 10, 0 ) ); + aData.aBottomEnvelope.push_back( ScRange( 0, 13, 0, 9, 13, 0 ) ); + aData.aBottomEnvelope.push_back( ScRange( 26, 13, 0, MAXCOL, 13, 0 ) ); + aData.aBottomEnvelope.push_back( ScRange( 10, 21, 0, 25, 21, 0 ) ); aData.aColsWithOneMark.emplace_back( 19, 8, 0, 0, 20, 0 ); aData.aColsWithOneMark.emplace_back( 20, 8, 0, 0, 20, 0 ); diff --git a/sc/qa/unit/rangelst_test.cxx b/sc/qa/unit/rangelst_test.cxx index 1e0236a549b1..0858f7a358af 100644 --- a/sc/qa/unit/rangelst_test.cxx +++ b/sc/qa/unit/rangelst_test.cxx @@ -410,24 +410,24 @@ void Test::testDeleteArea_0Ranges() void Test::testJoin_Case1() { ScRangeList aList; - aList.push_back(new ScRange(1,1,0,3,3,0)); + aList.push_back(ScRange(1,1,0,3,3,0)); aList.Join(ScRange(4,1,0,6,3,0)); CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), aList.size()); - CPPUNIT_ASSERT_EQUAL( ScRange(1,1,0,6,3,0), *aList[0]); + CPPUNIT_ASSERT_EQUAL( ScRange(1,1,0,6,3,0), aList[0]); } void Test::testJoin_Case2() { ScRangeList aList; - aList.push_back(new ScRange(1,1,0,3,3,0)); - aList.push_back(new ScRange(4,1,0,6,3,0)); - aList.push_back(new ScRange(7,1,0,9,3,0)); + aList.push_back(ScRange(1,1,0,3,3,0)); + aList.push_back(ScRange(4,1,0,6,3,0)); + aList.push_back(ScRange(7,1,0,9,3,0)); - aList.Join(*aList[2], true); + aList.Join(aList[2], true); CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), aList.size()); - CPPUNIT_ASSERT_EQUAL(ScRange(1,1,0,9,3,0), *aList[0]); + CPPUNIT_ASSERT_EQUAL(ScRange(1,1,0,9,3,0), aList[0]); } void Test::testJoin_Case3() @@ -438,7 +438,7 @@ void Test::testJoin_Case3() // The second one should have been swallowed by the first one CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), aList.size()); - CPPUNIT_ASSERT_EQUAL(ScRange(1,1,0,6,6,0), *aList[0]); + CPPUNIT_ASSERT_EQUAL(ScRange(1,1,0,6,6,0), aList[0]); // Add a disjoint one aList.Join(ScRange(8,8,0,9,9,0)); @@ -446,9 +446,9 @@ void Test::testJoin_Case3() // Should be two ones now CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), aList.size()); // The first one should still be as is - CPPUNIT_ASSERT_EQUAL(ScRange(1,1,0,6,6,0), *aList[0]); + CPPUNIT_ASSERT_EQUAL(ScRange(1,1,0,6,6,0), aList[0]); // Ditto for the second one - CPPUNIT_ASSERT_EQUAL(ScRange(8,8,0,9,9,0), *aList[1]); + CPPUNIT_ASSERT_EQUAL(ScRange(8,8,0,9,9,0), aList[1]); } void Test::testJoin_Case4() @@ -460,14 +460,14 @@ void Test::testJoin_Case4() // The one range in the list should have been extended CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), aList.size()); - CPPUNIT_ASSERT_EQUAL(ScRange(1,1,0,2,8,0), *aList[0]); + CPPUNIT_ASSERT_EQUAL(ScRange(1,1,0,2,8,0), aList[0]); // Join a range that overlaps it and extends it horizontally aList.Join(ScRange(2,1,0,4,8,0)); // Again, should have just been extended CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), aList.size()); - CPPUNIT_ASSERT_EQUAL(ScRange(1,1,0,4,8,0), *aList[0]); + CPPUNIT_ASSERT_EQUAL(ScRange(1,1,0,4,8,0), aList[0]); // And then the same but on top / to the left of existing range ScRangeList aList2; @@ -475,12 +475,12 @@ void Test::testJoin_Case4() aList2.Join(ScRange(4,1,0,8,6,0)); CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), aList2.size()); - CPPUNIT_ASSERT_EQUAL(ScRange(4,1,0,8,8,0), *aList2[0]); + CPPUNIT_ASSERT_EQUAL(ScRange(4,1,0,8,8,0), aList2[0]); aList2.Join(ScRange(1,1,0,6,8,0)); CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), aList2.size()); - CPPUNIT_ASSERT_EQUAL(ScRange(1,1,0,8,8,0), *aList2[0]); + CPPUNIT_ASSERT_EQUAL(ScRange(1,1,0,8,8,0), aList2[0]); } void Test::testJoin_Case5() @@ -491,14 +491,14 @@ void Test::testJoin_Case5() // Nothing special so far, two disjoint ranges CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), aList.size()); - CPPUNIT_ASSERT_EQUAL(ScRange(0,0,0,4,4,0), *aList[0]); - CPPUNIT_ASSERT_EQUAL(ScRange(8,0,0,10,4,0), *aList[1]); + CPPUNIT_ASSERT_EQUAL(ScRange(0,0,0,4,4,0), aList[0]); + CPPUNIT_ASSERT_EQUAL(ScRange(8,0,0,10,4,0), aList[1]); // This should join the two ranges into one aList.Join(ScRange(5,0,0,9,4,0)); CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), aList.size()); - CPPUNIT_ASSERT_EQUAL(ScRange(0,0,0,10,4,0), *aList[0]); + CPPUNIT_ASSERT_EQUAL(ScRange(0,0,0,10,4,0), aList[0]); } void Test::testUpdateReference_DeleteRow() diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx index d2544ab010fd..2b03df58ad9f 100644 --- a/sc/qa/unit/ucalc.cxx +++ b/sc/qa/unit/ucalc.cxx @@ -355,9 +355,9 @@ void Test::testRangeList() m_pDoc->InsertTab(0, "foo"); ScRangeList aRL; - aRL.Append(ScRange(1,1,0,3,10,0)); + aRL.push_back(ScRange(1,1,0,3,10,0)); CPPUNIT_ASSERT_EQUAL_MESSAGE("List should have one range.", size_t(1), aRL.size()); - const ScRange* p = aRL[0]; + const ScRange* p = &aRL[0]; CPPUNIT_ASSERT_MESSAGE("Failed to get the range object.", p); CPPUNIT_ASSERT_MESSAGE("Wrong range.", p->aStart == ScAddress(1,1,0) && p->aEnd == ScAddress(3,10,0)); @@ -582,8 +582,8 @@ void Test::testSelectionFunction() // Select B2:B8 & D2:D8 disjoint region. ScRangeList aRanges; - aRanges.Append(ScRange(1,1,0,1,7,0)); // B2:B8 - aRanges.Append(ScRange(3,1,0,3,7,0)); // D2:D8 + aRanges.push_back(ScRange(1,1,0,1,7,0)); // B2:B8 + aRanges.push_back(ScRange(3,1,0,3,7,0)); // D2:D8 ScMarkData aMark; aMark.MarkFromRangeList(aRanges, true); @@ -703,8 +703,8 @@ void Test::testSelectionFunction() // Mark B2 and C3 on first sheet. aRanges.RemoveAll(); - aRanges.Append(ScRange(1,1,0)); // B2 - aRanges.Append(ScRange(2,2,0)); // C3 + aRanges.push_back(ScRange(1,1,0)); // B2 + aRanges.push_back(ScRange(2,2,0)); // C3 aMark.MarkFromRangeList(aRanges, true); // Additionally select third sheet. aMark.SelectTable(2, true); @@ -3566,9 +3566,9 @@ void Test::testCopyPasteMultiRange() // Copy A2:B2, A4:B4, and A6:B6 to clipboard. ScDocument aClipDoc(SCDOCMODE_CLIP); ScClipParam aClipParam; - aClipParam.maRanges.Append(ScRange(0,1,0,1,1,0)); // A2:B2 - aClipParam.maRanges.Append(ScRange(0,3,0,1,3,0)); // A4:B4 - aClipParam.maRanges.Append(ScRange(0,5,0,1,5,0)); // A6:B6 + aClipParam.maRanges.push_back(ScRange(0,1,0,1,1,0)); // A2:B2 + aClipParam.maRanges.push_back(ScRange(0,3,0,1,3,0)); // A4:B4 + aClipParam.maRanges.push_back(ScRange(0,5,0,1,5,0)); // A6:B6 aClipParam.meDirection = ScClipParam::Row; m_pDoc->CopyToClip(aClipParam, &aClipDoc, &aMark, false, false); diff --git a/sc/qa/unit/ucalc_condformat.cxx b/sc/qa/unit/ucalc_condformat.cxx index 0e8721a0acb8..148e43416121 100644 --- a/sc/qa/unit/ucalc_condformat.cxx +++ b/sc/qa/unit/ucalc_condformat.cxx @@ -187,7 +187,7 @@ void Test::testCondFormatInsertDeleteSheets() // ... and its range is B2:B4. ScRangeList aCheckRange = pCheck->GetRange(); CPPUNIT_ASSERT_EQUAL_MESSAGE("This should be a single range.", size_t(1), aCheckRange.size()); - const ScRange* pRange = aCheckRange[0]; + const ScRange* pRange = &aCheckRange[0]; CPPUNIT_ASSERT(pRange); CPPUNIT_ASSERT_EQUAL_MESSAGE("Format should be applied to B2:B4.", ScRange(1,1,0,1,3,0), *pRange); @@ -205,7 +205,7 @@ void Test::testCondFormatInsertDeleteSheets() // Make sure the range also got shifted. aCheckRange = pCheck->GetRange(); CPPUNIT_ASSERT_EQUAL_MESSAGE("This should be a single range.", size_t(1), aCheckRange.size()); - pRange = aCheckRange[0]; + pRange = &aCheckRange[0]; CPPUNIT_ASSERT(pRange); CPPUNIT_ASSERT_EQUAL_MESSAGE("Format should be applied to B2:B4 on the 2nd sheet after the sheet insertion.", ScRange(1,1,1,1,3,1), *pRange); @@ -221,7 +221,7 @@ void Test::testCondFormatInsertDeleteSheets() // Make sure the range got shifted back. aCheckRange = pCheck->GetRange(); CPPUNIT_ASSERT_EQUAL_MESSAGE("This should be a single range.", size_t(1), aCheckRange.size()); - pRange = aCheckRange[0]; + pRange = &aCheckRange[0]; CPPUNIT_ASSERT(pRange); CPPUNIT_ASSERT_EQUAL_MESSAGE("Format should be applied to B2:B4 on the 1st sheet after the sheet removal.", ScRange(1,1,0,1,3,0), *pRange); @@ -238,7 +238,7 @@ void Test::testCondFormatInsertDeleteSheets() aCheckRange = pCheck->GetRange(); CPPUNIT_ASSERT_EQUAL_MESSAGE("This should be a single range.", size_t(1), aCheckRange.size()); - pRange = aCheckRange[0]; + pRange = &aCheckRange[0]; CPPUNIT_ASSERT(pRange); CPPUNIT_ASSERT_EQUAL_MESSAGE("Format should be applied to B2:B4 on the 2nd sheet after the undo of the sheet removal.", ScRange(1,1,1,1,3,1), *pRange); diff --git a/sc/source/core/data/clipparam.cxx b/sc/source/core/data/clipparam.cxx index 51738c9532e3..b33c4998c10b 100644 --- a/sc/source/core/data/clipparam.cxx +++ b/sc/source/core/data/clipparam.cxx @@ -32,7 +32,7 @@ ScClipParam::ScClipParam(const ScRange& rRange, bool bCutMode) : mbCutMode(bCutMode), mnSourceDocID(0) { - maRanges.Append(rRange); + maRanges.push_back(rRange); } bool ScClipParam::isMultiRange() const @@ -52,15 +52,15 @@ SCCOL ScClipParam::getPasteColSize() SCCOL nColSize = 0; for ( size_t i = 0, nListSize = maRanges.size(); i < nListSize; ++i ) { - ScRange* p = maRanges[ i ]; - nColSize += p->aEnd.Col() - p->aStart.Col() + 1; + const ScRange& rRange = maRanges[ i ]; + nColSize += rRange.aEnd.Col() - rRange.aStart.Col() + 1; } return nColSize; } case ScClipParam::Row: { // We assume that all ranges have identical column size. - const ScRange& rRange = *maRanges.front(); + const ScRange& rRange = maRanges.front(); return rRange.aEnd.Col() - rRange.aStart.Col() + 1; } case ScClipParam::Unspecified: @@ -80,7 +80,7 @@ SCROW ScClipParam::getPasteRowSize() case ScClipParam::Column: { // We assume that all ranges have identical row size. - const ScRange& rRange = *maRanges.front(); + const ScRange& rRange = maRanges.front(); return rRange.aEnd.Row() - rRange.aStart.Row() + 1; } case ScClipParam::Row: @@ -88,8 +88,8 @@ SCROW ScClipParam::getPasteRowSize() SCROW nRowSize = 0; for ( size_t i = 0, nListSize = maRanges.size(); i < nListSize; ++i ) { - ScRange* p = maRanges[ i ]; - nRowSize += p->aEnd.Row() - p->aStart.Row() + 1; + const ScRange& rRange = maRanges[ i ]; + nRowSize += rRange.aEnd.Row() - rRange.aStart.Row() + 1; } return nRowSize; } @@ -123,24 +123,24 @@ void ScClipParam::transpose() ScRangeList aNewRanges; if (!maRanges.empty()) { - ScRange* p = maRanges.front(); - SCCOL nColOrigin = p->aStart.Col(); - SCROW nRowOrigin = p->aStart.Row(); + const ScRange & rRange1 = maRanges.front(); + SCCOL nColOrigin = rRange1.aStart.Col(); + SCROW nRowOrigin = rRange1.aStart.Row(); for ( size_t i = 0, n = maRanges.size(); i < n; ++i ) { - p = maRanges[ i ]; - SCCOL nColDelta = p->aStart.Col() - nColOrigin; - SCROW nRowDelta = p->aStart.Row() - nRowOrigin; + const ScRange & rRange = maRanges[ i ]; + SCCOL nColDelta = rRange.aStart.Col() - nColOrigin; + SCROW nRowDelta = rRange.aStart.Row() - nRowOrigin; SCCOL nCol1 = 0; - SCCOL nCol2 = static_cast<SCCOL>(p->aEnd.Row() - p->aStart.Row()); + SCCOL nCol2 = static_cast<SCCOL>(rRange.aEnd.Row() - rRange.aStart.Row()); SCROW nRow1 = 0; - SCROW nRow2 = static_cast<SCROW>(p->aEnd.Col() - p->aStart.Col()); + SCROW nRow2 = static_cast<SCROW>(rRange.aEnd.Col() - rRange.aStart.Col()); nCol1 += static_cast<SCCOL>(nRowDelta); nCol2 += static_cast<SCCOL>(nRowDelta); nRow1 += static_cast<SCROW>(nColDelta); nRow2 += static_cast<SCROW>(nColDelta); - aNewRanges.push_back( new ScRange(nCol1, nRow1, p->aStart.Tab(), nCol2, nRow2, p->aStart.Tab() ) ); + aNewRanges.push_back( ScRange(nCol1, nRow1, rRange.aStart.Tab(), nCol2, nRow2, rRange.aStart.Tab() ) ); } } maRanges = aNewRanges; diff --git a/sc/source/core/data/colorscale.cxx b/sc/source/core/data/colorscale.cxx index a07f3ac0f1e6..8826fada3d04 100644 --- a/sc/source/core/data/colorscale.cxx +++ b/sc/source/core/data/colorscale.cxx @@ -393,13 +393,13 @@ std::vector<double>& ScColorFormat::getValues() const const ScRangeList& aRanges = GetRange(); for(size_t i = 0; i < n; ++i) { - const ScRange* pRange = aRanges[i]; - SCTAB nTab = pRange->aStart.Tab(); + const ScRange & rRange = aRanges[i]; + SCTAB nTab = rRange.aStart.Tab(); - SCCOL nColStart = pRange->aStart.Col(); - SCROW nRowStart = pRange->aStart.Row(); - SCCOL nColEnd = pRange->aEnd.Col(); - SCROW nRowEnd = pRange->aEnd.Row(); + SCCOL nColStart = rRange.aStart.Col(); + SCROW nRowStart = rRange.aStart.Row(); + SCCOL nColEnd = rRange.aEnd.Col(); + SCROW nRowEnd = rRange.aEnd.Row(); if(nRowEnd == MAXROW) { diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx index 412d62385dcb..2dad0de39037 100644 --- a/sc/source/core/data/column.cxx +++ b/sc/source/core/data/column.cxx @@ -207,7 +207,7 @@ bool ScColumn::HasSelectionMatrixFragment(const ScMarkData& rMark) const ScRangeList aRanges = rMark.GetMarkedRanges(); for (size_t i = 0, n = aRanges.size(); i < n; ++i) { - const ScRange& r = *aRanges[i]; + const ScRange& r = aRanges[i]; if (nTab < r.aStart.Tab() || r.aEnd.Tab() < nTab) continue; diff --git a/sc/source/core/data/columnspanset.cxx b/sc/source/core/data/columnspanset.cxx index a3f338abbb9b..d7d7718bbb84 100644 --- a/sc/source/core/data/columnspanset.cxx +++ b/sc/source/core/data/columnspanset.cxx @@ -337,15 +337,15 @@ void SingleColumnSpanSet::scan(const ScRangeList& rRanges, SCTAB nTab, SCCOL nCo { for (size_t i = 0, n = rRanges.size(); i < n; ++i) { - const ScRange* p = rRanges[i]; - if (nTab < p->aStart.Tab() || p->aEnd.Tab() < nTab) + const ScRange & rRange = rRanges[i]; + if (nTab < rRange.aStart.Tab() || rRange.aEnd.Tab() < nTab) continue; - if (nCol < p->aStart.Col() || p->aEnd.Col() < nCol) + if (nCol < rRange.aStart.Col() || rRange.aEnd.Col() < nCol) // This column is not in this range. Skip it. continue; - maSpans.insert_back(p->aStart.Row(), p->aEnd.Row()+1, true); + maSpans.insert_back(rRange.aStart.Row(), rRange.aEnd.Row()+1, true); } } diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx index c09e5e90b250..c07d7672d789 100644 --- a/sc/source/core/data/conditio.cxx +++ b/sc/source/core/data/conditio.cxx @@ -146,11 +146,8 @@ void start_listen_to(ScFormulaListener& rListener, const ScTokenArray* pTokens, size_t n = rRangeList.size(); for (size_t i = 0; i < n; ++i) { - const ScRange* pRange = rRangeList[i]; - if (!pRange) - continue; - - rListener.addTokenArray(pTokens, *pRange); + const ScRange & rRange = rRangeList[i]; + rListener.addTokenArray(pTokens, rRange); } } @@ -784,12 +781,12 @@ void ScConditionEntry::FillCache() const size_t nListCount = rRanges.size(); for( size_t i = 0; i < nListCount; i++ ) { - const ScRange *aRange = rRanges[i]; - SCROW nRow = aRange->aEnd.Row(); - SCCOL nCol = aRange->aEnd.Col(); - SCCOL nColStart = aRange->aStart.Col(); - SCROW nRowStart = aRange->aStart.Row(); - SCTAB nTab = aRange->aStart.Tab(); + const ScRange & rRange = rRanges[i]; + SCROW nRow = rRange.aEnd.Row(); + SCCOL nCol = rRange.aEnd.Col(); + SCCOL nColStart = rRange.aStart.Col(); + SCROW nRowStart = rRange.aStart.Row(); + SCTAB nTab = rRange.aStart.Tab(); // temporary fix to workaround slow duplicate entry // conditions, prevent to use a whole row @@ -1899,15 +1896,15 @@ void ScConditionalFormat::UpdateInsertTab( sc::RefUpdateInsertTabContext& rCxt ) for (size_t i = 0, n = maRanges.size(); i < n; ++i) { // We assume that the start and end sheet indices are equal. - ScRange* pRange = maRanges[i]; - SCTAB nTab = pRange->aStart.Tab(); + ScRange & rRange = maRanges[i]; + SCTAB nTab = rRange.aStart.Tab(); if (nTab < rCxt.mnInsertPos) // Unaffected. continue; - pRange->aStart.IncTab(rCxt.mnSheets); - pRange->aEnd.IncTab(rCxt.mnSheets); + rRange.aStart.IncTab(rCxt.mnSheets); + rRange.aEnd.IncTab(rCxt.mnSheets); } for (auto it = maEntries.cbegin(); it != maEntries.cend(); ++it) @@ -1919,8 +1916,8 @@ void ScConditionalFormat::UpdateDeleteTab( sc::RefUpdateDeleteTabContext& rCxt ) for (size_t i = 0, n = maRanges.size(); i < n; ++i) { // We assume that the start and end sheet indices are equal. - ScRange* pRange = maRanges[i]; - SCTAB nTab = pRange->aStart.Tab(); + ScRange & rRange = maRanges[i]; + SCTAB nTab = rRange.aStart.Tab(); if (nTab < rCxt.mnDeletePos) // Left of the deleted sheet(s). Unaffected. @@ -1929,14 +1926,14 @@ void ScConditionalFormat::UpdateDeleteTab( sc::RefUpdateDeleteTabContext& rCxt ) if (nTab <= rCxt.mnDeletePos+rCxt.mnSheets-1) { // On the deleted sheet(s). - pRange->aStart.SetTab(-1); - pRange->aEnd.SetTab(-1); + rRange.aStart.SetTab(-1); + rRange.aEnd.SetTab(-1); continue; } // Right of the deleted sheet(s). Adjust the sheet indices. - pRange->aStart.IncTab(-1*rCxt.mnSheets); - pRange->aEnd.IncTab(-1*rCxt.mnSheets); + rRange.aStart.IncTab(-1*rCxt.mnSheets); + rRange.aEnd.IncTab(-1*rCxt.mnSheets); } for (auto it = maEntries.cbegin(); it != maEntries.cend(); ++it) @@ -1950,8 +1947,8 @@ void ScConditionalFormat::UpdateMoveTab( sc::RefUpdateMoveTabContext& rCxt ) SCTAB nMaxTab = std::max<SCTAB>(rCxt.mnOldPos, rCxt.mnNewPos); for(size_t i = 0; i < n; ++i) { - ScRange* pRange = maRanges[i]; - SCTAB nTab = pRange->aStart.Tab(); + ScRange & rRange = maRanges[i]; + SCTAB nTab = rRange.aStart.Tab(); if(nTab < nMinTab || nTab > nMaxTab) { continue; @@ -1959,20 +1956,20 @@ void ScConditionalFormat::UpdateMoveTab( sc::RefUpdateMoveTabContext& rCxt ) if (nTab == rCxt.mnOldPos) { - pRange->aStart.SetTab(rCxt.mnNewPos); - pRange->aEnd.SetTab(rCxt.mnNewPos); + rRange.aStart.SetTab(rCxt.mnNewPos); + rRange.aEnd.SetTab(rCxt.mnNewPos); continue; } if (rCxt.mnNewPos < rCxt.mnOldPos) { - pRange->aStart.IncTab(); - pRange->aEnd.IncTab(); + rRange.aStart.IncTab(); + rRange.aEnd.IncTab(); } else { - pRange->aStart.IncTab(-1); - pRange->aEnd.IncTab(-1); + rRange.aStart.IncTab(-1); + rRange.aEnd.IncTab(-1); } } @@ -1985,7 +1982,7 @@ void ScConditionalFormat::DeleteArea( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCR if (maRanges.empty()) return; - SCTAB nTab = maRanges[0]->aStart.Tab(); + SCTAB nTab = maRanges[0].aStart.Tab(); maRanges.DeleteArea( nCol1, nRow1, nTab, nCol2, nRow2, nTab ); } @@ -2204,8 +2201,7 @@ ScRangeList ScConditionalFormatList::GetCombinedRange() const const ScRangeList& rRange = itr->GetRange(); for (size_t i = 0, n = rRange.size(); i < n; ++i) { - if (rRange[i]) - aRange.Join(*rRange[i]); + aRange.Join(rRange[i]); } } return aRange; @@ -2228,7 +2224,7 @@ void ScConditionalFormatList::AddToDocument(ScDocument* pDoc) const if (rRange.empty()) continue; - SCTAB nTab = rRange.front()->aStart.Tab(); + SCTAB nTab = rRange.front().aStart.Tab(); pDoc->AddCondFormatData(rRange, nTab, itr->GetKey()); } } diff --git a/sc/source/core/data/documen3.cxx b/sc/source/core/data/documen3.cxx index b4f300b352b3..ff79d99e347e 100644 --- a/sc/source/core/data/documen3.cxx +++ b/sc/source/core/data/documen3.cxx @@ -824,8 +824,8 @@ void ScDocument::CopyScenario( SCTAB nSrcTab, SCTAB nDestTab, bool bNewScenario bool bTouched = false; for ( size_t nR=0, nRangeCount = aRanges.size(); nR < nRangeCount && !bTouched; nR++ ) { - const ScRange* pRange = aRanges[ nR ]; - if ( maTabs[nTab]->HasScenarioRange( *pRange ) ) + const ScRange& rRange = aRanges[ nR ]; + if ( maTabs[nTab]->HasScenarioRange( rRange ) ) bTouched = true; } if (bTouched) @@ -1117,7 +1117,7 @@ void ScDocument::UpdateTranspose( const ScAddress& rDestPos, ScDocument* pClipDo ScRange aSource; ScClipParam& rClipParam = GetClipParam(); if (!rClipParam.maRanges.empty()) - aSource = *rClipParam.maRanges.front(); + aSource = rClipParam.maRanges.front(); ScAddress aDest = rDestPos; SCTAB nClipTab = 0; diff --git a/sc/source/core/data/documen5.cxx b/sc/source/core/data/documen5.cxx index f92b74087450..bb46fe857fef 100644 --- a/sc/source/core/data/documen5.cxx +++ b/sc/source/core/data/documen5.cxx @@ -137,8 +137,7 @@ void ScDocument::UpdateChartArea( const OUString& rChartName, const ScRange& rNewArea, bool bColHeaders, bool bRowHeaders, bool bAdd ) { - ScRangeListRef aRLR( new ScRangeList ); - aRLR->Append( rNewArea ); + ScRangeListRef aRLR( new ScRangeList(rNewArea) ); UpdateChartArea( rChartName, aRLR, bColHeaders, bRowHeaders, bAdd ); } @@ -295,7 +294,7 @@ void ScDocument::UpdateChartArea( const OUString& rChartName, aNewRanges->Parse( aRangesStr, this ); for ( size_t nAdd = 0, nAddCount = rNewList->size(); nAdd < nAddCount; ++nAdd ) - aNewRanges->Append( *(*rNewList)[nAdd] ); + aNewRanges->push_back( (*rNewList)[nAdd] ); } else { @@ -388,7 +387,7 @@ void ScDocument::RestoreChartListener( const OUString& rName ) ScRange aRange; ScAddress::Details aDetails(GetAddressConvention(), 0, 0); if ( aRange.ParseAny( aRepresentations[i], this, aDetails ) & ScRefFlags::VALID ) - aRanges->Append( aRange ); + aRanges->push_back( aRange ); } pChartListenerCollection->ChangeListening( rName, aRanges ); @@ -414,13 +413,13 @@ void ScDocument::UpdateChartRef( UpdateRefMode eUpdateRefMode, bool bDataChanged = false; for ( size_t i = 0, nListSize = aRLR->size(); i < nListSize; ++i ) { - ScRange* pR = (*aRLR)[i]; - SCCOL theCol1 = pR->aStart.Col(); - SCROW theRow1 = pR->aStart.Row(); - SCTAB theTab1 = pR->aStart.Tab(); - SCCOL theCol2 = pR->aEnd.Col(); - SCROW theRow2 = pR->aEnd.Row(); - SCTAB theTab2 = pR->aEnd.Tab(); + ScRange& rRange = (*aRLR)[i]; + SCCOL theCol1 = rRange.aStart.Col(); + SCROW theRow1 = rRange.aStart.Row(); + SCTAB theTab1 = rRange.aStart.Tab(); + SCCOL theCol2 = rRange.aEnd.Col(); + SCROW theRow2 = rRange.aEnd.Row(); + SCTAB theTab2 = rRange.aEnd.Tab(); ScRefUpdateRes eRes = ScRefUpdate::Update( this, eUpdateRefMode, nCol1,nRow1,nTab1, nCol2,nRow2,nTab2, @@ -430,24 +429,24 @@ void ScDocument::UpdateChartRef( UpdateRefMode eUpdateRefMode, if ( eRes != UR_NOTHING ) { bChanged = true; - aNewRLR->Append( ScRange( + aNewRLR->push_back( ScRange( theCol1, theRow1, theTab1, theCol2, theRow2, theTab2 )); if ( eUpdateRefMode == URM_INSDEL && !bDataChanged && (eRes == UR_INVALID || - ((pR->aEnd.Col() - pR->aStart.Col() + ((rRange.aEnd.Col() - rRange.aStart.Col() != theCol2 - theCol1) - || (pR->aEnd.Row() - pR->aStart.Row() + || (rRange.aEnd.Row() - rRange.aStart.Row() != theRow2 - theRow1) - || (pR->aEnd.Tab() - pR->aStart.Tab() + || (rRange.aEnd.Tab() - rRange.aStart.Tab() != theTab2 - theTab1))) ) { bDataChanged = true; } } else - aNewRLR->Append( *pR ); + aNewRLR->push_back( rRange ); } if ( bChanged ) { diff --git a/sc/source/core/data/documen6.cxx b/sc/source/core/data/documen6.cxx index 0a882e31857c..d4b8a41db979 100644 --- a/sc/source/core/data/documen6.cxx +++ b/sc/source/core/data/documen6.cxx @@ -191,7 +191,7 @@ SvtScriptType ScDocument::GetRangeScriptType( const ScRangeList& rRanges ) sc::ColumnSpanSet aSet(false); for (size_t i = 0, n = rRanges.size(); i < n; ++i) { - const ScRange& rRange = *rRanges[i]; + const ScRange& rRange = rRanges[i]; SCTAB nTab = rRange.aStart.Tab(); SCROW nRow1 = rRange.aStart.Row(); SCROW nRow2 = rRange.aEnd.Row(); diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx index 7ebdb404d7e8..aa1ef7129532 100644 --- a/sc/source/core/data/document.cxx +++ b/sc/source/core/data/document.cxx @@ -1151,7 +1151,7 @@ void ScDocument::LimitChartIfAll( ScRangeListRef& rRangeList ) { for ( size_t i = 0, nCount = rRangeList->size(); i < nCount; i++ ) { - ScRange aRange( *(*rRangeList)[i] ); + ScRange aRange( (*rRangeList)[i] ); if ( ( aRange.aStart.Col() == 0 && aRange.aEnd.Col() == MAXCOL ) || ( aRange.aStart.Row() == 0 && aRange.aEnd.Row() == MAXROW ) ) { @@ -1167,7 +1167,7 @@ void ScDocument::LimitChartIfAll( ScRangeListRef& rRangeList ) aRange.aEnd.SetCol( nEndCol ); aRange.aEnd.SetRow( nEndRow ); } - aNew->Append(aRange); + aNew->push_back(aRange); } } else @@ -2330,7 +2330,7 @@ void ScDocument::CopyTabToClip(SCCOL nCol1, SCROW nRow1, ScClipParam& rClipParam = pClipDoc->GetClipParam(); pClipDoc->aDocName = aDocName; rClipParam.maRanges.RemoveAll(); - rClipParam.maRanges.Append(ScRange(nCol1, nRow1, 0, nCol2, nRow2, 0)); + rClipParam.maRanges.push_back(ScRange(nCol1, nRow1, 0, nCol2, nRow2, 0)); pClipDoc->ResetClip( this, nTab ); sc::CopyToClipContext aCxt(*pClipDoc, false); @@ -2748,7 +2748,7 @@ void ScDocument::CopyNonFilteredFromClip( SCROW nSourceRow = rClipStartRow; SCROW nSourceEnd = 0; if (!rCxt.getClipDoc()->GetClipParam().maRanges.empty()) - nSourceEnd = rCxt.getClipDoc()->GetClipParam().maRanges.front()->aEnd.Row(); + nSourceEnd = rCxt.getClipDoc()->GetClipParam().maRanges.front().aEnd.Row(); SCROW nDestRow = nRow1; while ( nSourceRow <= nSourceEnd && nDestRow <= nRow2 ) @@ -2885,7 +2885,7 @@ void ScDocument::CopyFromClip( const ScRange& rDestRange, const ScMarkData& rMar ScRangeList aLocalRangeList; if (!pDestRanges) { - aLocalRangeList.Append( rDestRange); + aLocalRangeList.push_back( rDestRange); pDestRanges = &aLocalRangeList; } @@ -2898,11 +2898,11 @@ void ScDocument::CopyFromClip( const ScRange& rDestRange, const ScMarkData& rMar SCROW nClipEndRow = aClipRange.aEnd.Row(); for ( size_t nRange = 0; nRange < pDestRanges->size(); ++nRange ) { - const ScRange* pRange = (*pDestRanges)[nRange]; - SCCOL nCol1 = pRange->aStart.Col(); - SCROW nRow1 = pRange->aStart.Row(); - SCCOL nCol2 = pRange->aEnd.Col(); - SCROW nRow2 = pRange->aEnd.Row(); + const ScRange & rRange = (*pDestRanges)[nRange]; + SCCOL nCol1 = rRange.aStart.Col(); + SCROW nRow1 = rRange.aStart.Row(); + SCCOL nCol2 = rRange.aEnd.Col(); + SCROW nRow2 = rRange.aEnd.Row(); if (bSkipAttrForEmpty) { @@ -3067,12 +3067,12 @@ void ScDocument::CopyMultiRangeFromClip( for (size_t i = 0, n = rClipParam.maRanges.size(); i < n; ++i) { - ScRange* p = rClipParam.maRanges[i]; + const ScRange & rRange = rClipParam.maRanges[i]; - SCROW nRowCount = p->aEnd.Row() - p->aStart.Row() + 1; - SCCOL nDx = static_cast<SCCOL>(nCol1 - p->aStart.Col()); - SCROW nDy = static_cast<SCROW>(nRow1 - p->aStart.Row()); - SCCOL nCol2 = nCol1 + p->aEnd.Col() - p->aStart.Col(); + SCROW nRowCount = rRange.aEnd.Row() - rRange.aStart.Row() + 1; + SCCOL nDx = static_cast<SCCOL>(nCol1 - rRange.aStart.Col()); + SCROW nDy = static_cast<SCROW>(nRow1 - rRange.aStart.Row()); + SCCOL nCol2 = nCol1 + rRange.aEnd.Col() - rRange.aStart.Col(); SCROW nEndRow = nRow1 + nRowCount - 1; CopyBlockFromClip(aCxt, nCol1, nRow1, nCol2, nEndRow, rMark, nDx, nDy); @@ -3084,7 +3084,7 @@ void ScDocument::CopyMultiRangeFromClip( nRow1 += nRowCount; break; case ScClipParam::Column: - nCol1 += p->aEnd.Col() - p->aStart.Col() + 1; + nCol1 += rRange.aEnd.Col() - rRange.aStart.Col() + 1; break; default: ; @@ -3119,7 +3119,7 @@ void ScDocument::SetClipArea( const ScRange& rArea, bool bCut ) { ScClipParam& rClipParam = GetClipParam(); rClipParam.maRanges.RemoveAll(); - rClipParam.maRanges.Append(rArea); + rClipParam.maRanges.push_back(rArea); rClipParam.mbCutMode = bCut; } else @@ -3141,22 +3141,22 @@ void ScDocument::GetClipArea(SCCOL& nClipX, SCROW& nClipY, bool bIncludeFiltered // No clip range. Bail out. return; - ScRange* p = rClipRanges.front(); - SCCOL nStartCol = p->aStart.Col(); - SCCOL nEndCol = p->aEnd.Col(); - SCROW nStartRow = p->aStart.Row(); - SCROW nEndRow = p->aEnd.Row(); + ScRange & rRange = rClipRanges.front(); + SCCOL nStartCol = rRange.aStart.Col(); + SCCOL nEndCol = rRange.aEnd.Col(); + SCROW nStartRow = rRange.aStart.Row(); + SCROW nEndRow = rRange.aEnd.Row(); for ( size_t i = 1, n = rClipRanges.size(); i < n; ++i ) { - p = rClipRanges[ i ]; - if (p->aStart.Col() < nStartCol) - nStartCol = p->aStart.Col(); - if (p->aStart.Row() < nStartRow) - nStartRow = p->aStart.Row(); - if (p->aEnd.Col() > nEndCol) - nEndCol = p->aEnd.Col(); - if (p->aEnd.Row() < nEndRow) - nEndRow = p->aEnd.Row(); + rRange = rClipRanges[ i ]; + if (rRange.aStart.Col() < nStartCol) + nStartCol = rRange.aStart.Col(); + if (rRange.aStart.Row() < nStartRow) + nStartRow = rRange.aStart.Row(); + if (rRange.aEnd.Col() > nEndCol) + nEndCol = rRange.aEnd.Col(); + if (rRange.aEnd.Row() < nEndRow) + nEndRow = rRange.aEnd.Row(); } nClipX = nEndCol - nStartCol; @@ -3187,8 +3187,8 @@ void ScDocument::GetClipStart(SCCOL& nClipX, SCROW& nClipY) ScRangeList& rClipRanges = GetClipParam().maRanges; if ( !rClipRanges.empty() ) { - nClipX = rClipRanges.front()->aStart.Col(); - nClipY = rClipRanges.front()->aStart.Row(); + nClipX = rClipRanges.front().aStart.Col(); + nClipY = rClipRanges.front().aStart.Row(); } } else @@ -3210,8 +3210,8 @@ bool ScDocument::HasClipFilteredRows() for ( size_t i = 0, n = rClipRanges.size(); i < n; ++i ) { - ScRange* p = rClipRanges[ i ]; - bool bAnswer = maTabs[nCountTab]->HasFilteredRows(p->aStart.Row(), p->aEnd.Row()); + ScRange & rRange = rClipRanges[ i ]; + bool bAnswer = maTabs[nCountTab]->HasFilteredRows(rRange.aStart.Row(), rRange.aEnd.Row()); if (bAnswer) return true; } @@ -3910,7 +3910,7 @@ void ScDocument::InterpretDirtyCells( const ScRangeList& rRanges ) for (size_t nPos=0, nRangeCount = rRanges.size(); nPos < nRangeCount; nPos++) { - const ScRange& rRange = *rRanges[nPos]; + const ScRange& rRange = rRanges[nPos]; for (SCTAB nTab = rRange.aStart.Tab(); nTab <= rRange.aEnd.Tab(); ++nTab) { ScTable* pTab = FetchTable(nTab); @@ -5104,16 +5104,16 @@ void ScDocument::GetSelectionFrame( const ScMarkData& rMark, bool bMultipleRows = false, bMultipleCols = false; for( size_t nRangeIdx = 0; nRangeIdx < nRangeCount; ++nRangeIdx ) { - const ScRange* pRange = aRangeList[ nRangeIdx ]; - bMultipleRows = ( bMultipleRows || ( pRange->aStart.Row() != pRange->aEnd.Row() ) ); - bMultipleCols = ( bMultipleCols || ( pRange->aStart.Col() != pRange->aEnd.Col() ) ); + const ScRange rRange = aRangeList[ nRangeIdx ]; + bMultipleRows = ( bMultipleRows || ( rRange.aStart.Row() != rRange.aEnd.Row() ) ); + bMultipleCols = ( bMultipleCols || ( rRange.aStart.Col() != rRange.aEnd.Col() ) ); SCTAB nMax = static_cast<SCTAB>(maTabs.size()); ScMarkData::const_iterator itr = rMark.begin(), itrEnd = rMark.end(); for (; itr != itrEnd && *itr < nMax; ++itr) if (maTabs[*itr]) maTabs[*itr]->MergeBlockFrame( &rLineOuter, &rLineInner, aFlags, - pRange->aStart.Col(), pRange->aStart.Row(), - pRange->aEnd.Col(), pRange->aEnd.Row() ); + rRange.aStart.Col(), rRange.aStart.Row(), + rRange.aEnd.Col(), rRange.aEnd.Row() ); } rLineInner.EnableHor( bMultipleRows ); rLineInner.EnableVer( bMultipleCols ); @@ -5725,10 +5725,10 @@ void ScDocument::ApplySelectionFrame( const ScMarkData& rMark, { for ( size_t j=0; j < nRangeCount; j++ ) { - ScRange aRange = *aRangeList[ j ]; + const ScRange & rRange = aRangeList[ j ]; maTabs[*itr]->ApplyBlockFrame( rLineOuter, pLineInner, - aRange.aStart.Col(), aRange.aStart.Row(), - aRange.aEnd.Col(), aRange.aEnd.Row() ); + rRange.aStart.Col(), rRange.aStart.Row(), + rRange.aEnd.Col(), rRange.aEnd.Row() ); } } } @@ -5780,34 +5780,34 @@ void ScDocument::ApplySelectionFrame( const ScMarkData& rMark, size_t nEnvelopeRangeCount = rRangeListTopEnvelope.size(); for ( size_t j=0; j < nEnvelopeRangeCount; j++ ) { - const ScRange* pRange = rRangeListTopEnvelope[ j ]; + const ScRange & rRange = rRangeListTopEnvelope[ j ]; maTabs[*itr1]->ApplyBlockFrame( aTop, &aTopInfo, - pRange->aStart.Col(), pRange->aStart.Row(), - pRange->aEnd.Col(), pRange->aEnd.Row() ); + rRange.aStart.Col(), rRange.aStart.Row(), + rRange.aEnd.Col(), rRange.aEnd.Row() ); } nEnvelopeRangeCount = rRangeListBottomEnvelope.size(); for ( size_t j=0; j < nEnvelopeRangeCount; j++ ) { - const ScRange* pRange = rRangeListBottomEnvelope[ j ]; + const ScRange & rRange = rRangeListBottomEnvelope[ j ]; maTabs[*itr1]->ApplyBlockFrame( aBottom, &aBottomInfo, - pRange->aStart.Col(), pRange->aStart.Row(), - pRange->aEnd.Col(), pRange->aEnd.Row() ); + rRange.aStart.Col(), rRange.aStart.Row(), + rRange.aEnd.Col(), rRange.aEnd.Row() ); } nEnvelopeRangeCount = rRangeListLeftEnvelope.size(); for ( size_t j=0; j < nEnvelopeRangeCount; j++ ) { - const ScRange* pRange = rRangeListLeftEnvelope[ j ]; + const ScRange & rRange = rRangeListLeftEnvelope[ j ]; maTabs[*itr1]->ApplyBlockFrame( aLeft, &aLeftInfo, - pRange->aStart.Col(), pRange->aStart.Row(), - pRange->aEnd.Col(), pRange->aEnd.Row() ); + rRange.aStart.Col(), rRange.aStart.Row(), + rRange.aEnd.Col(), rRange.aEnd.Row() ); } nEnvelopeRangeCount = rRangeListRightEnvelope.size(); for ( size_t j=0; j < nEnvelopeRangeCount; j++ ) { - const ScRange* pRange = rRangeListRightEnvelope[ j ]; + const ScRange & rRange = rRangeListRightEnvelope[ j ]; maTabs[*itr1]->ApplyBlockFrame( aRight, &aRightInfo, - pRange->aStart.Col(), pRange->aStart.Row(), - pRange->aEnd.Col(), pRange->aEnd.Row() ); + rRange.aStart.Col(), rRange.aStart.Row(), + rRange.aEnd.Col(), rRange.aEnd.Row() ); } } } @@ -5892,9 +5892,8 @@ void ScDocument::DeleteSelection( InsertDeleteFlags nDelFlag, const ScMarkData& rMark.FillRangeListWithMarks( &aRangeList, false); for (size_t i = 0; i < aRangeList.size(); ++i) { - const ScRange* pRange = aRangeList[i]; - if (pRange) - EndListeningIntersectedGroups( aCxt, *pRange, &aGroupPos); + const ScRange & rRange = aRangeList[i]; + EndListeningIntersectedGroups( aCxt, rRange, &aGroupPos); } aCxt.purgeEmptyBroadcasters(); } @@ -5920,9 +5919,7 @@ void ScDocument::DeleteSelection( InsertDeleteFlags nDelFlag, const ScMarkData& rMark.FillRangeListWithMarks( &aRangeList, false); for (size_t i = 0; i < aRangeList.size(); ++i) { - const ScRange* pRange = aRangeList[i]; - if (pRange) - SetDirty( *pRange, true); + SetDirty( aRangeList[i], true); } //Notify listeners on top and bottom of the group that has been split for (size_t i = 0; i < aGroupPos.size(); ++i) { @@ -5953,10 +5950,10 @@ void ScDocument::DeleteSelectionTab( rMark.FillRangeListWithMarks( &aRangeList, false); for (size_t i = 0; i < aRangeList.size(); ++i) { - const ScRange* pRange = aRangeList[i]; - if (pRange && pRange->aStart.Tab() <= nTab && nTab <= pRange->aEnd.Tab()) + const ScRange & rRange = aRangeList[i]; + if (rRange.aStart.Tab() <= nTab && nTab <= rRange.aEnd.Tab()) { - ScRange aRange( *pRange); + ScRange aRange( rRange); aRange.aStart.SetTab( nTab); aRange.aEnd.SetTab( nTab); EndListeningIntersectedGroups( aCxt, aRange, &aGroupPos); @@ -5982,10 +5979,10 @@ void ScDocument::DeleteSelectionTab( rMark.FillRangeListWithMarks( &aRangeList, false); for (size_t i = 0; i < aRangeList.size(); ++i) { - const ScRange* pRange = aRangeList[i]; - if (pRange && pRange->aStart.Tab() <= nTab && nTab <= pRange->aEnd.Tab()) + const ScRange & rRange = aRangeList[i]; + if (rRange.aStart.Tab() <= nTab && nTab <= rRange.aEnd.Tab()) { - ScRange aRange( *pRange); + ScRange aRange( rRange); aRange.aStart.SetTab( nTab); aRange.aEnd.SetTab( nTab); SetDirty( aRange, true); @@ -6575,9 +6572,9 @@ void ScDocument::ForgetNoteCaptions( const ScRangeList& rRanges, bool bPreserveD { for (size_t i = 0, n = rRanges.size(); i < n; ++i) { - const ScRange* p = rRanges[i]; - const ScAddress& s = p->aStart; - const ScAddress& e = p->aEnd; + const ScRange & rRange = rRanges[i]; + const ScAddress& s = rRange.aStart; + const ScAddress& e = rRange.aEnd; for (SCTAB nTab = s.Tab(); nTab <= e.Tab(); ++nTab) { ScTable* pTab = FetchTable(nTab); @@ -6598,11 +6595,11 @@ CommentCaptionState ScDocument::GetAllNoteCaptionsState( const ScRangeList& rRan for (size_t i = 0, n = rRanges.size(); i < n; ++i) { - const ScRange* pRange = rRanges[i]; + const ScRange & rRange = rRanges[i]; - for( SCTAB nTab = pRange->aStart.Tab(); nTab <= pRange->aEnd.Tab(); ++nTab ) + for( SCTAB nTab = rRange.aStart.Tab(); nTab <= rRange.aEnd.Tab(); ++nTab ) { - aState = maTabs[nTab]->GetAllNoteCaptionsState( *pRange, aNotes ); + aState = maTabs[nTab]->GetAllNoteCaptionsState( rRange, aNotes ); if (aState == CommentCaptionState::MIXED) return aState; @@ -6706,14 +6703,14 @@ void ScDocument::GetAllNoteEntries( SCTAB nTab, std::vector<sc::NoteEntry>& rNot return pTab->GetAllNoteEntries( rNotes ); } -void ScDocument::GetNotesInRange( const ScRangeList& rRange, std::vector<sc::NoteEntry>& rNotes ) const +void ScDocument::GetNotesInRange( const ScRangeList& rRangeList, std::vector<sc::NoteEntry>& rNotes ) const { - for( size_t i = 0; i < rRange.size(); ++i) + for( size_t i = 0; i < rRangeList.size(); ++i) { - const ScRange* pRange = rRange[i]; - for( SCTAB nTab = pRange->aStart.Tab(); nTab <= pRange->aEnd.Tab(); ++nTab ) + const ScRange & rRange = rRangeList[i]; + for( SCTAB nTab = rRange.aStart.Tab(); nTab <= rRange.aEnd.Tab(); ++nTab ) { - maTabs[nTab]->GetNotesInRange( *pRange, rNotes ); + maTabs[nTab]->GetNotesInRange( rRange, rNotes ); } } } @@ -6723,14 +6720,14 @@ void ScDocument::GetUnprotectedCells( ScRangeList& rRangeList, SCTAB nTab ) cons maTabs[nTab]->GetUnprotectedCells( rRangeList ); } -bool ScDocument::ContainsNotesInRange( const ScRangeList& rRange ) const +bool ScDocument::ContainsNotesInRange( const ScRangeList& rRangeList ) const { - for( size_t i = 0; i < rRange.size(); ++i) + for( size_t i = 0; i < rRangeList.size(); ++i) { - const ScRange* pRange = rRange[i]; - for( SCTAB nTab = pRange->aStart.Tab(); nTab < pRange->aEnd.Tab(); ++nTab ) + const ScRange & rRange = rRangeList[i]; + for( SCTAB nTab = rRange.aStart.Tab(); nTab < rRange.aEnd.Tab(); ++nTab ) { - bool bContainsNote = maTabs[nTab]->ContainsNotesInRange( *pRange ); + bool bContainsNote = maTabs[nTab]->ContainsNotesInRange( rRange ); if(bContainsNote) return true; } diff --git a/sc/source/core/data/drwlayer.cxx b/sc/source/core/data/drwlayer.cxx index d15cd9d84108..341444525220 100644 --- a/sc/source/core/data/drwlayer.cxx +++ b/sc/source/core/data/drwlayer.cxx @@ -1426,8 +1426,8 @@ static bool lcl_IsAllInRange( const ::std::vector< ScRangeList >& rRangesVector, const ScRangeList& rRanges = *aIt; for ( size_t i = 0, nCount = rRanges.size(); i < nCount; i++ ) { - ScRange aRange = *rRanges[ i ]; - if ( !rClipRange.In( aRange ) ) + const ScRange & rRange = rRanges[ i ]; + if ( !rClipRange.In( rRange ) ) { return false; // at least one range is not valid } @@ -1448,13 +1448,13 @@ static bool lcl_MoveRanges( ::std::vector< ScRangeList >& rRangesVector, const S ScRangeList& rRanges = *aIt; for ( size_t i = 0, nCount = rRanges.size(); i < nCount; i++ ) { - ScRange* pRange = rRanges[ i ]; - if ( rSourceRange.In( *pRange ) ) + ScRange aRange = rRanges[ i ]; + if ( rSourceRange.In( aRange ) ) { SCCOL nDiffX = rDestPos.Col() - rSourceRange.aStart.Col(); SCROW nDiffY = rDestPos.Row() - rSourceRange.aStart.Row(); SCTAB nDiffZ = rDestPos.Tab() - rSourceRange.aStart.Tab(); - if (!pRange->Move( nDiffX, nDiffY, nDiffZ, aErrorRange)) + if (!aRange.Move( nDiffX, nDiffY, nDiffZ, aErrorRange)) { assert(!"can't move range"); } diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx index ebaefc38f7d3..04cfe1c0bb3e 100644 --- a/sc/source/core/data/formulacell.cxx +++ b/sc/source/core/data/formulacell.cxx @@ -4291,12 +4291,12 @@ struct ScDependantsCalculator for (size_t i = 0; i < aRangeList.size(); ++i) { - const ScRange* pRange = aRangeList[i]; - assert(pRange->aStart.Tab() == pRange->aEnd.Tab()); - for (auto nCol = pRange->aStart.Col(); nCol <= pRange->aEnd.Col(); nCol++) + const ScRange & rRange = aRangeList[i]; + assert(rRange.aStart.Tab() == rRange.aEnd.Tab()); + for (auto nCol = rRange.aStart.Col(); nCol <= rRange.aEnd.Col(); nCol++) { - if (!mrDoc.HandleRefArrayForParallelism(ScAddress(nCol, pRange->aStart.Row(), pRange->aStart.Tab()), - pRange->aEnd.Row() - pRange->aStart.Row() + 1)) + if (!mrDoc.HandleRefArrayForParallelism(ScAddress(nCol, rRange.aStart.Row(), rRange.aStart.Tab()), + rRange.aEnd.Row() - rRange.aStart.Row() + 1)) return false; } } diff --git a/sc/source/core/data/markdata.cxx b/sc/source/core/data/markdata.cxx index 73a22ae25760..ecd2b2ecaf13 100644 --- a/sc/source/core/data/markdata.cxx +++ b/sc/source/core/data/markdata.cxx @@ -341,7 +341,7 @@ void ScMarkData::MarkFromRangeList( const ScRangeList& rList, bool bReset ) size_t nCount = rList.size(); if ( nCount == 1 && !bMarked && !bMultiMarked ) { - const ScRange& rRange = *rList[ 0 ]; + const ScRange& rRange = rList[ 0 ]; SetMarkArea( rRange ); SelectTable( rRange.aStart.Tab(), true ); } @@ -349,7 +349,7 @@ void ScMarkData::MarkFromRangeList( const ScRangeList& rList, bool bReset ) { for (size_t i=0; i < nCount; i++) { - const ScRange& rRange = *rList[ i ]; + const ScRange& rRange = rList[ i ]; SetMultiMarkArea( rRange ); SelectTable( rRange.aStart.Tab(), true ); } @@ -405,13 +405,13 @@ void ScMarkData::FillRangeListWithMarks( ScRangeList* pList, bool bClear, SCTAB if ( bMarked ) { if (nForTab < 0) - pList->Append( aMarkRange ); + pList->push_back( aMarkRange ); else { ScRange aRange( aMarkRange ); aRange.aStart.SetTab( nForTab ); aRange.aEnd.SetTab( nForTab ); - pList->Append( aRange ); + pList->push_back( aRange ); } } } @@ -428,10 +428,10 @@ void ScMarkData::ExtendRangeListTables( ScRangeList* pList ) const for (; it != maTabMarked.end(); ++it) for ( size_t i=0, nCount = aOldList.size(); i<nCount; i++) { - ScRange aRange = *aOldList[ i ]; + ScRange aRange = aOldList[ i ]; aRange.aStart.SetTab(*it); aRange.aEnd.SetTab(*it); - pList->Append( aRange ); + pList->push_back( aRange ); } } @@ -459,7 +459,7 @@ std::vector<sc::ColRowSpan> ScMarkData::GetMarkedRowSpans() const for (size_t i = 0, n = aRanges.size(); i < n; ++i) { - const ScRange& r = *aRanges[i]; + const ScRange& r = aRanges[i]; itPos = aSpans.insert(itPos, r.aStart.Row(), r.aEnd.Row()+1, true).first; } @@ -706,7 +706,7 @@ void ScMarkData::GetSelectionCover( ScRange& rRange ) ScRange aAddRange(nCol - 1, nTop, aMultiRange.aStart.Tab(), nCol - 1, nBottom, aMultiRange.aStart.Tab()); lcl_AddRanges( rRange, aAddRange ); // Left envelope - aLeftEnvelope.Append( aAddRange ); + aLeftEnvelope.push_back( aAddRange ); } else if( nCol > nStartCol ) { @@ -728,7 +728,7 @@ void ScMarkData::GetSelectionCover( ScRange& rRange ) ScRange aAddRange( nCol - 1, nTop1, aMultiRange.aStart.Tab(), nCol - 1, nBottom1, aMultiRange.aStart.Tab() ); lcl_AddRanges( rRange, aAddRange ); // Left envelope - aLeftEnvelope.Append( aAddRange ); + aLeftEnvelope.push_back( aAddRange ); nTop1 = ++nBottom1; } } @@ -747,7 +747,7 @@ void ScMarkData::GetSelectionCover( ScRange& rRange ) ScRange aAddRange( nCol, nTopPrev, aMultiRange.aStart.Tab(), nCol, nBottomPrev, aMultiRange.aStart.Tab()); lcl_AddRanges( rRange, aAddRange ); // Right envelope - aRightEnvelope.Append( aAddRange ); + aRightEnvelope.push_back( aAddRange ); nTopPrev = nBottomPrev = (nBottom + 1); } else @@ -755,7 +755,7 @@ void ScMarkData::GetSelectionCover( ScRange& rRange ) ScRange aAddRange( nCol, nTopPrev, aMultiRange.aStart.Tab(), nCol, nBottomPrev, aMultiRange.aStart.Tab()); lcl_AddRanges( rRange, aAddRange ); // Right envelope - aRightEnvelope.Append( aAddRange ); + aRightEnvelope.push_back( aAddRange ); nTopPrev = ++nBottomPrev; } } @@ -795,7 +795,7 @@ void ScMarkData::GetSelectionCover( ScRange& rRange ) ScRange aAddRange(nCol, nTopPrev, aMultiRange.aStart.Tab(), nCol, nBottomPrev, aMultiRange.aStart.Tab()); lcl_AddRanges( rRange, aAddRange ); // Right envelope - aRightEnvelope.Append( aAddRange ); + aRightEnvelope.push_back( aAddRange ); nTopPrev = ++nBottomPrev; } else @@ -820,7 +820,7 @@ void ScMarkData::GetSelectionCover( ScRange& rRange ) ScRange aAddRange(nCol, nTopPrev, aMultiRange.aStart.Tab(), nCol, nBottomPrev, aMultiRange.aStart.Tab()); lcl_AddRanges( rRange, aAddRange ); // Right envelope - aRightEnvelope.Append( aAddRange ); + aRightEnvelope.push_back( aAddRange ); nTopPrev = ++nBottomPrev; } else @@ -844,7 +844,7 @@ void ScMarkData::GetSelectionCover( ScRange& rRange ) if( !rKV.second.getRangeData( nStart, aRange ) ) break; if( aRange.mbValue ) // is marked - aTopEnvelope.Append( ScRange( aRange.mnCol1, rKV.first, aMultiRange.aStart.Tab(), + aTopEnvelope.push_back( ScRange( aRange.mnCol1, rKV.first, aMultiRange.aStart.Tab(), aRange.mnCol2, rKV.first, aMultiRange.aStart.Tab() ) ); nStart = aRange.mnCol2 + 1; } @@ -858,7 +858,7 @@ void ScMarkData::GetSelectionCover( ScRange& rRange ) if( !rKV.second.getRangeData( nStart, aRange ) ) break; if( aRange.mbValue ) // is marked - aBottomEnvelope.Append( ScRange( aRange.mnCol1, rKV.first, aMultiRange.aStart.Tab(), + aBottomEnvelope.push_back( ScRange( aRange.mnCol1, rKV.first, aMultiRange.aStart.Tab(), aRange.mnCol2, rKV.first, aMultiRange.aStart.Tab() ) ); nStart = aRange.mnCol2 + 1; } @@ -878,22 +878,22 @@ void ScMarkData::GetSelectionCover( ScRange& rRange ) // Each envelope will have zero or more ranges for single rectangle selection. if( nCol1 > 0 ) { - aLeftEnvelope.Append( ScRange( nCol1 - 1, nRow1, nTab1, nCol1 - 1, nRow2, nTab2 ) ); + aLeftEnvelope.push_back( ScRange( nCol1 - 1, nRow1, nTab1, nCol1 - 1, nRow2, nTab2 ) ); --nCol1New; } if( nRow1 > 0 ) { - aTopEnvelope.Append( ScRange( nCol1, nRow1 - 1, nTab1, nCol2, nRow1 - 1, nTab2 ) ); + aTopEnvelope.push_back( ScRange( nCol1, nRow1 - 1, nTab1, nCol2, nRow1 - 1, nTab2 ) ); --nRow1New; } if( nCol2 < MAXCOL ) { - aRightEnvelope.Append( ScRange( nCol2 + 1, nRow1, nTab1, nCol2 + 1, nRow2, nTab2 ) ); + aRightEnvelope.push_back( ScRange( nCol2 + 1, nRow1, nTab1, nCol2 + 1, nRow2, nTab2 ) ); ++nCol2New; } if( nRow2 < MAXROW ) { - aBottomEnvelope.Append( ScRange( nCol1, nRow2 + 1, nTab1, nCol2, nRow2 + 1, nTab2 ) ); + aBottomEnvelope.push_back( ScRange( nCol1, nRow2 + 1, nTab1, nCol2, nRow2 + 1, nTab2 ) ); ++nRow2New; } rRange = ScRange( nCol1New, nRow1New, nTab1, nCol2New, nRow2New, nTab2 ); diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx index adb40b67a0c0..67e4da17f9c8 100644 --- a/sc/source/core/data/table2.cxx +++ b/sc/source/core/data/table2.cxx @@ -461,10 +461,10 @@ void ScTable::DeleteSelection( InsertDeleteFlags nDelFlag, const ScMarkData& rMa for (size_t i = 0; i < aRangeList.size(); ++i) { - ScRange* pRange = aRangeList[i]; + const ScRange & rRange = aRangeList[i]; - if((nDelFlag & InsertDeleteFlags::ATTRIB) && pRange && pRange->aStart.Tab() == nTab) - mpCondFormatList->DeleteArea( pRange->aStart.Col(), pRange->aStart.Row(), pRange->aEnd.Col(), pRange->aEnd.Row() ); + if((nDelFlag & InsertDeleteFlags::ATTRIB) && rRange.aStart.Tab() == nTab) + mpCondFormatList->DeleteArea( rRange.aStart.Col(), rRange.aStart.Row(), rRange.aEnd.Col(), rRange.aEnd.Row() ); } // Do not set protected cell in a protected sheet @@ -535,9 +535,8 @@ void ScTable::CopyToClip( { for ( size_t i = 0, nListSize = rRanges.size(); i < nListSize; ++i ) { - const ScRange* p = rRanges[ i ]; - if (p) - CopyToClip( rCxt, p->aStart.Col(), p->aStart.Row(), p->aEnd.Col(), p->aEnd.Row(), pTable); + const ScRange & r = rRanges[ i ]; + CopyToClip( rCxt, r.aStart.Col(), r.aStart.Row(), r.aEnd.Col(), r.aEnd.Row(), pTable); } } @@ -579,7 +578,7 @@ bool CheckAndDeduplicateCondFormat(ScDocument* pDocument, ScConditionalFormat* p ScRangeList& rDstRangeList = pOldFormat->GetRangeList(); for (size_t i = 0; i < rNewRangeList.size(); ++i) { - rDstRangeList.Join(*rNewRangeList[i]); + rDstRangeList.Join(rNewRangeList[i]); } pDocument->AddCondFormatData(pOldFormat->GetRange(), nTab, pOldFormat->GetKey()); return true; @@ -1365,8 +1364,8 @@ bool ScTable::HasScenarioRange( const ScRange& rRange ) const { for ( size_t j = 0, n = pList->size(); j < n; j++ ) { - const ScRange* pR = (*pList)[j]; - if ( pR->Intersects( aTabRange ) ) + const ScRange & rR = (*pList)[j]; + if ( rR.Intersects( aTabRange ) ) return true; } } @@ -2430,8 +2429,8 @@ bool ScTable::IsSelectionEditable( const ScMarkData& rMark, { for (size_t i=0, nRange = aRanges.size(); (i < nRange) && bIsEditable; i++ ) { - ScRange aRange = *aRanges[ i ]; - if(pDocument->HasScenarioRange(nScenTab, aRange)) + const ScRange & rRange = aRanges[ i ]; + if(pDocument->HasScenarioRange(nScenTab, rRange)) { ScScenarioFlags nFlags; pDocument->GetScenarioFlags(nScenTab,nFlags); @@ -2459,8 +2458,8 @@ bool ScTable::IsSelectionEditable( const ScMarkData& rMark, rMark.FillRangeListWithMarks( &aRanges, false ); for (size_t i = 0, nRange = aRanges.size(); (i < nRange) && bIsEditable; i++) { - ScRange aRange = *aRanges[ i ]; - if(pDocument->HasScenarioRange(nTab, aRange)) + const ScRange & rRange = aRanges[ i ]; + if(pDocument->HasScenarioRange(nTab, rRange)) { ScScenarioFlags nFlags; pDocument->GetScenarioFlags(nTab,nFlags); @@ -2575,16 +2574,16 @@ void ScTable::ApplyPatternIfNumberformatIncompatible( const ScRange& rRange, } } -void ScTable::AddCondFormatData( const ScRangeList& rRange, sal_uInt32 nIndex ) +void ScTable::AddCondFormatData( const ScRangeList& rRangeList, sal_uInt32 nIndex ) { - size_t n = rRange.size(); + size_t n = rRangeList.size(); for(size_t i = 0; i < n; ++i) { - const ScRange* pRange = rRange[i]; - SCCOL nColStart = pRange->aStart.Col(); - SCCOL nColEnd = pRange->aEnd.Col(); - SCROW nRowStart = pRange->aStart.Row(); - SCROW nRowEnd = pRange->aEnd.Row(); + const ScRange & rRange = rRangeList[i]; + SCCOL nColStart = rRange.aStart.Col(); + SCCOL nColEnd = rRange.aEnd.Col(); + SCROW nRowStart = rRange.aStart.Row(); + SCROW nRowEnd = rRange.aEnd.Row(); for(SCCOL nCol = nColStart; nCol <= nColEnd; ++nCol) { aCol[nCol].AddCondFormat(nRowStart, nRowEnd, nIndex); @@ -2592,16 +2591,16 @@ void ScTable::AddCondFormatData( const ScRangeList& rRange, sal_uInt32 nIndex ) } } -void ScTable::RemoveCondFormatData( const ScRangeList& rRange, sal_uInt32 nIndex ) +void ScTable::RemoveCondFormatData( const ScRangeList& rRangeList, sal_uInt32 nIndex ) { - size_t n = rRange.size(); + size_t n = rRangeList.size(); for(size_t i = 0; i < n; ++i) { - const ScRange* pRange = rRange[i]; - SCCOL nColStart = pRange->aStart.Col(); - SCCOL nColEnd = pRange->aEnd.Col(); - SCROW nRowStart = pRange->aStart.Row(); - SCROW nRowEnd = pRange->aEnd.Row(); + const ScRange & rRange = rRangeList[i]; + SCCOL nColStart = rRange.aStart.Col(); + SCCOL nColEnd = rRange.aEnd.Col(); + SCROW nRowStart = rRange.aStart.Row(); + SCROW nRowEnd = rRange.aEnd.Row(); for(SCCOL nCol = nColStart; nCol <= nColEnd; ++nCol) { aCol[nCol].RemoveCondFormat(nRowStart, nRowEnd, nIndex); diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx index 5d374368228b..217c74d3823d 100644 --- a/sc/source/core/data/table3.cxx +++ b/sc/source/core/data/table3.cxx @@ -1235,7 +1235,7 @@ void ScTable::SortReorderByRowRefUpdate( // could be anywhere in the sorted range after reordering. for (size_t i = 0, n = aTmp.size(); i < n; ++i) { - ScRange aRange = *aTmp[i]; + ScRange aRange = aTmp[i]; if (!aMoveRange.Intersects(aRange)) { // Doesn't overlap with the sorted range at all. diff --git a/sc/source/core/data/table6.cxx b/sc/source/core/data/table6.cxx index 4e0666846cb0..efdb51803935 100644 --- a/sc/source/core/data/table6.cxx +++ b/sc/source/core/data/table6.cxx @@ -842,8 +842,7 @@ bool ScTable::SearchAndReplaceEmptyCells( GetFirstDataPos(nColStart, nRowStart); GetLastDataPos(nColEnd, nRowEnd); - ScRangeList aRanges; - aRanges.Append(ScRange(nColStart, nRowStart, nTab, nColEnd, nRowEnd, nTab)); + ScRangeList aRanges(ScRange(nColStart, nRowStart, nTab, nColEnd, nRowEnd, nTab)); if (rSearchItem.GetSelection()) { @@ -856,23 +855,23 @@ bool ScTable::SearchAndReplaceEmptyCells( rMark.FillRangeListWithMarks(&aMarkedRanges, true); for ( size_t i = 0, n = aMarkedRanges.size(); i < n; ++i ) { - ScRange* p = aMarkedRanges[ i ]; - if (p->aStart.Col() > nColEnd || p->aStart.Row() > nRowEnd || p->aEnd.Col() < nColStart || p->aEnd.Row() < nRowStart) + ScRange & rRange = aMarkedRanges[ i ]; + if (rRange.aStart.Col() > nColEnd || rRange.aStart.Row() > nRowEnd || rRange.aEnd.Col() < nColStart || rRange.aEnd.Row() < nRowStart) // This range is outside the data area. Skip it. continue; // Shrink the range into data area only. - if (p->aStart.Col() < nColStart) - p->aStart.SetCol(nColStart); - if (p->aStart.Row() < nRowStart) - p->aStart.SetRow(nRowStart); + if (rRange.aStart.Col() < nColStart) + rRange.aStart.SetCol(nColStart); + if (rRange.aStart.Row() < nRowStart) + rRange.aStart.SetRow(nRowStart); - if (p->aEnd.Col() > nColEnd) - p->aEnd.SetCol(nColEnd); - if (p->aEnd.Row() > nRowEnd) - p->aEnd.SetRow(nRowEnd); + if (rRange.aEnd.Col() > nColEnd) + rRange.aEnd.SetCol(nColEnd); + if (rRange.aEnd.Row() > nRowEnd) + rRange.aEnd.SetRow(nRowEnd); - aNewRanges.Append(*p); + aNewRanges.push_back(rRange); } aRanges = aNewRanges; } @@ -884,8 +883,8 @@ bool ScTable::SearchAndReplaceEmptyCells( { for ( size_t i = aRanges.size(); i > 0; --i ) { - ScRange* p = aRanges[ i - 1 ]; - if (SearchRangeForEmptyCell(*p, rSearchItem, rCol, rRow, rUndoStr)) + const ScRange & rRange = aRanges[ i - 1 ]; + if (SearchRangeForEmptyCell(rRange, rSearchItem, rCol, rRow, rUndoStr)) return true; } } @@ -893,8 +892,8 @@ bool ScTable::SearchAndReplaceEmptyCells( { for ( size_t i = 0, nListSize = aRanges.size(); i < nListSize; ++i ) { - ScRange* p = aRanges[ i ]; - if (SearchRangeForEmptyCell(*p, rSearchItem, rCol, rRow, rUndoStr)) + const ScRange & rRange = aRanges[ i ]; + if (SearchRangeForEmptyCell(rRange, rSearchItem, rCol, rRow, rUndoStr)) return true; } } @@ -904,8 +903,8 @@ bool ScTable::SearchAndReplaceEmptyCells( bool bFound = false; for ( size_t i = 0, nListSize = aRanges.size(); i < nListSize; ++i ) { - ScRange* p = aRanges[ i ]; - bFound |= SearchRangeForAllEmptyCells(*p, rSearchItem, rMatchedRanges, rUndoStr, pUndoDoc); + ScRange const & rRange = aRanges[ i ]; + bFound |= SearchRangeForAllEmptyCells(rRange, rSearchItem, rMatchedRanges, rUndoStr, pUndoDoc); } return bFound; } diff --git a/sc/source/core/data/tabprotection.cxx b/sc/source/core/data/tabprotection.cxx index 05b53d16e551..3deb5504fa24 100644 --- a/sc/source/core/data/tabprotection.cxx +++ b/sc/source/core/data/tabprotection.cxx @@ -489,7 +489,7 @@ bool ScTableProtectionImpl::isBlockEditable( const ScRange& rRange ) const if (!(*it).hasSecurityDescriptor() && (*it).maRangeList.is()) { ScRangeList aList( (*it).maRangeList->GetIntersectedRange( rRange)); - if (aList.size() == 1 && *aList[0] == rRange) + if (aList.size() == 1 && aList[0] == rRange) { // Range is editable if no password is assigned. if (!(*it).hasPassword()) @@ -516,13 +516,13 @@ bool ScTableProtectionImpl::isBlockEditable( const ScRange& rRange ) const size_t nRanges = rRanges.size(); for (size_t i=0; i < nRanges; ++i) { - aRangeList.Append( *rRanges[i]); + aRangeList.push_back( rRanges[i]); } } } } ScRangeList aResultList( aRangeList.GetIntersectedRange( rRange)); - return aResultList.size() == 1 && *aResultList[0] == rRange; + return aResultList.size() == 1 && aResultList[0] == rRange; } bool ScTableProtectionImpl::isSelectionEditable( const ScRangeList& rRangeList ) const @@ -532,7 +532,7 @@ bool ScTableProtectionImpl::isSelectionEditable( const ScRangeList& rRangeList ) for (size_t i=0, nRanges = rRangeList.size(); i < nRanges; ++i) { - if (!isBlockEditable( *rRangeList[i])) + if (!isBlockEditable( rRangeList[i])) return false; } return true; diff --git a/sc/source/core/tool/chartarr.cxx b/sc/source/core/tool/chartarr.cxx index 6b020b0e3049..ef73e5727c48 100644 --- a/sc/source/core/tool/chartarr.cxx +++ b/sc/source/core/tool/chartarr.cxx @@ -68,8 +68,8 @@ ScMemChart* ScChartArray::CreateMemChart() return CreateMemChartMulti(); else if ( nCount == 1 ) { - ScRange* pR = aRangeListRef->front(); - if ( pR->aStart.Tab() != pR->aEnd.Tab() ) + const ScRange & rR = aRangeListRef->front(); + if ( rR.aStart.Tab() != rR.aEnd.Tab() ) return CreateMemChartMulti(); else return CreateMemChartSingle(); @@ -129,7 +129,7 @@ ScMemChart* ScChartArray::CreateMemChartSingle() SCROW nRow2; SCTAB nTab2; ScRangeListRef aRangeListRef(GetRangeList()); - aRangeListRef->front()->GetVars( nCol1, nRow1, nTab1, nCol2, nRow2, nTab2 ); + aRangeListRef->front().GetVars( nCol1, nRow1, nTab1, nCol2, nRow2, nTab2 ); SCCOL nStrCol = nCol1; // remember for labeling SCROW nStrRow = nRow1; diff --git a/sc/source/core/tool/charthelper.cxx b/sc/source/core/tool/charthelper.cxx index 12e05fa415e9..79140b928142 100644 --- a/sc/source/core/tool/charthelper.cxx +++ b/sc/source/core/tool/charthelper.cxx @@ -76,21 +76,21 @@ bool lcl_AdjustRanges( ScRangeList& rRanges, SCTAB nSourceTab, SCTAB nDestTab, S for ( size_t i=0, nCount = rRanges.size(); i < nCount; i++ ) { - ScRange* pRange = rRanges[ i ]; - if ( pRange->aStart.Tab() == nSourceTab && pRange->aEnd.Tab() == nSourceTab ) + ScRange & rRange = rRanges[ i ]; + if ( rRange.aStart.Tab() == nSourceTab && rRange.aEnd.Tab() == nSourceTab ) { - pRange->aStart.SetTab( nDestTab ); - pRange->aEnd.SetTab( nDestTab ); + rRange.aStart.SetTab( nDestTab ); + rRange.aEnd.SetTab( nDestTab ); bChanged = true; } - if ( pRange->aStart.Tab() >= nTabCount ) + if ( rRange.aStart.Tab() >= nTabCount ) { - pRange->aStart.SetTab( nTabCount > 0 ? ( nTabCount - 1 ) : 0 ); + rRange.aStart.SetTab( nTabCount > 0 ? ( nTabCount - 1 ) : 0 ); bChanged = true; } - if ( pRange->aEnd.Tab() >= nTabCount ) + if ( rRange.aEnd.Tab() >= nTabCount ) { - pRange->aEnd.SetTab( nTabCount > 0 ? ( nTabCount - 1 ) : 0 ); + rRange.aEnd.SetTab( nTabCount > 0 ? ( nTabCount - 1 ) : 0 ); bChanged = true; } } @@ -417,8 +417,7 @@ void ScChartHelper::CreateProtectedChartListenersAndNotify( ScDocument* pDoc, co { tools::Rectangle aRectangle = pSdrOle2Obj->GetSnapRect(); ScRange aRange( pDoc->GetRange( nTab, aRectangle ) ); - ScRangeList aChangeRanges; - aChangeRanges.Append( aRange ); + ScRangeList aChangeRanges( aRange ); uno::Sequence< beans::PropertyValue > aProperties( 1 ); aProperties[ 0 ].Name = "Name"; diff --git a/sc/source/core/tool/chartpos.cxx b/sc/source/core/tool/chartpos.cxx index db2469d853e5..fb78be869573 100644 --- a/sc/source/core/tool/chartpos.cxx +++ b/sc/source/core/tool/chartpos.cxx @@ -90,8 +90,7 @@ ScChartPositioner::~ScChartPositioner() void ScChartPositioner::SetRangeList( const ScRange& rRange ) { - aRangeListRef = new ScRangeList; - aRangeListRef->Append( rRange ); + aRangeListRef = new ScRangeList( rRange ); InvalidateGlue(); } @@ -105,7 +104,7 @@ void ScChartPositioner::GlueState() { if ( !aRangeListRef->empty() ) { - pR = aRangeListRef->front(); + pR = &aRangeListRef->front(); if ( pR->aStart.Tab() == pR->aEnd.Tab() ) eGlue = ScChartGlue::NONE; else @@ -122,7 +121,7 @@ void ScChartPositioner::GlueState() return; } - pR = aRangeListRef->front(); + pR = &aRangeListRef->front(); nStartCol = pR->aStart.Col(); nStartRow = pR->aStart.Row(); SCCOL nMaxCols, nEndCol; @@ -143,7 +142,7 @@ void ScChartPositioner::GlueState() // in last pass; i = nRanges so don't use at() if ( i < nRanges ) - pR = (*aRangeListRef)[i]; + pR = &(*aRangeListRef)[i]; } SCCOL nC = nEndCol - nStartCol + 1; if ( nC == 1 ) @@ -176,7 +175,7 @@ void ScChartPositioner::GlueState() SCROW nRow, nRow1, nRow2; for ( size_t i = 0, nRanges = aRangeListRef->size(); i < nRanges; ++i ) { // mark selections as used in 2D - pR = (*aRangeListRef)[i]; + pR = &(*aRangeListRef)[i]; nCol1 = pR->aStart.Col() - nStartCol; nCol2 = pR->aEnd.Col() - nStartCol; nRow1 = pR->aStart.Row() - nStartRow; @@ -274,7 +273,7 @@ void ScChartPositioner::CheckColRowHeaders() GlueState(); if ( aRangeListRef->size() == 1 ) { - aRangeListRef->front()->GetVars( nCol1, nRow1, nTab1, nCol2, nRow2, nTab2 ); + aRangeListRef->front().GetVars( nCol1, nRow1, nTab1, nCol2, nRow2, nTab2 ); if ( nCol1 > nCol2 || nRow1 > nRow2 ) bColStrings = bRowStrings = false; else @@ -299,8 +298,8 @@ void ScChartPositioner::CheckColRowHeaders() ++i ) { - ScRange* pR = (*aRangeListRef)[i]; - pR->GetVars( nCol1, nRow1, nTab1, nCol2, nRow2, nTab2 ); + const ScRange & rR = (*aRangeListRef)[i]; + rR.GetVars( nCol1, nRow1, nTab1, nCol2, nRow2, nTab2 ); bool bTopRow = (nRow1 == nStartRow); if ( bRowStrings && (bVert || nCol1 == nStartCol) ) { // NONE or ROWS: RowStrings in every selection possible @@ -362,8 +361,8 @@ void ScChartPositioner::CreatePositionMap() SCROW nNoGlueRow = 0; for ( size_t i = 0, nRanges = aRangeListRef->size(); i < nRanges; ++i ) { - ScRange* pR = (*aRangeListRef)[i]; - pR->GetVars( nCol1, nRow1, nTab1, nCol2, nRow2, nTab2 ); + const ScRange & rR = (*aRangeListRef)[i]; + rR.GetVars( nCol1, nRow1, nTab1, nCol2, nRow2, nTab2 ); for ( nTab = nTab1; nTab <= nTab2; nTab++ ) { // nTab in ColKey to allow to have the same col/row in another table diff --git a/sc/source/core/tool/dbdata.cxx b/sc/source/core/tool/dbdata.cxx index efb3f15671cf..75ff41b8f99a 100644 --- a/sc/source/core/tool/dbdata.cxx +++ b/sc/source/core/tool/dbdata.cxx @@ -1398,11 +1398,11 @@ void ScDBCollection::RefreshDirtyTableColumnNames() { for (size_t i=0; i < maNamedDBs.maDirtyTableColumnNames.size(); ++i) { - const ScRange* pRange = maNamedDBs.maDirtyTableColumnNames[i]; + const ScRange & rRange = maNamedDBs.maDirtyTableColumnNames[i]; for (auto const& it : maNamedDBs) { if (it->AreTableColumnNamesDirty()) - it->RefreshTableColumnNames( &maNamedDBs.mrDoc, *pRange); + it->RefreshTableColumnNames( &maNamedDBs.mrDoc, rRange); } } maNamedDBs.maDirtyTableColumnNames.RemoveAll(); diff --git a/sc/source/core/tool/rangelst.cxx b/sc/source/core/tool/rangelst.cxx index 0513d258a634..3b68a8fd5032 100644 --- a/sc/source/core/tool/rangelst.cxx +++ b/sc/source/core/tool/rangelst.cxx @@ -42,9 +42,9 @@ class FindEnclosingRange { public: explicit FindEnclosingRange(const T& rTest) : mrTest(rTest) {} - bool operator() (const ScRange* pRange) const + bool operator() (const ScRange & rRange) const { - return pRange->In(mrTest); + return rRange.In(mrTest); } private: const T& mrTest; @@ -55,9 +55,9 @@ class FindRangeIn { public: FindRangeIn(const T& rTest) : mrTest(rTest) {} - bool operator() (const ScRange* pRange) const + bool operator() (const ScRange& rRange) const { - return mrTest.In(*pRange); + return mrTest.In(rRange); } private: const T& mrTest; @@ -68,9 +68,9 @@ class FindIntersectingRange { public: explicit FindIntersectingRange(const T& rTest) : mrTest(rTest) {} - bool operator() (const ScRange* pRange) const + bool operator() (const ScRange & rRange) const { - return pRange->Intersects(mrTest); + return rRange.Intersects(mrTest); } private: const T& mrTest; @@ -79,13 +79,13 @@ private: class AppendToList { public: - explicit AppendToList(vector<ScRange*>& rRanges) : mrRanges(rRanges) {} - void operator() (const ScRange* p) + explicit AppendToList(vector<ScRange>& rRanges) : mrRanges(rRanges) {} + void operator() (const ScRange& r) { - mrRanges.push_back(new ScRange(*p)); + mrRanges.push_back(r); } private: - vector<ScRange*>& mrRanges; + vector<ScRange>& mrRanges; }; class CountCells @@ -93,12 +93,12 @@ class CountCells public: CountCells() : mnCellCount(0) {} - void operator() (const ScRange* p) + void operator() (const ScRange & r) { mnCellCount += - size_t(p->aEnd.Col() - p->aStart.Col() + 1) - * size_t(p->aEnd.Row() - p->aStart.Row() + 1) - * size_t(p->aEnd.Tab() - p->aStart.Tab() + 1); + size_t(r.aEnd.Col() - r.aStart.Col() + 1) + * size_t(r.aEnd.Row() - r.aStart.Row() + 1) + * size_t(r.aEnd.Tab() - r.aStart.Tab() + 1); } size_t getCellCount() const { return mnCellCount; } @@ -119,9 +119,9 @@ public: mbFirst(true), mbFullAddressNotation(bFullAddressNotation) {} - void operator() (const ScRange* p) + void operator() (const ScRange & r) { - OUString aStr(p->Format(mnFlags, mpDoc, meConv, mbFullAddressNotation)); + OUString aStr(r.Format(mnFlags, mpDoc, meConv, mbFullAddressNotation)); if (mbFirst) mbFirst = false; else @@ -175,7 +175,7 @@ ScRefFlags ScRangeList::Parse( const OUString& rStr, const ScDocument* pDoc, applyStartToEndFlags(nRes, nTmp1); if ( nRes & ScRefFlags::VALID ) - Append( aRange ); + push_back( aRange ); nResult &= nRes; // all common bits are preserved } while (nPos >= 0); @@ -200,11 +200,11 @@ void ScRangeList::Format( OUString& rStr, ScRefFlags nFlags, ScDocument* pDoc, rStr = aStr; } -void ScRangeList::Join( const ScRange& r, bool bIsInList ) +void ScRangeList::Join( const ScRange& rNewRange, bool bIsInList ) { if ( maRanges.empty() ) { - Append( r ); + push_back( rNewRange ); return ; } @@ -219,22 +219,22 @@ void ScRangeList::Join( const ScRange& r, bool bIsInList ) if (!bIsInList) { - const SCROW nRow1 = r.aStart.Row(); + const SCROW nRow1 = rNewRange.aStart.Row(); if (nRow1 > mnMaxRowUsed + 1) { - Append( r ); + push_back( rNewRange ); return; } else if (nRow1 == mnMaxRowUsed + 1) { // Check if we can simply enlarge the last range. - ScRange* p = maRanges.back(); - if (p->aEnd.Row() + 1 == nRow1 && - p->aStart.Col() == r.aStart.Col() && p->aEnd.Col() == r.aEnd.Col() && - p->aStart.Tab() == r.aStart.Tab() && p->aEnd.Tab() == r.aEnd.Tab()) + ScRange & rLast = maRanges.back(); + if (rLast.aEnd.Row() + 1 == nRow1 && + rLast.aStart.Col() == rNewRange.aStart.Col() && rLast.aEnd.Col() == rNewRange.aEnd.Col() && + rLast.aStart.Tab() == rNewRange.aStart.Tab() && rLast.aEnd.Tab() == rNewRange.aEnd.Tab()) { - const SCROW nRow2 = r.aEnd.Row(); - p->aEnd.SetRow( nRow2 ); + const SCROW nRow2 = rNewRange.aEnd.Row(); + rLast.aEnd.SetRow( nRow2 ); mnMaxRowUsed = nRow2; return; } @@ -242,7 +242,7 @@ void ScRangeList::Join( const ScRange& r, bool bIsInList ) } bool bJoinedInput = false; - const ScRange* pOver = &r; + const ScRange* pOver = &rNewRange; Label_Range_Join: @@ -257,14 +257,14 @@ Label_Range_Join: size_t nOverPos = std::numeric_limits<size_t>::max(); for (size_t i = 0; i < maRanges.size(); ++i) { - ScRange* p = maRanges[i]; - if ( p == pOver ) + ScRange & rRange = maRanges[i]; + if ( &rRange == pOver ) { nOverPos = i; continue; // the same one, continue with the next } bool bJoined = false; - if ( p->In( *pOver ) ) + if ( rRange.In( *pOver ) ) { // range pOver included in or identical to range p // XXX if we never used Append() before Join() we could remove // pOver and end processing, but it is not guaranteed and there can @@ -277,40 +277,40 @@ Label_Range_Join: break; // for } } - else if ( pOver->In( *p ) ) - { // range p included in range pOver, make pOver the new range - *p = *pOver; + else if ( pOver->In( rRange ) ) + { // range rRange included in range pOver, make pOver the new range + rRange = *pOver; bJoined = true; } - if ( !bJoined && p->aStart.Tab() == nTab1 && p->aEnd.Tab() == nTab2 ) + if ( !bJoined && rRange.aStart.Tab() == nTab1 && rRange.aEnd.Tab() == nTab2 ) { // 2D - if ( p->aStart.Col() == nCol1 && p->aEnd.Col() == nCol2 ) + if ( rRange.aStart.Col() == nCol1 && rRange.aEnd.Col() == nCol2 ) { - if ( p->aStart.Row() <= nRow2+1 && - p->aStart.Row() >= nRow1 ) + if ( rRange.aStart.Row() <= nRow2+1 && + rRange.aStart.Row() >= nRow1 ) { // top - p->aStart.SetRow( nRow1 ); + rRange.aStart.SetRow( nRow1 ); bJoined = true; } - else if ( p->aEnd.Row() >= nRow1-1 && - p->aEnd.Row() <= nRow2 ) + else if ( rRange.aEnd.Row() >= nRow1-1 && + rRange.aEnd.Row() <= nRow2 ) { // bottom - p->aEnd.SetRow( nRow2 ); + rRange.aEnd.SetRow( nRow2 ); bJoined = true; } } - else if ( p->aStart.Row() == nRow1 && p->aEnd.Row() == nRow2 ) + else if ( rRange.aStart.Row() == nRow1 && rRange.aEnd.Row() == nRow2 ) { - if ( p->aStart.Col() <= nCol2+1 && - p->aStart.Col() >= nCol1 ) + if ( rRange.aStart.Col() <= nCol2+1 && + rRange.aStart.Col() >= nCol1 ) { // left - p->aStart.SetCol( nCol1 ); + rRange.aStart.SetCol( nCol1 ); bJoined = true; } - else if ( p->aEnd.Col() >= nCol1-1 && - p->aEnd.Col() <= nCol2 ) + else if ( rRange.aEnd.Col() >= nCol1-1 && + rRange.aEnd.Col() <= nCol2 ) { // right - p->aEnd.SetCol( nCol2 ); + rRange.aEnd.SetCol( nCol2 ); bJoined = true; } } @@ -325,7 +325,7 @@ Label_Range_Join: { for (size_t nOver = 0, nRanges = maRanges.size(); nOver < nRanges; ++nOver) { - if (maRanges[nOver] == pOver) + if (&maRanges[nOver] == pOver) { Remove(nOver); break; @@ -334,13 +334,13 @@ Label_Range_Join: } } bJoinedInput = true; - pOver = p; + pOver = &rRange; bIsInList = true; goto Label_Range_Join; } } if ( !bIsInList && !bJoinedInput ) - Append( r ); + push_back( rNewRange ); } bool ScRangeList::operator==( const ScRangeList& r ) const @@ -351,13 +351,13 @@ bool ScRangeList::operator==( const ScRangeList& r ) const if (maRanges.size() != r.maRanges.size()) return false; - vector<ScRange*>::const_iterator itr1 = maRanges.begin(), itrEnd = maRanges.end(); - vector<ScRange*>::const_iterator itr2 = r.maRanges.begin(); + auto itr1 = maRanges.begin(), itrEnd = maRanges.end(); + auto itr2 = r.maRanges.begin(); for (; itr1 != itrEnd; ++itr1, ++itr2) { - const ScRange* p1 = *itr1; - const ScRange* p2 = *itr2; - if (*p1 != *p2) + const ScRange& r1 = *itr1; + const ScRange& r2 = *itr2; + if (r1 != r2) return false; } return true; @@ -413,14 +413,14 @@ bool ScRangeList::UpdateReference( iterator itr = maRanges.begin(), itrEnd = maRanges.end(); for (; itr != itrEnd; ++itr) { - ScRange* pR = *itr; + ScRange& rR = *itr; SCCOL theCol1; SCROW theRow1; SCTAB theTab1; SCCOL theCol2; SCROW theRow2; SCTAB theTab2; - pR->GetVars( theCol1, theRow1, theTab1, theCol2, theRow2, theTab2 ); + rR.GetVars( theCol1, theRow1, theTab1, theCol2, theRow2, theTab2 ); if ( ScRefUpdate::Update( pDoc, eUpdateRefMode, nCol1, nRow1, nTab1, nCol2, nRow2, nTab2, nDx, nDy, nDz, @@ -428,8 +428,8 @@ bool ScRangeList::UpdateReference( != UR_NOTHING ) { bChanged = true; - pR->aStart.Set( theCol1, theRow1, theTab1 ); - pR->aEnd.Set( theCol2, theRow2, theTab2 ); + rR.aStart.Set( theCol1, theRow1, theTab1 ); + rR.aEnd.Set( theCol2, theRow2, theTab2 ); if (mnMaxRowUsed < theRow2) mnMaxRowUsed = theRow2; } @@ -440,7 +440,7 @@ bool ScRangeList::UpdateReference( if( nDx < 0 || nDy < 0 ) { size_t n = maRanges.size(); - Join(*maRanges[n-1], true); + Join(maRanges[n-1], true); } } @@ -453,14 +453,14 @@ void ScRangeList::InsertRow( SCTAB nTab, SCCOL nColStart, SCCOL nColEnd, SCROW n for(iterator it = maRanges.begin(), itEnd = maRanges.end(); it != itEnd; ++it) { - ScRange* pRange = *it; - if(pRange->aStart.Tab() <= nTab && pRange->aEnd.Tab() >= nTab) + ScRange & rRange = *it; + if(rRange.aStart.Tab() <= nTab && rRange.aEnd.Tab() >= nTab) { - if(pRange->aEnd.Row() == nRowPos - 1 && (nColStart <= pRange->aEnd.Col() || nColEnd >= pRange->aStart.Col())) + if(rRange.aEnd.Row() == nRowPos - 1 && (nColStart <= rRange.aEnd.Col() || nColEnd >= rRange.aStart.Col())) { - SCCOL nNewRangeStartCol = std::max<SCCOL>(nColStart, pRange->aStart.Col()); - SCCOL nNewRangeEndCol = std::min<SCCOL>(nColEnd, pRange->aEnd.Col()); - SCROW nNewRangeStartRow = pRange->aEnd.Row() + 1; + SCCOL nNewRangeStartCol = std::max<SCCOL>(nColStart, rRange.aStart.Col()); + SCCOL nNewRangeEndCol = std::min<SCCOL>(nColEnd, rRange.aEnd.Col()); + SCROW nNewRangeStartRow = rRange.aEnd.Row() + 1; SCROW nNewRangeEndRow = nRowPos + nSize - 1; aNewRanges.emplace_back(nNewRangeStartCol, nNewRangeStartRow, nTab, nNewRangeEndCol, nNewRangeEndRow, nTab); @@ -486,14 +486,14 @@ void ScRangeList::InsertCol( SCTAB nTab, SCROW nRowStart, SCROW nRowEnd, SCCOL n for(iterator it = maRanges.begin(), itEnd = maRanges.end(); it != itEnd; ++it) { - ScRange* pRange = *it; - if(pRange->aStart.Tab() <= nTab && pRange->aEnd.Tab() >= nTab) + ScRange & rRange = *it; + if(rRange.aStart.Tab() <= nTab && rRange.aEnd.Tab() >= nTab) { ... etc. - the rest is truncated _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
