[Libreoffice-commits] core.git: 2 commits - editeng/source include/editeng

Noel Grandin noel.grandin at collabora.co.uk
Mon Feb 5 06:50:59 UTC 2018


 editeng/source/outliner/outliner.cxx |    9 ++++-----
 editeng/source/outliner/outlvw.cxx   |    2 +-
 editeng/source/uno/unotext.cxx       |   20 +++++++++-----------
 include/editeng/outliner.hxx         |    4 ++--
 include/editeng/unotext.hxx          |    4 ++--
 5 files changed, 18 insertions(+), 21 deletions(-)

New commits:
commit d69d9cdc40d7a2f3d80688ab519fcf4c932b8f7b
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Mon Jan 29 11:14:33 2018 +0200

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

diff --git a/editeng/source/uno/unotext.cxx b/editeng/source/uno/unotext.cxx
index 6b6127c92ec8..93dbfd6c0aef 100644
--- a/editeng/source/uno/unotext.cxx
+++ b/editeng/source/uno/unotext.cxx
@@ -219,7 +219,7 @@ SvxUnoTextRangeBase::SvxUnoTextRangeBase(const SvxEditSource* pSource, const Svx
 
     DBG_ASSERT(pSource,"SvxUnoTextRangeBase: I need a valid SvxEditSource!");
 
-    mpEditSource = pSource->Clone();
+    mpEditSource.reset( pSource->Clone() );
     if (mpEditSource != nullptr)
     {
         ESelection aSelection;
@@ -244,7 +244,7 @@ SvxUnoTextRangeBase::SvxUnoTextRangeBase(const SvxUnoTextRangeBase& rRange)
 {
     SolarMutexGuard aGuard;
 
-    mpEditSource = rRange.mpEditSource ? rRange.mpEditSource->Clone() : nullptr;
+    mpEditSource.reset( rRange.mpEditSource ? rRange.mpEditSource->Clone() : nullptr );
 
     SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : nullptr;
     if( pForwarder )
@@ -261,8 +261,6 @@ SvxUnoTextRangeBase::~SvxUnoTextRangeBase() throw()
 {
     if( mpEditSource )
         mpEditSource->removeRange( this );
-
-    delete mpEditSource;
 }
 
 void SvxUnoTextRangeBase::SetEditSource( SvxEditSource* pSource ) throw()
@@ -270,7 +268,7 @@ void SvxUnoTextRangeBase::SetEditSource( SvxEditSource* pSource ) throw()
     DBG_ASSERT(pSource,"SvxUnoTextRangeBase: I need a valid SvxEditSource!");
     DBG_ASSERT(mpEditSource==nullptr,"SvxUnoTextRangeBase::SetEditSource called while SvxEditSource already set" );
 
-    mpEditSource = pSource;
+    mpEditSource.reset( pSource );
 
     maSelection.nStartPara = EE_PARA_MAX_COUNT;
 
@@ -300,7 +298,7 @@ void SvxUnoTextRangeBase::SetSelection( const ESelection& rSelection ) throw()
     SolarMutexGuard aGuard;
 
     maSelection = rSelection;
-    CheckSelection( maSelection, mpEditSource );
+    CheckSelection( maSelection, mpEditSource.get() );
 }
 
 // Interface XTextRange ( XText )
@@ -1313,7 +1311,7 @@ uno::Sequence< uno::Any > SAL_CALL SvxUnoTextRangeBase::getPropertyDefaults( con
 // internal
 void SvxUnoTextRangeBase::CollapseToStart() throw()
 {
-    CheckSelection( maSelection, mpEditSource );
+    CheckSelection( maSelection, mpEditSource.get() );
 
     maSelection.nEndPara = maSelection.nStartPara;
     maSelection.nEndPos  = maSelection.nStartPos;
@@ -1321,7 +1319,7 @@ void SvxUnoTextRangeBase::CollapseToStart() throw()
 
 void SvxUnoTextRangeBase::CollapseToEnd() throw()
 {
-    CheckSelection( maSelection, mpEditSource );
+    CheckSelection( maSelection, mpEditSource.get() );
 
     maSelection.nStartPara = maSelection.nEndPara;
     maSelection.nStartPos  = maSelection.nEndPos;
@@ -1329,7 +1327,7 @@ void SvxUnoTextRangeBase::CollapseToEnd() throw()
 
 bool SvxUnoTextRangeBase::IsCollapsed() throw()
 {
-    CheckSelection( maSelection, mpEditSource );
+    CheckSelection( maSelection, mpEditSource.get() );
 
     return ( maSelection.nStartPara == maSelection.nEndPara &&
              maSelection.nStartPos  == maSelection.nEndPos );
@@ -1337,7 +1335,7 @@ bool SvxUnoTextRangeBase::IsCollapsed() throw()
 
 bool SvxUnoTextRangeBase::GoLeft(sal_Int16 nCount, bool Expand) throw()
 {
-    CheckSelection( maSelection, mpEditSource );
+    CheckSelection( maSelection, mpEditSource.get() );
 
     //  #75098# use end position, as in Writer (start is anchor, end is cursor)
     sal_uInt16 nNewPos = maSelection.nEndPos;
@@ -1423,7 +1421,7 @@ void SvxUnoTextRangeBase::GotoStart(bool Expand) throw()
 
 void SvxUnoTextRangeBase::GotoEnd(bool Expand) throw()
 {
-    CheckSelection( maSelection, mpEditSource );
+    CheckSelection( maSelection, mpEditSource.get() );
 
     SvxTextForwarder* pForwarder = mpEditSource ? mpEditSource->GetTextForwarder() : nullptr;
     if( pForwarder )
diff --git a/include/editeng/unotext.hxx b/include/editeng/unotext.hxx
index 514f83e8b6dd..1e15f8d5e033 100644
--- a/include/editeng/unotext.hxx
+++ b/include/editeng/unotext.hxx
@@ -253,7 +253,7 @@ class EDITENG_DLLPUBLIC SvxUnoTextRangeBase : public css::text::XTextRange,
     const SvxItemPropertySet* mpPropSet;
 
 protected:
-    SvxEditSource*          mpEditSource;
+    std::unique_ptr<SvxEditSource> mpEditSource;
     ESelection              maSelection;
 
     /// @throws css::beans::UnknownPropertyException
@@ -327,7 +327,7 @@ public:
 
     //const SfxItemPropertyMapEntry*   getPropertyMapEntries() const throw() { return maPropSet.getPropertyMapEntries(); }
     const SvxItemPropertySet*   getPropertySet() const throw() { return mpPropSet; }
-    SvxEditSource*              GetEditSource() const throw() { return mpEditSource; }
+    SvxEditSource*              GetEditSource() const throw() { return mpEditSource.get(); }
 
     static bool SetPropertyValueHelper( const SfxItemPropertySimpleEntry* pMap, const css::uno::Any& aValue, SfxItemSet& rNewSet, const ESelection* pSelection = nullptr, SvxEditSource* pEditSource = nullptr );
     /// @throws css::uno::RuntimeException
commit cb226e26cbdfe29bc97aba101d3d524f13482876
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Mon Jan 29 11:12:08 2018 +0200

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

diff --git a/editeng/source/outliner/outliner.cxx b/editeng/source/outliner/outliner.cxx
index f520239bf148..f83ec948ee52 100644
--- a/editeng/source/outliner/outliner.cxx
+++ b/editeng/source/outliner/outliner.cxx
@@ -1246,12 +1246,12 @@ Outliner::Outliner(SfxItemPool* pPool, OutlinerMode nMode)
     , bPasting(false)
 {
 
-    pParaList = new ParagraphList;
+    pParaList.reset( new ParagraphList );
     pParaList->SetVisibleStateChangedHdl( LINK( this, Outliner, ParaVisibleStateChangedHdl ) );
     Paragraph* pPara = new Paragraph( 0 );
     pParaList->Append(pPara);
 
-    pEditEngine = new OutlinerEditEng( this, pPool );
+    pEditEngine.reset( new OutlinerEditEng( this, pPool ) );
     pEditEngine->SetBeginMovingParagraphsHdl( LINK( this, Outliner, BeginMovingParagraphsHdl ) );
     pEditEngine->SetEndMovingParagraphsHdl( LINK( this, Outliner, EndMovingParagraphsHdl ) );
     pEditEngine->SetBeginPasteOrDropHdl( LINK( this, Outliner, BeginPasteOrDropHdl ) );
@@ -1262,10 +1262,9 @@ Outliner::Outliner(SfxItemPool* pPool, OutlinerMode nMode)
 
 Outliner::~Outliner()
 {
-
     pParaList->Clear();
-    delete pParaList;
-    delete pEditEngine;
+    pParaList.reset();
+    pEditEngine.reset();
 }
 
 size_t Outliner::InsertView( OutlinerView* pView, size_t nIndex )
diff --git a/editeng/source/outliner/outlvw.cxx b/editeng/source/outliner/outlvw.cxx
index 0c380d570604..49db7d25280c 100644
--- a/editeng/source/outliner/outlvw.cxx
+++ b/editeng/source/outliner/outlvw.cxx
@@ -52,7 +52,7 @@ using namespace ::com::sun::star;
 OutlinerView::OutlinerView( Outliner* pOut, vcl::Window* pWin )
 {
     pOwner                      = pOut;
-    pEditView.reset( new EditView( pOut->pEditEngine, pWin ) );
+    pEditView.reset( new EditView( pOut->pEditEngine.get(), pWin ) );
 }
 
 OutlinerView::~OutlinerView()
diff --git a/include/editeng/outliner.hxx b/include/editeng/outliner.hxx
index 2c2ca5f1285f..aad54a179ae4 100644
--- a/include/editeng/outliner.hxx
+++ b/include/editeng/outliner.hxx
@@ -587,9 +587,9 @@ private:
 
     friend class TextChainingUtils;
 
-    OutlinerEditEng*    pEditEngine;
+    std::unique_ptr<OutlinerEditEng> pEditEngine;
 
-    ParagraphList*      pParaList;
+    std::unique_ptr<ParagraphList>   pParaList;
     ViewList            aViewList;
 
     sal_Int32           mnFirstSelPage;


More information about the Libreoffice-commits mailing list