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

Caolán McNamara caolanm at redhat.com
Mon Jan 8 11:25:03 UTC 2018


 lotuswordpro/source/filter/lwpcelllayout.cxx |   49 +++++++++++++--------------
 lotuswordpro/source/filter/lwplayout.cxx     |    6 +--
 2 files changed, 28 insertions(+), 27 deletions(-)

New commits:
commit 231f7c28267c56442ba65809a41aca7ecf09dd1e
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Mon Jan 8 09:10:16 2018 +0000

    ofz#5025 Direct-leak
    
    Change-Id: I2eb3e93f99f63f842378ab1839c79db2c781147a
    Reviewed-on: https://gerrit.libreoffice.org/47569
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/lotuswordpro/source/filter/lwpcelllayout.cxx b/lotuswordpro/source/filter/lwpcelllayout.cxx
index c6da43589aee..ca16bde31ffd 100644
--- a/lotuswordpro/source/filter/lwpcelllayout.cxx
+++ b/lotuswordpro/source/filter/lwpcelllayout.cxx
@@ -177,8 +177,8 @@ void LwpCellLayout::ApplyBorders(XFCellStyle *pCellStyle)
     LwpCellBorderType eType = GetCellBorderType(crowid, ccolid, GetTableLayout());
 
     // get left cell and judge if neighbour border is different
-    XFBorders * pBorders = GetXFBorders();
-    if(!pBorders)
+    std::unique_ptr<XFBorders> xBorders(GetXFBorders());
+    if (!xBorders)
     {
         return;
     }
@@ -186,21 +186,21 @@ void LwpCellLayout::ApplyBorders(XFCellStyle *pCellStyle)
     switch (eType)
     {
     case enumNoBottomBorder:
-        pBorders->SetWidth(enumXFBorderBottom, 0);
+        xBorders->SetWidth(enumXFBorderBottom, 0);
         break;
     case enumNoLeftBorder:
-        pBorders->SetWidth(enumXFBorderLeft, 0);
+        xBorders->SetWidth(enumXFBorderLeft, 0);
         break;
     case enumNoLeftNoBottomBorder:
-        pBorders->SetWidth(enumXFBorderBottom, 0);
-        pBorders->SetWidth(enumXFBorderLeft, 0);
+        xBorders->SetWidth(enumXFBorderBottom, 0);
+        xBorders->SetWidth(enumXFBorderLeft, 0);
         break;
     case enumWholeBorder:
         break;
     default:
         assert(false);
     }
-    pCellStyle->SetBorders(pBorders);
+    pCellStyle->SetBorders(xBorders.release());
 }
 /**
  * @short   Apply watermark to cell style
@@ -424,13 +424,13 @@ LwpCellBorderType LwpCellLayout::GetCellBorderType(sal_uInt16 nRow, sal_uInt16 n
         return enumWholeBorder;
 
     // get left cell and judge if neighbour border is different
-    XFBorders * pBorders = GetXFBorders();
-    if(!pBorders)
+    std::unique_ptr<XFBorders> xBorders(GetXFBorders());
+    if (!xBorders)
     {
         return enumWholeBorder;
     }
-    XFBorder& rLeftBorder = pBorders->GetLeft();
-    XFBorder& rBottomBorder = pBorders->GetBottom();
+    XFBorder& rLeftBorder = xBorders->GetLeft();
+    XFBorder& rBottomBorder = xBorders->GetBottom();
     bool bNoLeftBorder = false;
     bool bNoBottomBorder = false;
 
@@ -471,7 +471,7 @@ LwpCellBorderType LwpCellLayout::GetCellBorderType(sal_uInt16 nRow, sal_uInt16 n
         }
     }
 
-    delete pBorders;
+    xBorders.reset();
 
     if (bNoBottomBorder)
     {
@@ -517,8 +517,8 @@ void LwpCellLayout::RegisterDefaultCell()
         ApplyFmtStyle(xCellStyle.get());
         xCellStyle->SetAlignType(enumXFAlignNone, GetVerticalAlignmentType());
 
-        XFBorders * pBorders = GetXFBorders();
-        if (pBorders)
+        std::unique_ptr<XFBorders> xBorders(GetXFBorders());
+        if (xBorders)
         {
             switch(eLoop)
             {
@@ -527,15 +527,15 @@ void LwpCellLayout::RegisterDefaultCell()
                 //| |
 
                 // remove bottom line
-                pBorders->SetWidth(enumXFBorderBottom, 0);
+                xBorders->SetWidth(enumXFBorderBottom, 0);
                 break;
             case enumNoLeftNoBottomBorder:
 
                 //  |
 
                 // remove left and bottom
-                pBorders->SetWidth(enumXFBorderLeft, 0);
-                pBorders->SetWidth(enumXFBorderBottom, 0);
+                xBorders->SetWidth(enumXFBorderLeft, 0);
+                xBorders->SetWidth(enumXFBorderBottom, 0);
                 break;
             case enumWholeBorder:
 
@@ -548,12 +548,12 @@ void LwpCellLayout::RegisterDefaultCell()
                 //| |
 
                 // remove left line
-                pBorders->SetWidth(enumXFBorderLeft, 0);
+                xBorders->SetWidth(enumXFBorderLeft, 0);
                 break;
             default:
                 assert(false);
             }
-            xCellStyle->SetBorders(pBorders);
+            xCellStyle->SetBorders(xBorders.release());
         }
         m_CellStyleNames[eLoop] = pXFStyleManager->AddStyle(xCellStyle.release()).m_pStyle->GetStyleName();
     }
@@ -721,13 +721,13 @@ LwpCellBorderType LwpConnectedCellLayout::GetCellBorderType(sal_uInt16 nRow, sal
     sal_uInt16 nRowSpan = m_nRealrowspan;
 
     // get left cell and judge if neighbour border is different
-    XFBorders * pBorders = GetXFBorders();
-    if(!pBorders)
+    std::unique_ptr<XFBorders> xBorders(GetXFBorders());
+    if( !xBorders)
     {
         return enumWholeBorder;
     }
-    XFBorder& rLeftBorder = pBorders->GetLeft();
-    XFBorder& rBottomBorder = pBorders->GetBottom();
+    XFBorder& rLeftBorder = xBorders->GetLeft();
+    XFBorder& rBottomBorder = xBorders->GetBottom();
     bool bNoLeftBorder = true;
     bool bNoBottomBorder = true;
 
@@ -788,7 +788,8 @@ LwpCellBorderType LwpConnectedCellLayout::GetCellBorderType(sal_uInt16 nRow, sal
             }
         }
     }
-    delete pBorders;
+
+    xBorders.reset();
 
     if (bNoBottomBorder)
     {
diff --git a/lotuswordpro/source/filter/lwplayout.cxx b/lotuswordpro/source/filter/lwplayout.cxx
index 2d7c61a703df..00ab92c6a4b3 100644
--- a/lotuswordpro/source/filter/lwplayout.cxx
+++ b/lotuswordpro/source/filter/lwplayout.cxx
@@ -813,7 +813,7 @@ XFBorders* LwpMiddleLayout::GetXFBorders()
     if(pBorderStuff&&pBorderStuff->GetSide() != 0)
     {
         //copy from lwpparastyle.
-        XFBorders   *pXFBorders = new XFBorders();
+        std::unique_ptr<XFBorders> xXFBorders(new XFBorders);
         // apply 4 borders respectively
         LwpBorderStuff::BorderType const pType[] = { LwpBorderStuff::LEFT, LwpBorderStuff::RIGHT,
             LwpBorderStuff::TOP, LwpBorderStuff::BOTTOM };
@@ -822,10 +822,10 @@ XFBorders* LwpMiddleLayout::GetXFBorders()
         {
             if (pBorderStuff->HasSide(nC))
             {
-                LwpParaStyle::ApplySubBorder(pBorderStuff, nC, pXFBorders);
+                LwpParaStyle::ApplySubBorder(pBorderStuff, nC, xXFBorders.get());
             }
         }
-        return pXFBorders;
+        return xXFBorders.release();
     }
     return nullptr;
 }


More information about the Libreoffice-commits mailing list