[Libreoffice-commits] core.git: basctl/source include/sfx2 sc/source sd/source sfx2/source starmath/source sw/source

Stephan Bergmann sbergman at redhat.com
Tue Jun 13 16:03:45 UTC 2017


 basctl/source/basicide/basdoc.cxx            |    5 ++++-
 include/sfx2/printer.hxx                     |   10 +++++-----
 sc/source/core/data/documen8.cxx             |    9 +++++----
 sc/source/ui/unoobj/confuno.cxx              |   11 ++++++++---
 sd/source/ui/docshell/docshel4.cxx           |    5 +++--
 sd/source/ui/unoidl/UnoDocumentSettings.cxx  |   15 ++++++++++-----
 sfx2/source/doc/printhelper.cxx              |    2 +-
 sfx2/source/view/printer.cxx                 |   22 ++++++++++++----------
 sfx2/source/view/viewprn.cxx                 |    4 ++--
 starmath/source/document.cxx                 |    6 ++++--
 starmath/source/unomodel.cxx                 |    9 ++++++---
 sw/source/core/doc/DocumentDeviceManager.cxx |   10 ++++++----
 sw/source/ui/config/optpage.cxx              |    9 +++++++--
 sw/source/ui/dialog/ascfldlg.cxx             |    9 +++++++--
 sw/source/uibase/misc/glshell.cxx            |    7 ++++---
 sw/source/uibase/uno/SwXDocumentSettings.cxx |    9 ++++++---
 16 files changed, 90 insertions(+), 52 deletions(-)

New commits:
commit cbdd3c32703fd21b6911b5a6fc5803faeed9befb
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Tue Jun 13 18:03:18 2017 +0200

    Use unique_ptr for SfxPrinter::pOptions
    
    Change-Id: I46be77225c0323f8b7f293de9c022f0de6f425b7

diff --git a/basctl/source/basicide/basdoc.cxx b/basctl/source/basicide/basdoc.cxx
index 0e1ea3142c9e..5bfb75ab67a0 100644
--- a/basctl/source/basicide/basdoc.cxx
+++ b/basctl/source/basicide/basdoc.cxx
@@ -17,6 +17,9 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+#include <sal/config.h>
+
+#include <o3tl/make_unique.hxx>
 #include <sfx2/app.hxx>
 #include <sfx2/printer.hxx>
 #include <sfx2/objface.hxx>
@@ -59,7 +62,7 @@ DocShell::~DocShell()
 SfxPrinter* DocShell::GetPrinter( bool bCreate )
 {
     if ( !pPrinter && bCreate )
-        pPrinter.disposeAndReset(VclPtr<SfxPrinter>::Create(new SfxItemSet(
+        pPrinter.disposeAndReset(VclPtr<SfxPrinter>::Create(o3tl::make_unique<SfxItemSet>(
             GetPool(), SID_PRINTER_NOTFOUND_WARN, SID_PRINTER_NOTFOUND_WARN
         )));
 
diff --git a/include/sfx2/printer.hxx b/include/sfx2/printer.hxx
index a2c40249c793..9704a73562db 100644
--- a/include/sfx2/printer.hxx
+++ b/include/sfx2/printer.hxx
@@ -35,17 +35,17 @@ struct SfxPrinter_Impl;
 class SFX2_DLLPUBLIC SfxPrinter : public Printer
 {
 private:
-    SfxItemSet*             pOptions;
+    std::unique_ptr<SfxItemSet> pOptions;
     std::unique_ptr< SfxPrinter_Impl >  pImpl;
     bool                    bKnown;
 
     SAL_DLLPRIVATE void operator =(SfxPrinter &) = delete;
 
 public:
-                            SfxPrinter( SfxItemSet *pTheOptions );
-                            SfxPrinter( SfxItemSet *pTheOptions,
+                            SfxPrinter( std::unique_ptr<SfxItemSet> &&pTheOptions );
+                            SfxPrinter( std::unique_ptr<SfxItemSet> &&pTheOptions,
                                         const OUString &rPrinterName );
-                            SfxPrinter( SfxItemSet *pTheOptions,
+                            SfxPrinter( std::unique_ptr<SfxItemSet> &&pTheOptions,
                                         const JobSetup &rTheOrigJobSetup );
                             SfxPrinter( const SfxPrinter &rPrinter );
                             virtual ~SfxPrinter() override;
@@ -53,7 +53,7 @@ public:
 
     VclPtr<SfxPrinter>      Clone() const;
 
-    static VclPtr<SfxPrinter> Create( SvStream &rStream, SfxItemSet *pOptions );
+    static VclPtr<SfxPrinter> Create( SvStream &rStream, std::unique_ptr<SfxItemSet> &&pOptions );
     void                    Store( SvStream &rStream ) const;
 
     const SfxItemSet&       GetOptions() const { return *pOptions; }
diff --git a/sc/source/core/data/documen8.cxx b/sc/source/core/data/documen8.cxx
index a3f81f202d2b..d01155961a13 100644
--- a/sc/source/core/data/documen8.cxx
+++ b/sc/source/core/data/documen8.cxx
@@ -19,7 +19,7 @@
 
 #include "scitems.hxx"
 #include <editeng/eeitem.hxx>
-
+#include <o3tl/make_unique.hxx>
 #include <tools/urlobj.hxx>
 #include <editeng/editobj.hxx>
 #include <editeng/editstat.hxx>
@@ -88,6 +88,7 @@
 #include <scopetools.hxx>
 
 #include <memory>
+#include <utility>
 
 using namespace com::sun::star;
 
@@ -117,8 +118,8 @@ SfxPrinter* ScDocument::GetPrinter(bool bCreateIfNotExist)
 {
     if ( !pPrinter && bCreateIfNotExist )
     {
-        SfxItemSet* pSet =
-            new SfxItemSet( *xPoolHelper->GetDocPool(),
+        auto pSet =
+            o3tl::make_unique<SfxItemSet>( *xPoolHelper->GetDocPool(),
                             SID_PRINTER_NOTFOUND_WARN,  SID_PRINTER_NOTFOUND_WARN,
                             SID_PRINTER_CHANGESTODOC,   SID_PRINTER_CHANGESTODOC,
                             SID_PRINT_SELECTEDSHEET,    SID_PRINT_SELECTEDSHEET,
@@ -134,7 +135,7 @@ SfxPrinter* ScDocument::GetPrinter(bool bCreateIfNotExist)
         pSet->Put( SfxFlagItem( SID_PRINTER_CHANGESTODOC, static_cast<int>(nFlags) ) );
         pSet->Put( SfxBoolItem( SID_PRINTER_NOTFOUND_WARN, aMisc.IsNotFoundWarning() ) );
 
-        pPrinter = VclPtr<SfxPrinter>::Create( pSet );
+        pPrinter = VclPtr<SfxPrinter>::Create( std::move(pSet) );
         pPrinter->SetMapMode( MapUnit::Map100thMM );
         UpdateDrawPrinter();
         pPrinter->SetDigitLanguage( SC_MOD()->GetOptDigitLanguage() );
diff --git a/sc/source/ui/unoobj/confuno.cxx b/sc/source/ui/unoobj/confuno.cxx
index ea4fa66be20e..1cbab301bb6d 100644
--- a/sc/source/ui/unoobj/confuno.cxx
+++ b/sc/source/ui/unoobj/confuno.cxx
@@ -17,6 +17,10 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+#include <sal/config.h>
+
+#include <utility>
+
 #include <config_features.h>
 
 #include "confuno.hxx"
@@ -33,6 +37,7 @@
 #include <com/sun/star/document/LinkUpdateModes.hpp>
 #include <cppuhelper/supportsservice.hxx>
 #include <formula/grammar.hxx>
+#include <o3tl/make_unique.hxx>
 #include <sfx2/printer.hxx>
 #include <xmloff/xmluconv.hxx>
 #include <rtl/ustrbuf.hxx>
@@ -207,7 +212,7 @@ void SAL_CALL ScDocumentConfiguration::setPropertyValue(
                     {
                         if (pPrinter->GetName() != sPrinterName)
                         {
-                            VclPtrInstance<SfxPrinter> pNewPrinter( pPrinter->GetOptions().Clone(), sPrinterName );
+                            VclPtrInstance<SfxPrinter> pNewPrinter( std::unique_ptr<SfxItemSet>(pPrinter->GetOptions().Clone()), sPrinterName );
                             if (pNewPrinter->IsKnown())
                                 pDocShell->SetPrinter( pNewPrinter, SfxPrinterChangeFlags::PRINTER );
                             else
@@ -232,13 +237,13 @@ void SAL_CALL ScDocumentConfiguration::setPropertyValue(
                 {
                     SvMemoryStream aStream (aSequence.getArray(), nSize, StreamMode::READ );
                     aStream.Seek ( STREAM_SEEK_TO_BEGIN );
-                    SfxItemSet* pSet = new SfxItemSet( *rDoc.GetPool(),
+                    auto pSet = o3tl::make_unique<SfxItemSet>( *rDoc.GetPool(),
                             SID_PRINTER_NOTFOUND_WARN, SID_PRINTER_NOTFOUND_WARN,
                             SID_PRINTER_CHANGESTODOC,  SID_PRINTER_CHANGESTODOC,
                             SID_PRINT_SELECTEDSHEET,   SID_PRINT_SELECTEDSHEET,
                             SID_SCPRINTOPTIONS,        SID_SCPRINTOPTIONS,
                             nullptr );
-                    pDocShell->SetPrinter( SfxPrinter::Create( aStream, pSet ) );
+                    pDocShell->SetPrinter( SfxPrinter::Create( aStream, std::move(pSet) ) );
                 }
             }
         }
diff --git a/sd/source/ui/docshell/docshel4.cxx b/sd/source/ui/docshell/docshel4.cxx
index 1e4c7c885d94..3f680f6871f2 100644
--- a/sd/source/ui/docshell/docshel4.cxx
+++ b/sd/source/ui/docshell/docshel4.cxx
@@ -20,6 +20,7 @@
 #include <sal/config.h>
 
 #include <memory>
+#include <utility>
 
 #include "DrawDocShell.hxx"
 #include <com/sun/star/document/PrinterIndependentLayout.hpp>
@@ -98,7 +99,7 @@ SfxPrinter* DrawDocShell::GetPrinter(bool bCreate)
     if (bCreate && !mpPrinter)
     {
         // create ItemSet with special pool area
-        SfxItemSet* pSet = new SfxItemSet( GetPool(),
+        auto pSet = o3tl::make_unique<SfxItemSet>( GetPool(),
                             SID_PRINTER_NOTFOUND_WARN,  SID_PRINTER_NOTFOUND_WARN,
                             SID_PRINTER_CHANGESTODOC,   SID_PRINTER_CHANGESTODOC,
                             ATTR_OPTIONS_PRINT,         ATTR_OPTIONS_PRINT,
@@ -115,7 +116,7 @@ SfxPrinter* DrawDocShell::GetPrinter(bool bCreate)
         pSet->Put( SfxBoolItem( SID_PRINTER_NOTFOUND_WARN, aPrintItem.GetOptionsPrint().IsWarningPrinter() ) );
         pSet->Put( aFlagItem );
 
-        mpPrinter = VclPtr<SfxPrinter>::Create(pSet);
+        mpPrinter = VclPtr<SfxPrinter>::Create(std::move(pSet));
         mbOwnPrinter = true;
 
         // set output quality
diff --git a/sd/source/ui/unoidl/UnoDocumentSettings.cxx b/sd/source/ui/unoidl/UnoDocumentSettings.cxx
index 0a5fd35da367..3958c469867a 100644
--- a/sd/source/ui/unoidl/UnoDocumentSettings.cxx
+++ b/sd/source/ui/unoidl/UnoDocumentSettings.cxx
@@ -17,6 +17,10 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+#include <sal/config.h>
+
+#include <memory>
+#include <utility>
 #include <vector>
 #include <com/sun/star/embed/XStorage.hpp>
 #include <com/sun/star/embed/ElementModes.hpp>
@@ -29,6 +33,7 @@
 #include <cppuhelper/supportsservice.hxx>
 #include <comphelper/propertysethelper.hxx>
 #include <comphelper/propertysetinfo.hxx>
+#include <o3tl/make_unique.hxx>
 #include <tools/urlobj.hxx>
 #include <svx/xtable.hxx>
 #include <osl/mutex.hxx>
@@ -722,7 +727,7 @@ DocumentSettings::_setPropertyValues(const PropertyMapEntry** ppEntries,
                             SfxPrinter *pTempPrinter = pDocSh->GetPrinter( true );
                             if (pTempPrinter)
                             {
-                                VclPtr<SfxPrinter> pNewPrinter = VclPtr<SfxPrinter>::Create( pTempPrinter->GetOptions().Clone(), aPrinterName );
+                                VclPtr<SfxPrinter> pNewPrinter = VclPtr<SfxPrinter>::Create( std::unique_ptr<SfxItemSet>(pTempPrinter->GetOptions().Clone()), aPrinterName );
                                 pDocSh->SetPrinter( pNewPrinter );
                             }
                         }
@@ -740,22 +745,22 @@ DocumentSettings::_setPropertyValues(const PropertyMapEntry** ppEntries,
                         {
                             SvMemoryStream aStream (aSequence.getArray(), nSize, StreamMode::READ );
                             aStream.Seek ( STREAM_SEEK_TO_BEGIN );
-                            SfxItemSet* pItemSet;
+                            std::unique_ptr<SfxItemSet> pItemSet;
 
                             if( pPrinter )
                             {
-                                pItemSet = pPrinter->GetOptions().Clone();
+                                pItemSet.reset(pPrinter->GetOptions().Clone());
                             }
                             else
                             {
-                                pItemSet = new SfxItemSet(pDoc->GetPool(),
+                                pItemSet = o3tl::make_unique<SfxItemSet>(pDoc->GetPool(),
                                             SID_PRINTER_NOTFOUND_WARN,  SID_PRINTER_NOTFOUND_WARN,
                                             SID_PRINTER_CHANGESTODOC,   SID_PRINTER_CHANGESTODOC,
                                             ATTR_OPTIONS_PRINT,         ATTR_OPTIONS_PRINT,
                                             0 );
                             }
 
-                            pPrinter = SfxPrinter::Create ( aStream, pItemSet );
+                            pPrinter = SfxPrinter::Create ( aStream, std::move(pItemSet) );
 
                             MapMode aMM (pPrinter->GetMapMode());
                             aMM.SetMapUnit(MapUnit::Map100thMM);
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() )
diff --git a/starmath/source/document.cxx b/starmath/source/document.cxx
index 1e9e2ee0c7a6..90720004064e 100644
--- a/starmath/source/document.cxx
+++ b/starmath/source/document.cxx
@@ -24,6 +24,7 @@
 #include <comphelper/accessibletexthelper.hxx>
 #include <comphelper/processfactory.hxx>
 #include <comphelper/storagehelper.hxx>
+#include <o3tl/make_unique.hxx>
 #include <rtl/ustrbuf.hxx>
 #include <rtl/ustring.hxx>
 #include <unotools/eventcfg.hxx>
@@ -94,6 +95,7 @@
 #include "accessibility.hxx"
 #include "cfgitem.hxx"
 #include <memory>
+#include <utility>
 
 using namespace ::com::sun::star;
 using namespace ::com::sun::star::accessibility;
@@ -558,7 +560,7 @@ Printer* SmDocShell::GetPrt()
     }
     else if (!mpPrinter)
     {
-        SfxItemSet* pOptions = new SfxItemSet(GetPool(),
+        auto pOptions = o3tl::make_unique<SfxItemSet>(GetPool(),
                                               SID_PRINTSIZE,       SID_PRINTSIZE,
                                               SID_PRINTZOOM,       SID_PRINTZOOM,
                                               SID_PRINTTITLE,      SID_PRINTTITLE,
@@ -570,7 +572,7 @@ Printer* SmDocShell::GetPrt()
                                               0);
         SmModule *pp = SM_MOD();
         pp->GetConfig()->ConfigToItemSet(*pOptions);
-        mpPrinter = VclPtr<SfxPrinter>::Create(pOptions);
+        mpPrinter = VclPtr<SfxPrinter>::Create(std::move(pOptions));
         mpPrinter->SetMapMode(MapMode(MapUnit::Map100thMM));
     }
     return mpPrinter;
diff --git a/starmath/source/unomodel.cxx b/starmath/source/unomodel.cxx
index 5b2fbf89f60b..53423f4160fc 100644
--- a/starmath/source/unomodel.cxx
+++ b/starmath/source/unomodel.cxx
@@ -19,7 +19,10 @@
 
 #include <sal/config.h>
 
+#include <utility>
+
 #include <o3tl/any.hxx>
+#include <o3tl/make_unique.hxx>
 #include <osl/mutex.hxx>
 #include <sfx2/printer.hxx>
 #include <vcl/svapp.hxx>
@@ -591,7 +594,7 @@ void SmModel::_setPropertyValues(const PropertyMapEntry** ppEntries, const Any*
                         {
                             if ( !sPrinterName.isEmpty() )
                             {
-                                VclPtrInstance<SfxPrinter> pNewPrinter( pPrinter->GetOptions().Clone(), sPrinterName );
+                                VclPtrInstance<SfxPrinter> pNewPrinter( std::unique_ptr<SfxItemSet>(pPrinter->GetOptions().Clone()), sPrinterName );
                                 if (pNewPrinter->IsKnown())
                                     pDocSh->SetPrinter ( pNewPrinter );
                                 else
@@ -624,10 +627,10 @@ void SmModel::_setPropertyValues(const PropertyMapEntry** ppEntries, const Any*
                         SID_AUTO_CLOSE_BRACKETS,    SID_AUTO_CLOSE_BRACKETS,
                         0
                     };
-                    SfxItemSet *pItemSet = new SfxItemSet( SmDocShell::GetPool(), nRange );
+                    auto pItemSet = o3tl::make_unique<SfxItemSet>( SmDocShell::GetPool(), nRange );
                     SmModule *pp = SM_MOD();
                     pp->GetConfig()->ConfigToItemSet(*pItemSet);
-                    VclPtr<SfxPrinter> pPrinter = SfxPrinter::Create ( aStream, pItemSet );
+                    VclPtr<SfxPrinter> pPrinter = SfxPrinter::Create ( aStream, std::move(pItemSet) );
 
                     pDocSh->SetPrinter( pPrinter );
                 }
diff --git a/sw/source/core/doc/DocumentDeviceManager.cxx b/sw/source/core/doc/DocumentDeviceManager.cxx
index fbcfdb7dfe2d..b5ccaa5aead6 100644
--- a/sw/source/core/doc/DocumentDeviceManager.cxx
+++ b/sw/source/core/doc/DocumentDeviceManager.cxx
@@ -20,6 +20,7 @@
 #include <DocumentDeviceManager.hxx>
 
 #include <memory>
+#include <utility>
 
 #include <IDocumentDeviceAccess.hxx>
 #include <doc.hxx>
@@ -27,6 +28,7 @@
 #include <IDocumentDrawModelAccess.hxx>
 #include <IDocumentState.hxx>
 #include <IDocumentLayoutAccess.hxx>
+#include <o3tl/make_unique.hxx>
 #include <sfx2/printer.hxx>
 #include <vcl/virdev.hxx>
 #include <vcl/outdev.hxx>
@@ -204,13 +206,13 @@ void DocumentDeviceManager::setJobsetup(/*[in]*/ const JobSetup &rJobSetup )
     if( !mpPrt )
     {
         //The ItemSet is deleted by Sfx!
-        SfxItemSet *pSet = new SfxItemSet( m_rDoc.GetAttrPool(),
+        auto pSet = o3tl::make_unique<SfxItemSet>( m_rDoc.GetAttrPool(),
                         FN_PARAM_ADDPRINTER, FN_PARAM_ADDPRINTER,
                         SID_HTML_MODE,  SID_HTML_MODE,
                         SID_PRINTER_NOTFOUND_WARN, SID_PRINTER_NOTFOUND_WARN,
                         SID_PRINTER_CHANGESTODOC, SID_PRINTER_CHANGESTODOC,
                         0 );
-        VclPtr<SfxPrinter> p = VclPtr<SfxPrinter>::Create( pSet, rJobSetup );
+        VclPtr<SfxPrinter> p = VclPtr<SfxPrinter>::Create( std::move(pSet), rJobSetup );
         if ( bCheckPageDescs )
             setPrinter( p, true, true );
         else
@@ -288,14 +290,14 @@ SfxPrinter& DocumentDeviceManager::CreatePrinter_() const
 
     // We create a default SfxPrinter.
     // The ItemSet is deleted by Sfx!
-    SfxItemSet *pSet = new SfxItemSet( m_rDoc.GetAttrPool(),
+    auto pSet = o3tl::make_unique<SfxItemSet>( m_rDoc.GetAttrPool(),
                     FN_PARAM_ADDPRINTER, FN_PARAM_ADDPRINTER,
                     SID_HTML_MODE,  SID_HTML_MODE,
                     SID_PRINTER_NOTFOUND_WARN, SID_PRINTER_NOTFOUND_WARN,
                     SID_PRINTER_CHANGESTODOC, SID_PRINTER_CHANGESTODOC,
                     0 );
 
-    VclPtr<SfxPrinter> pNewPrt = VclPtr<SfxPrinter>::Create( pSet );
+    VclPtr<SfxPrinter> pNewPrt = VclPtr<SfxPrinter>::Create( std::move(pSet) );
     const_cast<DocumentDeviceManager*>(this)->setPrinter( pNewPrt, true, true );
     return *mpPrt.get();
 }
diff --git a/sw/source/ui/config/optpage.cxx b/sw/source/ui/config/optpage.cxx
index 8c6306eb839b..83e249172f0e 100644
--- a/sw/source/ui/config/optpage.cxx
+++ b/sw/source/ui/config/optpage.cxx
@@ -17,6 +17,10 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+#include <sal/config.h>
+
+#include <utility>
+
 #include <optpage.hxx>
 #include <doc.hxx>
 #include <hintids.hxx>
@@ -49,6 +53,7 @@
 #include <editeng/fontitem.hxx>
 #include <editeng/langitem.hxx>
 #include <editeng/svxenum.hxx>
+#include <o3tl/make_unique.hxx>
 #include <sal/macros.h>
 #include <sfx2/dialoghelper.hxx>
 #include <sfx2/request.hxx>
@@ -806,11 +811,11 @@ void SwStdFontTabPage::Reset( const SfxItemSet* rSet)
     }
     else
     {
-        SfxItemSet* pPrinterSet = new SfxItemSet( *rSet->GetPool(),
+        auto pPrinterSet = o3tl::make_unique<SfxItemSet>( *rSet->GetPool(),
                     SID_PRINTER_NOTFOUND_WARN, SID_PRINTER_NOTFOUND_WARN,
                     SID_PRINTER_CHANGESTODOC, SID_PRINTER_CHANGESTODOC,
                     0 );
-        m_pPrt = VclPtr<SfxPrinter>::Create(pPrinterSet);
+        m_pPrt = VclPtr<SfxPrinter>::Create(std::move(pPrinterSet));
     }
     delete m_pFontList;
     m_pFontList = new FontList( m_pPrt );
diff --git a/sw/source/ui/dialog/ascfldlg.cxx b/sw/source/ui/dialog/ascfldlg.cxx
index 75e518af1657..665bd8d7a331 100644
--- a/sw/source/ui/dialog/ascfldlg.cxx
+++ b/sw/source/ui/dialog/ascfldlg.cxx
@@ -17,7 +17,12 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+#include <sal/config.h>
+
+#include <utility>
+
 #include <hintids.hxx>
+#include <o3tl/make_unique.hxx>
 #include <rtl/textenc.h>
 #include <i18nlangtag/mslangid.hxx>
 #include <com/sun/star/i18n/ScriptType.hpp>
@@ -177,11 +182,11 @@ SwAsciiFilterDlg::SwAsciiFilterDlg( vcl::Window* pParent, SwDocShell& rDocSh,
             VclPtr<SfxPrinter> pPrt = pDoc ? pDoc->getIDocumentDeviceAccess().getPrinter(false) : nullptr;
             if( !pPrt )
             {
-                SfxItemSet* pSet = new SfxItemSet( rDocSh.GetPool(),
+                auto pSet = o3tl::make_unique<SfxItemSet>( rDocSh.GetPool(),
                             SID_PRINTER_NOTFOUND_WARN, SID_PRINTER_NOTFOUND_WARN,
                             SID_PRINTER_CHANGESTODOC, SID_PRINTER_CHANGESTODOC,
                             0 );
-                pPrt = VclPtr<SfxPrinter>::Create( pSet );
+                pPrt = VclPtr<SfxPrinter>::Create( std::move(pSet) );
                 bDelPrinter = true;
             }
 
diff --git a/sw/source/uibase/misc/glshell.cxx b/sw/source/uibase/misc/glshell.cxx
index e3e6273a9fb5..f9be5953fe7c 100644
--- a/sw/source/uibase/misc/glshell.cxx
+++ b/sw/source/uibase/misc/glshell.cxx
@@ -18,7 +18,7 @@
  */
 
 #include <com/sun/star/frame/XTitle.hpp>
-
+#include <o3tl/make_unique.hxx>
 #include <svl/eitem.hxx>
 #include <svl/stritem.hxx>
 #include <sfx2/printer.hxx>
@@ -53,6 +53,7 @@
 #include <sfx2/msg.hxx>
 #include <swslots.hxx>
 #include <memory>
+#include <utility>
 
 using namespace ::com::sun::star;
 
@@ -239,12 +240,12 @@ SwDocShellRef SwGlossaries::EditGroupDoc( const OUString& rGroup, const OUString
         {
             // we create a default SfxPrinter.
             // ItemSet is deleted by Sfx!
-            SfxItemSet *pSet = new SfxItemSet( xDocSh->GetDoc()->GetAttrPool(),
+            auto pSet = o3tl::make_unique<SfxItemSet>( xDocSh->GetDoc()->GetAttrPool(),
                         FN_PARAM_ADDPRINTER, FN_PARAM_ADDPRINTER,
                         SID_PRINTER_NOTFOUND_WARN, SID_PRINTER_NOTFOUND_WARN,
                         SID_PRINTER_CHANGESTODOC, SID_PRINTER_CHANGESTODOC,
                         0 );
-            VclPtr<SfxPrinter> pPrinter = VclPtr<SfxPrinter>::Create( pSet );
+            VclPtr<SfxPrinter> pPrinter = VclPtr<SfxPrinter>::Create( std::move(pSet) );
 
             // and append it to the document.
             xDocSh->GetDoc()->getIDocumentDeviceAccess().setPrinter( pPrinter, true, true );
diff --git a/sw/source/uibase/uno/SwXDocumentSettings.cxx b/sw/source/uibase/uno/SwXDocumentSettings.cxx
index dfc3586184e7..7c314d82fc08 100644
--- a/sw/source/uibase/uno/SwXDocumentSettings.cxx
+++ b/sw/source/uibase/uno/SwXDocumentSettings.cxx
@@ -19,7 +19,10 @@
 
 #include <sal/config.h>
 
+#include <utility>
+
 #include <o3tl/any.hxx>
+#include <o3tl/make_unique.hxx>
 #include <osl/mutex.hxx>
 #include <sfx2/sfxbasecontroller.hxx>
 #include <SwXDocumentSettings.hxx>
@@ -388,7 +391,7 @@ void SwXDocumentSettings::_setSingleValue( const comphelper::PropertyInfo & rInf
                     SfxPrinter* pPrinter = mpDoc->getIDocumentDeviceAccess().getPrinter( true );
                     if ( pPrinter->GetName() != sPrinterName )
                     {
-                        VclPtrInstance<SfxPrinter> pNewPrinter( pPrinter->GetOptions().Clone(), sPrinterName );
+                        VclPtrInstance<SfxPrinter> pNewPrinter( std::unique_ptr<SfxItemSet>(pPrinter->GetOptions().Clone()), sPrinterName );
                         assert (! pNewPrinter->isDisposed() );
                         if( pNewPrinter->IsKnown() )
                         {
@@ -425,8 +428,8 @@ void SwXDocumentSettings::_setSingleValue( const comphelper::PropertyInfo & rInf
                         SID_PRINTER_CHANGESTODOC, SID_PRINTER_CHANGESTODOC,
                         0
                     };
-                    SfxItemSet *pItemSet = new SfxItemSet( mpDoc->GetAttrPool(), nRange );
-                    VclPtr<SfxPrinter> pPrinter = SfxPrinter::Create ( aStream, pItemSet );
+                    auto pItemSet = o3tl::make_unique<SfxItemSet>( mpDoc->GetAttrPool(), nRange );
+                    VclPtr<SfxPrinter> pPrinter = SfxPrinter::Create ( aStream, std::move(pItemSet) );
                     assert (! pPrinter->isDisposed() );
                     // set printer only once; in _postSetValues
                     mpPrinter.disposeAndClear();


More information about the Libreoffice-commits mailing list