mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 10:00:33 +00:00
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:
parent
b4c186e11e
commit
4d0cbd59af
@ -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
|
||||
|
@ -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,43 +72,52 @@ 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 const filepath = support::OnlyPath(filename);
|
||||
string const abspath = support::OnlyPath(absname);
|
||||
string const masterpath = external_in_tmpdir ?
|
||||
m_buffer->temppath() :
|
||||
m_buffer->filePath();
|
||||
string relToMasterPath = support::OnlyPath(
|
||||
support::MakeRelPath(absname, masterpath));
|
||||
if (relToMasterPath == "./")
|
||||
relToMasterPath.clear();
|
||||
string relToParentPath = support::OnlyPath(
|
||||
support::MakeRelPath(absname, parentpath));
|
||||
if (relToParentPath == "./")
|
||||
relToParentPath.clear();
|
||||
|
||||
result = support::subst(s, "$$FName", filename);
|
||||
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 ?
|
||||
m_buffer->temppath() :
|
||||
m_buffer->filePath();
|
||||
string relToMasterPath = support::OnlyPath(
|
||||
support::MakeRelPath(absname, masterpath));
|
||||
if (relToMasterPath == "./")
|
||||
relToMasterPath.clear();
|
||||
string relToParentPath = support::OnlyPath(
|
||||
support::MakeRelPath(absname, parentpath));
|
||||
if (relToParentPath == "./")
|
||||
relToParentPath.clear();
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
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, "$$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::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);
|
||||
|
@ -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 &,
|
||||
|
@ -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 +
|
||||
|
Loading…
Reference in New Issue
Block a user