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

Noel Grandin noel.grandin at collabora.co.uk
Mon Mar 5 06:34:07 UTC 2018


 lotuswordpro/inc/xfilter/xfdrawstyle.hxx           |    3 ++-
 lotuswordpro/source/filter/lwpdrawobj.cxx          |   13 ++++---------
 lotuswordpro/source/filter/lwpdrawobj.hxx          |    2 +-
 lotuswordpro/source/filter/xfilter/xfdrawstyle.cxx |   10 ++--------
 4 files changed, 9 insertions(+), 19 deletions(-)

New commits:
commit c0c42c56159d1d1185702cb0c400e460727dc168
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Thu Mar 1 11:18:42 2018 +0200

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

diff --git a/lotuswordpro/inc/xfilter/xfdrawstyle.hxx b/lotuswordpro/inc/xfilter/xfdrawstyle.hxx
index e6ea960100ca..e5a596a201ba 100644
--- a/lotuswordpro/inc/xfilter/xfdrawstyle.hxx
+++ b/lotuswordpro/inc/xfilter/xfdrawstyle.hxx
@@ -63,6 +63,7 @@
 #include <xfilter/xfstyle.hxx>
 #include <xfilter/xfcolor.hxx>
 #include <cassert>
+#include <memory>
 
 class XFDrawLineStyle;
 class XFDrawAreaStyle;
@@ -120,7 +121,7 @@ public:
     virtual void    ToXml(IXFStream *pStrm) override;
 
 private:
-    XFFontWorkStyle* m_pFontWorkStyle;
+    std::unique_ptr<XFFontWorkStyle> m_pFontWorkStyle;
     enumXFWrap  m_eWrap;
     XFDrawLineStyle *m_pLineStyle;
     XFDrawAreaStyle *m_pAreaStyle;
diff --git a/lotuswordpro/source/filter/xfilter/xfdrawstyle.cxx b/lotuswordpro/source/filter/xfilter/xfdrawstyle.cxx
index 445919b8f1e3..bb5c76013625 100644
--- a/lotuswordpro/source/filter/xfilter/xfdrawstyle.cxx
+++ b/lotuswordpro/source/filter/xfilter/xfdrawstyle.cxx
@@ -64,8 +64,7 @@
 #include "xffontworkstyle.hxx"
 #include <lwpglobalmgr.hxx>
 XFDrawStyle::XFDrawStyle()
-    : m_pFontWorkStyle(nullptr)
-    , m_eWrap(enumXFWrapNone)
+    : m_eWrap(enumXFWrapNone)
     , m_pLineStyle(nullptr)
     , m_pAreaStyle(nullptr)
     , m_fArrowStartSize(0.3)
@@ -77,11 +76,6 @@ XFDrawStyle::XFDrawStyle()
 XFDrawStyle::~XFDrawStyle()
 {
     //don't delete m_pLineStyle, it was managed by XFStyleManager.
-    if (m_pFontWorkStyle)
-    {
-        delete m_pFontWorkStyle;
-        m_pFontWorkStyle = nullptr;
-    }
 }
 
 void    XFDrawStyle::SetLineStyle(double width, XFColor color)
@@ -117,7 +111,7 @@ void XFDrawStyle::SetFontWorkStyle(enumXFFWStyle eStyle, enumXFFWAdjust eAdjust)
 {
     if (!m_pFontWorkStyle)
     {
-        m_pFontWorkStyle = new XFFontWorkStyle();
+        m_pFontWorkStyle.reset( new XFFontWorkStyle() );
     }
 
     m_pFontWorkStyle->SetButtonForm(0);
commit b7d4573b5c217cd5d32723092911c654452b554d
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Thu Mar 1 11:12:12 2018 +0200

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

diff --git a/lotuswordpro/source/filter/lwpdrawobj.cxx b/lotuswordpro/source/filter/lwpdrawobj.cxx
index 60a7b9a5a306..1fa5233a4ed0 100644
--- a/lotuswordpro/source/filter/lwpdrawobj.cxx
+++ b/lotuswordpro/source/filter/lwpdrawobj.cxx
@@ -1337,17 +1337,12 @@ void LwpDrawMetafile::Read()
  * @descr   Constructor of class LwpDrawBitmap
  * @param   pStream   The memory stream which contains the lwp-sdw draw objects
  */
-LwpDrawBitmap::LwpDrawBitmap(SvStream* pStream) : LwpDrawObj(pStream), m_pImageData(nullptr)
+LwpDrawBitmap::LwpDrawBitmap(SvStream* pStream) : LwpDrawObj(pStream)
 {
 }
 
 LwpDrawBitmap::~LwpDrawBitmap()
 {
-    if (m_pImageData)
-    {
-        delete [] m_pImageData;
-        m_pImageData = nullptr;
-    }
 }
 
 /**
@@ -1361,7 +1356,7 @@ void LwpDrawBitmap::Read()
     // 20 == length of draw-specific fields.
     // 14 == length of bmp file header.
     m_aBmpRec.nFileSize = m_aObjHeader.nRecLen - 20 + 14;
-    m_pImageData = new sal_uInt8 [m_aBmpRec.nFileSize];
+    m_pImageData.reset( new sal_uInt8 [m_aBmpRec.nFileSize] );
 
     BmpInfoHeader2 aInfoHeader2;
     m_pStream->ReadUInt32( aInfoHeader2.nHeaderLen );
@@ -1421,7 +1416,7 @@ void LwpDrawBitmap::Read()
     m_pImageData[13] = static_cast<sal_uInt8>(nOffBits >> 24);
 
     sal_uInt32 nDIBRemaining;
-    sal_uInt8* pPicData = m_pImageData;
+    sal_uInt8* pPicData = m_pImageData.get();
     if (aInfoHeader2.nHeaderLen== sizeof(BmpInfoHeader))
     {
         m_pImageData[14] = static_cast<sal_uInt8>(aInfoHeader2.nHeaderLen);
@@ -1479,7 +1474,7 @@ OUString LwpDrawBitmap::RegisterStyle()
 XFFrame* LwpDrawBitmap::CreateDrawObj(const OUString& rStyleName)
 {
     XFImage* pImage = new XFImage();
-    pImage->SetImageData(m_pImageData, m_aBmpRec.nFileSize);
+    pImage->SetImageData(m_pImageData.get(), m_aBmpRec.nFileSize);
     SetPosition(pImage);
 
     pImage->SetStyleName(rStyleName);
diff --git a/lotuswordpro/source/filter/lwpdrawobj.hxx b/lotuswordpro/source/filter/lwpdrawobj.hxx
index 01b946653b8b..a44ad489f780 100644
--- a/lotuswordpro/source/filter/lwpdrawobj.hxx
+++ b/lotuswordpro/source/filter/lwpdrawobj.hxx
@@ -357,7 +357,7 @@ class LwpDrawBitmap : public LwpDrawObj
 {
 private:
     SdwBmpRecord m_aBmpRec;
-    sal_uInt8* m_pImageData;
+    std::unique_ptr<sal_uInt8[]> m_pImageData;
 public:
     explicit LwpDrawBitmap(SvStream* pStream);
     virtual ~LwpDrawBitmap() override;


More information about the Libreoffice-commits mailing list