summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2017-11-16 10:47:00 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-11-17 08:10:48 +0100
commita9f6478561a65b97f28de2ee3a428a3f99e87f16 (patch)
treeb4f7b518a4af94feb02da0ff6898f2756172f4fc
parent54604f01330063635fb974b0ab4335d6af851551 (diff)
loplugin:useuniqueptr in SwTransferable
Change-Id: I803eef7270f8f1a13b253d5ac9ba4d7e41b5adef Reviewed-on: https://gerrit.libreoffice.org/44821 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--sw/source/uibase/dochdl/swdtflvr.cxx62
-rw-r--r--sw/source/uibase/inc/swdtflvr.hxx11
2 files changed, 35 insertions, 38 deletions
diff --git a/sw/source/uibase/dochdl/swdtflvr.cxx b/sw/source/uibase/dochdl/swdtflvr.cxx
index 0c5493e41331..00c42f143d4b 100644
--- a/sw/source/uibase/dochdl/swdtflvr.cxx
+++ b/sw/source/uibase/dochdl/swdtflvr.cxx
@@ -265,12 +265,6 @@ SwTransferable::~SwTransferable()
pMod->m_pXSelection = nullptr;
}
- delete m_pClpGraphic;
- delete m_pClpBitmap;
- delete m_pImageMap;
- delete m_pTargetURL;
- delete m_pBookmark;
-
m_eBufferType = TransferBufferType::NONE;
}
@@ -418,19 +412,19 @@ bool SwTransferable::GetData( const DataFlavor& rFlavor, const OUString& rDestDo
// SEL_GRF is from ContentType of editsh
if(bPending || ((SelectionType::Graphic | SelectionType::DbForm) & nSelectionType))
{
- m_pClpGraphic = new Graphic;
+ m_pClpGraphic.reset(new Graphic);
if( !m_pWrtShell->GetDrawObjGraphic( SotClipboardFormatId::GDIMETAFILE, *m_pClpGraphic ))
- m_pOrigGraphic = m_pClpGraphic;
- m_pClpBitmap = new Graphic;
+ m_pOrigGraphic = m_pClpGraphic.get();
+ m_pClpBitmap.reset(new Graphic);
if( !m_pWrtShell->GetDrawObjGraphic( SotClipboardFormatId::BITMAP, *m_pClpBitmap ))
- m_pOrigGraphic = m_pClpBitmap;
+ m_pOrigGraphic = m_pClpBitmap.get();
// is it an URL-Button ?
OUString sURL;
OUString sDesc;
if( m_pWrtShell->GetURLFromButton( sURL, sDesc ) )
{
- m_pBookmark = new INetBookmark( sURL, sDesc );
+ m_pBookmark.reset(new INetBookmark( sURL, sDesc ));
m_eBufferType = TransferBufferType::InetField;
}
}
@@ -458,9 +452,9 @@ bool SwTransferable::GetData( const DataFlavor& rFlavor, const OUString& rDestDo
!m_pWrtShell->GetView().GetDocShell()->IsReadOnly();
if( m_pWrtShell->GetContentAtPos( aPos, aContentAtPos, bSelect ) )
{
- m_pBookmark = new INetBookmark(
+ m_pBookmark.reset(new INetBookmark(
static_cast<const SwFormatINetFormat*>(aContentAtPos.aFnd.pAttr)->GetValue(),
- aContentAtPos.sStr );
+ aContentAtPos.sStr ));
m_eBufferType = TransferBufferType::InetField;
if( bSelect )
m_pWrtShell->SelectTextAttr( RES_TXTATR_INETFMT );
@@ -472,10 +466,10 @@ bool SwTransferable::GetData( const DataFlavor& rFlavor, const OUString& rDestDo
m_pWrtShell->GetFlyFrameAttr( aSet );
const SwFormatURL& rURL = static_cast<const SwFormatURL&>(aSet.Get( RES_URL ));
if( rURL.GetMap() )
- m_pImageMap = new ImageMap( *rURL.GetMap() );
+ m_pImageMap.reset(new ImageMap( *rURL.GetMap() ));
else if( !rURL.GetURL().isEmpty() )
- m_pTargetURL = new INetImage( aEmptyOUStr, rURL.GetURL(),
- rURL.GetTargetFrameName() );
+ m_pTargetURL.reset(new INetImage( aEmptyOUStr, rURL.GetURL(),
+ rURL.GetTargetFrameName() ));
}
}
@@ -792,12 +786,12 @@ int SwTransferable::PrepareForCopy( bool bIsCut )
const SelectionType nSelection = m_pWrtShell->GetSelectionType();
if( nSelection == SelectionType::Graphic )
{
- m_pClpGraphic = new Graphic;
+ m_pClpGraphic.reset(new Graphic);
if( !m_pWrtShell->GetDrawObjGraphic( SotClipboardFormatId::GDIMETAFILE, *m_pClpGraphic ))
- m_pOrigGraphic = m_pClpGraphic;
- m_pClpBitmap = new Graphic;
+ m_pOrigGraphic = m_pClpGraphic.get();
+ m_pClpBitmap.reset(new Graphic);
if( !m_pWrtShell->GetDrawObjGraphic( SotClipboardFormatId::BITMAP, *m_pClpBitmap ))
- m_pOrigGraphic = m_pClpBitmap;
+ m_pOrigGraphic = m_pClpBitmap.get();
m_pClpDocFac = new SwDocFac;
SwDoc *const pDoc = lcl_GetDoc(*m_pClpDocFac);
@@ -942,12 +936,12 @@ int SwTransferable::PrepareForCopy( bool bIsCut )
}
m_eBufferType = (TransferBufferType)( TransferBufferType::Graphic | m_eBufferType );
- m_pClpGraphic = new Graphic;
+ m_pClpGraphic.reset(new Graphic);
if( !m_pWrtShell->GetDrawObjGraphic( SotClipboardFormatId::GDIMETAFILE, *m_pClpGraphic ))
- m_pOrigGraphic = m_pClpGraphic;
- m_pClpBitmap = new Graphic;
+ m_pOrigGraphic = m_pClpGraphic.get();
+ m_pClpBitmap.reset(new Graphic);
if( !m_pWrtShell->GetDrawObjGraphic( SotClipboardFormatId::BITMAP, *m_pClpBitmap ))
- m_pOrigGraphic = m_pClpBitmap;
+ m_pOrigGraphic = m_pClpBitmap.get();
// is it an URL-Button ?
OUString sURL;
@@ -994,13 +988,13 @@ int SwTransferable::PrepareForCopy( bool bIsCut )
const SwFormatURL& rURL = static_cast<const SwFormatURL&>(aSet.Get( RES_URL ));
if( rURL.GetMap() )
{
- m_pImageMap = new ImageMap( *rURL.GetMap() );
+ m_pImageMap.reset( new ImageMap( *rURL.GetMap() ) );
AddFormat( SotClipboardFormatId::SVIM );
}
else if( !rURL.GetURL().isEmpty() )
{
- m_pTargetURL = new INetImage( sGrfNm, rURL.GetURL(),
- rURL.GetTargetFrameName() );
+ m_pTargetURL.reset(new INetImage( sGrfNm, rURL.GetURL(),
+ rURL.GetTargetFrameName() ));
AddFormat( SotClipboardFormatId::INET_IMAGE );
}
}
@@ -3074,12 +3068,12 @@ void SwTransferable::SetDataForDragAndDrop( const Point& rSttPos )
}
m_eBufferType = TransferBufferType::Graphic | m_eBufferType;
- m_pClpGraphic = new Graphic;
+ m_pClpGraphic.reset(new Graphic);
if( !m_pWrtShell->GetDrawObjGraphic( SotClipboardFormatId::GDIMETAFILE, *m_pClpGraphic ))
- m_pOrigGraphic = m_pClpGraphic;
- m_pClpBitmap = new Graphic;
+ m_pOrigGraphic = m_pClpGraphic.get();
+ m_pClpBitmap.reset(new Graphic);
if( !m_pWrtShell->GetDrawObjGraphic( SotClipboardFormatId::BITMAP, *m_pClpBitmap ))
- m_pOrigGraphic = m_pClpBitmap;
+ m_pOrigGraphic = m_pClpBitmap.get();
// is it an URL-Button ?
OUString sURL;
@@ -3130,13 +3124,13 @@ void SwTransferable::SetDataForDragAndDrop( const Point& rSttPos )
const SwFormatURL& rURL = static_cast<const SwFormatURL&>(aSet.Get( RES_URL ));
if( rURL.GetMap() )
{
- m_pImageMap = new ImageMap( *rURL.GetMap() );
+ m_pImageMap.reset( new ImageMap( *rURL.GetMap() ) );
AddFormat( SotClipboardFormatId::SVIM );
}
else if( !rURL.GetURL().isEmpty() )
{
- m_pTargetURL = new INetImage( sGrfNm, rURL.GetURL(),
- rURL.GetTargetFrameName() );
+ m_pTargetURL.reset(new INetImage( sGrfNm, rURL.GetURL(),
+ rURL.GetTargetFrameName() ));
AddFormat( SotClipboardFormatId::INET_IMAGE );
}
}
diff --git a/sw/source/uibase/inc/swdtflvr.hxx b/sw/source/uibase/inc/swdtflvr.hxx
index 6f9248551c92..2ecbd2c2f9d6 100644
--- a/sw/source/uibase/inc/swdtflvr.hxx
+++ b/sw/source/uibase/inc/swdtflvr.hxx
@@ -26,6 +26,7 @@
#include <sfx2/lnkbase.hxx>
#include <com/sun/star/embed/XEmbeddedObject.hpp>
#include <o3tl/typed_flags_set.hxx>
+#include <memory>
class Graphic;
class ImageMap;
@@ -67,10 +68,12 @@ class SW_DLLPUBLIC SwTransferable : public TransferableHelper
SwWrtShell. */
const SwFrameShell *m_pCreatorView;
SwDocFac *m_pClpDocFac;
- Graphic *m_pClpGraphic, *m_pClpBitmap, *m_pOrigGraphic;
- INetBookmark *m_pBookmark; // URL and description!
- ImageMap *m_pImageMap;
- INetImage *m_pTargetURL;
+ std::unique_ptr<Graphic> m_pClpGraphic;
+ std::unique_ptr<Graphic> m_pClpBitmap;
+ Graphic *m_pOrigGraphic;
+ std::unique_ptr<INetBookmark> m_pBookmark; // URL and description!
+ std::unique_ptr<ImageMap> m_pImageMap;
+ std::unique_ptr<INetImage> m_pTargetURL;
TransferBufferType m_eBufferType;