]> git.lyx.org Git - lyx.git/blobdiff - src/Paragraph.cpp
Do not scale statusbar icons
[lyx.git] / src / Paragraph.cpp
index 1faedd6fe58a5000e75baabb5259d84bb8d42d74..8ac87d31c2d2060cfa08f56d30d417a110c02023 100644 (file)
@@ -37,6 +37,7 @@
 #include "output_xhtml.h"
 #include "output_docbook.h"
 #include "ParagraphParameters.h"
+#include "Session.h"
 #include "SpellChecker.h"
 #include "texstream.h"
 #include "TexRow.h"
@@ -307,7 +308,7 @@ public:
        /// \return the number of characters written.
        int latexSurrogatePair(BufferParams const &, otexstream & os,
                               char_type c, char_type next,
-                              OutputParams const &);
+                              OutputParams const &) const;
 
        /// Output a space in appropriate formatting (or a surrogate pair
        /// if the next character is a combining character).
@@ -318,7 +319,7 @@ public:
                             pos_type i,
                             unsigned int & column,
                             Font const & font,
-                            Layout const & style);
+                            Layout const & style) const;
 
        /// This could go to ParagraphParameters if we want to.
        int startTeXParParams(BufferParams const &, otexstream &,
@@ -342,7 +343,7 @@ public:
                                   unsigned int & column,
                                   bool const fontswitch_inset,
                                   bool const closeLanguage,
-                                  bool const lang_switched_at_inset);
+                                  bool const lang_switched_at_inset) const;
 
        ///
        void latexSpecialChar(
@@ -354,7 +355,7 @@ public:
                                   Layout const & style,
                                   pos_type & i,
                                   pos_type end_pos,
-                                  unsigned int & column);
+                                  unsigned int & column) const;
 
        ///
        bool latexSpecialT1(
@@ -401,7 +402,7 @@ public:
                return speller_change_number > speller_state_.currentChangeNumber();
        }
 
-       bool ignoreWord(docstring const & word) const ;
+       bool ignoreWord(docstring const & word) const;
 
        void setMisspelled(pos_type from, pos_type to, SpellChecker::Result state)
        {
@@ -464,8 +465,7 @@ public:
                                 pos_type const & first, pos_type const & last,
                                 SpellChecker::Result result,
                                 docstring const & word,
-                                SkipPositions const & skips,
-                                vector<WordLangTuple> const & docdict);
+                                SkipPositions const & skips);
 
        InsetCode ownerCode() const
        {
@@ -833,6 +833,10 @@ void Paragraph::Private::insertChar(pos_type pos, char_type c,
 
        // Update list of misspelled positions
        speller_state_.increasePosAfterPos(pos);
+
+       // Update bookmarks
+       theSession().bookmarks().adjustPosAfterPos(inset_owner_->buffer().fileName(),
+                                                  id_, pos, 1);
 }
 
 
@@ -917,6 +921,10 @@ bool Paragraph::eraseChar(pos_type pos, bool trackChanges)
        d->speller_state_.decreasePosAfterPos(pos);
        d->speller_state_.refreshLast(size());
 
+       // Update bookmarks
+       theSession().bookmarks().adjustPosAfterPos(d->inset_owner_->buffer().fileName(),
+                                                  d->id_, pos, -1);
+
        return true;
 }
 
@@ -938,7 +946,7 @@ int Paragraph::eraseChars(pos_type start, pos_type end, bool trackChanges)
 // Handle combining characters
 int Paragraph::Private::latexSurrogatePair(BufferParams const & bparams,
                otexstream & os, char_type c, char_type next,
-               OutputParams const & runparams)
+               OutputParams const & runparams) const
 {
        // Writing next here may circumvent a possible font change between
        // c and next. Since next is only output if it forms a surrogate pair
@@ -975,7 +983,7 @@ bool Paragraph::Private::simpleTeXBlanks(BufferParams const & bparams,
                                       pos_type i,
                                       unsigned int & column,
                                       Font const & font,
-                                      Layout const & style)
+                                      Layout const & style) const
 {
        if (style.pass_thru || runparams.pass_thru)
                return false;
@@ -1028,7 +1036,7 @@ void Paragraph::Private::latexInset(BufferParams const & bparams,
                                    unsigned int & column,
                                    bool const fontswitch_inset,
                                    bool const closeLanguage,
-                                   bool const lang_switched_at_inset)
+                                   bool const lang_switched_at_inset) const
 {
        Inset * inset = owner_->getInset(i);
        LBUFERR(inset);
@@ -1194,7 +1202,7 @@ void Paragraph::Private::latexSpecialChar(otexstream & os,
                                          Layout const & style,
                                          pos_type & i,
                                          pos_type end_pos,
-                                         unsigned int & column)
+                                         unsigned int & column) const
 {
        char_type const c = owner_->getUChar(bparams, runparams, i);
 
@@ -4930,8 +4938,7 @@ void Paragraph::Private::markMisspelledWords(
        pos_type const & first, pos_type const & last,
        SpellChecker::Result result,
        docstring const & word,
-       SkipPositions const & skips,
-       vector<WordLangTuple> const & docdict)
+       SkipPositions const & skips)
 {
        if (!SpellChecker::misspelled(result)) {
                setMisspelled(first, last, SpellChecker::WORD_OK);
@@ -4951,7 +4958,7 @@ void Paragraph::Private::markMisspelledWords(
                /// should not happen if speller supports range checks
                if (!wlen)
                        continue;
-               docstring const candidate = word.substr(wstart, wlen);
+               WordLangTuple const candidate(word.substr(wstart, wlen), lang);
                wstart += first + numskipped;
                if (snext < wstart) {
                        /// mark the range of correct spelling
@@ -4961,26 +4968,19 @@ void Paragraph::Private::markMisspelledWords(
                }
                snext = wstart + wlen;
                // Check whether the candidate is in the document's local dict
-               vector<WordLangTuple>::const_iterator iit = docdict.begin();
                SpellChecker::Result actresult = result;
-               for (; iit != docdict.end(); ++iit) {
-                       if (iit->lang()->code() != lang->code())
-                               continue;
-                       if (iit->word() == candidate) {
-                               actresult = SpellChecker::WORD_OK;
-                               break;
-                       }
-               }
+               if (inset_owner_->buffer().params().spellignored(candidate))
+                       actresult = SpellChecker::DOCUMENT_LEARNED_WORD;
                numskipped += countSkips(it, et, snext);
                /// mark the range of misspelling
                setMisspelled(wstart, snext, actresult);
-               if (actresult == SpellChecker::WORD_OK)
+               if (actresult == SpellChecker::DOCUMENT_LEARNED_WORD)
                        LYXERR(Debug::GUI, "local dictionary word: \"" <<
-                                  candidate << "\" [" <<
+                                  candidate.word() << "\" [" <<
                                   wstart << ".." << (snext-1) << "]");
                else
                        LYXERR(Debug::GUI, "misspelled word: \"" <<
-                                  candidate << "\" [" <<
+                                  candidate.word() << "\" [" <<
                                   wstart << ".." << (snext-1) << "]");
                ++snext;
        }
@@ -5013,8 +5013,7 @@ void Paragraph::spellCheck() const
                        BufferParams const & bparams = d->inset_owner_->buffer().params();
                        SpellChecker::Result result = !word.empty() ?
                                speller->check(wl, bparams.spellignore()) : SpellChecker::WORD_OK;
-                       d->markMisspelledWords(lang, first, last, result, word, skips,
-                                              bparams.spellignore());
+                       d->markMisspelledWords(lang, first, last, result, word, skips);
                        first = ++last;
                }
        } else {