diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-03-07 14:17:38 +0200 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2018-03-10 19:22:01 +0100 |
commit | 6529cd54c29c5800340530a1b8182c341fbeeafb (patch) | |
tree | 2b09ee9429a0759b8104575aa97e1f4aeadd443e /sc/source/ui/view/viewfun3.cxx | |
parent | 4ea605cb5c31fe4c7d3931a656782a652b4d96fc (diff) |
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 <ci@libreoffice.org>
Reviewed-by: Eike Rathke <erack@redhat.com>
Diffstat (limited to 'sc/source/ui/view/viewfun3.cxx')
-rw-r--r-- | sc/source/ui/view/viewfun3.cxx | 57 |
1 files changed, 27 insertions, 30 deletions
diff --git a/sc/source/ui/view/viewfun3.cxx b/sc/source/ui/view/viewfun3.cxx index 3afb0f466a32..7d6efcf45b3d 100644 --- a/sc/source/ui/view/viewfun3.cxx +++ b/sc/source/ui/view/viewfun3.cxx @@ -161,8 +161,7 @@ bool ScViewFunc::CopyToClip( ScDocument* pClipDoc, bool bCut, bool bApi, bool bI if ( eMarkType == SC_MARK_SIMPLE || eMarkType == SC_MARK_SIMPLE_FILTERED ) { - ScRangeList aRangeList; - aRangeList.Append( aRange ); + ScRangeList aRangeList( aRange ); bDone = CopyToClip( pClipDoc, aRangeList, bCut, bApi, bIncludeObjects, bStopEdit ); } else if (eMarkType == SC_MARK_MULTI) @@ -190,7 +189,7 @@ bool ScViewFunc::CopyToClip( ScDocument* pClipDoc, const ScRangeList& rRanges, b if ( bStopEdit ) UpdateInputLine(); - ScRange aRange = *rRanges[0]; + ScRange aRange = rRanges[0]; ScClipParam aClipParam( aRange, bCut ); aClipParam.maRanges = rRanges; @@ -304,26 +303,26 @@ bool ScViewFunc::CopyToClip( ScDocument* pClipDoc, const ScRangeList& rRanges, b // Check for geometrical feasibility of the ranges. bool bValidRanges = true; - ScRange* p = aClipParam.maRanges.front(); + ScRange & r = aClipParam.maRanges.front(); SCCOL nPrevColDelta = 0; SCROW nPrevRowDelta = 0; - SCCOL nPrevCol = p->aStart.Col(); - SCROW nPrevRow = p->aStart.Row(); - SCCOL nPrevColSize = p->aEnd.Col() - p->aStart.Col() + 1; - SCROW nPrevRowSize = p->aEnd.Row() - p->aStart.Row() + 1; + SCCOL nPrevCol = r.aStart.Col(); + SCROW nPrevRow = r.aStart.Row(); + SCCOL nPrevColSize = r.aEnd.Col() - r.aStart.Col() + 1; + SCROW nPrevRowSize = r.aEnd.Row() - r.aStart.Row() + 1; for ( size_t i = 1; i < aClipParam.maRanges.size(); ++i ) { - p = aClipParam.maRanges[i]; + r = aClipParam.maRanges[i]; if ( pDoc->HasSelectedBlockMatrixFragment( - p->aStart.Col(), p->aStart.Row(), p->aEnd.Col(), p->aEnd.Row(), rMark) ) + r.aStart.Col(), r.aStart.Row(), r.aEnd.Col(), r.aEnd.Row(), rMark) ) { if (!bApi) ErrorMessage(STR_MATRIXFRAGMENTERR); return false; } - SCCOL nColDelta = p->aStart.Col() - nPrevCol; - SCROW nRowDelta = p->aStart.Row() - nPrevRow; + SCCOL nColDelta = r.aStart.Col() - nPrevCol; + SCROW nRowDelta = r.aStart.Row() - nPrevRow; if ((nColDelta && nRowDelta) || (nPrevColDelta && nRowDelta) || (nPrevRowDelta && nColDelta)) { @@ -339,8 +338,8 @@ bool ScViewFunc::CopyToClip( ScDocument* pClipDoc, const ScRangeList& rRanges, b aClipParam.meDirection = ScClipParam::Row; } - SCCOL nColSize = p->aEnd.Col() - p->aStart.Col() + 1; - SCROW nRowSize = p->aEnd.Row() - p->aStart.Row() + 1; + SCCOL nColSize = r.aEnd.Col() - r.aStart.Col() + 1; + SCROW nRowSize = r.aEnd.Row() - r.aStart.Row() + 1; if (aClipParam.meDirection == ScClipParam::Column && nRowSize != nPrevRowSize) { @@ -356,8 +355,8 @@ bool ScViewFunc::CopyToClip( ScDocument* pClipDoc, const ScRangeList& rRanges, b break; } - nPrevCol = p->aStart.Col(); - nPrevRow = p->aStart.Row(); + nPrevCol = r.aStart.Col(); + nPrevRow = r.aStart.Row(); nPrevColDelta = nColDelta; nPrevRowDelta = nRowDelta; nPrevColSize = nColSize; @@ -831,7 +830,7 @@ bool checkDestRangeForOverwrite(const ScRangeList& rDestRanges, const ScDocument { for (size_t i = 0; i < nRangeSize && bIsEmpty; ++i) { - const ScRange& rRange = *rDestRanges[i]; + const ScRange& rRange = rDestRanges[i]; bIsEmpty = pDoc->IsBlockEmpty( *itrTab, rRange.aStart.Col(), rRange.aStart.Row(), rRange.aEnd.Col(), rRange.aEnd.Row()); @@ -1018,8 +1017,8 @@ bool ScViewFunc::PasteFromClip( InsertDeleteFlags nFlags, ScDocument* pClipDoc, size_t ListSize = aRangeList.size(); for ( size_t i = 0; i < ListSize; ++i ) { - ScRange* p = aRangeList[i]; - nUnfilteredRows += p->aEnd.Row() - p->aStart.Row() + 1; + ScRange & r = aRangeList[i]; + nUnfilteredRows += r.aEnd.Row() - r.aStart.Row() + 1; } #if 0 /* This isn't needed but could be a desired restriction. */ @@ -1141,8 +1140,7 @@ bool ScViewFunc::PasteFromClip( InsertDeleteFlags nFlags, ScDocument* pClipDoc, SC_MOD()->GetInputOptions().GetReplaceCellsWarn(); if ( bAskIfNotEmpty ) { - ScRangeList aTestRanges; - aTestRanges.Append(aUserRange); + ScRangeList aTestRanges(aUserRange); vcl::Window* pWin = GetViewData().GetDialogParent(); if (!checkDestRangeForOverwrite(aTestRanges, pDoc, aFilteredMark, pWin ? pWin->GetFrameWeld() : nullptr)) return false; @@ -1510,8 +1508,7 @@ bool ScViewFunc::PasteMultiRangesFromClip( if (bAskIfNotEmpty) { - ScRangeList aTestRanges; - aTestRanges.Append(aMarkedRange); + ScRangeList aTestRanges(aMarkedRange); vcl::Window* pWin = GetViewData().GetDialogParent(); if (!checkDestRangeForOverwrite(aTestRanges, pDoc, aMark, pWin ? pWin->GetFrameWeld() : nullptr)) return false; @@ -1688,7 +1685,7 @@ bool ScViewFunc::PasteFromClipToMultiRanges( for (size_t i = 0, n = aRanges.size(); i < n; ++i) { pDoc->CopyToDocument( - *aRanges[i], nUndoFlags, false, *pUndoDoc, &aMark); + aRanges[i], nUndoFlags, false, *pUndoDoc, &aMark); } } @@ -1702,7 +1699,7 @@ bool ScViewFunc::PasteFromClipToMultiRanges( for (size_t i = 0, n = aRanges.size(); i < n; ++i) { pDoc->CopyToDocument( - *aRanges[i], InsertDeleteFlags::CONTENTS, false, *pMixDoc, &aMark); + aRanges[i], InsertDeleteFlags::CONTENTS, false, *pMixDoc, &aMark); } } } @@ -1716,14 +1713,14 @@ bool ScViewFunc::PasteFromClipToMultiRanges( for (size_t i = 0, n = aRanges.size(); i < n; ++i) { pDoc->CopyFromClip( - *aRanges[i], aMark, (nFlags & ~InsertDeleteFlags::OBJECTS), nullptr, pClipDoc, + aRanges[i], aMark, (nFlags & ~InsertDeleteFlags::OBJECTS), nullptr, pClipDoc, false, false, true, bSkipEmpty); } if (pMixDoc.get()) { for (size_t i = 0, n = aRanges.size(); i < n; ++i) - pDoc->MixDocument(*aRanges[i], nFunction, bSkipEmpty, pMixDoc.get()); + pDoc->MixDocument(aRanges[i], nFunction, bSkipEmpty, pMixDoc.get()); } AdjustBlockHeight(); // update row heights before pasting objects @@ -1734,7 +1731,7 @@ bool ScViewFunc::PasteFromClipToMultiRanges( for (size_t i = 0, n = aRanges.size(); i < n; ++i) { pDoc->CopyFromClip( - *aRanges[i], aMark, InsertDeleteFlags::OBJECTS, nullptr, pClipDoc, + aRanges[i], aMark, InsertDeleteFlags::OBJECTS, nullptr, pClipDoc, false, false, true, bSkipEmpty); } } @@ -1790,14 +1787,14 @@ void ScViewFunc::PostPasteFromClip(const ScRangeList& rPasteRanges, const ScMark ScRangeList aChangeRanges; for (size_t i = 0, n = rPasteRanges.size(); i < n; ++i) { - const ScRange& r = *rPasteRanges[i]; + const ScRange& r = rPasteRanges[i]; ScMarkData::const_iterator itr = rMark.begin(), itrEnd = rMark.end(); for (; itr != itrEnd; ++itr) { ScRange aChangeRange(r); aChangeRange.aStart.SetTab(*itr); aChangeRange.aEnd.SetTab(*itr); - aChangeRanges.Append(aChangeRange); + aChangeRanges.push_back(aChangeRange); } } HelperNotifyChanges::Notify(*pModelObj, aChangeRanges); |