diff options
author | Caolán McNamara <caolanm@redhat.com> | 2017-12-28 22:28:08 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2017-12-29 15:21:48 +0100 |
commit | 1f349bb10c3c1fc6d5d598847a7281cef728b762 (patch) | |
tree | 38b3017b4a55ed63dbddd7b457f4f61143cb4e63 | |
parent | 4475ffbdaec9353ba01b6e4a39420d81c562d5d9 (diff) |
ofz#4817 Chaos with multiple body tags
Change-Id: I4f2ab3a3be0909176599963c8ca113e3af85c832
Reviewed-on: https://gerrit.libreoffice.org/47159
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r-- | sw/source/filter/html/swhtml.cxx | 41 | ||||
-rw-r--r-- | sw/source/filter/html/swhtml.hxx | 2 |
2 files changed, 26 insertions, 17 deletions
diff --git a/sw/source/filter/html/swhtml.cxx b/sw/source/filter/html/swhtml.cxx index 53dc9e5e32ef..7376ab23da47 100644 --- a/sw/source/filter/html/swhtml.cxx +++ b/sw/source/filter/html/swhtml.cxx @@ -298,6 +298,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; @@ -1257,25 +1258,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 1392192852a9..7ba0e42ace00 100644 --- a/sw/source/filter/html/swhtml.hxx +++ b/sw/source/filter/html/swhtml.hxx @@ -483,6 +483,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]; |