* Text: new empty() method.
* buffer_funcs.cpp:updateLabels(): return early in case of empty document.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@19566
a592a061-630c-0410-9148-
cb99ea01b6c8
Buffer * const b = newFile(filename, templname, !name.empty());
if (b) {
Buffer * const b = newFile(filename, templname, !name.empty());
if (b) {
lyx_view_->setBuffer(b);
}
}
lyx_view_->setBuffer(b);
}
}
+bool Text::empty() const
+{
+ return pars_.empty() || (pars_.size() == 1 && pars_[0].empty()
+ // FIXME: Should we consider the labeled type as empty too?
+ && pars_[0].layout()->labeltype == LABEL_NO_LABEL);
+}
+
double Text::spacing(Buffer const & buffer,
Paragraph const & par) const
double Text::spacing(Buffer const & buffer,
Paragraph const & par) const
/// constructor
explicit Text();
/// constructor
explicit Text();
+ /// \return true if there's no content at all.
+ /// \warning a non standard layout on an empty paragraph doesn't
+ // count as empty.
+ bool empty() const;
+
///
Font getFont(Buffer const & buffer, Paragraph const & par,
pos_type pos) const;
///
Font getFont(Buffer const & buffer, Paragraph const & par,
pos_type pos) const;
+// FIXME: buf should should be const because updateLabels() modifies
+// the contents of the paragraphs.
void updateLabels(Buffer const & buf, bool childonly)
{
Buffer const * const master = buf.getMasterBuffer();
void updateLabels(Buffer const & buf, bool childonly)
{
Buffer const * const master = buf.getMasterBuffer();
textclass.counters().reset();
}
textclass.counters().reset();
}
+ Buffer & cbuf = const_cast<Buffer &>(buf);
+
+ if (buf.text().empty()) {
+ // FIXME: we don't call continue with updateLabels() here because
+ // it crashes on newly created documents. But the TocBackend needs to
+ // be initialised nonetheless so we update the tocBackend manually.
+ cbuf.tocBackend().update();
+ return;
+ }
+
// do the real work
ParIterator parit = par_iterator_begin(buf.inset());
updateLabels(buf, parit);
// do the real work
ParIterator parit = par_iterator_begin(buf.inset());
updateLabels(buf, parit);
- Buffer & cbuf = const_cast<Buffer &>(buf);
cbuf.tocBackend().update();
if (!childonly)
cbuf.structureChanged();
cbuf.tocBackend().update();
if (!childonly)
cbuf.structureChanged();