[Libreoffice-commits] core.git: lingucomponent/source sw/qa

László Németh (via logerrit) logerrit at kemper.freedesktop.org
Thu Jun 18 09:17:44 UTC 2020


 lingucomponent/source/numbertext/numbertext.cxx |   25 ++++++++++++++++++++----
 sw/qa/extras/uiwriter/uiwriter.cxx              |    2 -
 2 files changed, 21 insertions(+), 6 deletions(-)

New commits:
commit 41f926e7a8adf92e73a810227e049ec83ab104bf
Author:     László Németh <nemeth at numbertext.org>
AuthorDate: Wed Jun 17 21:35:39 2020 +0200
Commit:     László Németh <nemeth at numbertext.org>
CommitDate: Thu Jun 18 11:17:08 2020 +0200

    tdf#133589 Numbertext: fix Hung encoding on Windows
    
    Workaround to fix non-BMP Unicode characters in
    the case of Hung (Old Hungarian) module, resulted by
    std::wstring limitation on Windows.
    
    Change-Id: I4f6a72ad0e3d4f70ef7e35910bb4147aedb0e4ae
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96562
    Tested-by: Jenkins
    Reviewed-by: László Németh <nemeth at numbertext.org>

diff --git a/lingucomponent/source/numbertext/numbertext.cxx b/lingucomponent/source/numbertext/numbertext.cxx
index 70324c7027b2..89f5432624bf 100644
--- a/lingucomponent/source/numbertext/numbertext.cxx
+++ b/lingucomponent/source/numbertext/numbertext.cxx
@@ -21,6 +21,7 @@
 
 #include <osl/file.hxx>
 #include <tools/debug.hxx>
+#include <rtl/ustrbuf.hxx>
 
 #include <sal/config.h>
 #include <cppuhelper/factory.hxx>
@@ -132,11 +133,27 @@ OUString SAL_CALL NumberText_Impl::getNumberText(const OUString& rText, const Lo
         aCode += "-" + aCountry;
     OString aLangCode(OUStringToOString(aCode, RTL_TEXTENCODING_ASCII_US));
     OString aInput(OUStringToOString(rText, RTL_TEXTENCODING_UTF8));
-    std::wstring aResult = Numbertext::string2wstring(aInput.getStr());
-    bool result = m_aNumberText.numbertext(aResult, aLangCode.getStr());
+    std::wstring sResult = Numbertext::string2wstring(aInput.getStr());
+    bool result = m_aNumberText.numbertext(sResult, aLangCode.getStr());
     DBG_ASSERT(result, "numbertext: false");
-    OString aResult2(Numbertext::wstring2string(aResult).c_str());
-    return OUString::fromUtf8(aResult2);
+    OUString aResult = OUString::fromUtf8(Numbertext::wstring2string(sResult).c_str());
+#if defined(_WIN32)
+    // workaround to fix non-BMP Unicode characters resulted by wstring limitation
+    if (!aScript.isEmpty() && aScript == "Hung")
+    {
+        OUStringBuffer aFix;
+        for (int i = 0; i < aResult.getLength(); ++i)
+        {
+            sal_Unicode c = aResult[i];
+            if (0x0C80 <= c && c <= 0x0CFF)
+                aFix.append(sal_Unicode(0xD803)).append(sal_Unicode(c + 0xD000));
+            else
+                aFix.append(c);
+        }
+        aResult = aFix.makeStringAndClear();
+    }
+#endif
+    return aResult;
 }
 
 uno::Sequence<Locale> SAL_CALL NumberText_Impl::getAvailableLanguages()
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index 6851037952fc..1fff27fff064 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -7275,7 +7275,6 @@ void SwUiWriterTest::testTdf128860()
 
 void SwUiWriterTest::testTdf133589()
 {
-#if !defined(_WIN32)
     // Hungarian test document with right-to-left paragraph setting
     SwDoc* pDoc = createDoc("tdf133589.fodt");
     SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
@@ -7307,7 +7306,6 @@ void SwUiWriterTest::testTdf133589()
     nIndex = pWrtShell->GetCursor()->GetNode().GetIndex();
     sReplaced += u"𐳺𐳺𐳿𐳼𐳼 ";
     CPPUNIT_ASSERT_EQUAL(sReplaced, static_cast<SwTextNode*>(pDoc->GetNodes()[nIndex])->GetText());
-#endif
 }
 
 #if HAVE_FEATURE_PDFIUM


More information about the Libreoffice-commits mailing list