compilerplugins/clang/useuniqueptr.cxx           |    3 ++
 connectivity/source/drivers/mork/MConnection.cxx |    8 +++---
 connectivity/source/drivers/mork/MConnection.hxx |    6 ++--
 editeng/source/editeng/editeng.cxx               |    2 -
 editeng/source/editeng/impedit.hxx               |   16 ++++++------
 editeng/source/editeng/impedit2.cxx              |   24 ++++++++----------
 editeng/source/editeng/impedit3.cxx              |   30 +++++++++--------------
 editeng/source/editeng/impedit4.cxx              |   12 +++------
 8 files changed, 48 insertions(+), 53 deletions(-)

New commits:
commit c81791db5506f2576fac0466c760479902e7ccc8
Author: Noel Grandin <noel.gran...@collabora.co.uk>
Date:   Mon Jan 29 13:30:26 2018 +0200

    loplugin:useuniqueptr in OConnection
    
    Change-Id: I0f1069eefc6d0afa8aa852af76099e79c63cbed9
    Reviewed-on: https://gerrit.libreoffice.org/49181
    Tested-by: Jenkins <c...@libreoffice.org>
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/connectivity/source/drivers/mork/MConnection.cxx 
b/connectivity/source/drivers/mork/MConnection.cxx
index 6dc6f2b19349..74a1d1f7ec63 100644
--- a/connectivity/source/drivers/mork/MConnection.cxx
+++ b/connectivity/source/drivers/mork/MConnection.cxx
@@ -41,16 +41,16 @@ OConnection::OConnection(MorkDriver* _pDriver)
     :m_xDriver(_pDriver)
     ,m_aColumnAlias( _pDriver->getFactory() )
 {
-    m_pBook = new MorkParser();
-    m_pHistory = new MorkParser();
+    m_pBook.reset( new MorkParser() );
+    m_pHistory.reset( new MorkParser() );
 }
 
 OConnection::~OConnection()
 {
     if(!isClosed())
         close();
-    delete m_pBook;
-    delete m_pHistory;
+    m_pBook.reset();
+    m_pHistory.reset();
 }
 
 void OConnection::construct(const OUString& url)
diff --git a/connectivity/source/drivers/mork/MConnection.hxx 
b/connectivity/source/drivers/mork/MConnection.hxx
index 6c7e8a7fac87..c512e12316d1 100644
--- a/connectivity/source/drivers/mork/MConnection.hxx
+++ b/connectivity/source/drivers/mork/MConnection.hxx
@@ -35,9 +35,9 @@ namespace connectivity
                                                                //  driver 
object
             OColumnAlias    m_aColumnAlias;
             // Mork Parser (abook)
-            MorkParser* m_pBook;
+            std::unique_ptr<MorkParser> m_pBook;
             // Mork Parser (history)
-            MorkParser* m_pHistory;
+            std::unique_ptr<MorkParser> m_pHistory;
             // Store Catalog
             css::uno::Reference< css::sdbcx::XTablesSupplier> m_xCatalog;
 
@@ -48,7 +48,7 @@ namespace connectivity
             virtual ~OConnection() override;
 
             const rtl::Reference<MorkDriver>& getDriver() {return m_xDriver;};
-            MorkParser* getMorkParser(const OString& t) {return t == 
"CollectedAddressBook" ? m_pHistory : m_pBook;};
+            MorkParser* getMorkParser(const OString& t) {return t == 
"CollectedAddressBook" ? m_pHistory.get() : m_pBook.get();};
 
             // OComponentHelper
             virtual void SAL_CALL disposing() override;
commit 987cd20a33b396aa105b0abbec175b5592486c8f
Author: Noel Grandin <noel.gran...@collabora.co.uk>
Date:   Mon Jan 29 12:13:56 2018 +0200

    loplugin:useuniqueptr in ImpEditEngine
    
    Change-Id: I5afc846c803f5191bb5e04590923059e88434b76
    Reviewed-on: https://gerrit.libreoffice.org/49176
    Tested-by: Jenkins <c...@libreoffice.org>
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/compilerplugins/clang/useuniqueptr.cxx 
b/compilerplugins/clang/useuniqueptr.cxx
index 655a25fe4325..dfa0917735f0 100644
--- a/compilerplugins/clang/useuniqueptr.cxx
+++ b/compilerplugins/clang/useuniqueptr.cxx
@@ -213,6 +213,9 @@ void UseUniquePtr::CheckDeleteExpr(const CXXDestructorDecl* 
destructorDecl, cons
     // not sure how the node management is working here
     if (loplugin::hasPathnamePrefix(aFileName, SRCDIR 
"/i18npool/source/localedata/saxparser.cxx"))
         return;
+    // has a pointer that it only sometimes owns
+    if (loplugin::hasPathnamePrefix(aFileName, SRCDIR 
"/editeng/source/editeng/impedit.hxx"))
+        return;
 
     report(
         DiagnosticsEngine::Warning,
diff --git a/editeng/source/editeng/editeng.cxx 
b/editeng/source/editeng/editeng.cxx
index d2531b0f769b..05c0ffa7f2dc 100644
--- a/editeng/source/editeng/editeng.cxx
+++ b/editeng/source/editeng/editeng.cxx
@@ -523,7 +523,7 @@ void EditEngine::SetPolygon(const basegfx::B2DPolyPolygon& 
rPolyPolygon, const b
     }
 
     TextRanger* pRanger = new TextRanger( rPolyPolygon, pLinePolyPolygon, 30, 
2, 2, bSimple, true );
-    pImpEditEngine->SetTextRanger( pRanger );
+    pImpEditEngine->SetTextRanger( std::unique_ptr<TextRanger>(pRanger) );
     pImpEditEngine->SetPaperSize( pRanger->GetBoundRect().GetSize() );
 }
 
diff --git a/editeng/source/editeng/impedit.hxx 
b/editeng/source/editeng/impedit.hxx
index 1e53e23aa185..1f651ea7f43d 100644
--- a/editeng/source/editeng/impedit.hxx
+++ b/editeng/source/editeng/impedit.hxx
@@ -436,7 +436,7 @@ private:
     EditEngine*         pEditEngine;
     ViewsType           aEditViews;
     EditView*           pActiveView;
-    TextRanger*         pTextRanger;
+    std::unique_ptr<TextRanger> pTextRanger;
 
     SfxStyleSheetPool*  pStylePool;
     SfxItemPool*        pTextObjectPool;
@@ -446,13 +446,13 @@ private:
     VclPtr<VirtualDevice> mpOwnDev;
 
     svtools::ColorConfig maColorConfig;
-    mutable SvtCTLOptions*  pCTLOptions;
+    mutable std::unique_ptr<SvtCTLOptions> pCTLOptions;
 
     std::unique_ptr<SfxItemSet> pEmptyItemSet;
     EditUndoManager*    pUndoManager;
     ESelection*         pUndoMarkSelection;
 
-    ImplIMEInfos*       mpIMEInfos;
+    std::unique_ptr<ImplIMEInfos> mpIMEInfos;
 
     std::vector<EENotify> aNotifyCache;
 
@@ -474,7 +474,7 @@ private:
     sal_Int32          nBigTextObjectStart;
     css::uno::Reference< css::linguistic2::XSpellChecker1 > xSpeller;
     css::uno::Reference< css::linguistic2::XHyphenator >    xHyphenator;
-    SpellInfo*          pSpellInfo;
+    std::unique_ptr<SpellInfo> pSpellInfo;
     mutable css::uno::Reference < css::i18n::XBreakIterator > xBI;
     mutable css::uno::Reference < css::i18n::XExtendedInputSequenceChecker > 
xISC;
 
@@ -708,7 +708,7 @@ private:
     void ImplUpdateOverflowingParaNum( sal_uInt32 );
     void ImplUpdateOverflowingLineNum( sal_uInt32, sal_uInt32, sal_uInt32 );
 
-    SpellInfo *     CreateSpellInfo( bool bMultipleDocs );
+    void CreateSpellInfo( bool bMultipleDocs );
     /// Obtains a view shell ID from the active EditView.
     ViewShellId CreateViewShellId();
 
@@ -758,8 +758,8 @@ public:
     sal_uInt8               GetRightToLeft( sal_Int32 nPara, sal_Int32 nChar, 
sal_Int32* pStart = nullptr, sal_Int32* pEnd = nullptr );
     bool                    HasDifferentRTLLevels( const ContentNode* pNode );
 
-    void                    SetTextRanger( TextRanger* pRanger );
-    TextRanger*             GetTextRanger() const { return pTextRanger; }
+    void                    SetTextRanger( std::unique_ptr<TextRanger> pRanger 
);
+    TextRanger*             GetTextRanger() const { return pTextRanger.get(); }
 
     const Size&             GetMinAutoPaperSize() const             { return 
aMinAutoPaperSize; }
     void                    SetMinAutoPaperSize( const Size& rSz )  { 
aMinAutoPaperSize = rSz; }
@@ -942,7 +942,7 @@ public:
     void GetAllMisspellRanges( std::vector<editeng::MisspellRanges>& rRanges ) 
const;
     void SetAllMisspellRanges( const std::vector<editeng::MisspellRanges>& 
rRanges );
 
-    SpellInfo*          GetSpellInfo() const { return pSpellInfo; }
+    SpellInfo*          GetSpellInfo() const { return pSpellInfo.get(); }
 
     void                SetDefaultLanguage( LanguageType eLang ) { 
eDefLanguage = eLang; }
     LanguageType        GetDefaultLanguage() const { return eDefLanguage; }
diff --git a/editeng/source/editeng/impedit2.cxx 
b/editeng/source/editeng/impedit2.cxx
index a7e5ef0c9ceb..a72dfd647f3e 100644
--- a/editeng/source/editeng/impedit2.cxx
+++ b/editeng/source/editeng/impedit2.cxx
@@ -198,10 +198,10 @@ ImpEditEngine::~ImpEditEngine()
     // before destroying the ImpEditEngine!
     assert(!pUndoManager || typeid(*pUndoManager) == typeid(EditUndoManager));
     delete pUndoManager;
-    delete pTextRanger;
-    delete mpIMEInfos;
-    delete pCTLOptions;
-    delete pSpellInfo;
+    pTextRanger.reset();
+    mpIMEInfos.reset();
+    pCTLOptions.reset();
+    pSpellInfo.reset();
 }
 
 void ImpEditEngine::SetRefDevice( OutputDevice* pRef )
@@ -359,13 +359,13 @@ void ImpEditEngine::Command( const CommandEvent& rCEvt, 
EditView* pView )
     if ( rCEvt.GetCommand() == CommandEventId::StartExtTextInput )
     {
         pView->DeleteSelected();
-        delete mpIMEInfos;
+        mpIMEInfos.reset();
         EditPaM aPaM = pView->GetImpEditView()->GetEditSelection().Max();
         OUString aOldTextAfterStartPos = aPaM.GetNode()->Copy( aPaM.GetIndex() 
);
         sal_Int32 nMax = aOldTextAfterStartPos.indexOf( CH_FEATURE );
         if ( nMax != -1 )  // don't overwrite features!
             aOldTextAfterStartPos = aOldTextAfterStartPos.copy( 0, nMax );
-        mpIMEInfos = new ImplIMEInfos( aPaM, aOldTextAfterStartPos );
+        mpIMEInfos.reset( new ImplIMEInfos( aPaM, aOldTextAfterStartPos ) );
         mpIMEInfos->bWasCursorOverwrite = !pView->IsInsertMode();
         UndoActionStart( EDITUNDO_INSERT );
     }
@@ -400,8 +400,7 @@ void ImpEditEngine::Command( const CommandEvent& rCEvt, 
EditView* pView )
 
             bool bWasCursorOverwrite = mpIMEInfos->bWasCursorOverwrite;
 
-            delete mpIMEInfos;
-            mpIMEInfos = nullptr;
+            mpIMEInfos.reset();
 
             FormatAndUpdate( pView );
 
@@ -1590,7 +1589,7 @@ bool ImpEditEngine::IsInputSequenceCheckingRequired( 
sal_Unicode nChar, const Ed
 {
     uno::Reference < i18n::XBreakIterator > _xBI( ImplGetBreakIterator() );
     if (!pCTLOptions)
-        pCTLOptions = new SvtCTLOptions;
+        pCTLOptions.reset( new SvtCTLOptions );
 
     // get the index that really is first
     const sal_Int32 nFirstPos = std::min(rCurSel.Min().GetIndex(), 
rCurSel.Max().GetIndex());
@@ -2616,7 +2615,7 @@ EditPaM ImpEditEngine::InsertTextUserInput( const 
EditSelection& rCurSel,
         {
             uno::Reference < i18n::XExtendedInputSequenceChecker > _xISC( 
ImplGetInputSequenceChecker() );
             if (!pCTLOptions)
-                pCTLOptions = new SvtCTLOptions;
+                pCTLOptions.reset( new SvtCTLOptions );
 
             if (_xISC.is() || pCTLOptions)
             {
@@ -3453,8 +3452,7 @@ void ImpEditEngine::SetActiveView( EditView* pView )
 
     if ( !pView && mpIMEInfos )
     {
-        delete mpIMEInfos;
-        mpIMEInfos = nullptr;
+        mpIMEInfos.reset();
     }
 }
 
@@ -4355,7 +4353,7 @@ bool ImpEditEngine::IsVisualCursorTravelingEnabled()
     bool bVisualCursorTravaling = false;
 
     if( !pCTLOptions )
-        pCTLOptions = new SvtCTLOptions;
+        pCTLOptions.reset( new SvtCTLOptions );
 
     if ( pCTLOptions->IsCTLFontEnabled() && ( 
pCTLOptions->GetCTLCursorMovement() == SvtCTLOptions::MOVEMENT_VISUAL ) )
     {
diff --git a/editeng/source/editeng/impedit3.cxx 
b/editeng/source/editeng/impedit3.cxx
index f81e1f7fd46e..668b34ab552c 100644
--- a/editeng/source/editeng/impedit3.cxx
+++ b/editeng/source/editeng/impedit3.cxx
@@ -2610,25 +2610,21 @@ void ImpEditEngine::RecalcTextPortion( ParaPortion* 
pParaPortion, sal_Int32 nSta
 #endif
 }
 
-void ImpEditEngine::SetTextRanger( TextRanger* pRanger )
+void ImpEditEngine::SetTextRanger( std::unique_ptr<TextRanger> pRanger )
 {
-    if ( pTextRanger != pRanger )
-    {
-        delete pTextRanger;
-        pTextRanger = pRanger;
-
-        for ( sal_Int32 nPara = 0; nPara < GetParaPortions().Count(); nPara++ )
-        {
-            ParaPortion* pParaPortion = GetParaPortions()[nPara];
-            pParaPortion->MarkSelectionInvalid( 0 );
-            pParaPortion->GetLines().Reset();
-        }
+    pTextRanger = std::move(pRanger);
 
-        FormatFullDoc();
-        UpdateViews( GetActiveView() );
-        if ( GetUpdateMode() && GetActiveView() )
-            pActiveView->ShowCursor(false, false);
+    for ( sal_Int32 nPara = 0; nPara < GetParaPortions().Count(); nPara++ )
+    {
+        ParaPortion* pParaPortion = GetParaPortions()[nPara];
+        pParaPortion->MarkSelectionInvalid( 0 );
+        pParaPortion->GetLines().Reset();
     }
+
+    FormatFullDoc();
+    UpdateViews( GetActiveView() );
+    if ( GetUpdateMode() && GetActiveView() )
+        pActiveView->ShowCursor(false, false);
 }
 
 void ImpEditEngine::SetVertical( bool bVertical, bool bTopToBottom)
@@ -4353,7 +4349,7 @@ LanguageType 
ImpEditEngine::ImplCalcDigitLang(LanguageType eCurLang) const
     // #114278# Also setting up digit language from Svt options
     // (cannot reliably inherit the outdev's setting)
     if( !pCTLOptions )
-        pCTLOptions = new SvtCTLOptions;
+        pCTLOptions.reset( new SvtCTLOptions );
 
     LanguageType eLang = eCurLang;
     const SvtCTLOptions::TextNumerals nCTLTextNumerals = 
pCTLOptions->GetCTLTextNumerals();
diff --git a/editeng/source/editeng/impedit4.cxx 
b/editeng/source/editeng/impedit4.cxx
index 06e07e849cd4..2a995e8eb307 100644
--- a/editeng/source/editeng/impedit4.cxx
+++ b/editeng/source/editeng/impedit4.cxx
@@ -1426,10 +1426,10 @@ Reference< XSpellChecker1 > const & 
ImpEditEngine::GetSpeller()
 }
 
 
-SpellInfo * ImpEditEngine::CreateSpellInfo( bool bMultipleDocs )
+void ImpEditEngine::CreateSpellInfo( bool bMultipleDocs )
 {
     if (!pSpellInfo)
-        pSpellInfo = new SpellInfo;
+        pSpellInfo.reset( new SpellInfo );
     else
         *pSpellInfo = SpellInfo();  // reset to default values
 
@@ -1439,7 +1439,6 @@ SpellInfo * ImpEditEngine::CreateSpellInfo( bool 
bMultipleDocs )
     // further changes elsewhere to work properly)
     pSpellInfo->aSpellStart = EPaM();
     pSpellInfo->aSpellTo    = EPaM( EE_PARA_NOT_FOUND, EE_INDEX_NOT_FOUND );
-    return pSpellInfo;
 }
 
 
@@ -1459,7 +1458,7 @@ EESpellState ImpEditEngine::Spell( EditView* pEditView, 
bool bMultipleDoc )
     }
 
     EditSelection aCurSel( pEditView->pImpEditView->GetEditSelection() );
-    pSpellInfo = CreateSpellInfo( bMultipleDoc );
+    CreateSpellInfo( bMultipleDoc );
 
     bool bIsStart = false;
     if ( bMultipleDoc )
@@ -1483,8 +1482,7 @@ EESpellState ImpEditEngine::Spell( EditView* pEditView, 
bool bMultipleDoc )
         pEditView->ShowCursor( true, false );
     }
     EESpellState eState = pSpellInfo->eState;
-    delete pSpellInfo;
-    pSpellInfo = nullptr;
+    pSpellInfo.reset();
     return eState;
 }
 
@@ -1928,7 +1926,7 @@ bool ImpEditEngine::SpellSentence(EditView const & 
rEditView,
     bool bRet = false;
     EditSelection aCurSel( rEditView.pImpEditView->GetEditSelection() );
     if(!pSpellInfo)
-        pSpellInfo = CreateSpellInfo( true );
+        CreateSpellInfo( true );
     pSpellInfo->aCurSentenceStart = aCurSel.Min();
     DBG_ASSERT( xSpeller.is(), "No spell checker set!" );
     pSpellInfo->aLastSpellPortions.clear();
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to