20#include <com/sun/star/uno/Reference.h>
21#include <com/sun/star/linguistic2/SpellFailure.hpp>
22#include <com/sun/star/linguistic2/XSearchableDictionaryList.hpp>
23#include <osl/mutex.hxx>
46#define MAX_PROPOSALS 40
49 const std::vector< OUString > &rSeq,
50 std::u16string_view rTxt)
53 sal_Int32 nLen = rSeq.size();
54 for (sal_Int32
i = 0;
i < nLen && !bRes; ++
i)
65 std::vector< OUString > & rDicListProps )
70 const uno::Sequence< Reference< XDictionary > >
71 aDics( xDicList->getDictionaries() );
73 *pDic = aDics.getConstArray();
74 sal_Int32 nDics = xDicList->getCount();
76 for (sal_Int32
i = 0;
i < nDics;
i++)
82 if ( xDic.is() && xDic->isActive()
85#if OSL_DEBUG_LEVEL > 0
86 DictionaryType
eType = xDic->getDictionaryType();
88 assert(
eType != DictionaryType_MIXED &&
"unexpected dictionary type" );
97 aEntryTxt = rEntry->getDictionaryWord().replaceAll(
"=",
"");
99 if (!aEntryTxt.isEmpty() && aEntryTxt.getLength() > 1 &&
LevDistance( rText, aEntryTxt ) <= 2)
100 rDicListProps.push_back( aEntryTxt );
111 bool bSthRemoved =
false;
112 sal_Int32 nLen = rSeq.size();
113 for (sal_Int32
i = 0;
i < nLen; ++
i)
116 rSeq[
i], nLanguage,
false,
true ) );
125 std::vector< OUString > aNew;
133 std::vector< OUString > &rAlt1,
134 std::vector< OUString > &rAlt2 )
136 std::vector< OUString > aMerged;
138 size_t nAltCount1 = rAlt1.size();
139 size_t nAltCount2 = rAlt2.size();
141 sal_Int32 nCountNew = std::min<sal_Int32>( nAltCount1 + nAltCount2, sal_Int32(
MAX_PROPOSALS) );
142 aMerged.resize( nCountNew );
146 for (
int j = 0; j < 2; j++)
148 sal_Int32
nCount = j == 0 ? nAltCount1 : nAltCount2;
149 std::vector< OUString >& rAlt = j == 0 ? rAlt1 : rAlt2;
152 if (!rAlt[
i].isEmpty() &&
154 aMerged[
nIndex++ ] = rAlt[
i ];
166 nType = SpellFailure::IS_NEGATIVE_WORD;
173 aAlt (rAlternatives),
174 aWord (
std::move(aWord_)),
175 nType (SpellFailure::IS_NEGATIVE_WORD),
181SpellAlternatives::~SpellAlternatives()
186OUString SAL_CALL SpellAlternatives::getWord()
193Locale SAL_CALL SpellAlternatives::getLocale()
200sal_Int16 SAL_CALL SpellAlternatives::getFailureType()
207sal_Int16 SAL_CALL SpellAlternatives::getAlternativesCount()
210 return static_cast<sal_Int16
>(aAlt.getLength());
221void SAL_CALL SpellAlternatives::setAlternatives(
const uno::Sequence< OUString >& rAlternatives )
224 aAlt = rAlternatives;
228void SAL_CALL SpellAlternatives::setFailureType( sal_Int16 nFailureType )
231 nType = nFailureType;
235void SpellAlternatives::SetWordLanguage(
const OUString &rWord,
LanguageType nLang)
243void SpellAlternatives::SetFailureType(sal_Int16 nTypeP)
257css::uno::Reference < css::linguistic2::XSpellAlternatives > SpellAlternatives::CreateSpellAlternatives(
258 const OUString &rWord,
LanguageType nLang, sal_Int16 nTypeP,
const css::uno::Sequence< OUString > &rAlt )
261 pAlt->SetWordLanguage( rWord, nLang );
262 pAlt->SetFailureType( nTypeP );
263 pAlt->SetAlternatives( rAlt );
static css::lang::Locale convertToLocale(LanguageType nLangID, bool bResolveSystem=true)
SpellAlternatives(OUString aWord, LanguageType nLang, const css::uno::Sequence< OUString > &rAlternatives)
ScXMLEditAttributeMap::Entry const aEntries[]
void SearchSimilarText(const OUString &rText, LanguageType nLanguage, Reference< XSearchableDictionaryList > const &xDicList, std::vector< OUString > &rDicListProps)
bool LinguIsUnspecified(LanguageType nLanguage)
Checks if a LanguageType is one of the values that denote absence of language or undetermined languag...
uno::Reference< XDictionaryEntry > SearchDicList(const uno::Reference< XSearchableDictionaryList > &xDicList, const OUString &rWord, LanguageType nLanguage, bool bSearchPosDics, bool bSearchSpellEntry)
static bool SeqHasEntry(const std::vector< OUString > &rSeq, std::u16string_view rTxt)
osl::Mutex & GetLinguMutex()
! multi-thread safe mutex for all platforms !!
void SeqRemoveNegEntries(std::vector< OUString > &rSeq, Reference< XSearchableDictionaryList > const &rxDicList, LanguageType nLanguage)
sal_Int32 LevDistance(std::u16string_view rTxt1, std::u16string_view rTxt2)
std::vector< OUString > MergeProposalSeqs(std::vector< OUString > &rAlt1, std::vector< OUString > &rAlt2)
LanguageType LinguLocaleToLanguage(const css::lang::Locale &rLocale)
Convert Locale to LanguageType for legacy handling.