include/svx/sdr/contact/viewobjectcontactofpageobj.hxx | 3 ++- svx/source/sdr/contact/viewobjectcontactofpageobj.cxx | 4 +--- svx/source/svdraw/svdotext.cxx | 7 +++---- svx/source/table/tablecolumn.cxx | 11 +++-------- svx/source/table/tablerow.cxx | 11 +++-------- 5 files changed, 12 insertions(+), 24 deletions(-)
New commits: commit 11d513d580ed8b80fd32987cb9c73716b48ca916 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Tue Sep 4 14:03:36 2018 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Wed Sep 5 09:32:47 2018 +0200 loplugin:useuniqueptr in svx Change-Id: Iba9ceb0b86b175ef599f4de7b06bf0dccc2ba997 Reviewed-on: https://gerrit.libreoffice.org/60005 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> 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<basegfx::B2DPolyPolygon> 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<TableColumnUndo> 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<cppu::OWeakObject*>(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<TableRowUndo> 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<cppu::OWeakObject*>(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; } commit 1800cac964c145d9aa7e0048e0e545463901a03c Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Tue Sep 4 13:37:07 2018 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Wed Sep 5 09:32:36 2018 +0200 loplugin:useuniqueptr in ViewObjectContactOfPageObj Change-Id: I4f7af7bb8da2b4bfb27ab7cf748677fc3fa6fdbc Reviewed-on: https://gerrit.libreoffice.org/60004 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/include/svx/sdr/contact/viewobjectcontactofpageobj.hxx b/include/svx/sdr/contact/viewobjectcontactofpageobj.hxx index e9b115ee4e2e..ace62f1941c0 100644 --- a/include/svx/sdr/contact/viewobjectcontactofpageobj.hxx +++ b/include/svx/sdr/contact/viewobjectcontactofpageobj.hxx @@ -21,6 +21,7 @@ #define INCLUDED_SVX_SDR_CONTACT_VIEWOBJECTCONTACTOFPAGEOBJ_HXX #include <svx/sdr/contact/viewobjectcontactofsdrobj.hxx> +#include <memory> class SdrPage; @@ -32,7 +33,7 @@ class SVX_DLLPUBLIC ViewObjectContactOfPageObj : public ViewObjectContactOfSdrOb { private: // the page painter helper - PagePrimitiveExtractor* mpExtractor; + std::unique_ptr<PagePrimitiveExtractor> mpExtractor; protected: // This method is responsible for creating the graphical visualisation data which is diff --git a/svx/source/sdr/contact/viewobjectcontactofpageobj.cxx b/svx/source/sdr/contact/viewobjectcontactofpageobj.cxx index db64344e0447..e22cbc184891 100644 --- a/svx/source/sdr/contact/viewobjectcontactofpageobj.cxx +++ b/svx/source/sdr/contact/viewobjectcontactofpageobj.cxx @@ -313,13 +313,11 @@ ViewObjectContactOfPageObj::~ViewObjectContactOfPageObj() { // remember candidate and reset own pointer to avoid action when createPrimitive2DSequence() // would be called for any reason - PagePrimitiveExtractor* pCandidate = mpExtractor; - mpExtractor = nullptr; + std::unique_ptr<PagePrimitiveExtractor> pCandidate = std::move(mpExtractor); // also reset the StartPage to avoid ActionChanged() forwardings in the // PagePrimitiveExtractor::InvalidatePartOfView() implementation pCandidate->SetStartPage(nullptr); - delete pCandidate; } } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits