Replace a half-baked attempt to remove \lyxdot from the directory part of

file names with a proper one: Only replace dots in the base name, and only
request the lyxdot feature if it is needed. This is a partial fix of bug #7650.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@40115 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Georg Baum 2011-10-31 20:27:21 +00:00
parent f47bebe5fa
commit 07fc1c3abc
3 changed files with 16 additions and 13 deletions

View File

@ -767,7 +767,7 @@ void InsetExternal::validate(LaTeXFeatures & features) const
return;
}
// FIXME: We don't need that always
// FIXME: We don't need that always, see InsetGraphics
features.require("lyxdot");
vector<string>::const_iterator it = cit->second.requirements.begin();

View File

@ -790,12 +790,6 @@ void InsetGraphics::latex(otexstream & os,
// Remove the extension so LaTeX will use whatever is appropriate
// (when there are several versions in different formats)
string file_path = prepareFile(runparams);
if (!runparams.export_folder.empty()) {
// Relative pathnames starting with ../ will be sanitized
// if exporting to a different folder
while (file_path.substr(0, 17) == "\\lyxdot \\lyxdot /")
file_path = file_path.substr(17, file_path.length() - 17);
}
latex_str += file_path;
latex_str += '}' + after;
// FIXME UNICODE
@ -1005,9 +999,7 @@ void InsetGraphics::validate(LaTeXFeatures & features) const
features.require("graphicx");
if (features.runparams().nice) {
Buffer const * masterBuffer = features.buffer().masterBuffer();
string const rel_file = removeExtension(
params().filename.relFileName(masterBuffer->filePath()));
string const rel_file = params().filename.onlyFileNameWithoutExt();
if (contains(rel_file, "."))
features.require("lyxdot");
}

View File

@ -100,13 +100,13 @@ string const latex_path(string const & original_path,
// We can't use '"' because " is sometimes active (e.g. if
// babel is loaded with the "german" option)
if (extension == EXCLUDE_EXTENSION) {
// ChangeExtension calls os::internal_path internally
// changeExtension calls os::internal_path internally
// so don't use it to remove the extension.
string const ext = getExtension(path);
string const base = ext.empty() ?
path :
path.substr(0, path.length() - ext.length() - 1);
// ChangeExtension calls os::internal_path internally
// changeExtension calls os::internal_path internally
// so don't use it to re-add the extension.
path = "\\string\"" + base + "\\string\"." + ext;
} else {
@ -114,7 +114,18 @@ string const latex_path(string const & original_path,
}
}
return dots == ESCAPE_DOTS ? subst(path, ".", "\\lyxdot ") : path;
if (dots != ESCAPE_DOTS)
return path;
// Replace dots with the lyxdot macro, but only in the file name,
// not the directory part.
// addName etc call os::internal_path internally
// so don't use them for path manipulation
// The directory separator is always '/' for LaTeX.
string::size_type pos = path.rfind('/');
if (pos == string::npos)
return subst(path, ".", "\\lyxdot ");
return path.substr(0, pos) + subst(path.substr(pos), ".", "\\lyxdot ");
}