diff --git a/src/ChangeLog b/src/ChangeLog index f223526af6..541c85e90f 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,21 @@ +2003-05-22 Angus Leeming + + * latexrunparams.h: new file containing struct LatexRunParams. + * Makefile.am: add new file. + + * LaTeX.[Ch] (c-tor, run): + * buffer.[Ch] (makeLaTeXFile): + * bufferlist.[Ch] (updateIncludedTeXfiles): + * converter.C (convert, scanLog): + * converter.[Ch] (runLaTeX): + * exporter.C (Export): + * paragraph.[Ch] (simpleTeXOnePar): + * paragraph_funcs.C (TeXEnvironment, TeXOnePar, TeXDeeper): + * paragraph_funcs.[Ch] (latexParagraphs): + * paragraph_pimpl.[Ch] (simpleTeXSpecialChars): + * tabular.[Ch] (TeXLongtableHeaderFooter, TeXRow, latex): + pass around a LatexRunParams parameter. + 2003-05-22 Lars Gullik Bjønnes * paragraph.[Ch]: remove unused constructor @@ -39,7 +57,6 @@ * iterators.[Ch]: add two const's - 2003-05-21 Lars Gullik Bjønnes * toc.C (getTocList): adjust diff --git a/src/LaTeX.C b/src/LaTeX.C index 8908812d6f..53cf4e9241 100644 --- a/src/LaTeX.C +++ b/src/LaTeX.C @@ -107,8 +107,9 @@ bool operator!=(Aux_Info const & a, Aux_Info const & o) * CLASS LaTeX */ -LaTeX::LaTeX(string const & latex, string const & f, string const & p) - : cmd(latex), file(f), path(p) +LaTeX::LaTeX(string const & latex, LatexRunParams const & rp, + string const & f, string const & p) + : cmd(latex), file(f), path(p), runparams(rp) { num_errors = 0; depfile = file + ".dep"; @@ -163,7 +164,7 @@ int LaTeX::run(TeXErrors & terr, LyXFunc * lfun) bool rerun = false; // rerun requested // The class LaTeX does not know the temp path. - bufferlist.updateIncludedTeXfiles(lyx::getcwd()); + bufferlist.updateIncludedTeXfiles(lyx::getcwd(), runparams); // Never write the depfile if an error was encountered. diff --git a/src/LaTeX.h b/src/LaTeX.h index 7b2cfa6fc2..c4739b1907 100644 --- a/src/LaTeX.h +++ b/src/LaTeX.h @@ -15,6 +15,7 @@ #ifndef LATEX_H #define LATEX_H +#include "latexrunparams.h" #include "LString.h" #include "DepTable.h" #include @@ -129,7 +130,8 @@ public: cmd = the latex command, file = name of the (temporary) latex file, path = name of the files original path. */ - LaTeX(string const & cmd, string const & file, string const & path); + LaTeX(string const & cmd, LatexRunParams const &, + string const & file, string const & path); /// runs LaTeX several times int run(TeXErrors &, LyXFunc *); @@ -186,6 +188,9 @@ private: /// The name of the final output file. string output_file; + + /// + LatexRunParams runparams; }; #endif diff --git a/src/Makefile.am b/src/Makefile.am index 9079d1b694..b830c21dd9 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -71,6 +71,7 @@ lyx_SOURCES = \ LaTeX.h \ LaTeXFeatures.C \ LaTeXFeatures.h \ + latexrunparams.h \ Lsstream.h \ LyXAction.C \ LyXAction.h \ diff --git a/src/buffer.C b/src/buffer.C index e8c8f9de84..2e915abc33 100644 --- a/src/buffer.C +++ b/src/buffer.C @@ -951,6 +951,7 @@ void Buffer::writeFileAscii(ostream & os, int linelen) void Buffer::makeLaTeXFile(string const & fname, string const & original_path, + LatexRunParams const & runparams, bool nice, bool only_body, bool only_preamble) { lyxerr[Debug::LATEX] << "makeLaTeXFile..." << endl; @@ -964,7 +965,8 @@ void Buffer::makeLaTeXFile(string const & fname, return; } - makeLaTeXFile(ofs, original_path, nice, only_body, only_preamble); + makeLaTeXFile(ofs, original_path, + runparams, nice, only_body, only_preamble); ofs.close(); if (ofs.fail()) { @@ -975,6 +977,7 @@ void Buffer::makeLaTeXFile(string const & fname, void Buffer::makeLaTeXFile(ostream & os, string const & original_path, + LatexRunParams const & runparams, bool nice, bool only_body, bool only_preamble) { niceFile = nice; // this will be used by Insetincludes. @@ -1044,7 +1047,7 @@ void Buffer::makeLaTeXFile(ostream & os, texrow.newline(); } - latexParagraphs(this, paragraphs, os, texrow, false); + latexParagraphs(this, paragraphs, os, texrow, runparams, false); // add this just in case after all the paragraphs os << endl; @@ -1958,7 +1961,9 @@ int Buffer::runChktex() bool const removedErrorInsets = users->removeAutoInsets(); // Generate the LaTeX file if neccessary - makeLaTeXFile(name, org_path, false); + LatexRunParams runparams; + runparams.flavor = LatexRunParams::LATEX; + makeLaTeXFile(name, org_path, runparams, false); TeXErrors terr; Chktex chktex(lyxrc.chktex_command, name, filePath()); diff --git a/src/buffer.h b/src/buffer.h index c7dd087ba7..d905268797 100644 --- a/src/buffer.h +++ b/src/buffer.h @@ -1,14 +1,13 @@ // -*- C++ -*- -/* This file is part of - * ====================================================== +/** + * \file buffer.h + * This file is part of LyX, the document processor. + * Licence details can be found in the file COPYING. * - * LyX, The Document Processor - * Copyright 1995 Matthias Ettrich + * \author Lars Gullik Bjønnes * - * This file is Copyleft 1996 - * Lars Gullik Bjønnes - * - * ====================================================== */ + * Full author contact details are available in file CREDITS + */ #ifndef BUFFER_H #define BUFFER_H @@ -32,6 +31,7 @@ class BufferView; class LyXRC; class TeXErrors; class LaTeXFeatures; +class LatexRunParams; class Language; class ParIterator; class ParConstIterator; @@ -147,12 +147,14 @@ public: /// Just a wrapper for the method below, first creating the ofstream. void makeLaTeXFile(string const & filename, string const & original_path, + LatexRunParams const &, bool nice, bool only_body = false, bool only_preamble = false); /// void makeLaTeXFile(std::ostream & os, string const & original_path, + LatexRunParams const &, bool nice, bool only_body = false, bool only_preamble = false); diff --git a/src/bufferlist.C b/src/bufferlist.C index e31060cff9..a32bafd2a4 100644 --- a/src/bufferlist.C +++ b/src/bufferlist.C @@ -224,7 +224,8 @@ Buffer * BufferList::getBuffer(unsigned int choice) } -void BufferList::updateIncludedTeXfiles(string const & mastertmpdir) +void BufferList::updateIncludedTeXfiles(string const & mastertmpdir, + LatexRunParams const & runparams) { BufferStorage::iterator it = bstore.begin(); BufferStorage::iterator end = bstore.end(); @@ -234,7 +235,7 @@ void BufferList::updateIncludedTeXfiles(string const & mastertmpdir) writefile += '/'; writefile += (*it)->getLatexName(); (*it)->makeLaTeXFile(writefile, mastertmpdir, - false, true); + runparams, false, true); (*it)->markDepClean(mastertmpdir); } } diff --git a/src/bufferlist.h b/src/bufferlist.h index 0dbd2434b3..5ba7e6ffc5 100644 --- a/src/bufferlist.h +++ b/src/bufferlist.h @@ -19,6 +19,7 @@ #include class Buffer; +class LatexRunParams; /** * The class holds all all open buffers, and handles construction @@ -60,7 +61,7 @@ public: std::vector const getFileNames() const; /// FIXME - void updateIncludedTeXfiles(string const &); + void updateIncludedTeXfiles(string const &, LatexRunParams const &); /// emergency save for all buffers void emergencyWriteAll(); diff --git a/src/converter.C b/src/converter.C index 46de668a93..6ed16425ff 100644 --- a/src/converter.C +++ b/src/converter.C @@ -256,6 +256,9 @@ bool Converters::convert(Buffer const * buffer, if (edgepath.empty()) { return false; } + LatexRunParams runparams; + runparams.flavor = usePdflatex(edgepath) ? + LatexRunParams::PDFLATEX : LatexRunParams::LATEX; string path = OnlyPath(from_file); Path p(path); @@ -292,7 +295,7 @@ bool Converters::convert(Buffer const * buffer, run_latex = true; string command = subst(conv.command, token_from, ""); lyxerr[Debug::FILES] << "Running " << command << endl; - if (!runLaTeX(buffer, command)) + if (!runLaTeX(buffer, command, runparams)) return false; } else { if (conv.need_aux && !run_latex @@ -300,7 +303,7 @@ bool Converters::convert(Buffer const * buffer, lyxerr[Debug::FILES] << "Running " << latex_command_ << " to update aux file"<< endl; - runLaTeX(buffer, latex_command_); + runLaTeX(buffer, latex_command_, runparams); } string infile2 = (conv.original_dir) @@ -467,7 +470,9 @@ bool Converters::scanLog(Buffer const * buffer, string const & command, return false; BufferView * bv = buffer->getUser(); - LaTeX latex("", filename, ""); + LatexRunParams runparams; + runparams.flavor = LatexRunParams::LATEX; + LaTeX latex("", runparams, filename, ""); TeXErrors terr; int result = latex.scanLogFile(terr); @@ -481,7 +486,8 @@ bool Converters::scanLog(Buffer const * buffer, string const & command, } -bool Converters::runLaTeX(Buffer const * buffer, string const & command) +bool Converters::runLaTeX(Buffer const * buffer, string const & command, + LatexRunParams const & runparams) { if (!buffer) return false; @@ -496,7 +502,7 @@ bool Converters::runLaTeX(Buffer const * buffer, string const & command) // do the LaTeX run(s) string name = buffer->getLatexName(); - LaTeX latex(command, name, buffer->filePath()); + LaTeX latex(command, runparams, name, buffer->filePath()); TeXErrors terr; int result = latex.run(terr, bv ? &bv->owner()->getLyXFunc() : 0); diff --git a/src/converter.h b/src/converter.h index 4720d4f05b..e69a769ad0 100644 --- a/src/converter.h +++ b/src/converter.h @@ -13,6 +13,7 @@ * Full author contact details are available in file CREDITS */ +#include "latexrunparams.h" #include "graph.h" #include @@ -133,7 +134,8 @@ private: bool scanLog(Buffer const * buffer, string const & command, string const & filename); /// - bool runLaTeX(Buffer const * buffer, string const & command); + bool runLaTeX(Buffer const * buffer, string const & command, + LatexRunParams const &); /// ConverterList converterlist_; /// diff --git a/src/exporter.C b/src/exporter.C index bd11cd2354..2a1d8850e2 100644 --- a/src/exporter.C +++ b/src/exporter.C @@ -26,8 +26,6 @@ using std::vector; using std::find; -bool pdf_mode = false; - bool Exporter::Export(Buffer * buffer, string const & format, bool put_in_tempdir, string & result_file) { @@ -45,6 +43,8 @@ bool Exporter::Export(Buffer * buffer, string const & format, } string backend_format; + LatexRunParams runparams; + runparams.flavor = LatexRunParams::LATEX; vector backends = Backends(buffer); if (find(backends.begin(), backends.end(), format) == backends.end()) { for (vector::const_iterator it = backends.begin(); @@ -52,7 +52,8 @@ bool Exporter::Export(Buffer * buffer, string const & format, Graph::EdgePath p = converters.getPath(*it, format); if (!p.empty()) { - pdf_mode = converters.usePdflatex(p); + if (converters.usePdflatex(p)) + runparams.flavor = LatexRunParams::PDFLATEX; backend_format = *it; break; } @@ -83,13 +84,14 @@ bool Exporter::Export(Buffer * buffer, string const & format, buffer->makeDocBookFile(filename, !put_in_tempdir); // LaTeX backend else if (backend_format == format) - buffer->makeLaTeXFile(filename, string(), true); + buffer->makeLaTeXFile(filename, string(), runparams, true); else if (contains(buffer->filePath(), ' ')) { Alert::error(_("File name error"), _("The directory path to the document cannot contain spaces.")); return false; } else - buffer->makeLaTeXFile(filename, buffer->filePath(), false); + buffer->makeLaTeXFile(filename, buffer->filePath(), + runparams, false); string outfile_base = (put_in_tempdir) ? filename : buffer->getLatexName(false); diff --git a/src/graphics/ChangeLog b/src/graphics/ChangeLog index 359c40bf42..391de0e768 100644 --- a/src/graphics/ChangeLog +++ b/src/graphics/ChangeLog @@ -1,3 +1,7 @@ +2003-05-22 Angus Leeming + + * PreviewLoader.C (dumpPreamble): + pass around a LatexRunParams parameter. 2003-05-13 André Pönitz diff --git a/src/graphics/PreviewLoader.C b/src/graphics/PreviewLoader.C index 906d7fe2c2..6a92629ae1 100644 --- a/src/graphics/PreviewLoader.C +++ b/src/graphics/PreviewLoader.C @@ -564,7 +564,9 @@ void PreviewLoader::Impl::dumpPreamble(ostream & os) const // Why on earth is Buffer::makeLaTeXFile a non-const method? Buffer & tmp = const_cast(buffer_); // Dump the preamble only. - tmp.makeLaTeXFile(os, buffer_.filePath(), true, false, true); + LatexRunParams runparams; + runparams.flavor = LatexRunParams::LATEX; + tmp.makeLaTeXFile(os, buffer_.filePath(), runparams, true, false, true); // FIXME! This is a HACK! The proper fix is to control the 'true' // passed to WriteStream below: @@ -585,7 +587,7 @@ void PreviewLoader::Impl::dumpPreamble(ostream & os) const for (; it != end; ++it) if (it->lyxCode() == Inset::MATHMACRO_CODE) - it->latex(&buffer_, os, true, true); + it->latex(&buffer_, os, runparams, true, true); // All equation lables appear as "(#)" + preview.sty's rendering of // the label name diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index 76fcd35ff6..43dc2e3979 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,10 @@ +2003-05-22 Angus Leeming + + * inset*.[Ch] (latex): + passed a LatexRunParams parameter. + + * insetgraphics.C (latex): actually use it ;-) + 2003-05-22 Alfredo Braunstein * insetfloat.C (addToToc): trivial compile fix diff --git a/src/insets/inset.h b/src/insets/inset.h index ecb2a06820..7be1648523 100644 --- a/src/insets/inset.h +++ b/src/insets/inset.h @@ -26,6 +26,7 @@ class LyXFont; class Dimension; class Buffer; class Painter; +class LatexRunParams; class LyXText; class LyXLex; class Paragraph; @@ -193,7 +194,9 @@ public: If the free_spc (freespacing) variable is set, then this inset is in a free-spacing paragraph. */ - virtual int latex(Buffer const *, std::ostream &, bool fragile, + virtual int latex(Buffer const *, std::ostream &, + LatexRunParams const &, + bool fragile, bool free_spc) const = 0; /// virtual int ascii(Buffer const *, diff --git a/src/insets/insetbibtex.C b/src/insets/insetbibtex.C index 21b54b9112..9c8b162904 100644 --- a/src/insets/insetbibtex.C +++ b/src/insets/insetbibtex.C @@ -82,7 +82,7 @@ string const InsetBibtex::getScreenLabel(Buffer const *) const } -int InsetBibtex::latex(Buffer const * buffer, ostream & os, +int InsetBibtex::latex(Buffer const * buffer, ostream & os, LatexRunParams const &, bool /*fragile*/, bool/*fs*/) const { // changing the sequence of the commands diff --git a/src/insets/insetbibtex.h b/src/insets/insetbibtex.h index 966e3afc9a..df35d7901b 100644 --- a/src/insets/insetbibtex.h +++ b/src/insets/insetbibtex.h @@ -39,7 +39,7 @@ public: /// Inset::Code lyxCode() const { return Inset::BIBTEX_CODE; } /// - int latex(Buffer const *, std::ostream &, + int latex(Buffer const *, std::ostream &, LatexRunParams const &, bool fragile, bool freespace) const; /// void fillWithBibKeys(Buffer const *, diff --git a/src/insets/insetcaption.C b/src/insets/insetcaption.C index 36ba689686..19f2b20a12 100644 --- a/src/insets/insetcaption.C +++ b/src/insets/insetcaption.C @@ -105,7 +105,7 @@ void InsetCaption::draw(BufferView * bv, LyXFont const & f, } -int InsetCaption::latex(Buffer const * buf, ostream & os, +int InsetCaption::latex(Buffer const * buf, ostream & os, LatexRunParams const & runparams, bool fragile, bool free_spc) const { // This is a bit too simplistic to take advantage of @@ -114,7 +114,7 @@ int InsetCaption::latex(Buffer const * buf, ostream & os, // \caption{...}, later we will make it take advantage // of the one of the caption packages. (Lgb) ostringstream ost; - int const l = InsetText::latex(buf, ost, fragile, free_spc); + int const l = InsetText::latex(buf, ost, runparams, fragile, free_spc); os << "\\caption{" << ost.str() << "}\n"; return l + 1; } diff --git a/src/insets/insetcaption.h b/src/insets/insetcaption.h index d5d84fd95c..d9ed40a04f 100644 --- a/src/insets/insetcaption.h +++ b/src/insets/insetcaption.h @@ -37,7 +37,7 @@ public: virtual void draw(BufferView * bv, LyXFont const & f, int baseline, float & x) const; /// - virtual int latex(Buffer const * buf, std::ostream & os, + virtual int latex(Buffer const * buf, std::ostream & os, LatexRunParams const &, bool fragile, bool free_spc) const; /// int ascii(Buffer const * buf, std::ostream & os, int linelen) const; diff --git a/src/insets/insetcite.C b/src/insets/insetcite.C index 419cf6f219..d240a1d56e 100644 --- a/src/insets/insetcite.C +++ b/src/insets/insetcite.C @@ -353,7 +353,7 @@ int InsetCitation::ascii(Buffer const * buffer, ostream & os, int) const // the \cite command is valid. Eg, the user has natbib enabled, inputs some // citations and then changes his mind, turning natbib support off. The output // should revert to \cite[]{} -int InsetCitation::latex(Buffer const * buffer, ostream & os, +int InsetCitation::latex(Buffer const * buffer, ostream & os, LatexRunParams const &, bool /*fragile*/, bool/*fs*/) const { os << "\\"; diff --git a/src/insets/insetcite.h b/src/insets/insetcite.h index 587ba52564..1b8d575a2d 100644 --- a/src/insets/insetcite.h +++ b/src/insets/insetcite.h @@ -37,7 +37,7 @@ public: /// int ascii(Buffer const *, std::ostream &, int linelen) const; /// - int latex(Buffer const *, std::ostream &, bool, bool) const; + int latex(Buffer const *, std::ostream &, LatexRunParams const &, bool, bool) const; /// dispatch_result localDispatch(FuncRequest const & cmd); /// diff --git a/src/insets/insetcollapsable.C b/src/insets/insetcollapsable.C index 4b9c48381f..fe248ec92a 100644 --- a/src/insets/insetcollapsable.C +++ b/src/insets/insetcollapsable.C @@ -272,9 +272,10 @@ void InsetCollapsable::lfunMouseRelease(FuncRequest const & cmd) int InsetCollapsable::latex(Buffer const * buf, ostream & os, + LatexRunParams const & runparams, bool fragile, bool free_spc) const { - return inset.latex(buf, os, fragile, free_spc); + return inset.latex(buf, os, runparams, fragile, free_spc); } diff --git a/src/insets/insetcollapsable.h b/src/insets/insetcollapsable.h index 6550987174..67c0beb128 100644 --- a/src/insets/insetcollapsable.h +++ b/src/insets/insetcollapsable.h @@ -79,7 +79,7 @@ public: /// RESULT localDispatch(FuncRequest const &); /// - int latex(Buffer const *, std::ostream &, + int latex(Buffer const *, std::ostream &, LatexRunParams const &, bool fragile, bool free_spc) const; /// int ascii(Buffer const *, std::ostream &, int) const; diff --git a/src/insets/insetcommand.C b/src/insets/insetcommand.C index 7edcececf5..37d321b620 100644 --- a/src/insets/insetcommand.C +++ b/src/insets/insetcommand.C @@ -39,7 +39,7 @@ void InsetCommand::setParams(InsetCommandParams const & p) } -int InsetCommand::latex(Buffer const *, ostream & os, +int InsetCommand::latex(Buffer const *, ostream & os, LatexRunParams const &, bool /*fragile*/, bool/*fs*/) const { os << getCommand(); diff --git a/src/insets/insetcommand.h b/src/insets/insetcommand.h index 08a05823dd..6949c51a76 100644 --- a/src/insets/insetcommand.h +++ b/src/insets/insetcommand.h @@ -41,7 +41,7 @@ public: /// Can remove one InsetBibKey is modified void scanCommand(string const & c) { p_.scanCommand(c); }; /// - virtual int latex(Buffer const *, std::ostream &, + virtual int latex(Buffer const *, std::ostream &, LatexRunParams const &, bool fragile, bool free_spc) const; /// int ascii(Buffer const *, std::ostream &, int linelen) const; diff --git a/src/insets/insetenv.C b/src/insets/insetenv.C index e8ba7fde58..8e6bc59001 100644 --- a/src/insets/insetenv.C +++ b/src/insets/insetenv.C @@ -65,12 +65,13 @@ string const InsetEnvironment::editMessage() const } -int InsetEnvironment::latex(Buffer const * buf, - ostream & os, bool fragile, bool) const +int InsetEnvironment::latex(Buffer const * buf, ostream & os, + LatexRunParams const & runparams, + bool fragile, bool) const { os << layout_->latexheader; TexRow texrow; - latexParagraphs(buf, paragraphs, os, texrow, fragile, + latexParagraphs(buf, paragraphs, os, texrow, runparams, fragile, layout_->latexparagraph); os << layout_->latexfooter; return texrow.rows(); diff --git a/src/insets/insetenv.h b/src/insets/insetenv.h index a42b903d67..cceb75c9d1 100644 --- a/src/insets/insetenv.h +++ b/src/insets/insetenv.h @@ -30,7 +30,8 @@ public: /// Inset::Code lyxCode() const { return Inset::ENVIRONMENT_CODE; } /// - int latex(Buffer const *, std::ostream &, bool fragile, bool fp) const; + int latex(Buffer const *, std::ostream &, LatexRunParams const &, + bool fragile, bool fp) const; /// string const editMessage() const; /// diff --git a/src/insets/inseterror.h b/src/insets/inseterror.h index 06525a0356..93711de22e 100644 --- a/src/insets/inseterror.h +++ b/src/insets/inseterror.h @@ -38,7 +38,8 @@ public: /// void read(Buffer const *, LyXLex &) {} /// - int latex(Buffer const *, std::ostream &, bool, bool) const { return 0; } + int latex(Buffer const *, std::ostream &, LatexRunParams const &, + bool, bool) const { return 0; } /// int ascii(Buffer const *, std::ostream &, int) const { return 0; } /// diff --git a/src/insets/insetert.C b/src/insets/insetert.C index 881ca1c017..aab2a2b4d5 100644 --- a/src/insets/insetert.C +++ b/src/insets/insetert.C @@ -323,8 +323,8 @@ void InsetERT::lfunMouseMotion(FuncRequest const & cmd) } -int InsetERT::latex(Buffer const *, ostream & os, bool /*fragile*/, - bool /*free_spc*/) const +int InsetERT::latex(Buffer const *, ostream & os, LatexRunParams const &, + bool /*fragile*/, bool /*free_spc*/) const { ParagraphList::iterator par = inset.paragraphs.begin(); ParagraphList::iterator end = inset.paragraphs.end(); diff --git a/src/insets/insetert.h b/src/insets/insetert.h index 75984623f7..979ef251b1 100644 --- a/src/insets/insetert.h +++ b/src/insets/insetert.h @@ -64,7 +64,7 @@ public: /// EDITABLE editable() const; /// - int latex(Buffer const *, std::ostream &, bool fragile, + int latex(Buffer const *, std::ostream &, LatexRunParams const &, bool fragile, bool free_spc) const; /// int ascii(Buffer const *, diff --git a/src/insets/insetexternal.C b/src/insets/insetexternal.C index fa27977806..e69d373a0e 100644 --- a/src/insets/insetexternal.C +++ b/src/insets/insetexternal.C @@ -166,8 +166,8 @@ int InsetExternal::write(string const & format, } -int InsetExternal::latex(Buffer const * buf, - ostream & os, bool, bool) const +int InsetExternal::latex(Buffer const * buf, ostream & os, LatexRunParams const &, + bool, bool) const { return write("LaTeX", buf, os); } diff --git a/src/insets/insetexternal.h b/src/insets/insetexternal.h index 930a9d904c..a8d4910cd9 100644 --- a/src/insets/insetexternal.h +++ b/src/insets/insetexternal.h @@ -53,8 +53,8 @@ public: If the free_spc (freespacing) variable is set, then this inset is in a free-spacing paragraph. */ - virtual int latex(Buffer const *, std::ostream &, bool fragile, - bool free_spc) const; + virtual int latex(Buffer const *, std::ostream &, LatexRunParams const &, + bool fragile, bool free_spc) const; /// write ASCII output to the ostream virtual int ascii(Buffer const *, std::ostream &, int linelen) const; /// write LinuxDoc output to the ostream diff --git a/src/insets/insetfloat.C b/src/insets/insetfloat.C index a039efc266..9d3dee4875 100644 --- a/src/insets/insetfloat.C +++ b/src/insets/insetfloat.C @@ -271,8 +271,8 @@ string const InsetFloat::editMessage() const } -int InsetFloat::latex(Buffer const * buf, - ostream & os, bool fragile, bool fp) const +int InsetFloat::latex(Buffer const * buf, ostream & os, LatexRunParams const & runparams, + bool fragile, bool fp) const { FloatList const & floats = buf->params.getLyXTextClass().floats(); string const tmptype = (params_.wide ? params_.type + "*" : params_.type); @@ -303,7 +303,7 @@ int InsetFloat::latex(Buffer const * buf, } os << '\n'; - int const i = inset.latex(buf, os, fragile, fp); + int const i = inset.latex(buf, os, runparams, fragile, fp); // The \n is used to force \end{} to appear in a new line. // In this case, we do not case if the current output line is empty. diff --git a/src/insets/insetfloat.h b/src/insets/insetfloat.h index 568dfa1289..9a45ede4d4 100644 --- a/src/insets/insetfloat.h +++ b/src/insets/insetfloat.h @@ -57,7 +57,8 @@ public: /// Inset::Code lyxCode() const { return Inset::FLOAT_CODE; } /// - int latex(Buffer const *, std::ostream &, bool fragile, bool fp) const; + int latex(Buffer const *, std::ostream &, LatexRunParams const &, + bool fragile, bool fp) const; /// int docbook(Buffer const *, std::ostream &, bool mixcont) const; /// diff --git a/src/insets/insetfloatlist.C b/src/insets/insetfloatlist.C index 0891b43cb4..c6075d5a98 100644 --- a/src/insets/insetfloatlist.C +++ b/src/insets/insetfloatlist.C @@ -107,7 +107,8 @@ dispatch_result InsetFloatList::localDispatch(FuncRequest const & cmd) } -int InsetFloatList::latex(Buffer const * buf, ostream & os, bool, bool) const +int InsetFloatList::latex(Buffer const * buf, ostream & os, LatexRunParams const &, + bool, bool) const { FloatList const & floats = buf->params.getLyXTextClass().floats(); FloatList::const_iterator cit = floats[getCmdName()]; diff --git a/src/insets/insetfloatlist.h b/src/insets/insetfloatlist.h index f5ec613dfc..ec2f3acfbb 100644 --- a/src/insets/insetfloatlist.h +++ b/src/insets/insetfloatlist.h @@ -44,7 +44,8 @@ public: /// void read(Buffer const *, LyXLex &); /// - int latex(Buffer const *, std::ostream &, bool, bool) const; + int latex(Buffer const *, std::ostream &, LatexRunParams const &, + bool, bool) const; /// int linuxdoc(Buffer const *, std::ostream &) const { return 0; } /// diff --git a/src/insets/insetfoot.C b/src/insets/insetfoot.C index e030627886..eee9bbe698 100644 --- a/src/insets/insetfoot.C +++ b/src/insets/insetfoot.C @@ -57,8 +57,8 @@ string const InsetFoot::editMessage() const } -int InsetFoot::latex(Buffer const * buf, - ostream & os, bool fragile, bool fp) const +int InsetFoot::latex(Buffer const * buf, ostream & os, LatexRunParams const & runparams, + bool fragile, bool fp) const { if (buf && parOwner()) { LyXLayout_ptr const & layout = parOwner()->layout(); @@ -67,7 +67,7 @@ int InsetFoot::latex(Buffer const * buf, os << "%\n\\footnote{"; - int const i = inset.latex(buf, os, fragile, fp); + int const i = inset.latex(buf, os, runparams, fragile, fp); os << "%\n}"; return i + 2; diff --git a/src/insets/insetfoot.h b/src/insets/insetfoot.h index a897e7d060..9dace19829 100644 --- a/src/insets/insetfoot.h +++ b/src/insets/insetfoot.h @@ -31,7 +31,8 @@ public: /// Inset::Code lyxCode() const { return Inset::FOOT_CODE; } /// - int latex(Buffer const *, std::ostream &, bool fragile, bool fp) const; + int latex(Buffer const *, std::ostream &, LatexRunParams const &, + bool fragile, bool fp) const; /// int docbook(Buffer const *, std::ostream &, bool mixcont) const; /// diff --git a/src/insets/insetgraphics.C b/src/insets/insetgraphics.C index 5a5f25ffc8..61e55499e8 100644 --- a/src/insets/insetgraphics.C +++ b/src/insets/insetgraphics.C @@ -69,6 +69,7 @@ TODO #include "funcrequest.h" #include "gettext.h" #include "LaTeXFeatures.h" +#include "latexrunparams.h" #include "Lsstream.h" #include "lyxlex.h" #include "lyxrc.h" @@ -99,7 +100,6 @@ TODO extern string system_tempdir; // set by Exporters -extern bool pdf_mode; using std::ostream; using std::endl; @@ -127,12 +127,10 @@ string const uniqueID() } -string findTargetFormat(string const & suffix) +string findTargetFormat(string const & suffix, LatexRunParams const & runparams) { - // pdf_mode means: - // Are we creating a PDF or a PS file? - // (Should actually mean, are we using latex or pdflatex). - if (pdf_mode) { + // Are we using latex or pdflatex). + if (runparams.flavor == LatexRunParams::PDFLATEX) { lyxerr[Debug::GRAPHICS] << "findTargetFormat: PDF mode\n"; if (contains(suffix, "ps") || suffix == "pdf") return "pdf"; @@ -516,7 +514,8 @@ string const InsetGraphics::createLatexOptions() const } -string const InsetGraphics::prepareFile(Buffer const * buf) const +string const InsetGraphics::prepareFile(Buffer const * buf, + LatexRunParams const & runparams) const { // LaTeX can cope if the graphics file doesn't exist, so just return the // filename. @@ -577,7 +576,7 @@ string const InsetGraphics::prepareFile(Buffer const * buf) const } string const from = getExtFromContents(orig_file_with_path); - string const to = findTargetFormat(from); + string const to = findTargetFormat(from, runparams); lyxerr[Debug::GRAPHICS] << "\t we have: from " << from << " to " << to << '\n'; @@ -673,7 +672,7 @@ string const InsetGraphics::prepareFile(Buffer const * buf) const } -int InsetGraphics::latex(Buffer const * buf, ostream & os, +int InsetGraphics::latex(Buffer const * buf, ostream & os, LatexRunParams const & runparams, bool /*fragile*/, bool/*fs*/) const { // If there is no file specified or not existing, @@ -736,7 +735,7 @@ int InsetGraphics::latex(Buffer const * buf, ostream & os, // and remove the extension so the LaTeX will use whatever is // appropriate (when there are several versions in different formats) string const latex_str = message.empty() ? - (before + '{' + os::external_path(prepareFile(buf)) + '}' + after) : + (before + '{' + os::external_path(prepareFile(buf, runparams)) + '}' + after) : (before + '{' + params().filename + " not found!}" + after); os << latex_str; diff --git a/src/insets/insetgraphics.h b/src/insets/insetgraphics.h index 99c1273b83..f9d0fb330b 100644 --- a/src/insets/insetgraphics.h +++ b/src/insets/insetgraphics.h @@ -49,7 +49,7 @@ public: #fragile == true# means, that the inset should take care about fragile commands by adding a #\protect# before. */ - int latex(Buffer const *, std::ostream &, + int latex(Buffer const *, std::ostream &, LatexRunParams const &, bool fragile, bool free_spc) const; /// int ascii(Buffer const *, std::ostream &, int linelen) const; @@ -101,7 +101,7 @@ private: /// Create the options for the latex command. string const createLatexOptions() const; /// Convert the file if needed, and return the location of the file. - string const prepareFile(Buffer const * buf) const; + string const prepareFile(Buffer const * buf, LatexRunParams const &) const; /// InsetGraphicsParams params_; diff --git a/src/insets/insethfill.C b/src/insets/insethfill.C index 2a01033757..73ef63dd54 100644 --- a/src/insets/insethfill.C +++ b/src/insets/insethfill.C @@ -21,7 +21,7 @@ InsetHFill::InsetHFill() {} -int InsetHFill::latex(Buffer const *, ostream & os, +int InsetHFill::latex(Buffer const *, ostream & os, LatexRunParams const &, bool /*fragile*/, bool /*fs*/) const { os << getCommand(); diff --git a/src/insets/insethfill.h b/src/insets/insethfill.h index e584f38014..7336ed8416 100644 --- a/src/insets/insethfill.h +++ b/src/insets/insethfill.h @@ -28,7 +28,8 @@ public: /// Inset::Code lyxCode() const { return Inset::HFILL_CODE; } /// - int latex(Buffer const *, std::ostream &, bool fragile, bool free_spc) const; + int latex(Buffer const *, std::ostream &, LatexRunParams const &, + bool fragile, bool free_spc) const; /// int ascii(Buffer const *, std::ostream &, int linelen) const; /// diff --git a/src/insets/insetinclude.C b/src/insets/insetinclude.C index 1cb80029f3..fa8bd85bf8 100644 --- a/src/insets/insetinclude.C +++ b/src/insets/insetinclude.C @@ -18,6 +18,7 @@ #include "funcrequest.h" #include "gettext.h" #include "LaTeXFeatures.h" +#include "latexrunparams.h" #include "Lsstream.h" #include "lyxlex.h" #include "lyxrc.h" @@ -285,6 +286,7 @@ bool InsetInclude::loadIfNeeded() const int InsetInclude::latex(Buffer const * buffer, ostream & os, + LatexRunParams const & runparams, bool /*fragile*/, bool /*fs*/) const { string incfile(params_.cparams.getContents()); @@ -328,6 +330,7 @@ int InsetInclude::latex(Buffer const * buffer, ostream & os, tmp->makeLaTeXFile(writefile, OnlyPath(getMasterFilename()), + runparams, buffer->niceFile, true); } @@ -573,7 +576,9 @@ string const InsetInclude::PreviewImpl::latexString() const return string(); ostringstream os; - parent().latex(view()->buffer(), os, false, false); + LatexRunParams runparams; + runparams.flavor = LatexRunParams::LATEX; + parent().latex(view()->buffer(), os, runparams, false, false); return STRCONV(os.str()); } diff --git a/src/insets/insetinclude.h b/src/insets/insetinclude.h index 99d930061e..6d9c461593 100644 --- a/src/insets/insetinclude.h +++ b/src/insets/insetinclude.h @@ -91,7 +91,7 @@ public: /// void read(Buffer const *, LyXLex &); /// - int latex(Buffer const *, std::ostream &, + int latex(Buffer const *, std::ostream &, LatexRunParams const &, bool fragile, bool free_spc) const; /// int ascii(Buffer const *, std::ostream &, int linelen) const; diff --git a/src/insets/insetlabel.C b/src/insets/insetlabel.C index 128f4ac7f7..7db9dcba24 100644 --- a/src/insets/insetlabel.C +++ b/src/insets/insetlabel.C @@ -82,7 +82,7 @@ dispatch_result InsetLabel::localDispatch(FuncRequest const & cmd) } -int InsetLabel::latex(Buffer const *, ostream & os, +int InsetLabel::latex(Buffer const *, ostream & os, LatexRunParams const &, bool /*fragile*/, bool /*fs*/) const { os << escape(getCommand()); diff --git a/src/insets/insetlabel.h b/src/insets/insetlabel.h index db4272070e..7425067f5e 100644 --- a/src/insets/insetlabel.h +++ b/src/insets/insetlabel.h @@ -36,7 +36,7 @@ public: /// std::vector const getLabelList() const; /// - int latex(Buffer const *, std::ostream &, + int latex(Buffer const *, std::ostream &, LatexRunParams const &, bool fragile, bool free_spc) const; /// int ascii(Buffer const *, std::ostream &, int linelen) const; diff --git a/src/insets/insetlatexaccent.C b/src/insets/insetlatexaccent.C index d29506dc3f..3ac614137c 100644 --- a/src/insets/insetlatexaccent.C +++ b/src/insets/insetlatexaccent.C @@ -621,7 +621,7 @@ void InsetLatexAccent::read(Buffer const *, LyXLex & lex) } -int InsetLatexAccent::latex(Buffer const *, ostream & os, +int InsetLatexAccent::latex(Buffer const *, ostream & os, LatexRunParams const &, bool /*fragile*/, bool/*fs*/) const { os << contents; diff --git a/src/insets/insetlatexaccent.h b/src/insets/insetlatexaccent.h index 3c6bcf390b..35834619b0 100644 --- a/src/insets/insetlatexaccent.h +++ b/src/insets/insetlatexaccent.h @@ -49,7 +49,7 @@ public: /// void read(Buffer const *, LyXLex & lex); /// - int latex(Buffer const *, std::ostream &, + int latex(Buffer const *, std::ostream &, LatexRunParams const &, bool fragile, bool free_spc) const; /// int ascii(Buffer const *, std::ostream &, int linelen) const; diff --git a/src/insets/insetlist.h b/src/insets/insetlist.h index 6ed5875529..9f179223cd 100644 --- a/src/insets/insetlist.h +++ b/src/insets/insetlist.h @@ -27,7 +27,8 @@ public: /// Inset::Code lyxCode() const { return Inset::FOOT_CODE; } /// - int latex(Buffer const *, std::ostream &, bool fragile, bool fp) const; + int latex(Buffer const *, std::ostream &, LatexRunParams const &, + bool fragile, bool fp) const; /// string const editMessage() const; }; diff --git a/src/insets/insetmarginal.C b/src/insets/insetmarginal.C index 0c70cbfc22..d59634d604 100644 --- a/src/insets/insetmarginal.C +++ b/src/insets/insetmarginal.C @@ -53,12 +53,12 @@ string const InsetMarginal::editMessage() const } -int InsetMarginal::latex(Buffer const * buf, - ostream & os, bool fragile, bool fp) const +int InsetMarginal::latex(Buffer const * buf, ostream & os, LatexRunParams const & runparams, + bool fragile, bool fp) const { os << "%\n\\marginpar{"; - int const i = inset.latex(buf, os, fragile, fp); + int const i = inset.latex(buf, os, runparams, fragile, fp); os << "%\n}"; return i + 2; diff --git a/src/insets/insetmarginal.h b/src/insets/insetmarginal.h index e7551a9a6a..fae6b701b6 100644 --- a/src/insets/insetmarginal.h +++ b/src/insets/insetmarginal.h @@ -30,7 +30,8 @@ public: /// Inset::Code lyxCode() const { return Inset::MARGIN_CODE; } /// - int latex(Buffer const *, std::ostream &, bool fragile, bool fp) const; + int latex(Buffer const *, std::ostream &, LatexRunParams const &, + bool fragile, bool fp) const; /// string const editMessage() const; }; diff --git a/src/insets/insetminipage.C b/src/insets/insetminipage.C index 90454e3779..3cbe2514bc 100644 --- a/src/insets/insetminipage.C +++ b/src/insets/insetminipage.C @@ -250,8 +250,8 @@ string const InsetMinipage::editMessage() const } -int InsetMinipage::latex(Buffer const * buf, - ostream & os, bool fragile, bool fp) const +int InsetMinipage::latex(Buffer const * buf, ostream & os, LatexRunParams const & runparams, + bool fragile, bool fp) const { string s_pos; switch (params_.pos) { @@ -268,7 +268,7 @@ int InsetMinipage::latex(Buffer const * buf, os << "\\begin{minipage}[" << s_pos << "]{" << params_.width.asLatexString() << "}%\n"; - int i = inset.latex(buf, os, fragile, fp); + int i = inset.latex(buf, os, runparams, fragile, fp); os << "\\end{minipage}%\n"; return i + 2; diff --git a/src/insets/insetminipage.h b/src/insets/insetminipage.h index 33eb8ff90f..12604728ca 100644 --- a/src/insets/insetminipage.h +++ b/src/insets/insetminipage.h @@ -72,7 +72,8 @@ public: /// Inset::Code lyxCode() const { return Inset::MINIPAGE_CODE; } /// - int latex(Buffer const *, std::ostream &, bool fragile, bool fp) const; + int latex(Buffer const *, std::ostream &, LatexRunParams const &, + bool fragile, bool fp) const; /// string const editMessage() const; /// diff --git a/src/insets/insetnewline.C b/src/insets/insetnewline.C index 1becea0d8e..9623b8b10b 100644 --- a/src/insets/insetnewline.C +++ b/src/insets/insetnewline.C @@ -46,7 +46,8 @@ void InsetNewline::dimension(BufferView *, LyXFont const & font, } -int InsetNewline::latex(Buffer const *, ostream &, bool, bool) const +int InsetNewline::latex(Buffer const *, ostream &, LatexRunParams const &, + bool, bool) const { lyxerr << "Eek, calling InsetNewline::latex !" << endl; return 0; diff --git a/src/insets/insetnewline.h b/src/insets/insetnewline.h index 84baa12ba2..814639b1c3 100644 --- a/src/insets/insetnewline.h +++ b/src/insets/insetnewline.h @@ -31,7 +31,8 @@ public: virtual void draw(BufferView *, LyXFont const &, int baseline, float & x) const; - virtual int latex(Buffer const *, std::ostream &, bool fragile, bool free_spc) const; + virtual int latex(Buffer const *, std::ostream &, LatexRunParams const &, + bool fragile, bool free_spc) const; virtual int ascii(Buffer const *, std::ostream &, int linelen) const; diff --git a/src/insets/insetnote.h b/src/insets/insetnote.h index 1043300d92..0100e75917 100644 --- a/src/insets/insetnote.h +++ b/src/insets/insetnote.h @@ -33,7 +33,8 @@ public: /// void write(Buffer const *, std::ostream &) const; /// - int latex(Buffer const *, std::ostream &, bool, bool) const + int latex(Buffer const *, std::ostream &, LatexRunParams const &, + bool, bool) const { return 0; } /// int linuxdoc(Buffer const *, std::ostream &) const diff --git a/src/insets/insetoptarg.C b/src/insets/insetoptarg.C index a95783ac33..09a6ca8c6f 100644 --- a/src/insets/insetoptarg.C +++ b/src/insets/insetoptarg.C @@ -66,17 +66,18 @@ void InsetOptArg::write(Buffer const * buf, ostream & os) const } -int InsetOptArg::latex(Buffer const *, ostream &, bool, bool) const +int InsetOptArg::latex(Buffer const *, ostream &, LatexRunParams const &, + bool, bool) const { return 0; } int InsetOptArg::latexOptional(Buffer const * buf, ostream & os, - bool, bool fp) const + LatexRunParams const & runparams, bool, bool fp) const { os << '['; - int const i = inset.latex(buf, os, false, fp); + int const i = inset.latex(buf, os, runparams, false, fp); os << ']'; return i + 2; } diff --git a/src/insets/insetoptarg.h b/src/insets/insetoptarg.h index 8fea596408..5aa2e0e592 100644 --- a/src/insets/insetoptarg.h +++ b/src/insets/insetoptarg.h @@ -38,11 +38,11 @@ public: string const editMessage() const; /// Standard LaTeX output -- short-circuited - int latex(Buffer const *, std::ostream &, - bool fragile, bool fp) const; + int latex(Buffer const *, std::ostream &, LatexRunParams const &, + bool fragile, bool fp) const; /// Outputting the optional parameter of a LaTeX command - int latexOptional(Buffer const *, std::ostream &, - bool fragile, bool fp) const; + int latexOptional(Buffer const *, std::ostream &, LatexRunParams const &, + bool fragile, bool fp) const; /// Write out tothe .lyx file void write(Buffer const * buf, std::ostream & os) const; }; diff --git a/src/insets/insetparent.C b/src/insets/insetparent.C index 7f1097ba6f..7ec4dddd12 100644 --- a/src/insets/insetparent.C +++ b/src/insets/insetparent.C @@ -54,10 +54,10 @@ dispatch_result InsetParent::localDispatch(FuncRequest const & cmd) // LaTeX must just ignore this command -int InsetParent::latex(Buffer const * buf, ostream & os, +int InsetParent::latex(Buffer const * buf, ostream & os, LatexRunParams const & runparams, bool fragile, bool free_spc) const { os << "%%#{lyx}"; - InsetCommand::latex(buf, os, fragile, free_spc); + InsetCommand::latex(buf, os, runparams, fragile, free_spc); return 0; } diff --git a/src/insets/insetparent.h b/src/insets/insetparent.h index 1dc44baa7e..71299d90d3 100644 --- a/src/insets/insetparent.h +++ b/src/insets/insetparent.h @@ -39,7 +39,7 @@ public: /// Inset::Code lyxCode() const { return Inset::PARENT_CODE; } /// - int latex(Buffer const *, std::ostream &, + int latex(Buffer const *, std::ostream &, LatexRunParams const &, bool fragile, bool free_spc) const; /// void setParent(string const & fn) { setContents(fn); } diff --git a/src/insets/insetquotes.C b/src/insets/insetquotes.C index 53fbebdb40..349af2356e 100644 --- a/src/insets/insetquotes.C +++ b/src/insets/insetquotes.C @@ -239,7 +239,7 @@ void InsetQuotes::read(Buffer const *, LyXLex & lex) extern bool use_babel; -int InsetQuotes::latex(Buffer const * buf, ostream & os, +int InsetQuotes::latex(Buffer const * buf, ostream & os, LatexRunParams const &, bool /*fragile*/, bool /* free_spc */) const { // How do we get the local language here?? diff --git a/src/insets/insetquotes.h b/src/insets/insetquotes.h index 4e9e0bf01f..5650259e4f 100644 --- a/src/insets/insetquotes.h +++ b/src/insets/insetquotes.h @@ -83,7 +83,7 @@ public: /// void read(Buffer const *, LyXLex & lex); /// - int latex(Buffer const *, std::ostream &, + int latex(Buffer const *, std::ostream &, LatexRunParams const &, bool fragile, bool free_spc) const; /// int ascii(Buffer const *, std::ostream &, int linelen) const; diff --git a/src/insets/insetref.C b/src/insets/insetref.C index 0231e58d7b..3ac5351ac8 100644 --- a/src/insets/insetref.C +++ b/src/insets/insetref.C @@ -71,7 +71,7 @@ string const InsetRef::getScreenLabel(Buffer const *) const } -int InsetRef::latex(Buffer const *, ostream & os, +int InsetRef::latex(Buffer const *, ostream & os, LatexRunParams const &, bool /*fragile*/, bool /*fs*/) const { if (getOptions().empty()) diff --git a/src/insets/insetref.h b/src/insets/insetref.h index a54ea0313c..01955ffd60 100644 --- a/src/insets/insetref.h +++ b/src/insets/insetref.h @@ -54,7 +54,7 @@ public: /// bool display() const { return false; } /// - int latex(Buffer const *, std::ostream &, + int latex(Buffer const *, std::ostream &, LatexRunParams const &, bool fragile, bool free_spc) const; /// int ascii(Buffer const *, std::ostream &, int linelen) const; diff --git a/src/insets/insetspace.C b/src/insets/insetspace.C index d4abadea67..2210a24ff9 100644 --- a/src/insets/insetspace.C +++ b/src/insets/insetspace.C @@ -156,8 +156,8 @@ void InsetSpace::read(Buffer const *, LyXLex & lex) } -int InsetSpace::latex(Buffer const *, ostream & os, bool /*fragile*/, - bool free_space) const +int InsetSpace::latex(Buffer const *, ostream & os, LatexRunParams const &, + bool /*fragile*/, bool free_space) const { switch (kind_) { case NORMAL: diff --git a/src/insets/insetspace.h b/src/insets/insetspace.h index 0425c7548e..c92b173c43 100644 --- a/src/insets/insetspace.h +++ b/src/insets/insetspace.h @@ -61,7 +61,7 @@ public: /// Will not be used when lyxf3 void read(Buffer const *, LyXLex & lex); /// - int latex(Buffer const *, std::ostream &, + int latex(Buffer const *, std::ostream &, LatexRunParams const &, bool fragile, bool free_spc) const; /// int ascii(Buffer const *, std::ostream &, int linelen) const; diff --git a/src/insets/insetspecialchar.C b/src/insets/insetspecialchar.C index ca09fa1f64..72b0877e55 100644 --- a/src/insets/insetspecialchar.C +++ b/src/insets/insetspecialchar.C @@ -160,8 +160,8 @@ void InsetSpecialChar::read(Buffer const *, LyXLex & lex) } -int InsetSpecialChar::latex(Buffer const *, ostream & os, bool /*fragile*/, - bool free_space) const +int InsetSpecialChar::latex(Buffer const *, ostream & os, LatexRunParams const &, + bool /*fragile*/, bool free_space) const { switch (kind_) { case HYPHENATION: diff --git a/src/insets/insetspecialchar.h b/src/insets/insetspecialchar.h index 822cd39c9a..dd2e92d4b2 100644 --- a/src/insets/insetspecialchar.h +++ b/src/insets/insetspecialchar.h @@ -54,7 +54,7 @@ public: /// Will not be used when lyxf3 void read(Buffer const *, LyXLex & lex); /// - int latex(Buffer const *, std::ostream &, + int latex(Buffer const *, std::ostream &, LatexRunParams const &, bool fragile, bool free_spc) const; /// int ascii(Buffer const *, std::ostream &, int linelen) const; diff --git a/src/insets/insettabular.C b/src/insets/insettabular.C index 84cfd4f024..9e3749bb8f 100644 --- a/src/insets/insettabular.C +++ b/src/insets/insettabular.C @@ -1192,10 +1192,10 @@ Inset::RESULT InsetTabular::localDispatch(FuncRequest const & cmd) } -int InsetTabular::latex(Buffer const * buf, ostream & os, +int InsetTabular::latex(Buffer const * buf, ostream & os, LatexRunParams const & runparams, bool fragile, bool fp) const { - return tabular->latex(buf, os, fragile, fp); + return tabular->latex(buf, os, runparams, fragile, fp); } diff --git a/src/insets/insettabular.h b/src/insets/insettabular.h index eeb146a2a9..91c23bd17a 100644 --- a/src/insets/insettabular.h +++ b/src/insets/insettabular.h @@ -125,7 +125,8 @@ public: /// RESULT localDispatch(FuncRequest const &); /// - int latex(Buffer const *, std::ostream &, bool, bool) const; + int latex(Buffer const *, std::ostream &, LatexRunParams const &, + bool, bool) const; /// int ascii(Buffer const *, std::ostream &, int linelen) const; /// diff --git a/src/insets/insettext.C b/src/insets/insettext.C index 250e0f9e5e..05701273cf 100644 --- a/src/insets/insettext.C +++ b/src/insets/insettext.C @@ -1447,10 +1447,11 @@ Inset::RESULT InsetText::localDispatch(FuncRequest const & cmd) } -int InsetText::latex(Buffer const * buf, ostream & os, bool fragile, bool) const +int InsetText::latex(Buffer const * buf, ostream & os, LatexRunParams const & runparams, + bool fragile, bool) const { TexRow texrow; - latexParagraphs(buf, paragraphs, os, texrow, fragile); + latexParagraphs(buf, paragraphs, os, texrow, runparams, fragile); return texrow.rows(); } diff --git a/src/insets/insettext.h b/src/insets/insettext.h index 45e80b730e..7cbc02f48f 100644 --- a/src/insets/insettext.h +++ b/src/insets/insettext.h @@ -112,7 +112,7 @@ public: /// RESULT localDispatch(FuncRequest const &); /// - int latex(Buffer const *, std::ostream &, + int latex(Buffer const *, std::ostream &, LatexRunParams const &, bool fragile, bool free_spc) const; /// int ascii(Buffer const *, std::ostream &, int linelen) const; diff --git a/src/insets/insettheorem.h b/src/insets/insettheorem.h index eac9f19b0f..8ade61ce04 100644 --- a/src/insets/insettheorem.h +++ b/src/insets/insettheorem.h @@ -31,7 +31,8 @@ public: /// bool display() const { return true; } /// - int latex(Buffer const *, std::ostream &, bool fragile, bool fp) const; + int latex(Buffer const *, std::ostream &, LatexRunParams const &, + bool fragile, bool fp) const; /// string const editMessage() const; }; diff --git a/src/insets/inseturl.C b/src/insets/inseturl.C index 56f85717ef..3e3d5aa8b0 100644 --- a/src/insets/inseturl.C +++ b/src/insets/inseturl.C @@ -70,7 +70,7 @@ string const InsetUrl::getScreenLabel(Buffer const *) const } -int InsetUrl::latex(Buffer const *, ostream & os, +int InsetUrl::latex(Buffer const *, ostream & os, LatexRunParams const &, bool fragile, bool /*free_spc*/) const { if (!getOptions().empty()) diff --git a/src/insets/inseturl.h b/src/insets/inseturl.h index 83f2a80058..b382bc7c69 100644 --- a/src/insets/inseturl.h +++ b/src/insets/inseturl.h @@ -43,7 +43,7 @@ public: /// bool display() const { return false; } /// - int latex(Buffer const *, std::ostream &, + int latex(Buffer const *, std::ostream &, LatexRunParams const &, bool fragile, bool free_spc) const; /// int ascii(Buffer const *, std::ostream &, int linelen) const; diff --git a/src/insets/insetwrap.C b/src/insets/insetwrap.C index 62be16ee36..bc06311c4d 100644 --- a/src/insets/insetwrap.C +++ b/src/insets/insetwrap.C @@ -192,8 +192,8 @@ string const InsetWrap::editMessage() const } -int InsetWrap::latex(Buffer const * buf, - ostream & os, bool fragile, bool fp) const +int InsetWrap::latex(Buffer const * buf, ostream & os, LatexRunParams const & runparams, + bool fragile, bool fp) const { os << "\\begin{floating" << params_.type << '}'; if (!params_.placement.empty()) { @@ -201,7 +201,7 @@ int InsetWrap::latex(Buffer const * buf, } os << '{' << params_.width.asLatexString() << "}%\n"; - int const i = inset.latex(buf, os, fragile, fp); + int const i = inset.latex(buf, os, runparams, fragile, fp); os << "\\end{floating" << params_.type << "}%\n"; return i + 2; diff --git a/src/insets/insetwrap.h b/src/insets/insetwrap.h index f53691d2fe..369bcfc40c 100644 --- a/src/insets/insetwrap.h +++ b/src/insets/insetwrap.h @@ -55,7 +55,8 @@ public: /// Inset::Code lyxCode() const { return Inset::WRAP_CODE; } /// - int latex(Buffer const *, std::ostream &, bool fragile, bool fp) const; + int latex(Buffer const *, std::ostream &, LatexRunParams const &, + bool fragile, bool fp) const; /// int docbook(Buffer const *, std::ostream &, bool mixcont) const; /// diff --git a/src/latexrunparams.h b/src/latexrunparams.h new file mode 100644 index 0000000000..baf5f2e997 --- /dev/null +++ b/src/latexrunparams.h @@ -0,0 +1,37 @@ +// -*- C++ -*- +/** + * \file latexrunparams.h + * This file is part of LyX, the document processor. + * Licence details can be found in the file COPYING. + * + * \author Angus Leeming + * + * Full author contact details are available in file CREDITS + */ + +#ifndef LatexRunParams_H +#define LatexRunParams_H + +/** The latex that we export depends occasionally on what is to + compile the file. +*/ +struct LatexRunParams { + enum FLAVOR { + LATEX, + PDFLATEX + }; + + LatexRunParams() : flavor(LATEX) {} + //, nice(false), fragile(false) {} + + FLAVOR flavor; +// bool nice; +// bool fragile; +}; + +// enum LatexFlavor { +// LATEX_FLAVOR, +// PDFLATEX_FLAVOR +// }; + +#endif // LatexRunParams_H diff --git a/src/mathed/ChangeLog b/src/mathed/ChangeLog index 1f2daa0992..5292389b49 100644 --- a/src/mathed/ChangeLog +++ b/src/mathed/ChangeLog @@ -1,3 +1,8 @@ +2003-05-22 Angus Leeming + + * formula.[Ch] (latex): + * formulamacro.[Ch] (latex): + passed a LatexRunParams parameter. 2003-05-19 André Pönitz diff --git a/src/mathed/formula.C b/src/mathed/formula.C index 79efa32e3a..5f0eb86aaa 100644 --- a/src/mathed/formula.C +++ b/src/mathed/formula.C @@ -127,7 +127,8 @@ void InsetFormula::write(Buffer const *, ostream & os) const } -int InsetFormula::latex(Buffer const *, ostream & os, bool fragile, bool) const +int InsetFormula::latex(Buffer const *, ostream & os, LatexRunParams const &, + bool fragile, bool) const { WriteStream wi(os, fragile, true); par_->write(wi); diff --git a/src/mathed/formula.h b/src/mathed/formula.h index 22a93b57cb..105587825d 100644 --- a/src/mathed/formula.h +++ b/src/mathed/formula.h @@ -44,7 +44,8 @@ public: /// void read(Buffer const *, LyXLex & lex); /// - int latex(Buffer const *, std::ostream &, bool fragile, bool free_spc) const; + int latex(Buffer const *, std::ostream &, LatexRunParams const &, + bool fragile, bool free_spc) const; /// int ascii(Buffer const *, std::ostream &, int linelen) const; /// diff --git a/src/mathed/formulamacro.C b/src/mathed/formulamacro.C index 0159403f40..a82183ba48 100644 --- a/src/mathed/formulamacro.C +++ b/src/mathed/formulamacro.C @@ -79,8 +79,8 @@ void InsetFormulaMacro::write(Buffer const *, ostream & os) const } -int InsetFormulaMacro::latex(Buffer const *, ostream & os, bool fragile, - bool /*free_spacing*/) const +int InsetFormulaMacro::latex(Buffer const *, ostream & os, LatexRunParams const &, + bool fragile, bool /*free_spacing*/) const { WriteStream wi(os, fragile, true); par()->write(wi); diff --git a/src/mathed/formulamacro.h b/src/mathed/formulamacro.h index 4566b86dea..066d1660c7 100644 --- a/src/mathed/formulamacro.h +++ b/src/mathed/formulamacro.h @@ -44,7 +44,8 @@ public: /// int ascii(Buffer const *, std::ostream &, int linelen) const; /// - int latex(Buffer const *, std::ostream & os, bool fragile, bool free_spc) const; + int latex(Buffer const *, std::ostream & os, LatexRunParams const &, + bool fragile, bool free_spc) const; /// int linuxdoc(Buffer const *, std::ostream & os) const; /// diff --git a/src/paragraph.C b/src/paragraph.C index 5b95e3d116..7662e1ebaf 100644 --- a/src/paragraph.C +++ b/src/paragraph.C @@ -906,6 +906,7 @@ bool Paragraph::simpleTeXOnePar(Buffer const * buf, BufferParams const & bparams, LyXFont const & outerfont, ostream & os, TexRow & texrow, + LatexRunParams const & runparams, bool moving_arg) { lyxerr[Debug::LATEX] << "SimpleTeXOnePar... " << this << endl; @@ -1052,7 +1053,7 @@ bool Paragraph::simpleTeXOnePar(Buffer const * buf, running_change = change; pimpl_->simpleTeXSpecialChars(buf, bparams, - os, texrow, moving_arg, + os, texrow, runparams, moving_arg, font, running_font, basefont, outerfont, open_font, running_change, diff --git a/src/paragraph.h b/src/paragraph.h index 1ad9141228..2dcbbb94e1 100644 --- a/src/paragraph.h +++ b/src/paragraph.h @@ -27,6 +27,7 @@ class Counters; class InsetBibitem; class Language; class LaTeXFeatures; +class LatexRunParams; class ParagraphParameters; class TexRow; @@ -99,7 +100,8 @@ public: /// bool simpleTeXOnePar(Buffer const *, BufferParams const &, LyXFont const & outerfont, std::ostream &, - TexRow & texrow, bool moving_arg); + TexRow & texrow, LatexRunParams const &, + bool moving_arg); /// bool hasSameLayout(Paragraph const & par) const; diff --git a/src/paragraph_funcs.C b/src/paragraph_funcs.C index a9c851dcef..de31d3e05f 100644 --- a/src/paragraph_funcs.C +++ b/src/paragraph_funcs.C @@ -274,13 +274,15 @@ ParagraphList::iterator TeXEnvironment(Buffer const * buf, ParagraphList const & paragraphs, ParagraphList::iterator pit, - ostream & os, TexRow & texrow); + ostream & os, TexRow & texrow, + LatexRunParams const & runparams); ParagraphList::iterator TeXOnePar(Buffer const * buf, ParagraphList const & paragraphs, ParagraphList::iterator pit, ostream & os, TexRow & texrow, + LatexRunParams const & runparams, bool moving_arg, string const & everypar = string()); @@ -289,7 +291,8 @@ ParagraphList::iterator TeXDeeper(Buffer const * buf, ParagraphList const & paragraphs, ParagraphList::iterator pit, - ostream & os, TexRow & texrow) + ostream & os, TexRow & texrow, + LatexRunParams const & runparams) { lyxerr[Debug::LATEX] << "TeXDeeper... " << &*pit << endl; ParagraphList::iterator par = pit; @@ -298,10 +301,10 @@ TeXDeeper(Buffer const * buf, par->params().depth() == pit->params().depth()) { if (par->layout()->isEnvironment()) { par = TeXEnvironment(buf, paragraphs, par, - os, texrow); + os, texrow, runparams); } else { par = TeXOnePar(buf, paragraphs, par, - os, texrow, false); + os, texrow, runparams, false); } } lyxerr[Debug::LATEX] << "TeXDeeper...done " << &*par << endl; @@ -314,7 +317,8 @@ ParagraphList::iterator TeXEnvironment(Buffer const * buf, ParagraphList const & paragraphs, ParagraphList::iterator pit, - ostream & os, TexRow & texrow) + ostream & os, TexRow & texrow, + LatexRunParams const & runparams) { lyxerr[Debug::LATEX] << "TeXEnvironment... " << &*pit << endl; @@ -374,7 +378,7 @@ TeXEnvironment(Buffer const * buf, } ParagraphList::iterator par = pit; do { - par = TeXOnePar(buf, paragraphs, par, os, texrow, false); + par = TeXOnePar(buf, paragraphs, par, os, texrow, runparams, false); if (par != paragraphs.end()&& par->params().depth() > pit->params().depth()) { if (par->layout()->isParagraph()) { @@ -396,7 +400,8 @@ TeXEnvironment(Buffer const * buf, os << '\n'; texrow.newline(); } - par = TeXDeeper(buf, paragraphs, par, os, texrow); + par = TeXDeeper(buf, paragraphs, par, os, texrow, + runparams); } } while (par != paragraphs.end() && par->layout() == pit->layout() @@ -438,6 +443,7 @@ TeXOnePar(Buffer const * buf, ParagraphList const & paragraphs, ParagraphList::iterator pit, ostream & os, TexRow & texrow, + LatexRunParams const & runparams, bool moving_arg, string const & everypar) { @@ -547,7 +553,8 @@ TeXOnePar(Buffer const * buf, if (style->optionalargs == 1) { InsetOptArg * it = optArgInset(*pit); if (it) - it->latexOptional(buf, os, false, false); + it->latexOptional(buf, os, runparams, + false, false); } else os << style->latexparam(); @@ -566,7 +573,7 @@ TeXOnePar(Buffer const * buf, os << everypar; bool need_par = pit->simpleTeXOnePar(buf, bparams, outerFont(pit, paragraphs), - os, texrow, moving_arg); + os, texrow, runparams, moving_arg); // Make sure that \\par is done with the font of the last // character if this has another size as the default. @@ -689,6 +696,7 @@ void latexParagraphs(Buffer const * buf, ParagraphList const & paragraphs, ostream & os, TexRow & texrow, + LatexRunParams const & runparams, bool moving_arg, string const & everypar) { @@ -738,18 +746,19 @@ void latexParagraphs(Buffer const * buf, if (layout->is_environment) { par = TeXOnePar(buf, paragraphs, par, os, texrow, - moving_arg, everypar); + runparams, moving_arg, everypar); } else if (layout->isEnvironment() || !par->params().leftIndent().zero()) { - par = TeXEnvironment(buf, paragraphs, par, os, texrow); + par = TeXEnvironment(buf, paragraphs, par, os, + texrow, runparams); } else { par = TeXOnePar(buf, paragraphs, par, os, texrow, - moving_arg, everypar); + runparams, moving_arg, everypar); } } else { par = TeXOnePar(buf, paragraphs, par, os, texrow, - moving_arg, everypar); + runparams, moving_arg, everypar); } } // It might be that we only have a title in this document diff --git a/src/paragraph_funcs.h b/src/paragraph_funcs.h index 4c78eceb5e..c730090dc8 100644 --- a/src/paragraph_funcs.h +++ b/src/paragraph_funcs.h @@ -19,6 +19,7 @@ class Buffer; class BufferParams; class TexRow; +class LatexRunParams; class LyXLex; /// @@ -65,8 +66,9 @@ void latexParagraphs(Buffer const * buf, ParagraphList const & paragraphs, std::ostream & ofs, TexRow & texrow, + LatexRunParams const &, bool moving_arg, - string const & everypar = string()); + string const & everypar = string()); /// read a paragraph from a .lyx file. Returns number of unrecognised tokens int readParagraph(Buffer & buf, Paragraph & par, LyXLex & lex); diff --git a/src/paragraph_pimpl.C b/src/paragraph_pimpl.C index 260d5d801d..491d1a5521 100644 --- a/src/paragraph_pimpl.C +++ b/src/paragraph_pimpl.C @@ -483,6 +483,7 @@ void Paragraph::Pimpl::simpleTeXSpecialChars(Buffer const * buf, BufferParams const & bparams, ostream & os, TexRow & texrow, + LatexRunParams const & runparams, bool moving_arg, LyXFont & font, LyXFont & running_font, @@ -579,7 +580,7 @@ void Paragraph::Pimpl::simpleTeXSpecialChars(Buffer const * buf, running_font = basefont; } - int tmp = inset->latex(buf, os, moving_arg, + int tmp = inset->latex(buf, os, runparams, moving_arg, style.free_spacing); if (close) diff --git a/src/paragraph_pimpl.h b/src/paragraph_pimpl.h index 4bdb69ed82..0f883fa01b 100644 --- a/src/paragraph_pimpl.h +++ b/src/paragraph_pimpl.h @@ -153,7 +153,7 @@ struct Paragraph::Pimpl { /// void simpleTeXSpecialChars(Buffer const *, BufferParams const &, std::ostream &, TexRow & texrow, - bool moving_arg, + LatexRunParams const &, bool moving_arg, LyXFont & font, LyXFont & running_font, LyXFont & basefont, LyXFont const & outerfont, diff --git a/src/tabular.C b/src/tabular.C index 1a51d8ee18..894e8097de 100644 --- a/src/tabular.C +++ b/src/tabular.C @@ -1872,6 +1872,7 @@ int LyXTabular::TeXCellPostamble(ostream & os, int cell) const int LyXTabular::TeXLongtableHeaderFooter(ostream & os, Buffer const * buf, + LatexRunParams const & runparams, bool fragile, bool fp) const { if (!is_long_tabular) @@ -1886,7 +1887,7 @@ int LyXTabular::TeXLongtableHeaderFooter(ostream & os, Buffer const * buf, } for (int i = 0; i < rows_; ++i) { if (row_info[i].endhead) { - ret += TeXRow(os, i, buf, fragile, fp); + ret += TeXRow(os, i, buf, runparams, fragile, fp); } } if (endhead.bottomDL) { @@ -1908,7 +1909,7 @@ int LyXTabular::TeXLongtableHeaderFooter(ostream & os, Buffer const * buf, } for (int i = 0; i < rows_; ++i) { if (row_info[i].endfirsthead) { - ret += TeXRow(os, i, buf, fragile, fp); + ret += TeXRow(os, i, buf, runparams, fragile, fp); } } if (endfirsthead.bottomDL) { @@ -1926,7 +1927,7 @@ int LyXTabular::TeXLongtableHeaderFooter(ostream & os, Buffer const * buf, } for (int i = 0; i < rows_; ++i) { if (row_info[i].endfoot) { - ret += TeXRow(os, i, buf, fragile, fp); + ret += TeXRow(os, i, buf, runparams, fragile, fp); } } if (endfoot.bottomDL) { @@ -1948,7 +1949,7 @@ int LyXTabular::TeXLongtableHeaderFooter(ostream & os, Buffer const * buf, } for (int i = 0; i < rows_; ++i) { if (row_info[i].endlastfoot) { - ret += TeXRow(os, i, buf, fragile, fp); + ret += TeXRow(os, i, buf, runparams, fragile, fp); } } if (endlastfoot.bottomDL) { @@ -1972,7 +1973,7 @@ bool LyXTabular::isValidRow(int const row) const int LyXTabular::TeXRow(ostream & os, int const i, Buffer const * buf, - bool fragile, bool fp) const + LatexRunParams const & runparams, bool fragile, bool fp) const { int ret = 0; int cell = GetCellNumber(i, 0); @@ -1989,7 +1990,7 @@ int LyXTabular::TeXRow(ostream & os, int const i, Buffer const * buf, if (rtl) os << "\\R{"; - ret += inset->latex(buf, os, fragile, fp); + ret += inset->latex(buf, os, runparams, fragile, fp); if (rtl) os << '}'; @@ -2007,8 +2008,8 @@ int LyXTabular::TeXRow(ostream & os, int const i, Buffer const * buf, } -int LyXTabular::latex(Buffer const * buf, - ostream & os, bool fragile, bool fp) const +int LyXTabular::latex(Buffer const * buf, ostream & os, + LatexRunParams const & runparams, bool fragile, bool fp) const { int ret = 0; @@ -2082,7 +2083,7 @@ int LyXTabular::latex(Buffer const * buf, os << "}\n"; ++ret; - ret += TeXLongtableHeaderFooter(os, buf, fragile, fp); + ret += TeXLongtableHeaderFooter(os, buf, runparams, fragile, fp); //+--------------------------------------------------------------------- //+ the single row and columns (cells) + @@ -2090,7 +2091,7 @@ int LyXTabular::latex(Buffer const * buf, for (int i = 0; i < rows_; ++i) { if (isValidRow(i)) { - ret += TeXRow(os, i, buf, fragile, fp); + ret += TeXRow(os, i, buf, runparams, fragile, fp); if (is_long_tabular && row_info[i].newpage) { os << "\\newpage\n"; ++ret; diff --git a/src/tabular.h b/src/tabular.h index 1940c69231..06917c7323 100644 --- a/src/tabular.h +++ b/src/tabular.h @@ -24,6 +24,7 @@ class InsetTabular; class BufferParams; class LaTeXFeatures; +class LatexRunParams; class Buffer; class LyXLex; @@ -290,7 +291,7 @@ public: /// void Read(Buffer const *, LyXLex &); /// - int latex(Buffer const *, std::ostream &, bool, bool) const; + int latex(Buffer const *, std::ostream &, LatexRunParams const &, bool, bool) const; /// int docbook(Buffer const * buf, std::ostream & os, bool mixcont) const; /// @@ -559,12 +560,12 @@ private: int TeXCellPostamble(std::ostream &, int cell) const; /// int TeXLongtableHeaderFooter(std::ostream &, Buffer const * buf, - bool fragile, bool fp) const; + LatexRunParams const &, bool fragile, bool fp) const; /// bool isValidRow(int const row) const; /// int TeXRow(std::ostream &, int const row, Buffer const * buf, - bool fragile, bool fp) const; + LatexRunParams const &, bool fragile, bool fp) const; /// // helper function for ASCII returns number of newlines ///