}
-LyXText * DocIterator::text() const
+LyXText * DocIterator::text()
+{
+ BOOST_ASSERT(!empty());
+ return top().text();
+}
+
+LyXText const * DocIterator::text() const
{
BOOST_ASSERT(!empty());
return top().text();
Row & DocIterator::textRow()
{
- return *paragraph().getRow(pos());
+ BOOST_ASSERT(!paragraph().rows().empty());
+ return paragraph().getRow(pos());
}
Row const & DocIterator::textRow() const
{
- return *paragraph().getRow(pos());
+ BOOST_ASSERT(!paragraph().rows().empty());
+ return paragraph().getRow(pos());
}
-DocIterator::par_type DocIterator::lastpar() const
+DocIterator::pit_type DocIterator::lastpit() const
{
return inMathed() ? 0 : text()->paragraphs().size() - 1;
}
}
-DocIterator::row_type DocIterator::crow() const
-{
- return paragraph().row(pos());
-}
-
-
-DocIterator::row_type DocIterator::lastcrow() const
-{
- return paragraph().rows.size();
-}
-
-
DocIterator::idx_type DocIterator::lastidx() const
{
return top().lastidx();
}
-LyXText * DocIterator::innerText() const
+LyXText * DocIterator::innerText()
+{
+ BOOST_ASSERT(!empty());
+ // go up until first non-0 text is hit
+ // (innermost text is 0 in mathed)
+ for (int i = size() - 1; i >= 0; --i)
+ if (operator[](i).text())
+ return operator[](i).text();
+ return 0;
+}
+
+LyXText const * DocIterator::innerText() const
{
BOOST_ASSERT(!empty());
// go up until first non-0 text is hit
//lyxerr << "... no next pos" << endl;
// otherwise move on one paragraph if possible
- if (top.par() < lastpar()) {
+ if (top.pit() < lastpit()) {
//lyxerr << "... next par" << endl;
- ++top.par();
+ ++top.pit();
top.pos() = 0;
return;
}
- //lyxerr << "... no next par" << endl;
+ //lyxerr << "... no next pit" << endl;
// otherwise try to move on one cell if possible
if (top.idx() < lastidx()) {
//lyxerr << "... next idx" << endl;
++top.idx();
- top.par() = 0;
+ top.pit() = 0;
top.pos() = 0;
return;
}
if (empty()) {
push_back(CursorSlice(*inset_));
back().idx() = lastidx();
- back().par() = lastpar();
+ back().pit() = lastpit();
back().pos() = lastpos();
return;
}
if (top.pos() != 0) {
--top.pos();
- } else if (top.par() != 0) {
- --top.par();
+ } else if (top.pit() != 0) {
+ --top.pit();
top.pos() = lastpos();
return;
} else if (top.idx() != 0) {
--top.idx();
- top.par() = lastpar();
+ top.pit() = lastpit();
top.pos() = lastpos();
return;
} else {
if (n && n->isActive()) {
push_back(CursorSlice(*n));
back().idx() = lastidx();
- back().par() = lastpar();
+ back().pit() = lastpit();
back().pos() = lastpos();
}
}