Fix bug 2107:

* src/LaTeXFeatures.[Ch]: replace nice_ by runparams_

        * src/insets/insetexternal.C
        (InsetExternal::validate): Use the correct template for the desired
        output format

        * src/insets/insetgraphics.C
        (InsetGraphics::prepareFile): Record the needed files for "latex"
        or "pdflatex" format, dependant on the desired output format

        * src/insets/insetinclude.C
        (InsetInclude::latex): ditto

        * src/BufferView_pimpl.C
        (BufferView::Pimpl::getStatus): adapt to LaTeXFeatures changes

        * src/paragraph_pimpl.C
        (Paragraph::Pimpl::simpleTeXSpecialC): ditto

        * src/buffer.C
        (Buffer::makeLaTeXFile): ditto
        (Buffer::makeLinuxDocFile): ditto
        (Buffer::makeDocBookFile): ditto

        * src/paragraph.C
        (Paragraph::simpleTeXOnePar): ditto

        * src/exporter.C
        (Backends): Add "pdflatex" backend format
        (Exporter::Export): set runparams.flavor correctly for "pdflatex" format

        * lib/external_templates
        (RasterImage): Use "pdflatex" format in PDFLaTeX template
        (XFig): ditto
        (ChessDiagram): Add PDFLaTeX template
        (Date): ditto

        * lib/configure.py: Add "pdflatex" format


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@13520 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Georg Baum 2006-03-28 18:49:46 +00:00
parent 149c83d35d
commit fc7f2d9805
12 changed files with 72 additions and 33 deletions

View File

@ -224,7 +224,7 @@ if LATEX != 'none':
removeFiles(['chklatex.ltx', 'chklatex.log']) removeFiles(['chklatex.ltx', 'chklatex.log'])
checkProg('the pdflatex program', ['pdflatex $$i'], checkProg('the pdflatex program', ['pdflatex $$i'],
rc_entry = [ r'\converter latex pdf2 "%%" "latex"' ]) rc_entry = [ r'\converter pdflatex pdf2 "%%" "latex"' ])
checkProg('a Tgif viewer and editor', ['tgif'], checkProg('a Tgif viewer and editor', ['tgif'],
rc_entry = [ r'\Format tgif obj Tgif "" "%%" "%%"']) rc_entry = [ r'\Format tgif obj Tgif "" "%%" "%%"'])
@ -262,8 +262,9 @@ checkProg('a text editor', ['xemacs', 'gvim', 'kedit', 'kwrite', 'kate', \
\Format docbook sgml DocBook B "" "%%" \Format docbook sgml DocBook B "" "%%"
\Format docbook-xml xml "Docbook (XML)" "" "" "%%" \Format docbook-xml xml "Docbook (XML)" "" "" "%%"
\Format literate nw NoWeb N "" "%%" \Format literate nw NoWeb N "" "%%"
\Format latex tex LaTeX L "" "%%" \Format latex tex "TeX (latex)" L "" "%%"
\Format linuxdoc sgml LinuxDoc x "" "%%" \Format linuxdoc sgml LinuxDoc x "" "%%"
\Format pdflatex tex "TeX (pdflatex)" "" "" "%%"
\Format text txt "Plain text" a "" "%%" \Format text txt "Plain text" a "" "%%"
\Format textparagraph txt "Plain text (paragraphs)" "" "" "%%"''' ]) \Format textparagraph txt "Plain text (paragraphs)" "" "" "%%"''' ])

View File

@ -82,7 +82,7 @@ Template RasterImage
UpdateFormat png UpdateFormat png
UpdateResult "$$AbsPath$$Basename.png" UpdateResult "$$AbsPath$$Basename.png"
Requirement "graphicx" Requirement "graphicx"
ReferencedFile latex "$$AbsPath$$Basename.png" ReferencedFile pdflatex "$$AbsPath$$Basename.png"
FormatEnd FormatEnd
Format Ascii Format Ascii
Product "$$Contents(\"$$AbsPath$$Basename.asc\")" Product "$$Contents(\"$$AbsPath$$Basename.asc\")"
@ -134,8 +134,8 @@ Template XFig
Requirement "graphicx" Requirement "graphicx"
# Preamble WarnNotFound # Preamble WarnNotFound
# Preamble InputOrWarn # Preamble InputOrWarn
ReferencedFile latex "$$AbsOrRelPathMaster$$Basename.pdftex_t" ReferencedFile pdflatex "$$AbsOrRelPathMaster$$Basename.pdftex_t"
ReferencedFile latex "$$AbsPath$$Basename.pdf" ReferencedFile pdflatex "$$AbsPath$$Basename.pdf"
FormatEnd FormatEnd
Format Ascii Format Ascii
Product "$$Contents(\"$$AbsPath$$Basename.asc\")" Product "$$Contents(\"$$AbsPath$$Basename.asc\")"
@ -184,6 +184,11 @@ Template ChessDiagram
Requirement "chess" Requirement "chess"
ReferencedFile latex "$$AbsPath$$Basename$$Extension" ReferencedFile latex "$$AbsPath$$Basename$$Extension"
FormatEnd FormatEnd
Format PDFLaTeX
Product "\\loadgame{$$AbsOrRelPathMaster$$Basename}\\showboard"
Requirement "chess"
ReferencedFile pdflatex "$$AbsPath$$Basename$$Extension"
FormatEnd
Format Ascii Format Ascii
Product "$$Contents(\"$$AbsPath$$Basename.asc\")" Product "$$Contents(\"$$AbsPath$$Basename.asc\")"
UpdateFormat asciichess UpdateFormat asciichess
@ -212,6 +217,11 @@ Template Date
UpdateFormat dateout UpdateFormat dateout
UpdateResult "$$Tempname" UpdateResult "$$Tempname"
FormatEnd FormatEnd
Format PDFLaTeX
Product "$$Contents(\"$$Tempname\")"
UpdateFormat dateout
UpdateResult "$$Tempname"
FormatEnd
Format Ascii Format Ascii
Product "$$Contents(\"$$Tempname\")" Product "$$Contents(\"$$Tempname\")"
UpdateFormat dateout UpdateFormat dateout

View File

@ -1072,7 +1072,8 @@ FuncStatus BufferView::Pimpl::getStatus(FuncRequest const & cmd)
break; break;
case LFUN_OUTPUT_CHANGES: { case LFUN_OUTPUT_CHANGES: {
LaTeXFeatures features(*buffer_, buffer_->params(), false); OutputParams runparams;
LaTeXFeatures features(*buffer_, buffer_->params(), runparams);
flag.enabled(buffer_ && buffer_->params().tracking_changes flag.enabled(buffer_ && buffer_->params().tracking_changes
&& features.isAvailable("dvipost")); && features.isAvailable("dvipost"));
flag.setOnOff(buffer_->params().output_changes); flag.setOnOff(buffer_->params().output_changes);

View File

@ -49,8 +49,9 @@ namespace biblio = lyx::biblio;
LaTeXFeatures::PackagesList LaTeXFeatures::packages_; LaTeXFeatures::PackagesList LaTeXFeatures::packages_;
LaTeXFeatures::LaTeXFeatures(Buffer const & b, BufferParams const & p, bool n) LaTeXFeatures::LaTeXFeatures(Buffer const & b, BufferParams const & p,
: buffer_(&b), params_(p), nice_(n) OutputParams const & r)
: buffer_(&b), params_(p), runparams_(r)
{} {}

View File

@ -14,6 +14,8 @@
#define LATEXFEATURES_H #define LATEXFEATURES_H
#include "outputparams.h"
#include <set> #include <set>
#include <list> #include <list>
#include <map> #include <map>
@ -39,7 +41,8 @@ class Language;
class LaTeXFeatures { class LaTeXFeatures {
public: public:
/// ///
LaTeXFeatures(Buffer const &, BufferParams const &, bool); LaTeXFeatures(Buffer const &, BufferParams const &,
OutputParams const &);
/// The packages needed by the document /// The packages needed by the document
std::string const getPackages() const; std::string const getPackages() const;
/// The macros definitions needed by the document /// The macros definitions needed by the document
@ -88,8 +91,8 @@ public:
BufferParams const & bufferParams() const; BufferParams const & bufferParams() const;
/// the return value is dependent upon both LyXRC and LaTeXFeatures. /// the return value is dependent upon both LyXRC and LaTeXFeatures.
bool useBabel() const; bool useBabel() const;
/// /// Runparams that will be used for exporting this file.
bool nice() const { return nice_; }; OutputParams const & runparams() const { return runparams_; }
private: private:
std::list<std::string> usedLayouts_; std::list<std::string> usedLayouts_;
@ -124,10 +127,10 @@ private:
Buffer const * buffer_; Buffer const * buffer_;
/// ///
BufferParams const & params_; BufferParams const & params_;
/** If we are writing a nice LaTeX file or not. /** Some insets need to know details about the to-be-produced file
* Only needed by InsetInclude::validate(). * in validate().
*/ */
bool nice_; OutputParams const & runparams_;
}; };
#endif #endif

View File

@ -833,7 +833,7 @@ void Buffer::makeLaTeXFile(ostream & os,
// validate the buffer. // validate the buffer.
lyxerr[Debug::LATEX] << " Validating buffer..." << endl; lyxerr[Debug::LATEX] << " Validating buffer..." << endl;
LaTeXFeatures features(*this, params(), runparams.nice); LaTeXFeatures features(*this, params(), runparams);
validate(features); validate(features);
lyxerr[Debug::LATEX] << " Buffer validation done." << endl; lyxerr[Debug::LATEX] << " Buffer validation done." << endl;
@ -986,7 +986,7 @@ void Buffer::makeLinuxDocFile(string const & fname,
if (!openFileWrite(ofs, fname)) if (!openFileWrite(ofs, fname))
return; return;
LaTeXFeatures features(*this, params(), runparams.nice); LaTeXFeatures features(*this, params(), runparams);
validate(features); validate(features);
texrow().reset(); texrow().reset();
@ -1044,7 +1044,7 @@ void Buffer::makeDocBookFile(string const & fname,
if (!openFileWrite(ofs, fname)) if (!openFileWrite(ofs, fname))
return; return;
LaTeXFeatures features(*this, params(), runparams.nice); LaTeXFeatures features(*this, params(), runparams);
validate(features); validate(features);
texrow().reset(); texrow().reset();

View File

@ -58,8 +58,12 @@ namespace {
vector<string> const Backends(Buffer const & buffer) vector<string> const Backends(Buffer const & buffer)
{ {
vector<string> v; vector<string> v;
if (buffer.params().getLyXTextClass().isTeXClassAvailable()) if (buffer.params().getLyXTextClass().isTeXClassAvailable()) {
v.push_back(BufferFormat(buffer)); v.push_back(BufferFormat(buffer));
// FIXME: Don't hardcode format names here, but use a flag
if (v.back() == "latex")
v.push_back("pdflatex");
}
v.push_back("text"); v.push_back("text");
v.push_back("lyx"); v.push_back("lyx");
return v; return v;
@ -169,8 +173,12 @@ bool Exporter::Export(Buffer * buffer, string const & format,
formats.prettyName(format))); formats.prettyName(format)));
return false; return false;
} }
} else } else {
backend_format = format; backend_format = format;
// FIXME: Don't hardcode format names here, but use a flag
if (backend_format == "pdflatex")
runparams.flavor = OutputParams::PDFLATEX;
}
string filename = buffer->getLatexName(false); string filename = buffer->getLatexName(false);
filename = AddName(buffer->temppath(), filename); filename = AddName(buffer->temppath(), filename);

View File

@ -753,9 +753,20 @@ void InsetExternal::validate(LaTeXFeatures & features) const
return; return;
external::Template const & et = *et_ptr; external::Template const & et = *et_ptr;
// FIXME: This is wrong if we export to PDFLaTeX string format;
switch (features.runparams().flavor) {
case OutputParams::LATEX:
format = "LaTeX";
break;
case OutputParams::PDFLATEX:
format = "PDFLaTeX";
break;
case OutputParams::XML:
format = "DocBook";
break;
}
external::Template::Formats::const_iterator cit = external::Template::Formats::const_iterator cit =
et.formats.find("LaTeX"); et.formats.find(format);
if (cit == et.formats.end()) if (cit == et.formats.end())
return; return;

View File

@ -607,6 +607,8 @@ string const InsetGraphics::prepareFile(Buffer const & buf,
params().filename.outputFilename(m_buffer->filePath()) : params().filename.outputFilename(m_buffer->filePath()) :
OnlyFilename(temp_file)); OnlyFilename(temp_file));
string const source_file = runparams.nice ? orig_file : temp_file; string const source_file = runparams.nice ? orig_file : temp_file;
string const tex_format = (runparams.flavor == OutputParams::LATEX) ?
"latex" : "pdflatex";
if (zipped) { if (zipped) {
if (params().noUnzip) { if (params().noUnzip) {
@ -619,7 +621,7 @@ string const InsetGraphics::prepareFile(Buffer const & buf,
string const bb_orig_file = ChangeExtension(orig_file, "bb"); string const bb_orig_file = ChangeExtension(orig_file, "bb");
if (runparams.nice) { if (runparams.nice) {
runparams.exportdata->addExternalFile("latex", runparams.exportdata->addExternalFile(tex_format,
bb_orig_file, bb_orig_file,
ChangeExtension(output_file, "bb")); ChangeExtension(output_file, "bb"));
} else { } else {
@ -630,10 +632,10 @@ string const InsetGraphics::prepareFile(Buffer const & buf,
copyFileIfNeeded(bb_orig_file, bb_file); copyFileIfNeeded(bb_orig_file, bb_file);
if (status == FAILURE) if (status == FAILURE)
return orig_file; return orig_file;
runparams.exportdata->addExternalFile("latex", runparams.exportdata->addExternalFile(tex_format,
bb_file); bb_file);
} }
runparams.exportdata->addExternalFile("latex", runparams.exportdata->addExternalFile(tex_format,
source_file, output_file); source_file, output_file);
runparams.exportdata->addExternalFile("dvi", runparams.exportdata->addExternalFile("dvi",
source_file, output_file); source_file, output_file);
@ -678,7 +680,7 @@ string const InsetGraphics::prepareFile(Buffer const & buf,
if (from == to) { if (from == to) {
// The extension of temp_file might be != ext! // The extension of temp_file might be != ext!
runparams.exportdata->addExternalFile("latex", source_file, runparams.exportdata->addExternalFile(tex_format, source_file,
output_file); output_file);
runparams.exportdata->addExternalFile("dvi", source_file, runparams.exportdata->addExternalFile("dvi", source_file,
output_file); output_file);
@ -695,7 +697,7 @@ string const InsetGraphics::prepareFile(Buffer const & buf,
<< bformat(_("No conversion of %1$s is needed after all"), << bformat(_("No conversion of %1$s is needed after all"),
rel_file) rel_file)
<< std::endl; << std::endl;
runparams.exportdata->addExternalFile("latex", to_file, runparams.exportdata->addExternalFile(tex_format, to_file,
output_to_file); output_to_file);
runparams.exportdata->addExternalFile("dvi", to_file, runparams.exportdata->addExternalFile("dvi", to_file,
output_to_file); output_to_file);
@ -709,7 +711,7 @@ string const InsetGraphics::prepareFile(Buffer const & buf,
<< "\t from " << from << " to " << to << '\n'; << "\t from " << from << " to " << to << '\n';
if (converters.convert(&buf, temp_file, temp_file, from, to, true)) { if (converters.convert(&buf, temp_file, temp_file, from, to, true)) {
runparams.exportdata->addExternalFile("latex", runparams.exportdata->addExternalFile(tex_format,
to_file, output_to_file); to_file, output_to_file);
runparams.exportdata->addExternalFile("dvi", runparams.exportdata->addExternalFile("dvi",
to_file, output_to_file); to_file, output_to_file);
@ -884,7 +886,7 @@ void InsetGraphics::validate(LaTeXFeatures & features) const
features.require("graphicx"); features.require("graphicx");
if (features.nice()) { if (features.runparams().nice) {
Buffer const * m_buffer = features.buffer().getMasterBuffer(); Buffer const * m_buffer = features.buffer().getMasterBuffer();
string basename = string basename =
params().filename.outputFilename(m_buffer->filePath()); params().filename.outputFilename(m_buffer->filePath());

View File

@ -407,11 +407,13 @@ int InsetInclude::latex(Buffer const & buffer, ostream & os,
} }
} }
string const tex_format = (runparams.flavor == OutputParams::LATEX) ?
"latex" : "pdflatex";
if (isVerbatim(params_)) { if (isVerbatim(params_)) {
incfile = latex_path(incfile); incfile = latex_path(incfile);
os << '\\' << params_.getCmdName() << '{' << incfile << '}'; os << '\\' << params_.getCmdName() << '{' << incfile << '}';
} else if (type(params_) == INPUT) { } else if (type(params_) == INPUT) {
runparams.exportdata->addExternalFile("latex", writefile, runparams.exportdata->addExternalFile(tex_format, writefile,
exportfile); exportfile);
// \input wants file with extension (default is .tex) // \input wants file with extension (default is .tex)
@ -426,7 +428,7 @@ int InsetInclude::latex(Buffer const & buffer, ostream & os,
<< '}'; << '}';
} }
} else { } else {
runparams.exportdata->addExternalFile("latex", writefile, runparams.exportdata->addExternalFile(tex_format, writefile,
exportfile); exportfile);
// \include don't want extension and demands that the // \include don't want extension and demands that the
@ -556,7 +558,7 @@ void InsetInclude::validate(LaTeXFeatures & features) const
else else
writefile = included_file; writefile = included_file;
if (!features.nice() && !isVerbatim(params_)) { if (!features.runparams().nice && !isVerbatim(params_)) {
incfile = FileName(writefile).mangledFilename(); incfile = FileName(writefile).mangledFilename();
writefile = MakeAbsPath(incfile, writefile = MakeAbsPath(incfile,
buffer.getMasterBuffer()->temppath()); buffer.getMasterBuffer()->temppath());

View File

@ -885,7 +885,7 @@ bool Paragraph::simpleTeXOnePar(Buffer const & buf,
LyXFont basefont; LyXFont basefont;
LaTeXFeatures features(buf, bparams, runparams.nice); LaTeXFeatures features(buf, bparams, runparams);
// output change tracking marks only if desired, // output change tracking marks only if desired,
// if dvipost is installed, // if dvipost is installed,

View File

@ -531,7 +531,7 @@ void Paragraph::Pimpl::simpleTeXSpecialChars(Buffer const & buf,
// output change tracking marks only if desired, // output change tracking marks only if desired,
// if dvipost is installed, // if dvipost is installed,
// and with dvi/ps (other formats don't work) // and with dvi/ps (other formats don't work)
LaTeXFeatures features(buf, bparams, runparams.nice); LaTeXFeatures features(buf, bparams, runparams);
bool const output = bparams.output_changes bool const output = bparams.output_changes
&& runparams.flavor == OutputParams::LATEX && runparams.flavor == OutputParams::LATEX
&& features.isAvailable("dvipost"); && features.isAvailable("dvipost");