]> git.lyx.org Git - lyx.git/blobdiff - src/insets/insetexternal.C
* In the process of fixing the math background color bug, this commit transfer backgr...
[lyx.git] / src / insets / insetexternal.C
index 910d3d071a55a3d2230672a217d987144652de64..588dabc39969747a563997b3ae28e1ad6b4a506a 100644 (file)
@@ -674,7 +674,7 @@ void InsetExternal::read(Buffer const & buffer, LyXLex & lex)
 
 
 int InsetExternal::latex(Buffer const & buf, odocstream & os,
-                        OutputParams const & runparams) const
+                         OutputParams const & runparams) const
 {
        if (params_.draft) {
                // FIXME UNICODE
@@ -687,8 +687,9 @@ int InsetExternal::latex(Buffer const & buf, odocstream & os,
        // "nice" means that the buffer is exported to LaTeX format but not
        // run through the LaTeX compiler.
        // If we're running through the LaTeX compiler, we should write the
-       // generated files in the bufer's temporary directory.
-       bool const external_in_tmpdir = !runparams.nice && !runparams.dryrun;
+       // generated files in the buffer's temporary directory.
+       bool const external_in_tmpdir = !runparams.nice;
+       bool const dryrun = runparams.dryrun || runparams.inComment;
 
        // If the template has specified a PDFLaTeX output, then we try and
        // use that.
@@ -707,33 +708,34 @@ int InsetExternal::latex(Buffer const & buf, odocstream & os,
                                                        buf, os,
                                                        *(runparams.exportdata),
                                                        external_in_tmpdir,
-                                                       runparams.inComment);
+                                                       dryrun);
                 }
-                
        }
-        
+
        return external::writeExternal(params_, "LaTeX", buf, os,
                                        *(runparams.exportdata),
                                        external_in_tmpdir,
-                                       runparams.inComment);
+                                       dryrun);
 }
 
 
 int InsetExternal::plaintext(Buffer const & buf, odocstream & os,
-                        OutputParams const & runparams) const
+                             OutputParams const & runparams) const
 {
-       return external::writeExternal(params_, "Ascii", buf, os,
-                                      *(runparams.exportdata), false,
-                                      runparams.inComment);
+       os << '\n'; // output external material on a new line
+       external::writeExternal(params_, "Ascii", buf, os,
+                               *(runparams.exportdata), false,
+                               runparams.dryrun || runparams.inComment);
+       return PLAINTEXT_NEWLINE;
 }
 
 
 int InsetExternal::docbook(Buffer const & buf, odocstream & os,
-                          OutputParams const & runparams) const
+                           OutputParams const & runparams) const
 {
        return external::writeExternal(params_, "DocBook", buf, os,
                                       *(runparams.exportdata), false,
-                                      runparams.inComment);
+                                      runparams.dryrun || runparams.inComment);
 }
 
 
@@ -801,7 +803,9 @@ bool preview_wanted(InsetExternalParams const & params)
 docstring const latex_string(InsetExternal const & inset, Buffer const & buffer)
 {
        odocstringstream os;
-       OutputParams runparams;
+       // We don't need to set runparams.encoding since it is not used by
+       // latex().
+       OutputParams runparams(0);
        runparams.flavor = OutputParams::LATEX;
        inset.latex(buffer, os, runparams);
        return os.str();