X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FBuffer.cpp;h=1dc5d592e506f46f66ae3b360ffd4d37c48ad3cc;hb=5279d5a8a58b9e59442b9f3f504ea397274e2b19;hp=76ec7d81ab217aad1d23365916a69b608a0e3990;hpb=3285ce1d5cb9ba79af700d004401115269e97ada;p=lyx.git diff --git a/src/Buffer.cpp b/src/Buffer.cpp index 76ec7d81ab..1dc5d592e5 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -195,6 +195,9 @@ public: /// is this an unnamed file (New...)? bool unnamed; + /// is this an internal bufffer? + bool internal_buffer; + /// buffer is r/o bool read_only; @@ -355,11 +358,12 @@ static FileName createBufferTmpDir() Buffer::Impl::Impl(Buffer * owner, FileName const & file, bool readonly_, Buffer const * cloned_buffer) : owner_(owner), lyx_clean(true), bak_clean(true), unnamed(false), - read_only(readonly_), filename(file), file_fully_loaded(false), - toc_backend(owner), macro_lock(false), timestamp_(0), checksum_(0), - wa_(0), gui_(0), undo_(*owner), bibinfo_cache_valid_(false), - bibfile_cache_valid_(false), cite_labels_valid_(false), - preview_loader_(0), cloned_buffer_(cloned_buffer), clone_list_(0), + internal_buffer(false), read_only(readonly_), filename(file), + file_fully_loaded(false), toc_backend(owner), macro_lock(false), + timestamp_(0), checksum_(0), wa_(0), gui_(0), undo_(*owner), + bibinfo_cache_valid_(false), bibfile_cache_valid_(false), + cite_labels_valid_(false), preview_loader_(0), + cloned_buffer_(cloned_buffer), clone_list_(0), doing_export(false), parent_buffer(0) { if (!cloned_buffer_) { @@ -379,6 +383,7 @@ Buffer::Impl::Impl(Buffer * owner, FileName const & file, bool readonly_, bibfile_status_ = cloned_buffer_->d->bibfile_status_; cite_labels_valid_ = cloned_buffer_->d->cite_labels_valid_; unnamed = cloned_buffer_->d->unnamed; + internal_buffer = cloned_buffer_->d->internal_buffer; } @@ -1769,7 +1774,7 @@ void Buffer::writeLyXHTMLSource(odocstream & os, bool const output_preamble = output == FullSource || output == OnlyPreamble; bool const output_body = - output == FullSource || output == OnlyBody; + output == FullSource || output == OnlyBody || output == IncludedFile; if (output_preamble) { os << "\n" @@ -1852,11 +1857,14 @@ void Buffer::writeLyXHTMLSource(odocstream & os, } if (output_body) { - os << "\n"; + bool const output_body_tag = (output != IncludedFile); + if (output_body_tag) + os << "\n"; XHTMLStream xs(os); params().documentClass().counters().reset(); xhtmlParagraphs(text(), *this, xs, runparams); - os << "\n"; + if (output_body_tag) + os << "\n"; } if (output_preamble) @@ -2665,7 +2673,13 @@ bool Buffer::isUnnamed() const /// retrieving fileName() nor for checking if it is unnamed or not. bool Buffer::isInternal() const { - return fileName().extension() == "internal"; + return d->internal_buffer; +} + + +void Buffer::setInternal(bool flag) +{ + d->internal_buffer = flag; } @@ -3303,9 +3317,7 @@ void Buffer::getSourceCode(odocstream & os, string const format, texrow.newline(); texrow.newline(); // output paragraphs - if (params().isDocBook()) - docbookParagraphs(text(), *this, os, runparams); - else if (runparams.flavor == OutputParams::HTML) { + if (runparams.flavor == OutputParams::HTML) { XHTMLStream xs(os); setMathFlavor(runparams); xhtmlParagraphs(text(), *this, xs, runparams); @@ -3315,6 +3327,8 @@ void Buffer::getSourceCode(odocstream & os, string const format, // Probably should have some routine with a signature like them. writePlaintextParagraph(*this, text().paragraphs()[par_begin], os, runparams, dummy); + } else if (params().isDocBook()) { + docbookParagraphs(text(), *this, os, runparams); } else { // latex or literate otexstream ots(os, texrow); @@ -3332,11 +3346,16 @@ void Buffer::getSourceCode(odocstream & os, string const format, d->texrow.reset(); d->texrow.newline(); d->texrow.newline(); - if (params().isDocBook()) - writeDocBookSource(os, absFileName(), runparams, output); - else if (runparams.flavor == OutputParams::HTML) + if (runparams.flavor == OutputParams::HTML) { writeLyXHTMLSource(os, runparams, output); - else { + } else if (runparams.flavor == OutputParams::TEXT) { + if (output == OnlyPreamble) { + os << _("% Plaintext does not have a preamble."); + } else + writePlaintextFile(*this, os, runparams); + } else if (params().isDocBook()) { + writeDocBookSource(os, absFileName(), runparams, output); + } else { // latex or literate otexstream ots(os, d->texrow); writeLaTeXSource(ots, string(), runparams, output);