sw/source/core/inc/UndoSort.hxx | 2 -- sw/source/core/undo/unsort.cxx | 24 ++++++++++-------------- sw/source/core/unocore/unoframe.cxx | 11 ++++------- 3 files changed, 14 insertions(+), 23 deletions(-)
New commits: commit 77e62790800f912f557613d98273555292b002d6 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Thu Jan 10 16:52:17 2019 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Fri Jan 11 08:41:58 2019 +0100 use unique_ptr in SwXFrame Change-Id: I3671bf7ab7913a2f07eec347c1e07d036bfca4c4 Reviewed-on: https://gerrit.libreoffice.org/66122 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/sw/source/core/unocore/unoframe.cxx b/sw/source/core/unocore/unoframe.cxx index d63bd91847b1..18da4371bc2c 100644 --- a/sw/source/core/unocore/unoframe.cxx +++ b/sw/source/core/unocore/unoframe.cxx @@ -1548,7 +1548,7 @@ void SwXFrame::setPropertyValue(const OUString& rPropertyName, const ::uno::Any& UnoActionContext aAction(pFormat->GetDoc()); - SfxItemSet* pSet = nullptr; + std::unique_ptr<SfxItemSet> pSet; // #i31771#, #i25798# - No adjustment of // anchor ( no call of method <sw_ChkAndSetNewAnchor(..)> ), // if document is currently in reading mode. @@ -1563,21 +1563,18 @@ void SwXFrame::setPropertyValue(const OUString& rPropertyName, const ::uno::Any& const ::SfxPoolItem* pItem; if( SfxItemState::SET == pFrameFormat->GetItemState( RES_ANCHOR, false, &pItem )) { - pSet = new SfxItemSet( pDoc->GetAttrPool(), aFrameFormatSetRange ); + pSet.reset(new SfxItemSet( pDoc->GetAttrPool(), aFrameFormatSetRange )); pSet->Put( *pItem ); if ( pFormat->GetDoc()->GetEditShell() != nullptr && !sw_ChkAndSetNewAnchor( *pFly, *pSet ) ) { - delete pSet; - pSet = nullptr; + pSet.reset(); } } } } - pFormat->GetDoc()->SetFrameFormatToFly( *pFormat, *pFrameFormat, pSet ); - delete pSet; - + pFormat->GetDoc()->SetFrameFormatToFly( *pFormat, *pFrameFormat, pSet.get() ); } else if (FN_UNO_GRAPHIC_FILTER == pEntry->nWID) { commit 9e2ca20b0514cc77102c9985ad72f242c0af910e Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Thu Jan 10 16:43:53 2019 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Fri Jan 11 08:41:44 2019 +0100 no need to allocate on heap in SwUndoSortList Change-Id: I949a9d32b18d5ccae17dee26f030173307d0b3fb Reviewed-on: https://gerrit.libreoffice.org/66121 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/sw/source/core/inc/UndoSort.hxx b/sw/source/core/inc/UndoSort.hxx index 167aaa4ef625..27f97ceaf995 100644 --- a/sw/source/core/inc/UndoSort.hxx +++ b/sw/source/core/inc/UndoSort.hxx @@ -57,8 +57,6 @@ struct SwSortUndoElement ~SwSortUndoElement(); }; -typedef std::vector<SwNodeIndex*> SwUndoSortList; - class SwUndoSort : public SwUndo, private SwUndRng { std::unique_ptr<SwSortOptions> pSortOpt; diff --git a/sw/source/core/undo/unsort.cxx b/sw/source/core/undo/unsort.cxx index ac354d889be4..b20d4e5b94a2 100644 --- a/sw/source/core/undo/unsort.cxx +++ b/sw/source/core/undo/unsort.cxx @@ -121,7 +121,8 @@ void SwUndoSort::UndoImpl(::sw::UndoRedoContext & rContext) // create index for (sorted) positions // The IndexList must be created based on (asc.) sorted SourcePosition. - SwUndoSortList aIdxList; + std::vector<SwNodeIndex> aIdxList; + aIdxList.reserve(m_SortList.size()); for (size_t i = 0; i < m_SortList.size(); ++i) { @@ -129,9 +130,8 @@ void SwUndoSort::UndoImpl(::sw::UndoRedoContext & rContext) { if (j->SORT_TXT_TBL.TXT.nSource == nSttNode + i) { - SwNodeIndex* pIdx = new SwNodeIndex( rDoc.GetNodes(), - j->SORT_TXT_TBL.TXT.nTarget ); - aIdxList.insert( aIdxList.begin() + i, pIdx ); + aIdxList.push_back( SwNodeIndex( rDoc.GetNodes(), + j->SORT_TXT_TBL.TXT.nTarget ) ); break; } } @@ -140,13 +140,11 @@ void SwUndoSort::UndoImpl(::sw::UndoRedoContext & rContext) for (size_t i = 0; i < m_SortList.size(); ++i) { SwNodeIndex aIdx( rDoc.GetNodes(), nSttNode + i ); - SwNodeRange aRg( *aIdxList[i], 0, *aIdxList[i], 1 ); + SwNodeRange aRg( aIdxList[i], 0, aIdxList[i], 1 ); rDoc.getIDocumentContentOperations().MoveNodeRange(aRg, aIdx, SwMoveFlags::DEFAULT); } // delete indices - for(auto& rpIdx : aIdxList) - delete rpIdx; aIdxList.clear(); SetPaM(rPam, true); } @@ -203,25 +201,23 @@ void SwUndoSort::RedoImpl(::sw::UndoRedoContext & rContext) SetPaM(rPam); RemoveIdxFromRange(rPam, true); - SwUndoSortList aIdxList; + std::vector<SwNodeIndex> aIdxList; + aIdxList.reserve(m_SortList.size()); for (size_t i = 0; i < m_SortList.size(); ++i) { // current position is starting point - SwNodeIndex* pIdx = new SwNodeIndex( rDoc.GetNodes(), - m_SortList[i]->SORT_TXT_TBL.TXT.nSource); - aIdxList.insert( aIdxList.begin() + i, pIdx ); + aIdxList.push_back( SwNodeIndex( rDoc.GetNodes(), + m_SortList[i]->SORT_TXT_TBL.TXT.nSource) ); } for (size_t i = 0; i < m_SortList.size(); ++i) { SwNodeIndex aIdx( rDoc.GetNodes(), nSttNode + i); - SwNodeRange aRg( *aIdxList[i], 0, *aIdxList[i], 1 ); + SwNodeRange aRg( aIdxList[i], 0, aIdxList[i], 1 ); rDoc.getIDocumentContentOperations().MoveNodeRange(aRg, aIdx, SwMoveFlags::DEFAULT); } // delete indices - for(auto& rpIdx : aIdxList) - delete rpIdx; aIdxList.clear(); SetPaM(rPam, true); SwTextNode const*const pTNd = rPam.GetNode().GetTextNode(); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits