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 <nemeth@numbertext.org>
diff --git a/sw/qa/extras/uiwriter/uiwriter6.cxx b/sw/qa/extras/uiwriter/uiwriter6.cxx
index 122f607..77901a2 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 93594207..06ab123 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)),