sw/qa/extras/uiwriter/uiwriter6.cxx |    5 +++++
 sw/source/core/edit/acorrect.cxx    |   15 +++++++++++++--
 2 files changed, 18 insertions(+), 2 deletions(-)

New commits:
commit 733bfd9597fc42c569c6855bb71c56429e009fa6
Author:     László Németh <nem...@numbertext.org>
AuthorDate: Thu Nov 3 21:42:48 2022 +0100
Commit:     László Németh <nem...@numbertext.org>
CommitDate: Fri Nov 4 09:52:19 2022 +0100

    tdf#148672 Old Hungarian transliteration: fix "word]"
    
    Words ending with closing bracket weren't transliterated,
    because NatNum12 parameters couldn't contain closing bracket.
    Transliterate without the bracket, and append it to the
    result.
    
    Note: "[word]", "(word)" etc. forms will be handled
    by the next libnumbertext release.
    
    Change-Id: Id0d34267575782487819e3a3f76d1b547866e362
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142254
    Tested-by: Jenkins
    Reviewed-by: László Németh <nem...@numbertext.org>

diff --git a/sw/qa/extras/uiwriter/uiwriter6.cxx 
b/sw/qa/extras/uiwriter/uiwriter6.cxx
index 122f607fb7cc..77901a2ea17e 100644
--- a/sw/qa/extras/uiwriter/uiwriter6.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter6.cxx
@@ -1787,6 +1787,11 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testTdf133589)
     emulateTyping(rXTextDocument, u"„idézőjel” ");
     sReplaced += u"⹂𐳐𐳇𐳋𐳯𐳟𐳒𐳉𐳖‟ ";
     CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString());
+
+    // tdf#148672 transliterate word with closing bracket
+    emulateTyping(rXTextDocument, u"word] ");
+    sReplaced += u"𐳮𐳛𐳢𐳇] "; // This was "word]" (no transliteration)
+    CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString());
 }
 
 CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testAutoCorr)
diff --git a/sw/source/core/edit/acorrect.cxx b/sw/source/core/edit/acorrect.cxx
index 9359420785b8..06ab1231ff40 100644
--- a/sw/source/core/edit/acorrect.cxx
+++ b/sw/source/core/edit/acorrect.cxx
@@ -563,10 +563,21 @@ bool SwAutoCorrDoc::TransliterateRTLWord( sal_Int32& 
rSttPos, sal_Int32 nEndPos,
         if (pFormatter && !sWord.isEmpty())
         {
             const Color* pColor = nullptr;
-            // Send text as NatNum12 prefix
-            OUString sPrefix("[NatNum12 " + sDisambiguatedWord + "]0");
+
+            // Send text as NatNum12 prefix: "word" -> "[NatNum12 word]0"
+
+            // Closing bracket doesn't allowed in NatNum parameters, remove it 
from transliteration:
+            // "[word]" -> "[NatNum12 [word]0"
+            bool bHasBracket = sWord.endsWith("]");
+            if ( !bHasBracket )
+                sDisambiguatedWord.append("]");
+            OUString sPrefix("[NatNum12 " + sDisambiguatedWord + "0");
             if (pFormatter->GetPreviewString(sPrefix, 0, sConverted, &pColor, 
LANGUAGE_USER_HUNGARIAN_ROVAS))
+            {
+                if ( bHasBracket )
+                    sConverted = sConverted + "]";
                 bRet = true;
+            }
         }
 
         SwPaM aPam(pFrame->MapViewToModelPos(TextFrameIndex(rSttPos)),

Reply via email to