From 9ad3a5f665f83ee4f635d37f1fc35b33661ea094 Mon Sep 17 00:00:00 2001 From: Kohei Yoshida Date: Mon, 10 Feb 2014 01:26:35 -0500 Subject: fdo#46707: Don't bother with synonyms for text with mixed script types. Change-Id: I7922905523406d05f864b10e1ecfd27f3fb5f9d6 (cherry picked from commit 49341001e76389f11bf67d756f4742275bc9dcd9) Reviewed-on: https://gerrit.libreoffice.org/7963 Reviewed-by: Eike Rathke Tested-by: Eike Rathke --- editeng/source/outliner/outlvw.cxx | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/editeng/source/outliner/outlvw.cxx b/editeng/source/outliner/outlvw.cxx index c1b8fa8bd255..52429ed84379 100644 --- a/editeng/source/outliner/outlvw.cxx +++ b/editeng/source/outliner/outlvw.cxx @@ -29,6 +29,7 @@ #include #include +#include #include #include @@ -1559,6 +1560,24 @@ Selection OutlinerView::GetSurroundingTextSelection() const // ===== some code for thesaurus sub menu within context menu // ====================================================================== +namespace { + +bool isSingleScriptType( sal_uInt16 nScriptType ) +{ + sal_uInt8 nScriptCount = 0; + + if (nScriptType & SCRIPTTYPE_LATIN) + ++nScriptCount; + if (nScriptType & SCRIPTTYPE_ASIAN) + ++nScriptCount; + if (nScriptType & SCRIPTTYPE_COMPLEX) + ++nScriptCount; + + return nScriptCount == 1; +} + +} + // returns: true if a word for thesaurus look-up was found at the current cursor position. // The status string will be word + iso language string (e.g. "light#en-US") bool EDITENG_DLLPUBLIC GetStatusValueForThesaurusFromContext( @@ -1574,6 +1593,10 @@ bool EDITENG_DLLPUBLIC GetStatusValueForThesaurusFromContext( aTextSel = pEditEngine->GetWord( aTextSel, i18n::WordType::DICTIONARY_WORD ); aText = pEditEngine->GetText( aTextSel ); aTextSel.Adjust(); + + if (!isSingleScriptType(pEditEngine->GetScriptType(aTextSel))) + return false; + LanguageType nLang = pEditEngine->GetLanguage( aTextSel.nStartPara, aTextSel.nStartPos ); OUString aLangText( LanguageTag( nLang ).getBcp47() ); -- cgit v1.2.3