[Libreoffice-commits] core.git: 2 commits - sc/inc sc/source

Noel Grandin noel.grandin at collabora.co.uk
Wed Jul 11 06:07:38 UTC 2018


 sc/inc/docuno.hxx              |    4 ++--
 sc/source/ui/inc/printfun.hxx  |    4 ++--
 sc/source/ui/unoobj/docuno.cxx |   21 +++++++++------------
 sc/source/ui/view/printfun.cxx |   10 +++++-----
 4 files changed, 18 insertions(+), 21 deletions(-)

New commits:
commit 72eb6f7e47d7c8c19c76cea67330464af47648f1
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Tue Jul 10 13:04:24 2018 +0200

    loplugin:useuniqueptr in ScPrintFunc
    
    Change-Id: I135c0a333633bbdc362fb80699c6d009a80b23a5
    Reviewed-on: https://gerrit.libreoffice.org/57243
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/sc/source/ui/inc/printfun.hxx b/sc/source/ui/inc/printfun.hxx
index d96fb277b788..f298eeb0db4e 100644
--- a/sc/source/ui/inc/printfun.hxx
+++ b/sc/source/ui/inc/printfun.hxx
@@ -264,8 +264,8 @@ private:
 
     sc::PrintPageRanges m_aRanges;
 
-    ScHeaderEditEngine* pEditEngine;
-    SfxItemSet*         pEditDefaults;
+    std::unique_ptr<ScHeaderEditEngine> pEditEngine;
+    std::unique_ptr<SfxItemSet>         pEditDefaults;
 
     ScHeaderFieldData   aFieldData;
 
diff --git a/sc/source/ui/view/printfun.cxx b/sc/source/ui/view/printfun.cxx
index f96fd9b74d28..6087ef2bee21 100644
--- a/sc/source/ui/view/printfun.cxx
+++ b/sc/source/ui/view/printfun.cxx
@@ -400,8 +400,8 @@ void ScPrintFunc::FillPageData()
 
 ScPrintFunc::~ScPrintFunc()
 {
-    delete pEditDefaults;
-    delete pEditEngine;
+    pEditDefaults.reset();
+    pEditEngine.reset();
 
     //  Printer settings are now restored from outside
 
@@ -1704,7 +1704,7 @@ void ScPrintFunc::MakeEditEngine()
     {
         //  can't use document's edit engine pool here,
         //  because pool must have twips as default metric
-        pEditEngine = new ScHeaderEditEngine( EditEngine::CreatePool() );
+        pEditEngine.reset( new ScHeaderEditEngine( EditEngine::CreatePool() ) );
 
         pEditEngine->EnableUndo(false);
         //fdo#45869 we want text to be positioned as it would be for the
@@ -1718,10 +1718,10 @@ void ScPrintFunc::MakeEditEngine()
         pEditEngine->EnableAutoColor( bUseStyleColor );
 
         //  Default-Set for alignment
-        pEditDefaults = new SfxItemSet( pEditEngine->GetEmptyItemSet() );
+        pEditDefaults.reset( new SfxItemSet( pEditEngine->GetEmptyItemSet() ) );
 
         const ScPatternAttr& rPattern = pDoc->GetPool()->GetDefaultItem(ATTR_PATTERN);
-        rPattern.FillEditItemSet( pEditDefaults );
+        rPattern.FillEditItemSet( pEditDefaults.get() );
         //  FillEditItemSet adjusts font height to 1/100th mm,
         //  but for header/footer twips is needed, as in the PatternAttr:
         std::unique_ptr<SfxPoolItem> pNewItem(rPattern.GetItem(ATTR_FONT_HEIGHT).CloneSetWhich(EE_CHAR_FONTHEIGHT));
commit 92c2a7e026beaaabf4cd3b8c612c15e9b933a90a
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Tue Jul 10 11:17:50 2018 +0200

    loplugin:useuniqueptr in ScModelObj
    
    Change-Id: I12635d45555bc59d14134b8eef3e093f3fd4e6a0
    Reviewed-on: https://gerrit.libreoffice.org/57242
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/sc/inc/docuno.hxx b/sc/inc/docuno.hxx
index c9a450210ef3..630caed76206 100644
--- a/sc/inc/docuno.hxx
+++ b/sc/inc/docuno.hxx
@@ -93,8 +93,8 @@ class SC_DLLPUBLIC ScModelObj : public SfxBaseModel,
 private:
     SfxItemPropertySet      aPropSet;
     ScDocShell*             pDocShell;
-    ScPrintFuncCache*       pPrintFuncCache;
-    ScPrintUIOptions*       pPrinterOptions;
+    std::unique_ptr<ScPrintFuncCache> pPrintFuncCache;
+    std::unique_ptr<ScPrintUIOptions> pPrinterOptions;
     std::unique_ptr<ScPrintState> m_pPrintState;
     css::uno::Reference<css::uno::XAggregation> xNumberAgg;
     css::uno::Reference<css::uno::XInterface> xDrawGradTab;
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index b910162833ef..06a5d3e122d7 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -410,8 +410,8 @@ ScModelObj::~ScModelObj()
     if (xNumberAgg.is())
         xNumberAgg->setDelegator(uno::Reference<uno::XInterface>());
 
-    delete pPrintFuncCache;
-    delete pPrinterOptions;
+    pPrintFuncCache.reset();
+    pPrinterOptions.reset();
 }
 
 uno::Reference< uno::XAggregation> const & ScModelObj::GetFormatter()
@@ -1336,7 +1336,7 @@ void ScModelObj::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
                 pNumFmt->SetNumberFormatter( nullptr );
         }
 
-        DELETEZ( pPrintFuncCache );     // must be deleted because it has a pointer to the DocShell
+        pPrintFuncCache.reset();     // must be deleted because it has a pointer to the DocShell
         m_pPrintState.reset();
     }
     else if ( nId == SfxHintId::DataChanged )
@@ -1344,7 +1344,7 @@ void ScModelObj::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
         //  cached data for rendering become invalid when contents change
         //  (if a broadcast is added to SetDrawModified, is has to be tested here, too)
 
-        DELETEZ( pPrintFuncCache );
+        pPrintFuncCache.reset();
         m_pPrintState.reset();
 
         // handle "OnCalculate" sheet events (search also for VBA event handlers)
@@ -1708,8 +1708,7 @@ sal_Int32 SAL_CALL ScModelObj::getRendererCount(const uno::Any& aSelection,
 
     if ( !pPrintFuncCache || !pPrintFuncCache->IsSameSelection( aStatus ) )
     {
-        delete pPrintFuncCache;
-        pPrintFuncCache = new ScPrintFuncCache( pDocShell, aMark, aStatus );
+        pPrintFuncCache.reset(new ScPrintFuncCache( pDocShell, aMark, aStatus ));
     }
     sal_Int32 nPages = pPrintFuncCache->GetPageCount();
 
@@ -1763,8 +1762,7 @@ uno::Sequence<beans::PropertyValue> SAL_CALL ScModelObj::getRenderer( sal_Int32
     {
         if ( !pPrintFuncCache || !pPrintFuncCache->IsSameSelection( aStatus ) )
         {
-            delete pPrintFuncCache;
-            pPrintFuncCache = new ScPrintFuncCache( pDocShell, aMark, aStatus );
+            pPrintFuncCache.reset(new ScPrintFuncCache( pDocShell, aMark, aStatus ));
         }
         nTotalPages = pPrintFuncCache->GetPageCount();
     }
@@ -1802,7 +1800,7 @@ uno::Sequence<beans::PropertyValue> SAL_CALL ScModelObj::getRenderer( sal_Int32
         }));
 
         if( ! pPrinterOptions )
-            pPrinterOptions = new ScPrintUIOptions;
+            pPrinterOptions.reset(new ScPrintUIOptions);
         else
             pPrinterOptions->SetDefaults();
         pPrinterOptions->appendPrintUIOptions( aSequence );
@@ -1886,7 +1884,7 @@ uno::Sequence<beans::PropertyValue> SAL_CALL ScModelObj::getRenderer( sal_Int32
     }
 
     if( ! pPrinterOptions )
-        pPrinterOptions = new ScPrintUIOptions;
+        pPrinterOptions.reset(new ScPrintUIOptions);
     else
         pPrinterOptions->SetDefaults();
     pPrinterOptions->appendPrintUIOptions( aSequence );
@@ -1912,8 +1910,7 @@ void SAL_CALL ScModelObj::render( sal_Int32 nSelRenderer, const uno::Any& aSelec
 
     if ( !pPrintFuncCache || !pPrintFuncCache->IsSameSelection( aStatus ) )
     {
-        delete pPrintFuncCache;
-        pPrintFuncCache = new ScPrintFuncCache( pDocShell, aMark, aStatus );
+        pPrintFuncCache.reset(new ScPrintFuncCache( pDocShell, aMark, aStatus ));
     }
     long nTotalPages = pPrintFuncCache->GetPageCount();
     sal_Int32 nRenderer = lcl_GetRendererNum( nSelRenderer, aPagesStr, nTotalPages );


More information about the Libreoffice-commits mailing list