diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-03-15 17:05:46 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-03-16 08:25:53 +0100 |
commit | 0a8af607ba0936d8802fca96ec3259c7eedcd571 (patch) | |
tree | ed1dc643be2602fe2aab6458f7698ec23c371b8c | |
parent | a7e98725901412aa334a1abe87194e682c1ae836 (diff) |
loplugin:useuniqueptr in SwBlockCursor
Change-Id: I3c3b9969ea26bd378a25a3c58e4710a5538889fb
Reviewed-on: https://gerrit.libreoffice.org/51373
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r-- | sw/source/core/crsr/BlockCursor.cxx | 36 | ||||
-rw-r--r-- | sw/source/core/crsr/BlockCursor.hxx | 17 |
2 files changed, 9 insertions, 44 deletions
diff --git a/sw/source/core/crsr/BlockCursor.cxx b/sw/source/core/crsr/BlockCursor.cxx index 89c8d8f745fe..9f2c399a7393 100644 --- a/sw/source/core/crsr/BlockCursor.cxx +++ b/sw/source/core/crsr/BlockCursor.cxx @@ -22,8 +22,6 @@ SwBlockCursor::~SwBlockCursor() { - delete pStartPt; - delete pEndPt; } SwShellCursor& SwBlockCursor::getShellCursor() @@ -31,38 +29,4 @@ SwShellCursor& SwBlockCursor::getShellCursor() return aCursor; } -void SwBlockCursor::setStartPoint( const Point &rPt ) -{ - if( pStartPt ) - *pStartPt = rPt; - else - pStartPt = new Point( rPt ); -} - -void SwBlockCursor::setEndPoint( const Point &rPt ) -{ - if( pEndPt ) - *pEndPt = rPt; - else - pEndPt = new Point( rPt ); -} - -const Point* SwBlockCursor::getStartPoint() const -{ - return pStartPt; -} - -const Point* SwBlockCursor::getEndPoint() const -{ - return pEndPt; -} - -void SwBlockCursor::clearPoints() -{ - delete pStartPt; - delete pEndPt; - pStartPt = nullptr; - pEndPt = nullptr; -} - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/crsr/BlockCursor.hxx b/sw/source/core/crsr/BlockCursor.hxx index 3238993c87cd..c0b764662f15 100644 --- a/sw/source/core/crsr/BlockCursor.hxx +++ b/sw/source/core/crsr/BlockCursor.hxx @@ -20,6 +20,7 @@ #define INCLUDED_SW_SOURCE_CORE_CRSR_BLOCKCURSOR_HXX #include <crsrsh.hxx> +#include <boost/optional.hpp> class SwCursorShell; struct SwPosition; @@ -37,12 +38,12 @@ class Point; class SwBlockCursor { SwShellCursor aCursor; - Point *pStartPt; - Point *pEndPt; + boost::optional<Point> maStartPt; + boost::optional<Point> maEndPt; public: SwBlockCursor( const SwCursorShell& rCursorSh, const SwPosition &rPos ) : - aCursor( rCursorSh, rPos ), pStartPt(nullptr), pEndPt(nullptr) {} + aCursor( rCursorSh, rPos ) {} /** Access to the shell cursor @return SwShellCursor& which represents the start and end position of the @@ -55,31 +56,31 @@ public: rPt should contain the document coordinates of the mouse cursor when the block selection starts (MouseButtonDown) */ - void setStartPoint( const Point &rPt ); + void setStartPoint( const Point &rPt ) { maStartPt = rPt; } /** Defines the ending vertex of the block selection @param rPt rPt should contain the document coordinates of the mouse cursor when the block selection has started and the mouse has been moved (MouseMove) */ - void setEndPoint( const Point &rPt ); + void setEndPoint( const Point &rPt ) { maEndPt = rPt; } /** The document coordinates where the block selection has been started @return 0, if no start point has been set */ - const Point* getStartPoint() const; + boost::optional<Point> const & getStartPoint() const { return maStartPt; } /** The document coordinates where the block selection ends (at the moment) @return 0, if no end point has been set */ - const Point* getEndPoint() const; + boost::optional<Point> const & getEndPoint() const { return maEndPt; } /** Deletion of the mouse created rectangle When start and end points exist, the block cursor depends on this. If the cursor is moved by cursor keys (e.g. up/down, home/end) the mouse rectangle is obsolete and has to be deleted. */ - void clearPoints(); + void clearPoints() { maStartPt.reset(); maEndPt.reset(); } ~SwBlockCursor(); }; |