mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-24 21:55:29 +00:00
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:
parent
149c83d35d
commit
fc7f2d9805
@ -224,7 +224,7 @@ if LATEX != 'none':
|
||||
removeFiles(['chklatex.ltx', 'chklatex.log'])
|
||||
|
||||
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'],
|
||||
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-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)" "" "" "%%"''' ])
|
||||
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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)
|
||||
{}
|
||||
|
||||
|
||||
|
@ -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
|
||||
|
@ -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();
|
||||
|
@ -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, 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);
|
||||
|
@ -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;
|
||||
|
||||
|
@ -607,6 +607,8 @@ string const InsetGraphics::prepareFile(Buffer const & buf,
|
||||
params().filename.outputFilename(m_buffer->filePath()) :
|
||||
OnlyFilename(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 (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);
|
||||
@ -678,7 +680,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);
|
||||
@ -695,7 +697,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);
|
||||
@ -709,7 +711,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);
|
||||
@ -884,7 +886,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());
|
||||
|
@ -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());
|
||||
|
@ -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,
|
||||
|
@ -531,7 +531,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");
|
||||
|
Loading…
Reference in New Issue
Block a user