diff options
author | Caolán McNamara <caolanm@redhat.com> | 2017-12-28 22:28:08 +0000 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2018-01-03 16:29:50 +0100 |
commit | ef3d75d90724b29c6367f6b0dc4502cfb417ac84 (patch) | |
tree | b36e90fbd73e6e343bd3593feba83deb0818093d /sw | |
parent | 46597d2b096fffba1863c3172adbc73551312138 (diff) |
ofz#4817 Chaos with multiple body tags
Change-Id: I4f2ab3a3be0909176599963c8ca113e3af85c832
Reviewed-on: https://gerrit.libreoffice.org/47175
Reviewed-by: Michael Stahl <mstahl@redhat.com>
Tested-by: Michael Stahl <mstahl@redhat.com>
Diffstat (limited to 'sw')
-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 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]; |