From: Angus Leeming Date: Thu, 22 May 2003 21:10:22 +0000 (+0000) Subject: The 'nice' changes. X-Git-Tag: 1.6.10~16776 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=e9d6c8c04c1446e681395902a8b429ab0c0f39de;p=features.git The 'nice' changes. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7013 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/ChangeLog b/src/ChangeLog index 03adbb5a69..1af9be2867 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -2,6 +2,16 @@ * paragraph.C (Paragraph): initialize next_par_ and prev_par_ +2003-05-22 Angus Leeming + + * latexrunparams.h: add a 'bool nice' which defaults to false. + + * buffer.[Ch] (makeLaTeXFile): remove the nice parameter as it is + now encapsulated within runparams. + + * bufferlist.C (updateIncludedTeXfiles): + * exporter.C (Export): ensuing change to the calls to makeLaTeXFile. + 2003-05-22 Angus Leeming * latexrunparams.h: new file containing struct LatexRunParams. diff --git a/src/buffer.C b/src/buffer.C index 2e915abc33..00ec0e569b 100644 --- a/src/buffer.C +++ b/src/buffer.C @@ -952,7 +952,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) + bool only_body, bool only_preamble) { lyxerr[Debug::LATEX] << "makeLaTeXFile..." << endl; @@ -966,7 +966,7 @@ void Buffer::makeLaTeXFile(string const & fname, } makeLaTeXFile(ofs, original_path, - runparams, nice, only_body, only_preamble); + runparams, only_body, only_preamble); ofs.close(); if (ofs.fail()) { @@ -977,10 +977,11 @@ 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) + LatexRunParams const & runparams_in, + bool only_body, bool only_preamble) { - niceFile = nice; // this will be used by Insetincludes. + LatexRunParams runparams = runparams_in; + niceFile = runparams.nice; // this will be used by Insetincludes. // validate the buffer. lyxerr[Debug::LATEX] << " Validating buffer..." << endl; @@ -993,7 +994,7 @@ void Buffer::makeLaTeXFile(ostream & os, // first paragraph of the document. (Asger) texrow.start(paragraphs.begin()->id(), 0); - if (!only_body && nice) { + if (!only_body && runparams.nice) { os << "%% " << lyx_docversion << " created this file. " "For more info, see http://www.lyx.org/.\n" "%% Do not edit unless you really know what " @@ -1010,7 +1011,7 @@ void Buffer::makeLaTeXFile(ostream & os, // original_path is set. This is done for usual tex-file, but not // for nice-latex-file. (Matthias 250696) if (!only_body) { - if (!nice) { + if (!runparams.nice) { // code for usual, NOT nice-latex-file os << "\\batchmode\n"; // changed // from \nonstopmode @@ -1963,7 +1964,8 @@ int Buffer::runChktex() // Generate the LaTeX file if neccessary LatexRunParams runparams; runparams.flavor = LatexRunParams::LATEX; - makeLaTeXFile(name, org_path, runparams, false); + runparams.nice = false; + makeLaTeXFile(name, org_path, runparams); TeXErrors terr; Chktex chktex(lyxrc.chktex_command, name, filePath()); diff --git a/src/buffer.h b/src/buffer.h index d905268797..468178b0f8 100644 --- a/src/buffer.h +++ b/src/buffer.h @@ -148,14 +148,12 @@ public: 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 a32bafd2a4..cc2dcdcb04 100644 --- a/src/bufferlist.C +++ b/src/bufferlist.C @@ -235,7 +235,7 @@ void BufferList::updateIncludedTeXfiles(string const & mastertmpdir, writefile += '/'; writefile += (*it)->getLatexName(); (*it)->makeLaTeXFile(writefile, mastertmpdir, - runparams, false, true); + runparams, true); (*it)->markDepClean(mastertmpdir); } } diff --git a/src/exporter.C b/src/exporter.C index 2a1d8850e2..e32a451926 100644 --- a/src/exporter.C +++ b/src/exporter.C @@ -83,15 +83,17 @@ bool Exporter::Export(Buffer * buffer, string const & format, else if (buffer->isDocBook()) buffer->makeDocBookFile(filename, !put_in_tempdir); // LaTeX backend - else if (backend_format == format) - buffer->makeLaTeXFile(filename, string(), runparams, true); - else if (contains(buffer->filePath(), ' ')) { + else if (backend_format == format) { + runparams.nice = true; + buffer->makeLaTeXFile(filename, string(), runparams); + } 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(), - runparams, false); + } else { + runparams.nice = false; + buffer->makeLaTeXFile(filename, buffer->filePath(), runparams); + } string outfile_base = (put_in_tempdir) ? filename : buffer->getLatexName(false); diff --git a/src/graphics/ChangeLog b/src/graphics/ChangeLog index 391de0e768..85b4c670ad 100644 --- a/src/graphics/ChangeLog +++ b/src/graphics/ChangeLog @@ -1,3 +1,8 @@ +2003-05-22 Angus Leeming + + * PreviewLoader.C (dumpPreamble): the 'nice' param passed to + makeLaTeXFile is now encapsulated within runparams. + 2003-05-22 Angus Leeming * PreviewLoader.C (dumpPreamble): diff --git a/src/graphics/PreviewLoader.C b/src/graphics/PreviewLoader.C index 6a92629ae1..9b90e0aff7 100644 --- a/src/graphics/PreviewLoader.C +++ b/src/graphics/PreviewLoader.C @@ -566,7 +566,8 @@ void PreviewLoader::Impl::dumpPreamble(ostream & os) const // Dump the preamble only. LatexRunParams runparams; runparams.flavor = LatexRunParams::LATEX; - tmp.makeLaTeXFile(os, buffer_.filePath(), runparams, true, false, true); + runparams.nice = true; + tmp.makeLaTeXFile(os, buffer_.filePath(), runparams, false, true); // FIXME! This is a HACK! The proper fix is to control the 'true' // passed to WriteStream below: diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index 9cc1b43f53..162b2f64f9 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -2,6 +2,13 @@ * insetspecialchar.C (dimension): use a string. +2003-05-22 Angus Leeming + + * insetbibtex.C (latex): + * insetgraphics.C (latex): + * insetinclude.C (latex): extract the buffer's 'nice'ness from + runparams rather than from the buffer itself. + 2003-05-22 Angus Leeming * inset*.[Ch] (latex): diff --git a/src/insets/insetbibtex.C b/src/insets/insetbibtex.C index 9c8b162904..3d2531f345 100644 --- a/src/insets/insetbibtex.C +++ b/src/insets/insetbibtex.C @@ -16,6 +16,7 @@ #include "debug.h" #include "funcrequest.h" #include "gettext.h" +#include "latexrunparams.h" #include "support/filetools.h" #include "support/path.h" @@ -82,7 +83,8 @@ string const InsetBibtex::getScreenLabel(Buffer const *) const } -int InsetBibtex::latex(Buffer const * buffer, ostream & os, LatexRunParams const &, +int InsetBibtex::latex(Buffer const * buffer, ostream & os, + LatexRunParams const & runparams, bool /*fragile*/, bool/*fs*/) const { // changing the sequence of the commands @@ -103,7 +105,7 @@ int InsetBibtex::latex(Buffer const * buffer, ostream & os, LatexRunParams const } } - if (!buffer->niceFile + if (!runparams.nice && IsFileReadable(MakeAbsPath(style, buffer->filePath()) + ".bst")) { style = MakeAbsPath(style, buffer->filePath()); } @@ -143,7 +145,7 @@ int InsetBibtex::latex(Buffer const * buffer, ostream & os, LatexRunParams const // have a comma-separated list of bibliographies string db_out; while (!adb.empty()) { - if (!buffer->niceFile && + if (!runparams.nice && IsFileReadable(MakeAbsPath(adb, buffer->filePath())+".bib")) adb = os::external_path(MakeAbsPath(adb, buffer->filePath())); db_out += adb; diff --git a/src/insets/insetgraphics.C b/src/insets/insetgraphics.C index 61e55499e8..cda1d8d3ea 100644 --- a/src/insets/insetgraphics.C +++ b/src/insets/insetgraphics.C @@ -672,7 +672,8 @@ string const InsetGraphics::prepareFile(Buffer const * buf, } -int InsetGraphics::latex(Buffer const * buf, ostream & os, LatexRunParams const & runparams, +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, @@ -726,7 +727,7 @@ int InsetGraphics::latex(Buffer const * buf, ostream & os, LatexRunParams const // "nice" means that the buffer is exported to LaTeX format but not // run through the LaTeX compiler. - if (buf->niceFile) { + if (runparams.nice) { os << before <<'{' << params().filename << '}' << after; return 1; } diff --git a/src/insets/insetinclude.C b/src/insets/insetinclude.C index fa8bd85bf8..d334c7307c 100644 --- a/src/insets/insetinclude.C +++ b/src/insets/insetinclude.C @@ -313,8 +313,7 @@ int InsetInclude::latex(Buffer const * buffer, ostream & os, // write it to a file (so far the complete file) string writefile = ChangeExtension(getFileName(), ".tex"); - if (!buffer->tmppath.empty() - && !buffer->niceFile) { + if (!buffer->tmppath.empty() && !runparams.nice) { incfile = subst(incfile, '/','@'); #ifdef __EMX__ incfile = subst(incfile, ':', '$'); @@ -328,10 +327,8 @@ int InsetInclude::latex(Buffer const * buffer, ostream & os, tmp->markDepClean(buffer->tmppath); - tmp->makeLaTeXFile(writefile, - OnlyPath(getMasterFilename()), - runparams, - buffer->niceFile, true); + tmp->makeLaTeXFile(writefile, OnlyPath(getMasterFilename()), + runparams, true); } if (isVerbatim()) { diff --git a/src/latexrunparams.h b/src/latexrunparams.h index baf5f2e997..77d8140f71 100644 --- a/src/latexrunparams.h +++ b/src/latexrunparams.h @@ -12,26 +12,24 @@ #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) {} + LatexRunParams() : flavor(LATEX), nice(false) {} + /** The latex that we export depends occasionally on what is to + compile the file. + */ FLAVOR flavor; -// bool nice; -// bool fragile; + /** Are we to write a 'nice' LaTeX file or not. + This esentially seems to mean whether InsetInclude, InsetGraphics + and InsetExternal should add the absolute path to any external + files or not. + */ + bool nice; }; -// enum LatexFlavor { -// LATEX_FLAVOR, -// PDFLATEX_FLAVOR -// }; - #endif // LatexRunParams_H