summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-09-14 13:54:12 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-09-18 08:59:27 +0200
commit81d7755d026f1f7b34140d5a090a7ee24c7f62f3 (patch)
tree76f13dc5967309cc36331c9f9208bedfcaa9510a
parentddb67a4e6ec3e9de6cf5b2e47c1ce3d9cfd2b05d (diff)
loplugin:useuniqueptr in SwViewShell::PrintOrPDFExport
Change-Id: Id32017ea2d3214e2bb568501ec633f182c5766de Reviewed-on: https://gerrit.libreoffice.org/60603 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--sw/source/core/view/vprint.cxx17
1 files changed, 8 insertions, 9 deletions
diff --git a/sw/source/core/view/vprint.cxx b/sw/source/core/view/vprint.cxx
index ebae2c55c8f0..82a677aea364 100644
--- a/sw/source/core/view/vprint.cxx
+++ b/sw/source/core/view/vprint.cxx
@@ -492,7 +492,7 @@ bool SwViewShell::PrintOrPDFExport(
// It is implemented this way because PDF export calls this Prt function
// once per page and we do not like to always have the temporary document
// to be created that often here.
- SwViewShell *pShell = new SwViewShell(*this, nullptr, pOutDev);
+ std::unique_ptr<SwViewShell> pShell(new SwViewShell(*this, nullptr, pOutDev));
SdrView *pDrawView = pShell->GetDrawView();
if (pDrawView)
@@ -503,7 +503,7 @@ bool SwViewShell::PrintOrPDFExport(
{ // additional scope so that the CurrShell is reset before destroying the shell
- SET_CURR_SHELL( pShell );
+ SET_CURR_SHELL( pShell.get() );
//JP 01.02.99: Bug 61335 - the ReadOnly flag is never copied
if( mpOpt->IsReadonly() )
@@ -519,7 +519,7 @@ bool SwViewShell::PrintOrPDFExport(
"SwViewShell::PrintOrPDFExport: nPage not valid" );
SwViewShell *const pViewSh2 = (nPage < 0)
? rPrintData.GetRenderData().m_pPostItShell.get()// post-it page
- : pShell; // a 'regular' page, not one from the post-it doc
+ : pShell.get(); // a 'regular' page, not one from the post-it doc
SwPageFrame const*const pStPage =
sw_getPage(*pViewSh2->GetLayout(), abs(nPage));
@@ -577,7 +577,7 @@ bool SwViewShell::PrintOrPDFExport(
}
}
- delete pShell;
+ pShell.reset();
// restore settings of OutputDevice (should be done always now since the
// output device is now provided by a call from outside the Writer)
@@ -591,14 +591,14 @@ void SwViewShell::PrtOle2( SwDoc *pDoc, const SwViewOption *pOpt, const SwPrintD
{
// For printing a shell is needed. Either the Doc already has one, than we
// create a new view, or it has none, than we create the first view.
- SwViewShell *pSh;
+ std::unique_ptr<SwViewShell> pSh;
if( pDoc->getIDocumentLayoutAccess().GetCurrentViewShell() )
- pSh = new SwViewShell( *pDoc->getIDocumentLayoutAccess().GetCurrentViewShell(), nullptr, &rRenderContext,VSHELLFLAG_SHARELAYOUT );
+ pSh.reset(new SwViewShell( *pDoc->getIDocumentLayoutAccess().GetCurrentViewShell(), nullptr, &rRenderContext,VSHELLFLAG_SHARELAYOUT ));
else
- pSh = new SwViewShell( *pDoc, nullptr, pOpt, &rRenderContext);
+ pSh.reset(new SwViewShell( *pDoc, nullptr, pOpt, &rRenderContext));
{
- SET_CURR_SHELL( pSh );
+ SET_CURR_SHELL( pSh.get() );
pSh->PrepareForPrint( rOptions );
pSh->SetPrtFormatOption( true );
@@ -625,7 +625,6 @@ void SwViewShell::PrtOle2( SwDoc *pDoc, const SwViewOption *pOpt, const SwPrintD
rRenderContext.Pop();
// first the CurrShell object needs to be destroyed!
}
- delete pSh;
}
/// Check if the DocNodesArray contains fields.