#include <map>
#include <set>
#include <sstream>
-#include <stack>
#include <vector>
using namespace std;
/// This is here to force the test to be done whenever parent_buffer
/// is accessed.
- Buffer const * parent() const {
+ Buffer const * parent() const
+ {
// ignore_parent temporarily "orphans" a buffer
// (e.g. if a child is compiled standalone)
if (ignore_parent)
}
///
- void setParent(Buffer const * pb) {
+ void setParent(Buffer const * pb)
+ {
if (parent_buffer == pb)
// nothing to do
return;
/// \p from initial position
/// \p to points to the end position
void updateStatistics(DocIterator & from, DocIterator & to,
- bool skipNoOutput = true);
+ bool skipNoOutput = true);
/// statistics accessor functions
- int wordCount() const { return word_count_; }
- int charCount(bool with_blanks) const {
+ int wordCount() const
+ {
+ return word_count_;
+ }
+ int charCount(bool with_blanks) const
+ {
return char_count_
+ (with_blanks ? blank_count_ : 0);
}
Buffer * Buffer::cloneFromMaster() const
{
BufferMap bufmap;
- cloned_buffers.push_back(new CloneList());
+ cloned_buffers.push_back(new CloneList);
CloneList * clones = cloned_buffers.back();
masterBuffer()->cloneWithChildren(bufmap, clones);
Buffer * Buffer::cloneBufferOnly() const {
- cloned_buffers.push_back(new CloneList());
+ cloned_buffers.push_back(new CloneList);
CloneList * clones = cloned_buffers.back();
Buffer * buffer_clone = new Buffer(fileName().absFileName(), false, this);
clones->insert(buffer_clone);
runparams.use_japanese = features.isRequired("japanese");
- if (!output_body)
+ if (!output_body) {
+ // Restore the parenthood if needed
+ if (!runparams.is_child)
+ d->ignore_parent = false;
return;
+ }
// make the body.
os << "\\begin{document}\n";
void Buffer::validate(LaTeXFeatures & features) const
{
- params().validate(features);
+ // Validate the buffer params, but not for included
+ // files, since they also use the parent buffer's
+ // params (# 5941)
+ if (!features.runparams().is_child)
+ params().validate(features);
for_each(paragraphs().begin(), paragraphs().end(),
bind(&Paragraph::validate, _1, ref(features)));
void Buffer::getSourceCode(odocstream & os, string const format,
pit_type par_begin, pit_type par_end,
- OutputWhat output) const
+ OutputWhat output, bool master) const
{
OutputParams runparams(¶ms().encoding());
runparams.nice = true;
// child of some other buffer, let's cut the link here,
// so that no concurring settings from the master
// (e.g. branch state) interfere (see #8101).
- // FIXME: Add an optional "from master" perspective.
- d->ignore_parent = true;
+ if (!master)
+ d->ignore_parent = true;
// We need to validate the Buffer params' features here
// in order to know if we should output polyglossia
// macros (instead of babel macros)
latexParagraphs(*this, text(), ots, runparams);
// Restore the parenthood
- d->ignore_parent = false;
+ if (!master)
+ d->ignore_parent = false;
}
} else {
os << "% ";
d->texrow.newline();
d->texrow.newline();
otexstream ots(os, d->texrow);
+ if (master)
+ runparams.is_child = true;
writeLaTeXSource(ots, string(), runparams, output);
}
}
buf->d->bak_clean = true;
FileName const fname = getAutosaveFileName();
- if (d->cloned_buffer_) {
- // If this buffer is cloned, we assume that
- // we are running in a separate thread already.
- FileName const tmp_ret = FileName::tempName("lyxauto");
- if (!tmp_ret.empty()) {
- writeFile(tmp_ret);
- // assume successful write of tmp_ret
- if (tmp_ret.moveTo(fname))
- return true;
- }
- // failed to write/rename tmp_ret so try writing direct
- return writeFile(fname);
- } else {
- /// This function is deprecated as the frontend needs to take care
- /// of cloning the buffer and autosaving it in another thread. It
- /// is still here to allow (QT_VERSION < 0x040400).
- AutoSaveBuffer autosave(*this, fname);
- autosave.start();
- return true;
+ LASSERT(d->cloned_buffer_, return false);
+
+ // If this buffer is cloned, we assume that
+ // we are running in a separate thread already.
+ FileName const tmp_ret = FileName::tempName("lyxauto");
+ if (!tmp_ret.empty()) {
+ writeFile(tmp_ret);
+ // assume successful write of tmp_ret
+ if (tmp_ret.moveTo(fname))
+ return true;
}
+ // failed to write/rename tmp_ret so try writing direct
+ return writeFile(fname);
}