]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetText.cpp
Change inset label from ": filename" to "Program Listing: filename" for listings...
[lyx.git] / src / insets / InsetText.cpp
index 2a596c01388ab2f5b62a8f3b77aed8287a9a5a64..8231d2cb385755cf349406d95dc4413125cfe609 100644 (file)
@@ -52,7 +52,7 @@
 #include "support/lstrings.h"
 
 #include <boost/bind.hpp>
-#include <boost/assert.hpp>
+#include "support/lassert.h"
 
 using namespace std;
 using namespace lyx::support;
@@ -91,7 +91,7 @@ InsetText::InsetText()
 
 void InsetText::initParagraphs(Buffer const & buf)
 {
-       BOOST_ASSERT(paragraphs().empty());
+       LASSERT(paragraphs().empty(), /**/);
        buffer_ = const_cast<Buffer *>(&buf);
        paragraphs().push_back(Paragraph());
        Paragraph & ourpar = paragraphs().back();
@@ -109,7 +109,7 @@ void InsetText::setParagraphOwner()
 void InsetText::clear()
 {
        ParagraphList & pars = paragraphs();
-       BOOST_ASSERT(!pars.empty());
+       LASSERT(!pars.empty(), /**/);
 
        // This is a gross hack...
        Layout const & old_layout = pars.begin()->layout();
@@ -147,12 +147,11 @@ void InsetText::read(Lexer & lex)
        Paragraph oldpar = *paragraphs().begin();
        paragraphs().clear();
        ErrorList errorList;
+       lex.setContext("InsetText::read");
        bool res = text_.read(buffer(), lex, errorList, this);
 
-       if (!res) {
-               lex.printError("Missing \\end_inset at this point. "
-                                          "Read: `$$Token'");
-       }
+       if (!res)
+               lex.printError("Missing \\end_inset at this point. ");
 
        // sanity check
        // ensure we have at least one paragraph.
@@ -424,7 +423,7 @@ ParagraphList & InsetText::paragraphs()
 }
 
 
-//void InsetInclude::addToToc(ParConstIterator const & cpit) const
+//void InsetInclude::addToToc(DocIterator const & cpit)
 //{
 //}
 
@@ -433,8 +432,15 @@ void InsetText::updateLabels(ParIterator const & it)
 {
        ParIterator it2 = it;
        it2.forwardPos();
-       BOOST_ASSERT(&it2.inset() == this && it2.pit() == 0);
-       lyx::updateLabels(buffer(), it2);
+       LASSERT(&it2.inset() == this && it2.pit() == 0, /**/);
+       if (producesOutput())
+               lyx::updateLabels(buffer(), it2);
+       else {
+               DocumentClass const & tclass = buffer().params().documentClass();
+               Counters const savecnt = tclass.counters();
+               lyx::updateLabels(buffer(), it2);
+               tclass.counters() = savecnt;
+       }
 }
 
 
@@ -446,9 +452,9 @@ bool InsetText::notifyCursorLeaves(Cursor const & old, Cursor & cur)
        // find text inset in old cursor
        Cursor insetCur = old;
        int scriptSlice = insetCur.find(this);
-       BOOST_ASSERT(scriptSlice != -1);
+       LASSERT(scriptSlice != -1, /**/);
        insetCur.cutOff(scriptSlice);
-       BOOST_ASSERT(&insetCur.inset() == this);
+       LASSERT(&insetCur.inset() == this, /**/);
        
        // update the old paragraph's words
        insetCur.paragraph().updateWords(insetCur.top());