#include "lyxlex.h"
#include "factory.h"
#include "Lsstream.h"
+
#include "support/lstrings.h"
+
#include "insets/insetoptarg.h"
#include "insets/insetcommandparams.h"
#include "insets/insetbibitem.h"
#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;
InsetList::const_iterator it = par.insetlist.begin();
InsetList::const_iterator end = par.insetlist.end();
for (; it != end; ++it) {
- Inset * ins = it->inset;
- if (ins->lyxCode() == Inset::OPTARG_CODE) {
+ InsetOld * ins = it->inset;
+ if (ins->lyxCode() == InsetOld::OPTARG_CODE) {
return static_cast<InsetOptArg *>(ins);
}
}
<< "'" << endl;
BufferParams const & bparams = buf->params;
- Inset const * in = pit->inInset();
+ InsetOld const * in = pit->inInset();
bool further_blank_line = false;
LyXLayout_ptr style;
// if only_body
while (par != endpar) {
- Inset * in = par->inInset();
+ InsetOld * in = par->inInset();
// well we have to check if we are in an inset with unlimited
// length (all in one row) if that is true then we don't allow
// any special options in the paragraph and also we don't allow
layoutname = tclass.defaultLayoutName();
}
-#ifdef USE_CAPTION
- // The is the compability reading of layout caption.
- if (compare_ascii_no_case(layoutname, "caption") == 0) {
- // We expect that the par we are now working on is
- // really inside a InsetText inside a InsetFloat.
- // We also know that captions can only be
- // one paragraph. (Lgb)
-
- // We should now read until the next "\layout"
- // is reached.
- // This is probably not good enough, what if the
- // caption is the last par in the document (Lgb)
- istream & ist = lex.getStream();
- stringstream ss;
- string line;
- int begin = 0;
- while (true) {
- getline(ist, line);
- if (prefixIs(line, "\\layout")) {
- lex.pushToken(line);
- break;
- }
- if (prefixIs(line, "\\begin_inset"))
- ++begin;
- if (prefixIs(line, "\\end_inset")) {
- if (begin)
- --begin;
- else {
- lex.pushToken(line);
- break;
- }
- }
-
- ss << line << '\n';
- }
-
- // Now we should have the whole layout in ss
- // we should now be able to give this to the
- // caption inset.
- ss << "\\end_inset\n";
-
- // This seems like a bug in stringstream.
- // We really should be able to use ss
- // directly. (Lgb)
- istringstream is(ss.str());
- LyXLex tmplex(0, 0);
- tmplex.setStream(is);
- Inset * inset = new InsetCaption;
- inset->Read(this, tmplex);
- par.insertInset(pos, inset, font);
- ++pos;
- } else {
-#endif
- par.layout(bp.getLyXTextClass()[layoutname]);
+ par.layout(bp.getLyXTextClass()[layoutname]);
- // Test whether the layout is obsolete.
- LyXLayout_ptr const & layout = par.layout();
- if (!layout->obsoleted_by().empty())
- par.layout(bp.getLyXTextClass()[layout->obsoleted_by()]);
+ // Test whether the layout is obsolete.
+ LyXLayout_ptr const & layout = par.layout();
+ if (!layout->obsoleted_by().empty())
+ par.layout(bp.getLyXTextClass()[layout->obsoleted_by()]);
- par.params().read(lex);
-#if USE_CAPTION
- }
-#endif
+ par.params().read(lex);
+ } else if (token == "\\end_layout") {
+ lyxerr << "Solitary \\end_layout in line " << lex.getLineNo() << "\n"
+ << "Missing \\layout?.\n";
} else if (token == "\\end_inset") {
lyxerr << "Solitary \\end_inset in line " << lex.getLineNo() << "\n"
<< "Missing \\begin_inset?.\n";
- // Simply ignore this. The insets do not have
- // to read this.
- // But insets should read it, it is a part of
- // the inset isn't it? Lgb.
} else if (token == "\\begin_inset") {
- Inset * i = readInset(lex, buf);
- par.insertInset(par.size(), i, font, change);
+ InsetOld * inset = readInset(lex, buf);
+ par.insertInset(par.size(), inset, font, change);
} else if (token == "\\family") {
lex.next();
font.setLyXFamily(lex.getString());
}
}
} else {
- Inset * inset = 0;
+ InsetOld * inset = 0;
if (token == "\\SpecialChar" )
inset = new InsetSpecialChar;
else
par.insertInset(par.size(), inset, font, change);
}
} else if (token == "\\i") {
- Inset * inset = new InsetLatexAccent;
+ InsetOld * inset = new InsetLatexAccent;
inset->read(&buf, lex);
par.insertInset(par.size(), inset, font, change);
} else if (token == "\\backslash") {
par.insertChar(par.size(), '\\', font, change);
} else if (token == "\\newline") {
- Inset * inset = new InsetNewline;
+ InsetOld * inset = new InsetNewline;
inset->read(&buf, lex);
par.insertInset(par.size(), inset, font, change);
} else if (token == "\\LyXTable") {
- Inset * inset = new InsetTabular(buf);
+ InsetOld * inset = new InsetTabular(buf);
inset->read(&buf, lex);
par.insertInset(par.size(), inset, font, change);
} else if (token == "\\bibitem") {
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.error(ErrorItem(_("Unknown token"), s,
+ par.id(), 0, par.size()));
return 1;
}
return 0;
if (token.empty())
continue;
+ if (token == "\\end_layout") {
+ //Ok, paragraph finished
+ break;
+ }
+
lyxerr[Debug::PARSER] << "Handling paragraph token: `"
<< token << '\'' << endl;
-
- // reached the next paragraph. FIXME: really we should
- // change the file format to indicate the end of a par
- // clearly, but for now, this hack will do
if (token == "\\layout" || token == "\\the_end"
|| token == "\\end_inset" || token == "\\begin_deeper"
|| token == "\\end_deeper") {
lex.pushToken(token);
+ lyxerr << "Paragraph ended in line "
+ << lex.getLineNo() << "\n"
+ << "Missing \\end_layout.\n";
break;
}
}
return tmpfont;
}
-
-
-LyXFont const realizeFont(LyXFont const & font,
- BufferParams const & params)
-{
- LyXTextClass const & tclass = params.getLyXTextClass();
- LyXFont tmpfont(font);
- tmpfont.realize(tclass.defaultfont());
- return tmpfont;
-}