summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2017-06-13 18:03:18 +0200
committerStephan Bergmann <sbergman@redhat.com>2017-06-13 18:03:18 +0200
commitcbdd3c32703fd21b6911b5a6fc5803faeed9befb (patch)
tree34d88820a086096e8f36c00c0c68dad1269ffc41 /sfx2
parent423dacde87cbb3cba466c9701ed10dadc2b8b4e0 (diff)
Use unique_ptr for SfxPrinter::pOptions
Change-Id: I46be77225c0323f8b7f293de9c022f0de6f425b7
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/source/doc/printhelper.cxx2
-rw-r--r--sfx2/source/view/printer.cxx22
-rw-r--r--sfx2/source/view/viewprn.cxx4
3 files changed, 15 insertions, 13 deletions
diff --git a/sfx2/source/doc/printhelper.cxx b/sfx2/source/doc/printhelper.cxx
index 2072bd949e3e..f4824a6b8fe8 100644
--- a/sfx2/source/doc/printhelper.cxx
+++ b/sfx2/source/doc/printhelper.cxx
@@ -345,7 +345,7 @@ void SfxPrintHelper::impl_setPrinter(const uno::Sequence< beans::PropertyValue >
if ( aPrinterName != pPrinter->GetName() )
{
- pPrinter = VclPtr<SfxPrinter>::Create( pPrinter->GetOptions().Clone(), aPrinterName );
+ pPrinter = VclPtr<SfxPrinter>::Create( std::unique_ptr<SfxItemSet>(pPrinter->GetOptions().Clone()), aPrinterName );
nChangeFlags = SfxPrinterChangeFlags::PRINTER;
}
break;
diff --git a/sfx2/source/view/printer.cxx b/sfx2/source/view/printer.cxx
index 941aaa8cd131..5b9bf2212525 100644
--- a/sfx2/source/view/printer.cxx
+++ b/sfx2/source/view/printer.cxx
@@ -22,6 +22,8 @@
#include <vcl/msgbox.hxx>
#include <unotools/printwarningoptions.hxx>
#include <svtools/printoptions.hxx>
+
+#include <utility>
#include <vector>
#include <sfx2/printer.hxx>
@@ -59,7 +61,7 @@ struct SfxPrintOptDlg_Impl
// class SfxPrinter ------------------------------------------------------
-VclPtr<SfxPrinter> SfxPrinter::Create( SvStream& rStream, SfxItemSet* pOptions )
+VclPtr<SfxPrinter> SfxPrinter::Create( SvStream& rStream, std::unique_ptr<SfxItemSet>&& pOptions )
/* [Description]
@@ -78,7 +80,7 @@ VclPtr<SfxPrinter> SfxPrinter::Create( SvStream& rStream, SfxItemSet* pOptions )
ReadJobSetup( rStream, aFileJobSetup );
// Get printers
- VclPtr<SfxPrinter> pPrinter = VclPtr<SfxPrinter>::Create( pOptions, aFileJobSetup );
+ VclPtr<SfxPrinter> pPrinter = VclPtr<SfxPrinter>::Create( std::move(pOptions), aFileJobSetup );
return pPrinter;
}
@@ -95,13 +97,13 @@ void SfxPrinter::Store( SvStream& rStream ) const
}
-SfxPrinter::SfxPrinter( SfxItemSet* pTheOptions ) :
+SfxPrinter::SfxPrinter( std::unique_ptr<SfxItemSet>&& pTheOptions ) :
/* [Description]
This constructor creates a default printer.
*/
- pOptions( pTheOptions ),
+ pOptions( std::move(pTheOptions) ),
pImpl( new SfxPrinter_Impl ),
bKnown( true )
{
@@ -109,10 +111,10 @@ SfxPrinter::SfxPrinter( SfxItemSet* pTheOptions ) :
}
-SfxPrinter::SfxPrinter( SfxItemSet* pTheOptions,
+SfxPrinter::SfxPrinter( std::unique_ptr<SfxItemSet>&& pTheOptions,
const JobSetup& rTheOrigJobSetup ) :
Printer( rTheOrigJobSetup.GetPrinterName() ),
- pOptions( pTheOptions ),
+ pOptions( std::move(pTheOptions) ),
pImpl( new SfxPrinter_Impl )
{
assert(pOptions);
@@ -123,10 +125,10 @@ SfxPrinter::SfxPrinter( SfxItemSet* pTheOptions,
}
-SfxPrinter::SfxPrinter( SfxItemSet* pTheOptions,
+SfxPrinter::SfxPrinter( std::unique_ptr<SfxItemSet>&& pTheOptions,
const OUString& rPrinterName ) :
Printer( rPrinterName ),
- pOptions( pTheOptions ),
+ pOptions( std::move(pTheOptions) ),
pImpl( new SfxPrinter_Impl ),
bKnown( GetName() == rPrinterName )
{
@@ -157,7 +159,7 @@ VclPtr<SfxPrinter> SfxPrinter::Clone() const
{
if ( IsDefPrinter() )
{
- VclPtr<SfxPrinter> pNewPrinter = VclPtr<SfxPrinter>::Create( GetOptions().Clone() );
+ VclPtr<SfxPrinter> pNewPrinter = VclPtr<SfxPrinter>::Create( std::unique_ptr<SfxItemSet>(GetOptions().Clone()) );
pNewPrinter->SetJobSetup( GetJobSetup() );
pNewPrinter->SetPrinterProps( this );
pNewPrinter->SetMapMode( GetMapMode() );
@@ -179,7 +181,7 @@ SfxPrinter::~SfxPrinter()
void SfxPrinter::dispose()
{
- delete pOptions;
+ pOptions.reset();
pImpl.reset();
Printer::dispose();
}
diff --git a/sfx2/source/view/viewprn.cxx b/sfx2/source/view/viewprn.cxx
index ade45a9623df..a616d2d1237f 100644
--- a/sfx2/source/view/viewprn.cxx
+++ b/sfx2/source/view/viewprn.cxx
@@ -376,7 +376,7 @@ void SfxPrinterController::jobFinished( css::view::PrintableState nState )
pDocPrt->SetJobSetup( getPrinter()->GetJobSetup() );
else
{
- VclPtr<SfxPrinter> pNewPrt = VclPtr<SfxPrinter>::Create( pDocPrt->GetOptions().Clone(), getPrinter()->GetName() );
+ VclPtr<SfxPrinter> pNewPrt = VclPtr<SfxPrinter>::Create( std::unique_ptr<SfxItemSet>(pDocPrt->GetOptions().Clone()), getPrinter()->GetName() );
pNewPrt->SetJobSetup( getPrinter()->GetJobSetup() );
mpViewShell->SetPrinter( pNewPrt, SfxPrinterChangeFlags::PRINTER | SfxPrinterChangeFlags::JOBSETUP );
}
@@ -757,7 +757,7 @@ void SfxViewShell::ExecPrint_Impl( SfxRequest &rReq )
if ( pPrinterItem )
{
// use PrinterName parameter to create a printer
- pPrinter = VclPtr<SfxPrinter>::Create( pDocPrinter->GetOptions().Clone(), pPrinterItem->GetValue() );
+ pPrinter = VclPtr<SfxPrinter>::Create( std::unique_ptr<SfxItemSet>(pDocPrinter->GetOptions().Clone()), pPrinterItem->GetValue() );
// if printer is unknown, it can't be used - now printer from document will be used
if ( !pPrinter->IsKnown() )