mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
Georg's latest contribution to squashing bug 605.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8615 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
57501b9306
commit
dcd66fa802
@ -1,3 +1,8 @@
|
||||
2004-04-06 Georg Baum <Georg.Baum@post.rwth-aachen.de>
|
||||
|
||||
* external_templates: use some new variables instead of $$Basename
|
||||
(needed to fix bug #605)
|
||||
|
||||
2004-04-01 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
|
||||
|
||||
* help/ and contents is gone (outdated).
|
||||
|
@ -35,14 +35,14 @@ PreambleDefEnd
|
||||
|
||||
|
||||
Template RasterImage
|
||||
GuiName "Bitmap: $$Basename"
|
||||
GuiName "Bitmap: $$AbsOrRelPathParent$$Basename"
|
||||
HelpText
|
||||
A bitmap file.
|
||||
This template uses Gimp for editing.
|
||||
HelpTextEnd
|
||||
InputFormat "*"
|
||||
FileFilter "*.{gif,png,jpg,bmp,pbm,ppm,tga,tif,xpm,xbm}"
|
||||
EditCommand "gimp $$FName"
|
||||
EditCommand "gimp $$Absname"
|
||||
AutomaticProduction true
|
||||
Transform Rotate
|
||||
Transform Resize
|
||||
@ -54,9 +54,9 @@ Template RasterImage
|
||||
TransformOption Clip ClipLatexOption
|
||||
TransformOption Extra ExtraOption
|
||||
Option Arg "[$$Extra,$$Rotate,$$Resize,$$Clip]"
|
||||
Product "\\includegraphics$$Arg{$$Basename}"
|
||||
Product "\\includegraphics$$Arg{$$AbsOrRelPathMaster$$Basename}"
|
||||
UpdateFormat eps
|
||||
UpdateResult "$$Basename.eps"
|
||||
UpdateResult "$$AbsPath$$Basename.eps"
|
||||
Requirement "graphicx"
|
||||
FormatEnd
|
||||
Format PDFLaTeX
|
||||
@ -65,20 +65,20 @@ Template RasterImage
|
||||
TransformOption Clip ClipLatexOption
|
||||
TransformOption Extra ExtraOption
|
||||
Option Arg "[$$Extra,$$Rotate,$$Resize,$$Clip]"
|
||||
Product "\\includegraphics$$Arg{$$Basename}"
|
||||
Product "\\includegraphics$$Arg{$$AbsOrRelPathMaster$$Basename}"
|
||||
UpdateFormat png
|
||||
UpdateResult "$$Basename.png"
|
||||
UpdateResult "$$AbsPath$$Basename.png"
|
||||
Requirement "graphicx"
|
||||
FormatEnd
|
||||
Format Ascii
|
||||
Product "$$Contents(\"$$Basename.asc\")"
|
||||
Product "$$Contents(\"$$AbsPath$$Basename.asc\")"
|
||||
UpdateFormat asciiimage
|
||||
UpdateResult "$$Basename.asc"
|
||||
UpdateResult "$$AbsPath$$Basename.asc"
|
||||
FormatEnd
|
||||
Format DocBook
|
||||
Product "<graphic fileref=\"$$Basename.eps\"></graphic>"
|
||||
Product "<graphic fileref=\"$$AbsOrRelPathMaster$$Basename.eps\"></graphic>"
|
||||
UpdateFormat eps
|
||||
UpdateResult "$$Basename.eps"
|
||||
UpdateResult "$$AbsPath$$Basename.eps"
|
||||
FormatEnd
|
||||
Format LinuxDoc
|
||||
Product "[Bitmap: $$FName]"
|
||||
@ -87,23 +87,23 @@ TemplateEnd
|
||||
|
||||
|
||||
Template XFig
|
||||
GuiName "XFig: $$Basename"
|
||||
GuiName "XFig: $$AbsOrRelPathParent$$Basename"
|
||||
HelpText
|
||||
An XFig figure.
|
||||
This template uses XFig for editing.
|
||||
HelpTextEnd
|
||||
InputFormat fig
|
||||
FileFilter "*.fig"
|
||||
EditCommand "xfig $$FName"
|
||||
EditCommand "xfig $$Absname"
|
||||
AutomaticProduction true
|
||||
Transform Rotate
|
||||
Transform Resize
|
||||
Format LaTeX
|
||||
TransformCommand Rotate RotationLatexCommand
|
||||
TransformCommand Resize ResizeLatexCommand
|
||||
Product "$$RotateFront$$ResizeFront\\input{$$Basename.pstex_t}$$ResizeBack$$RotateBack"
|
||||
Product "$$RotateFront$$ResizeFront\\input{$$AbsOrRelPathMaster$$Basename.pstex_t}$$ResizeBack$$RotateBack"
|
||||
UpdateFormat pstex
|
||||
UpdateResult "$$Basename.pstex_t"
|
||||
UpdateResult "$$AbsPath$$Basename.pstex_t"
|
||||
Requirement "graphicx"
|
||||
Preamble WarnNotFound
|
||||
Preamble InputOrWarn
|
||||
@ -111,22 +111,22 @@ Template XFig
|
||||
Format PDFLaTeX
|
||||
TransformCommand Rotate RotationLatexCommand
|
||||
TransformCommand Resize ResizeLatexCommand
|
||||
Product "$$RotateFront$$ResizeFront\\input{$$Basename.pdftex_t}$$ResizeBack$$RotateBack"
|
||||
Product "$$RotateFront$$ResizeFront\\input{$$AbsOrRelPathMaster$$Basename.pdftex_t}$$ResizeBack$$RotateBack"
|
||||
UpdateFormat pdftex
|
||||
UpdateResult "$$Basename.pdftex_t"
|
||||
UpdateResult "$$AbsPath$$Basename.pdftex_t"
|
||||
Requirement "graphicx"
|
||||
Preamble WarnNotFound
|
||||
Preamble InputOrWarn
|
||||
FormatEnd
|
||||
Format Ascii
|
||||
Product "$$Contents(\"$$Basename.asc\")"
|
||||
Product "$$Contents(\"$$AbsPath$$Basename.asc\")"
|
||||
UpdateFormat asciixfig
|
||||
UpdateResult "$$Basename.asc"
|
||||
UpdateResult "$$AbsPath$$Basename.asc"
|
||||
FormatEnd
|
||||
Format DocBook
|
||||
Product "<graphic fileref=\"$$Basename.eps\"></graphic>"
|
||||
Product "<graphic fileref=\"$$AbsOrRelPathMaster$$Basename.eps\"></graphic>"
|
||||
UpdateFormat eps
|
||||
UpdateResult "$$Basename.eps"
|
||||
UpdateResult "$$AbsPath$$Basename.eps"
|
||||
FormatEnd
|
||||
Format LinuxDoc
|
||||
Product "[XFig: $$FName]"
|
||||
@ -135,7 +135,7 @@ TemplateEnd
|
||||
|
||||
|
||||
Template ChessDiagram
|
||||
GuiName "Chess: $$Basename"
|
||||
GuiName "Chess: $$AbsOrRelPathParent$$Basename"
|
||||
HelpText
|
||||
A chess position diagram.
|
||||
This template will use XBoard to edit the position.
|
||||
@ -157,19 +157,19 @@ Template ChessDiagram
|
||||
HelpTextEnd
|
||||
InputFormat fen
|
||||
FileFilter "*.fen"
|
||||
EditCommand "xboard -lpf $$FName -mode EditPosition"
|
||||
EditCommand "xboard -lpf $$Absname -mode EditPosition"
|
||||
AutomaticProduction true
|
||||
Format LaTeX
|
||||
Product "\\loadgame{$$FPath$$Basename}\\showboard"
|
||||
Product "\\loadgame{$$AbsOrRelPathMaster$$Basename}\\showboard"
|
||||
Requirement "chess"
|
||||
FormatEnd
|
||||
Format Ascii
|
||||
Product "$$Contents(\"$$Basename.asc\")"
|
||||
Product "$$Contents(\"$$AbsPath$$Basename.asc\")"
|
||||
UpdateFormat asciichess
|
||||
UpdateResult "$$Basename.asc"
|
||||
UpdateResult "$$AbsPath$$Basename.asc"
|
||||
FormatEnd
|
||||
Format DocBook
|
||||
Product "[Chess: $$Basename]"
|
||||
Product "[Chess: $$AbsOrRelPathMaster$$Basename]"
|
||||
FormatEnd
|
||||
Format LinuxDoc
|
||||
Product "[Chess: $$FName]"
|
||||
|
@ -1,3 +1,11 @@
|
||||
2004-04-06 Georg Baum <Georg.Baum@post.rwth-aachen.de>
|
||||
|
||||
* ExternalSupport.C (doSubstitution): add new variables $$AbsPath,
|
||||
$$RelPath_Master, $$RelPath_Parent, $$Extension,
|
||||
$$AbsOrRelPath_Master and $$AbsOrRelPath_Parent. Change the meaning
|
||||
of $$Basename
|
||||
* ExternalSupport.C (updateExternal): use absolute and output
|
||||
filename where appropriate
|
||||
|
||||
2004-04-05 André Pönitz <poenitz@gmx.net>
|
||||
|
||||
|
@ -73,17 +73,51 @@ void editExternal(InsetExternalParams const & params, Buffer const & buffer)
|
||||
|
||||
namespace {
|
||||
|
||||
/** Substitute meta-variables in the string \p s.
|
||||
\p filename has to be the filename as read from the .lyx file (this
|
||||
can be an absolute path or a path relative to the parent document).
|
||||
Otherwise, the $$AbsOrRelPath* variables would not work.
|
||||
If we are using a temporary directory, \p filename is the mangled name.
|
||||
*/
|
||||
string const doSubstitution(InsetExternalParams const & params,
|
||||
Buffer const & buffer, string const & s,
|
||||
string const & filename)
|
||||
{
|
||||
string result;
|
||||
string const basename = support::ChangeExtension(filename, string());
|
||||
string const basename = support::ChangeExtension(
|
||||
support::OnlyFilename(filename), string());
|
||||
string const absname = support::MakeAbsPath(filename, buffer.filePath());
|
||||
string const filepath = support::OnlyPath(filename);
|
||||
string const abspath = support::OnlyPath(absname);
|
||||
Buffer const * m_buffer = buffer.getMasterBuffer();
|
||||
string relToMasterPath = support::OnlyPath(
|
||||
support::MakeRelPath(absname, m_buffer->filePath()));
|
||||
if (relToMasterPath == "./")
|
||||
relToMasterPath.clear();
|
||||
string relToParentPath = support::OnlyPath(
|
||||
support::MakeRelPath(absname, buffer.filePath()));
|
||||
if (relToParentPath == "./")
|
||||
relToParentPath.clear();
|
||||
|
||||
result = support::subst(s, "$$FName", filename);
|
||||
result = support::subst(result, "$$Basename", basename);
|
||||
result = support::subst(result, "$$Extension",
|
||||
'.' + support::GetExtension(filename));
|
||||
result = support::subst(result, "$$FPath", filepath);
|
||||
result = support::subst(result, "$$AbsPath", abspath);
|
||||
result = support::subst(result, "$$RelPathMaster", relToMasterPath);
|
||||
result = support::subst(result, "$$RelPathParent", relToParentPath);
|
||||
if (support::AbsolutePath(filename)) {
|
||||
result = support::subst(result, "$$AbsOrRelPathMaster",
|
||||
abspath);
|
||||
result = support::subst(result, "$$AbsOrRelPathParent",
|
||||
abspath);
|
||||
} else {
|
||||
result = support::subst(result, "$$AbsOrRelPathMaster",
|
||||
relToMasterPath);
|
||||
result = support::subst(result, "$$AbsOrRelPathParent",
|
||||
relToParentPath);
|
||||
}
|
||||
result = support::subst(result, "$$Tempname", params.tempname());
|
||||
result = support::subst(result, "$$Sysdir", support::system_lyxdir());
|
||||
|
||||
@ -96,7 +130,7 @@ string const doSubstitution(InsetExternalParams const & params,
|
||||
string contents;
|
||||
|
||||
string const filepath = support::IsFileReadable(file) ?
|
||||
buffer.filePath() : buffer.getMasterBuffer()->temppath();
|
||||
buffer.filePath() : m_buffer->temppath();
|
||||
support::Path p(filepath);
|
||||
|
||||
if (support::IsFileReadable(file))
|
||||
@ -139,16 +173,17 @@ void updateExternal(InsetExternalParams const & params,
|
||||
if (from_format.empty())
|
||||
return; // NOT_NEEDED
|
||||
|
||||
string from_file = params.filename.absFilename();
|
||||
string abs_from_file = params.filename.absFilename();
|
||||
|
||||
if (from_format == "*") {
|
||||
if (from_file.empty())
|
||||
if (abs_from_file.empty())
|
||||
return; // NOT_NEEDED
|
||||
|
||||
// Try and ascertain the file format from its contents.
|
||||
from_format = support::getExtFromContents(from_file);
|
||||
from_format = support::getExtFromContents(abs_from_file);
|
||||
if (from_format.empty())
|
||||
return; // FAILURE
|
||||
|
||||
}
|
||||
|
||||
string const to_format = outputFormat.updateFormat;
|
||||
@ -163,24 +198,32 @@ void updateExternal(InsetExternalParams const & params,
|
||||
return; // FAILURE
|
||||
}
|
||||
|
||||
string from_file = params.filename.outputFilename(buffer.filePath());
|
||||
|
||||
// The master buffer. This is useful when there are multiple levels
|
||||
// of include files
|
||||
Buffer const * m_buffer = buffer.getMasterBuffer();
|
||||
|
||||
if (external_in_tmpdir && !from_file.empty()) {
|
||||
if (external_in_tmpdir && !abs_from_file.empty()) {
|
||||
// We are running stuff through LaTeX
|
||||
string const temp_file =
|
||||
support::MakeAbsPath(params.filename.mangledFilename(),
|
||||
m_buffer->temppath());
|
||||
unsigned long const from_checksum = support::sum(from_file);
|
||||
unsigned long const from_checksum = support::sum(abs_from_file);
|
||||
unsigned long const temp_checksum = support::sum(temp_file);
|
||||
|
||||
if (from_checksum != temp_checksum) {
|
||||
if (!support::copy(from_file, temp_file))
|
||||
if (!support::copy(abs_from_file, temp_file)) {
|
||||
lyxerr[Debug::EXTERNAL]
|
||||
<< "external::updateExternal. "
|
||||
<< "Unable to copy "
|
||||
<< abs_from_file << " to " << temp_file << endl;
|
||||
return; // FAILURE
|
||||
}
|
||||
}
|
||||
|
||||
from_file = temp_file;
|
||||
abs_from_file = temp_file;
|
||||
}
|
||||
|
||||
string const to_file = doSubstitution(params, buffer,
|
||||
@ -194,13 +237,13 @@ void updateExternal(InsetExternalParams const & params,
|
||||
|
||||
// Do we need to perform the conversion?
|
||||
// Yes if to_file does not exist or if from_file is newer than to_file
|
||||
if (support::compare_timestamps(from_file, abs_to_file) < 0)
|
||||
if (support::compare_timestamps(abs_from_file, abs_to_file) < 0)
|
||||
return; // SUCCESS
|
||||
|
||||
string const to_file_base =
|
||||
support::ChangeExtension(to_file, string());
|
||||
/* bool const success = */
|
||||
converters.convert(&buffer, from_file, to_file_base,
|
||||
converters.convert(&buffer, abs_from_file, to_file_base,
|
||||
from_format, to_format);
|
||||
// return success
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user