]> git.lyx.org Git - lyx.git/commitdiff
use the lyxdot replacement mechanism also in insetexternal
authorGeorg Baum <Georg.Baum@post.rwth-aachen.de>
Sun, 10 Jul 2005 09:31:27 +0000 (09:31 +0000)
committerGeorg Baum <Georg.Baum@post.rwth-aachen.de>
Sun, 10 Jul 2005 09:31:27 +0000 (09:31 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@10162 a592a061-630c-0410-9148-cb99ea01b6c8

src/insets/ChangeLog
src/insets/ExternalSupport.C
src/insets/insetexternal.C
src/insets/insetgraphics.C
src/support/ChangeLog
src/support/filetools.C
src/support/filetools.h

index f6b934a9d038ce2db86d6c21b406ba576f722559..2c5e1cada82b1a0579e63be5b357066dbe829136 100644 (file)
@@ -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>
 
        * ExternalSupport.C (subst_path): new argument exclude_extension
index 7c6a1b441a6de506b82e03d57841a80c025b2877..6a64f2867557eddf363ccf46b4fdfe5a4ad5fc9a 100644 (file)
@@ -67,12 +67,13 @@ string const subst_path(string const & input,
                        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);
 }
@@ -113,30 +114,50 @@ string const doSubstitution(InsetExternalParams const & params,
                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);
index 3fcd5902e432143b803d68c7f1c2968a3478101d..4af98bba7798aaabc06d8a9fd1291caf1e7f6f18 100644 (file)
@@ -755,6 +755,9 @@ void InsetExternal::validate(LaTeXFeatures & features) const
        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)
index d8e10b67bd5bcb25328c1f61cae8f8c00d717bfb..44a37fd723496af1c9d4f2acaa2690984183e62f 100644 (file)
@@ -528,10 +528,13 @@ string const stripExtensionIfPossible(string const & file)
        // 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);
 }
 
 
@@ -546,7 +549,7 @@ string const stripExtensionIfPossible(string const & file, string const & to)
            (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
@@ -633,7 +636,8 @@ string const InsetGraphics::prepareFile(Buffer const & buf,
                                        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);
index 927dacbc26e283f1240323af0d26ceb03a7ae8b2..52cf9c73ae68c47246bb84e11b30e95dfd9c91ec 100644 (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>
 
        * filetools.[Ch] (latex_path): add exclude_extension argument
index a5e47c18f5ec58c20562e69b7a2cd6ab46276eae..60735f9503eb3f02c0af2422ef2b50b5457edcbb 100644 (file)
@@ -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, "\\", "/");
        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
@@ -97,6 +99,8 @@ string const latex_path(string const & original_path, bool exclude_extension)
                        path = "\\string\"" + base + "\\string\"." + ext;
                } else
                        path = "\\string\"" + path + "\\string\"";
+       if (dots == ESCAPE_DOTS)
+               return subst(path, ".", "\\lyxdot ");
        return path;
 }
 
index c3dd0459db519fd0213a6c320c39df73160e0ebd..11142403c642846ae6db30bd46ff43a010becacc 100644 (file)
@@ -102,6 +102,16 @@ i18nLibFileSearch(std::string const & dir, std::string const & name,
  */
 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 '\'.
  *
@@ -112,14 +122,18 @@ std::string const LibScriptSearch(std::string const & command);
  *  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);