From 07fc1c3abce02fb92ff1b2c3d7ea42db50c1e237 Mon Sep 17 00:00:00 2001 From: Georg Baum Date: Mon, 31 Oct 2011 20:27:21 +0000 Subject: [PATCH] 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 --- src/insets/InsetExternal.cpp | 2 +- src/insets/InsetGraphics.cpp | 10 +--------- src/support/filetools.cpp | 17 ++++++++++++++--- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/insets/InsetExternal.cpp b/src/insets/InsetExternal.cpp index bd9df03e1c..54b04b3946 100644 --- a/src/insets/InsetExternal.cpp +++ b/src/insets/InsetExternal.cpp @@ -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::const_iterator it = cit->second.requirements.begin(); diff --git a/src/insets/InsetGraphics.cpp b/src/insets/InsetGraphics.cpp index f3e3c47079..123af44ea5 100644 --- a/src/insets/InsetGraphics.cpp +++ b/src/insets/InsetGraphics.cpp @@ -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"); } diff --git a/src/support/filetools.cpp b/src/support/filetools.cpp index bf61983325..bb531b807c 100644 --- a/src/support/filetools.cpp +++ b/src/support/filetools.cpp @@ -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 "); }