Backport of r39360, r39361 and r39363:

- move spellchecker backend change action to actOnUpdatedPrefs where it belongs to
- add missing action for change of spellchecker_accept_compound preference
- care for a change of accept_compound and reconfigure the aspell backend accordingly
- only aspell is using spellchecker_accept_compound rc variable


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_2_0_X@39471 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Stephan Witt 2011-08-11 11:25:01 +00:00
parent 34b08f3c55
commit 91eb9c8c68
5 changed files with 30 additions and 5 deletions

View File

@ -41,6 +41,7 @@ namespace {
struct Speller {
AspellConfig * config;
AspellCanHaveError * e_speller;
bool accept_compound;
docstring_list ignored_words_;
};
@ -255,6 +256,7 @@ AspellSpeller * AspellChecker::Private::addSpeller(Language const * lang)
// Report run-together words as errors
aspell_config_replace(m.config, "run-together", "false");
m.accept_compound = lyxrc.spellchecker_accept_compound;
m.e_speller = new_aspell_speller(m.config);
if (aspell_error_number(m.e_speller) != 0) {
// FIXME: We should indicate somehow that this language is not supported.
@ -278,9 +280,25 @@ AspellSpeller * AspellChecker::Private::addSpeller(Language const * lang)
AspellSpeller * AspellChecker::Private::speller(Language const * lang)
{
Spellers::iterator it = spellers_.find(lang->lang());
if (it != spellers_.end())
return to_aspell_speller(it->second.e_speller);
if (it != spellers_.end()) {
Speller aspell = it->second;
if (lyxrc.spellchecker_accept_compound != aspell.accept_compound) {
// spell checker setting changed... adjust run-together
aspell.accept_compound = lyxrc.spellchecker_accept_compound;
if (aspell.accept_compound)
// Consider run-together words as legal compounds
aspell_config_replace(aspell.config, "run-together", "true");
else
// Report run-together words as errors
aspell_config_replace(aspell.config, "run-together", "false");
AspellCanHaveError * e_speller = aspell.e_speller;
aspell.e_speller = new_aspell_speller(aspell.config);
delete_aspell_speller(to_aspell_speller(e_speller));
spellers_[lang->lang()] = aspell;
}
return to_aspell_speller(aspell.e_speller);
}
return addSpeller(lang);
}

View File

@ -26,6 +26,7 @@
#include "LyX.h"
#include "Mover.h"
#include "Session.h"
#include "SpellChecker.h"
#include "version.h"
#include "graphics/GraphicsTypes.h"
@ -2903,6 +2904,8 @@ void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC const & lyxrc_new)
switch (tag) {
case LyXRC::RC_LAST:
case LyXRC::RC_ACCEPT_COMPOUND:
if (lyxrc_orig.spellchecker_accept_compound != lyxrc_new.spellchecker_accept_compound)
if (theSpellChecker()) theSpellChecker()->advanceChangeNumber();
case LyXRC::RC_ALT_LANG:
case LyXRC::RC_PLAINTEXT_LINELEN:
case LyXRC::RC_AUTOCORRECTION_MATH:
@ -3024,6 +3027,8 @@ void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC const & lyxrc_new)
case LyXRC::RC_SHOW_BANNER:
case LyXRC::RC_OPEN_BUFFERS_IN_TABS:
case LyXRC::RC_SPELLCHECKER:
if (lyxrc_orig.spellchecker != lyxrc_new.spellchecker)
setSpellChecker();
case LyXRC::RC_SPELLCHECK_CONTINUOUSLY:
case LyXRC::RC_SPELLCHECK_NOTES:
case LyXRC::RC_SPLITINDEX_COMMAND:

View File

@ -1439,7 +1439,6 @@ void GuiApplication::dispatch(FuncRequest const & cmd, DispatchResult & dr)
}
actOnUpdatedPrefs(lyxrc_orig, lyxrc);
setSpellChecker();
resetGui();
break;

View File

@ -1526,7 +1526,7 @@ void PrefSpellchecker::on_spellcheckerCB_currentIndexChanged(int index)
{
QString spellchecker = spellcheckerCB->itemData(index).toString();
compoundWordCB->setEnabled(spellchecker != QString("native"));
compoundWordCB->setEnabled(spellchecker == QString("aspell"));
}

View File

@ -60,6 +60,9 @@ What's new
- Sort entries in the "More Formats and Options" dialog (bug 7714).
- Enable "Accept compound" preference setting for Aspell backend only.
Reconfigure the aspell backend when "Accept compound" preference is
changed immediately.
* DOCUMENTATION AND LOCALIZATION