]> git.lyx.org Git - lyx.git/blobdiff - src/Buffer.cpp
That didn't really work. So revert to old CSS for gray notes.
[lyx.git] / src / Buffer.cpp
index 15c7553af243061be82ea0e0b2fe3a25234eb869..90512f0b63cbab0329fd588e93584ff600bbbd96 100644 (file)
@@ -127,7 +127,7 @@ namespace {
 
 // Do not remove the comment below, so we get merge conflict in
 // independent branches. Instead add your own.
-int const LYX_FORMAT = 372; // jspitzm: buffer param fontenc
+int const LYX_FORMAT = 373; // jspitzm: merge g-brief class
 
 typedef map<string, bool> DepClean;
 typedef map<docstring, pair<InsetLabel const *, Buffer::References> > RefCache;
@@ -356,6 +356,17 @@ Buffer::~Buffer()
 }
 
 
+Buffer * Buffer::clone() const
+{
+       Buffer * clone = new Buffer(fileName().absFilename(), false);
+       clone->d->file_fully_loaded = true;
+       clone->d->params = d->params;
+       clone->d->inset = static_cast<InsetText *>(d->inset->clone());
+       clone->d->inset->setBuffer(*clone);
+       return clone;
+}
+
+
 void Buffer::changed() const
 {
        if (d->wa_)
@@ -1417,6 +1428,7 @@ void Buffer::writeLyXHTMLSource(odocstream & os,
 {
        LaTeXFeatures features(*this, params(), runparams);
        validate(features);
+       updateLabels(UpdateMaster, true);
 
        d->texrow.reset();
 
@@ -2654,14 +2666,11 @@ void Buffer::updateMacroInstances() const
        LYXERR(Debug::MACROS, "updateMacroInstances for "
                << d->filename.onlyFileName());
        DocIterator it = doc_iterator_begin(this);
-       DocIterator end = doc_iterator_end(this);
-       for (; it != end; it.forwardPos()) {
-               // look for MathData cells in InsetMathNest insets
-               Inset * inset = it.nextInset();
-               if (!inset)
-                       continue;
-
-               InsetMath * minset = inset->asInsetMath();
+       it.forwardInset();
+       DocIterator const end = doc_iterator_end(this);
+       for (; it != end; it.forwardInset()) {
+               // look for MathData cells in InsetMathNest insets
+               InsetMath * minset = it.nextInset()->asInsetMath();
                if (!minset)
                        continue;
 
@@ -3442,7 +3451,7 @@ void Buffer::setBuffersForInsets() const
 }
 
 
-void Buffer::updateLabels(bool out, UpdateScope scope) const
+void Buffer::updateLabels(UpdateScope scope, bool out) const
 {
        // Use the master text class also for child documents
        Buffer const * const master = masterBuffer();
@@ -3456,7 +3465,7 @@ void Buffer::updateLabels(bool out, UpdateScope scope) const
                // If this is a child document start with the master
                if (master != this) {
                        bufToUpdate.insert(this);
-                       master->updateLabels(out);
+                       master->updateLabels(UpdateMaster, out);
                        // Do this here in case the master has no gui associated with it. Then, 
                        // the TocModel is not updated and TocModel::toc_ is invalid (bug 5699).
                        if (!master->gui_)
@@ -3737,15 +3746,26 @@ int Buffer::spellCheck(DocIterator & from, DocIterator & to,
        DocIterator const end = doc_iterator_end(this);
        for (; from != end; from.forwardPos()) {
                // We are only interested in text so remove the math CursorSlice.
-               while (from.inMathed())
-                       from.forwardInset();
+               while (from.inMathed()) {
+                       from.pop_back();
+                       from.pos()++;
+               }
+               // If from is at the end of the document (which is possible
+               // when leaving the mathed) LyX will crash later.
+               if (from == end)
+                       break;
                to = from;
                if (from.paragraph().spellCheck(from.pos(), to.pos(), wl, suggestions)) {
                        word_lang = wl;
                        break;
                }
-               from = to;
-               ++progress;
+
+               // Do not increase progress when from == to, otherwise the word
+               // count will be wrong.
+               if (from != to) {
+                       from = to;
+                       ++progress;
+               }
        }
        return progress;
 }