+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>
* ExternalSupport.C (subst_path): new argument exclude_extension
string const & placeholder,
string const & 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)
return input;
string const path2 = use_latex_path ?
- support::latex_path(path, exclude_extension) :
+ support::latex_path(path, ext, dots) :
support::os::external_path(path);
return support::subst(input, placeholder, path2);
}
if (relToParentPath == "./")
relToParentPath.clear();
- result = subst_path(result, "$$FPath", filepath, use_latex_path);
- result = subst_path(result, "$$AbsPath", abspath, use_latex_path);
+ result = subst_path(result, "$$FPath", filepath,
+ 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",
- relToMasterPath, use_latex_path);
+ relToMasterPath, use_latex_path,
+ support::PROTECT_EXTENSION,
+ support::ESCAPE_DOTS);
result = subst_path(result, "$$RelPathParent",
- relToParentPath, use_latex_path);
+ relToParentPath, use_latex_path,
+ support::PROTECT_EXTENSION,
+ support::ESCAPE_DOTS);
if (support::AbsolutePath(filename)) {
result = subst_path(result, "$$AbsOrRelPathMaster",
- abspath, use_latex_path);
+ abspath, use_latex_path,
+ support::PROTECT_EXTENSION,
+ support::ESCAPE_DOTS);
result = subst_path(result, "$$AbsOrRelPathParent",
- abspath, use_latex_path);
+ abspath, use_latex_path,
+ support::PROTECT_EXTENSION,
+ support::ESCAPE_DOTS);
} else {
result = subst_path(result, "$$AbsOrRelPathMaster",
- relToMasterPath, use_latex_path);
+ relToMasterPath, use_latex_path,
+ support::PROTECT_EXTENSION,
+ support::ESCAPE_DOTS);
result = subst_path(result, "$$AbsOrRelPathParent",
- relToParentPath, use_latex_path);
+ relToParentPath, use_latex_path,
+ support::PROTECT_EXTENSION,
+ support::ESCAPE_DOTS);
}
}
if (what == PATHS)
return result;
- result = subst_path(result, "$$FName", filename, use_latex_path, true);
- result = subst_path(result, "$$Basename", basename, use_latex_path);
+ result = subst_path(result, "$$FName", filename, 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",
'.' + support::GetExtension(filename), use_latex_path);
result = subst_path(result, "$$Tempname", params.tempname(), use_latex_path);
if (cit == et.formats.end())
return;
+ // FIXME: We don't need that always
+ features.require("lyxdot");
+
vector<string>::const_iterator it = cit->second.requirements.begin();
vector<string>::const_iterator end = cit->second.requirements.end();
for (; it != end; ++it)
// dots with a macro whose definition is just a dot ;-)
// The automatic format selection does not work if the file
// 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, '"'))
return latex_name;
- return subst(latex_path(RemoveExtension(file)), ".", "\\lyxdot ");
+ return latex_path(RemoveExtension(file),
+ lyx::support::PROTECT_EXTENSION,
+ lyx::support::ESCAPE_DOTS);
}
(to_format == "eps" && file_format == "ps") ||
(to_format == "ps" && file_format == "eps"))
return stripExtensionIfPossible(file);
- return latex_path(file, true);
+ return latex_path(file, lyx::support::EXCLUDE_EXTENSION);
}
} // namespace anon
source_file, output_file);
// We can't strip the extension, because we don't know
// 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);
+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>
* filetools.[Ch] (latex_path): add exclude_extension argument
}
-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, "\\", "/");
path = subst(path, "~", "\\string~");
if (path.find(' ') != string::npos)
// We can't use '"' because " is sometimes active (e.g. if
// babel is loaded with the "german" option)
- if (exclude_extension) {
+ if (extension == EXCLUDE_EXTENSION) {
string const base = ChangeExtension(path, string());
string const ext = GetExtension(path);
// ChangeExtension calls os::internal_path internally
path = "\\string\"" + base + "\\string\"." + ext;
} else
path = "\\string\"" + path + "\\string\"";
+ if (dots == ESCAPE_DOTS)
+ return subst(path, ".", "\\lyxdot ");
return path;
}
*/
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
* are indicated by '/', not by '\'.
*
* If @c path contains spaces, then the returned path is enclosed in
* "-quotes. This last fix will lead to successful compiliation of the
* 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)
* (format=pdflatex 2005.4.11) in combination with
* pdftex.def 2002/06/19 v0.03k graphics/color for pdftex:
* 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,
- bool exclude_extension = false);
+ latex_path_extension extension = PROTECT_EXTENSION,
+ latex_path_dots dots = LEAVE_DOTS);
/// Substitutes active latex characters with underscores in filename
std::string const MakeLatexName(std::string const & file);