]> git.lyx.org Git - features.git/commitdiff
* support/lstring.{cpp,h}:
authorJürgen Spitzmüller <spitz@lyx.org>
Tue, 9 Feb 2010 17:35:35 +0000 (17:35 +0000)
committerJürgen Spitzmüller <spitz@lyx.org>
Tue, 9 Feb 2010 17:35:35 +0000 (17:35 +0000)
- new function hasDigit
* src/Paragraph.cpp (spellcheck):
- ignore words with digits, as in 1.6 (bug 6493).

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@33395 a592a061-630c-0410-9148-cb99ea01b6c8

src/Paragraph.cpp
src/support/lstrings.cpp
src/support/lstrings.h

index 3ccb524deb1f41e6c60f6a289c6d9d7722735844..af6158881dc8ed3287b757c048f2da441ec7f54e 100644 (file)
@@ -3170,6 +3170,10 @@ bool Paragraph::spellCheck(pos_type & from, pos_type & to, WordLangTuple & wl,
                return false;
 
        docstring word = asString(from, to, AS_STR_INSETS);
+       // Ignore words with digits
+       // FIXME: make this customizable
+       // (note that hunspell ignores words with digits by default)
+       bool const ignored = hasDigit(word);
        Language * lang = const_cast<Language *>(getFontSettings(
                    d->inset_owner_->buffer().params(), from).language());
        if (lang == d->inset_owner_->buffer().params().language
@@ -3181,7 +3185,8 @@ bool Paragraph::spellCheck(pos_type & from, pos_type & to, WordLangTuple & wl,
                lang->setVariety(lang_variety);
        }
        wl = WordLangTuple(word, lang);
-       SpellChecker::Result res = speller->check(wl);
+       SpellChecker::Result res = ignored ?
+               SpellChecker::OK : speller->check(wl);
 #if 0
 // FIXME: the code below makes aspell abort if a word in an unknown
 //       language is checked.
index fef11cf1d4de92c1294d913d37cb590d84f9b825..f5f3b1c4760ac6a86b8cb99b7cf4d7f4852aed56 100644 (file)
@@ -315,6 +315,26 @@ bool isStrDbl(string const & str)
 }
 
 
+bool hasDigit(docstring const & str)
+{
+       if (str.empty())
+               return false;
+
+       // Remove leading and trailing white space chars.
+       docstring const tmpstr = trim(str);
+       if (tmpstr.empty())
+               return false;
+
+       docstring::const_iterator cit = tmpstr.begin();
+       docstring::const_iterator end = tmpstr.end();
+       for (; cit != end; ++cit)
+               if (isdigit((*cit)))
+                       return true;
+
+       return false;
+}
+
+
 static bool isHexChar(char_type c)
 {
        return c == '0' ||
index 7b4751b020d0dddc9eb0807bdf4f804a23e62450..3bd30e8a77294ea478f57bab94c7810fdb8af298 100644 (file)
@@ -44,6 +44,9 @@ bool isStrUnsignedInt(std::string const & str);
 ///
 bool isStrDbl(std::string const & str);
 
+/// does the string contain a digit?
+bool hasDigit(docstring const & str);
+
 bool isHex(docstring const & str);
 
 int hexToInt(docstring const & str);