]> git.lyx.org Git - lyx.git/blobdiff - src/insets/insetexternal.C
This commit saves the need to check for lyx::use_gui in a number of places.
[lyx.git] / src / insets / insetexternal.C
index e93ca9e49f7863b19074be6ad09e352350199fcd..586b46cfd894339886d6ee9f76adb35fb328d29f 100644 (file)
@@ -22,6 +22,7 @@
 #include "debug.h"
 #include "dispatchresult.h"
 #include "exporter.h"
+#include "FuncStatus.h"
 #include "funcrequest.h"
 #include "gettext.h"
 #include "LaTeXFeatures.h"
@@ -31,9 +32,6 @@
 #include "metricsinfo.h"
 #include "outputparams.h"
 
-#include "frontends/lyx_gui.h"
-#include "frontends/LyXView.h"
-
 #include "graphics/PreviewLoader.h"
 
 #include "support/filetools.h"
@@ -50,6 +48,7 @@ namespace support = lyx::support;
 namespace external = lyx::external;
 namespace graphics = lyx::graphics;
 
+using lyx::docstring;
 using std::endl;
 using std::string;
 using std::auto_ptr;
@@ -438,7 +437,7 @@ void InsetExternal::doDispatch(LCursor & cur, FuncRequest & cmd)
        case LFUN_EXTERNAL_EDIT: {
                Buffer const & buffer = cur.buffer();
                InsetExternalParams p;
-               InsetExternalMailer::string2params(cmd.argument, buffer, p);
+               InsetExternalMailer::string2params(lyx::to_utf8(cmd.argument()), buffer, p);
                external::editExternal(p, buffer);
                break;
        }
@@ -446,7 +445,7 @@ void InsetExternal::doDispatch(LCursor & cur, FuncRequest & cmd)
        case LFUN_INSET_MODIFY: {
                Buffer const & buffer = cur.buffer();
                InsetExternalParams p;
-               InsetExternalMailer::string2params(cmd.argument, buffer, p);
+               InsetExternalMailer::string2params(lyx::to_utf8(cmd.argument()), buffer, p);
                setParams(p, buffer);
                break;
        }
@@ -563,22 +562,25 @@ graphics::Params get_grfx_params(InsetExternalParams const & eparams)
        if (gparams.display == graphics::DefaultDisplay)
                gparams.display = lyxrc.display_graphics;
        // Override the above if we're not using a gui
-       if (!lyx_gui::use_gui)
+       if (!lyx::use_gui)
                gparams.display = graphics::NoDisplay;
 
        return gparams;
 }
 
 
-string const getScreenLabel(InsetExternalParams const & params,
+docstring const getScreenLabel(InsetExternalParams const & params,
                            Buffer const & buffer)
 {
        external::Template const * const ptr =
                external::getTemplatePtr(params);
        if (!ptr)
-               return support::bformat(_("External template %1$s is not installed"),
-                                       params.templatename());
-       return external::doSubstitution(params, buffer, ptr->guiName, false);
+               // FIXME UNICODE
+               return support::bformat((_("External template %1$s is not installed")),
+                                       lyx::from_utf8(params.templatename()));
+       // FIXME UNICODE
+       return lyx::from_utf8(external::doSubstitution(params, buffer,
+                               ptr->guiName, false));
 }
 
 void add_preview_and_start_loading(RenderMonitoredPreview &,
@@ -688,7 +690,7 @@ int InsetExternal::latex(Buffer const & buf, ostream & os,
        // 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;
+       bool const external_in_tmpdir = !runparams.nice && !runparams.dryrun;
 
        // If the template has specified a PDFLaTeX output, then we try and
        // use that.
@@ -715,21 +717,16 @@ int InsetExternal::latex(Buffer const & buf, ostream & os,
 }
 
 
-int InsetExternal::plaintext(Buffer const & buf, ostream & os,
+int InsetExternal::plaintext(Buffer const & buf, lyx::odocstream & os,
                         OutputParams const & runparams) const
 {
-       return external::writeExternal(params_, "Ascii", buf, os,
-                                      *(runparams.exportdata), false,
-                                      runparams.inComment);
-}
-
-
-int InsetExternal::linuxdoc(Buffer const & buf, ostream & os,
-                           OutputParams const & runparams) const
-{
-       return external::writeExternal(params_, "LinuxDoc", buf, os,
+       std::ostringstream oss;
+       int const retval = external::writeExternal(params_, "Ascii", buf, oss,
                                       *(runparams.exportdata), false,
                                       runparams.inComment);
+       // FIXME UNICODE
+       os << lyx::from_utf8(oss.str());
+       return retval;
 }
 
 
@@ -801,7 +798,7 @@ bool preview_wanted(InsetExternalParams const & params)
        string const included_file = params.filename.absFilename();
 
        return params.display == external::PreviewDisplay &&
-               support::IsFileReadable(included_file);
+               support::isFileReadable(included_file);
 }