Author: baum
Date: Mon Oct 31 21:27:21 2011
New Revision: 40115
URL: http://www.lyx.org/trac/changeset/40115

Log:
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.

Modified:
   lyx-devel/trunk/src/insets/InsetExternal.cpp
   lyx-devel/trunk/src/insets/InsetGraphics.cpp
   lyx-devel/trunk/src/support/filetools.cpp

Modified: lyx-devel/trunk/src/insets/InsetExternal.cpp
==============================================================================
--- lyx-devel/trunk/src/insets/InsetExternal.cpp        Mon Oct 31 06:10:24 
2011        (r40114)
+++ lyx-devel/trunk/src/insets/InsetExternal.cpp        Mon Oct 31 21:27:21 
2011        (r40115)
@@ -767,7 +767,7 @@
                        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();

Modified: lyx-devel/trunk/src/insets/InsetGraphics.cpp
==============================================================================
--- lyx-devel/trunk/src/insets/InsetGraphics.cpp        Mon Oct 31 06:10:24 
2011        (r40114)
+++ lyx-devel/trunk/src/insets/InsetGraphics.cpp        Mon Oct 31 21:27:21 
2011        (r40115)
@@ -790,12 +790,6 @@
        // 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 @@
        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");
        }

Modified: lyx-devel/trunk/src/support/filetools.cpp
==============================================================================
--- lyx-devel/trunk/src/support/filetools.cpp   Mon Oct 31 06:10:24 2011        
(r40114)
+++ lyx-devel/trunk/src/support/filetools.cpp   Mon Oct 31 21:27:21 2011        
(r40115)
@@ -100,13 +100,13 @@
                // 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 @@
                }
        }
 
-       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 ");
 }
 
 

Reply via email to