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

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Wed Aug 15 06:38:28 UTC 2018


 editeng/source/editeng/editobj.cxx  |   13 ++++++-------
 editeng/source/editeng/editobj2.hxx |    4 ++--
 editeng/source/editeng/impedit4.cxx |    6 +++---
 3 files changed, 11 insertions(+), 12 deletions(-)

New commits:
commit 7ec60cdc3a6ca76d96411288ad55435de39c4b0c
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Sat Aug 11 10:22:05 2018 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Wed Aug 15 08:38:03 2018 +0200

    loplugin:useuniqueptr pass XEditAttribute around by std::unique_ptr
    
    Change-Id: Idaf02002cecb1300a5fc3bcb0e298b11a1958bb1
    Reviewed-on: https://gerrit.libreoffice.org/59008
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/editeng/source/editeng/editobj.cxx b/editeng/source/editeng/editobj.cxx
index 9b7fa07924d6..57eea220c5a8 100644
--- a/editeng/source/editeng/editobj.cxx
+++ b/editeng/source/editeng/editobj.cxx
@@ -60,12 +60,12 @@ using std::endl;
 using namespace com::sun::star;
 
 
-XEditAttribute* MakeXEditAttribute( SfxItemPool& rPool, const SfxPoolItem& rItem, sal_Int32 nStart, sal_Int32 nEnd )
+std::unique_ptr<XEditAttribute> MakeXEditAttribute( SfxItemPool& rPool, const SfxPoolItem& rItem, sal_Int32 nStart, sal_Int32 nEnd )
 {
     // Create thw new attribute in the pool
     const SfxPoolItem& rNew = rPool.Put( rItem );
 
-    XEditAttribute* pNew = new XEditAttribute( rNew, nStart, nEnd );
+    std::unique_ptr<XEditAttribute> pNew(new XEditAttribute( rNew, nStart, nEnd ));
     return pNew;
 }
 
@@ -130,9 +130,9 @@ ContentInfo::ContentInfo( const ContentInfo& rCopyFrom, SfxItemPool& rPoolToUse
     for (const auto & aAttrib : rCopyFrom.maCharAttribs)
     {
         const XEditAttribute& rAttr = *aAttrib.get();
-        XEditAttribute* pMyAttr = MakeXEditAttribute(
+        std::unique_ptr<XEditAttribute> pMyAttr = MakeXEditAttribute(
             rPoolToUse, *rAttr.GetItem(), rAttr.GetStart(), rAttr.GetEnd());
-        maCharAttribs.push_back(std::unique_ptr<XEditAttribute>(pMyAttr));
+        maCharAttribs.push_back(std::move(pMyAttr));
     }
 
     if ( rCopyFrom.GetWrongList() )
@@ -644,15 +644,14 @@ void EditTextObjectImpl::SetScriptType( SvtScriptType nType )
     nScriptType = nType;
 }
 
-XEditAttribute* EditTextObjectImpl::CreateAttrib( const SfxPoolItem& rItem, sal_Int32 nStart, sal_Int32 nEnd )
+std::unique_ptr<XEditAttribute> EditTextObjectImpl::CreateAttrib( const SfxPoolItem& rItem, sal_Int32 nStart, sal_Int32 nEnd )
 {
     return MakeXEditAttribute( *pPool, rItem, nStart, nEnd );
 }
 
-void EditTextObjectImpl::DestroyAttrib( XEditAttribute* pAttr )
+void EditTextObjectImpl::DestroyAttrib( std::unique_ptr<XEditAttribute> pAttr )
 {
     pPool->Remove( *pAttr->GetItem() );
-    delete pAttr;
 }
 
 
diff --git a/editeng/source/editeng/editobj2.hxx b/editeng/source/editeng/editobj2.hxx
index b30fadb3fe63..7da37fc2f31d 100644
--- a/editeng/source/editeng/editobj2.hxx
+++ b/editeng/source/editeng/editobj2.hxx
@@ -219,8 +219,8 @@ public:
     void                    SetScriptType( SvtScriptType nType );
 
     ContentInfo*            CreateAndInsertContent();
-    XEditAttribute*         CreateAttrib( const SfxPoolItem& rItem, sal_Int32 nStart, sal_Int32 nEnd );
-    void                    DestroyAttrib( XEditAttribute* pAttr );
+    std::unique_ptr<XEditAttribute> CreateAttrib( const SfxPoolItem& rItem, sal_Int32 nStart, sal_Int32 nEnd );
+    void                    DestroyAttrib( std::unique_ptr<XEditAttribute> pAttr );
 
     ContentInfosType&       GetContents() { return aContents;}
     const ContentInfosType& GetContents() const { return aContents;}
diff --git a/editeng/source/editeng/impedit4.cxx b/editeng/source/editeng/impedit4.cxx
index b9b55534b37e..5c2378917381 100644
--- a/editeng/source/editeng/impedit4.cxx
+++ b/editeng/source/editeng/impedit4.cxx
@@ -1060,7 +1060,7 @@ std::unique_ptr<EditTextObject> ImpEditEngine::CreateTextObject( EditSelection a
             if ( bEmptyPara ||
                  ( ( pAttr->GetEnd() > nStartPos ) && ( pAttr->GetStart() < nEndPos ) ) )
             {
-                XEditAttribute* pX = pTxtObj->mpImpl->CreateAttrib(*pAttr->GetItem(), pAttr->GetStart(), pAttr->GetEnd());
+                std::unique_ptr<XEditAttribute> pX = pTxtObj->mpImpl->CreateAttrib(*pAttr->GetItem(), pAttr->GetStart(), pAttr->GetEnd());
                 // Possibly Correct ...
                 if ( ( nNode == nStartNode ) && ( nStartPos != 0 ) )
                 {
@@ -1075,9 +1075,9 @@ std::unique_ptr<EditTextObject> ImpEditEngine::CreateTextObject( EditSelection a
                 }
                 DBG_ASSERT( pX->GetEnd() <= (nEndPos-nStartPos), "CreateBinTextObject: Attribute too long!" );
                 if ( !pX->GetLen() && !bEmptyPara )
-                    pTxtObj->mpImpl->DestroyAttrib(pX);
+                    pTxtObj->mpImpl->DestroyAttrib(std::move(pX));
                 else
-                    pC->GetCharAttribs().push_back(std::unique_ptr<XEditAttribute>(pX));
+                    pC->GetCharAttribs().push_back(std::move(pX));
             }
             nAttr++;
             pAttr = GetAttrib( pNode->GetCharAttribs().GetAttribs(), nAttr );


More information about the Libreoffice-commits mailing list