X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Finsets%2FInsetExternal.cpp;h=6e0baff5d739556fb9437c5f78968c7606938389;hb=239b9919ffe28338d789e6dc9122228f77ab77a7;hp=b04ea898d7e3a6eb7f5411a6169a6dca3d875731;hpb=102e6340e522747a04c8b3f42834ff21ba6b225b;p=lyx.git diff --git a/src/insets/InsetExternal.cpp b/src/insets/InsetExternal.cpp index b04ea898d7..6e0baff5d7 100644 --- a/src/insets/InsetExternal.cpp +++ b/src/insets/InsetExternal.cpp @@ -30,6 +30,8 @@ #include "MetricsInfo.h" #include "OutputParams.h" #include "output_latex.h" +#include "output_xhtml.h" +#include "texstream.h" #include "TocBackend.h" #include "frontends/alert.h" @@ -97,7 +99,8 @@ TempName::~TempName() TempName & TempName::operator=(TempName const & other) { if (this != &other) { - tempname_.removeFile(); + if (!tempname_.empty()) + tempname_.removeFile(); support::TempFile f("lyxextXXXXXX.tmp"); f.setAutoRemove(false); tempname_ = f.name(); @@ -376,6 +379,8 @@ bool InsetExternalParams::read(Buffer const & buffer, Lexer & lex) if (lyxerr.debugging(Debug::EXTERNAL)) { lyxerr << "InsetExternalParams::read:\n"; + // false positive + // coverity[NEGATIVE_RETURNS] write(buffer, lyxerr); } @@ -419,7 +424,7 @@ InsetExternal::InsetExternal(Buffer * buf) // Mouse hover is not copied and remains empty InsetExternal::InsetExternal(InsetExternal const & other) : Inset(other), - boost::signals::trackable(), + boost::signals2::trackable(), params_(other.params_), renderer_(other.renderer_->clone(this)) {} @@ -501,11 +506,10 @@ bool InsetExternal::getStatus(Cursor & cur, FuncRequest const & cmd, void InsetExternal::addToToc(DocIterator const & cpit, bool output_active, UpdateType) const { - DocIterator pit = cpit; - pit.push_back(CursorSlice(const_cast(*this))); - shared_ptr toc = buffer().tocBackend().toc("external"); docstring str = screenLabel(params_, buffer()); - toc->push_back(TocItem(pit, 0, str, output_active)); + TocBuilder & b = buffer().tocBackend().builder("external"); + b.pushItem(cpit, str, output_active); + b.pop(); } @@ -558,9 +562,8 @@ static bool isPreviewWanted(InsetExternalParams const & params) static docstring latexString(InsetExternal const & inset) { - TexRow texrow; odocstringstream ods; - otexstream os(ods, texrow); + otexstream os(ods); // We don't need to set runparams.encoding since it is not used by // latex(). OutputParams runparams(0); @@ -728,12 +731,12 @@ int InsetExternal::plaintext(odocstringstream & os, if (runparams.for_tooltip) return 0; - TexRow texrow; - otexstream ots(os, texrow); + bool const external_in_tmpdir = !runparams.nice; + bool const dryrun = runparams.dryrun || runparams.inComment; + otexstream ots(os); ots << '\n'; // output external material on a new line external::writeExternal(params_, "Ascii", buffer(), ots, - *(runparams.exportdata), false, - runparams.dryrun || runparams.inComment); + *(runparams.exportdata), external_in_tmpdir, dryrun); return PLAINTEXT_NEWLINE; } @@ -741,23 +744,27 @@ int InsetExternal::plaintext(odocstringstream & os, int InsetExternal::docbook(odocstream & os, OutputParams const & runparams) const { - TexRow texrow; + bool const external_in_tmpdir = !runparams.nice; + bool const dryrun = runparams.dryrun || runparams.inComment; odocstringstream ods; - otexstream ots(ods, texrow); + otexstream ots(ods); external::writeExternal(params_, "DocBook", buffer(), ots, - *(runparams.exportdata), false, - runparams.dryrun || runparams.inComment); + *(runparams.exportdata), external_in_tmpdir, dryrun); os << ods.str(); return int(count(ods.str().begin(), ods.str().end(), '\n')); } -docstring InsetExternal::xhtml(XHTMLStream & /*xs*/, - OutputParams const & /*rp*/) const +docstring InsetExternal::xhtml(XHTMLStream & xs, + OutputParams const & runparams) const { -// external::writeExternal(params_, "XHTML", buffer(), os, -// *(runparams.exportdata), false, -// runparams.dryrun || runparams.inComment); + bool const external_in_tmpdir = !runparams.nice; + bool const dryrun = runparams.dryrun || runparams.inComment; + odocstringstream ods; + otexstream ots(ods); + external::writeExternal(params_, "XHTML", buffer(), ots, + *(runparams.exportdata), external_in_tmpdir, dryrun); + xs << XHTMLStream::ESCAPE_NONE << ods.str(); return docstring(); } @@ -821,10 +828,8 @@ void InsetExternal::validate(LaTeXFeatures & features) const external::TemplateManager & etm = external::TemplateManager::get(); - it = cit->second.preambleNames.begin(); - end = cit->second.preambleNames.end(); - for (; it != end; ++it) { - string const preamble = etm.getPreambleDefByName(*it); + for (string const & name : cit->second.preambleNames) { + docstring const preamble = etm.getPreambleDefByName(name); if (!preamble.empty()) features.addPreambleSnippet(preamble); }