From: Georg Baum Date: Sun, 10 Jul 2005 09:31:27 +0000 (+0000) Subject: use the lyxdot replacement mechanism also in insetexternal X-Git-Tag: 1.6.10~14157 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=1828d1b3f5053973b776bc0642109163528369fe;p=features.git use the lyxdot replacement mechanism also in insetexternal git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@10162 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index f6b934a9d0..2c5e1cada8 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,10 @@ +2005-07-10 Georg Baum + + * 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 * ExternalSupport.C (subst_path): new argument exclude_extension diff --git a/src/insets/ExternalSupport.C b/src/insets/ExternalSupport.C index 7c6a1b441a..6a64f28675 100644 --- a/src/insets/ExternalSupport.C +++ b/src/insets/ExternalSupport.C @@ -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); diff --git a/src/insets/insetexternal.C b/src/insets/insetexternal.C index 3fcd5902e4..4af98bba77 100644 --- a/src/insets/insetexternal.C +++ b/src/insets/insetexternal.C @@ -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::const_iterator it = cit->second.requirements.begin(); vector::const_iterator end = cit->second.requirements.end(); for (; it != end; ++it) diff --git a/src/insets/insetgraphics.C b/src/insets/insetgraphics.C index d8e10b67bd..44a37fd723 100644 --- a/src/insets/insetgraphics.C +++ b/src/insets/insetgraphics.C @@ -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); diff --git a/src/support/ChangeLog b/src/support/ChangeLog index 927dacbc26..52cf9c73ae 100644 --- a/src/support/ChangeLog +++ b/src/support/ChangeLog @@ -1,3 +1,8 @@ +2005-07-10 Georg Baum + + * filetools.[Ch] (latex_path): convert boolean exclude_extension + argument to an enum and add argument to replace dots + 2005-07-08 Georg Baum * filetools.[Ch] (latex_path): add exclude_extension argument diff --git a/src/support/filetools.C b/src/support/filetools.C index a5e47c18f5..60735f9503 100644 --- a/src/support/filetools.C +++ b/src/support/filetools.C @@ -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; } diff --git a/src/support/filetools.h b/src/support/filetools.h index c3dd0459db..11142403c6 100644 --- a/src/support/filetools.h +++ b/src/support/filetools.h @@ -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);