]> git.lyx.org Git - features.git/blobdiff - src/insets/InsetExternal.cpp
Completion: handle undo in insets' insertCompletion methods
[features.git] / src / insets / InsetExternal.cpp
index 7fd96cbb1d277967b3ef3a50e407a2e85d410506..92308db704c3c020bddc3525f5054b024433d994 100644 (file)
@@ -29,7 +29,6 @@
 #include "LyX.h" // use_gui
 #include "LyXRC.h"
 #include "MetricsInfo.h"
-#include "OutputParams.h"
 #include "output_latex.h"
 #include "output_xhtml.h"
 #include "texstream.h"
@@ -570,7 +569,7 @@ static docstring latexString(InsetExternal const & inset)
        // We don't need to set runparams.encoding since it is not used by
        // latex().
        OutputParams runparams(0);
-       runparams.flavor = OutputParams::LATEX;
+       runparams.flavor = Flavor::LaTeX;
        inset.latex(os, runparams);
        return ods.str();
 }
@@ -649,7 +648,7 @@ void InsetExternal::updatePreview() const
                renderer_ = make_unique<RenderMonitoredPreview>(this);
                RenderMonitoredPreview * preview_ptr = renderer_->asMonitoredPreview();
                // This connection is closed at the same time as this is destroyed.
-               preview_ptr->connect([=]() { fileChanged(); });
+               preview_ptr->connect([this]() { fileChanged(); });
                add_preview_and_start_loading(*preview_ptr, *this, buffer());
                break;
        }
@@ -713,7 +712,7 @@ void InsetExternal::latex(otexstream & os, OutputParams const & runparams) const
 
        // If the template has specified a PDFLaTeX output, then we try and
        // use that.
-       if (runparams.flavor == OutputParams::PDFLATEX) {
+       if (runparams.flavor == Flavor::PdfLaTeX) {
                external::Template const * const et_ptr =
                        external::getTemplatePtr(params_);
                if (!et_ptr)
@@ -770,42 +769,35 @@ int InsetExternal::plaintext(odocstringstream & os,
 }
 
 
-int InsetExternal::docbook(odocstream & os,
-                          OutputParams const & runparams) const
+void InsetExternal::generateXML(XMLStream & xs, OutputParams const & runparams, std::string const & format) const
 {
        bool const external_in_tmpdir = !runparams.nice;
        bool const dryrun = runparams.dryrun || runparams.inComment;
        odocstringstream ods;
        otexstream ots(ods);
        external::RetVal retval =
-               external::writeExternal(params_, "DocBook", buffer(), ots,
-                   *(runparams.exportdata), external_in_tmpdir, dryrun);
+                       external::writeExternal(params_, format, buffer(), ots,
+                                               *(runparams.exportdata), external_in_tmpdir, dryrun);
        if (retval == external::KILLED) {
                LYXERR0("External template preparation killed.");
                if (buffer().isClone() && buffer().isExporting())
                        throw ConversionException();
        }
-       os << ods.str();
-       return int(count(ods.str().begin(), ods.str().end(), '\n'));
+       xs << XMLStream::ESCAPE_NONE << ods.str();
+}
+
+
+void InsetExternal::docbook(XMLStream & xs,
+                            OutputParams const & runparams) const
+{
+       generateXML(xs, runparams, "DocBook");
 }
 
 
 docstring InsetExternal::xhtml(XMLStream & xs,
                        OutputParams const & runparams) const
 {
-       bool const external_in_tmpdir = !runparams.nice;
-       bool const dryrun = runparams.dryrun || runparams.inComment;
-       odocstringstream ods;
-       otexstream ots(ods);
-       external::RetVal retval =
-               external::writeExternal(params_, "XHTML", buffer(), ots,
-                   *(runparams.exportdata), external_in_tmpdir, dryrun);
-       if (retval == external::KILLED) {
-               LYXERR0("External template preparation killed.");
-               if (buffer().isClone() && buffer().isExporting())
-                       throw ConversionException();
-       }
-       xs << XMLStream::ESCAPE_NONE << ods.str();
+       generateXML(xs, runparams, "XHTML");
        return docstring();
 }
 
@@ -823,25 +815,25 @@ void InsetExternal::validate(LaTeXFeatures & features) const
 
        string format;
        switch (features.runparams().flavor) {
-       case OutputParams::LATEX:
-       case OutputParams::DVILUATEX:
+       case Flavor::LaTeX:
+       case Flavor::DviLuaTeX:
                format = "LaTeX";
                break;
-       case OutputParams::LUATEX:
-       case OutputParams::PDFLATEX:
-       case OutputParams::XETEX:
+       case Flavor::LuaTeX:
+       case Flavor::PdfLaTeX:
+       case Flavor::XeTeX:
                format = "PDFLaTeX";
                break;
-       case OutputParams::XML:
+       case Flavor::DocBook5:
                format = "DocBook";
                break;
-       case OutputParams::HTML:
+       case Flavor::Html:
                format = "html";
                break;
-       case OutputParams::TEXT:
+       case Flavor::Text:
                format = "text";
                break;
-       case OutputParams::LYX:
+       case Flavor::LyX:
                format = "lyx";
                break;
        }