// Do not remove the comment below, so we get merge conflict in
// independent branches. Instead add your own.
-int const LYX_FORMAT = 370; // uwestoehr: option to suppress default date
+int const LYX_FORMAT = 371; // uwestoehr: option to turn off mhchem
typedef map<string, bool> DepClean;
typedef map<docstring, pair<InsetLabel const *, Buffer::References> > RefCache;
return parent_buffer;
}
///
- void setParent(Buffer const * pb) { parent_buffer = pb; }
+ void setParent(Buffer const * pb) {
+ if (parent_buffer && pb && parent_buffer != pb)
+ LYXERR0("Warning: a buffer should not have two parents!");
+ parent_buffer = pb;
+ }
private:
/// So we can force access via the accessors.
mutable Buffer const * parent_buffer;
{
LYXERR(Debug::INFO, "Buffer::Buffer()");
- d->inset = new InsetText(*this);
+ d->inset = new InsetText(this);
d->inset->setAutoBreakRows(true);
d->inset->getText(0)->setMacrocontextPosition(par_iterator_begin());
}
// read main text
bool const res = text().read(lex, errorList, d->inset);
+ usermacros.clear();
updateMacros();
updateMacroInstances();
return res;
d->texrow.reset();
if (!only_body) {
- os << "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"" <<
- " \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n";
+ os << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
+ os << "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1 plus MathML 2.0//EN\" \"http://www.w3.org/TR/MathML2/dtd/xhtml-math11-f.dtd\">\n";
// FIXME Language should be set properly.
- os << "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">\n";
+ os << "<html xmlns=\"http://www.w3.org/1999/xhtml\">\n";
// FIXME Header
os << "<head>\n";
// FIXME Presumably need to set this right
os << "</head>\n<body>\n";
}
+ XHTMLStream xs(os);
params().documentClass().counters().reset();
- xhtmlParagraphs(text(), *this, os, runparams);
+ xhtmlParagraphs(text(), *this, xs, runparams);
if (!only_body)
os << "</body>\n</html>\n";
}
}
-std::vector<Buffer *> Buffer::getChildren() const
+std::vector<Buffer *> Buffer::getChildren(bool grand_children) const
{
std::vector<Buffer *> clist;
// loop over children
for (; it != end; ++it) {
Buffer * child = const_cast<Buffer *>(it->first);
clist.push_back(child);
- // there might be grandchildren
- std::vector<Buffer *> glist = child->getChildren();
- for (vector<Buffer *>::const_iterator git = glist.begin();
- git != glist.end(); ++git)
- clist.push_back(*git);
+ if (grand_children) {
+ // there might be grandchildren
+ std::vector<Buffer *> glist = child->getChildren();
+ for (vector<Buffer *>::const_iterator git = glist.begin();
+ git != glist.end(); ++git)
+ clist.push_back(*git);
+ }
}
return clist;
}
// get macro data
MathMacroTemplate & macroTemplate =
static_cast<MathMacroTemplate &>(*iit->inset);
- MacroContext mc(*this, it);
+ MacroContext mc(this, it);
macroTemplate.updateToContext(mc);
// valid?
continue;
// register macro
+ // FIXME (Abdel), I don't understandt why we pass 'it' here
+ // instead of 'macroTemplate' defined above... is this correct?
d->macros[macroTemplate.name()][it] =
- Impl::ScopeMacro(scope, MacroData(*this, it));
+ Impl::ScopeMacro(scope, MacroData(const_cast<Buffer *>(this), it));
}
// next paragraph
// update macro in all cells of the InsetMathNest
DocIterator::idx_type n = minset->nargs();
- MacroContext mc = MacroContext(*this, it);
+ MacroContext mc = MacroContext(this, it);
for (DocIterator::idx_type i = 0; i < n; ++i) {
MathData & data = minset->cell(i);
data.updateMacros(0, mc);
int AutoSaveBuffer::generateChild()
{
+#if defined(__APPLE__)
+ /* FIXME fork() is not usable for autosave on Mac OS X 10.6 (snow leopard)
+ * We should use something else like threads.
+ *
+ * Since I do not know how to determine at run time what is the OS X
+ * version, I just disable forking altogether for now (JMarc)
+ */
+ pid_t const pid = -1;
+#else
// tmp_ret will be located (usually) in /tmp
// will that be a problem?
// Note that this calls ForkedCalls::fork(), so it's
// you should set pid to -1, and comment out the fork.
if (pid != 0 && pid != -1)
return pid;
+#endif
// pid = -1 signifies that lyx was unable
// to fork. But we will do the save
updateMacroInstances();
// Plain text backend
- if (backend_format == "text")
+ if (backend_format == "text") {
+ runparams.flavor = OutputParams::TEXT;
writePlaintextFile(*this, FileName(filename), runparams);
+ }
// HTML backend
else if (backend_format == "xhtml") {
runparams.flavor = OutputParams::HTML;
vector<Format const *> Buffer::exportableFormats(bool only_viewable) const
{
- vector<string> backs = backends();
+ vector<string> const backs = backends();
vector<Format const *> result =
theConverters().getReachable(backs[0], only_viewable, true);
for (vector<string>::const_iterator it = backs.begin() + 1;
vector<string> Buffer::backends() const
{
vector<string> v;
- if (params().baseClass()->isTeXClassAvailable()) {
- v.push_back(bufferFormat());
- // FIXME: Don't hardcode format names here, but use a flag
- if (v.back() == "latex")
- v.push_back("pdflatex");
- }
- v.push_back("text");
+ v.push_back(bufferFormat());
+ // FIXME: Don't hardcode format names here, but use a flag
+ if (v.back() == "latex")
+ v.push_back("pdflatex");
v.push_back("xhtml");
+ v.push_back("text");
v.push_back("lyx");
return v;
}
// set the label of a paragraph. This includes the counters.
-static void setLabel(Buffer const & buf, ParIterator & it)
+void Buffer::setLabel(ParIterator & it) const
{
- BufferParams const & bp = buf.masterBuffer()->params();
+ BufferParams const & bp = this->masterBuffer()->params();
DocumentClass const & textclass = bp.documentClass();
Paragraph & par = it.paragraph();
Layout const & layout = par.layout();
string const & type = counters.current_float();
docstring full_label;
if (type.empty())
- full_label = buf.B_("Senseless!!! ");
+ full_label = this->B_("Senseless!!! ");
else {
- docstring name = buf.B_(textclass.floats().getType(type).name());
+ docstring name = this->B_(textclass.floats().getType(type).name());
if (counters.hasCounter(from_utf8(type))) {
string const & lang = par.getParLanguage(bp)->code();
counters.step(from_utf8(type));
maxdepth = parit->getMaxDepthAfter();
// set the counter for this paragraph
- setLabel(*this, parit);
+ setLabel(parit);
// Now the insets
InsetList::const_iterator iit = parit->insetList().begin();