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.

Conflicts:
	sw/source/core/edit/acorrect.cxx

(cherry-picked from commit 733bfd9597fc42c569c6855bb71c56429e009fa6)

Change-Id: Id0d34267575782487819e3a3f76d1b547866e362
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142254
Tested-by: Jenkins
Reviewed-by: László Németh <nemeth@numbertext.org>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142672
diff --git a/sw/qa/extras/uiwriter/uiwriter6.cxx b/sw/qa/extras/uiwriter/uiwriter6.cxx
index e66fae3..48b8bcf 100644
--- a/sw/qa/extras/uiwriter/uiwriter6.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter6.cxx
@@ -1803,6 +1803,11 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest6, testTdf133589)
    emulateTyping(*pXTextDocument, u"„idézőjel” ");
    sReplaced += u"⹂𐳐𐳇𐳋𐳯𐳟𐳒𐳉𐳖‟ ";
    CPPUNIT_ASSERT_EQUAL(sReplaced, getParagraph(1)->getString());

    // tdf#148672 transliterate word with closing bracket
    emulateTyping(*pXTextDocument, 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 75b4548..ed2a0fb 100644
--- a/sw/source/core/edit/acorrect.cxx
+++ b/sw/source/core/edit/acorrect.cxx
@@ -564,10 +564,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.makeStringAndClear() + "]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.makeStringAndClear() + "0");
            if (pFormatter->GetPreviewString(sPrefix, 0, sConverted, &pColor, LANGUAGE_USER_HUNGARIAN_ROVAS))
            {
                if ( bHasBracket )
                    sConverted = sConverted + "]";
                bRet = true;
            }
        }

        SwPaM aPam(pFrame->MapViewToModelPos(TextFrameIndex(rSttPos)),