From 82c584805830f432341d566ae4e989ec8f92ec8c Mon Sep 17 00:00:00 2001 From: Georg Baum Date: Mon, 20 Jun 2005 14:11:11 +0000 Subject: [PATCH] fix quoted graphics file names git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@10093 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/insets/ChangeLog | 6 ++++++ src/insets/insetgraphics.C | 21 +++++++++++++-------- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index 995b46095a..7bde2258ff 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,9 @@ +2005-06-20 Georg Baum + + * insetgraphics.C (prepareFile): don't strip the extension of quoted + filenames + * insetgraphics.C (stripExtensionIfPossible): fix lyxdot replacement + 2005-06-16 Jürgen Spitzmüller * insettabular.C (getStatus): disable LFUN_TABULAR_INSERT diff --git a/src/insets/insetgraphics.C b/src/insets/insetgraphics.C index 72139e5bab..3b6e2b4146 100644 --- a/src/insets/insetgraphics.C +++ b/src/insets/insetgraphics.C @@ -518,7 +518,7 @@ copyToDirIfNeeded(string const & file_in, string const & dir, bool zipped) } -string const stripExtension(string const & file) +string const stripExtensionIfPossible(string const & file) { // Remove the extension so the LaTeX will use whatever // is appropriate (when there are several versions in @@ -526,7 +526,12 @@ string const stripExtension(string const & file) // This works only if the filename contains no dots besides // the just removed one. We can fool here by replacing all // dots with a macro whose definition is just a dot ;-) - return subst(RemoveExtension(file), ".", "\\lyxdot "); + // The automatic format selection does not work if the file + // name is escaped. + string const latex_name = latex_path(file); + if (latex_name[0] == '"') + return latex_name; + return subst(latex_path(RemoveExtension(file)), ".", "\\lyxdot "); } @@ -540,8 +545,8 @@ string const stripExtensionIfPossible(string const & file, string const & to) if (to_format == file_format || (to_format == "eps" && file_format == "ps") || (to_format == "ps" && file_format == "eps")) - return stripExtension(file); - return file; + return stripExtensionIfPossible(file); + return latex_path(file); } } // namespace anon @@ -628,7 +633,7 @@ 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 output_file; + return latex_path(output_file); } string const unzipped_temp_file = unzippedFileName(temp_file); @@ -688,7 +693,7 @@ string const InsetGraphics::prepareFile(Buffer const & buf, output_to_file); runparams.exportdata->addExternalFile("dvi", to_file, output_to_file); - return stripExtension(output_file); + return stripExtensionIfPossible(output_file); } lyxerr[Debug::GRAPHICS] @@ -704,7 +709,7 @@ string const InsetGraphics::prepareFile(Buffer const & buf, to_file, output_to_file); } - return stripExtension(output_file); + return stripExtensionIfPossible(output_file); } @@ -760,7 +765,7 @@ int InsetGraphics::latex(Buffer const & buf, ostream & os, // Convert the file if necessary. // Remove the extension so LaTeX will use whatever is appropriate // (when there are several versions in different formats) - latex_str += latex_path(prepareFile(buf, runparams)); + latex_str += prepareFile(buf, runparams); latex_str += '}' + after; os << latex_str;