diff options
author | Michael Stahl <mstahl@redhat.com> | 2018-01-22 19:48:06 +0100 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2018-03-06 21:37:57 +0100 |
commit | 12605a68effc52b887d9bc6b59bcf34920bdc05c (patch) | |
tree | 22d694ee4bba07a2176abb0b1bf76764cfa79a48 /sw | |
parent | cd9d633151727d68629a150fbb65be0c996e23c0 (diff) |
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 <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
(cherry picked from commit 8b1a83bffe35ae0e71735569512c1586bcb37b25)
Reviewed-on: https://gerrit.libreoffice.org/48526
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Eike Rathke <erack@redhat.com>
(cherry picked from commit 7283bdaf9cdc81dbec55c915ecd8c2571478bc4d)
Change-Id: Ia6195d80670631669c252d572242874b13642b74
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/filter/html/htmltab.cxx | 3 | ||||
-rw-r--r-- | sw/source/filter/html/swhtml.cxx | 33 | ||||
-rw-r--r-- | sw/source/filter/html/swhtml.hxx | 2 |
3 files changed, 25 insertions, 13 deletions
diff --git a/sw/source/filter/html/htmltab.cxx b/sw/source/filter/html/htmltab.cxx index d5d5736b6cd4..be6ea7d0bcba 100644 --- a/sw/source/filter/html/htmltab.cxx +++ b/sw/source/filter/html/htmltab.cxx @@ -18,6 +18,7 @@ */ #include "hintids.hxx" +#include <comphelper/flagguard.hxx> #include <vcl/svapp.hxx> #include <vcl/wrkwin.hxx> #include <editeng/boxitem.hxx> @@ -3398,6 +3399,7 @@ void SwHTMLParser::BuildTableCell( HTMLTable *pCurTable, bool bReadOptions, if( !IsParserWorking() && !m_pPendStack ) return; + ::comphelper::FlagRestorationGuard g(m_isInTableStructure, false); CellSaveStruct* pSaveStruct; int nToken = 0; @@ -5120,6 +5122,7 @@ HTMLTable *SwHTMLParser::BuildTable( SvxAdjust eParentAdjust, if( !IsParserWorking() && !m_pPendStack ) return nullptr; + ::comphelper::FlagRestorationGuard g(m_isInTableStructure, true); int nToken = 0; bool bPending = false; TableSaveStruct* pSaveStruct; diff --git a/sw/source/filter/html/swhtml.cxx b/sw/source/filter/html/swhtml.cxx index 058c39ad0b89..fb2a16ed1bff 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_isInTableStructure(false), m_pTempViewFrame(nullptr) { m_nEventId = nullptr; @@ -1543,26 +1544,32 @@ void SwHTMLParser::NextToken( int nToken ) // divisions case HTML_DIVISION_ON: case HTML_CENTER_ON: - if( m_nOpenParaToken ) - { - if( IsReadPRE() ) - m_nOpenParaToken = 0; - else - EndPara(); + if (!m_isInTableStructure) + { + if( m_nOpenParaToken ) + { + if( IsReadPRE() ) + m_nOpenParaToken = 0; + else + EndPara(); + } + NewDivision( nToken ); } - NewDivision( nToken ); break; case HTML_DIVISION_OFF: case HTML_CENTER_OFF: - if( m_nOpenParaToken ) + if (!m_isInTableStructure) { - if( IsReadPRE() ) - m_nOpenParaToken = 0; - else - EndPara(); + if( m_nOpenParaToken ) + { + if( IsReadPRE() ) + m_nOpenParaToken = 0; + else + EndPara(); + } + EndDivision( nToken ); } - EndDivision( nToken ); break; case HTML_MULTICOL_ON: diff --git a/sw/source/filter/html/swhtml.hxx b/sw/source/filter/html/swhtml.hxx index 6ef39ce7dd88..53111f6ef36d 100644 --- a/sw/source/filter/html/swhtml.hxx +++ b/sw/source/filter/html/swhtml.hxx @@ -477,6 +477,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]; |