Kaydet (Commit) e450351a authored tarafından Noel Grandin's avatar Noel Grandin

use unique_ptr in sw

Change-Id: I369ef79e88a40c01f5384e2427c3dec429ea0457
Reviewed-on: https://gerrit.libreoffice.org/66311
Tested-by: Jenkins
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 35ea8fc2
......@@ -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();
......
......@@ -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
......
......@@ -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();
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment