sax/source/tools/fastserializer.cxx | 25 ++----------------------- sw/qa/extras/ooxmlexport/data/nonbmpchar.docx |binary sw/qa/extras/ooxmlexport/ooxmlexport5.cxx | 9 +++++++++ 3 files changed, 11 insertions(+), 23 deletions(-)
New commits: commit 7ec5ba47783ac8b2d0141109d0efe6b20b363ced Author: Mark Hung <mark...@gmail.com> Date: Sun Jan 10 00:28:14 2016 +0800 Fix FastSaxSerializer::write() for non-BMP unicode characters. Change-Id: I6ee9d028813c970b9ac5b9f0574af932e73111bd Reviewed-on: https://gerrit.libreoffice.org/21293 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Michael Stahl <mst...@redhat.com> diff --git a/sax/source/tools/fastserializer.cxx b/sax/source/tools/fastserializer.cxx index 37ed847..8437ff0 100644 --- a/sax/source/tools/fastserializer.cxx +++ b/sax/source/tools/fastserializer.cxx @@ -94,29 +94,8 @@ namespace sax_fastparser { void FastSaxSerializer::write( const OUString& sOutput, bool bEscape ) { - const sal_Int32 nLength = sOutput.getLength(); - for (sal_Int32 i = 0; i < nLength; ++i) - { - const sal_Unicode cUnicode = sOutput[ i ]; - const char cChar = cUnicode; - if (cUnicode & 0xff80) - { - write( OString(&cUnicode, 1, RTL_TEXTENCODING_UTF8) ); - } - else if(bEscape) switch( cChar ) - { - case '<': writeBytes( "<", 4 ); break; - case '>': writeBytes( ">", 4 ); break; - case '&': writeBytes( "&", 5 ); break; - case '\'': writeBytes( "'", 6 ); break; - case '"': writeBytes( """, 6 ); break; - case '\n': writeBytes( " ", 5 ); break; - case '\r': writeBytes( " ", 5 ); break; - default: writeBytes( &cChar, 1 ); break; - } - else - writeBytes( &cChar, 1 ); - } + write( sOutput.toUtf8(), bEscape ); + } void FastSaxSerializer::write( const OString& sOutput, bool bEscape ) diff --git a/sw/qa/extras/ooxmlexport/data/nonbmpchar.docx b/sw/qa/extras/ooxmlexport/data/nonbmpchar.docx new file mode 100644 index 0000000..a6b5d41 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/nonbmpchar.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx index 9deea3e..68c0e2d 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx @@ -1011,6 +1011,15 @@ DECLARE_OOXMLEXPORT_TEST(testOO106020, "ooo106020-1.odt") assertXPath(pXmlDoc, "//w:tbl", 1); } +DECLARE_OOXMLEXPORT_TEST(testNonBMPChar, "nonbmpchar.docx") +{ + sal_uInt32 nCh = 0x24b62; + OUString aExpected( &nCh, 1); + // Assert that UTF8 encoded non-BMP Unicode character is correct + uno::Reference<text::XTextRange> xTextRange1 = getRun(getParagraph(1), 1); + CPPUNIT_ASSERT_EQUAL(aExpected, xTextRange1->getString()); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits