#include "LayoutFile.h"
#include "LayoutModuleList.h"
#include "LyX.h"
-#include "LyXFunc.h"
#include "LyXRC.h"
#include "Lexer.h"
#include "MetricsInfo.h"
+#include "output_xhtml.h"
#include "OutputParams.h"
#include "TextClass.h"
#include "TocBackend.h"
}
+void InsetInclude::setChildBuffer(Buffer * buffer)
+{
+ child_buffer_ = buffer;
+}
+
+
ParamInfo const & InsetInclude::findInfo(string const & /* cmdName */)
{
// FIXME
}
+bool InsetInclude::isChildIncluded() const
+{
+ std::list<std::string> includeonlys =
+ buffer().params().getIncludedChildren();
+ if (includeonlys.empty())
+ return true;
+ return (std::find(includeonlys.begin(),
+ includeonlys.end(),
+ to_utf8(params()["filename"])) != includeonlys.end());
+}
+
+
docstring InsetInclude::screenLabel() const
{
docstring temp;
temp = buffer().B_("Verbatim Input*");
break;
case INCLUDE:
- temp = buffer().B_("Include");
+ if (isChildIncluded())
+ temp = buffer().B_("Include");
+ else
+ temp += buffer().B_("Include (excluded)");
break;
case LISTINGS:
temp = listings_label_;
Buffer * InsetInclude::loadIfNeeded() const
{
+ // This is for background export and preview. We don't want to load the
+ // cloned child document again.
+ if (child_buffer_ && theBufferList().isLoaded(child_buffer_)
+ && child_buffer_->isClone())
+ return child_buffer_;
+
// Don't try to load it again if we failed before.
if (failedtoload_ || isVerbatim(params()) || isListings(params()))
return 0;
}
-docstring InsetInclude::xhtml(odocstream & os, OutputParams const &rp) const
+docstring InsetInclude::xhtml(XHTMLStream & xs, OutputParams const &rp) const
{
if (rp.inComment)
return docstring();
bool const listing = isListings(params());
if (listing || isVerbatim(params())) {
if (listing)
- os << "<pre>\n";
+ xs << html::StartTag("pre");
// FIXME: We don't know the encoding of the file, default to UTF-8.
- os << includedFilename(buffer(), params()).fileContents("UTF-8");
+ xs << includedFilename(buffer(), params()).fileContents("UTF-8");
if (listing)
- os << "</pre>\n";
+ xs << html::EndTag("pre");
return docstring();
}
Buffer const * const ibuf = loadIfNeeded();
if (!ibuf)
return docstring();
- ibuf->writeLyXHTMLSource(os, rp, true);
+ ibuf->writeLyXHTMLSource(xs.os(), rp, true);
return docstring();
}
} // namespace anon
-void InsetInclude::addPreview(graphics::PreviewLoader & ploader) const
+void InsetInclude::addPreview(DocIterator const & /*inset_pos*/,
+ graphics::PreviewLoader & ploader) const
{
Buffer const & buffer = ploader.buffer();
if (!preview_wanted(params(), buffer))
setParams(p);
}
-void InsetInclude::updateLabels(ParIterator const & it)
+void InsetInclude::updateBuffer(ParIterator const & it, UpdateType utype)
{
Buffer const * const childbuffer = getChildBuffer();
if (childbuffer) {
- childbuffer->updateLabels(Buffer::UpdateChildOnly);
+ childbuffer->updateBuffer(Buffer::UpdateChildOnly, utype);
return;
}
if (!isListings(params()))
return;
if (label_)
- label_->updateLabels(it);
+ label_->updateBuffer(it, utype);
InsetListingsParams const par(to_utf8(params()["lstparams"]));
if (par.getParamValue("caption").empty()) {
docstring const cnt = from_ascii("listing");
listings_label_ = master.B_("Program Listing");
if (counters.hasCounter(cnt)) {
- counters.step(cnt);
+ counters.step(cnt, utype);
listings_label_ += " " + convert<docstring>(counters.value(cnt));
}
}