diff options
author | Mark Hung <marklh9@gmail.com> | 2020-02-08 13:44:05 +0800 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2020-02-10 12:25:03 +0100 |
commit | f40456f093fed10fd6153ad4c5960bd0f7b438c6 (patch) | |
tree | 3d0d94ab6f6559b7eca245ae15cbee701afce4c7 /sw | |
parent | 89150f1bcbb71c0cc505bed1547ee0526ace3b2c (diff) |
sw/qa: fix libxml2 parser error for testChinese
in htmlexport CUT on Windows with tradtional Chinese
as the system locale.
Libxml2 complaints about encoding:
Entity: line 2: parser error : Input is not proper UTF-8,
indicate encoding !
Bytes: 0xB4 0x49 0xA4 0xE5
- By default SvxHtmlOptions::GetTextEncoding() uses
SvtSysLocale::GetBestMimeEncoding() to decide the decoding,
where osl_getThreadTextEncoding() is used. That results in
big5 if you're using Windows with tradtional Chinese as the
system Locale.
- libxml2 expects the xml begins with "<?xm", and guesses the
encoding based on first 4 bytes of the content. So it always
falls back to utf8 in our test.
Change-Id: I48be9bf552ab6ea76f8baea7e48a8c02a7e8c2cb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88260
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/CppunitTest_sw_htmlexport.mk | 1 | ||||
-rw-r--r-- | sw/qa/extras/htmlexport/htmlexport.cxx | 8 |
2 files changed, 9 insertions, 0 deletions
diff --git a/sw/CppunitTest_sw_htmlexport.mk b/sw/CppunitTest_sw_htmlexport.mk index 3e2188bc07dc..957152c7fd8b 100644 --- a/sw/CppunitTest_sw_htmlexport.mk +++ b/sw/CppunitTest_sw_htmlexport.mk @@ -25,6 +25,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sw_htmlexport, \ sal \ sfx \ sw \ + svt \ test \ tl \ unotest \ diff --git a/sw/qa/extras/htmlexport/htmlexport.cxx b/sw/qa/extras/htmlexport/htmlexport.cxx index b5d2f0955aaa..ab1aaf366818 100644 --- a/sw/qa/extras/htmlexport/htmlexport.cxx +++ b/sw/qa/extras/htmlexport/htmlexport.cxx @@ -17,6 +17,7 @@ #include <com/sun/star/frame/XDispatchHelper.hpp> #include <com/sun/star/frame/DispatchHelper.hpp> +#include <svtools/htmlcfg.hxx> #include <swmodule.hxx> #include <swdll.hxx> #include <usrpref.hxx> @@ -776,6 +777,12 @@ CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testChinese) comphelper::makePropertyValue("FilterName", OUString("HTML (StarWriter)")), comphelper::makePropertyValue("FilterOptions", OUString("xhtmlns=reqif-xhtml")), }; + + // Prevent parseXmlStream guess incompatible encoding and complaint. + SvxHtmlOptions& rOptions = SvxHtmlOptions::Get(); + rtl_TextEncoding eOldEncoding = rOptions.GetTextEncoding(); + rOptions.SetTextEncoding(RTL_TEXTENCODING_UTF8); + xStorable->storeToURL(maTempFile.GetURL(), aStoreProperties); SvMemoryStream aStream; HtmlExportTest::wrapFragment(maTempFile, aStream); @@ -784,6 +791,7 @@ CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testChinese) // Without the accompanying fix in place, this test would have failed as the output was not // well-formed. CPPUNIT_ASSERT(pDoc); + rOptions.SetTextEncoding(eOldEncoding); } CPPUNIT_TEST_FIXTURE(SwHtmlDomExportTest, testReqifComment) |