Backporting this fix was now trivial since lib/configure.py is used. Jean-Marc, shall I commit it? It has a compatibility problem with external templates, but this is not a big deal since external templates for any other format than latex are broken anyway (this is also corrected by this patch).
Georg Log: 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
Index: src/LaTeXFeatures.C =================================================================== --- src/LaTeXFeatures.C (Revision 13742) +++ src/LaTeXFeatures.C (Arbeitskopie) @@ -49,8 +49,9 @@ namespace biblio = lyx::biblio; LaTeXFeatures::PackagesList LaTeXFeatures::packages_; -LaTeXFeatures::LaTeXFeatures(Buffer const & b, BufferParams const & p, bool n) - : buffer_(&b), params_(p), nice_(n) +LaTeXFeatures::LaTeXFeatures(Buffer const & b, BufferParams const & p, + OutputParams const & r) + : buffer_(&b), params_(p), runparams_(r) {} Index: src/insets/insetexternal.C =================================================================== --- src/insets/insetexternal.C (Revision 13742) +++ src/insets/insetexternal.C (Arbeitskopie) @@ -753,9 +753,20 @@ void InsetExternal::validate(LaTeXFeatur return; 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 = - et.formats.find("LaTeX"); + et.formats.find(format); if (cit == et.formats.end()) return; Index: src/insets/insetgraphics.C =================================================================== --- src/insets/insetgraphics.C (Revision 13742) +++ src/insets/insetgraphics.C (Arbeitskopie) @@ -607,6 +607,8 @@ string const InsetGraphics::prepareFile( params().filename.outputFilename(m_buffer->filePath()) : OnlyFilename(temp_file)); string source_file = runparams.nice ? orig_file : temp_file; + string const tex_format = (runparams.flavor == OutputParams::LATEX) ? + "latex" : "pdflatex"; if (zipped) { if (params().noUnzip) { @@ -619,7 +621,7 @@ string const InsetGraphics::prepareFile( string const bb_orig_file = ChangeExtension(orig_file, "bb"); if (runparams.nice) { - runparams.exportdata->addExternalFile("latex", + runparams.exportdata->addExternalFile(tex_format, bb_orig_file, ChangeExtension(output_file, "bb")); } else { @@ -630,10 +632,10 @@ string const InsetGraphics::prepareFile( copyFileIfNeeded(bb_orig_file, bb_file); if (status == FAILURE) return orig_file; - runparams.exportdata->addExternalFile("latex", + runparams.exportdata->addExternalFile(tex_format, bb_file); } - runparams.exportdata->addExternalFile("latex", + runparams.exportdata->addExternalFile(tex_format, source_file, output_file); runparams.exportdata->addExternalFile("dvi", source_file, output_file); @@ -680,7 +682,7 @@ string const InsetGraphics::prepareFile( if (from == to) { // The extension of temp_file might be != ext! - runparams.exportdata->addExternalFile("latex", source_file, + runparams.exportdata->addExternalFile(tex_format, source_file, output_file); runparams.exportdata->addExternalFile("dvi", source_file, output_file); @@ -697,7 +699,7 @@ string const InsetGraphics::prepareFile( << bformat(_("No conversion of %1$s is needed after all"), rel_file) << std::endl; - runparams.exportdata->addExternalFile("latex", to_file, + runparams.exportdata->addExternalFile(tex_format, to_file, output_to_file); runparams.exportdata->addExternalFile("dvi", to_file, output_to_file); @@ -711,7 +713,7 @@ string const InsetGraphics::prepareFile( << "\t from " << from << " to " << to << '\n'; 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); runparams.exportdata->addExternalFile("dvi", to_file, output_to_file); @@ -886,7 +888,7 @@ void InsetGraphics::validate(LaTeXFeatur features.require("graphicx"); - if (features.nice()) { + if (features.runparams().nice) { Buffer const * m_buffer = features.buffer().getMasterBuffer(); string basename = params().filename.outputFilename(m_buffer->filePath()); Index: src/insets/insetinclude.C =================================================================== --- src/insets/insetinclude.C (Revision 13742) +++ src/insets/insetinclude.C (Arbeitskopie) @@ -407,11 +407,13 @@ int InsetInclude::latex(Buffer const & b } } + string const tex_format = (runparams.flavor == OutputParams::LATEX) ? + "latex" : "pdflatex"; if (isVerbatim(params_)) { incfile = latex_path(incfile); os << '\\' << params_.getCmdName() << '{' << incfile << '}'; } else if (type(params_) == INPUT) { - runparams.exportdata->addExternalFile("latex", writefile, + runparams.exportdata->addExternalFile(tex_format, writefile, exportfile); // \input wants file with extension (default is .tex) @@ -426,7 +428,7 @@ int InsetInclude::latex(Buffer const & b << '}'; } } else { - runparams.exportdata->addExternalFile("latex", writefile, + runparams.exportdata->addExternalFile(tex_format, writefile, exportfile); // \include don't want extension and demands that the @@ -556,7 +558,7 @@ void InsetInclude::validate(LaTeXFeature else writefile = included_file; - if (!features.nice() && !isVerbatim(params_)) { + if (!features.runparams().nice && !isVerbatim(params_)) { incfile = FileName(writefile).mangledFilename(); writefile = MakeAbsPath(incfile, buffer.getMasterBuffer()->temppath()); Index: src/BufferView_pimpl.C =================================================================== --- src/BufferView_pimpl.C (Revision 13742) +++ src/BufferView_pimpl.C (Arbeitskopie) @@ -1072,7 +1072,8 @@ FuncStatus BufferView::Pimpl::getStatus( break; 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 && features.isAvailable("dvipost")); flag.setOnOff(buffer_->params().output_changes); Index: src/paragraph_pimpl.C =================================================================== --- src/paragraph_pimpl.C (Revision 13742) +++ src/paragraph_pimpl.C (Arbeitskopie) @@ -540,7 +540,7 @@ void Paragraph::Pimpl::simpleTeXSpecialC // output change tracking marks only if desired, // if dvipost is installed, // 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 && runparams.flavor == OutputParams::LATEX && features.isAvailable("dvipost"); Index: src/exporter.C =================================================================== --- src/exporter.C (Revision 13742) +++ src/exporter.C (Arbeitskopie) @@ -58,8 +58,12 @@ namespace { vector<string> const Backends(Buffer const & buffer) { vector<string> v; - if (buffer.params().getLyXTextClass().isTeXClassAvailable()) + if (buffer.params().getLyXTextClass().isTeXClassAvailable()) { 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("lyx"); return v; @@ -169,8 +173,12 @@ bool Exporter::Export(Buffer * buffer, s formats.prettyName(format))); return false; } - } else + } else { 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); filename = AddName(buffer->temppath(), filename); Index: src/LaTeXFeatures.h =================================================================== --- src/LaTeXFeatures.h (Revision 13742) +++ src/LaTeXFeatures.h (Arbeitskopie) @@ -14,6 +14,8 @@ #define LATEXFEATURES_H +#include "outputparams.h" + #include <set> #include <list> #include <map> @@ -39,7 +41,8 @@ class Language; class LaTeXFeatures { public: /// - LaTeXFeatures(Buffer const &, BufferParams const &, bool); + LaTeXFeatures(Buffer const &, BufferParams const &, + OutputParams const &); /// The packages needed by the document std::string const getPackages() const; /// The macros definitions needed by the document @@ -88,8 +91,8 @@ public: BufferParams const & bufferParams() const; /// the return value is dependent upon both LyXRC and LaTeXFeatures. bool useBabel() const; - /// - bool nice() const { return nice_; }; + /// Runparams that will be used for exporting this file. + OutputParams const & runparams() const { return runparams_; } private: std::list<std::string> usedLayouts_; @@ -124,10 +127,10 @@ private: Buffer const * buffer_; /// BufferParams const & params_; - /** If we are writing a nice LaTeX file or not. - * Only needed by InsetInclude::validate(). + /** Some insets need to know details about the to-be-produced file + * in validate(). */ - bool nice_; + OutputParams const & runparams_; }; #endif Index: src/buffer.C =================================================================== --- src/buffer.C (Revision 13742) +++ src/buffer.C (Arbeitskopie) @@ -833,7 +833,7 @@ void Buffer::makeLaTeXFile(ostream & os, // validate the buffer. lyxerr[Debug::LATEX] << " Validating buffer..." << endl; - LaTeXFeatures features(*this, params(), runparams.nice); + LaTeXFeatures features(*this, params(), runparams); validate(features); lyxerr[Debug::LATEX] << " Buffer validation done." << endl; @@ -986,7 +986,7 @@ void Buffer::makeLinuxDocFile(string con if (!openFileWrite(ofs, fname)) return; - LaTeXFeatures features(*this, params(), runparams.nice); + LaTeXFeatures features(*this, params(), runparams); validate(features); texrow().reset(); @@ -1044,7 +1044,7 @@ void Buffer::makeDocBookFile(string cons if (!openFileWrite(ofs, fname)) return; - LaTeXFeatures features(*this, params(), runparams.nice); + LaTeXFeatures features(*this, params(), runparams); validate(features); texrow().reset(); Index: src/paragraph.C =================================================================== --- src/paragraph.C (Revision 13742) +++ src/paragraph.C (Arbeitskopie) @@ -885,7 +885,7 @@ bool Paragraph::simpleTeXOnePar(Buffer c LyXFont basefont; - LaTeXFeatures features(buf, bparams, runparams.nice); + LaTeXFeatures features(buf, bparams, runparams); // output change tracking marks only if desired, // if dvipost is installed, Index: lib/external_templates =================================================================== --- lib/external_templates (Revision 13742) +++ lib/external_templates (Arbeitskopie) @@ -82,7 +82,7 @@ Template RasterImage UpdateFormat png UpdateResult "$$AbsPath$$Basename.png" Requirement "graphicx" - ReferencedFile latex "$$AbsPath$$Basename.png" + ReferencedFile pdflatex "$$AbsPath$$Basename.png" FormatEnd Format Ascii Product "$$Contents(\"$$AbsPath$$Basename.asc\")" @@ -134,8 +134,8 @@ Template XFig Requirement "graphicx" # Preamble WarnNotFound # Preamble InputOrWarn - ReferencedFile latex "$$AbsOrRelPathMaster$$Basename.pdftex_t" - ReferencedFile latex "$$AbsPath$$Basename.pdf" + ReferencedFile pdflatex "$$AbsOrRelPathMaster$$Basename.pdftex_t" + ReferencedFile pdflatex "$$AbsPath$$Basename.pdf" FormatEnd Format Ascii Product "$$Contents(\"$$AbsPath$$Basename.asc\")" @@ -184,6 +184,11 @@ Template ChessDiagram Requirement "chess" ReferencedFile latex "$$AbsPath$$Basename$$Extension" FormatEnd + Format PDFLaTeX + Product "\\loadgame{$$AbsOrRelPathMaster$$Basename}\\showboard" + Requirement "chess" + ReferencedFile pdflatex "$$AbsPath$$Basename$$Extension" + FormatEnd Format Ascii Product "$$Contents(\"$$AbsPath$$Basename.asc\")" UpdateFormat asciichess @@ -212,6 +217,11 @@ Template Date UpdateFormat dateout UpdateResult "$$Tempname" FormatEnd + Format PDFLaTeX + Product "$$Contents(\"$$Tempname\")" + UpdateFormat dateout + UpdateResult "$$Tempname" + FormatEnd Format Ascii Product "$$Contents(\"$$Tempname\")" UpdateFormat dateout Index: lib/configure.py =================================================================== --- lib/configure.py (Revision 13743) +++ lib/configure.py (Arbeitskopie) @@ -223,8 +223,9 @@ def checkFormatEntries(): \Format docbook sgml DocBook B "" "%%" \Format docbook-xml xml "Docbook (XML)" "" "" "%%" \Format literate nw NoWeb N "" "%%" -\Format latex tex LaTeX L "" "%%" +\Format latex tex "TeX (latex)" l "" "%%" \Format linuxdoc sgml LinuxDoc x "" "%%" +\Format pdflatex tex "TeX (pdflatex)" "" "" "%%" \Format text txt "Plain text" a "" "%%" \Format textparagraph txt "Plain text (paragraphs)" "" "" "%%"''' ]) # @@ -264,7 +265,7 @@ def checkFormatEntries(): def checkConverterEntries(): ''' Check all converters (\converter entries) ''' checkProg('the pdflatex program', ['pdflatex $$i'], - rc_entry = [ r'\converter latex pdf2 "%%" "latex"' ]) + rc_entry = [ r'\converter pdflatex pdf2 "%%" "latex"' ]) ''' If we're running LyX in-place then tex2lyx will be found in ../src/tex2lyx. Add this directory to the PATH temporarily and