From 7e9bd4bd81ed3a7bf501d69183b2a75a2ac40a05 Mon Sep 17 00:00:00 2001 From: Georg Baum Date: Wed, 26 Apr 2006 11:44:26 +0000 Subject: [PATCH] =?UTF-8?q?Fix=20bug=202107:=20=C2=A0=20=C2=A0=20=C2=A0=20?= =?UTF-8?q?=C2=A0=20*=20src/LaTeXFeatures.[Ch]:=20replace=20nice=5F=20by?= =?UTF-8?q?=20runparams=5F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit         * 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/branches/BRANCH_1_4_X@13745 a592a061-630c-0410-9148-cb99ea01b6c8 --- lib/configure.py | 5 +++-- lib/external_templates | 16 +++++++++++++--- src/BufferView_pimpl.C | 3 ++- src/LaTeXFeatures.C | 5 +++-- src/LaTeXFeatures.h | 15 +++++++++------ src/buffer.C | 6 +++--- src/exporter.C | 12 ++++++++++-- src/insets/insetexternal.C | 15 +++++++++++++-- src/insets/insetgraphics.C | 16 +++++++++------- src/insets/insetinclude.C | 8 +++++--- src/paragraph.C | 2 +- src/paragraph_pimpl.C | 2 +- status.14x | 6 ++++++ 13 files changed, 78 insertions(+), 33 deletions(-) diff --git a/lib/configure.py b/lib/configure.py index 4cf0b845e5..7cef2fe989 100644 --- a/lib/configure.py +++ b/lib/configure.py @@ -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 "LaTeX (plain)" L "" "%%" \Format linuxdoc sgml LinuxDoc x "" "%%" +\Format pdflatex tex "LaTeX (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 diff --git a/lib/external_templates b/lib/external_templates index c552511a46..f58404e641 100644 --- a/lib/external_templates +++ b/lib/external_templates @@ -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 diff --git a/src/BufferView_pimpl.C b/src/BufferView_pimpl.C index d1529f798e..7578634399 100644 --- a/src/BufferView_pimpl.C +++ b/src/BufferView_pimpl.C @@ -1072,7 +1072,8 @@ FuncStatus BufferView::Pimpl::getStatus(FuncRequest const & cmd) 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); diff --git a/src/LaTeXFeatures.C b/src/LaTeXFeatures.C index 36fdeb295e..ed3969ce60 100644 --- a/src/LaTeXFeatures.C +++ b/src/LaTeXFeatures.C @@ -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) {} diff --git a/src/LaTeXFeatures.h b/src/LaTeXFeatures.h index 0b4d6cd0ec..56930afadc 100644 --- a/src/LaTeXFeatures.h +++ b/src/LaTeXFeatures.h @@ -14,6 +14,8 @@ #define LATEXFEATURES_H +#include "outputparams.h" + #include #include #include @@ -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 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 diff --git a/src/buffer.C b/src/buffer.C index 5abf1f6dda..337783a453 100644 --- a/src/buffer.C +++ b/src/buffer.C @@ -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 const & fname, 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 const & fname, if (!openFileWrite(ofs, fname)) return; - LaTeXFeatures features(*this, params(), runparams.nice); + LaTeXFeatures features(*this, params(), runparams); validate(features); texrow().reset(); diff --git a/src/exporter.C b/src/exporter.C index 57aca837ea..154ef8cb12 100644 --- a/src/exporter.C +++ b/src/exporter.C @@ -58,8 +58,12 @@ namespace { vector const Backends(Buffer const & buffer) { vector 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, string const & format, 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); diff --git a/src/insets/insetexternal.C b/src/insets/insetexternal.C index 61cc1dca28..e6b1f89ced 100644 --- a/src/insets/insetexternal.C +++ b/src/insets/insetexternal.C @@ -753,9 +753,20 @@ void InsetExternal::validate(LaTeXFeatures & features) const 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; diff --git a/src/insets/insetgraphics.C b/src/insets/insetgraphics.C index 017ce426eb..185911e2ee 100644 --- a/src/insets/insetgraphics.C +++ b/src/insets/insetgraphics.C @@ -607,6 +607,8 @@ string const InsetGraphics::prepareFile(Buffer const & buf, 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(Buffer const & buf, 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(Buffer const & buf, 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(Buffer const & buf, 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(Buffer const & buf, << 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(Buffer const & buf, << "\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(LaTeXFeatures & features) const 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()); diff --git a/src/insets/insetinclude.C b/src/insets/insetinclude.C index ea9c3f6028..3212cf50fa 100644 --- a/src/insets/insetinclude.C +++ b/src/insets/insetinclude.C @@ -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_)) { 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 & buffer, ostream & os, << '}'; } } 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(LaTeXFeatures & features) const 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()); diff --git a/src/paragraph.C b/src/paragraph.C index 5904e014cd..6031f231d1 100644 --- a/src/paragraph.C +++ b/src/paragraph.C @@ -885,7 +885,7 @@ bool Paragraph::simpleTeXOnePar(Buffer const & buf, LyXFont basefont; - LaTeXFeatures features(buf, bparams, runparams.nice); + LaTeXFeatures features(buf, bparams, runparams); // output change tracking marks only if desired, // if dvipost is installed, diff --git a/src/paragraph_pimpl.C b/src/paragraph_pimpl.C index 90c923880b..05747d4f43 100644 --- a/src/paragraph_pimpl.C +++ b/src/paragraph_pimpl.C @@ -540,7 +540,7 @@ void Paragraph::Pimpl::simpleTeXSpecialChars(Buffer const & buf, // 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"); diff --git a/status.14x b/status.14x index 3522bb8a2c..c49383e9b1 100644 --- a/status.14x +++ b/status.14x @@ -26,6 +26,10 @@ What's new - add support for Austrian (new spelling) as document language. +- add "LaTeX (pdflatex)" output format. This new output format produces + .tex files that are suitable for pdflatex, including figure conversion + to png, pdf or jpeg instead of eps. + ** Bug fixes * Document input/output: @@ -39,6 +43,8 @@ What's new - Don't get confused by 0-Characters in MikTeX logfiles anymore +- Always honor the "Requirement" tag in External Template Definitions + * Math editor: - Fix metrics of AMS array environments like bmatrix, vmatrix etc. (bug 2036)