#include "LayoutFile.h"
#include "LayoutModuleList.h"
#include "LyX.h"
-#include "LyXRC.h"
#include "Lexer.h"
#include "MetricsInfo.h"
#include "output_plaintext.h"
#include "support/lassert.h"
#include "support/lstrings.h" // contains
#include "support/lyxalgo.h"
+#include "support/mutex.h"
#include "support/bind.h"
docstring const uniqueID()
{
static unsigned int seed = 1000;
+ static Mutex mutex;
+ Mutex::Locker lock(&mutex);
return "file" + convert<docstring>(++seed);
}
bool isInputOrInclude(InsetCommandParams const & params)
{
Types const t = type(params);
- return t == INPUT || t == INCLUDE;
+ return t == INPUT || t == INCLUDE;
}
{
Buffer * childBuffer = loadIfNeeded();
- // FIXME: recursive includes
+ // FIXME RECURSIVE INCLUDE
+ // This isn't sufficient, as the inclusion could be downstream.
+ // But it'll have to do for now.
return (childBuffer == &buffer()) ? 0 : childBuffer;
}
from_utf8(incfile), true);
}
- FileName const writefile(makeAbsPath(mangled, masterBuffer->temppath()));
+ FileName const writefile(makeAbsPath(mangled, runparams.for_preview ?
+ buffer().temppath() : masterBuffer->temppath()));
LYXERR(Debug::LATEX, "incfile:" << incfile);
LYXERR(Debug::LATEX, "exportfile:" << exportfile);
// and language.
Encoding const * const oldEnc = runparams.encoding;
Language const * const oldLang = runparams.master_language;
- // If the master has full unicode flavor (XeTeX, LuaTeX),
+ // If the master uses non-TeX fonts (XeTeX, LuaTeX),
// the children must be encoded in plain utf8!
- runparams.encoding = runparams.isFullUnicode() ?
+ runparams.encoding = masterBuffer->params().useNonTeXFonts ?
encodings.fromLyXName("utf8-plain")
: &tmp->params().encoding();
runparams.master_language = buffer().params().language;
Buffer * child = loadIfNeeded();
if (!child)
return;
+ // FIXME RECURSIVE INCLUDE
+ // This isn't sufficient, as the inclusion could be downstream.
+ // But it'll have to do for now.
+ if (child == &buffer())
+ return;
child->collectBibKeys();
}
LBUFERR(mi.base.bv);
bool use_preview = false;
- if (RenderPreview::status() != LyXRC::PREVIEW_OFF) {
+ if (RenderPreview::previewText()) {
graphics::PreviewImage const * pimage =
preview_->getPreviewImage(mi.base.bv->buffer());
use_preview = pimage && pimage->image();
LBUFERR(pi.base.bv);
bool use_preview = false;
- if (RenderPreview::status() != LyXRC::PREVIEW_OFF) {
+ if (RenderPreview::previewText()) {
graphics::PreviewImage const * pimage =
preview_->getPreviewImage(pi.base.bv->buffer());
use_preview = pimage && pimage->image();
}
+void InsetInclude::write(ostream & os) const
+{
+ params().Write(os, &buffer());
+}
+
+
string InsetInclude::contextMenuName() const
{
return "context-include";
return;
preview_->removePreview(*buffer);
- add_preview(*preview_.get(), *this, *buffer);
+ add_preview(*preview_, *this, *buffer);
preview_->startLoading(*buffer);
}
// by latex() anyway.
OutputParams runparams(0);
runparams.flavor = OutputParams::LATEX;
+ runparams.for_preview = true;
inset.latex(os, runparams);
return ods.str();
Buffer const & buffer)
{
InsetCommandParams const & params = inset.params();
- if (RenderPreview::status() != LyXRC::PREVIEW_OFF &&
- preview_wanted(params, buffer)) {
+ if (RenderPreview::previewText() && preview_wanted(params, buffer)) {
renderer.setAbsFile(includedFileName(buffer, params));
docstring const snippet = latexString(inset);
renderer.addPreview(snippet, buffer);
}
-void InsetInclude::addToToc(DocIterator const & cpit, bool output_active) const
+void InsetInclude::addToToc(DocIterator const & cpit, bool output_active,
+ UpdateType utype) const
{
TocBackend & backend = buffer().tocBackend();
if (isListings(params())) {
if (label_)
- label_->addToToc(cpit, output_active);
+ label_->addToToc(cpit, output_active, utype);
InsetListingsParams p(to_utf8(params()["lstparams"]));
string caption = p.getParamValue("caption");
if (caption.empty())
return;
- Toc & toc = backend.toc("listing");
- docstring str = convert<docstring>(toc.size() + 1)
+ shared_ptr<Toc> toc = backend.toc("listing");
+ docstring str = convert<docstring>(toc->size() + 1)
+ ". " + from_utf8(caption);
DocIterator pit = cpit;
- toc.push_back(TocItem(pit, 0, str, output_active));
- return;
- }
- Buffer const * const childbuffer = getChildBuffer();
- if (!childbuffer)
- return;
+ toc->push_back(TocItem(pit, 0, str, output_active));
+ } else {
+ Buffer const * const childbuffer = getChildBuffer();
+ if (!childbuffer)
+ return;
- Toc & toc = backend.toc("child");
- docstring str = childbuffer->fileName().displayName();
- toc.push_back(TocItem(cpit, 0, str, output_active));
-
- TocList & toclist = backend.tocs();
- childbuffer->tocBackend().update(output_active);
- TocList const & childtoclist = childbuffer->tocBackend().tocs();
- TocList::const_iterator it = childtoclist.begin();
- TocList::const_iterator const end = childtoclist.end();
- for(; it != end; ++it)
- toclist[it->first].insert(toclist[it->first].end(),
- it->second.begin(), it->second.end());
+ shared_ptr<Toc> toc = backend.toc("child");
+ docstring str = childbuffer->fileName().displayName();
+ toc->push_back(TocItem(cpit, 0, str, output_active));
+
+ childbuffer->tocBackend().update(output_active, utype);
+ TocList const & childtoclist = childbuffer->tocBackend().tocs();
+ TocList::const_iterator it = childtoclist.begin();
+ TocList::const_iterator const end = childtoclist.end();
+ for(; it != end; ++it) {
+ shared_ptr<Toc> toc = backend.toc(it->first);
+ toc->insert(toc->end(), it->second->begin(), it->second->end());
+ }
+ }
}