X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FBuffer.cpp;h=445503993eae7ad536bd105b1649645d89c93ed8;hb=d9082639080b9de993742bd352f92e5183058cf5;hp=0d5de8c78c8e15f12017869badd9da5ebcc9ab54;hpb=c0a59871813d853ba455ec8d39be61db4f4b2848;p=lyx.git diff --git a/src/Buffer.cpp b/src/Buffer.cpp index 0d5de8c78c..445503993e 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -69,7 +69,6 @@ #include "insets/InsetBranch.h" #include "insets/InsetInclude.h" -#include "insets/InsetTabular.h" #include "insets/InsetText.h" #include "mathed/InsetMathHull.h" @@ -1772,7 +1771,7 @@ Buffer::ExportStatus Buffer::makeLaTeXFile(FileName const & fname, catch (EncodingException const & e) { docstring const failed(1, e.failed_char); ostringstream oss; - oss << "0x" << hex << e.failed_char << dec; + oss << "0x" << hex << static_cast(e.failed_char) << dec; if (getParFromID(e.par_id).paragraph().layout().pass_thru) { docstring msg = bformat(_("Uncodable character '%1$s'" " (code point %2$s)"), @@ -2138,7 +2137,7 @@ Buffer::ExportStatus Buffer::writeDocBookSource(odocstream & os, // parsep in output_docbook.cpp). os << "\n" << "\n"; + << "\n See https://www.lyx.org/ for more information -->\n"; // Directly output the root tag, based on the current type of document. string languageCode = params().language->code(); @@ -2593,18 +2592,16 @@ void Buffer::collectBibKeys(FileNameList & checkedFiles) const } -void Buffer::addBiblioInfo(BiblioInfo const & bin) const +void Buffer::addBiblioInfo(BiblioInfo const & bi_in) const { - // We add the biblio info to the master buffer, - // if there is one, but also to every single buffer, - // in case a child is compiled alone. - BiblioInfo & bi = d->bibinfo_; - bi.mergeBiblioInfo(bin); + // We add the biblio info to the parent buffer, + // if there is one, but also to this buffer, in case + // it is compiled alone. + BiblioInfo & our_bi = d->bibinfo_; + our_bi.mergeBiblioInfo(bi_in); - if (parent() != nullptr) { - BiblioInfo & masterbi = parent()->d->bibinfo_; - masterbi.mergeBiblioInfo(bin); - } + if (parent()) + parent()->addBiblioInfo(bi_in); } @@ -3139,6 +3136,11 @@ ParConstIterator Buffer::par_iterator_end() const return ParConstIterator(doc_iterator_end(this)); } +bool Buffer::empty() const +{ + return paragraphs().size() == 1 && paragraphs().front().empty(); +} + Language const * Buffer::language() const { @@ -4054,18 +4056,29 @@ unique_ptr Buffer::getSourceCode(odocstream & os, string const & format, // Some macros rely on font encoding runparams.main_fontenc = params().main_font_encoding(); + // Use the right wrapping for the comment at the beginning of the generated + // snippet, so that it is either valid LaTeX or valid XML (including HTML and DocBook). + docstring comment_start = from_ascii("% "); + docstring comment_end = from_ascii(""); + if (runparams.flavor == Flavor::Html || runparams.flavor == Flavor::DocBook5) { + comment_start = from_ascii(""); + } + if (output == CurrentParagraph) { runparams.par_begin = par_begin; runparams.par_end = par_end; if (par_begin + 1 == par_end) { - os << "% " + os << comment_start << bformat(_("Preview source code for paragraph %1$d"), par_begin) + << comment_end << "\n\n"; } else { - os << "% " + os << comment_start << bformat(_("Preview source code from paragraph %1$s to %2$s"), convert(par_begin), convert(par_end - 1)) + << comment_end << "\n\n"; } // output paragraphs @@ -4115,13 +4128,14 @@ unique_ptr Buffer::getSourceCode(odocstream & os, string const & format, d->ignore_parent = false; } } else { - os << "% "; + os << comment_start; if (output == FullSource) os << _("Preview source code"); else if (output == OnlyPreamble) os << _("Preview preamble"); else if (output == OnlyBody) os << _("Preview body"); + os << comment_end; os << "\n\n"; if (runparams.flavor == Flavor::LyX) { ostringstream ods; @@ -4135,9 +4149,9 @@ unique_ptr Buffer::getSourceCode(odocstream & os, string const & format, } else if (runparams.flavor == Flavor::Html) { writeLyXHTMLSource(os, runparams, output); } else if (runparams.flavor == Flavor::Text) { - if (output == OnlyPreamble) { + if (output == OnlyPreamble) os << "% "<< _("Plain text does not have a preamble."); - } else + else writePlaintextFile(*this, os, runparams); } else if (runparams.flavor == Flavor::DocBook5) { writeDocBookSource(os, runparams, output);