Am Mittwoch, 16. Februar 2005 22:48 schrieb Angus Leeming:

> After the third or fourth loop, latex fails to process the file.

Well, what do you expect? If I specify that a nonexisting figure should be 
included I tell LyX/LaTeX to do something impossible.
Since I agree in general that playing too many nice tricks is bad, I 
propose the attached patch. The filename can of course have the wrong 
extension and may be relative to the child doc instead of the master doc, 
but I would rather not change prepareFile().
Is this patch OK?


Georg
diff -p -r -U 3 -X excl.tmp lyx-1.4-clean/src/insets/ChangeLog lyx-1.4-cvs/src/insets/ChangeLog
--- lyx-1.4-clean/src/insets/ChangeLog	2005-02-15 20:46:44.000000000 +0100
+++ lyx-1.4-cvs/src/insets/ChangeLog	2005-02-17 19:50:58.000000000 +0100
@@ -1,3 +1,9 @@
+2005-02-17  Georg Baum  <[EMAIL PROTECTED]>
+
+	* insetgraphics.C (prepareFile): handle non-existing files
+	* insetgraphics.C (latex): remove special handling of non-existing
+	files
+
 2005-02-13  André Pönitz  <[EMAIL PROTECTED]>
 
 	* insettext.[Ch] (border_): new 
diff -p -r -U 3 -X excl.tmp lyx-1.4-clean/src/insets/insetgraphics.C lyx-1.4-cvs/src/insets/insetgraphics.C
--- lyx-1.4-clean/src/insets/insetgraphics.C	2005-02-08 20:29:07.000000000 +0100
+++ lyx-1.4-cvs/src/insets/insetgraphics.C	2005-02-17 19:54:52.000000000 +0100
@@ -532,7 +540,10 @@ string const stripExtensionIfPossible(st
 string const InsetGraphics::prepareFile(Buffer const & buf,
 					OutputParams const & runparams) const
 {
-	// We assume that the file exists (the caller checks this)
+	// The following code depends on non-empty filenames
+	if (params().filename.empty())
+		return string();
+
 	string const orig_file = params().filename.absFilename();
 	string const rel_file = params().filename.relFilename(buf.filePath());
 
@@ -549,6 +560,12 @@ string const InsetGraphics::prepareFile(
 	// of include files
 	Buffer const * m_buffer = buf.getMasterBuffer();
 
+	// Return the output name if the file does not exist.
+	// We are not going to change the extension or using the name of the
+	// temporary file, the code is already complicated enough.
+	if (!IsFileReadable(orig_file))
+		return params().filename.outputFilename(m_buffer->filePath());
+
 	// We place all temporary files in the master buffer's temp dir.
 	// This is possible because we use mangled file names.
 	// This is necessary for DVI export.
@@ -731,15 +747,10 @@ int InsetGraphics::latex(Buffer const & 
 
 
 	string latex_str = before + '{';
-	if (file_exists)
-		// Convert the file if necessary.
-		// Remove the extension so the LaTeX will use whatever
-		// is appropriate (when there are several versions in
-		// different formats)
-		latex_str += prepareFile(buf, runparams);
-	else
-		latex_str += relative_file + " not found!";
-
+	// 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 += prepareFile(buf, runparams);
 	latex_str += '}' + after;
 	os << latex_str;
 

Reply via email to