]> git.lyx.org Git - features.git/blobdiff - src/BufferParams.cpp
Fix deprecation warning
[features.git] / src / BufferParams.cpp
index 7004a9211f2e176ceed5c65ace6641b75eb204c5..35c2172340f01ba52e077bfd7cd50220e79dfa6a 100644 (file)
@@ -341,6 +341,7 @@ public:
 
        AuthorList authorlist;
        BranchList branchlist;
+       IgnoreList spellignore;
        Bullet temp_bullets[4];
        Bullet user_defined_bullets[4];
        IndicesList indiceslist;
@@ -600,6 +601,38 @@ IndicesList const & BufferParams::indiceslist() const
 }
 
 
+typedef std::vector<WordLangTuple> IgnoreList;
+
+
+IgnoreList & BufferParams::spellignore()
+{
+       return pimpl_->spellignore;
+}
+
+
+IgnoreList const & BufferParams::spellignore() const
+{
+       return pimpl_->spellignore;
+}
+
+
+bool BufferParams::spellignored(WordLangTuple const & wl) const
+{
+       bool has_item = false;
+       vector<WordLangTuple> il = spellignore();
+       vector<WordLangTuple>::const_iterator it = il.begin();
+       for (; it != il.end(); ++it) {
+               if (it->lang()->code() != wl.lang()->code())
+                       continue;
+               if (it->word() == wl.word()) {
+                       has_item = true;
+                       break;
+               }
+       }
+       return has_item;
+}
+
+
 Bullet & BufferParams::temp_bullet(lyx::size_type const index)
 {
        LASSERT(index < 4, return pimpl_->temp_bullets[0]);
@@ -1032,6 +1065,14 @@ string BufferParams::readToken(Lexer & lex, string const & token,
                                        lcolor.setColor(to_utf8(shortcut)+ "@" + filename.absFileName(), color);
                        }
                }
+       } else if (token == "\\spellchecker_ignore") {
+               lex.eatLine();
+               docstring wl = lex.getDocString();
+               docstring language;
+               docstring word = split(wl, language, ' ');
+               Language const * lang = languages.getLanguage(to_ascii(language));
+               if (lang)
+                       spellignore().push_back(WordLangTuple(word, lang));
        } else if (token == "\\author") {
                lex.eatLine();
                istringstream ss(lex.getString());
@@ -1408,6 +1449,12 @@ void BufferParams::writeFile(ostream & os, Buffer const * buf) const
                   << "\n";
        }
 
+       for (auto const & si : spellignore()) {
+               os << "\\spellchecker_ignore " << si.lang()->lang()
+                  << " " << to_utf8(si.word())
+                  << "\n";
+       }
+
        if (!paperwidth.empty())
                os << "\\paperwidth "
                   << VSpace(paperwidth).asLyXCommand() << '\n';