sw/source/uibase/dochdl/swdtflvr.cxx | 14 +++++++------- sw/source/uibase/docvw/PageBreakWin.cxx | 22 ++++++++-------------- sw/source/uibase/inc/PageBreakWin.hxx | 5 +++-- sw/source/uibase/inc/swdtflvr.hxx | 2 +- 4 files changed, 19 insertions(+), 24 deletions(-)
New commits: commit b05b2eafa2a15f861de065bc6c3a4a31d6f126d7 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Tue Jul 24 10:12:48 2018 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Wed Jul 25 08:45:13 2018 +0200 loplugin:useuniqueptr in SwPageBreakWin and fix check in UpdatePosition, which would previously never have returned early Change-Id: Ie0d3feaf193dd3216f359a88c11ce6e504ac451c Reviewed-on: https://gerrit.libreoffice.org/57934 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/sw/source/uibase/docvw/PageBreakWin.cxx b/sw/source/uibase/docvw/PageBreakWin.cxx index 366c204f9dc8..7d68143d0acb 100644 --- a/sw/source/uibase/docvw/PageBreakWin.cxx +++ b/sw/source/uibase/docvw/PageBreakWin.cxx @@ -86,8 +86,7 @@ namespace if ( !rMEvt.IsSynthetic() && !m_pWin->IsVisible() ) { - Point* pPtr = new Point( rMEvt.GetPosPixel() ); - m_pWin->UpdatePosition( pPtr ); + m_pWin->UpdatePosition( rMEvt.GetPosPixel() ); } } } @@ -100,8 +99,7 @@ SwPageBreakWin::SwPageBreakWin( SwEditWin* pEditWin, const SwFrame *pFrame ) : m_bIsAppearing( false ), m_nFadeRate( 100 ), m_nDelayAppearing( 0 ), - m_bDestroyed( false ), - m_pMousePt( nullptr ) + m_bDestroyed( false ) { // Use pixels for the rest of the drawing SetMapMode( MapMode ( MapUnit::MapPixel ) ); @@ -131,9 +129,6 @@ void SwPageBreakWin::dispose() m_pPopupMenu.clear(); m_aBuilder.disposeBuilder(); - delete m_pMousePt; - m_pMousePt = nullptr; - SwFrameMenuButtonBase::dispose(); } @@ -328,14 +323,13 @@ void SwPageBreakWin::Activate( ) MenuButton::Activate(); } -void SwPageBreakWin::UpdatePosition( const Point* pEvtPt ) +void SwPageBreakWin::UpdatePosition( boost::optional<Point> xEvtPt ) { - if ( pEvtPt != nullptr ) + if ( xEvtPt ) { - if ( pEvtPt == m_pMousePt ) + if ( xEvtPt == m_xMousePt ) return; - delete m_pMousePt; - m_pMousePt = pEvtPt; + m_xMousePt = xEvtPt; } const SwPageFrame* pPageFrame = GetPageFrame(); @@ -380,9 +374,9 @@ void SwPageBreakWin::UpdatePosition( const Point* pEvtPt ) long nLineRight = std::min( nPgRight, aVisArea.Right() ); long nBtnLeft = nLineLeft; - if ( m_pMousePt ) + if ( m_xMousePt ) { - nBtnLeft = nLineLeft + m_pMousePt->X() - aBtnSize.getWidth() / 2; + nBtnLeft = nLineLeft + m_xMousePt->X() - aBtnSize.getWidth() / 2; if ( nBtnLeft < nLineLeft ) nBtnLeft = nLineLeft; diff --git a/sw/source/uibase/inc/PageBreakWin.hxx b/sw/source/uibase/inc/PageBreakWin.hxx index c659be062f0d..5b84ee1d8a6a 100644 --- a/sw/source/uibase/inc/PageBreakWin.hxx +++ b/sw/source/uibase/inc/PageBreakWin.hxx @@ -12,6 +12,7 @@ #include "FrameControl.hxx" #include <vcl/builder.hxx> #include <vcl/menubtn.hxx> +#include <boost/optional.hpp> class SwPageFrame; @@ -31,7 +32,7 @@ class SwPageBreakWin : public SwFrameMenuButtonBase Timer m_aFadeTimer; bool m_bDestroyed; - const Point* m_pMousePt; + boost::optional<Point> m_xMousePt; public: SwPageBreakWin( SwEditWin* pEditWin, const SwFrame *pFrame ); @@ -43,7 +44,7 @@ public: virtual void MouseMove( const MouseEvent& rMEvt ) override; virtual void Activate( ) override; - void UpdatePosition( const Point* pEvtPt = nullptr ); + void UpdatePosition( boost::optional<Point> xEvtPt = boost::optional<Point>() ); virtual void ShowAll( bool bShow ) override; virtual bool Contains( const Point &rDocPt ) const override; commit 7789628e9aebc68fb194d42252dcb5e29f183f96 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Tue Jul 24 10:12:00 2018 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Wed Jul 25 08:45:03 2018 +0200 loplugin:useuniqueptr in SwTransferable Change-Id: I857bd0416d3c093021409af18a28815eddbdb66a Reviewed-on: https://gerrit.libreoffice.org/57933 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/sw/source/uibase/dochdl/swdtflvr.cxx b/sw/source/uibase/dochdl/swdtflvr.cxx index f2b8aa3d0fbc..d69c680a0424 100644 --- a/sw/source/uibase/dochdl/swdtflvr.cxx +++ b/sw/source/uibase/dochdl/swdtflvr.cxx @@ -245,7 +245,7 @@ SwTransferable::~SwTransferable() // release reference to the document so that aDocShellRef will delete // it (if aDocShellRef is set). Otherwise, the OLE nodes keep references // to their sub-storage when the storage is already dead. - delete m_pClpDocFac; + m_pClpDocFac.reset(); // first close, then the Ref. can be cleared as well, so that // the DocShell really gets deleted! @@ -429,7 +429,7 @@ bool SwTransferable::GetData( const DataFlavor& rFlavor, const OUString& rDestDo } } - m_pClpDocFac = new SwDocFac; + m_pClpDocFac.reset(new SwDocFac); SwDoc *const pTmpDoc = lcl_GetDoc(*m_pClpDocFac); pTmpDoc->getIDocumentFieldsAccess().LockExpFields(); // never update fields - leave text as it is @@ -793,7 +793,7 @@ int SwTransferable::PrepareForCopy( bool bIsCut ) if( !m_pWrtShell->GetDrawObjGraphic( SotClipboardFormatId::BITMAP, *m_pClpBitmap )) m_pOrigGraphic = m_pClpBitmap.get(); - m_pClpDocFac = new SwDocFac; + m_pClpDocFac.reset(new SwDocFac); SwDoc *const pDoc = lcl_GetDoc(*m_pClpDocFac); m_pWrtShell->Copy( pDoc ); @@ -815,7 +815,7 @@ int SwTransferable::PrepareForCopy( bool bIsCut ) } else if ( nSelection == SelectionType::Ole ) { - m_pClpDocFac = new SwDocFac; + m_pClpDocFac.reset(new SwDocFac); SwDoc *const pDoc = lcl_GetDoc(*m_pClpDocFac); m_aDocShellRef = new SwDocShell( pDoc, SfxObjectCreateMode::EMBEDDED); m_aDocShellRef->DoInitNew(); @@ -858,7 +858,7 @@ int SwTransferable::PrepareForCopy( bool bIsCut ) if( m_pWrtShell->ShouldWait() ) pWait.reset(new SwWait( *m_pWrtShell->GetView().GetDocShell(), true )); - m_pClpDocFac = new SwDocFac; + m_pClpDocFac.reset(new SwDocFac); // create additional cursor so that equal treatment of keyboard // and mouse selection is possible. @@ -1020,7 +1020,7 @@ void SwTransferable::CalculateAndCopy() OUString aStr( m_pWrtShell->Calculate() ); - m_pClpDocFac = new SwDocFac; + m_pClpDocFac.reset(new SwDocFac); SwDoc *const pDoc = lcl_GetDoc(*m_pClpDocFac); m_pWrtShell->Copy(pDoc, & aStr); m_eBufferType = TransferBufferType::Document; @@ -1035,7 +1035,7 @@ bool SwTransferable::CopyGlossary( SwTextBlocks& rGlossary, const OUString& rStr return false; SwWait aWait( *m_pWrtShell->GetView().GetDocShell(), true ); - m_pClpDocFac = new SwDocFac; + m_pClpDocFac.reset(new SwDocFac); SwDoc *const pCDoc = lcl_GetDoc(*m_pClpDocFac); SwNodes& rNds = pCDoc->GetNodes(); diff --git a/sw/source/uibase/inc/swdtflvr.hxx b/sw/source/uibase/inc/swdtflvr.hxx index 58990e80f943..d230f6f21387 100644 --- a/sw/source/uibase/inc/swdtflvr.hxx +++ b/sw/source/uibase/inc/swdtflvr.hxx @@ -68,7 +68,7 @@ class SW_DLLPUBLIC SwTransferable : public TransferableHelper /* #96392# Added pCreatorView to distinguish SwFrameShell from SwWrtShell. */ const SwFrameShell *m_pCreatorView; - SwDocFac *m_pClpDocFac; + std::unique_ptr<SwDocFac> m_pClpDocFac; std::unique_ptr<Graphic> m_pClpGraphic; std::unique_ptr<Graphic> m_pClpBitmap; Graphic *m_pOrigGraphic; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits