From 055a98c1e7bd87780d65fb51351b79e2ed0b1958 Mon Sep 17 00:00:00 2001 From: Angus Leeming Date: Tue, 26 Mar 2002 15:21:58 +0000 Subject: [PATCH] "latexify" the file name if the graphics file is not found. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3842 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/insets/ChangeLog | 2 +- src/insets/insetgraphics.C | 46 +++++++++++++++++++++++++++++++++++++- 2 files changed, 46 insertions(+), 2 deletions(-) diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index 9de84bde84..04a57e7482 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -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 diff --git a/src/insets/insetgraphics.C b/src/insets/insetgraphics.C index b7e93ddb5b..f09ccdec5b 100644 --- a/src/insets/insetgraphics.C +++ b/src/insets/insetgraphics.C @@ -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 -- 2.39.2