[Libreoffice-commits] core.git: Branch 'libreoffice-6-0' - sw/source

Caolán McNamara caolanm at redhat.com
Wed Jan 3 15:30:16 UTC 2018


 sw/source/filter/html/swhtml.cxx |   41 ++++++++++++++++++++++-----------------
 sw/source/filter/html/swhtml.hxx |    2 +
 2 files changed, 26 insertions(+), 17 deletions(-)

New commits:
commit ef3d75d90724b29c6367f6b0dc4502cfb417ac84
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Dec 28 22:28:08 2017 +0000

    ofz#4817 Chaos with multiple body tags
    
    Change-Id: I4f2ab3a3be0909176599963c8ca113e3af85c832
    Reviewed-on: https://gerrit.libreoffice.org/47175
    Reviewed-by: Michael Stahl <mstahl at redhat.com>
    Tested-by: Michael Stahl <mstahl at redhat.com>

diff --git a/sw/source/filter/html/swhtml.cxx b/sw/source/filter/html/swhtml.cxx
index 7a6d70b612d1..057dc3ad4c04 100644
--- a/sw/source/filter/html/swhtml.cxx
+++ b/sw/source/filter/html/swhtml.cxx
@@ -296,6 +296,7 @@ SwHTMLParser::SwHTMLParser( SwDoc* pD, SwPaM& rCursor, SvStream& rIn,
     m_bInFootEndNoteSymbol( false ),
     m_bIgnoreHTMLComments( bNoHTMLComments ),
     m_bRemoveHidden( false ),
+    m_bBodySeen( false ),
     m_pTempViewFrame(nullptr)
 {
     m_nEventId = nullptr;
@@ -1245,25 +1246,31 @@ void SwHTMLParser::NextToken( HtmlTokenId nToken )
     switch( nToken )
     {
     case HtmlTokenId::BODY_ON:
-        if( !m_aStyleSource.isEmpty() )
-        {
-            m_pCSS1Parser->ParseStyleSheet( m_aStyleSource );
-            m_aStyleSource.clear();
-        }
-        if( IsNewDoc() )
+        if (m_bBodySeen)
+            eState = SvParserState::Error;
+        else
         {
-            InsertBodyOptions();
-            // If there is a template for the first or the right page,
-            // it is set here.
-            const SwPageDesc *pPageDesc = nullptr;
-            if( m_pCSS1Parser->IsSetFirstPageDesc() )
-                pPageDesc = m_pCSS1Parser->GetFirstPageDesc();
-            else if( m_pCSS1Parser->IsSetRightPageDesc() )
-                pPageDesc = m_pCSS1Parser->GetRightPageDesc();
-
-            if( pPageDesc )
+            m_bBodySeen = true;
+            if( !m_aStyleSource.isEmpty() )
             {
-                m_xDoc->getIDocumentContentOperations().InsertPoolItem( *m_pPam, SwFormatPageDesc( pPageDesc ) );
+                m_pCSS1Parser->ParseStyleSheet( m_aStyleSource );
+                m_aStyleSource.clear();
+            }
+            if( IsNewDoc() )
+            {
+                InsertBodyOptions();
+                // If there is a template for the first or the right page,
+                // it is set here.
+                const SwPageDesc *pPageDesc = nullptr;
+                if( m_pCSS1Parser->IsSetFirstPageDesc() )
+                    pPageDesc = m_pCSS1Parser->GetFirstPageDesc();
+                else if( m_pCSS1Parser->IsSetRightPageDesc() )
+                    pPageDesc = m_pCSS1Parser->GetRightPageDesc();
+
+                if( pPageDesc )
+                {
+                    m_xDoc->getIDocumentContentOperations().InsertPoolItem( *m_pPam, SwFormatPageDesc( pPageDesc ) );
+                }
             }
         }
         break;
diff --git a/sw/source/filter/html/swhtml.hxx b/sw/source/filter/html/swhtml.hxx
index 98b380dbb13c..66f7837704ae 100644
--- a/sw/source/filter/html/swhtml.hxx
+++ b/sw/source/filter/html/swhtml.hxx
@@ -472,6 +472,8 @@ class SwHTMLParser : public SfxHTMLParser, public SwClient
     bool m_bIgnoreHTMLComments : 1;
     bool m_bRemoveHidden : 1; // the filter implementation might set the hidden flag
 
+    bool m_bBodySeen : 1;
+
     /// the names corresponding to the DOCINFO field subtypes INFO[1-4]
     OUString m_InfoNames[4];
 


More information about the Libreoffice-commits mailing list