fix export in insetgraphics and insetexternal

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9476 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Georg Baum 2005-01-14 08:52:35 +00:00
parent b4c186e11e
commit 4d0cbd59af
4 changed files with 77 additions and 39 deletions

View File

@ -1,3 +1,11 @@
2005-01-11 Georg Baum <Georg.Baum@post.rwth-aachen.de>
* insetgraphics.C (prepareFile): add missing calls to addExternalFile
* updateExternal.[Ch] (doSubstitution): take a new parameter that
determines what variables are substituted
* updateExternal.C (updateExternal): fix substitution of
ReferencedFiles
2005-01-10 Angus Leeming <leeming@lyx.org>
* ExternalTemplate.C: use support/package.h to provide the paths to the

View File

@ -62,7 +62,8 @@ void editExternal(InsetExternalParams const & params, Buffer const & buffer)
string const doSubstitution(InsetExternalParams const & params,
Buffer const & buffer, string const & s,
bool external_in_tmpdir)
bool external_in_tmpdir,
Substitute what)
{
Buffer const * m_buffer = buffer.getMasterBuffer();
string const parentpath = external_in_tmpdir ?
@ -71,10 +72,12 @@ string const doSubstitution(InsetExternalParams const & params,
string const filename = external_in_tmpdir ?
params.filename.mangledFilename() :
params.filename.outputFilename(parentpath);
string result;
string const basename = support::ChangeExtension(
support::OnlyFilename(filename), string());
string const absname = support::MakeAbsPath(filename, parentpath);
string result = s;
if (what != ALL_BUT_PATHS) {
string const filepath = support::OnlyPath(filename);
string const abspath = support::OnlyPath(absname);
string const masterpath = external_in_tmpdir ?
@ -89,14 +92,12 @@ string const doSubstitution(InsetExternalParams const & params,
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);
result = support::subst(result, "$$RelPathMaster",
relToMasterPath);
result = support::subst(result, "$$RelPathParent",
relToParentPath);
if (support::AbsolutePath(filename)) {
result = support::subst(result, "$$AbsOrRelPathMaster",
abspath);
@ -108,6 +109,15 @@ string const doSubstitution(InsetExternalParams const & params,
result = support::subst(result, "$$AbsOrRelPathParent",
relToParentPath);
}
}
if (what == PATHS)
return result;
result = support::subst(result, "$$FName", filename);
result = support::subst(result, "$$Basename", basename);
result = support::subst(result, "$$Extension",
'.' + support::GetExtension(filename));
result = support::subst(result, "$$Tempname", params.tempname());
result = support::subst(result, "$$Sysdir",
support::package().system_support());
@ -139,8 +149,8 @@ string const doSubstitution(InsetExternalParams const & params,
namespace {
/** update the file represented by the template.
If \param external_in_tmpdir == true, then the generated file is
place in the buffer's temporary directory.
If \p external_in_tmpdir == true, then the generated file is
placed in the buffer's temporary directory.
*/
void updateExternal(InsetExternalParams const & params,
string const & format,
@ -238,9 +248,17 @@ void updateExternal(InsetExternalParams const & params,
doSubstitution(params, buffer, *fit,
true),
m_buffer->temppath());
string const file = doSubstitution(params, buffer,
*fit,
external_in_tmpdir);
// The path of the referenced file is never the
// temp path, but the filename may be the mangled
// or the real name. Therefore we substitute the
// paths and names separately.
string file = support::subst(*fit, "$$FName",
"$$FPath$$Basename$$Extension");
file = doSubstitution(params, buffer, file, false,
PATHS);
file = doSubstitution(params, buffer, file,
external_in_tmpdir,
ALL_BUT_PATHS);
// if file is a relative name, it is interpreted
// relative to the master document.
exportdata.addExternalFile(rit->first, source, file);

View File

@ -34,6 +34,12 @@ void editExternal(InsetExternalParams const & params,
Buffer const & buffer);
enum Substitute {
ALL,
PATHS,
ALL_BUT_PATHS
};
/** Substitute meta-variables in string \p s, making use of \p params and
\p buffer.
If \p external_in_tmpdir is true, all files are assumed to be in the
@ -44,12 +50,13 @@ void editExternal(InsetExternalParams const & params,
std::string const doSubstitution(InsetExternalParams const & params,
Buffer const & buffer,
std::string const & s,
bool external_in_tmpdir = false);
bool external_in_tmpdir = false,
Substitute what = ALL);
/** Write the output for a specific file format
and generate any external data files.
If \param external_in_tmpdir == true, then the generated file is
If \p external_in_tmpdir == true, then the generated file is
place in the buffer's temporary directory.
*/
int writeExternal(InsetExternalParams const &,

View File

@ -674,7 +674,12 @@ string const InsetGraphics::prepareFile(Buffer const & buf,
// if no special converter defined, then we take the default one
// from ImageMagic: convert from:inname.from to:outname.to
if (!converters.convert(&buf, temp_file, temp_file, from, to)) {
if (converters.convert(&buf, temp_file, temp_file, from, to)) {
runparams.exportdata->addExternalFile("latex",
to_file, output_to_file);
runparams.exportdata->addExternalFile("dvi",
to_file, output_to_file);
} else {
string const command =
"sh " + LibFileSearch("scripts", "convertDefault.sh") +
' ' + formats.extension(from) + ':' + temp_file +