* support/lstring.{cpp,h}:

- 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
This commit is contained in:
Jürgen Spitzmüller 2010-02-09 17:35:35 +00:00
parent 70d5b8fe06
commit 5f4c5c5da9
3 changed files with 29 additions and 1 deletions

View 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.

View 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' ||

View 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);