summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2019-01-14 08:48:28 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2019-01-15 06:57:01 +0100
commite450351a9a1b4b37e34f1c5058a83f284b4979d2 (patch)
treea1054d03b353ef5e960fd07d43364e3195e62575
parent35ea8fc24ae749b8a87b7ddb5df22ecc4f58cfd3 (diff)
use unique_ptr in sw
Change-Id: I369ef79e88a40c01f5384e2427c3dec429ea0457 Reviewed-on: https://gerrit.libreoffice.org/66311 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--sw/source/uibase/app/docsh.cxx9
-rw-r--r--sw/source/uibase/app/docsh2.cxx5
-rw-r--r--sw/source/uibase/app/docstyle.cxx12
3 files changed, 12 insertions, 14 deletions
diff --git a/sw/source/uibase/app/docsh.cxx b/sw/source/uibase/app/docsh.cxx
index 0d02885d3d4f..afcb2aea7596 100644
--- a/sw/source/uibase/app/docsh.cxx
+++ b/sw/source/uibase/app/docsh.cxx
@@ -872,12 +872,12 @@ void SwDocShell::Draw( OutputDevice* pDev, const JobSetup& rSetup,
// reconnect it after PrtOle2. We don't use an empty JobSetup because
// that would only lead to questionable results after expensive
// reformatting (Preview!)
- JobSetup *pOrig = nullptr;
+ std::unique_ptr<JobSetup> pOrig;
if ( !rSetup.GetPrinterName().isEmpty() && ASPECT_THUMBNAIL != nAspect )
{
- pOrig = const_cast<JobSetup*>(m_xDoc->getIDocumentDeviceAccess().getJobsetup());
- if( pOrig ) // then we copy that
- pOrig = new JobSetup( *pOrig );
+ const JobSetup* pCurrentJobSetup = m_xDoc->getIDocumentDeviceAccess().getJobsetup();
+ if( pCurrentJobSetup ) // then we copy that
+ pOrig.reset(new JobSetup( *pCurrentJobSetup ));
m_xDoc->getIDocumentDeviceAccess().setJobsetup( rSetup );
}
@@ -896,7 +896,6 @@ void SwDocShell::Draw( OutputDevice* pDev, const JobSetup& rSetup,
if( pOrig )
{
m_xDoc->getIDocumentDeviceAccess().setJobsetup( *pOrig );
- delete pOrig;
}
if ( bResetModified )
EnableSetModified();
diff --git a/sw/source/uibase/app/docsh2.cxx b/sw/source/uibase/app/docsh2.cxx
index ddcb76e54617..0d30c019c1d0 100644
--- a/sw/source/uibase/app/docsh2.cxx
+++ b/sw/source/uibase/app/docsh2.cxx
@@ -843,7 +843,7 @@ void SwDocShell::Execute(SfxRequest& rReq)
WriterRef xWrt;
// mba: looks as if relative URLs don't make sense here
::GetRTFWriter( OUString('O'), OUString(), xWrt );
- SvMemoryStream *pStrm = new SvMemoryStream();
+ std::unique_ptr<SvMemoryStream> pStrm (new SvMemoryStream());
pStrm->SetBufferSize( 16348 );
SwWriter aWrt( *pStrm, *GetDoc() );
ErrCode eErr = aWrt.Write( xWrt );
@@ -864,7 +864,7 @@ void SwDocShell::Execute(SfxRequest& rReq)
pStrm->Seek( STREAM_SEEK_TO_BEGIN );
// Transfer ownership of stream to a lockbytes object
- SvLockBytes aLockBytes( pStrm, true );
+ SvLockBytes aLockBytes( pStrm.release(), true );
SvLockBytesStat aStat;
if ( aLockBytes.Stat( &aStat ) == ERRCODE_NONE )
{
@@ -887,7 +887,6 @@ void SwDocShell::Execute(SfxRequest& rReq)
pStrm->GetData()), pStrm->GetEndOfData() );
pClipCntnr->CopyToClipboard(
GetView()? &GetView()->GetEditWin() : nullptr );
- delete pStrm;
}
}
else
diff --git a/sw/source/uibase/app/docstyle.cxx b/sw/source/uibase/app/docstyle.cxx
index 5979314905c8..e842ec88b3b4 100644
--- a/sw/source/uibase/app/docstyle.cxx
+++ b/sw/source/uibase/app/docstyle.cxx
@@ -1455,7 +1455,7 @@ void SwDocStyleSheet::SetItemSet( const SfxItemSet& rSet,
}
SwFormat* pFormat = nullptr;
- SwPageDesc* pNewDsc = nullptr;
+ std::unique_ptr<SwPageDesc> pNewDsc;
size_t nPgDscPos = 0;
switch(nFamily)
@@ -1611,7 +1611,7 @@ void SwDocStyleSheet::SetItemSet( const SfxItemSet& rSet,
if (rDoc.FindPageDesc(pDesc->GetName(), &nPgDscPos))
{
- pNewDsc = new SwPageDesc( *pDesc );
+ pNewDsc.reset( new SwPageDesc( *pDesc ) );
// #i48949# - no undo actions for the
// copy of the page style
::sw::UndoGuard const ug(rDoc.GetIDocumentUndoRedo());
@@ -1696,8 +1696,8 @@ void SwDocStyleSheet::SetItemSet( const SfxItemSet& rSet,
::ItemSetToPageDesc( aSet, *pNewDsc );
rDoc.ChgPageDesc( nPgDscPos, *pNewDsc );
pDesc = &rDoc.GetPageDesc( nPgDscPos );
- rDoc.PreDelPageDesc(pNewDsc); // #i7983#
- delete pNewDsc;
+ rDoc.PreDelPageDesc(pNewDsc.get()); // #i7983#
+ pNewDsc.reset();
}
else
rDoc.ChgFormat(*pFormat, aSet); // put all that is set
@@ -1707,8 +1707,8 @@ void SwDocStyleSheet::SetItemSet( const SfxItemSet& rSet,
aCoreSet.ClearItem();
if( pNewDsc ) // we still need to delete it
{
- rDoc.PreDelPageDesc(pNewDsc); // #i7983#
- delete pNewDsc;
+ rDoc.PreDelPageDesc(pNewDsc.get()); // #i7983#
+ pNewDsc.reset();
}
}