]> git.lyx.org Git - lyx.git/commitdiff
Herbert's graphics10.diff patch, part I.
authorAngus Leeming <leeming@lyx.org>
Wed, 13 Feb 2002 18:53:36 +0000 (18:53 +0000)
committerAngus Leeming <leeming@lyx.org>
Wed, 13 Feb 2002 18:53:36 +0000 (18:53 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3533 a592a061-630c-0410-9148-cb99ea01b6c8

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

index 5a27f5bdf72a9732a5bee742ac579afda5e18ea2..9e5dfe3afc479c7daf4157b5f222dd49041c9d1a 100644 (file)
@@ -1,3 +1,7 @@
+2002-02-12  Herbert Voss  <voss@lyx.org>
+
+       * insetgraphics.C: latex(), return the correct newlines
+
 2002-02-13  José Matos  <jamatos@fep.up.pt>
 
        * inseturl.C (docbook): escape & in url.
index c5a679d0050673adf4cd89ec072dedd886ef7139..22c3e617a11467049a702c9d3617e6d7c48b6ba6 100644 (file)
@@ -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;
 }