]> git.lyx.org Git - features.git/commitdiff
Don't play too many nice tricks for non-existing graphics files
authorGeorg Baum <Georg.Baum@post.rwth-aachen.de>
Tue, 22 Feb 2005 16:57:36 +0000 (16:57 +0000)
committerGeorg Baum <Georg.Baum@post.rwth-aachen.de>
Tue, 22 Feb 2005 16:57:36 +0000 (16:57 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9667 a592a061-630c-0410-9148-cb99ea01b6c8

src/insets/ChangeLog
src/insets/insetgraphics.C

index 409f1c9edc7f164c0575fa3e3f9e323711e6b4c2..5d6f61a7d0b1aebbeafbffcb8256e9347deb5307 100644 (file)
@@ -1,3 +1,9 @@
+2005-02-22  Georg Baum  <Georg.Baum@post.rwth-aachen.de>
+
+       * insetgraphics.C (prepareFile): handle non-existing files
+       * insetgraphics.C (latex): remove special handling of non-existing
+       files
+
 2005-02-22  Jürgen Spitzmüller  <j.spitzmueller@gmx.de>
 
        * insetcharstyle.C: add TEXT_TO_INSET_OFFSET and adjust metrics.
index 3a867e60201976853b3e9fa40bf5017623ddd2af..e6d6bf4dbb55106789eea2b3470d6b1e4162abc6 100644 (file)
@@ -532,7 +532,10 @@ string const stripExtensionIfPossible(string const & file, string const & to)
 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 +552,12 @@ string const InsetGraphics::prepareFile(Buffer const & buf,
        // 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 +740,10 @@ int InsetGraphics::latex(Buffer const & buf, ostream & os,
 
 
        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;