From: Angus Leeming Date: Wed, 13 Feb 2002 18:53:36 +0000 (+0000) Subject: Herbert's graphics10.diff patch, part I. X-Git-Tag: 1.6.10~19862 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=49dcb7a5d44f5cdd1a32769f866a5229d7e6e42f;p=features.git Herbert's graphics10.diff patch, part I. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3533 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index 5a27f5bdf7..9e5dfe3afc 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,7 @@ +2002-02-12 Herbert Voss + + * insetgraphics.C: latex(), return the correct newlines + 2002-02-13 José Matos * inseturl.C (docbook): escape & in url. diff --git a/src/insets/insetgraphics.C b/src/insets/insetgraphics.C index c5a679d005..22c3e617a1 100644 --- a/src/insets/insetgraphics.C +++ b/src/insets/insetgraphics.C @@ -105,8 +105,9 @@ TODO Before initial production release: #include "lyx_gui_misc.h" #include "support/FileInfo.h" #include "support/filetools.h" -#include "frontends/controllers/helper_funcs.h" +#include "support/lyxalgo.h" // lyx::count #include "support/lyxlib.h" +#include "frontends/controllers/helper_funcs.h" #include "lyxtext.h" #include "lyxrc.h" #include "font.h" // For the lyxfont class. @@ -581,31 +582,32 @@ int InsetGraphics::latex(Buffer const *buf, ostream & os, << _("empty figure path") << "}\n"; return 1; // One end of line marker added to the stream. } - // Keep count of newlines that we issued. -#warning the newlines=0 were in the original code. where is the sense? (Herbert) - int newlines = 0; - // This variables collect all the latex code that should be before and + // These variables collect all the latex code that should be before and // after the actual includegraphics command. string before; string after; // Do we want subcaptions? if (params.subcaption) { before += "\\subfigure[" + params.subcaptionText + "]{"; - after = '}' + after; + after = '}'; } // We never use the starred form, we use the "clip" option instead. - os << before << "\\includegraphics"; + before += "\\includegraphics"; // Write the options if there are any. string const opts = createLatexOptions(); if (!opts.empty()) { - os << "[%\n" << opts << ']'; + before += ("[%\n" + opts +']'); } // Make the filename relative to the lyx file // and remove the extension so the LaTeX will use whatever is // appropriate (when there are several versions in different formats) - string const filename = prepareFile(buf); - os << '{' << filename << '}' << after; + string const latex_str = before + '{' + prepareFile(buf) + '}' + after; + os << latex_str; // Return how many newlines we issued. + int const newlines = + int(lyx::count(latex_str.begin(), latex_str.end(),'\n') + 1); + // lyxerr << "includegraphics: " << newlines << " lines of text" + // << endl; return newlines; }