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

Noel Grandin noel.grandin at collabora.co.uk
Mon May 14 09:19:25 UTC 2018


 editeng/source/editeng/editobj.cxx      |    6 +-----
 editeng/source/editeng/editobj2.hxx     |    8 ++++----
 editeng/source/editeng/impedit4.cxx     |    2 +-
 filter/source/graphicfilter/eps/eps.cxx |   12 ++++++------
 4 files changed, 12 insertions(+), 16 deletions(-)

New commits:
commit 3f32388fd4ed343ff1e3036edfc7f97127202949
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Wed May 9 13:27:33 2018 +0200

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

diff --git a/filter/source/graphicfilter/eps/eps.cxx b/filter/source/graphicfilter/eps/eps.cxx
index 0eb4e23afb61..3eba386bac82 100644
--- a/filter/source/graphicfilter/eps/eps.cxx
+++ b/filter/source/graphicfilter/eps/eps.cxx
@@ -138,7 +138,7 @@ private:
     vcl::Font           maLastFont;
     sal_uInt8           nNextChrSetId;      // first unused ChrSet-Id
 
-    PSLZWCTreeNode*     pTable;             // LZW compression data
+    std::unique_ptr<PSLZWCTreeNode[]> pTable; // LZW compression data
     PSLZWCTreeNode*     pPrefix;            // the compression is as same as the TIFF compression
     sal_uInt16          nDataSize;
     sal_uInt16          nClearCode;
@@ -2507,7 +2507,7 @@ void PSWriter::StartCompression()
     nOffset = 32;                       // number of free unused in dwShift
     dwShift = 0;
 
-    pTable = new PSLZWCTreeNode[ 4096 ];
+    pTable.reset(new PSLZWCTreeNode[ 4096 ]);
 
     for ( i = 0; i < 4096; i++ )
     {
@@ -2526,7 +2526,7 @@ void PSWriter::Compress( sal_uInt8 nCompThis )
 
     if( !pPrefix )
     {
-        pPrefix = pTable + nCompThis;
+        pPrefix = pTable.get() + nCompThis;
     }
     else
     {
@@ -2558,14 +2558,14 @@ void PSWriter::Compress( sal_uInt8 nCompThis )
                 if( nTableSize == static_cast<sal_uInt16>( ( 1 << nCodeSize ) - 1 ) )
                     nCodeSize++;
 
-                p = pTable + ( nTableSize++ );
+                p = pTable.get() + ( nTableSize++ );
                 p->pBrother = pPrefix->pFirstChild;
                 pPrefix->pFirstChild = p;
                 p->nValue = nV;
                 p->pFirstChild = nullptr;
             }
 
-            pPrefix = pTable + nV;
+            pPrefix = pTable.get() + nV;
         }
     }
 }
@@ -2576,7 +2576,7 @@ void PSWriter::EndCompression()
         WriteBits( pPrefix->nCode, nCodeSize );
 
     WriteBits( nEOICode, nCodeSize );
-    delete[] pTable;
+    pTable.reset();
 }
 
 sal_uInt8* PSWriter::ImplSearchEntry( sal_uInt8* pSource, sal_uInt8 const * pDest, sal_uLong nComp, sal_uLong nSize )
commit d0242b11638938c8873643ee3fc768e4a3a52b95
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Wed May 9 12:49:17 2018 +0200

    loplugin:useuniqueptr in EditTextObjectImpl
    
    Change-Id: I8c0aca098cb2453f3780ea123b35848eb417e5f1
    Reviewed-on: https://gerrit.libreoffice.org/54177
    Tested-by: Jenkins <ci at libreoffice.org>
    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 5ae80f43b67c..b76e99ea4d95 100644
--- a/editeng/source/editeng/editobj.cxx
+++ b/editeng/source/editeng/editobj.cxx
@@ -688,11 +688,7 @@ OUString EditTextObjectImpl::GetText(sal_Int32 nPara) const
 
 void EditTextObjectImpl::ClearPortionInfo()
 {
-    if ( pPortionInfo )
-    {
-        delete pPortionInfo;
-        pPortionInfo = nullptr;
-    }
+    pPortionInfo.reset();
 }
 
 bool EditTextObjectImpl::HasOnlineSpellErrors() const
diff --git a/editeng/source/editeng/editobj2.hxx b/editeng/source/editeng/editobj2.hxx
index 44fc5ac82c47..26576d4fdb1b 100644
--- a/editeng/source/editeng/editobj2.hxx
+++ b/editeng/source/editeng/editobj2.hxx
@@ -184,7 +184,7 @@ private:
 
     ContentInfosType        aContents;
     SfxItemPool*            pPool;
-    XParaPortionList*       pPortionInfo;
+    std::unique_ptr<XParaPortionList> pPortionInfo;
 
     sal_uInt32              nObjSettings;
     sal_uInt16              nMetric;
@@ -227,9 +227,9 @@ public:
     ContentInfosType&       GetContents() { return aContents;}
     const ContentInfosType& GetContents() const { return aContents;}
     SfxItemPool*            GetPool() const         { return pPool; }
-    XParaPortionList*       GetPortionInfo() const  { return pPortionInfo; }
-    void                    SetPortionInfo( XParaPortionList* pP )
-                                { pPortionInfo = pP; }
+    XParaPortionList*       GetPortionInfo() const  { return pPortionInfo.get(); }
+    void                    SetPortionInfo( std::unique_ptr<XParaPortionList> pP )
+                                { pPortionInfo = std::move(pP); }
 
     sal_Int32 GetParagraphCount() const;
     OUString GetText(sal_Int32 nParagraph) const;
diff --git a/editeng/source/editeng/impedit4.cxx b/editeng/source/editeng/impedit4.cxx
index 930f873d7fd6..e2f7e2412dd0 100644
--- a/editeng/source/editeng/impedit4.cxx
+++ b/editeng/source/editeng/impedit4.cxx
@@ -1095,7 +1095,7 @@ std::unique_ptr<EditTextObject> ImpEditEngine::CreateTextObject( EditSelection a
     if ( bAllowBigObjects && bOnlyFullParagraphs && IsFormatted() && GetUpdateMode() && ( nTextPortions >= nBigObjectStart ) )
     {
         XParaPortionList* pXList = new XParaPortionList( GetRefDevice(), aPaperSize.Width(), nStretchX, nStretchY );
-        pTxtObj->mpImpl->SetPortionInfo(pXList);
+        pTxtObj->mpImpl->SetPortionInfo(std::unique_ptr<XParaPortionList>(pXList));
         for ( nNode = nStartNode; nNode <= nEndNode; nNode++  )
         {
             const ParaPortion* pParaPortion = GetParaPortions()[nNode];


More information about the Libreoffice-commits mailing list