#include "CutAndPaste.h"
#include "DispatchResult.h"
#include "DocIterator.h"
-#include "Encoding.h"
+#include "BufferEncodings.h"
#include "ErrorList.h"
#include "Exporter.h"
#include "Format.h"
CloneList * clone_list_;
/// are we in the process of exporting this buffer?
mutable bool doing_export;
-
+
/// compute statistics
/// \p from initial position
/// \p to points to the end position
/// Creates the per buffer temporary directory
static FileName createBufferTmpDir()
{
+ // FIXME THREAD
static int count;
// We are in our own directory. Why bother to mangle name?
// In fact I wrote this code to circumvent a problematic behaviour
// The clone needs its own DocumentClass, since running updateBuffer() will
// modify it, and we would otherwise be sharing it with the original Buffer.
- buffer_clone->params().makeDocumentClass();
+ buffer_clone->params().makeDocumentClass(true);
ErrorList el;
cap::switchBetweenClasses(
params().documentClassPtr(), buffer_clone->params().documentClassPtr(),
// The clone needs its own DocumentClass, since running updateBuffer() will
// modify it, and we would otherwise be sharing it with the original Buffer.
- buffer_clone->params().makeDocumentClass();
+ buffer_clone->params().makeDocumentClass(true);
ErrorList el;
cap::switchBetweenClasses(
params().documentClassPtr(), buffer_clone->params().documentClassPtr(),
}
+BufferParams const & Buffer::masterParams() const
+{
+ if (masterBuffer() == this)
+ return params();
+
+ BufferParams & mparams = const_cast<Buffer *>(masterBuffer())->params();
+ // Copy child authors to the params. We need those pointers.
+ AuthorList const & child_authors = params().authors();
+ AuthorList::Authors::const_iterator it = child_authors.begin();
+ for (; it != child_authors.end(); it++)
+ mparams.authors().record(*it);
+ return mparams;
+}
+
+
ParagraphList & Buffer::paragraphs()
{
return text().paragraphs();
}
}
- if (!params().master.empty()) {
+ if (!parent() && !params().master.empty()) {
FileName const master_file = makeAbsPath(params().master,
onlyPath(absFileName()));
if (isLyXFileName(master_file.absFileName())) {
TempFile const tempfile("Buffer_importStringXXXXXX." + fmt->extension());
FileName const name(tempfile.name());
ofdocstream os(name.toFilesystemEncoding().c_str());
- bool const success = (os << contents);
+ // Do not convert os implicitly to bool, since that is forbidden in C++11.
+ bool const success = !(os << contents).fail();
os.close();
bool converted = false;
// The top of the file should not be written by params().
// write out a comment in the top of the file
+ // Important: Keep the version formatting in sync with lyx2lyx and
+ // tex2lyx (bug 7951)
ofs << "#LyX " << lyx_version_major << "." << lyx_version_minor
<< " created this file. For more info see http://www.lyx.org/\n"
<< "\\lyxformat " << LYX_FORMAT << "\n"
lyxerr << "File '" << fname << "' was not closed properly." << endl;
}
- errors("Export");
+ if (runparams_in.silent)
+ errorList.clear();
+ else
+ errors("Export");
return !failed_export;
}
d->ignore_parent = true;
// Classify the unicode characters appearing in math insets
- Encodings::initUnicodeMath(*this);
+ BufferEncodings::initUnicodeMath(*this);
// validate the buffer.
LYXERR(Debug::LATEX, " Validating buffer...");
LaTeXFeatures features(*this, params(), runparams);
validate(features);
- runparams.use_polyglossia = features.usePolyglossia();
+ // This is only set once per document (in master)
+ if (!runparams.is_child)
+ runparams.use_polyglossia = features.usePolyglossia();
LYXERR(Debug::LATEX, " Buffer validation done.");
bool const output_preamble =
runparams.use_babel = params().writeLaTeX(os, features,
d->filename.onlyPath());
- runparams.use_japanese = features.isRequired("japanese");
+ // Japanese might be required only in some children of a document,
+ // but once required, we must keep use_japanese true.
+ runparams.use_japanese |= features.isRequired("japanese");
if (!output_body) {
// Restore the parenthood if needed
if (output_preamble) {
os << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
- << "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1 plus MathML 2.0//EN\" \"http://www.w3.org/TR/2001/REC-MathML2-20010221/dtd/xhtml-math11-f.dtd\">\n"
+ << "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1 plus MathML 2.0//EN\" \"http://www.w3.org/Math/DTD/mathml2/xhtml-math11-f.dtd\">\n"
// FIXME Language should be set properly.
<< "<html xmlns=\"http://www.w3.org/1999/xhtml\">\n"
<< "<head>\n"
<< ";\n";
css << "}\n";
}
-
+
docstring const dstyles = css.str();
if (!dstyles.empty()) {
bool written = false;
setBusy(false);
- errors("ChkTeX");
+ if (runparams.silent)
+ d->errorLists["ChkTeX"].clear();
+ else
+ errors("ChkTeX");
return res;
}
break;
}
- case LFUN_BUILD_PROGRAM:
- doExport("program", true);
+ case LFUN_BUILD_PROGRAM: {
+ ExportStatus const status = doExport("program", true);
+ dr.setError(status != ExportSuccess);
+ if (status != ExportSuccess)
+ dr.setMessage(_("Error generating literate programming code."));
break;
+ }
case LFUN_BUFFER_CHKTEX:
runChktex();
msg += ("\n");
msg += bformat(_("Branch \"%1$s\" already exists."), branch_name);
} else {
+ undo().recordUndoFullDocument(CursorData());
branch_list.add(branch_name);
branch = branch_list.find(branch_name);
string const x11hexname = X11hexname(branch->color());
break;
}
- if (!doExport("dvi", true)) {
+ if (doExport("dvi", true) != ExportSuccess) {
showPrintError(absFileName());
dr.setMessage(_("Error exporting to DVI."));
break;
string const paramName = "key";
for (InsetIterator it = inset_iterator_begin(inset()); it; ++it) {
- if (it->lyxCode() != CITE_CODE)
+ if (it->lyxCode() != CITE_CODE)
continue;
InsetCommand * inset = it->asInsetCommand();
docstring const oldValue = inset->getParam(paramName);
// Emit the signal to show the error list or copy it back to the
// cloned Buffer so that it can be emitted afterwards.
if (format != backend_format) {
- if (d->cloned_buffer_) {
+ if (runparams.silent)
+ error_list.clear();
+ else if (d->cloned_buffer_)
d->cloned_buffer_->d->errorLists[error_type] =
d->errorLists[error_type];
- } else
+ else
errors(error_type);
// also to the children, in case of master-buffer-view
ListOfBuffers clist = getDescendents();
ListOfBuffers::const_iterator cit = clist.begin();
ListOfBuffers::const_iterator const cen = clist.end();
for (; cit != cen; ++cit) {
- if (d->cloned_buffer_) {
+ if (runparams.silent)
+ (*cit)->d->errorLists[error_type].clear();
+ else if (d->cloned_buffer_) {
// Enable reverse search by copying back the
// texrow object to the cloned buffer.
// FIXME: this is not thread safe.
DocumentClass const & textclass = master->params().documentClass();
// do this only if we are the top-level Buffer
- if (master == this)
+ if (master == this) {
+ textclass.counters().reset(from_ascii("bibitem"));
reloadBibInfoCache();
+ }
// keep the buffers to be children in this set. If the call from the
// master comes back we can see which of them were actually seen (i.e.
if (master != this) {
bufToUpdate.insert(this);
master->updateBuffer(UpdateMaster, utype);
- // Do this here in case the master has no gui associated with it. Then,
- // the TocModel is not updated and TocModel::toc_ is invalid (bug 5699).
- if (!master->d->gui_)
+ // If the master buffer has no gui associated with it, then the TocModel is
+ // not updated during the updateBuffer call and TocModel::toc_ is invalid
+ // (bug 5699). The same happens if the master buffer is open in a different
+ // window. This test catches both possibilities.
+ // See: http://marc.info/?l=lyx-devel&m=138590578911716&w=2
+ // There remains a problem here: If there is another child open in yet a third
+ // window, that TOC is not updated. So some more general solution is needed at
+ // some point.
+ if (master->d->gui_ != d->gui_)
structureChanged();
// was buf referenced from the master (i.e. not in bufToUpdate anymore)?
word_count_ = 0;
char_count_ = 0;
blank_count_ = 0;
-
+
for (DocIterator dit = from ; dit != to && !dit.atEnd(); ) {
if (!dit.inTexted()) {
dit.forwardPos();
continue;
}
-
+
Paragraph const & par = dit.paragraph();
pos_type const pos = dit.pos();
-
+
// Copied and adapted from isWordSeparator() in Paragraph
if (pos == dit.lastpos()) {
inword = false;
break;
continue;
} else if (!par.isDeleted(pos)) {
- if (par.isWordSeparator(pos))
+ if (par.isWordSeparator(pos))
inword = false;
else if (!inword) {
++word_count_;
}
-Buffer::ReadStatus Buffer::reload(bool clearUndo)
+Buffer::ReadStatus Buffer::reload()
{
setBusy(true);
// c.f. bug http://www.lyx.org/trac/ticket/6587
updateTitles();
markClean();
message(bformat(_("Document %1$s reloaded."), disp_fn));
- if (clearUndo)
- d->undo_.clear();
+ d->undo_.clear();
} else {
message(bformat(_("Could not reload document %1$s."), disp_fn));
}