Jean-Marc Lasgouttes wrote:

> Do I have a chance to say yes too?

Of course ;-)
 
> Please go ahead.

Done.

Here is the patch for 1.4. It is a bit different, because we can (and
should) test here more easyly whether the extension can be removed or not.
The patch fixes also a bug related to the order of lyxdot replacement and
latex_path.
Of course the test for the quoted filenames will need to change, but that
comes later.
I'll apply this shortly.


Georg
Index: src/insets/ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/ChangeLog,v
retrieving revision 1.1152
diff -u -p -r1.1152 ChangeLog
--- src/insets/ChangeLog	16 Jun 2005 15:20:09 -0000	1.1152
+++ src/insets/ChangeLog	20 Jun 2005 09:32:04 -0000
@@ -1,3 +1,9 @@
+2005-06-20  Georg Baum  <[EMAIL PROTECTED]>
+
+	* insetgraphics.C (prepareFile): don't strip the extension of quoted
+	filenames
+	* insetgraphics.C (stripExtensionIfPossible): fix lyxdot replacement
+
 2005-06-16  Jürgen Spitzmüller  <[EMAIL PROTECTED]>
 
 	* insettabular.C (getStatus): disable LFUN_TABULAR_INSERT
Index: src/insets/insetgraphics.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetgraphics.C,v
retrieving revision 1.278
diff -u -p -r1.278 insetgraphics.C
--- src/insets/insetgraphics.C	9 May 2005 17:29:22 -0000	1.278
+++ src/insets/insetgraphics.C	20 Jun 2005 09:32:05 -0000
@@ -518,7 +527,7 @@ copyToDirIfNeeded(string const & file_in
 }
 
 
-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 +535,12 @@ string const stripExtension(string const
 	// 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 +554,8 @@ string const stripExtensionIfPossible(st
 	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 +642,7 @@ string const InsetGraphics::prepareFile(
 					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 +701,7 @@ string const InsetGraphics::prepareFile(
 		                                      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 +717,7 @@ string const InsetGraphics::prepareFile(
 				to_file, output_to_file);
 	}
 
-	return stripExtension(output_file);
+	return stripExtensionIfPossible(output_file);
 }
 
 
@@ -760,7 +773,7 @@ int InsetGraphics::latex(Buffer const & 
 	// 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;
 

Reply via email to