if (inTexted()) {
Buffer const & buffer = *bv().buffer();
- ParagraphList & pars = text()->paragraphs();
+ ParagraphList const & pars = text()->paragraphs();
// should be const ...
pit_type startpit = selBegin().pit();
// The paragraphs in between (if any)
for (pit_type pit = startpit + 1; pit != endpit; ++pit) {
- Paragraph & par = pars[pit];
+ Paragraph const & par = pars[pit];
result += par.asString(buffer, 0, par.size(), label) + "\n\n";
}
}
-size_t CursorSlice::nargs() const
+MathArray & CursorSlice::cell() const
{
- BOOST_ASSERT(inset_);
- return inset_->nargs();
+ return inset_->asMathInset()->cell(idx_);
}
-size_t CursorSlice::nrows() const
+Paragraph & CursorSlice::paragraph()
{
- BOOST_ASSERT(inset_);
- return inset_->nrows();
+ return text()->getPar(pit_);
}
-size_t CursorSlice::ncols() const
+Paragraph const & CursorSlice::paragraph() const
{
- BOOST_ASSERT(inset_);
- return inset_->ncols();
+ return text()->getPar(pit_);
}
}
-MathInset * CursorSlice::asMathInset() const
-{
- BOOST_ASSERT(inset_);
- return inset_->asMathInset();
-}
-
-
-MathArray & CursorSlice::cell() const
-{
- BOOST_ASSERT(asMathInset());
- return asMathInset()->cell(idx_);
-}
-
-
-LyXText * CursorSlice::text()
-{
- BOOST_ASSERT(inset_);
- return inset_->getText(idx_);
-}
-
-LyXText const * CursorSlice::text() const
-{
- BOOST_ASSERT(inset_);
- return inset_->getText(idx_);
-}
-
-
-Paragraph & CursorSlice::paragraph()
-{
- // access to the main lyx text must be handled in the cursor
- BOOST_ASSERT(text());
- return text()->getPar(pit_);
-}
-
-
-Paragraph const & CursorSlice::paragraph() const
-{
- // access to the main lyx text must be handled in the cursor
- BOOST_ASSERT(text());
- return text()->getPar(pit_);
-}
-
-
bool operator==(CursorSlice const & p, CursorSlice const & q)
{
return &p.inset() == &q.inset()
#ifndef CURSORSLICE_H
#define CURSORSLICE_H
+#include "insets/insetbase.h"
#include "support/types.h"
#include <cstddef>
class LyXText;
class Paragraph;
-
/// This encapsulates a single slice of a document iterator as used e.g.
/// for cursors.
/// return the last position within the paragraph
pos_type lastpos() const;
/// return the number of embedded cells
- size_t nargs() const;
- /*!
- * \return the number of columns.
- * This does only make sense in grid like insets.
- */
- size_t ncols() const;
- /*!
- * \return the number of rows.
- * This does only make sense in grid like insets.
- */
- size_t nrows() const;
+ size_t nargs() const { return inset_->nargs(); }
+ /// return the number of columns (1 in non-grid-like insets)
+ size_t ncols() const { return inset_->ncols(); }
+ /// return the number of rows (1 in non-grid-like insets)
+ size_t nrows() const { return inset_->nrows(); }
/*!
* \return the grid row of the current cell.
* This does only make sense in grid like insets.
/// texted specific stuff
///
/// returns text corresponding to this position
- LyXText * text();
+ LyXText * text() { return inset_->getText(idx_); }
/// returns text corresponding to this position
- LyXText const * text() const;
+ LyXText const * text() const { return inset_->getText(idx_); }
/// paragraph in this cell
Paragraph & paragraph();
/// paragraph in this cell
///
/// mathed specific stuff
///
+ /// returns the owning inset if it is a MathInset, else 0
+ MathInset * asMathInset() const { return inset_->asMathInset(); }
/// returns cell corresponding to this position
MathArray & cell() const;
- /// returns the owning inset if it is a MathInset, else 0
- MathInset * asMathInset() const;
/// write some debug information to \p os
friend std::ostream & operator<<(std::ostream &, CursorSlice const &);
* Cell index of a position in this inset.
* This is the primary cell information also for grid like insets,
* although we have the convenience functions row() and col() for
- * those.
- * This means that the corresponding idx_ of a cell in a given row
- * and column changes every time the number of columns or number of
- * rows changes. Normally the cursor should stay in the same cell,
+ * those * and column changes every time the number of columns ornumber
+ * of rows changes. Normally the cursor should stay in the same cell,
* so these changes should typically be performed like the following:
* \code
* row_type const r = cur.row();
case LFUN_CELL_BACKWARD:
case LFUN_CELL_FORWARD:
status.enabled(true);
- return true;
+ return true;
// disable these with multiple cells selected
case LFUN_INSET_INSERT:
FuncStatus & status) const;
/// access to out BufferView. This should go...
-// BufferView * bv();
- /// access to out BufferView. This should go...
BufferView * bv() const;
- /// access to individual paragraphs
- Paragraph & getPar(pit_type par) const;
+ /// read-only access to individual paragraph
+ Paragraph const & getPar(pit_type pit) const { return pars_[pit]; }
+ /// read-write access to individual paragraph
+ Paragraph & getPar(pit_type pit) { return pars_[pit]; }
// Returns the current font and depth as a message.
std::string LyXText::currentState(LCursor & cur);
RowMetrics computeRowMetrics(pit_type pit, Row const & row) const;
/// access to our paragraphs
- ParagraphList & paragraphs() const;
+ ParagraphList const & paragraphs() const { return pars_; }
+ ParagraphList & paragraphs() { return pars_; }
/// return true if this is the main text
bool isMainText() const;
ms << "<graphic fileref=\"eqn/";
if ( !label(0).empty())
ms << sgml::cleanID(buf, runparams, label(0));
- else {
+ else
ms << sgml::uniqueID("anon");
- }
+
if (runparams.flavor == OutputParams::XML)
ms << "\"/>";
else
Paragraph & ParIterator::operator*() const
{
- return text()->getPar(pit());
+ return const_cast<Paragraph&>(text()->getPar(pit()));
}
Paragraph * ParIterator::operator->() const
{
- return &text()->getPar(pit());
+ return const_cast<Paragraph*>(&text()->getPar(pit()));
}
ParagraphList & ParIterator::plist() const
{
- return text()->paragraphs();
+ return const_cast<ParagraphList&>(text()->paragraphs());
}
/// LyXText for the row
LyXText const & text_;
- ParagraphList & pars_;
+ ParagraphList const & pars_;
/// The row to paint
Row const & row_;
static PainterInfo nullpi(pi.base.bv, nop);
int const ww = pi.base.bv->workHeight();
- Paragraph & par = text.paragraphs()[pit];
+ Paragraph const & par = text.paragraphs()[pit];
RowList::const_iterator const rb = par.rows().begin();
RowList::const_iterator const re = par.rows().end();
}
-Paragraph & LyXText::getPar(pit_type par) const
-{
- //lyxerr << "getPar: " << par << " from " << paragraphs().size() << endl;
- BOOST_ASSERT(par >= 0);
- BOOST_ASSERT(par < int(paragraphs().size()));
- return paragraphs()[par];
-}
-
-
Row const & LyXText::firstRow() const
{
return *paragraphs().front().rows().begin();
} else if (cur.pit() > 0) {
--cur.pit();
//cannot use 'par' now
- updateNeeded |= setCursor(cur, cur.pit(), x2pos(cur.pit(), cur.paragraph().rows().size() - 1, x));
+ updateNeeded |= setCursor(cur, cur.pit(),
+ x2pos(cur.pit(), cur.paragraph().rows().size() - 1, x));
}
cur.x_target() = x;
}
-ParagraphList & LyXText::paragraphs() const
-{
- return const_cast<ParagraphList &>(pars_);
-}
-
-
void LyXText::recUndo(pit_type first, pit_type last) const
{
recordUndo(bv()->cursor(), Undo::ATOMIC, first, last);
// record the relevant paragraphs
LyXText const * text = cell.text();
BOOST_ASSERT(text);
- ParagraphList & plist = text->paragraphs();
- ParagraphList::iterator first = plist.begin();
+ ParagraphList const & plist = text->paragraphs();
+ ParagraphList::const_iterator first = plist.begin();
advance(first, first_pit);
- ParagraphList::iterator last = plist.begin();
+ ParagraphList::const_iterator last = plist.begin();
advance(last, last_pit + 1);
undo.pars = ParagraphList(first, last);
}