]> 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 e5bca13233c3ae87eb26fb9f00dc7e493e92fa7e..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(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(UpdateScope scope) const
                // If this is a child document start with the master
                if (master != this) {
                        bufToUpdate.insert(this);
-                       master->updateLabels();
+                       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_)
@@ -3484,7 +3493,7 @@ void Buffer::updateLabels(UpdateScope scope) const
 
        // do the real work
        ParIterator parit = cbuf.par_iterator_begin();
-       updateLabels(parit);
+       updateLabels(parit, out);
 
        if (master != this)
                // TocBackend update will be done later.
@@ -3576,7 +3585,7 @@ void Buffer::setLabel(ParIterator & it) const
 
        if (par.params().startOfAppendix()) {
                // FIXME: only the counter corresponding to toplevel
-               // sectionning should be reset
+               // sectioning should be reset
                counters.reset();
                counters.appendix(true);
        }
@@ -3695,7 +3704,7 @@ void Buffer::setLabel(ParIterator & it) const
 }
 
 
-void Buffer::updateLabels(ParIterator & parit) const
+void Buffer::updateLabels(ParIterator & parit, bool out) const
 {
        LASSERT(parit.pit() == 0, /**/);
 
@@ -3720,7 +3729,7 @@ void Buffer::updateLabels(ParIterator & parit) const
                InsetList::const_iterator end = parit->insetList().end();
                for (; iit != end; ++iit) {
                        parit.pos() = iit->pos;
-                       iit->inset->updateLabels(parit);
+                       iit->inset->updateLabels(parit, out);
                }
        }
 }
@@ -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;
 }