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

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Tue Jan 15 05:58:06 UTC 2019


 sw/source/filter/ww8/wrtw8num.cxx |   10 ++++------
 sw/source/filter/ww8/ww8par.hxx   |    2 +-
 sw/source/filter/ww8/ww8par2.cxx  |   14 ++++----------
 sw/source/filter/ww8/ww8par6.cxx  |   10 ++++------
 sw/source/uibase/wrtsh/wrtsh2.cxx |   26 +++++++++++++-------------
 5 files changed, 26 insertions(+), 36 deletions(-)

New commits:
commit 11f85d828a16b1beee5c476bd4d8d21c3e450592
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Mon Jan 14 10:43:10 2019 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Tue Jan 15 06:57:58 2019 +0100

    use unique_ptr in SwWW8ImplReader::ConstructApo
    
    Change-Id: I104168fbbd04f81d500bc9d63d4328aee0a11f24
    Reviewed-on: https://gerrit.libreoffice.org/66318
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/sw/source/filter/ww8/ww8par.hxx b/sw/source/filter/ww8/ww8par.hxx
index 4a91dc1da609..33b0a9349141 100644
--- a/sw/source/filter/ww8/ww8par.hxx
+++ b/sw/source/filter/ww8/ww8par.hxx
@@ -1493,7 +1493,7 @@ private:
     bool IsListOrDropcap() { return (!m_xCurrentItemSet  || m_bDropCap); };
 
     //Apo == Absolutely Positioned Object, MSWord's old-style frames
-    WW8FlyPara *ConstructApo(const ApoTestResults &rApo,
+    std::unique_ptr<WW8FlyPara> ConstructApo(const ApoTestResults &rApo,
         const WW8_TablePos *pTabPos);
     bool StartApo(const ApoTestResults &rApo, const WW8_TablePos *pTabPos);
     void StopApo();
diff --git a/sw/source/filter/ww8/ww8par2.cxx b/sw/source/filter/ww8/ww8par2.cxx
index 04f896ea268f..f5224bec80a1 100644
--- a/sw/source/filter/ww8/ww8par2.cxx
+++ b/sw/source/filter/ww8/ww8par2.cxx
@@ -460,9 +460,7 @@ ApoTestResults SwWW8ImplReader::TestApo(int nCellLevel, bool bTableRowEnd,
     bool bNowApo = aRet.HasFrame() || pTopLevelTable;
     if (bNowApo)
     {
-        if (WW8FlyPara *pTest = ConstructApo(aRet, pTabPos))
-            delete pTest;
-        else
+        if (!ConstructApo(aRet, pTabPos))
             bNowApo = false;
     }
 
@@ -2080,10 +2078,7 @@ WW8TabDesc::WW8TabDesc(SwWW8ImplReader* pIoClass, WW8_CP nStartCp) :
         if (aApo.mbStartApo)
         {
             //if there really is a fly here, and not a "null" fly then break.
-            WW8FlyPara *pNewFly = m_pIo->ConstructApo(aApo, pTabPos);
-            if (pNewFly)
-                delete pNewFly;
-            else
+            if (m_pIo->ConstructApo(aApo, pTabPos))
                 break;
         }
 
@@ -3408,7 +3403,7 @@ bool SwWW8ImplReader::StartTable(WW8_CP nStartCp)
 
     // #i33818# - determine absolute position object attributes,
     // if possible. It's needed for nested tables.
-    WW8FlyPara* pTableWFlyPara( nullptr );
+    std::unique_ptr<WW8FlyPara> pTableWFlyPara;
     WW8SwFlyPara* pTableSFlyPara( nullptr );
     // #i45301# - anchor nested table inside Writer fly frame
     // only at-character, if absolute position object attributes are available.
@@ -3485,7 +3480,7 @@ bool SwWW8ImplReader::StartTable(WW8_CP nStartCp)
             // if existing, and apply them to the created Writer fly frame.
             if ( pTableWFlyPara && pTableSFlyPara )
             {
-                WW8FlySet aFlySet( *this, pTableWFlyPara, pTableSFlyPara, false );
+                WW8FlySet aFlySet( *this, pTableWFlyPara.get(), pTableSFlyPara, false );
                 SwFormatAnchor aAnchor( RndStdIds::FLY_AT_CHAR );
                 aAnchor.SetAnchor( m_xTableDesc->m_pParentPos );
                 aFlySet.Put( aAnchor );
@@ -3510,7 +3505,6 @@ bool SwWW8ImplReader::StartTable(WW8_CP nStartCp)
         PopTableDesc();
 
     // #i33818#
-    delete pTableWFlyPara;
     delete pTableSFlyPara;
 
     return m_xTableDesc != nullptr;
diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx
index a178f5c788d0..2b12c2619a1b 100644
--- a/sw/source/filter/ww8/ww8par6.cxx
+++ b/sw/source/filter/ww8/ww8par6.cxx
@@ -2364,14 +2364,13 @@ SwTwips SwWW8ImplReader::MoveOutsideFly(SwFrameFormat *pFlyFormat,
     return nRetWidth;
 }
 
-WW8FlyPara *SwWW8ImplReader::ConstructApo(const ApoTestResults &rApo,
+std::unique_ptr<WW8FlyPara> SwWW8ImplReader::ConstructApo(const ApoTestResults &rApo,
     const WW8_TablePos *pTabPos)
 {
-    WW8FlyPara *pRet = nullptr;
     OSL_ENSURE(rApo.HasFrame() || pTabPos,
         "If no frame found, *MUST* be in a table");
 
-    pRet = new WW8FlyPara(m_bVer67, rApo.mpStyleApo);
+    std::unique_ptr<WW8FlyPara> pRet(new WW8FlyPara(m_bVer67, rApo.mpStyleApo));
 
     // find APO parameter and test for bGrafApo
     if (rApo.HasFrame())
@@ -2381,8 +2380,7 @@ WW8FlyPara *SwWW8ImplReader::ConstructApo(const ApoTestResults &rApo,
 
     if (pRet->IsEmpty())
     {
-        delete pRet;
-        pRet = nullptr;
+        pRet.reset();
     }
     return pRet;
 }
@@ -2418,7 +2416,7 @@ bool SwWW8ImplReader::IsDropCap()
 
 bool SwWW8ImplReader::StartApo(const ApoTestResults &rApo, const WW8_TablePos *pTabPos)
 {
-    m_xWFlyPara.reset(ConstructApo(rApo, pTabPos));
+    m_xWFlyPara = ConstructApo(rApo, pTabPos);
     if (!m_xWFlyPara)
         return false;
 
commit 9c6cd998aeb7061f38ec1334e160d002008dd66b
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Mon Jan 14 10:37:09 2019 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Tue Jan 15 06:57:43 2019 +0100

    use unique_ptr in sw
    
    Change-Id: I8c472a7d363eb308e9ec78aadd7f1f20c824447b
    Reviewed-on: https://gerrit.libreoffice.org/66317
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/sw/source/filter/ww8/wrtw8num.cxx b/sw/source/filter/ww8/wrtw8num.cxx
index b0b0cde57768..3fdd90134014 100644
--- a/sw/source/filter/ww8/wrtw8num.cxx
+++ b/sw/source/filter/ww8/wrtw8num.cxx
@@ -480,7 +480,7 @@ void MSWordExportBase::AbstractNumberingDefinitions()
             }
 
             // Attributes of the numbering
-            wwFont *pPseudoFont = nullptr;
+            std::unique_ptr<wwFont> pPseudoFont;
             const SfxItemSet* pOutSet = nullptr;
 
             // cbGrpprlChpx
@@ -500,8 +500,8 @@ void MSWordExportBase::AbstractNumberingDefinitions()
                     if ( sFontName.isEmpty() )
                         sFontName = pBulletFont->GetFamilyName();
 
-                    pPseudoFont = new wwFont( sFontName, pBulletFont->GetPitch(),
-                        eFamily, eChrSet);
+                    pPseudoFont.reset(new wwFont( sFontName, pBulletFont->GetPitch(),
+                        eFamily, eChrSet));
                 }
                 else
                     pOutSet = &rFormat.GetCharFormat()->GetAttrSet();
@@ -531,12 +531,10 @@ void MSWordExportBase::AbstractNumberingDefinitions()
                     rFormat.GetNumAdjust(),
                     aNumLvlPos,
                     nFollow,
-                    pPseudoFont, pOutSet,
+                    pPseudoFont.get(), pOutSet,
                     nIndentAt, nFirstLineIndex, nListTabPos,
                     sNumStr,
                     rFormat.GetNumberingType()==SVX_NUM_BITMAP ? rFormat.GetBrush():nullptr);
-
-            delete pPseudoFont;
         }
         AttrOutput().EndAbstractNumbering();
     }
diff --git a/sw/source/uibase/wrtsh/wrtsh2.cxx b/sw/source/uibase/wrtsh/wrtsh2.cxx
index bff262badbf3..5fccd756bae9 100644
--- a/sw/source/uibase/wrtsh/wrtsh2.cxx
+++ b/sw/source/uibase/wrtsh/wrtsh2.cxx
@@ -134,14 +134,17 @@ void SwWrtShell::Insert(SwField const &rField)
 void SwWrtShell::UpdateInputFields( SwInputFieldList* pLst )
 {
     // Go through the list of fields and updating
-    SwInputFieldList* pTmp = pLst;
-    if( !pTmp )
-        pTmp = new SwInputFieldList( this );
+    std::unique_ptr<SwInputFieldList> pTmp;
+    if (!pLst)
+    {
+        pTmp.reset(new SwInputFieldList( this ));
+        pLst = pTmp.get();
+    }
 
-    const size_t nCnt = pTmp->Count();
+    const size_t nCnt = pLst->Count();
     if(nCnt)
     {
-        pTmp->PushCursor();
+        pLst->PushCursor();
 
         bool bCancel = false;
 
@@ -153,7 +156,7 @@ void SwWrtShell::UpdateInputFields( SwInputFieldList* pLst )
         {
             for (size_t i = 0; i < nCnt; i++)
             {
-                if (pField == pTmp->GetField(i))
+                if (pField == pLst->GetField(i))
                 {
                     nIndex = i;
                     break;
@@ -165,8 +168,8 @@ void SwWrtShell::UpdateInputFields( SwInputFieldList* pLst )
         {
             bool bPrev = nIndex > 0;
             bool bNext = nIndex < nCnt - 1;
-            pTmp->GotoFieldPos(nIndex);
-            pField = pTmp->GetField(nIndex);
+            pLst->GotoFieldPos(nIndex);
+            pField = pLst->GetField(nIndex);
             if (pField->GetTyp()->Which() == SwFieldIds::Dropdown)
             {
                 bCancel = StartDropDownFieldDlg(pField, bPrev, bNext, GetView().GetFrameWeld(), &ePressedButton);
@@ -177,7 +180,7 @@ void SwWrtShell::UpdateInputFields( SwInputFieldList* pLst )
             if (!bCancel)
             {
                 // Otherwise update error at multi-selection:
-                pTmp->GetField(nIndex)->GetTyp()->UpdateFields();
+                pLst->GetField(nIndex)->GetTyp()->UpdateFields();
 
                 if (ePressedButton == FieldDialogPressedButton::Previous && nIndex > 0)
                     nIndex--;
@@ -188,11 +191,8 @@ void SwWrtShell::UpdateInputFields( SwInputFieldList* pLst )
             }
         }
 
-        pTmp->PopCursor();
+        pLst->PopCursor();
     }
-
-    if( !pLst )
-        delete pTmp;
 }
 
 // Listener class: will close InputField dialog if input field(s)


More information about the Libreoffice-commits mailing list