sw/CppunitTest_sw_htmlexport.mk | 1 + sw/qa/extras/htmlexport/htmlexport.cxx | 8 ++++++++ 2 files changed, 9 insertions(+)
New commits: commit f40456f093fed10fd6153ad4c5960bd0f7b438c6 Author: Mark Hung <[email protected]> AuthorDate: Sat Feb 8 13:44:05 2020 +0800 Commit: Miklos Vajna <[email protected]> CommitDate: Mon Feb 10 12:25:03 2020 +0100 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 <[email protected]> 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) _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
