#include "DocIterator.h"
#include "debug.h"
-#include "LyXText.h"
+#include "Text.h"
#include "Paragraph.h"
#include "mathed/MathData.h"
{}
-DocIterator::DocIterator(InsetBase & inset)
+DocIterator::DocIterator(Inset & inset)
: boundary_(false), inset_(&inset)
{}
-DocIterator doc_iterator_begin(InsetBase & inset)
+DocIterator doc_iterator_begin(Inset & inset)
{
DocIterator dit(inset);
dit.forwardPos();
}
-DocIterator doc_iterator_end(InsetBase & inset)
+DocIterator doc_iterator_end(Inset & inset)
{
return DocIterator(inset);
}
-InsetBase * DocIterator::nextInset()
+Inset * DocIterator::nextInset()
{
BOOST_ASSERT(!empty());
if (pos() == lastpos())
}
-InsetBase * DocIterator::prevInset()
+Inset * DocIterator::prevInset()
{
BOOST_ASSERT(!empty());
if (pos() == 0)
}
-InsetBase const * DocIterator::prevInset() const
+Inset const * DocIterator::prevInset() const
{
BOOST_ASSERT(!empty());
if (pos() == 0)
}
-InsetBase * DocIterator::realInset() const
+Inset * DocIterator::realInset() const
{
BOOST_ASSERT(inTexted());
// if we are in a tabular, we need the cell
- if (inset().lyxCode() == InsetBase::TABULAR_CODE) {
+ if (inset().lyxCode() == Inset::TABULAR_CODE) {
InsetTabular & tabular = static_cast<InsetTabular&>(inset());
return tabular.cell(idx()).get();
}
}
-LyXText * DocIterator::text()
+Text * DocIterator::text()
{
BOOST_ASSERT(!empty());
return top().text();
}
-LyXText const * DocIterator::text() const
+Text const * DocIterator::text() const
{
BOOST_ASSERT(!empty());
return top().text();
}
+Paragraph const & DocIterator::innerParagraph() const
+{
+ BOOST_ASSERT(!empty());
+ // go up until first non-0 text is hit
+ // (innermost text is 0 in mathed)
+ for (int i = depth() - 1; i >= 0; --i)
+ if (slices_[i].text())
+ return slices_[i].paragraph();
+
+ // This case is in principe not possible. We _must_
+ // be inside a Paragraph.
+ BOOST_ASSERT(false);
+ return paragraph();
+}
+
+
pit_type DocIterator::lastpit() const
{
return inMathed() ? 0 : text()->paragraphs().size() - 1;
}
-LyXText * DocIterator::innerText()
+Text * DocIterator::innerText()
{
BOOST_ASSERT(!empty());
// Go up until first non-0 text is hit
return 0;
}
-LyXText const * DocIterator::innerText() const
+Text const * DocIterator::innerText() const
{
BOOST_ASSERT(!empty());
// go up until first non-0 text is hit
}
-InsetBase * DocIterator::innerInsetOfType(int code) const
+Inset * DocIterator::innerInsetOfType(int code) const
{
for (int i = depth() - 1; i >= 0; --i)
if (slices_[i].inset_->lyxCode() == code)
return;
}
- InsetBase * const nextinset = nextInset();
+ Inset * const nextinset = nextInset();
// jump over collapsables if they are collapsed
// FIXME: the check for asInsetMath() shouldn't be necessary
// but math insets do not return a sensible editable() state yet.
if (ignorecollapsed && nextinset && (!nextinset->asInsetMath()
- && nextinset->editable() != InsetBase::HIGHLY_EDITABLE)) {
+ && nextinset->editable() != Inset::HIGHLY_EDITABLE)) {
++top().pos();
return;
}
pos_type const lastp = lastpos();
// move into an inset to the right if possible
- InsetBase * n = 0;
+ Inset * n = 0;
if (tip.pos() != lastp) {
// this is impossible for pos() == size()
}
// move into an inset to the left if possible
- InsetBase * n = 0;
+ Inset * n = 0;
if (inMathed()) {
n = (tip.cell().begin() + tip.pos())->nucleus();
}
-void DocIterator::updateInsets(InsetBase * inset)
+void DocIterator::updateInsets(Inset * inset)
{
// this function re-creates the cache of inset pointers.
// code taken in part from StableDocIterator::asDocIterator.
}
-DocIterator StableDocIterator::asDocIterator(InsetBase * inset) const
+DocIterator StableDocIterator::asDocIterator(Inset * inset) const
{
// this function re-creates the cache of inset pointers
//lyxerr << "converting:\n" << *this << endl;