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

Caolán McNamara caolanm at redhat.com
Thu Dec 14 10:10:00 UTC 2017


 sw/source/core/doc/htmltbl.cxx     |    7 +++----
 sw/source/filter/html/htmlctxt.cxx |    1 +
 sw/source/filter/html/htmlgrin.cxx |    2 +-
 sw/source/filter/html/htmltab.cxx  |   35 ++++++++++++++++++++++-------------
 4 files changed, 27 insertions(+), 18 deletions(-)

New commits:
commit 5399998c498bd3047ecb430868d3aa0cde61fef2
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Wed Dec 13 12:46:34 2017 +0000

    fiddle with leaks some more
    
    Change-Id: Ia4297ce2b537953fe2262b645b7bf7f8a85b5d41
    Reviewed-on: https://gerrit.libreoffice.org/46408
    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/sw/source/core/doc/htmltbl.cxx b/sw/source/core/doc/htmltbl.cxx
index 7c45dd598f16..a234f7bfbf13 100644
--- a/sw/source/core/doc/htmltbl.cxx
+++ b/sw/source/core/doc/htmltbl.cxx
@@ -545,10 +545,9 @@ void SwHTMLTableLayout::AutoLayoutPass1()
                             nIdx++;
                         }
                     }
-                    else
+                    else if (SwHTMLTableLayout *pChild = pCnts->GetTable())
                     {
                         OSL_ENSURE( false, "Sub tables in HTML import?" );
-                        SwHTMLTableLayout *pChild = pCnts->GetTable();
                         pChild->AutoLayoutPass1();
                         sal_uLong nMaxTableCnts = pChild->m_nMax;
                         sal_uLong nAbsMinTableCnts = pChild->m_nMin;
@@ -1592,7 +1591,7 @@ void SwHTMLTableLayout::SetWidths( bool bCallPass2, sal_uInt16 nAbsAvail,
                 {
                     SetBoxWidth( pBox, j, pCell->GetColSpan() );
                 }
-                else
+                else if (SwHTMLTableLayout *pTable = pContents->GetTable())
                 {
                     sal_uInt16 nAbs = 0, nRel = 0, nLSpace = 0, nRSpace = 0,
                            nInhSpace = 0;
@@ -1604,7 +1603,7 @@ void SwHTMLTableLayout::SetWidths( bool bCallPass2, sal_uInt16 nAbsAvail,
                         nRSpace = GetRightCellSpace( j, nColSpan );
                         nInhSpace = GetInhCellSpace( j, nColSpan );
                     }
-                    pContents->GetTable()->SetWidths( bCallPass2, nAbs, nRel,
+                    pTable->SetWidths( bCallPass2, nAbs, nRel,
                                                     nLSpace, nRSpace,
                                                     nInhSpace );
                 }
diff --git a/sw/source/filter/html/htmlctxt.cxx b/sw/source/filter/html/htmlctxt.cxx
index 91b7384c844d..263c347b01b7 100644
--- a/sw/source/filter/html/htmlctxt.cxx
+++ b/sw/source/filter/html/htmlctxt.cxx
@@ -375,6 +375,7 @@ void SwHTMLParser::ClearContext( HTMLAttrContext *pContext )
         // but if you get that wrong, quite a lot is messed up
         DeleteAttr( pAttr );
     }
+    rAttrs.clear();
 
     OSL_ENSURE( !pContext->GetSpansSection(),
             "Area can no longer be exited" );
diff --git a/sw/source/filter/html/htmlgrin.cxx b/sw/source/filter/html/htmlgrin.cxx
index e2781d6e7d5f..54e967e661f4 100644
--- a/sw/source/filter/html/htmlgrin.cxx
+++ b/sw/source/filter/html/htmlgrin.cxx
@@ -263,7 +263,7 @@ void SwHTMLParser::SetAnchorAndAdjustment( sal_Int16 eVertOri,
     if (aAnchor.GetAnchorId() == RndStdIds::FLY_AS_CHAR && !m_pPam->GetNode().GetTextNode())
     {
         eState = SvParserState::Error;
-        throw std::runtime_error("missing paragraph");
+        return;
     }
 
     aAnchor.SetAnchor( m_pPam->GetPoint() );
diff --git a/sw/source/filter/html/htmltab.cxx b/sw/source/filter/html/htmltab.cxx
index 80d0d883d8e8..d0dd6dfd22de 100644
--- a/sw/source/filter/html/htmltab.cxx
+++ b/sw/source/filter/html/htmltab.cxx
@@ -1673,9 +1673,9 @@ SwTableBox *HTMLTable::MakeTableBox( SwTableLine *pUpper,
             pBox = NewTableBox( pCnts->GetStartNode(), pUpper );
             pCnts->SetTableBox( pBox );
         }
-        else
+        else if (HTMLTable* pTable = pCnts->GetTable().get())
         {
-            pCnts->GetTable()->InheritVertBorders( this, nLeftCol,
+            pTable->InheritVertBorders( this, nLeftCol,
                                                    nRightCol-nLeftCol );
             // ... that's a table. We'll build a new box and put the rows of the table
             // in the rows of the box
@@ -1688,6 +1688,10 @@ SwTableBox *HTMLTable::MakeTableBox( SwTableLine *pUpper,
             pCnts->GetTable()->MakeTable( pBox, nAbs, nRel, nLSpace, nRSpace,
                                           nInhSpace );
         }
+        else
+        {
+            return nullptr;
+        }
     }
     else
     {
@@ -2707,7 +2711,7 @@ const SwStartNode *SwHTMLParser::InsertTableSection( sal_uInt16 nPoolId )
         if (!pTableNd)
         {
             eState = SvParserState::Error;
-            throw std::runtime_error("missing table");
+            return nullptr;
         }
         if( pTableNd->GetTable().GetHTMLTableLayout() )
         { // if there is already a HTMTableLayout, this table is already finished
@@ -2731,7 +2735,6 @@ const SwStartNode *SwHTMLParser::InsertTableSection( sal_uInt16 nPoolId )
     if (!pStNd)
     {
         eState = SvParserState::Error;
-        throw std::runtime_error("missing table start node");
     }
 
     return pStNd;
@@ -3900,15 +3903,21 @@ void SwHTMLParser::BuildTableCell( HTMLTable *pCurTable, bool bReadOptions,
             InsertTableSection( static_cast< sal_uInt16 >(xSaveStruct->IsHeaderCell()
                                         ? RES_POOLCOLL_TABLE_HDLN
                                         : RES_POOLCOLL_TABLE ));
-        const SwEndNode *pEndNd = pStNd->EndOfSectionNode();
-        SwContentNode *pCNd = m_xDoc->GetNodes()[pEndNd->GetIndex()-1] ->GetContentNode();
-        //Added defaults to CJK and CTL
-        SvxFontHeightItem aFontHeight( 40, 100, RES_CHRATR_FONTSIZE );
-        pCNd->SetAttr( aFontHeight );
-        SvxFontHeightItem aFontHeightCJK( 40, 100, RES_CHRATR_CJK_FONTSIZE );
-        pCNd->SetAttr( aFontHeightCJK );
-        SvxFontHeightItem aFontHeightCTL( 40, 100, RES_CHRATR_CTL_FONTSIZE );
-        pCNd->SetAttr( aFontHeightCTL );
+
+        if (!pStNd)
+            eState = SvParserState::Error;
+        else
+        {
+            const SwEndNode *pEndNd = pStNd->EndOfSectionNode();
+            SwContentNode *pCNd = m_xDoc->GetNodes()[pEndNd->GetIndex()-1] ->GetContentNode();
+            //Added defaults to CJK and CTL
+            SvxFontHeightItem aFontHeight( 40, 100, RES_CHRATR_FONTSIZE );
+            pCNd->SetAttr( aFontHeight );
+            SvxFontHeightItem aFontHeightCJK( 40, 100, RES_CHRATR_CJK_FONTSIZE );
+            pCNd->SetAttr( aFontHeightCJK );
+            SvxFontHeightItem aFontHeightCTL( 40, 100, RES_CHRATR_CTL_FONTSIZE );
+            pCNd->SetAttr( aFontHeightCTL );
+        }
 
         xSaveStruct->AddContents( new HTMLTableCnts(pStNd) );
         xSaveStruct->ClearIsInSection();


More information about the Libreoffice-commits mailing list