sw/source/filter/html/htmltab.cxx | 3 +++ sw/source/filter/html/swhtml.cxx | 31 +++++++++++++++++++------------ sw/source/filter/html/swhtml.hxx | 2 ++ 3 files changed, 24 insertions(+), 12 deletions(-)
New commits: commit 7283bdaf9cdc81dbec55c915ecd8c2571478bc4d Author: Michael Stahl <[email protected]> Date: Mon Jan 22 19:48:06 2018 +0100 ofz#5566 sw: HTML import: ignore <DIV> in table structure elements Looking at the HTML4 DTD https://www.w3.org/TR/html4/sgml/dtd.html, inside TABLE only various elements defining the structure of the table allowed, except inside cells (TD and TH elements). DIV in a table but outside cells may cause cursor positions to go off the rails, so better ignore such invalid DIV tags. Reviewed-on: https://gerrit.libreoffice.org/48359 Tested-by: Jenkins <[email protected]> Reviewed-by: Caolán McNamara <[email protected]> Tested-by: Caolán McNamara <[email protected]> (cherry picked from commit 8b1a83bffe35ae0e71735569512c1586bcb37b25) Change-Id: Ia6195d80670631669c252d572242874b13642b74 Reviewed-on: https://gerrit.libreoffice.org/48526 Tested-by: Jenkins <[email protected]> Reviewed-by: Eike Rathke <[email protected]> diff --git a/sw/source/filter/html/htmltab.cxx b/sw/source/filter/html/htmltab.cxx index 0a499420f247..e033e4f36c61 100644 --- a/sw/source/filter/html/htmltab.cxx +++ b/sw/source/filter/html/htmltab.cxx @@ -19,6 +19,7 @@ #include <memory> #include "hintids.hxx" +#include <comphelper/flagguard.hxx> #include <vcl/svapp.hxx> #include <vcl/wrkwin.hxx> #include <editeng/boxitem.hxx> @@ -3313,6 +3314,7 @@ void SwHTMLParser::BuildTableCell( HTMLTable *pCurTable, bool bReadOptions, if( !IsParserWorking() && !m_pPendStack ) return; + ::comphelper::FlagRestorationGuard g(m_isInTableStructure, false); CellSaveStruct* pSaveStruct; HtmlTokenId nToken = HtmlTokenId::NONE; @@ -4978,6 +4980,7 @@ HTMLTable *SwHTMLParser::BuildTable( SvxAdjust eParentAdjust, if( !IsParserWorking() && !m_pPendStack ) return nullptr; + ::comphelper::FlagRestorationGuard g(m_isInTableStructure, true); HtmlTokenId nToken = HtmlTokenId::NONE; bool bPending = false; TableSaveStruct* pSaveStruct; diff --git a/sw/source/filter/html/swhtml.cxx b/sw/source/filter/html/swhtml.cxx index 3ec9997c8c33..f3560b11fbb6 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_isInTableStructure(false), m_pTempViewFrame(nullptr) { m_nEventId = nullptr; @@ -1538,26 +1539,32 @@ void SwHTMLParser::NextToken( HtmlTokenId nToken ) // divisions case HtmlTokenId::DIVISION_ON: case HtmlTokenId::CENTER_ON: - if( m_nOpenParaToken != HtmlTokenId::NONE ) + if (!m_isInTableStructure) { - if( IsReadPRE() ) - m_nOpenParaToken = HtmlTokenId::NONE; - else - EndPara(); + if (m_nOpenParaToken != HtmlTokenId::NONE) + { + if (IsReadPRE()) + m_nOpenParaToken = HtmlTokenId::NONE; + else + EndPara(); + } + NewDivision( nToken ); } - NewDivision( nToken ); break; case HtmlTokenId::DIVISION_OFF: case HtmlTokenId::CENTER_OFF: - if( m_nOpenParaToken != HtmlTokenId::NONE ) + if (!m_isInTableStructure) { - if( IsReadPRE() ) - m_nOpenParaToken = HtmlTokenId::NONE; - else - EndPara(); + if (m_nOpenParaToken != HtmlTokenId::NONE) + { + if (IsReadPRE()) + m_nOpenParaToken = HtmlTokenId::NONE; + else + EndPara(); + } + EndDivision(); } - EndDivision(); break; case HtmlTokenId::MULTICOL_ON: diff --git a/sw/source/filter/html/swhtml.hxx b/sw/source/filter/html/swhtml.hxx index a1ef95e54d8c..5284590f9f0f 100644 --- a/sw/source/filter/html/swhtml.hxx +++ b/sw/source/filter/html/swhtml.hxx @@ -476,6 +476,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_isInTableStructure; + /// the names corresponding to the DOCINFO field subtypes INFO[1-4] OUString m_InfoNames[4]; _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
