summaryrefslogtreecommitdiff
path: root/lingucomponent
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2016-08-30 09:27:05 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2017-02-13 08:22:29 +0000
commit53b186d85894c2c41afc025bda459db5cc6ef452 (patch)
tree71918796bcf2432539d5367d1a37b2f7d3394a21 /lingucomponent
parentac0b2c90a9ae6a6442111b72113257fa16916d47 (diff)
Resolves: tdf#105426 upgrade to hunspell-1.6.0
and use alternative optimizations for buffer creation bottleneck Change-Id: I9f29e8d3e5e97fe403a3e0d7d03c6ac01c7689c4 (cherry picked from commit 163435fa23fbfc237a7718c9d440a98847e4f626) Reviewed-on: https://gerrit.libreoffice.org/34183 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Diffstat (limited to 'lingucomponent')
-rw-r--r--lingucomponent/source/spellcheck/spell/sspellimp.cxx44
1 files changed, 36 insertions, 8 deletions
diff --git a/lingucomponent/source/spellcheck/spell/sspellimp.cxx b/lingucomponent/source/spellcheck/spell/sspellimp.cxx
index db690ae83d11..a47ab58074e7 100644
--- a/lingucomponent/source/spellcheck/spell/sspellimp.cxx
+++ b/lingucomponent/source/spellcheck/spell/sspellimp.cxx
@@ -270,8 +270,11 @@ sal_Bool SAL_CALL SpellChecker::hasLocale(const Locale& rLocale)
return bRes;
}
-sal_Int16 SpellChecker::GetSpellFailure( const OUString &rWord, const Locale &rLocale )
+sal_Int16 SpellChecker::GetSpellFailure(const OUString &rWord, const Locale &rLocale)
{
+ if (rWord.getLength() > MAXWORDLEN)
+ return -1;
+
Hunspell * pMS = nullptr;
rtl_TextEncoding eEnc = RTL_TEXTENCODING_DONTKNOW;
@@ -334,7 +337,11 @@ sal_Int16 SpellChecker::GetSpellFailure( const OUString &rWord, const Locale &rL
#endif
aDicts[i] = new Hunspell(aTmpaff.getStr(),aTmpdict.getStr());
+#if defined(H_DEPRECATED)
+ aDEncs[i] = getTextEncodingFromCharset(aDicts[i]->get_dict_encoding().c_str());
+#else
aDEncs[i] = getTextEncodingFromCharset(aDicts[i]->get_dic_encoding());
+#endif
}
pMS = aDicts[i];
eEnc = aDEncs[i];
@@ -351,8 +358,12 @@ sal_Int16 SpellChecker::GetSpellFailure( const OUString &rWord, const Locale &rL
return -1;
OString aWrd(OU2ENC(nWord,eEnc));
- int rVal = pMS->spell(aWrd.getStr());
- if (rVal != 1) {
+#if defined(H_DEPRECATED)
+ bool bVal = pMS->spell(std::string(aWrd.getStr()));
+#else
+ bool bVal = pMS->spell(aWrd.getStr()) != 0;
+#endif
+ if (!bVal) {
if (extrachar && (eEnc != RTL_TEXTENCODING_UTF8)) {
OUStringBuffer aBuf(nWord);
n = aBuf.getLength();
@@ -370,8 +381,12 @@ sal_Int16 SpellChecker::GetSpellFailure( const OUString &rWord, const Locale &rL
}
OUString aWord(aBuf.makeStringAndClear());
OString bWrd(OU2ENC(aWord, eEnc));
- rVal = pMS->spell(bWrd.getStr());
- if (rVal == 1) return -1;
+#if defined(H_DEPRECATED)
+ bVal = pMS->spell(std::string(bWrd.getStr()));
+#else
+ bVal = pMS->spell(bWrd.getStr()) != 0;
+#endif
+ if (bVal) return -1;
}
nRes = SpellFailure::SPELLING_ERROR;
} else {
@@ -470,10 +485,23 @@ Reference< XSpellAlternatives >
if (pMS)
{
- char ** suglst = nullptr;
OString aWrd(OU2ENC(nWord,eEnc));
+#if defined(H_DEPRECATED)
+ std::vector<std::string> suglst = pMS->suggest(std::string(aWrd.getStr()));
+ if (!suglst.empty())
+ {
+ aStr.realloc(numsug + suglst.size());
+ OUString *pStr = aStr.getArray();
+ for (size_t ii = 0; ii < suglst.size(); ++ii)
+ {
+ OUString cvtwrd(suglst[ii].c_str(), suglst[ii].size(), eEnc);
+ pStr[numsug + ii] = cvtwrd;
+ }
+ numsug += suglst.size();
+ }
+#else
+ char ** suglst = nullptr;
int count = pMS->suggest(&suglst, aWrd.getStr());
-
if (count)
{
aStr.realloc( numsug + count );
@@ -485,8 +513,8 @@ Reference< XSpellAlternatives >
}
numsug += count;
}
-
pMS->free_list(&suglst, count);
+#endif
}
}