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

Caolán McNamara caolanm at redhat.com
Tue Jan 2 20:55:46 UTC 2018


 sw/source/filter/html/htmlsect.cxx |    7 ++++++-
 sw/source/filter/html/swhtml.cxx   |    1 +
 sw/source/filter/html/swhtml.hxx   |   11 +++++++++--
 3 files changed, 16 insertions(+), 3 deletions(-)

New commits:
commit 834cebd153573eea3cc321eca5bcb572b4776dec
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Tue Jan 2 17:19:32 2018 +0000

    ofz: assert on trying to insert footer when already inserting the footer
    
    Change-Id: I1fd91cca4aec91700f7db233b420fe27752d659b
    Reviewed-on: https://gerrit.libreoffice.org/47272
    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/filter/html/htmlsect.cxx b/sw/source/filter/html/htmlsect.cxx
index 0b2facf82e62..9a23aebaa8f9 100644
--- a/sw/source/filter/html/htmlsect.cxx
+++ b/sw/source/filter/html/htmlsect.cxx
@@ -138,8 +138,11 @@ void SwHTMLParser::NewDivision( HtmlTokenId nToken )
         }
     }
 
-    if( !bPositioned && (bHeader || bFooter) && IsNewDoc() )
+    if (!bPositioned && (bHeader || bFooter) && IsNewDoc() && !m_bReadingHeaderOrFooter)
     {
+        m_bReadingHeaderOrFooter = true;
+        xCntxt->SetHeaderOrFooter(true);
+
         SwPageDesc *pPageDesc = m_pCSS1Parser->GetMasterPageDesc();
         SwFrameFormat& rPageFormat = pPageDesc->GetMaster();
 
@@ -403,6 +406,8 @@ void SwHTMLParser::EndDivision()
         // close attribute
         EndContext(xCntxt.get());
         SetAttr();  // set paragraph attributes really fast because of JavaScript
+        if (xCntxt->IsHeaderOrFooter())
+            m_bReadingHeaderOrFooter = false;
     }
 }
 
diff --git a/sw/source/filter/html/swhtml.cxx b/sw/source/filter/html/swhtml.cxx
index e8d3b316aaab..86a305b836a8 100644
--- a/sw/source/filter/html/swhtml.cxx
+++ b/sw/source/filter/html/swhtml.cxx
@@ -299,6 +299,7 @@ SwHTMLParser::SwHTMLParser( SwDoc* pD, SwPaM& rCursor, SvStream& rIn,
     m_bIgnoreHTMLComments( bNoHTMLComments ),
     m_bRemoveHidden( false ),
     m_bBodySeen( false ),
+    m_bReadingHeaderOrFooter( false ),
     m_pTempViewFrame(nullptr)
 {
     m_nEventId = nullptr;
diff --git a/sw/source/filter/html/swhtml.hxx b/sw/source/filter/html/swhtml.hxx
index 8d6130d6c70c..45b5effe1857 100644
--- a/sw/source/filter/html/swhtml.hxx
+++ b/sw/source/filter/html/swhtml.hxx
@@ -231,6 +231,7 @@ class HTMLAttrContext
     bool    bRestartPRE : 1;
     bool    bRestartXMP : 1;
     bool    bRestartListing : 1;
+    bool    bHeaderOrFooter : 1;
 
 public:
     void ClearSaveDocContext();
@@ -255,7 +256,8 @@ public:
         bFinishPREListingXMP( false ),
         bRestartPRE( false ),
         bRestartXMP( false ),
-        bRestartListing( false )
+        bRestartListing( false ),
+        bHeaderOrFooter( false )
     {}
 
     explicit HTMLAttrContext( HtmlTokenId nTokn ) :
@@ -276,7 +278,8 @@ public:
         bFinishPREListingXMP( false ),
         bRestartPRE( false ),
         bRestartXMP( false ),
-        bRestartListing( false )
+        bRestartListing( false ),
+        bHeaderOrFooter( false )
     {}
 
     ~HTMLAttrContext() { ClearSaveDocContext(); }
@@ -326,6 +329,9 @@ public:
     void SetRestartListing( bool bSet ) { bRestartListing = bSet; }
     bool IsRestartListing() const { return bRestartListing; }
 
+    void SetHeaderOrFooter( bool bSet ) { bHeaderOrFooter = bSet; }
+    bool IsHeaderOrFooter() const { return bHeaderOrFooter; }
+
     void SetAppendMode( SwHTMLAppendMode eMode ) { eAppend = eMode; }
     SwHTMLAppendMode GetAppendMode() const { return eAppend; }
 };
@@ -485,6 +491,7 @@ class SwHTMLParser : public SfxHTMLParser, public SwClient
     bool m_bRemoveHidden : 1; // the filter implementation might set the hidden flag
 
     bool m_bBodySeen : 1;
+    bool m_bReadingHeaderOrFooter : 1;
 
     /// the names corresponding to the DOCINFO field subtypes INFO[1-4]
     OUString m_InfoNames[4];


More information about the Libreoffice-commits mailing list