diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-05-31 11:20:42 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-06-01 08:49:35 +0200 |
commit | d95e54676039a593b797455674863ccd9a902d52 (patch) | |
tree | 97cd279fa6b5ec3dc89a85f241ca0fc017874312 | |
parent | 6fc8a6b0b52509d735971f079d7b1660559d475d (diff) |
no need to allocate these on the heap
Change-Id: I912b1aafcc615efb87455fa9ba02caf7bef044cd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116480
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r-- | sc/source/core/data/attarray.cxx | 26 | ||||
-rw-r--r-- | sc/source/core/data/column.cxx | 6 | ||||
-rw-r--r-- | sc/source/core/data/column2.cxx | 6 | ||||
-rw-r--r-- | sc/source/core/data/documen8.cxx | 6 | ||||
-rw-r--r-- | sc/source/core/data/patattr.cxx | 8 | ||||
-rw-r--r-- | sc/source/ui/view/viewfunc.cxx | 4 |
6 files changed, 27 insertions, 29 deletions
diff --git a/sc/source/core/data/attarray.cxx b/sc/source/core/data/attarray.cxx index d7683b601435..41fb51471c43 100644 --- a/sc/source/core/data/attarray.cxx +++ b/sc/source/core/data/attarray.cxx @@ -1529,12 +1529,11 @@ void ScAttrArray::RemoveAreaMerge(SCROW nStartRow, SCROW nEndRow) for (SCROW nThisRow = nThisStart; nThisRow <= nThisEnd; nThisRow++) rDocument.ApplyAttr( nThisCol, nThisRow, nTab, *pAttr ); - std::unique_ptr<ScPatternAttr> pNewPattern(new ScPatternAttr( rDocument.GetPool() )); - SfxItemSet* pSet = &pNewPattern->GetItemSet(); + ScPatternAttr aNewPattern( rDocument.GetPool() ); + SfxItemSet* pSet = &aNewPattern.GetItemSet(); pSet->Put( *pFlagAttr ); rDocument.ApplyPatternAreaTab( nThisCol, nThisStart, nMergeEndCol, nMergeEndRow, - nTab, *pNewPattern ); - pNewPattern.reset(); + nTab, aNewPattern ); Search( nThisEnd, nIndex ); // data changed } @@ -1819,15 +1818,14 @@ void ScAttrArray::FindStyleSheet( const SfxStyleSheetBase* pStyleSheet, ScFlatBo if (bReset) { - std::unique_ptr<ScPatternAttr> pNewPattern(new ScPatternAttr(*mvData[nPos].pPattern)); + ScPatternAttr aNewPattern(*mvData[nPos].pPattern); rDocument.GetPool()->Remove(*mvData[nPos].pPattern); - pNewPattern->SetStyleSheet( static_cast<ScStyleSheet*>( + aNewPattern.SetStyleSheet( static_cast<ScStyleSheet*>( rDocument.GetStyleSheetPool()-> Find( ScResId(STR_STYLENAME_STANDARD), SfxStyleFamily::Para, SfxStyleSearchBits::Auto | SfxStyleSearchBits::ScStandard ) ) ); - mvData[nPos].pPattern = &rDocument.GetPool()->Put(*pNewPattern); - pNewPattern.reset(); + mvData[nPos].pPattern = &rDocument.GetPool()->Put(aNewPattern); if (Concat(nPos)) { @@ -2427,20 +2425,20 @@ void ScAttrArray::CopyArea( } else if ( nStripFlags != ScMF::NONE ) { - std::unique_ptr<ScPatternAttr> pTmpPattern(new ScPatternAttr( *pOldPattern )); + ScPatternAttr aTmpPattern( *pOldPattern ); ScMF nNewFlags = ScMF::NONE; if ( nStripFlags != ScMF::All ) - nNewFlags = pTmpPattern->GetItem(ATTR_MERGE_FLAG).GetValue() & ~nStripFlags; + nNewFlags = aTmpPattern.GetItem(ATTR_MERGE_FLAG).GetValue() & ~nStripFlags; if ( nNewFlags != ScMF::NONE ) - pTmpPattern->GetItemSet().Put( ScMergeFlagAttr( nNewFlags ) ); + aTmpPattern.GetItemSet().Put( ScMergeFlagAttr( nNewFlags ) ); else - pTmpPattern->GetItemSet().ClearItem( ATTR_MERGE_FLAG ); + aTmpPattern.GetItemSet().ClearItem( ATTR_MERGE_FLAG ); if (bSamePool) - pNewPattern = &pDestDocPool->Put(*pTmpPattern); + pNewPattern = &pDestDocPool->Put(aTmpPattern); else - pNewPattern = pTmpPattern->PutInPool( &rAttrArray.rDocument, &rDocument ); + pNewPattern = aTmpPattern.PutInPool( &rAttrArray.rDocument, &rDocument ); } else { diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx index cf8231d4eca7..8cdbf7e9386c 100644 --- a/sc/source/core/data/column.cxx +++ b/sc/source/core/data/column.cxx @@ -720,9 +720,9 @@ void ScColumn::ApplyAttr( SCROW nRow, const SfxPoolItem& rAttr ) ScDocumentPool* pDocPool = GetDoc().GetPool(); const ScPatternAttr* pOldPattern = pAttrArray->GetPattern( nRow ); - std::unique_ptr<ScPatternAttr> pTemp(new ScPatternAttr(*pOldPattern)); - pTemp->GetItemSet().Put(rAttr); - const ScPatternAttr* pNewPattern = &pDocPool->Put( *pTemp ); + ScPatternAttr aTemp(*pOldPattern); + aTemp.GetItemSet().Put(rAttr); + const ScPatternAttr* pNewPattern = &pDocPool->Put( aTemp ); if ( pNewPattern != pOldPattern ) pAttrArray->SetPattern( nRow, pNewPattern ); diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx index dd0337784fa0..21217e9cbbe1 100644 --- a/sc/source/core/data/column2.cxx +++ b/sc/source/core/data/column2.cxx @@ -391,9 +391,9 @@ tools::Long ScColumn::GetNeededSize( std::unique_ptr<SfxItemSet> pSet(new SfxItemSet( pEngine->GetEmptyItemSet() )); if ( ScStyleSheet* pPreviewStyle = rDocument.GetPreviewCellStyle( nCol, nRow, nTab ) ) { - std::unique_ptr<ScPatternAttr> pPreviewPattern(new ScPatternAttr( *pPattern )); - pPreviewPattern->SetStyleSheet(pPreviewStyle); - pPreviewPattern->FillEditItemSet( pSet.get(), pCondSet ); + ScPatternAttr aPreviewPattern( *pPattern ); + aPreviewPattern.SetStyleSheet(pPreviewStyle); + aPreviewPattern.FillEditItemSet( pSet.get(), pCondSet ); } else { diff --git a/sc/source/core/data/documen8.cxx b/sc/source/core/data/documen8.cxx index b9ee4c8a0e66..0e7761d7b087 100644 --- a/sc/source/core/data/documen8.cxx +++ b/sc/source/core/data/documen8.cxx @@ -1251,9 +1251,9 @@ void ScDocument::TransliterateText( const ScMarkData& rMultiMark, Transliteratio std::unique_ptr<SfxItemSet> pDefaults(new SfxItemSet( pEngine->GetEmptyItemSet() )); if ( ScStyleSheet* pPreviewStyle = GetPreviewCellStyle( nCol, nRow, nTab ) ) { - std::unique_ptr<ScPatternAttr> pPreviewPattern(new ScPatternAttr( *pPattern )); - pPreviewPattern->SetStyleSheet(pPreviewStyle); - pPreviewPattern->FillEditItemSet( pDefaults.get() ); + ScPatternAttr aPreviewPattern( *pPattern ); + aPreviewPattern.SetStyleSheet(pPreviewStyle); + aPreviewPattern.FillEditItemSet( pDefaults.get() ); } else { diff --git a/sc/source/core/data/patattr.cxx b/sc/source/core/data/patattr.cxx index 548eb6ef1f91..d5f137f09117 100644 --- a/sc/source/core/data/patattr.cxx +++ b/sc/source/core/data/patattr.cxx @@ -1031,8 +1031,8 @@ ScPatternAttr* ScPatternAttr::PutInPool( ScDocument* pDestDoc, ScDocument* pSrcD { const SfxItemSet* pSrcSet = &GetItemSet(); - std::unique_ptr<ScPatternAttr> pDestPattern( new ScPatternAttr(pDestDoc->GetPool()) ); - SfxItemSet* pDestSet = &pDestPattern->GetItemSet(); + ScPatternAttr aDestPattern( pDestDoc->GetPool() ); + SfxItemSet* pDestSet = &aDestPattern.GetItemSet(); // Copy cell pattern style to other document: @@ -1048,7 +1048,7 @@ ScPatternAttr* ScPatternAttr::PutInPool( ScDocument* pDestDoc, ScDocument* pSrcD pDestDoc->GetStyleSheetPool(), pDestDoc->GetFormatExchangeList() ); - pDestPattern->SetStyleSheet( static_cast<ScStyleSheet*>(pStyleCpy) ); + aDestPattern.SetStyleSheet( static_cast<ScStyleSheet*>(pStyleCpy) ); } for ( sal_uInt16 nAttrId = ATTR_PATTERN_START; nAttrId <= ATTR_PATTERN_END; nAttrId++ ) @@ -1096,7 +1096,7 @@ ScPatternAttr* ScPatternAttr::PutInPool( ScDocument* pDestDoc, ScDocument* pSrcD } } - ScPatternAttr* pPatternAttr = const_cast<ScPatternAttr*>( &pDestDoc->GetPool()->Put(*pDestPattern) ); + ScPatternAttr* pPatternAttr = const_cast<ScPatternAttr*>( &pDestDoc->GetPool()->Put(aDestPattern) ); return pPatternAttr; } diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx index a4c5c6db55a7..718d8cd0e8c7 100644 --- a/sc/source/ui/view/viewfunc.cxx +++ b/sc/source/ui/view/viewfunc.cxx @@ -1220,7 +1220,7 @@ void ScViewFunc::ApplySelectionPattern( const ScPatternAttr& rAttr, bool bCursor } aChangeRanges.push_back(aPos); - std::unique_ptr<ScPatternAttr> pOldPat(new ScPatternAttr(*rDoc.GetPattern( nCol, nRow, nTab ))); + std::optional<ScPatternAttr> pOldPat(*rDoc.GetPattern( nCol, nRow, nTab )); rDoc.ApplyPattern( nCol, nRow, nTab, rAttr ); @@ -1229,7 +1229,7 @@ void ScViewFunc::ApplySelectionPattern( const ScPatternAttr& rAttr, bool bCursor if (bRecord) { std::unique_ptr<ScUndoCursorAttr> pUndo(new ScUndoCursorAttr( - pDocSh, nCol, nRow, nTab, pOldPat.get(), pNewPat, &rAttr )); + pDocSh, nCol, nRow, nTab, &*pOldPat, pNewPat, &rAttr )); pUndo->SetEditData(std::move(pOldEditData), std::move(pNewEditData)); pDocSh->GetUndoManager()->AddUndoAction(std::move(pUndo)); } |