diff options
author | Jens-Heiner Rechtien <hr@openoffice.org> | 2003-04-28 16:05:44 +0000 |
---|---|---|
committer | Jens-Heiner Rechtien <hr@openoffice.org> | 2003-04-28 16:05:44 +0000 |
commit | 940b9c3c93c27a1fa93454462dfdf5d5404ee663 (patch) | |
tree | db478044e985c1d62377566d1415a20e79d4015d /lingucomponent | |
parent | d896a36bb6479f74a925fc3f784452cff762e67d (diff) |
INTEGRATION: CWS ooo20030412 (1.6.2.2.4.1.2.1.4.1.2); FILE MERGED
2003/03/25 21:07:20 khendricks 1.6.2.2.4.1.2.1.4.1.2.1: minor updates and fixes for lingucomponent
includes a bug fix for issue 9887
Kevin
Diffstat (limited to 'lingucomponent')
-rw-r--r-- | lingucomponent/source/spellcheck/spell/sspellimp.cxx | 39 |
1 files changed, 30 insertions, 9 deletions
diff --git a/lingucomponent/source/spellcheck/spell/sspellimp.cxx b/lingucomponent/source/spellcheck/spell/sspellimp.cxx index 3c4e996b908a..981c36171d7c 100644 --- a/lingucomponent/source/spellcheck/spell/sspellimp.cxx +++ b/lingucomponent/source/spellcheck/spell/sspellimp.cxx @@ -2,9 +2,9 @@ * * $RCSfile: sspellimp.cxx,v $ * - * $Revision: 1.9 $ + * $Revision: 1.10 $ * - * last change: $Author: hr $ $Date: 2003-03-26 13:03:04 $ + * last change: $Author: hr $ $Date: 2003-04-28 17:05:44 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -97,7 +97,7 @@ #include <svtools/useroptions.hxx> #endif #include <osl/file.hxx> - +#include <rtl/ustrbuf.hxx> using namespace utl; @@ -330,9 +330,19 @@ INT16 SpellChecker::GetSpellFailure( const OUString &rWord, const Locale &rLocal INT16 nRes = -1; - String aTmp( rWord ); - if (aTmp.Len()) + // first handle smart quotes both single and double + OUStringBuffer rBuf(rWord); + sal_Int32 n = rBuf.getLength(); + sal_Unicode c; + for (sal_Int32 ix=0; ix < n; ix++) { + c = rBuf.charAt(ix); + if ((c == 0x201C) || (c == 0x201D)) rBuf.setCharAt(ix,(sal_Unicode)0x0022); + if ((c == 0x2018) || (c == 0x2019)) rBuf.setCharAt(ix,(sal_Unicode)0x0027); + } + OUString nWord(rBuf.makeStringAndClear()); + + if (n) { for (int i =0; i < numdict; i++) { @@ -362,7 +372,7 @@ INT16 SpellChecker::GetSpellFailure( const OUString &rWord, const Locale &rLocal } if (pMS) { - OString aWrd(OU2ENC(rWord,aEnc)); + OString aWrd(OU2ENC(nWord,aEnc)); int rVal = pMS->spell((char*)aWrd.getStr()); if (rVal != 1) { @@ -438,8 +448,18 @@ Reference< XSpellAlternatives > int count; int numsug = 0; - String aTmp( rWord ); - if (aTmp.Len()) + // first handle smart quotes (single and double) + OUStringBuffer rBuf(rWord); + sal_Int32 n = rBuf.getLength(); + sal_Unicode c; + for (sal_Int32 ix=0; ix < n; ix++) { + c = rBuf.charAt(ix); + if ((c == 0x201C) || (c == 0x201D)) rBuf.setCharAt(ix,(sal_Unicode)0x0022); + if ((c == 0x2018) || (c == 0x2019)) rBuf.setCharAt(ix,(sal_Unicode)0x0027); + } + OUString nWord(rBuf.makeStringAndClear()); + + if (n) { INT16 nLang = LocaleToLanguage( rLocale ); @@ -460,7 +480,7 @@ Reference< XSpellAlternatives > if (pMS) { char ** suglst = NULL; - OString aWrd(OU2ENC(rWord,aEnc)); + OString aWrd(OU2ENC(nWord,aEnc)); count = pMS->suggest(&suglst, (const char *) aWrd.getStr()); if (count) { @@ -482,6 +502,7 @@ Reference< XSpellAlternatives > // now return an empty alternative for no suggestions or the list of alternatives if some found SpellAlternatives *pAlt = new SpellAlternatives; + String aTmp(rWord); pAlt->SetWordLanguage( aTmp, nLang ); pAlt->SetFailureType( SpellFailure::SPELLING_ERROR ); pAlt->SetAlternatives( aStr ); |