[Libreoffice-commits] core.git: Branch 'libreoffice-5-4' - sw/source

Caolán McNamara caolanm at redhat.com
Tue Nov 28 13:34:10 UTC 2017


 sw/source/core/table/swnewtable.cxx |   32 ++++++++++++++++----------------
 1 file changed, 16 insertions(+), 16 deletions(-)

New commits:
commit 9a110b6a284657f4db33627d8f76c270dac23810
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Mon Nov 27 17:07:25 2017 +0000

    ofz: fix mem leak
    
    Change-Id: I97b6ad9b0e873ac75a8791c731a1a8a862ef01af
    Reviewed-on: https://gerrit.libreoffice.org/45367
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Michael Stahl <mstahl at redhat.com>

diff --git a/sw/source/core/table/swnewtable.cxx b/sw/source/core/table/swnewtable.cxx
index f484a65c200c..b0130d82b903 100644
--- a/sw/source/core/table/swnewtable.cxx
+++ b/sw/source/core/table/swnewtable.cxx
@@ -60,11 +60,11 @@
 class SwBoxSelection
 {
 public:
-    std::vector<const SwSelBoxes*> aBoxes;
+    std::vector<SwSelBoxes> maBoxes;
     long mnMergeWidth;
     SwBoxSelection() : mnMergeWidth(0) {}
-    bool isEmpty() const { return aBoxes.empty(); }
-    void insertBoxes( const SwSelBoxes* pNew ){ aBoxes.insert( aBoxes.end(), pNew ); }
+    bool isEmpty() const { return maBoxes.empty(); }
+    void push_back(const SwSelBoxes& rNew) { maBoxes.push_back(rNew); }
 };
 
 /** NewMerge(..) removes the superfluous cells after cell merge
@@ -381,7 +381,7 @@ SwBoxSelection* SwTable::CollectBoxSelection( const SwPaM& rPam ) const
     {
         SwTableLine* pLine = m_aLines[nRow];
         OSL_ENSURE( pLine, "Missing table line" );
-        SwSelBoxes *pBoxes = new SwSelBoxes;
+        SwSelBoxes aBoxes;
         long nRight = 0;
         const size_t nCount = pLine->GetTabBoxes().size();
         for( size_t nCurrBox = 0; nCurrBox < nCount; ++nCurrBox )
@@ -408,7 +408,7 @@ SwBoxSelection* SwTable::CollectBoxSelection( const SwPaM& rPam ) const
                 {
                     if( nCurrBox )
                     {
-                        pBoxes->insert( pBox );
+                        aBoxes.insert(pBox);
                         pInnerBox = pBox;
                         pLeftBox = pLine->GetTabBoxes()[nCurrBox-1];
                         nDiff = nMin - nLeft;
@@ -439,7 +439,7 @@ SwBoxSelection* SwTable::CollectBoxSelection( const SwPaM& rPam ) const
             }
             else if( nRight <= nMax )
             {
-                pBoxes->insert( pBox );
+                aBoxes.insert(pBox);
                 if( nRow == nTop && nRowSpan < 0 )
                 {
                     bOkay = false;
@@ -458,7 +458,7 @@ SwBoxSelection* SwTable::CollectBoxSelection( const SwPaM& rPam ) const
                 {
                     if( nCurrBox+1 < nCount )
                     {
-                        pBoxes->insert( pBox );
+                        aBoxes.insert(pBox);
                         pInnerBox = pBox;
                         pRightBox = pLine->GetTabBoxes()[nCurrBox+1];
                         nDiff = nRight - nMax;
@@ -558,7 +558,7 @@ SwBoxSelection* SwTable::CollectBoxSelection( const SwPaM& rPam ) const
             --nLeftSpanCnt;
         if( nRightSpanCnt )
             --nRightSpanCnt;
-        pRet->insertBoxes( pBoxes );
+        pRet->push_back(aBoxes);
     }
     pRet->mnMergeWidth = nMax - nMin;
     if( nCheckBottom > nBottom )
@@ -825,7 +825,7 @@ bool SwTable::PrepareMerge( const SwPaM& rPam, SwSelBoxes& rBoxes,
     // i.e. contiguous cells in contiguous rows
     bool bMerge = false; // will be set if any content is transferred from
     // a "not already overlapped" cell into the new master cell.
-    SwTableBox *pMergeBox = (*pSel->aBoxes[0])[0]; // the master cell box
+    SwTableBox *pMergeBox = pSel->maBoxes[0][0]; // the master cell box
     if( !pMergeBox )
         return false;
     (*ppMergeBox) = pMergeBox;
@@ -840,7 +840,7 @@ bool SwTable::PrepareMerge( const SwPaM& rPam, SwSelBoxes& rBoxes,
     SwPosition aInsPos( *pMergeBox->GetSttNd()->EndOfSectionNode() );
     SwPaM aChkPam( aInsPos );
     // The number of lines in the selection rectangle: nLineCount
-    const size_t nLineCount = pSel->aBoxes.size();
+    const size_t nLineCount = pSel->maBoxes.size();
     // BTW: nLineCount is the rowspan of the new master cell
     long nRowSpan = static_cast<long>(nLineCount);
     // We will need the first and last line of the selection
@@ -851,12 +851,12 @@ bool SwTable::PrepareMerge( const SwPaM& rPam, SwSelBoxes& rBoxes,
     for( size_t nCurrLine = 0; nCurrLine < nLineCount; ++nCurrLine )
     {
         // The selected boxes in the current line
-        const SwSelBoxes* pBoxes = pSel->aBoxes[ nCurrLine ];
-        size_t nColCount = pBoxes->size();
+        const SwSelBoxes& rLineBoxes = pSel->maBoxes[nCurrLine];
+        size_t nColCount = rLineBoxes.size();
         // Iteration over the selected cell in the current row
         for (size_t nCurrCol = 0; nCurrCol < nColCount; ++nCurrCol)
         {
-            SwTableBox* pBox = (*pBoxes)[nCurrCol];
+            SwTableBox* pBox = rLineBoxes[nCurrCol];
             rMerged.insert( pBox );
             // Only the first selected cell in every row will be alive,
             // the other will be deleted => put into rBoxes
@@ -928,11 +928,11 @@ bool SwTable::PrepareMerge( const SwPaM& rPam, SwSelBoxes& rBoxes,
         pNewFormat->SetFormatAttr( SwFormatFrameSize( ATT_VAR_SIZE, pSel->mnMergeWidth, 0 ) );
         for( size_t nCurrLine = 0; nCurrLine < nLineCount; ++nCurrLine )
         {
-            const SwSelBoxes* pBoxes = pSel->aBoxes[ nCurrLine ];
-            size_t nColCount = pBoxes->size();
+            const SwSelBoxes& rLineBoxes = pSel->maBoxes[nCurrLine];
+            size_t nColCount = rLineBoxes.size();
             for (size_t nCurrCol = 0; nCurrCol < nColCount; ++nCurrCol)
             {
-                SwTableBox* pBox = (*pBoxes)[nCurrCol];
+                SwTableBox* pBox = rLineBoxes[nCurrCol];
                 if( nCurrCol )
                 {
                     // Even this box will be deleted soon,


More information about the Libreoffice-commits mailing list