mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-03 08:28:25 +00:00
use the lyxdot replacement mechanism also in insetexternal
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@10162 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
14d7a4424e
commit
1828d1b3f5
@ -1,3 +1,10 @@
|
|||||||
|
2005-07-10 Georg Baum <Georg.Baum@post.rwth-aachen.de>
|
||||||
|
|
||||||
|
* ExternalSupport.C (subst_path): adjust to latex_path changes and
|
||||||
|
replace dots if appropriate
|
||||||
|
* insetgraphics.C (prepareFile): move lyxdot replacement to latex_path
|
||||||
|
* insetexternal.C (validate): require lyxdot
|
||||||
|
|
||||||
2005-07-08 Georg Baum <Georg.Baum@post.rwth-aachen.de>
|
2005-07-08 Georg Baum <Georg.Baum@post.rwth-aachen.de>
|
||||||
|
|
||||||
* ExternalSupport.C (subst_path): new argument exclude_extension
|
* ExternalSupport.C (subst_path): new argument exclude_extension
|
||||||
|
@ -67,12 +67,13 @@ string const subst_path(string const & input,
|
|||||||
string const & placeholder,
|
string const & placeholder,
|
||||||
string const & path,
|
string const & path,
|
||||||
bool use_latex_path,
|
bool use_latex_path,
|
||||||
bool exclude_extension = false)
|
support::latex_path_extension ext = support::PROTECT_EXTENSION,
|
||||||
|
support::latex_path_dots dots = support::LEAVE_DOTS)
|
||||||
{
|
{
|
||||||
if (input.find(placeholder) == string::npos)
|
if (input.find(placeholder) == string::npos)
|
||||||
return input;
|
return input;
|
||||||
string const path2 = use_latex_path ?
|
string const path2 = use_latex_path ?
|
||||||
support::latex_path(path, exclude_extension) :
|
support::latex_path(path, ext, dots) :
|
||||||
support::os::external_path(path);
|
support::os::external_path(path);
|
||||||
return support::subst(input, placeholder, path2);
|
return support::subst(input, placeholder, path2);
|
||||||
}
|
}
|
||||||
@ -113,30 +114,50 @@ string const doSubstitution(InsetExternalParams const & params,
|
|||||||
if (relToParentPath == "./")
|
if (relToParentPath == "./")
|
||||||
relToParentPath.clear();
|
relToParentPath.clear();
|
||||||
|
|
||||||
result = subst_path(result, "$$FPath", filepath, use_latex_path);
|
result = subst_path(result, "$$FPath", filepath,
|
||||||
result = subst_path(result, "$$AbsPath", abspath, use_latex_path);
|
use_latex_path,
|
||||||
|
support::PROTECT_EXTENSION,
|
||||||
|
support::ESCAPE_DOTS);
|
||||||
|
result = subst_path(result, "$$AbsPath", abspath,
|
||||||
|
use_latex_path,
|
||||||
|
support::PROTECT_EXTENSION,
|
||||||
|
support::ESCAPE_DOTS);
|
||||||
result = subst_path(result, "$$RelPathMaster",
|
result = subst_path(result, "$$RelPathMaster",
|
||||||
relToMasterPath, use_latex_path);
|
relToMasterPath, use_latex_path,
|
||||||
|
support::PROTECT_EXTENSION,
|
||||||
|
support::ESCAPE_DOTS);
|
||||||
result = subst_path(result, "$$RelPathParent",
|
result = subst_path(result, "$$RelPathParent",
|
||||||
relToParentPath, use_latex_path);
|
relToParentPath, use_latex_path,
|
||||||
|
support::PROTECT_EXTENSION,
|
||||||
|
support::ESCAPE_DOTS);
|
||||||
if (support::AbsolutePath(filename)) {
|
if (support::AbsolutePath(filename)) {
|
||||||
result = subst_path(result, "$$AbsOrRelPathMaster",
|
result = subst_path(result, "$$AbsOrRelPathMaster",
|
||||||
abspath, use_latex_path);
|
abspath, use_latex_path,
|
||||||
|
support::PROTECT_EXTENSION,
|
||||||
|
support::ESCAPE_DOTS);
|
||||||
result = subst_path(result, "$$AbsOrRelPathParent",
|
result = subst_path(result, "$$AbsOrRelPathParent",
|
||||||
abspath, use_latex_path);
|
abspath, use_latex_path,
|
||||||
|
support::PROTECT_EXTENSION,
|
||||||
|
support::ESCAPE_DOTS);
|
||||||
} else {
|
} else {
|
||||||
result = subst_path(result, "$$AbsOrRelPathMaster",
|
result = subst_path(result, "$$AbsOrRelPathMaster",
|
||||||
relToMasterPath, use_latex_path);
|
relToMasterPath, use_latex_path,
|
||||||
|
support::PROTECT_EXTENSION,
|
||||||
|
support::ESCAPE_DOTS);
|
||||||
result = subst_path(result, "$$AbsOrRelPathParent",
|
result = subst_path(result, "$$AbsOrRelPathParent",
|
||||||
relToParentPath, use_latex_path);
|
relToParentPath, use_latex_path,
|
||||||
|
support::PROTECT_EXTENSION,
|
||||||
|
support::ESCAPE_DOTS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (what == PATHS)
|
if (what == PATHS)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
result = subst_path(result, "$$FName", filename, use_latex_path, true);
|
result = subst_path(result, "$$FName", filename, use_latex_path,
|
||||||
result = subst_path(result, "$$Basename", basename, use_latex_path);
|
support::EXCLUDE_EXTENSION);
|
||||||
|
result = subst_path(result, "$$Basename", basename, use_latex_path,
|
||||||
|
support::PROTECT_EXTENSION, support::ESCAPE_DOTS);
|
||||||
result = subst_path(result, "$$Extension",
|
result = subst_path(result, "$$Extension",
|
||||||
'.' + support::GetExtension(filename), use_latex_path);
|
'.' + support::GetExtension(filename), use_latex_path);
|
||||||
result = subst_path(result, "$$Tempname", params.tempname(), use_latex_path);
|
result = subst_path(result, "$$Tempname", params.tempname(), use_latex_path);
|
||||||
|
@ -755,6 +755,9 @@ void InsetExternal::validate(LaTeXFeatures & features) const
|
|||||||
if (cit == et.formats.end())
|
if (cit == et.formats.end())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// FIXME: We don't need that always
|
||||||
|
features.require("lyxdot");
|
||||||
|
|
||||||
vector<string>::const_iterator it = cit->second.requirements.begin();
|
vector<string>::const_iterator it = cit->second.requirements.begin();
|
||||||
vector<string>::const_iterator end = cit->second.requirements.end();
|
vector<string>::const_iterator end = cit->second.requirements.end();
|
||||||
for (; it != end; ++it)
|
for (; it != end; ++it)
|
||||||
|
@ -528,10 +528,13 @@ string const stripExtensionIfPossible(string const & file)
|
|||||||
// dots with a macro whose definition is just a dot ;-)
|
// dots with a macro whose definition is just a dot ;-)
|
||||||
// The automatic format selection does not work if the file
|
// The automatic format selection does not work if the file
|
||||||
// name is escaped.
|
// name is escaped.
|
||||||
string const latex_name = latex_path(file, true);
|
string const latex_name = latex_path(file,
|
||||||
|
lyx::support::EXCLUDE_EXTENSION);
|
||||||
if (contains(latex_name, '"'))
|
if (contains(latex_name, '"'))
|
||||||
return latex_name;
|
return latex_name;
|
||||||
return subst(latex_path(RemoveExtension(file)), ".", "\\lyxdot ");
|
return latex_path(RemoveExtension(file),
|
||||||
|
lyx::support::PROTECT_EXTENSION,
|
||||||
|
lyx::support::ESCAPE_DOTS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -546,7 +549,7 @@ string const stripExtensionIfPossible(string const & file, string const & to)
|
|||||||
(to_format == "eps" && file_format == "ps") ||
|
(to_format == "eps" && file_format == "ps") ||
|
||||||
(to_format == "ps" && file_format == "eps"))
|
(to_format == "ps" && file_format == "eps"))
|
||||||
return stripExtensionIfPossible(file);
|
return stripExtensionIfPossible(file);
|
||||||
return latex_path(file, true);
|
return latex_path(file, lyx::support::EXCLUDE_EXTENSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace anon
|
} // namespace anon
|
||||||
@ -633,7 +636,8 @@ string const InsetGraphics::prepareFile(Buffer const & buf,
|
|||||||
source_file, output_file);
|
source_file, output_file);
|
||||||
// We can't strip the extension, because we don't know
|
// We can't strip the extension, because we don't know
|
||||||
// the unzipped file format
|
// the unzipped file format
|
||||||
return latex_path(output_file, true);
|
return latex_path(output_file,
|
||||||
|
lyx::support::EXCLUDE_EXTENSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
string const unzipped_temp_file = unzippedFileName(temp_file);
|
string const unzipped_temp_file = unzippedFileName(temp_file);
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
2005-07-10 Georg Baum <Georg.Baum@post.rwth-aachen.de>
|
||||||
|
|
||||||
|
* filetools.[Ch] (latex_path): convert boolean exclude_extension
|
||||||
|
argument to an enum and add argument to replace dots
|
||||||
|
|
||||||
2005-07-08 Georg Baum <Georg.Baum@post.rwth-aachen.de>
|
2005-07-08 Georg Baum <Georg.Baum@post.rwth-aachen.de>
|
||||||
|
|
||||||
* filetools.[Ch] (latex_path): add exclude_extension argument
|
* filetools.[Ch] (latex_path): add exclude_extension argument
|
||||||
|
@ -82,14 +82,16 @@ bool IsSGMLFilename(string const & filename)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
string const latex_path(string const & original_path, bool exclude_extension)
|
string const latex_path(string const & original_path,
|
||||||
|
latex_path_extension extension,
|
||||||
|
latex_path_dots dots)
|
||||||
{
|
{
|
||||||
string path = subst(original_path, "\\", "/");
|
string path = subst(original_path, "\\", "/");
|
||||||
path = subst(path, "~", "\\string~");
|
path = subst(path, "~", "\\string~");
|
||||||
if (path.find(' ') != string::npos)
|
if (path.find(' ') != string::npos)
|
||||||
// We can't use '"' because " is sometimes active (e.g. if
|
// We can't use '"' because " is sometimes active (e.g. if
|
||||||
// babel is loaded with the "german" option)
|
// babel is loaded with the "german" option)
|
||||||
if (exclude_extension) {
|
if (extension == EXCLUDE_EXTENSION) {
|
||||||
string const base = ChangeExtension(path, string());
|
string const base = ChangeExtension(path, string());
|
||||||
string const ext = GetExtension(path);
|
string const ext = GetExtension(path);
|
||||||
// ChangeExtension calls os::internal_path internally
|
// ChangeExtension calls os::internal_path internally
|
||||||
@ -97,6 +99,8 @@ string const latex_path(string const & original_path, bool exclude_extension)
|
|||||||
path = "\\string\"" + base + "\\string\"." + ext;
|
path = "\\string\"" + base + "\\string\"." + ext;
|
||||||
} else
|
} else
|
||||||
path = "\\string\"" + path + "\\string\"";
|
path = "\\string\"" + path + "\\string\"";
|
||||||
|
if (dots == ESCAPE_DOTS)
|
||||||
|
return subst(path, ".", "\\lyxdot ");
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,6 +102,16 @@ i18nLibFileSearch(std::string const & dir, std::string const & name,
|
|||||||
*/
|
*/
|
||||||
std::string const LibScriptSearch(std::string const & command);
|
std::string const LibScriptSearch(std::string const & command);
|
||||||
|
|
||||||
|
enum latex_path_extension {
|
||||||
|
PROTECT_EXTENSION,
|
||||||
|
EXCLUDE_EXTENSION
|
||||||
|
};
|
||||||
|
|
||||||
|
enum latex_path_dots {
|
||||||
|
LEAVE_DOTS,
|
||||||
|
ESCAPE_DOTS
|
||||||
|
};
|
||||||
|
|
||||||
/** @param path a file path in internal_path format. Ie, directories
|
/** @param path a file path in internal_path format. Ie, directories
|
||||||
* are indicated by '/', not by '\'.
|
* are indicated by '/', not by '\'.
|
||||||
*
|
*
|
||||||
@ -112,14 +122,18 @@ std::string const LibScriptSearch(std::string const & command);
|
|||||||
* If @c path contains spaces, then the returned path is enclosed in
|
* If @c path contains spaces, then the returned path is enclosed in
|
||||||
* "-quotes. This last fix will lead to successful compiliation of the
|
* "-quotes. This last fix will lead to successful compiliation of the
|
||||||
* LaTeX file only if a sufficiently modern LaTeX compiler is used.
|
* LaTeX file only if a sufficiently modern LaTeX compiler is used.
|
||||||
* If @c exclude_extension is true the extension is left outside the quotes.
|
* If @c ext == EXCLUDE_EXTENSION the extension is left outside the quotes.
|
||||||
* This is needed for pdfeTeX, Version 3.141592-1.21a-2.2 (Web2C 7.5.4)
|
* This is needed for pdfeTeX, Version 3.141592-1.21a-2.2 (Web2C 7.5.4)
|
||||||
* (format=pdflatex 2005.4.11) in combination with
|
* (format=pdflatex 2005.4.11) in combination with
|
||||||
* pdftex.def 2002/06/19 v0.03k graphics/color for pdftex:
|
* pdftex.def 2002/06/19 v0.03k graphics/color for pdftex:
|
||||||
* It does not recognize the file extension if it is inside the quotes.
|
* It does not recognize the file extension if it is inside the quotes.
|
||||||
|
* If @c dots == ESCAPE_DOTS dots in the filename are replaced by
|
||||||
|
* "\\lyxdot ". This is needed for the \\includegraphics command if the
|
||||||
|
* automatic format selection is used.
|
||||||
*/
|
*/
|
||||||
std::string const latex_path(std::string const & path,
|
std::string const latex_path(std::string const & path,
|
||||||
bool exclude_extension = false);
|
latex_path_extension extension = PROTECT_EXTENSION,
|
||||||
|
latex_path_dots dots = LEAVE_DOTS);
|
||||||
|
|
||||||
/// Substitutes active latex characters with underscores in filename
|
/// Substitutes active latex characters with underscores in filename
|
||||||
std::string const MakeLatexName(std::string const & file);
|
std::string const MakeLatexName(std::string const & file);
|
||||||
|
Loading…
Reference in New Issue
Block a user