diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-03-13 17:02:09 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-03-15 07:30:26 +0100 |
commit | a3aceef8200e48173df4b5e67b5d6fb393a23ad9 (patch) | |
tree | 7b0b0b117c8e3c15c2b126b085d11a21c2446991 /sc/source/ui | |
parent | d775ef360168271f429466bbc174ae7dec402f1d (diff) |
don't use heap for elements in ScRangePairList
no need to store small objects like this out of line.
And use std::array for ScRangePair, so we get range checking in debug
mode.
Change-Id: Ie4690edbb4c3fdc4e08206cb016b8167a399d95a
Reviewed-on: https://gerrit.libreoffice.org/51268
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sc/source/ui')
-rw-r--r-- | sc/source/ui/miscdlgs/crnrdlg.cxx | 12 | ||||
-rw-r--r-- | sc/source/ui/unoobj/nameuno.cxx | 29 |
2 files changed, 18 insertions, 23 deletions
diff --git a/sc/source/ui/miscdlgs/crnrdlg.cxx b/sc/source/ui/miscdlgs/crnrdlg.cxx index 31df267e218f..8cbdf77a2b1c 100644 --- a/sc/source/ui/miscdlgs/crnrdlg.cxx +++ b/sc/source/ui/miscdlgs/crnrdlg.cxx @@ -391,7 +391,7 @@ void ScColRowNameRangesDlg::UpdateNames() pLbRange->SetEntryData( nPos, reinterpret_cast<void*>(nEntryDataDelim) ); if ( (nCount = xColNameRanges->size()) > 0 ) { - std::vector<ScRangePair*> aSortArray(xColNameRanges->CreateNameSortedArray( + std::vector<const ScRangePair*> aSortArray(xColNameRanges->CreateNameSortedArray( pDoc )); nCount = aSortArray.size(); for ( j=0; j < nCount; j++ ) @@ -435,7 +435,7 @@ void ScColRowNameRangesDlg::UpdateNames() pLbRange->SetEntryData( nPos, reinterpret_cast<void*>(nEntryDataDelim) ); if ( (nCount = xRowNameRanges->size()) > 0 ) { - std::vector<ScRangePair*> aSortArray(xRowNameRanges->CreateNameSortedArray( + std::vector<const ScRangePair*> aSortArray(xRowNameRanges->CreateNameSortedArray( pDoc )); nCount = aSortArray.size(); for ( j=0; j < nCount; j++ ) @@ -557,11 +557,11 @@ IMPL_LINK_NOARG(ScColRowNameRangesDlg, AddBtnHdl, Button*, void) ScRangePair* pPair; if ( ( pPair = xColNameRanges->Find( theCurArea ) ) != nullptr ) { - xColNameRanges->Remove( pPair ); + xColNameRanges->Remove( *pPair ); } if ( ( pPair = xRowNameRanges->Find( theCurArea ) ) != nullptr ) { - xRowNameRanges->Remove( pPair ); + xRowNameRanges->Remove( *pPair ); } if ( pBtnColHead->IsChecked() ) xColNameRanges->Join( ScRangePair( theCurArea, theCurData ) ); @@ -619,9 +619,9 @@ IMPL_LINK_NOARG(ScColRowNameRangesDlg, RemoveBtnHdl, Button*, void) if (RET_YES == QUERYBOX(GetFrameWeld(), aMsg)) { if ( bColName ) - xColNameRanges->Remove( pPair ); + xColNameRanges->Remove( *pPair ); else - xRowNameRanges->Remove( pPair ); + xRowNameRanges->Remove( *pPair ); UpdateNames(); const sal_Int32 nCnt = pLbRange->GetEntryCount(); diff --git a/sc/source/ui/unoobj/nameuno.cxx b/sc/source/ui/unoobj/nameuno.cxx index 1caa62e9920c..e1e7d1478c28 100644 --- a/sc/source/ui/unoobj/nameuno.cxx +++ b/sc/source/ui/unoobj/nameuno.cxx @@ -1041,9 +1041,8 @@ ScLabelRangeObj* ScLabelRangesObj::GetObjectByIndex_Impl(size_t nIndex) ScRangePairList* pList = bColumn ? rDoc.GetColNameRanges() : rDoc.GetRowNameRanges(); if ( pList && nIndex < pList->size() ) { - ScRangePair* pData = (*pList)[nIndex]; - if (pData) - return new ScLabelRangeObj( pDocShell, bColumn, pData->GetRange(0) ); + ScRangePair & rData = (*pList)[nIndex]; + return new ScLabelRangeObj( pDocShell, bColumn, rData.GetRange(0) ); } } return nullptr; @@ -1094,23 +1093,19 @@ void SAL_CALL ScLabelRangesObj::removeByIndex( sal_Int32 nIndex ) { ScRangePairListRef xNewList(pOldList->Clone()); - ScRangePair* pEntry = (*xNewList)[nIndex]; - if (pEntry) - { - xNewList->Remove( pEntry ); + xNewList->Remove( nIndex ); - if (bColumn) - rDoc.GetColNameRangesRef() = xNewList; - else - rDoc.GetRowNameRangesRef() = xNewList; + if (bColumn) + rDoc.GetColNameRangesRef() = xNewList; + else + rDoc.GetRowNameRangesRef() = xNewList; - rDoc.CompileColRowNameFormula(); - pDocShell->PostPaint( 0,0,0, MAXCOL,MAXROW,MAXTAB, PaintPartFlags::Grid ); - pDocShell->SetDocumentModified(); - bDone = true; + rDoc.CompileColRowNameFormula(); + pDocShell->PostPaint( 0,0,0, MAXCOL,MAXROW,MAXTAB, PaintPartFlags::Grid ); + pDocShell->SetDocumentModified(); + bDone = true; - //! Undo ?!?! (here and from dialog) - } + //! Undo ?!?! (here and from dialog) } } if (!bDone) |