]> git.lyx.org Git - lyx.git/blobdiff - src/paragraph_funcs.C
last Friday's text*.C -> text_func shuffle
[lyx.git] / src / paragraph_funcs.C
index 3b0201e0c3861a528b3e5a67783d781c9927c931..8c137d68688e3a76e9d89f2847cd0cd5374b1f8b 100644 (file)
 #include "insets/insetlatexaccent.h"
 #include "insets/insettabular.h"
 #include "insets/insethfill.h"
-#include "insets/inseterror.h"
 #include "insets/insetnewline.h"
 
 extern string bibitemWidest(Buffer const *);
 
+using namespace lyx::support;
+
 using lyx::pos_type;
 //using lyx::layout_type;
 using std::endl;
@@ -71,7 +72,7 @@ void breakParagraph(BufferParams const & bparams,
                tmp->setLabelWidthString(par->params().labelWidthString());
        }
 
-       bool const isempty = (par->layout()->keepempty && par->empty());
+       bool const isempty = (par->allowEmpty() && par->empty());
 
        if (!isempty && (par->size() > pos || par->empty() || flag == 2)) {
                tmp->layout(par->layout());
@@ -379,7 +380,7 @@ TeXEnvironment(Buffer const * buf,
        do {
                par = TeXOnePar(buf, paragraphs, par, os, texrow, runparams);
 
-               if (par != const_cast<ParagraphList&>(paragraphs).end()&& par->params().depth() > pit->params().depth()) {
+               if (par != const_cast<ParagraphList&>(paragraphs).end() && par->params().depth() > pit->params().depth()) {
                            if (par->layout()->isParagraph()) {
 
                            // Thinko!
@@ -425,10 +426,10 @@ TeXEnvironment(Buffer const * buf,
 InsetOptArg * optArgInset(Paragraph const & par)
 {
        // Find the entry.
-       InsetList::iterator it = par.insetlist.begin();
-       InsetList::iterator end = par.insetlist.end();
+       InsetList::const_iterator it = par.insetlist.begin();
+       InsetList::const_iterator end = par.insetlist.end();
        for (; it != end; ++it) {
-               Inset * ins = it.getInset();
+               Inset * ins = it->inset;
                if (ins->lyxCode() == Inset::OPTARG_CODE) {
                        return static_cast<InsetOptArg *>(ins);
                }
@@ -610,13 +611,17 @@ TeXOnePar(Buffer const * buf,
                        texrow.newline();
                }
                break;
-       case LATEX_ENVIRONMENT:
+       case LATEX_ENVIRONMENT: {
                // if its the last paragraph of the current environment
                // skip it otherwise fall through
-               if (boost::next(pit) != const_cast<ParagraphList&>(paragraphs).end()
-                   && (boost::next(pit)->layout() != pit->layout()
-                       || boost::next(pit)->params().depth() != pit->params().depth()))
+               ParagraphList::iterator next = boost::next(pit);
+
+               if (next != const_cast<ParagraphList&>(paragraphs).end()
+                   && (next->layout() != pit->layout()
+                       || next->params().depth() != pit->params().depth()))
                        break;
+       }
+
                // fall through possible
        default:
                // we don't need it for the last paragraph!!!
@@ -933,10 +938,9 @@ int readParToken(Buffer & buf, Paragraph & par, LyXLex & lex, string const & tok
                lex.next();
                font.setLyXColor(lex.getString());
        } else if (token == "\\InsetSpace" || token == "\\SpecialChar") {
-               LyXLayout_ptr const & layout = par.layout();
 
                // Insets don't make sense in a free-spacing context! ---Kayvan
-               if (layout->free_spacing || par.isFreeSpacing()) {
+               if (par.isFreeSpacing()) {
                        if (token == "\\InsetSpace")
                                par.insertChar(par.size(), ' ', font, change);
                        else if (lex.isOK()) {
@@ -1004,9 +1008,9 @@ int readParToken(Buffer & buf, Paragraph & par, LyXLex & lex, string const & tok
                lex.eatLine();
                string const s = bformat(_("Unknown token: %1$s %2$s\n"),
                        token, lex.getString());
-               // we can do this here this way because we're actually reading
-               // the buffer and don't care about LyXText right now.
-               par.insertInset(par.size(), new InsetError(s), font);
+
+               buf.parseError(ErrorItem(_("Unknown token"), s,
+                                        par.id(), 0, par.size()));
                return 1;
        }
        return 0;