]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetExternal.cpp
Merge branch 'master' of git.lyx.org:lyx
[lyx.git] / src / insets / InsetExternal.cpp
index 67671ac135b0bec06a1a76c6d8d2956b0618facf..ea51664978c33fca4dee8ea53e9d1791182b3240 100644 (file)
 
 #include "graphics/PreviewLoader.h"
 
+#include "support/bind.h"
 #include "support/convert.h"
 #include "support/debug.h"
 #include "support/ExceptionMessage.h"
 #include "support/filetools.h"
 #include "support/gettext.h"
+#include "support/lassert.h"
 #include "support/lstrings.h"
 #include "support/lyxlib.h"
-#include "support/Translator.h"
-
-#include "support/bind.h"
 
 #include <sstream>
+#include <vector>
 
 using namespace std;
 using namespace lyx::support;
@@ -503,8 +503,14 @@ docstring screenLabel(InsetExternalParams const & params,
                                        from_utf8(params.templatename()));
        // FIXME UNICODE
        docstring gui = _(ptr->guiName);
-       return from_utf8(external::doSubstitution(params, buffer,
-                               to_utf8(gui), false));
+       gui += ": ";
+
+       if (params.filename.empty())
+               gui += "???";
+       else
+               gui += from_utf8(params.filename.relFileName(buffer.filePath()));
+
+       return gui;
 }
 
 } // namespace anon
@@ -518,8 +524,9 @@ static bool isPreviewWanted(InsetExternalParams const & params)
 
 static docstring latexString(InsetExternal const & inset)
 {
+       TexRow texrow;
        odocstringstream ods;
-       otexstream os(ods);
+       otexstream os(ods, texrow);
        // We don't need to set runparams.encoding since it is not used by
        // latex().
        OutputParams runparams(0);
@@ -636,14 +643,14 @@ void InsetExternal::read(Lexer & lex)
 }
 
 
-int InsetExternal::latex(otexstream & os, OutputParams const & runparams) const
+void InsetExternal::latex(otexstream & os, OutputParams const & runparams) const
 {
        if (params_.draft) {
                // FIXME UNICODE
                os << "\\fbox{\\ttfamily{}"
                   << from_utf8(params_.filename.outputFileName(buffer().filePath()))
                   << "}\n";
-               return 1;
+               return;
        }
 
        // "nice" means that the buffer is exported to LaTeX format but not
@@ -659,25 +666,28 @@ int InsetExternal::latex(otexstream & os, OutputParams const & runparams) const
                external::Template const * const et_ptr =
                        external::getTemplatePtr(params_);
                if (!et_ptr)
-                       return 0;
+                       return;
                external::Template const & et = *et_ptr;
 
                external::Template::Formats::const_iterator cit =
                        et.formats.find("PDFLaTeX");
 
                if (cit != et.formats.end()) {
-                       return external::writeExternal(params_, "PDFLaTeX",
-                                                      buffer(), os.os(),
-                                                      *(runparams.exportdata),
-                                                      external_in_tmpdir,
-                                                      dryrun);
+                       int l = external::writeExternal(params_, "PDFLaTeX",
+                                                       buffer(), os.os(),
+                                                       *(runparams.exportdata),
+                                                       external_in_tmpdir,
+                                                       dryrun);
+                       os.texrow().newlines(l);
+                       return;
                }
        }
 
-       return external::writeExternal(params_, "LaTeX", buffer(), os.os(),
-                                      *(runparams.exportdata),
-                                      external_in_tmpdir,
-                                      dryrun);
+       int l = external::writeExternal(params_, "LaTeX", buffer(), os.os(),
+                                       *(runparams.exportdata),
+                                       external_in_tmpdir,
+                                       dryrun);
+       os.texrow().newlines(l);
 }
 
 
@@ -725,6 +735,7 @@ void InsetExternal::validate(LaTeXFeatures & features) const
        string format;
        switch (features.runparams().flavor) {
        case OutputParams::LATEX:
+       case OutputParams::DVILUATEX:
                format = "LaTeX";
                break;
        case OutputParams::LUATEX:
@@ -741,6 +752,9 @@ void InsetExternal::validate(LaTeXFeatures & features) const
        case OutputParams::TEXT:
                format = "text";
                break;
+       case OutputParams::LYX:
+               format = "lyx";
+               break;
        }
        external::Template::Formats::const_iterator cit =
                et.formats.find(format);
@@ -756,7 +770,7 @@ void InsetExternal::validate(LaTeXFeatures & features) const
                        return;
        }
 
-       // FIXME: We don't need that always
+       // FIXME: We don't need that always, see InsetGraphics
        features.require("lyxdot");
 
        vector<string>::const_iterator it  = cit->second.requirements.begin();
@@ -791,9 +805,9 @@ void InsetExternal::addPreview(DocIterator const & /*inset_pos*/,
 }
 
 
-docstring InsetExternal::contextMenuName() const
+string InsetExternal::contextMenuName() const
 {
-       return from_ascii("context-external");
+       return "context-external";
 }