[Libreoffice-commits] core.git: Branch 'distro/vector/vector-5.4' - svtools/qa svtools/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Wed Aug 29 07:14:01 UTC 2018
svtools/qa/unit/testHtmlReader.cxx | 22 ++++++++++++++++++++++
svtools/source/svhtml/parhtml.cxx | 3 ++-
2 files changed, 24 insertions(+), 1 deletion(-)
New commits:
commit b922673b9a1f1537a77c8fc8a0063f445a983193
Author: Miklos Vajna <vmiklos at collabora.co.uk>
AuthorDate: Tue Aug 28 18:10:03 2018 +0200
Commit: Miklos Vajna <vmiklos at collabora.co.uk>
CommitDate: Wed Aug 29 08:51:13 2018 +0200
XHTML import: <br></br> is one line break
But only for XHTML, HTML stays unchanged to be in sync with web
browsers.
Change-Id: I3a1cf6651dab565bafece68963acb112ae715cdd
Reviewed-on: https://gerrit.libreoffice.org/59727
Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
Tested-by: Jenkins
(cherry picked from commit 60362accc78fdff4213fa6c28bb4fbf00e06972f)
diff --git a/svtools/qa/unit/testHtmlReader.cxx b/svtools/qa/unit/testHtmlReader.cxx
index 151976eabc9d..d5ad61d4a9a5 100644
--- a/svtools/qa/unit/testHtmlReader.cxx
+++ b/svtools/qa/unit/testHtmlReader.cxx
@@ -23,8 +23,11 @@ class TestHTMLParser : public HTMLParser
public:
TestHTMLParser(SvStream& rStream);
virtual void NextToken(HtmlTokenId nToken) override;
+ /// Make this public for test purposes.
+ using HTMLParser::SetNamespace;
OUString m_aDocument;
+ int m_nLineBreakCount = 0;
};
TestHTMLParser::TestHTMLParser(SvStream& rStream)
@@ -36,6 +39,8 @@ void TestHTMLParser::NextToken(HtmlTokenId nToken)
{
if (nToken == HtmlTokenId::TEXTTOKEN)
m_aDocument += aToken;
+ else if (nToken == HtmlTokenId::LINEBREAK)
+ ++m_nLineBreakCount;
}
/// Tests HTMLParser.
@@ -43,9 +48,11 @@ class Test : public CppUnit::TestFixture
{
public:
void testTdf114428();
+ void testLineBreak();
CPPUNIT_TEST_SUITE(Test);
CPPUNIT_TEST(testTdf114428);
+ CPPUNIT_TEST(testLineBreak);
CPPUNIT_TEST_SUITE_END();
};
@@ -64,6 +71,21 @@ void Test::testTdf114428()
CPPUNIT_ASSERT_EQUAL(OUString("hello"), xParser->m_aDocument.trim());
}
+void Test::testLineBreak()
+{
+ SvMemoryStream aStream;
+ OString aDocument("aaa<br></br>bbb");
+ aStream.WriteBytes(aDocument.getStr(), aDocument.getLength());
+ aStream.Seek(0);
+
+ tools::SvRef<TestHTMLParser> xParser = new TestHTMLParser(aStream);
+ xParser->SetNamespace("reqif-xhtml");
+ xParser->CallParser();
+
+ // This was 2, <br></br> was interpreted as 2 line breaks in XHTML mode.
+ CPPUNIT_ASSERT_EQUAL(1, xParser->m_nLineBreakCount);
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(Test);
}
diff --git a/svtools/source/svhtml/parhtml.cxx b/svtools/source/svhtml/parhtml.cxx
index 1964dd9a42fd..ad65dec1484f 100644
--- a/svtools/source/svhtml/parhtml.cxx
+++ b/svtools/source/svhtml/parhtml.cxx
@@ -1077,10 +1077,11 @@ HtmlTokenId HTMLParser::GetNextToken_()
// and there is an off token, return off token instead
nRet = (HtmlTokenId)((int)nRet + 1);
}
- else if( HtmlTokenId::LINEBREAK!=nRet )
+ else if( HtmlTokenId::LINEBREAK!=nRet || !maNamespace.isEmpty())
{
// and there is no off token, return unknown token.
// (except for </BR>, that is treated like <BR>)
+ // No exception for XHTML, though.
nRet = HtmlTokenId::UNKNOWNCONTROL_OFF;
}
}
More information about the Libreoffice-commits
mailing list