* LyX, The Document Processor
*
* Copyright 1995 Matthias Ettrich
- * Copyright 1995-1999 The LyX Team.
+ * Copyright 1995-2000 The LyX Team.
*
* This file is Copyright 1996-1999
* Lars Gullik Bjønnes
#include <fstream>
#include <iomanip>
-using std::ofstream;
-using std::ifstream;
-using std::fstream;
-using std::ios;
-using std::setw;
-
#include <cstdlib>
#include <unistd.h>
#include "insets/insetspecialchar.h"
#include "insets/figinset.h"
#include "insets/insettext.h"
+//#include "insets/insetnumber.h"
#include "insets/insetert.h"
#include "insets/insetgraphics.h"
+#include "insets/insetfoot.h"
#include "support/filetools.h"
#include "support/path.h"
#include "LaTeX.h"
#include "support/FileInfo.h"
#include "lyxtext.h"
#include "gettext.h"
+#include "language.h"
+
+using std::ostream;
+using std::ofstream;
+using std::ifstream;
+using std::fstream;
+using std::ios;
+using std::setw;
+using std::endl;
+using std::pair;
// Uncomment this line to enable a workaround for the weird behaviour
// of the cursor between a displayed inset and last character
extern LyXAction lyxaction;
-static const float LYX_FORMAT = 2.15;
+static const float LYX_FORMAT = 2.16;
extern int tex_code_break_column;
extern void FreeUpdateTimer();
-Buffer::Buffer(string const & file, LyXRC * lyxrc, bool ronly)
+Buffer::Buffer(string const & file, bool ronly)
{
lyxerr[Debug::INFO] << "Buffer::Buffer()" << endl;
filename = file;
read_only = ronly;
users = 0;
lyxvc.buffer(this);
- if (read_only || (lyxrc && lyxrc->use_tempdir)) {
+ if (read_only || (lyxrc.use_tempdir)) {
tmppath = CreateBufferTmpDir();
} else tmppath.clear();
}
}
+string Buffer::getLatexName(bool no_path /* = true */) const
+{
+ return ChangeExtension(MakeLatexName(filename),
+ ".tex", no_path);
+}
+
+
+void Buffer::setReadonly(bool flag /* = true */)
+{
+ if (read_only != flag) {
+ read_only = flag;
+ updateTitles();
+ updateAllVisibleBufferRelatedPopups();
+ }
+ if (read_only) {
+ WarnReadonly(filename);
+ }
+}
+
+
bool Buffer::saveParamsAsDefaults()
{
string fname = AddName(AddPath(user_lyxdir, "templates/"),
bool the_end_read = false;
LyXParagraph * return_par = 0;
- LyXFont font(LyXFont::ALL_INHERIT);
+ LyXFont font(LyXFont::ALL_INHERIT,params.language_info);
+ if (format < 2.16 && params.language == "hebrew")
+ font.setLanguage(default_language);
// If we are inserting, we cheat and get a token in advance
bool has_token = false;
inset = new InsetLatexAccent;
inset->Read(lex);
par->InsertChar(pos, LyXParagraph::META_INSET);
-
par->InsertInset(pos, inset);
par->SetFont(pos, font);
++pos;
if (!return_par)
return_par = par;
else {
- par->text.resize(par->text.size());
+ par->fitToSize();
par = new LyXParagraph(par);
}
pos = 0;
par->footnoteflag = footnoteflag;
par->footnotekind = footnotekind;
par->depth = depth;
- font = LyXFont(LyXFont::ALL_INHERIT);
+ font = LyXFont(LyXFont::ALL_INHERIT,params.language_info);
+ if (format < 2.16 && params.language == "hebrew")
+ font.setLanguage(default_language);
} else if (token == "\\end_float") {
if (!return_par)
return_par = par;
else {
- par->text.resize(par->text.size());
+ par->fitToSize();
par = new LyXParagraph(par);
}
footnotekind = LyXParagraph::FOOTNOTE;
pos = 0;
lex.EatLine();
par->layout = LYX_DUMMY_LAYOUT;
- font = LyXFont(LyXFont::ALL_INHERIT);
+ font = LyXFont(LyXFont::ALL_INHERIT,params.language_info);
+ if (format < 2.16 && params.language == "hebrew")
+ font.setLanguage(default_language);
} else if (token == "\\begin_float") {
tmpret = lex.FindToken(string_footnotekinds);
if (tmpret == -1) ++tmpret;
} else if (token == "\\defskip") {
lex.nextToken();
params.defskip = VSpace(lex.GetString());
+#if 0
} else if (token == "\\no_isolatin1") { // obsolete
lex.nextToken();
} else if (token == "\\no_babel") { // obsolete
lex.nextToken();
} else if (token == "\\no_epsfig") { // obsolete
lex.nextToken();
+#endif
} else if (token == "\\epsfig") { // obsolete
// Indeed it is obsolete, but we HAVE to be backwards
// compatible until 0.14, because otherwise all figures
else
lex.printError("Unknown LaTeX font flag "
"`$$Token'");
- } else if (token == "\\direction") {
+ } else if (token == "\\lang") {
+ lex.next();
+ string tok = lex.GetString();
+ Languages::iterator lit = languages.find(tok);
+ if (lit != languages.end()) {
+ font.setLanguage(&(*lit).second);
+ } else {
+ font.setLanguage(params.language_info);
+ lex.printError("Unknown language `$$Token'");
+ }
+ } else if (token == "\\direction") { // obsolete
+ if (format >= 2.16)
+ lex.printError("Command \\direction is obsolete");
lex.next();
string tok = lex.GetString();
- if (tok == "ltr")
- font.setDirection(LyXFont::LTR_DIR);
- else if (tok == "rtl")
- font.setDirection(LyXFont::RTL_DIR);
+ if (tok == "rtl")
+ font.setLanguage(&languages["hebrew"]);
else if (tok == "default")
- font.setDirection(LyXFont::INHERIT_DIR);
+ if (params.language == "hebrew")
+ font.setLanguage(default_language);
+ else
+ font.setLanguage(params.language_info);
else
- lex.printError("Unknown font flag "
- "`$$Token'");
+ lex.printError("Unknown direction `$$Token'");
} else if (token == "\\emph") {
lex.next();
font.setEmph(font.setLyXMisc(lex.GetString()));
}
} else if (token == "\\added_space_top") {
lex.nextToken();
- par->added_space_top = lex.GetString();
+ par->added_space_top = VSpace(lex.GetString());
} else if (token == "\\added_space_bottom") {
lex.nextToken();
- par->added_space_bottom = lex.GetString();
+ par->added_space_bottom = VSpace(lex.GetString());
} else if (token == "\\pextra_type") {
lex.nextToken();
par->pextra_type = lex.GetInteger();
par->InsertInset(pos, inset);
par->SetFont(pos, font);
++pos;
+#if 0
+ } else if (tmptok == "Number") {
+ inset = new InsetNumber(this);
+ inset->Read(lex);
+ par->InsertChar(pos, LyXParagraph::META_INSET);
+ par->InsertInset(pos, inset);
+ par->SetFont(pos, font);
+ ++pos;
+#endif
+ } else if (tmptok == "Foot") {
+ inset = new InsetFoot(this);
+ inset->Read(lex);
+ par->InsertChar(pos, LyXParagraph::META_INSET);
+ par->InsertInset(pos, inset);
+ par->SetFont(pos, font);
+ ++pos;
} else if (tmptok == "GRAPHICS") {
inset = new InsetGraphics;
//inset->Read(lex);
if (!inscmd.getOptions().empty() || !inscmd.getContents().empty()) {
inset = new InsetRef(inscmd, this);
}
-#warning Verify that this else clause is still needed. (Lgb)
+#warning Check if this else clause is still needed. (Lgb)
#if 0
// This condition comes from a
// temporary solution to the latexdel
par->SetFont(pos, font);
++pos;
} else if (token == "\\SpecialChar") {
- inset = new InsetSpecialChar;
- inset->Read(lex);
- par->InsertChar(pos, LyXParagraph::META_INSET);
- par->InsertInset(pos, inset);
- par->SetFont(pos, font);
+ LyXLayout const & layout =
+ textclasslist.Style(params.textclass,
+ par->GetLayout());
+
+ // Insets don't make sense in a free-spacing context! ---Kayvan
+ if (layout.free_spacing)
+ {
+ if (lex.IsOK()) {
+ string next_token;
+ lex.next();
+ next_token = lex.GetString();
+ if (next_token == "\\-") {
+ par->InsertChar(pos, '-');
+ par->SetFont(pos, font);
+ } else if (next_token == "\\protected_separator") {
+ par->InsertChar(pos, ' ');
+ par->SetFont(pos, font);
+ } else {
+ lex.printError("Token `$$Token' "
+ "is in free space "
+ "paragraph layout!");
+ pos--;
+ }
+ }
+ }
+ else
+ {
+ inset = new InsetSpecialChar;
+ inset->Read(lex);
+ par->InsertChar(pos, LyXParagraph::META_INSET);
+ par->InsertInset(pos, inset);
+ par->SetFont(pos, font);
+ }
++pos;
} else if (token == "\\Figure") {
inset = new InsetFig(100, 100, this);
++pos;
} else if (token == "\\protected_separator") { // obsolete
#if 1
- inset = new InsetSpecialChar(InsetSpecialChar::PROTECTED_SEPARATOR);
- par->InsertChar(pos, LyXParagraph::META_INSET);
- par->InsertInset(pos, inset);
- par->SetFont(pos, font);
+ LyXLayout const & layout =
+ textclasslist.Style(params.textclass,
+ par->GetLayout());
+
+ if (layout.free_spacing) {
+ par->InsertChar(pos, ' ');
+ par->SetFont(pos, font);
+ } else {
+ inset = new InsetSpecialChar(InsetSpecialChar::PROTECTED_SEPARATOR);
+ par->InsertChar(pos, LyXParagraph::META_INSET);
+ par->InsertInset(pos, inset);
+ par->SetFont(pos, font);
+ }
#else
par->InsertChar(pos, LyXParagraph::META_PROTECTED_SEPARATOR);
par->SetFont(pos, font);
// Should probably be moved to somewhere else: BufferView? LyXView?
-bool Buffer::save(bool makeBackup) const
+bool Buffer::save() const
{
// We don't need autosaves in the immediate future. (Asger)
resetAutosaveTimers();
// make a backup
- if (makeBackup) {
- string s = fileName() + '~';
+ string s;
+ if (lyxrc.make_backup) {
+ s = fileName() + '~';
+ if (!lyxrc.backupdir_path.empty())
+ s = AddName(lyxrc.backupdir_path,
+ subst(CleanupPath(s),'/','!'));
+
// Rename is the wrong way of making a backup,
// this is the correct way.
/* truss cp fil fil2:
FileInfo finfo(fileName());
if (finfo.exist()) {
mode_t fmode = finfo.getMode();
- struct utimbuf * times = new struct utimbuf;
+ struct utimbuf times = {
+ finfo.getAccessTime(),
+ finfo.getModificationTime() };
- times->actime = finfo.getAccessTime();
- times->modtime = finfo.getModificationTime();
ifstream ifs(fileName().c_str());
ofstream ofs(s.c_str(), ios::out|ios::trunc);
if (ifs && ofs) {
ofs.close();
::chmod(s.c_str(), fmode);
- if (::utime(s.c_str(), times)) {
+ if (::utime(s.c_str(), ×)) {
lyxerr << "utime error." << endl;
}
} else {
lyxerr << "LyX was not able to make "
"backupcopy. Beware." << endl;
}
- delete times;
}
}
}
} else {
// Saving failed, so backup is not backup
- if (makeBackup) {
- string s = fileName() + '~';
+ if (lyxrc.make_backup) {
::rename(s.c_str(), fileName().c_str());
}
return false;
noparbreak = 1;
}
+ LyXLayout const & layout =
+ textclasslist.Style(params.textclass,
+ par->GetLayout());
+ bool free_spc = layout.free_spacing;
+
/* It might be a table */
if (par->table){
#if 0
- if (!lyxrc->ascii_roff_command.empty() &&
- lyxrc->ascii_roff_command != "none") {
+ if (!lyxrc.ascii_roff_command.empty() &&
+ lyxrc.ascii_roff_command != "none") {
RoffAsciiTable(ofs, par);
par = par->next;
continue;
cells = par->table->columns;
clen = new int [cells];
memset(clen, 0, sizeof(int) * cells);
+
for (i = 0, j = 0, h = 1; i < par->size(); ++i, ++h) {
c = par->GetChar(i);
if (c == LyXParagraph::META_INSET) {
if ((inset = par->GetInset(i))) {
#if 1
#ifdef HAVE_SSTREAM
- ostringstream ost;
- inset->Latex(ost, -1);
+ std::ostringstream ost;
+ inset->Latex(ost, -1, free_spc);
h += ost.str().length();
#else
ostrstream ost;
- inset->Latex(ost, -1);
+ inset->Latex(ost, -1, free_spc);
ost << '\0';
char * tmp = ost.str();
string tstr(tmp);
WriteFSAlert(_("Error: Cannot open temporary file:"), fname1);
return;
}
- inset->Latex(fs, -1);
+ inset->Latex(fs, -1, free_spc);
h += fs.tellp() - 1;
::remove(fname1.c_str());
#endif
clen[j] = h;
}
- font1 = LyXFont(LyXFont::ALL_INHERIT);
+ font1 = LyXFont(LyXFont::ALL_INHERIT,params.language_info);
actcell = 0;
for (i = 0, actpos = 1; i < par->size(); ++i, ++actpos) {
if (!i && !footnoteflag && !noparbreak){
case LyXParagraph::META_INSET:
if ((inset = par->GetInset(i))) {
fpos = ofs.tellp();
- inset->Latex(ofs, -1);
+ inset->Latex(ofs, -1, free_spc);
currlinelen += (ofs.tellp() - fpos);
actpos += (ofs.tellp() - fpos) - 1;
}
}
-#ifdef USE_OSTREAM_ONLY
void Buffer::makeLaTeXFile(string const & fname,
string const & original_path,
bool nice, bool only_body)
niceFile = nice; // this will be used by Insetincludes.
- tex_code_break_column = lyxrc->ascii_linelen;
+ tex_code_break_column = lyxrc.ascii_linelen;
LyXTextClass const & tclass =
textclasslist.TextClass(params.textclass);
// validate the buffer.
lyxerr[Debug::LATEX] << " Validating buffer..." << endl;
- LaTeXFeatures features(tclass.numLayouts());
+ LaTeXFeatures features(params, tclass.numLayouts());
validate(features);
lyxerr[Debug::LATEX] << " Buffer validation done." << endl;
&& params.orientation == BufferParams::ORIENTATION_LANDSCAPE)
options += "landscape,";
- // language should be a parameter to \documentclass
- if (params.language != "default") {
- if (params.language == "hebrew")
- options += "english,";
- else if (lyxrc->rtl_support)
- options += "hebrew,";
- options += params.language + ',';
- } else if (lyxrc->rtl_support)
- options += "hebrew,english,";
+ // language should be a parameter to \documentclass
+ bool use_babel = false;
+ if (params.language != "default" ||
+ !features.UsedLanguages.empty() ) {
+ use_babel = true;
+ for (LaTeXFeatures::LanguageList::const_iterator cit =
+ features.UsedLanguages.begin();
+ cit != features.UsedLanguages.end(); ++cit) {
+ options += (*cit)->lang + ",";
+ }
+ if (default_language != params.language_info)
+ options += default_language ->lang + ',';
+ options += params.language_info->lang + ',';
+ }
// the user-defined options
if (!params.options.empty()) {
texrow.newline();
}
// this one is not per buffer
- if (lyxrc->fontenc != "default") {
- ofs << "\\usepackage[" << lyxrc->fontenc
+ if (lyxrc.fontenc != "default") {
+ ofs << "\\usepackage[" << lyxrc.fontenc
<< "]{fontenc}\n";
texrow.newline();
}
break;
default:
// default papersize ie BufferParams::VM_PAPER_DEFAULT
- switch (lyxrc->default_papersize) {
+ switch (lyxrc.default_papersize) {
case BufferParams::PAPER_DEFAULT: // keep compiler happy
case BufferParams::PAPER_USLETTER:
ofs << ",letterpaper";
// We try to load babel late, in case it interferes
// with other packages.
- if (params.language != "default" || lyxrc->rtl_support ) {
- ofs << "\\usepackage{babel}\n";
+ if (use_babel) {
+ ofs << lyxrc.language_package << endl;
texrow.newline();
}
string preamble, tmppreamble;
// The optional packages;
- preamble = features.getPackages(params);
+ preamble = features.getPackages();
// this might be useful...
preamble += "\n\\makeatletter\n\n";
// Some macros LyX will need
- tmppreamble = features.getMacros(params);
+ tmppreamble = features.getMacros();
if (!tmppreamble.empty()) {
preamble += "\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% "
}
// the text class specific preamble
- tmppreamble = features.getTClassPreamble(params);
+ tmppreamble = features.getTClassPreamble();
if (!tmppreamble.empty()) {
preamble += "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% "
"Textclass specific LaTeX commands.\n"
texrow.newline();
} // only_body
lyxerr.debug() << "preamble finished, now the body." << endl;
+ if (!lyxrc.language_auto_begin && params.language != "default") {
+ ofs << subst(lyxrc.language_command_begin, "$$lang",
+ params.language)
+ << endl;
+ texrow.newline();
+ }
bool was_title = false;
bool already_title = false;
#ifdef HAVE_SSTREAM
- ostringstream ftnote;
+ std::ostringstream ftnote;
#else
char * tmpholder = 0;
#endif
texrow.newline();
}
+ if (!lyxrc.language_auto_end && params.language != "default") {
+ ofs << subst(lyxrc.language_command_end, "$$lang",
+ params.language)
+ << endl;
+ texrow.newline();
+ }
+
if (!only_body) {
ofs << "\\end{document}\n";
texrow.newline();
// if we are in batchmode or not (within mathed_write()
// in math_write.C) so we must set it to a non-zero
// value when we leave otherwise we save incorrect .lyx files.
- tex_code_break_column = lyxrc->ascii_linelen;
+ tex_code_break_column = lyxrc.ascii_linelen;
ofs.close();
if (ofs.fail()) {
lyxerr.debug() << "Finished making latex file." << endl;
}
-#else
-void Buffer::makeLaTeXFile(string const & fname,
- string const & original_path,
- bool nice, bool only_body)
+
+
+bool Buffer::isLatex() const
{
- lyxerr[Debug::LATEX] << "makeLaTeXFile..." << endl;
-
- niceFile = nice; // this will be used by Insetincludes.
+ return textclasslist.TextClass(params.textclass).outputType() == LATEX;
+}
- tex_code_break_column = lyxrc->ascii_linelen;
- LyXTextClass const & tclass =
- textclasslist.TextClass(params.textclass);
+bool Buffer::isLinuxDoc() const
+{
+ return textclasslist.TextClass(params.textclass).outputType() == LINUXDOC;
+}
+
+
+bool Buffer::isLiterate() const
+{
+ return textclasslist.TextClass(params.textclass).outputType() == LITERATE;
+}
+
+
+bool Buffer::isDocBook() const
+{
+ return textclasslist.TextClass(params.textclass).outputType() == DOCBOOK;
+}
+
+
+bool Buffer::isSGML() const
+{
+ return textclasslist.TextClass(params.textclass).outputType() == LINUXDOC ||
+ textclasslist.TextClass(params.textclass).outputType() == DOCBOOK;
+}
+
+
+void Buffer::sgmlOpenTag(ostream & os, int depth,
+ string const & latexname) const
+{
+ os << string(depth, ' ') << "<" << latexname << ">\n";
+}
+
+
+void Buffer::sgmlCloseTag(ostream & os, int depth,
+ string const & latexname) const
+{
+ os << string(depth, ' ') << "</" << latexname << ">\n";
+}
+
+
+void Buffer::makeLinuxDocFile(string const & fname, int column)
+{
+ LyXParagraph * par = paragraph;
+
+ string top_element = textclasslist.LatexnameOfClass(params.textclass);
+ string environment_stack[10];
+ string item_name;
+
+ int depth = 0; /* paragraph depth */
ofstream ofs(fname.c_str());
+
if (!ofs) {
- WriteFSAlert(_("Error: Cannot open file: "), fname);
+ WriteAlert(_("LYX_ERROR:"), _("Cannot write file"), fname);
return;
}
-
- // validate the buffer.
- lyxerr[Debug::LATEX] << " Validating buffer..." << endl;
- LaTeXFeatures features(tclass.numLayouts());
- validate(features);
- lyxerr[Debug::LATEX] << " Buffer validation done." << endl;
-
+
+ tex_code_break_column = column;
texrow.reset();
- // The starting paragraph of the coming rows is the
- // first paragraph of the document. (Asger)
- texrow.start(paragraph, 0);
+
+ if (params.preamble.empty()) {
+ ofs << "<!doctype linuxdoc system>\n\n";
+ }
+ else {
+ ofs << "<!doctype linuxdoc system \n [ "
+ << params.preamble << " \n]>\n\n";
+ }
- string LFile;
-
- if (!only_body && nice) {
- LFile += "%% " LYX_DOCVERSION " created this file. "
- "For more info, see http://www.lyx.org/.\n";
- LFile += "%% Do not edit unless you really know what you are doing.\n";
- texrow.newline();
- texrow.newline();
+ ofs << "<!-- " << LYX_DOCVERSION
+ << " created this file. For more info see http://www.lyx.org/"
+ << " -->\n";
+
+ if(params.options.empty())
+ sgmlOpenTag(ofs, 0, top_element);
+ else {
+ string top = top_element;
+ top += " ";
+ top += params.options;
+ sgmlOpenTag(ofs, 0, top);
}
- lyxerr.debug() << "lyx header finished" << endl;
- // There are a few differences between nice LaTeX and usual files:
- // usual is \batchmode and has a
- // special input@path to allow the including of figures
- // with either \input or \includegraphics (what figinsets do).
- // batchmode is not set if there is a tex_code_break_column.
- // In this case somebody is interested in the generated LaTeX,
- // so this is OK. input@path is set when the actual parameter
- // original_path is set. This is done for usual tex-file, but not
- // for nice-latex-file. (Matthias 250696)
- if (!only_body) {
- if (!nice){
- // code for usual, NOT nice-latex-file
- LFile += "\\batchmode\n"; // changed
- // from \nonstopmode
- texrow.newline();
- }
- if (!original_path.empty()) {
- LFile += "\\makeatletter\n";
- texrow.newline();
- LFile += "\\def\\input@path{{" + original_path
- + "/}}\n";
- texrow.newline();
- LFile += "\\makeatother\n";
- texrow.newline();
- }
-
- LFile += "\\documentclass";
-
- string options; // the document class options.
-
- if (tokenPos(tclass.opt_fontsize(), '|', params.fontsize) >= 0) {
- // only write if existing in list (and not default)
- options += params.fontsize;
- options += "pt,";
- }
-
-
- if (!params.use_geometry &&
- (params.paperpackage == BufferParams::PACKAGE_NONE)) {
- switch (params.papersize) {
- case BufferParams::PAPER_A4PAPER:
- options += "a4paper,";
- break;
- case BufferParams::PAPER_USLETTER:
- options += "letterpaper,";
- break;
- case BufferParams::PAPER_A5PAPER:
- options += "a5paper,";
- break;
- case BufferParams::PAPER_B5PAPER:
- options += "b5paper,";
- break;
- case BufferParams::PAPER_EXECUTIVEPAPER:
- options += "executivepaper,";
- break;
- case BufferParams::PAPER_LEGALPAPER:
- options += "legalpaper,";
- break;
- }
- }
-
- // if needed
- if (params.sides != tclass.sides()) {
- switch (params.sides) {
- case LyXTextClass::OneSide:
- options += "oneside,";
- break;
- case LyXTextClass::TwoSides:
- options += "twoside,";
- break;
- }
-
- }
-
- // if needed
- if (params.columns != tclass.columns()) {
- if (params.columns == 2)
- options += "twocolumn,";
- else
- options += "onecolumn,";
- }
-
- if (!params.use_geometry
- && params.orientation == BufferParams::ORIENTATION_LANDSCAPE)
- options += "landscape,";
-
- // language should be a parameter to \documentclass
- if (params.language != "default") {
- if (params.language == "hebrew")
- options += "english,";
- else if (lyxrc->rtl_support)
- options += "hebrew,";
- options += params.language + ',';
- } else if (lyxrc->rtl_support)
- options += "hebrew,english,";
-
- // the user-defined options
- if (!params.options.empty()) {
- options += params.options + ',';
- }
-
- if (!options.empty()){
- options = strip(options, ',');
- LFile += '[';
- LFile += options;
- LFile += ']';
- }
-
- LFile += '{';
- LFile += textclasslist.LatexnameOfClass(params.textclass);
- LFile += "}\n";
- texrow.newline();
- // end of \documentclass defs
-
- // font selection must be done before loading fontenc.sty
- if (params.fonts != "default") {
- LFile += "\\usepackage{" + params.fonts + "}\n";
- texrow.newline();
- }
- // this one is not per buffer
- if (lyxrc->fontenc != "default") {
- LFile += "\\usepackage[" + lyxrc->fontenc
- + "]{fontenc}\n";
- texrow.newline();
- }
- if (params.inputenc != "default") {
- LFile += "\\usepackage[" + params.inputenc
- + "]{inputenc}\n";
- texrow.newline();
- }
-
- /* at the very beginning the text parameters */
- if (params.paperpackage != BufferParams::PACKAGE_NONE) {
- switch (params.paperpackage) {
- case BufferParams::PACKAGE_A4:
- LFile += "\\usepackage{a4}\n";
- texrow.newline();
- break;
- case BufferParams::PACKAGE_A4WIDE:
- LFile += "\\usepackage{a4wide}\n";
- texrow.newline();
- break;
- case BufferParams::PACKAGE_WIDEMARGINSA4:
- LFile += "\\usepackage[widemargins]{a4}\n";
- texrow.newline();
- break;
- }
- }
- if (params.use_geometry) {
- LFile += "\\usepackage{geometry}\n";
- texrow.newline();
- LFile += "\\geometry{verbose";
- if (params.orientation == BufferParams::ORIENTATION_LANDSCAPE)
- LFile += ",landscape";
- switch (params.papersize2) {
- case BufferParams::VM_PAPER_CUSTOM:
- if (!params.paperwidth.empty())
- LFile += ",paperwidth="
- + params.paperwidth;
- if (!params.paperheight.empty())
- LFile += ",paperheight="
- + params.paperheight;
- break;
- case BufferParams::VM_PAPER_USLETTER:
- LFile += ",letterpaper";
- break;
- case BufferParams::VM_PAPER_USLEGAL:
- LFile += ",legalpaper";
- break;
- case BufferParams::VM_PAPER_USEXECUTIVE:
- LFile += ",executivepaper";
- break;
- case BufferParams::VM_PAPER_A3:
- LFile += ",a3paper";
- break;
- case BufferParams::VM_PAPER_A4:
- LFile += ",a4paper";
- break;
- case BufferParams::VM_PAPER_A5:
- LFile += ",a5paper";
- break;
- case BufferParams::VM_PAPER_B3:
- LFile += ",b3paper";
- break;
- case BufferParams::VM_PAPER_B4:
- LFile += ",b4paper";
- break;
- case BufferParams::VM_PAPER_B5:
- LFile += ",b5paper";
- break;
- default:
- // default papersize ie BufferParams::VM_PAPER_DEFAULT
- switch (lyxrc->default_papersize) {
- case BufferParams::PAPER_DEFAULT: // keep compiler happy
- case BufferParams::PAPER_USLETTER:
- LFile += ",letterpaper";
- break;
- case BufferParams::PAPER_LEGALPAPER:
- LFile += ",legalpaper";
- break;
- case BufferParams::PAPER_EXECUTIVEPAPER:
- LFile += ",executivepaper";
- break;
- case BufferParams::PAPER_A3PAPER:
- LFile += ",a3paper";
- break;
- case BufferParams::PAPER_A4PAPER:
- LFile += ",a4paper";
- break;
- case BufferParams::PAPER_A5PAPER:
- LFile += ",a5paper";
- break;
- case BufferParams::PAPER_B5PAPER:
- LFile += ",b5paper";
- break;
- }
- }
- if (!params.topmargin.empty())
- LFile += ",tmargin=" + params.topmargin;
- if (!params.bottommargin.empty())
- LFile += ",bmargin=" + params.bottommargin;
- if (!params.leftmargin.empty())
- LFile += ",lmargin=" + params.leftmargin;
- if (!params.rightmargin.empty())
- LFile += ",rmargin=" + params.rightmargin;
- if (!params.headheight.empty())
- LFile += ",headheight=" + params.headheight;
- if (!params.headsep.empty())
- LFile += ",headsep=" + params.headsep;
- if (!params.footskip.empty())
- LFile += ",footskip=" + params.footskip;
- LFile += "}\n";
- texrow.newline();
- }
- if (params.use_amsmath
- && !prefixIs(textclasslist.LatexnameOfClass(params.textclass), "ams")) {
- LFile += "\\usepackage{amsmath}\n";
- }
-
- if (tokenPos(tclass.opt_pagestyle(), '|', params.pagestyle) >= 0) {
- if (params.pagestyle == "fancy") {
- LFile += "\\usepackage{fancyhdr}\n";
- texrow.newline();
- }
- LFile += "\\pagestyle{" + params.pagestyle + "}\n";
- texrow.newline();
- }
-
- // We try to load babel late, in case it interferes
- // with other packages.
- if (params.language != "default" || lyxrc->rtl_support ) {
- LFile += "\\usepackage{babel}\n";
- texrow.newline();
- }
-
- if (params.secnumdepth != tclass.secnumdepth()) {
- LFile += "\\setcounter{secnumdepth}{";
- LFile += tostr(params.secnumdepth);
- LFile += "}\n";
- texrow.newline();
- }
- if (params.tocdepth != tclass.tocdepth()) {
- LFile += "\\setcounter{tocdepth}{";
- LFile += tostr(params.tocdepth);
- LFile += "}\n";
- texrow.newline();
- }
-
- if (params.paragraph_separation) {
- switch (params.defskip.kind()) {
- case VSpace::SMALLSKIP:
- LFile += "\\setlength\\parskip{\\smallskipamount}\n";
- break;
- case VSpace::MEDSKIP:
- LFile += "\\setlength\\parskip{\\medskipamount}\n";
- break;
- case VSpace::BIGSKIP:
- LFile += "\\setlength\\parskip{\\bigskipamount}\n";
- break;
- case VSpace::LENGTH:
- LFile += "\\setlength\\parskip{"
- + params.defskip.length().asLatexString()
- + "}\n";
- break;
- default: // should never happen // Then delete it.
- LFile += "\\setlength\\parskip{\\medskipamount}\n";
- break;
- }
- texrow.newline();
-
- LFile += "\\setlength\\parindent{0pt}\n";
- texrow.newline();
- }
-
- // Write out what we've generated so far...and reset LFile
- ofs << LFile;
- LFile.clear();
-
- // Now insert the LyX specific LaTeX commands...
- string preamble, tmppreamble;
-
- // The optional packages;
- preamble = features.getPackages(params);
-
- // this might be useful...
- preamble += "\n\\makeatletter\n\n";
-
- // Some macros LyX will need
- tmppreamble = features.getMacros(params);
-
- if (!tmppreamble.empty()) {
- preamble += "\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% "
- "LyX specific LaTeX commands.\n"
- + tmppreamble + '\n';
- }
-
- // the text class specific preamble
- tmppreamble = features.getTClassPreamble(params);
- if (!tmppreamble.empty()) {
- preamble += "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% "
- "Textclass specific LaTeX commands.\n"
- + tmppreamble + '\n';
- }
-
- /* the user-defined preamble */
- if (!params.preamble.empty()) {
- preamble += "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% "
- "User specified LaTeX commands.\n"
- + params.preamble + '\n';
- }
-
- preamble += "\\makeatother\n\n";
-
- // Itemize bullet settings need to be last in case the user
- // defines their own bullets that use a package included
- // in the user-defined preamble -- ARRae
- // Actually it has to be done much later than that
- // since some packages like frenchb make modifications
- // at \begin{document} time -- JMarc
- string bullets_def;
- for (int i = 0; i < 4; ++i) {
- if (params.user_defined_bullets[i] != ITEMIZE_DEFAULTS[i]) {
- if (bullets_def.empty())
- bullets_def="\\AtBeginDocument{\n";
- bullets_def += " \\renewcommand{\\labelitemi";
- switch (i) {
- // `i' is one less than the item to modify
- case 0:
- break;
- case 1:
- bullets_def += 'i';
- break;
- case 2:
- bullets_def += "ii";
- break;
- case 3:
- bullets_def += 'v';
- break;
- }
- bullets_def += "}{" +
- params.user_defined_bullets[i].getText()
- + "}\n";
- }
- }
-
- if (!bullets_def.empty())
- preamble += bullets_def + "}\n\n";
-
- for (int j = countChar(preamble, '\n'); j-- ;) {
- texrow.newline();
- }
-
- ofs << preamble;
-
- // make the body.
- LFile += "\\begin{document}\n\n";
- texrow.newline();
- texrow.newline();
- } // only_body
- lyxerr.debug() << "preamble finished, now the body." << endl;
-
- bool was_title = false;
- bool already_title = false;
- string ftnote;
- TexRow ft_texrow;
- int ftcount = 0;
- int loop_count = 0;
-
- LyXParagraph * par = paragraph;
-
- // if only_body
- while (par) {
- ++loop_count;
- if (par->IsDummy())
- lyxerr[Debug::LATEX] << "Error in MakeLateXFile."
- << endl;
- LyXLayout const & layout =
- textclasslist.Style(params.textclass,
- par->layout);
-
- if (layout.intitle) {
- if (already_title) {
- lyxerr <<"Error in MakeLatexFile: You"
- " should not mix title layouts"
- " with normal ones." << endl;
- } else
- was_title = true;
- } else if (was_title && !already_title) {
- LFile += "\\maketitle\n";
- texrow.newline();
- already_title = true;
- was_title = false;
- }
- // We are at depth 0 so we can just use
- // ordinary \footnote{} generation
- // flag this with ftcount
- ftcount = -1;
- if (layout.isEnvironment()
- || par->pextra_type != LyXParagraph::PEXTRA_NONE) {
- par = par->TeXEnvironment(LFile, texrow,
- ftnote, ft_texrow, ftcount);
- } else {
- par = par->TeXOnePar(LFile, texrow,
- ftnote, ft_texrow, ftcount);
- }
-
- // Write out what we've generated...and reset LFile
- if (ftcount >= 1) {
- if (ftcount > 1) {
- LFile += "\\addtocounter{footnote}{-";
- LFile += tostr(ftcount - 1);
- LFile += '}';
- }
- LFile += ftnote;
- texrow += ft_texrow;
- ftnote.clear();
- ft_texrow.reset();
- ftcount = 0;
- }
- if (loop_count == 2) {
- // fwrite()ing every second time through the loop
- // gains a few extra % of speed; going higher than
- // 2 will slow things down again. I'll look at
- // LFile.length() in a future revision. ARRae
- ofs << LFile;
- LFile.clear();
- loop_count = 0;
- }
- }
-
- // It might be that we only have a title in this document
- if (was_title && !already_title) {
- LFile += "\\maketitle\n";
- texrow.newline();
- }
-
- if (!only_body) {
- LFile += "\\end{document}\n";
- texrow.newline();
-
- lyxerr[Debug::LATEX] << "makeLaTeXFile...done" << endl;
- } else {
- lyxerr[Debug::LATEX] << "LaTeXFile for inclusion made."
- << endl;
- }
-
- // Just to be sure. (Asger)
- texrow.newline();
-
- // Write out what we've generated...and reset LFile
- ofs << LFile;
- LFile.clear();
-
- // tex_code_break_column's value is used to decide
- // if we are in batchmode or not (within mathed_write()
- // in math_write.C) so we must set it to a non-zero
- // value when we leave otherwise we save incorrect .lyx files.
- tex_code_break_column = lyxrc->ascii_linelen;
-
- // How to check if the close went ok when using fstreams
- ofs.close();
- lyxerr.debug() << "Finished making latex file." << endl;
-}
-#endif
-
-
-bool Buffer::isLatex() const
-{
- return textclasslist.TextClass(params.textclass).outputType() == LATEX;
-}
-
-
-bool Buffer::isLinuxDoc() const
-{
- return textclasslist.TextClass(params.textclass).outputType() == LINUXDOC;
-}
-
-
-bool Buffer::isLiterate() const
-{
- return textclasslist.TextClass(params.textclass).outputType() == LITERATE;
-}
-
-
-bool Buffer::isDocBook() const
-{
- return textclasslist.TextClass(params.textclass).outputType() == DOCBOOK;
-}
-
-
-bool Buffer::isSGML() const
-{
- return textclasslist.TextClass(params.textclass).outputType() == LINUXDOC ||
- textclasslist.TextClass(params.textclass).outputType() == DOCBOOK;
-}
-
-
-void Buffer::sgmlOpenTag(ostream & os, int depth,
- string const & latexname) const
-{
- os << string(depth, ' ') << "<" << latexname << ">\n";
-}
-
-
-void Buffer::sgmlCloseTag(ostream & os, int depth,
- string const & latexname) const
-{
- os << string(depth, ' ') << "</" << latexname << ">\n";
-}
-
-
-void Buffer::makeLinuxDocFile(string const & fname, int column)
-{
- LyXParagraph * par = paragraph;
-
- string top_element = textclasslist.LatexnameOfClass(params.textclass);
- string environment_stack[10];
- string item_name;
-
- int depth = 0; /* paragraph depth */
-
- ofstream ofs(fname.c_str());
-
- if (!ofs) {
- WriteAlert(_("LYX_ERROR:"), _("Cannot write file"), fname);
- return;
- }
-
- tex_code_break_column = column;
- texrow.reset();
-
- if (params.preamble.empty()) {
- ofs << "<!doctype linuxdoc system>\n\n";
- }
- else {
- ofs << "<!doctype linuxdoc system \n [ "
- << params.preamble << " \n]>\n\n";
- }
-
- ofs << "<!-- " << LYX_DOCVERSION
- << " created this file. For more info see http://www.lyx.org/"
- << " -->\n";
-
- if(params.options.empty())
- sgmlOpenTag(ofs, 0, top_element);
- else {
- string top = top_element;
- top += " ";
- top += params.options;
- sgmlOpenTag(ofs, 0, top);
- }
-
- while (par) {
- int desc_on = 0; /* description mode*/
- LyXLayout const & style =
- textclasslist.Style(users->buffer()->params.textclass,
- par->layout);
- par->AutoDeleteInsets();
-
- /* treat <toc> as a special case for compatibility with old code */
- if (par->GetChar(0) == LyXParagraph::META_INSET) {
- Inset * inset = par->GetInset(0);
- char lyx_code = inset->LyxCode();
- if (lyx_code == Inset::TOC_CODE){
- string temp = "toc";
- sgmlOpenTag(ofs, depth, temp);
-
- par = par->next;
- linuxDocHandleFootnote(ofs, par, depth);
- continue;
+
+ while (par) {
+ int desc_on = 0; /* description mode*/
+ LyXLayout const & style =
+ textclasslist.Style(users->buffer()->params.textclass,
+ par->layout);
+ par->AutoDeleteInsets();
+
+ /* treat <toc> as a special case for compatibility with old code */
+ if (par->GetChar(0) == LyXParagraph::META_INSET) {
+ Inset * inset = par->GetInset(0);
+ char lyx_code = inset->LyxCode();
+ if (lyx_code == Inset::TOC_CODE){
+ string temp = "toc";
+ sgmlOpenTag(ofs, depth, temp);
+
+ par = par->next;
+ linuxDocHandleFootnote(ofs, par, depth);
+ continue;
}
}
tpar->layout == textclasslist.NumberOfLayout(params.textclass,
"Caption").second) {
sgmlOpenTag(os, depth + 1, inner_tag);
-#ifdef USE_OSTREAM_ONLY
string extra_par;
SimpleDocBookOnePar(os, extra_par, tpar,
desc_on, depth + 2);
-#else
- string tmp_par, extra_par;
- SimpleDocBookOnePar(tmp_par, extra_par, tpar,
- desc_on, depth + 2);
- tmp_par = strip(tmp_par);
- tmp_par = frontStrip(tmp_par);
- os << tmp_par;
-#endif
sgmlCloseTag(os, depth+1, inner_tag);
if(!extra_par.empty())
os << extra_par;
bool inner_span = false;
int desc_on = 4;
- // This is not how I like to see enums. They should not be anonymous
- // and variables of its type should not be declared right after the
- // last brace. (Lgb)
+ // Someone should give this enum a proper name (Lgb)
enum SOME_ENUM {
NO_ONE,
FOOTNOTE_LIKE,
if(!tmp_par.empty()) {
os << tmp_par;
tmp_par.clear();
- sgmlCloseTag(os, depth+1, inner_tag);
- sgmlOpenTag(os, depth+1, inner_tag);
+ sgmlCloseTag(os, depth + 1, inner_tag);
+ sgmlOpenTag(os, depth + 1, inner_tag);
}
}
else
}
}
// ignore all caption here, we processed them above!!!
- if (par->layout != textclasslist.NumberOfLayout(params.textclass,
- "Caption").second) {
-#ifdef USE_OSTREAM_ONLY
+ if (par->layout != textclasslist
+ .NumberOfLayout(params.textclass,
+ "Caption").second) {
#ifdef HAVE_SSTREAM
- ostringstream ost;
+ std::ostringstream ost;
#else
ostrstream ost;
#endif
char * ctmp = ost.str();
tmp_par += ctmp;
delete [] ctmp;
-#endif
-#else
#endif
}
tmp_par = frontStrip(strip(tmp_par));
os << "<" << stack[i] << ">";
}
+
void Buffer::pop_tag(ostream & os, char const * tag,
int & pos, char stack[5][3])
{
const unsigned int newcol)
{
colcount += newcol;
- if (colcount > lyxrc->ascii_linelen) {
+ if (colcount > lyxrc.ascii_linelen) {
os << "\n";
colcount = newcol; // assume write after this call
}
if (font2.latex() == LyXFont::ON) {
// "TeX"-Mode on == > SGML-Mode on.
- if (c!= '\0')
+ if (c != '\0')
os << c; // see LaTeX-Generation...
++char_line_count;
} else if (c == LyXParagraph::META_INSET) {
inset = par->GetInset(i);
-#ifdef USE_OSTREAM_ONLY
inset->Linuxdoc(os);
-#else
- string tmp_out;
- inset->Linuxdoc(tmp_out);
- os << tmp_out;
-#endif
- }
- else {
+ } else {
string sgml_string;
if (par->linuxDocConvertChar(c, sgml_string)
&& !style.free_spacing) { // in freespacing
}
do {
-#ifdef USE_OSTREAM_ONLY
string extra_par;
SimpleDocBookOnePar(ofs, extra_par, par, desc_on,
depth + 1 + command_depth);
par = par->next;
DocBookHandleFootnote(ofs, par,
depth + 1 + command_depth);
-#else
- string tmp_par, extra_par;
-
- SimpleDocBookOnePar(tmp_par, extra_par, par, desc_on,
- depth + 1 + command_depth);
- ofs << tmp_par;
-
- par = par->next;
- DocBookHandleFootnote(ofs, par,
- depth + 1 + command_depth);
-#endif
}
while(par && par->IsDummy());
}
-#ifdef USE_OSTREAM_ONLY
void Buffer::SimpleDocBookOnePar(ostream & os, string & extra,
LyXParagraph * par, int & desc_on,
int const depth)
par->SimpleDocBookOneTablePar(os, extra, desc_on, depth);
return;
}
- LyXFont font1, font2;
- char c;
- Inset * inset;
- LyXParagraph::size_type main_body;
- int j;
- //string emph = "emphasis";
+
bool emph_flag = false;
- int char_line_count = 0;
LyXLayout const & style = textclasslist.Style(params.textclass,
par->GetLayout());
+ LyXParagraph::size_type main_body;
if (style.labeltype != LABEL_MANUAL)
main_body = 0;
else
main_body = par->BeginningOfMainBody();
// gets paragraph main font
- if (main_body > 0)
- font1 = style.labelfont;
- else
- font1 = style.font;
-
- char_line_count = depth;
+ //if (main_body > 0)
+ // font1 = style.labelfont;
+ //else
+ // font1 = style.font;
+ LyXFont font1 = main_body > 0 ? style.labelfont : style.font;
+
+ int char_line_count = depth;
if(!style.free_spacing)
- for (j = 0; j < depth; ++j)
+ for (int j = 0; j < depth; ++j)
os << ' ';
// parsing main loop
for (LyXParagraph::size_type i = 0;
i < par->size(); ++i) {
- font2 = par->getFont(i);
+ LyXFont font2 = par->getFont(i);
// handle <emphasis> tag
if (font1.emph() != font2.emph() && i) {
if (font2.emph() == LyXFont::ON) {
os << "<emphasis>";
- emph_flag= true;
+ emph_flag = true;
}else {
os << "</emphasis>";
- emph_flag= false;
+ emph_flag = false;
}
}
- c = par->GetChar(i);
+ char c = par->GetChar(i);
if (c == LyXParagraph::META_INSET) {
- inset = par->GetInset(i);
+ Inset * inset = par->GetInset(i);
#ifdef HAVE_SSTREAM
- ostringstream ost;
+ std::ostringstream ost;
inset->DocBook(ost);
string tmp_out = ost.str().c_str();
#else
}
} else if (font2.latex() == LyXFont::ON) {
// "TeX"-Mode on ==> SGML-Mode on.
- if (c!= '\0')
+ if (c != '\0')
os << c;
++char_line_count;
}
}
os << '\n';
}
-#else
-void Buffer::SimpleDocBookOnePar(string & file, string & extra,
- LyXParagraph * par, int & desc_on,
- int const depth)
-{
- if (par->table) {
- par->SimpleDocBookOneTablePar(file, extra, desc_on, depth);
- return;
- }
- LyXFont font1, font2;
- char c;
- Inset * inset;
- LyXParagraph::size_type main_body;
- int j;
- string emph= "emphasis";
- bool emph_flag= false;
- int char_line_count= 0;
-
- LyXLayout const & style = textclasslist.Style(params.textclass,
- par->GetLayout());
-
- if (style.labeltype != LABEL_MANUAL)
- main_body = 0;
- else
- main_body = par->BeginningOfMainBody();
-
- /* gets paragraph main font */
- if (main_body > 0)
- font1 = style.labelfont;
- else
- font1 = style.font;
-
- char_line_count = depth;
- if(!style.free_spacing)
- for (j = 0; j < depth; ++j)
- file += ' ';
-
- /* parsing main loop */
- for (LyXParagraph::size_type i = 0;
- i < par->size(); ++i) {
- font2 = par->getFont(i);
-
- /* handle <emphasis> tag */
- if (font1.emph() != font2.emph() && i) {
- if (font2.emph() == LyXFont::ON) {
- file += "<emphasis>";
- emph_flag= true;
- }else {
- file += "</emphasis>";
- emph_flag= false;
- }
- }
-
- c = par->GetChar(i);
-
- if (c == LyXParagraph::META_INSET) {
- inset = par->GetInset(i);
-#ifdef USE_OSTREAM_ONLY
-#ifdef HAVE_SSTREAM
- ostringstream ost;
- inset->DocBook(ost);
- string tmp_out = ost.str().c_str();
-#else
- ostrstream ost;
- inset->DocBook(ost);
- ost << '\0';
- char * ctmp = ost.str();
- string tmp_out(ctmp);
- delete [] ctmp;
-#endif
-#else
- string tmp_out;
- inset->DocBook(tmp_out);
-#endif
- //
- // This code needs some explanation:
- // Two insets are treated specially
- // label if it is the first element in a command paragraph
- // desc_on == 3
- // graphics inside tables or figure floats can't go on
- // title (the equivalente in latex for this case is caption
- // and title should come first
- // desc_on == 4
- //
- if(desc_on!= 3 || i!= 0) {
- if(!tmp_out.empty() && tmp_out[0] == '@') {
- if(desc_on == 4)
- extra += frontStrip(tmp_out, '@');
- else
- file += frontStrip(tmp_out, '@');
- }
- else
- file += tmp_out;
- }
- } else if (font2.latex() == LyXFont::ON) {
- // "TeX"-Mode on ==> SGML-Mode on.
- if (c!= '\0')
- file += c;
- ++char_line_count;
- }
- else {
- string sgml_string;
- if (par->linuxDocConvertChar(c, sgml_string)
- && !style.free_spacing) { // in freespacing
- // mode, spaces are
- // non-breaking characters
- // char is ' '
- if (desc_on == 1) {
- ++char_line_count;
- file += '\n';
- file += "</term><listitem><para>";
- desc_on = 2;
- }
- else {
- file += c;
- }
- }
- else {
- file += sgml_string;
- }
- }
- font1 = font2;
- }
-
- /* needed if there is an optional argument but no contents */
- if (main_body > 0 && main_body == par->size()) {
- font1 = style.font;
- }
- if (emph_flag) {
- file += "</emphasis>";
- }
-
- /* resets description flag correctly */
- switch(desc_on){
- case 1:
- /* <term> not closed... */
- file += "</term>";
- break;
- }
- file += '\n';
-}
-#endif
int Buffer::runLaTeX()
string path = OnlyPath(filename);
string org_path = path;
- if (lyxrc->use_tempdir || (IsDirWriteable(path) < 1)) {
+ if (lyxrc.use_tempdir || (IsDirWriteable(path) < 1)) {
path = tmppath;
}
// do the LaTex run(s)
TeXErrors terr;
- string latex_command = lyxrc->pdf_mode ?
- lyxrc->pdflatex_command : lyxrc->latex_command;
+ string latex_command = lyxrc.pdf_mode ?
+ lyxrc.pdflatex_command : lyxrc.latex_command;
LaTeX latex(latex_command, name, filepath);
int res = latex.run(terr,
users->owner()->getMiniBuffer()); // running latex
string name = getLatexName();
// get Literate-Filename
string lit_name = ChangeExtension (getLatexName(),
- lyxrc->literate_extension, true);
+ lyxrc.literate_extension, true);
string path = OnlyPath(filename);
string org_path = path;
- if (lyxrc->use_tempdir || (IsDirWriteable(path) < 1)) {
+ if (lyxrc.use_tempdir || (IsDirWriteable(path) < 1)) {
path = tmppath;
}
markDviDirty();
}
- string latex_command = lyxrc->pdf_mode ?
- lyxrc->pdflatex_command : lyxrc->latex_command;
+ string latex_command = lyxrc.pdf_mode ?
+ lyxrc.pdflatex_command : lyxrc.latex_command;
Literate literate(latex_command, name, filepath,
lit_name,
- lyxrc->literate_command, lyxrc->literate_error_filter,
- lyxrc->build_command, lyxrc->build_error_filter);
+ lyxrc.literate_command, lyxrc.literate_error_filter,
+ lyxrc.build_command, lyxrc.build_error_filter);
TeXErrors terr;
int res = literate.weave(terr, users->owner()->getMiniBuffer());
string name = getLatexName();
// get Literate-Filename
string lit_name = ChangeExtension(getLatexName(),
- lyxrc->literate_extension, true);
+ lyxrc.literate_extension, true);
string path = OnlyPath(filename);
string org_path = path;
- if (lyxrc->use_tempdir || (IsDirWriteable(path) < 1)) {
+ if (lyxrc.use_tempdir || (IsDirWriteable(path) < 1)) {
path = tmppath;
}
markNwDirty();
}
- string latex_command = lyxrc->pdf_mode ?
- lyxrc->pdflatex_command : lyxrc->latex_command;
+ string latex_command = lyxrc.pdf_mode ?
+ lyxrc.pdflatex_command : lyxrc.latex_command;
Literate literate(latex_command, name, filepath,
lit_name,
- lyxrc->literate_command, lyxrc->literate_error_filter,
- lyxrc->build_command, lyxrc->build_error_filter);
+ lyxrc.literate_command, lyxrc.literate_error_filter,
+ lyxrc.build_command, lyxrc.build_error_filter);
TeXErrors terr;
int res = literate.build(terr, users->owner()->getMiniBuffer());
string path = OnlyPath(filename);
string org_path = path;
- if (lyxrc->use_tempdir || (IsDirWriteable(path) < 1)) {
+ if (lyxrc.use_tempdir || (IsDirWriteable(path) < 1)) {
path = tmppath;
}
}
TeXErrors terr;
- Chktex chktex(lyxrc->chktex_command, name, filepath);
+ Chktex chktex(lyxrc.chktex_command, name, filepath);
int res = chktex.run(terr); // run chktex
if (res == -1) {
#if 0
void Buffer::RoffAsciiTable(ostream & os, LyXParagraph * par)
{
- LyXFont font1(LyXFont::ALL_INHERIT);
+ LyXFont font1(LyXFont::ALL_INHERIT,params.language_info);
LyXFont font2;
Inset * inset;
LyXParagraph::size_type i;
}
par->table->RoffEndOfCell(ofs, cell);
ofs.close();
- string cmd = lyxrc->ascii_roff_command + " >" + fname2;
+ string cmd = lyxrc.ascii_roff_command + " >" + fname2;
cmd = subst(cmd, "$$FName", fname1);
Systemcalls one(Systemcalls::System, cmd);
if (!(lyxerr.debugging(Debug::ROFF))) {
/// changed Heinrich Bauer, 23/03/98
bool Buffer::isDviClean() const
{
- if (lyxrc->use_tempdir)
+ if (lyxrc.use_tempdir)
return dvi_clean_tmpd;
else
return dvi_clean_orgd;
/// changed Heinrich Bauer, 23/03/98
void Buffer::markDviClean()
{
- if (lyxrc->use_tempdir)
+ if (lyxrc.use_tempdir)
dvi_clean_tmpd = true;
else
dvi_clean_orgd = true;
/// changed Heinrich Bauer, 23/03/98
void Buffer::markDviDirty()
{
- if (lyxrc->use_tempdir)
+ if (lyxrc.use_tempdir)
dvi_clean_tmpd = false;
else
dvi_clean_orgd = false;
}
if (lyxerr.debugging(Debug::LATEX)) {
- features.showStruct(params);
+ features.showStruct();
}
}
} // end of switch
}
+
+void Buffer::ChangeLanguage(Language const * from, Language const * to)
+{
+
+ LyXParagraph * par = paragraph;
+ while (par) {
+ par->ChangeLanguage(from,to);
+ par = par->next;
+ }
+}
+
+bool Buffer::isMultiLingual()
+{
+
+ LyXParagraph * par = paragraph;
+ while (par) {
+ if (par->isMultiLingual())
+ return true;
+ par = par->next;
+ }
+ return false;
+}