]> git.lyx.org Git - features.git/commitdiff
"latexify" the file name if the graphics file is not found.
authorAngus Leeming <leeming@lyx.org>
Tue, 26 Mar 2002 15:21:58 +0000 (15:21 +0000)
committerAngus Leeming <leeming@lyx.org>
Tue, 26 Mar 2002 15:21:58 +0000 (15:21 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3842 a592a061-630c-0410-9148-cb99ea01b6c8

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

index 9de84bde84db89d729f178573769a320587e8723..04a57e7482ed7e414132eda4c4974e34374cee84 100644 (file)
@@ -2,7 +2,7 @@
 
        * insetgraphicsParams.C (Read): revert Herbert's fix and apply the
        proper fix to the graphics cache.
-       (latex): nice output if the file is not found.
+       (latex): "really" nice output if the file is not found ;-)
 
 2002-03-26  Juergen Vigna  <jug@sad.it>
 
index b7e93ddb5b438fe29ff3b8a1aa362003fb950d74..f09ccdec5b08e01f04b5b96aa6e60c938cab14d3 100644 (file)
@@ -642,6 +642,49 @@ string const InsetGraphics::prepareFile(Buffer const *buf) const
 }
 
 
+namespace {
+
+string const latexify(string const str)
+{
+       ostringstream out;
+
+       string::const_iterator it  = str.begin();
+       string::const_iterator end = str.end();
+
+       for (; it != end; ++it) {
+               switch (*it) {
+                       
+               case ('$'):
+               case ('&'):
+               case ('%'):
+               case ('#'):
+               case ('_'):
+               case ('{'):
+               case ('}'):
+                       out << '\\' << *it;
+                       break;
+
+               case ('~'):
+               case ('^'):
+                       out << '\\' << *it << "{}";
+                       break;
+
+               case ('\\'):
+                       out << "$\backslash$";
+                       break;
+
+               default:
+                       out << *it;
+                       break;
+               }
+       }
+       
+       return out.str().c_str();
+}
+} // namespace anon
+
+
 int InsetGraphics::latex(Buffer const *buf, ostream & os,
                         bool /*fragile*/, bool/*fs*/) const
 {
@@ -655,7 +698,8 @@ int InsetGraphics::latex(Buffer const *buf, ostream & os,
        // Ditto if the file is not there.
        if (!IsFileReadable(MakeAbsPath(params().filename, buf->filePath()))) {
                os  << "\\fbox{\\rule[-0.5in]{0pt}{1in}"
-                   << _("file not found") << "}\n";
+                   << latexify(MakeRelPath(params().filename, buf->filePath()))
+                   << _(" not found") << "}\n";
                return 1; // One end-of-line marker added to the stream.
        }
        // These variables collect all the latex code that should be before and