mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-11 19:14:51 +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>
|
2004-04-01 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
|
||||||
|
|
||||||
* help/ and contents is gone (outdated).
|
* help/ and contents is gone (outdated).
|
||||||
|
@ -35,14 +35,14 @@ PreambleDefEnd
|
|||||||
|
|
||||||
|
|
||||||
Template RasterImage
|
Template RasterImage
|
||||||
GuiName "Bitmap: $$Basename"
|
GuiName "Bitmap: $$AbsOrRelPathParent$$Basename"
|
||||||
HelpText
|
HelpText
|
||||||
A bitmap file.
|
A bitmap file.
|
||||||
This template uses Gimp for editing.
|
This template uses Gimp for editing.
|
||||||
HelpTextEnd
|
HelpTextEnd
|
||||||
InputFormat "*"
|
InputFormat "*"
|
||||||
FileFilter "*.{gif,png,jpg,bmp,pbm,ppm,tga,tif,xpm,xbm}"
|
FileFilter "*.{gif,png,jpg,bmp,pbm,ppm,tga,tif,xpm,xbm}"
|
||||||
EditCommand "gimp $$FName"
|
EditCommand "gimp $$Absname"
|
||||||
AutomaticProduction true
|
AutomaticProduction true
|
||||||
Transform Rotate
|
Transform Rotate
|
||||||
Transform Resize
|
Transform Resize
|
||||||
@ -54,9 +54,9 @@ Template RasterImage
|
|||||||
TransformOption Clip ClipLatexOption
|
TransformOption Clip ClipLatexOption
|
||||||
TransformOption Extra ExtraOption
|
TransformOption Extra ExtraOption
|
||||||
Option Arg "[$$Extra,$$Rotate,$$Resize,$$Clip]"
|
Option Arg "[$$Extra,$$Rotate,$$Resize,$$Clip]"
|
||||||
Product "\\includegraphics$$Arg{$$Basename}"
|
Product "\\includegraphics$$Arg{$$AbsOrRelPathMaster$$Basename}"
|
||||||
UpdateFormat eps
|
UpdateFormat eps
|
||||||
UpdateResult "$$Basename.eps"
|
UpdateResult "$$AbsPath$$Basename.eps"
|
||||||
Requirement "graphicx"
|
Requirement "graphicx"
|
||||||
FormatEnd
|
FormatEnd
|
||||||
Format PDFLaTeX
|
Format PDFLaTeX
|
||||||
@ -65,20 +65,20 @@ Template RasterImage
|
|||||||
TransformOption Clip ClipLatexOption
|
TransformOption Clip ClipLatexOption
|
||||||
TransformOption Extra ExtraOption
|
TransformOption Extra ExtraOption
|
||||||
Option Arg "[$$Extra,$$Rotate,$$Resize,$$Clip]"
|
Option Arg "[$$Extra,$$Rotate,$$Resize,$$Clip]"
|
||||||
Product "\\includegraphics$$Arg{$$Basename}"
|
Product "\\includegraphics$$Arg{$$AbsOrRelPathMaster$$Basename}"
|
||||||
UpdateFormat png
|
UpdateFormat png
|
||||||
UpdateResult "$$Basename.png"
|
UpdateResult "$$AbsPath$$Basename.png"
|
||||||
Requirement "graphicx"
|
Requirement "graphicx"
|
||||||
FormatEnd
|
FormatEnd
|
||||||
Format Ascii
|
Format Ascii
|
||||||
Product "$$Contents(\"$$Basename.asc\")"
|
Product "$$Contents(\"$$AbsPath$$Basename.asc\")"
|
||||||
UpdateFormat asciiimage
|
UpdateFormat asciiimage
|
||||||
UpdateResult "$$Basename.asc"
|
UpdateResult "$$AbsPath$$Basename.asc"
|
||||||
FormatEnd
|
FormatEnd
|
||||||
Format DocBook
|
Format DocBook
|
||||||
Product "<graphic fileref=\"$$Basename.eps\"></graphic>"
|
Product "<graphic fileref=\"$$AbsOrRelPathMaster$$Basename.eps\"></graphic>"
|
||||||
UpdateFormat eps
|
UpdateFormat eps
|
||||||
UpdateResult "$$Basename.eps"
|
UpdateResult "$$AbsPath$$Basename.eps"
|
||||||
FormatEnd
|
FormatEnd
|
||||||
Format LinuxDoc
|
Format LinuxDoc
|
||||||
Product "[Bitmap: $$FName]"
|
Product "[Bitmap: $$FName]"
|
||||||
@ -87,23 +87,23 @@ TemplateEnd
|
|||||||
|
|
||||||
|
|
||||||
Template XFig
|
Template XFig
|
||||||
GuiName "XFig: $$Basename"
|
GuiName "XFig: $$AbsOrRelPathParent$$Basename"
|
||||||
HelpText
|
HelpText
|
||||||
An XFig figure.
|
An XFig figure.
|
||||||
This template uses XFig for editing.
|
This template uses XFig for editing.
|
||||||
HelpTextEnd
|
HelpTextEnd
|
||||||
InputFormat fig
|
InputFormat fig
|
||||||
FileFilter "*.fig"
|
FileFilter "*.fig"
|
||||||
EditCommand "xfig $$FName"
|
EditCommand "xfig $$Absname"
|
||||||
AutomaticProduction true
|
AutomaticProduction true
|
||||||
Transform Rotate
|
Transform Rotate
|
||||||
Transform Resize
|
Transform Resize
|
||||||
Format LaTeX
|
Format LaTeX
|
||||||
TransformCommand Rotate RotationLatexCommand
|
TransformCommand Rotate RotationLatexCommand
|
||||||
TransformCommand Resize ResizeLatexCommand
|
TransformCommand Resize ResizeLatexCommand
|
||||||
Product "$$RotateFront$$ResizeFront\\input{$$Basename.pstex_t}$$ResizeBack$$RotateBack"
|
Product "$$RotateFront$$ResizeFront\\input{$$AbsOrRelPathMaster$$Basename.pstex_t}$$ResizeBack$$RotateBack"
|
||||||
UpdateFormat pstex
|
UpdateFormat pstex
|
||||||
UpdateResult "$$Basename.pstex_t"
|
UpdateResult "$$AbsPath$$Basename.pstex_t"
|
||||||
Requirement "graphicx"
|
Requirement "graphicx"
|
||||||
Preamble WarnNotFound
|
Preamble WarnNotFound
|
||||||
Preamble InputOrWarn
|
Preamble InputOrWarn
|
||||||
@ -111,22 +111,22 @@ Template XFig
|
|||||||
Format PDFLaTeX
|
Format PDFLaTeX
|
||||||
TransformCommand Rotate RotationLatexCommand
|
TransformCommand Rotate RotationLatexCommand
|
||||||
TransformCommand Resize ResizeLatexCommand
|
TransformCommand Resize ResizeLatexCommand
|
||||||
Product "$$RotateFront$$ResizeFront\\input{$$Basename.pdftex_t}$$ResizeBack$$RotateBack"
|
Product "$$RotateFront$$ResizeFront\\input{$$AbsOrRelPathMaster$$Basename.pdftex_t}$$ResizeBack$$RotateBack"
|
||||||
UpdateFormat pdftex
|
UpdateFormat pdftex
|
||||||
UpdateResult "$$Basename.pdftex_t"
|
UpdateResult "$$AbsPath$$Basename.pdftex_t"
|
||||||
Requirement "graphicx"
|
Requirement "graphicx"
|
||||||
Preamble WarnNotFound
|
Preamble WarnNotFound
|
||||||
Preamble InputOrWarn
|
Preamble InputOrWarn
|
||||||
FormatEnd
|
FormatEnd
|
||||||
Format Ascii
|
Format Ascii
|
||||||
Product "$$Contents(\"$$Basename.asc\")"
|
Product "$$Contents(\"$$AbsPath$$Basename.asc\")"
|
||||||
UpdateFormat asciixfig
|
UpdateFormat asciixfig
|
||||||
UpdateResult "$$Basename.asc"
|
UpdateResult "$$AbsPath$$Basename.asc"
|
||||||
FormatEnd
|
FormatEnd
|
||||||
Format DocBook
|
Format DocBook
|
||||||
Product "<graphic fileref=\"$$Basename.eps\"></graphic>"
|
Product "<graphic fileref=\"$$AbsOrRelPathMaster$$Basename.eps\"></graphic>"
|
||||||
UpdateFormat eps
|
UpdateFormat eps
|
||||||
UpdateResult "$$Basename.eps"
|
UpdateResult "$$AbsPath$$Basename.eps"
|
||||||
FormatEnd
|
FormatEnd
|
||||||
Format LinuxDoc
|
Format LinuxDoc
|
||||||
Product "[XFig: $$FName]"
|
Product "[XFig: $$FName]"
|
||||||
@ -135,7 +135,7 @@ TemplateEnd
|
|||||||
|
|
||||||
|
|
||||||
Template ChessDiagram
|
Template ChessDiagram
|
||||||
GuiName "Chess: $$Basename"
|
GuiName "Chess: $$AbsOrRelPathParent$$Basename"
|
||||||
HelpText
|
HelpText
|
||||||
A chess position diagram.
|
A chess position diagram.
|
||||||
This template will use XBoard to edit the position.
|
This template will use XBoard to edit the position.
|
||||||
@ -157,19 +157,19 @@ Template ChessDiagram
|
|||||||
HelpTextEnd
|
HelpTextEnd
|
||||||
InputFormat fen
|
InputFormat fen
|
||||||
FileFilter "*.fen"
|
FileFilter "*.fen"
|
||||||
EditCommand "xboard -lpf $$FName -mode EditPosition"
|
EditCommand "xboard -lpf $$Absname -mode EditPosition"
|
||||||
AutomaticProduction true
|
AutomaticProduction true
|
||||||
Format LaTeX
|
Format LaTeX
|
||||||
Product "\\loadgame{$$FPath$$Basename}\\showboard"
|
Product "\\loadgame{$$AbsOrRelPathMaster$$Basename}\\showboard"
|
||||||
Requirement "chess"
|
Requirement "chess"
|
||||||
FormatEnd
|
FormatEnd
|
||||||
Format Ascii
|
Format Ascii
|
||||||
Product "$$Contents(\"$$Basename.asc\")"
|
Product "$$Contents(\"$$AbsPath$$Basename.asc\")"
|
||||||
UpdateFormat asciichess
|
UpdateFormat asciichess
|
||||||
UpdateResult "$$Basename.asc"
|
UpdateResult "$$AbsPath$$Basename.asc"
|
||||||
FormatEnd
|
FormatEnd
|
||||||
Format DocBook
|
Format DocBook
|
||||||
Product "[Chess: $$Basename]"
|
Product "[Chess: $$AbsOrRelPathMaster$$Basename]"
|
||||||
FormatEnd
|
FormatEnd
|
||||||
Format LinuxDoc
|
Format LinuxDoc
|
||||||
Product "[Chess: $$FName]"
|
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>
|
2004-04-05 André Pönitz <poenitz@gmx.net>
|
||||||
|
|
||||||
|
@ -73,17 +73,51 @@ void editExternal(InsetExternalParams const & params, Buffer const & buffer)
|
|||||||
|
|
||||||
namespace {
|
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,
|
string const doSubstitution(InsetExternalParams const & params,
|
||||||
Buffer const & buffer, string const & s,
|
Buffer const & buffer, string const & s,
|
||||||
string const & filename)
|
string const & filename)
|
||||||
{
|
{
|
||||||
string result;
|
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 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(s, "$$FName", filename);
|
||||||
result = support::subst(result, "$$Basename", basename);
|
result = support::subst(result, "$$Basename", basename);
|
||||||
|
result = support::subst(result, "$$Extension",
|
||||||
|
'.' + support::GetExtension(filename));
|
||||||
result = support::subst(result, "$$FPath", filepath);
|
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, "$$Tempname", params.tempname());
|
||||||
result = support::subst(result, "$$Sysdir", support::system_lyxdir());
|
result = support::subst(result, "$$Sysdir", support::system_lyxdir());
|
||||||
|
|
||||||
@ -96,7 +130,7 @@ string const doSubstitution(InsetExternalParams const & params,
|
|||||||
string contents;
|
string contents;
|
||||||
|
|
||||||
string const filepath = support::IsFileReadable(file) ?
|
string const filepath = support::IsFileReadable(file) ?
|
||||||
buffer.filePath() : buffer.getMasterBuffer()->temppath();
|
buffer.filePath() : m_buffer->temppath();
|
||||||
support::Path p(filepath);
|
support::Path p(filepath);
|
||||||
|
|
||||||
if (support::IsFileReadable(file))
|
if (support::IsFileReadable(file))
|
||||||
@ -139,16 +173,17 @@ void updateExternal(InsetExternalParams const & params,
|
|||||||
if (from_format.empty())
|
if (from_format.empty())
|
||||||
return; // NOT_NEEDED
|
return; // NOT_NEEDED
|
||||||
|
|
||||||
string from_file = params.filename.absFilename();
|
string abs_from_file = params.filename.absFilename();
|
||||||
|
|
||||||
if (from_format == "*") {
|
if (from_format == "*") {
|
||||||
if (from_file.empty())
|
if (abs_from_file.empty())
|
||||||
return; // NOT_NEEDED
|
return; // NOT_NEEDED
|
||||||
|
|
||||||
// Try and ascertain the file format from its contents.
|
// 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())
|
if (from_format.empty())
|
||||||
return; // FAILURE
|
return; // FAILURE
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
string const to_format = outputFormat.updateFormat;
|
string const to_format = outputFormat.updateFormat;
|
||||||
@ -163,24 +198,32 @@ void updateExternal(InsetExternalParams const & params,
|
|||||||
return; // FAILURE
|
return; // FAILURE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string from_file = params.filename.outputFilename(buffer.filePath());
|
||||||
|
|
||||||
// The master buffer. This is useful when there are multiple levels
|
// The master buffer. This is useful when there are multiple levels
|
||||||
// of include files
|
// of include files
|
||||||
Buffer const * m_buffer = buffer.getMasterBuffer();
|
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
|
// We are running stuff through LaTeX
|
||||||
string const temp_file =
|
string const temp_file =
|
||||||
support::MakeAbsPath(params.filename.mangledFilename(),
|
support::MakeAbsPath(params.filename.mangledFilename(),
|
||||||
m_buffer->temppath());
|
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);
|
unsigned long const temp_checksum = support::sum(temp_file);
|
||||||
|
|
||||||
if (from_checksum != temp_checksum) {
|
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
|
return; // FAILURE
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
from_file = temp_file;
|
from_file = temp_file;
|
||||||
|
abs_from_file = temp_file;
|
||||||
}
|
}
|
||||||
|
|
||||||
string const to_file = doSubstitution(params, buffer,
|
string const to_file = doSubstitution(params, buffer,
|
||||||
@ -194,13 +237,13 @@ void updateExternal(InsetExternalParams const & params,
|
|||||||
|
|
||||||
// Do we need to perform the conversion?
|
// Do we need to perform the conversion?
|
||||||
// Yes if to_file does not exist or if from_file is newer than to_file
|
// 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
|
return; // SUCCESS
|
||||||
|
|
||||||
string const to_file_base =
|
string const to_file_base =
|
||||||
support::ChangeExtension(to_file, string());
|
support::ChangeExtension(to_file, string());
|
||||||
/* bool const success = */
|
/* bool const success = */
|
||||||
converters.convert(&buffer, from_file, to_file_base,
|
converters.convert(&buffer, abs_from_file, to_file_base,
|
||||||
from_format, to_format);
|
from_format, to_format);
|
||||||
// return success
|
// return success
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user