#include "BufferView.h"
#include "ParagraphParameters.h"
#include "iterators.h"
+#include "lyxtextclasslist.h"
#include "mathed/formulamacro.h"
#include "mathed/formula.h"
Buffer::Buffer(string const & file, bool ronly)
+ : paragraph(0), lyx_clean(true), bak_clean(true),
+ unnamed(false), dep_clean(0), read_only(ronly),
+ filename(file), users(0)
{
lyxerr[Debug::INFO] << "Buffer::Buffer()" << endl;
- filename = file;
+// filename = file;
filepath = OnlyPath(file);
- paragraph = 0;
- lyx_clean = true;
- bak_clean = true;
- dep_clean = 0;
- read_only = ronly;
- unnamed = false;
- users = 0;
+// paragraph = 0;
+// lyx_clean = true;
+// bak_clean = true;
+// dep_clean = 0;
+// read_only = ronly;
+// unnamed = false;
+// users = 0;
lyxvc.buffer(this);
- if (read_only || (lyxrc.use_tempdir)) {
+ if (read_only || lyxrc.use_tempdir) {
tmppath = CreateBufferTmpDir();
- } else tmppath.erase();
+ } else {
+ tmppath.erase();
+ }
}
string contents;
bool active;
bool in_tabular;
+ LyXFont font;
};
std::stack<ErtComp> ert_stack;
} else {
// We are inserting into an existing document
users->text->breakParagraph(users);
- first_par = users->text->firstParagraph();
+ first_par = users->text->ownerParagraph();
pos = 0;
markDirty();
// We don't want to adopt the parameters from the
#ifndef NO_COMPABILITY
-void Buffer::insertErtContents(Paragraph * par, int & pos,
- LyXFont const & f, bool set_inactive)
+void Buffer::insertErtContents(Paragraph * par, int & pos, bool set_inactive)
{
if (!ert_comp.contents.empty()) {
lyxerr[Debug::INSETS] << "ERT contents:\n'"
<< ert_comp.contents << "'" << endl;
Inset * inset = new InsetERT(ert_comp.contents, true);
- LyXFont font;
- font.setLanguage(f.language());
- par->insertInset(pos++, inset, font);
+ par->insertInset(pos++, inset, ert_comp.font);
ert_comp.contents.erase();
}
if (set_inactive) {
#ifndef NO_COMPABILITY
ert_comp.in_tabular = false;
// Do the insetert.
- insertErtContents(par, pos, font);
+ insertErtContents(par, pos);
#endif
lex.eatLine();
string const layoutname = lex.getString();
+ //lyxerr << "Looking for layout '"
+ // << layoutname << "'!" << endl;
+
pair<bool, layout_type> pp
= textclasslist.NumberOfLayout(params.textclass, layoutname);
+ //lyxerr << "Result: " << pp.first << "/" << pp.second << endl;
+
#ifndef NO_COMPABILITY
if (compare_no_case(layoutname, "latex") == 0) {
ert_comp.active = true;
+ ert_comp.font = font;
}
#endif
#ifdef USE_CAPTION
} else {
// layout not found
// use default layout "Standard" (0)
+ //lyxerr << "Layout '" << layoutname
+ // << "' was not found!" << endl;
+
par->layout = 0;
++unknown_layouts;
string const s = _("Layout had to be changed from\n")
#ifndef NO_COMPABILITY
} else if (token == "\\begin_float") {
- insertErtContents(par, pos, font);
- //insertErtContents(par, pos, font, false);
+ insertErtContents(par, pos);
+ //insertErtContents(par, pos, false);
//ert_stack.push(ert_comp);
//ert_comp = ErtComp();
inset->read(this, nylex);
par->insertInset(pos, inset, font);
++pos;
- insertErtContents(par, pos, font);
+ insertErtContents(par, pos);
#endif
} else if (token == "\\begin_deeper") {
++depth;
par->params().startOfAppendix(true);
} else if (token == "\\paragraph_separation") {
int tmpret = lex.findToken(string_paragraph_separation);
- if (tmpret == -1) ++tmpret;
+ if (tmpret == -1)
+ ++tmpret;
if (tmpret != LYX_LAYOUT_DEFAULT)
params.paragraph_separation =
static_cast<BufferParams::PARSEP>(tmpret);
} else if (token == "\\defskip") {
lex.nextToken();
params.defskip = VSpace(lex.getString());
+#ifndef NO_COMPABILITY
} else if (token == "\\epsfig") { // obsolete
// Indeed it is obsolete, but we HAVE to be backwards
// compatible until 0.14, because otherwise all figures
// in existing documents are irretrivably lost. (Asger)
params.readGraphicsDriver(lex);
+#endif
} else if (token == "\\quotes_language") {
int tmpret = lex.findToken(string_quotes_language);
- if (tmpret == -1) ++tmpret;
+ if (tmpret == -1)
+ ++tmpret;
if (tmpret != LYX_LAYOUT_DEFAULT) {
InsetQuotes::quote_language tmpl =
InsetQuotes::EnglishQ;
params.use_numerical_citations = lex.getInteger();
} else if (token == "\\paperorientation") {
int tmpret = lex.findToken(string_orientation);
- if (tmpret == -1) ++tmpret;
+ if (tmpret == -1)
+ ++tmpret;
if (tmpret != LYX_LAYOUT_DEFAULT)
params.orientation = static_cast<BufferParams::PAPER_ORIENTATION>(tmpret);
} else if (token == "\\paperwidth") {
string const tok = lex.getString();
if (tok == "no_latex") {
// Do the insetert.
- insertErtContents(par, pos, font);
+ insertErtContents(par, pos);
} else if (tok == "latex") {
ert_comp.active = true;
+ ert_comp.font = font;
} else if (tok == "default") {
// Do the insetert.
- insertErtContents(par, pos, font);
+ insertErtContents(par, pos);
} else {
lex.printError("Unknown LaTeX font flag "
"`$$Token'");
// the inset isn't it? Lgb.
} else if (token == "\\begin_inset") {
#ifndef NO_COMPABILITY
- insertErtContents(par, pos, font, false);
+ insertErtContents(par, pos, false);
ert_stack.push(ert_comp);
ert_comp = ErtComp();
#endif
#ifndef NO_COMPABILITY
ert_comp = ert_stack.top();
ert_stack.pop();
- insertErtContents(par, pos, font);
+ insertErtContents(par, pos);
#endif
} else if (token == "\\SpecialChar") {
LyXLayout const & layout =
// Since we cannot know it this is only a regular
// newline or a tabular cell delimter we have to
// handle the ERT here.
- insertErtContents(par, pos, font, false);
+ insertErtContents(par, pos, false);
par->insertChar(pos, Paragraph::META_NEWLINE, font);
++pos;
#ifndef NO_COMPABILITY
// If we still have some ert active here we have to insert
// it so we don't loose it. (Lgb)
- insertErtContents(par, pos, font);
+ insertErtContents(par, pos);
#endif
the_end_read = true;
#ifndef NO_COMPABILITY
{
Inset const * inset = par->getInset(i);
if (inset) {
- if (linelen > 0)
+ if (linelen > 0) {
buffer << word.str();
+ word.str("");
+ }
if (inset->ascii(this, buffer, linelen)) {
// to be sure it breaks paragraph
currlinelen += linelen;
ofs << "\n";
}
+
bool use_babel;
+
void Buffer::makeLaTeXFile(string const & fname,
string const & original_path,
bool nice, bool only_body)
texrow.newline();
}
- if (features.isRequired("amsstyle")
- && !tclass.provides(LyXTextClass::amsmath)) {
- ofs << "\\usepackage{amsmath}\n";
- texrow.newline();
- }
-
if (tokenPos(tclass.opt_pagestyle(),
'|', params.pagestyle) >= 0) {
if (params.pagestyle == "fancy") {
// LaTeX all paragraphs from par to endpar, if endpar == 0 then to the end
//
void Buffer::latexParagraphs(ostream & ofs, Paragraph * par,
- Paragraph * endpar, TexRow & texrow) const
+ Paragraph * endpar, TexRow & texrow) const
{
bool was_title = false;
bool already_title = false;
// if only_body
while (par != endpar) {
- LyXLayout const & layout =
- textclasslist.Style(params.textclass,
- par->layout);
+ Inset * in = par->inInset();
+ // well we have to check if we are in an inset with unlimited
+ // lenght (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
+ // any environment other then "Standard" to be valid!
+ if ((in == 0) || !in->forceDefaultParagraphs(in)) {
+ LyXLayout const & layout =
+ textclasslist.Style(params.textclass, par->layout);
if (layout.intitle) {
- if (already_title) {
- lyxerr <<"Error in latexParagraphs: You"
- " should not mix title layouts"
- " with normal ones." << endl;
- } else
- was_title = true;
+ if (already_title) {
+ lyxerr <<"Error in latexParagraphs: You"
+ " should not mix title layouts"
+ " with normal ones." << endl;
+ } else
+ was_title = true;
} else if (was_title && !already_title) {
- ofs << "\\maketitle\n";
- texrow.newline();
- already_title = true;
- was_title = false;
- }
-
- if (layout.isEnvironment()) {
- par = par->TeXEnvironment(this, params, ofs, texrow);
+ ofs << "\\maketitle\n";
+ texrow.newline();
+ already_title = true;
+ was_title = false;
+ }
+
+ if (layout.isEnvironment()) {
+ par = par->TeXEnvironment(this, params, ofs, texrow);
+ } else {
+ par = par->TeXOnePar(this, params, ofs, texrow, false);
+ }
} else {
par = par->TeXOnePar(this, params, ofs, texrow, false);
}
// AMS Style is at document level
if (params.use_amsmath || tclass.provides(LyXTextClass::amsmath))
- features.require("amsstyle");
+ features.require("amsmath");
while (par) {
// We don't use "lyxerr.debug" because of speed. (Asger)