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

Noel Grandin noel.grandin at collabora.co.uk
Wed Jul 11 13:51:17 UTC 2018


 sw/source/core/text/itratr.cxx   |   31 ++++++++++++++++++++++++++++++-
 sw/source/core/text/itratr.hxx   |   37 +++++--------------------------------
 sw/source/core/text/redlnitr.cxx |    4 ++--
 3 files changed, 37 insertions(+), 35 deletions(-)

New commits:
commit ba2a084d0e133faefadfe329fb1c28aa8c4f2a32
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Tue Jul 10 14:57:15 2018 +0200

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

diff --git a/sw/source/core/text/itratr.cxx b/sw/source/core/text/itratr.cxx
index b6e53480d6e4..6e81b4539e60 100644
--- a/sw/source/core/text/itratr.cxx
+++ b/sw/source/core/text/itratr.cxx
@@ -69,6 +69,35 @@ using namespace ::com::sun::star;
 static sal_Int32 GetNextAttrImpl(SwTextNode const* pTextNode,
         size_t nStartIndex, size_t nEndIndex, sal_Int32 nPosition);
 
+SwAttrIter::SwAttrIter(SwTextNode const * pTextNode)
+    : m_pViewShell(nullptr)
+    , m_pFont(nullptr)
+    , m_pScriptInfo(nullptr)
+    , m_pLastOut(nullptr)
+    , m_nChgCnt(0)
+    , m_nStartIndex(0)
+    , m_nEndIndex(0)
+    , m_nPosition(0)
+    , m_nPropFont(0)
+    , m_pTextNode(pTextNode)
+    , m_pMergedPara(nullptr)
+{
+    m_aMagicNo[SwFontScript::Latin] = m_aMagicNo[SwFontScript::CJK] = m_aMagicNo[SwFontScript::CTL] = nullptr;
+}
+
+SwAttrIter::SwAttrIter(SwTextNode& rTextNode, SwScriptInfo& rScrInf, SwTextFrame const*const pFrame)
+    : m_pViewShell(nullptr)
+    , m_pFont(nullptr)
+    , m_pScriptInfo(nullptr)
+    , m_pLastOut(nullptr)
+    , m_nChgCnt(0)
+    , m_nPropFont(0)
+    , m_pTextNode(&rTextNode)
+    , m_pMergedPara(nullptr)
+{
+    CtorInitAttrIter(rTextNode, rScrInf, pFrame);
+}
+
 void SwAttrIter::Chg( SwTextAttr const *pHt )
 {
     assert(pHt && m_pFont && "No attribute of font available for change");
@@ -92,7 +121,7 @@ void SwAttrIter::Rst( SwTextAttr const *pHt )
 
 SwAttrIter::~SwAttrIter()
 {
-    delete m_pRedline;
+    m_pRedline.reset();
     delete m_pFont;
 }
 
diff --git a/sw/source/core/text/itratr.hxx b/sw/source/core/text/itratr.hxx
index c47be02230d8..568a5ed53f26 100644
--- a/sw/source/core/text/itratr.hxx
+++ b/sw/source/core/text/itratr.hxx
@@ -42,14 +42,14 @@ protected:
 
     SwAttrHandler m_aAttrHandler;
     SwViewShell *m_pViewShell;
-    SwFont *m_pFont;
+    SwFont* m_pFont;
     SwScriptInfo* m_pScriptInfo;
 
 private:
     VclPtr<OutputDevice> m_pLastOut;
     /// count currently open hints, redlines, ext-input
     short m_nChgCnt;
-    SwRedlineItr *m_pRedline;
+    std::unique_ptr<SwRedlineItr> m_pRedline;
     /// current iteration index in HintStarts
     size_t m_nStartIndex;
     /// current iteration index in HintEnds
@@ -72,44 +72,17 @@ protected:
     void Chg( SwTextAttr const *pHt );
     void Rst( SwTextAttr const *pHt );
     void CtorInitAttrIter(SwTextNode& rTextNode, SwScriptInfo& rScrInf, SwTextFrame const* pFrame = nullptr);
-    explicit SwAttrIter(SwTextNode const * pTextNode)
-        : m_pViewShell(nullptr)
-        , m_pFont(nullptr)
-        , m_pScriptInfo(nullptr)
-        , m_pLastOut(nullptr)
-        , m_nChgCnt(0)
-        , m_pRedline(nullptr)
-        , m_nStartIndex(0)
-        , m_nEndIndex(0)
-        , m_nPosition(0)
-        , m_nPropFont(0)
-        , m_pTextNode(pTextNode)
-        , m_pMergedPara(nullptr)
-        {
-            m_aMagicNo[SwFontScript::Latin] = m_aMagicNo[SwFontScript::CJK] = m_aMagicNo[SwFontScript::CTL] = nullptr;
-        }
+    explicit SwAttrIter(SwTextNode const * pTextNode);
 
 public:
     /// All subclasses of this always have a SwTextFrame passed to the
     /// constructor, but SwAttrIter itself may be created without a
     /// SwTextFrame in certain special cases via this ctor here
-    SwAttrIter(SwTextNode& rTextNode, SwScriptInfo& rScrInf, SwTextFrame const*const pFrame = nullptr)
-        : m_pViewShell(nullptr)
-        , m_pFont(nullptr)
-        , m_pScriptInfo(nullptr)
-        , m_pLastOut(nullptr)
-        , m_nChgCnt(0)
-        , m_pRedline(nullptr)
-        , m_nPropFont(0)
-        , m_pTextNode(&rTextNode)
-        , m_pMergedPara(nullptr)
-    {
-        CtorInitAttrIter(rTextNode, rScrInf, pFrame);
-    }
+    SwAttrIter(SwTextNode& rTextNode, SwScriptInfo& rScrInf, SwTextFrame const*const pFrame = nullptr);
 
     virtual ~SwAttrIter();
 
-    SwRedlineItr *GetRedln() { return m_pRedline; }
+    SwRedlineItr *GetRedln() { return m_pRedline.get(); }
     // The parameter returns the position of the next change before or at the
     // char position.
     TextFrameIndex GetNextAttr() const;
diff --git a/sw/source/core/text/redlnitr.cxx b/sw/source/core/text/redlnitr.cxx
index b7ded98a503b..fa0673bc80e5 100644
--- a/sw/source/core/text/redlnitr.cxx
+++ b/sw/source/core/text/redlnitr.cxx
@@ -272,13 +272,13 @@ void SwAttrIter::CtorInitAttrIter(SwTextNode & rTextNode,
                 Seek( TextFrameIndex(0) );
             }
 
-            m_pRedline = new SwRedlineItr( rTextNode, *m_pFont, m_aAttrHandler, nRedlPos,
+            m_pRedline.reset(new SwRedlineItr( rTextNode, *m_pFont, m_aAttrHandler, nRedlPos,
                             m_pMergedPara
                                 ? SwRedlineItr::Mode::Hide
                                 : bShow
                                     ? SwRedlineItr::Mode::Show
                                     : SwRedlineItr::Mode::Ignore,
-                            pArr, pExtInp ? pExtInp->Start() : nullptr);
+                            pArr, pExtInp ? pExtInp->Start() : nullptr));
 
             if( m_pRedline->IsOn() )
                 ++m_nChgCnt;


More information about the Libreoffice-commits mailing list