From 11d513d580ed8b80fd32987cb9c73716b48ca916 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Tue, 4 Sep 2018 14:03:36 +0200 Subject: loplugin:useuniqueptr in svx Change-Id: Iba9ceb0b86b175ef599f4de7b06bf0dccc2ba997 Reviewed-on: https://gerrit.libreoffice.org/60005 Tested-by: Jenkins Reviewed-by: Noel Grandin --- svx/source/svdraw/svdotext.cxx | 7 +++---- svx/source/table/tablecolumn.cxx | 11 +++-------- svx/source/table/tablerow.cxx | 11 +++-------- 3 files changed, 9 insertions(+), 20 deletions(-) (limited to 'svx/source') diff --git a/svx/source/svdraw/svdotext.cxx b/svx/source/svdraw/svdotext.cxx index b0799a92b5d8..91a5a23040bf 100644 --- a/svx/source/svdraw/svdotext.cxx +++ b/svx/source/svdraw/svdotext.cxx @@ -539,7 +539,7 @@ void SdrTextObj::AdaptTextMinSize() void SdrTextObj::ImpSetContourPolygon( SdrOutliner& rOutliner, tools::Rectangle const & rAnchorRect, bool bLineWidth ) const { basegfx::B2DPolyPolygon aXorPolyPolygon(TakeXorPoly()); - basegfx::B2DPolyPolygon* pContourPolyPolygon = nullptr; + std::unique_ptr pContourPolyPolygon; basegfx::B2DHomMatrix aMatrix(basegfx::utils::createTranslateB2DHomMatrix( -rAnchorRect.Left(), -rAnchorRect.Top())); @@ -555,7 +555,7 @@ void SdrTextObj::ImpSetContourPolygon( SdrOutliner& rOutliner, tools::Rectangle { // Take line width into account. // When doing the hit test, avoid this. (Performance!) - pContourPolyPolygon = new basegfx::B2DPolyPolygon(); + pContourPolyPolygon.reset(new basegfx::B2DPolyPolygon()); // test if shadow needs to be avoided for TakeContour() const SfxItemSet& rSet = GetObjectItemSet(); @@ -590,8 +590,7 @@ void SdrTextObj::ImpSetContourPolygon( SdrOutliner& rOutliner, tools::Rectangle pContourPolyPolygon->transform(aMatrix); } - rOutliner.SetPolygon(aXorPolyPolygon, pContourPolyPolygon); - delete pContourPolyPolygon; + rOutliner.SetPolygon(aXorPolyPolygon, pContourPolyPolygon.get()); } void SdrTextObj::TakeUnrotatedSnapRect(tools::Rectangle& rRect) const diff --git a/svx/source/table/tablecolumn.cxx b/svx/source/table/tablecolumn.cxx index e4007b3b35cf..7cff0359a916 100644 --- a/svx/source/table/tablecolumn.cxx +++ b/svx/source/table/tablecolumn.cxx @@ -142,12 +142,12 @@ void SAL_CALL TableColumn::setFastPropertyValue( sal_Int32 nHandle, const Any& a bool bChange = false; SdrModel& rModel(mxTableModel->getSdrTableObj()->getSdrModelFromSdrObject()); - TableColumnUndo* pUndo = nullptr; + std::unique_ptr pUndo; if( mxTableModel.is() && mxTableModel->getSdrTableObj() && mxTableModel->getSdrTableObj()->IsInserted() && rModel.IsUndoEnabled() ) { TableColumnRef xThis( this ); - pUndo = new TableColumnUndo( xThis ); + pUndo.reset( new TableColumnUndo( xThis ) ); } switch( nHandle ) @@ -201,12 +201,10 @@ void SAL_CALL TableColumn::setFastPropertyValue( sal_Int32 nHandle, const Any& a break; } default: - delete pUndo; throw UnknownPropertyException( OUString::number(nHandle), static_cast(this)); } if( !bOk ) { - delete pUndo; throw IllegalArgumentException(); } @@ -214,13 +212,10 @@ void SAL_CALL TableColumn::setFastPropertyValue( sal_Int32 nHandle, const Any& a { if( pUndo ) { - rModel.AddUndo( pUndo ); - pUndo = nullptr; + rModel.AddUndo( pUndo.release() ); } mxTableModel->setModified(true); } - - delete pUndo; } diff --git a/svx/source/table/tablerow.cxx b/svx/source/table/tablerow.cxx index cf765b47830a..c3b4e03475ae 100644 --- a/svx/source/table/tablerow.cxx +++ b/svx/source/table/tablerow.cxx @@ -213,13 +213,13 @@ void SAL_CALL TableRow::setFastPropertyValue( sal_Int32 nHandle, const Any& aVal SdrModel& rModel(rTableObj.getSdrModelFromSdrObject()); bool bOk(false); bool bChange(false); - TableRowUndo* pUndo(nullptr); + std::unique_ptr pUndo; const bool bUndo(rTableObj.IsInserted() && rModel.IsUndoEnabled()); if( bUndo ) { TableRowRef xThis( this ); - pUndo = new TableRowUndo( xThis ); + pUndo.reset(new TableRowUndo( xThis )); } switch( nHandle ) @@ -274,13 +274,11 @@ void SAL_CALL TableRow::setFastPropertyValue( sal_Int32 nHandle, const Any& aVal break; } default: - delete pUndo; throw UnknownPropertyException( OUString::number(nHandle), static_cast(this)); } if( !bOk ) { - delete pUndo; throw IllegalArgumentException(); } @@ -288,13 +286,10 @@ void SAL_CALL TableRow::setFastPropertyValue( sal_Int32 nHandle, const Any& aVal { if( pUndo ) { - rModel.AddUndo( pUndo ); - pUndo = nullptr; + rModel.AddUndo( pUndo.release() ); } mxTableModel->setModified(true); } - - delete pUndo; } -- cgit