]> git.lyx.org Git - lyx.git/blobdiff - src/cursor_slice.C
update build instructions (Qt 4.2.2 etc.)
[lyx.git] / src / cursor_slice.C
index f4a59dfb80da84c6f3747c05fb647c7d6f2f24f9..02e7b4ab6270d82dbd3b3b8976c68a2ac8668b29 100644 (file)
 #include "lyxtext.h"
 #include "paragraph.h"
 
-#include "mathed/math_inset.h"
-#include "mathed/math_data.h"
+#include "mathed/InsetMath.h"
+#include "mathed/MathData.h"
 
-#include "insets/updatableinset.h"
+#include <boost/assert.hpp>
 
 
-#include <boost/assert.hpp>
+namespace lyx {
 
 using std::endl;
 
@@ -41,101 +41,48 @@ CursorSlice::CursorSlice(InsetBase & p)
 }
 
 
-size_t CursorSlice::nargs() const
+MathArray & CursorSlice::cell() const
 {
-       BOOST_ASSERT(inset_);
-       return inset_->nargs();
+       return inset_->asInsetMath()->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_);
 }
 
 
-CursorSlice::pos_type CursorSlice::lastpos() const
+pos_type CursorSlice::lastpos() const
 {
        BOOST_ASSERT(inset_);
-       return inset_->asMathInset() ? cell().size() : paragraph().size();
+       return inset_->asInsetMath() ? cell().size() : paragraph().size();
 }
 
 
 CursorSlice::row_type CursorSlice::row() const
 {
-       BOOST_ASSERT(asMathInset());
-       return asMathInset()->row(idx_);
+       BOOST_ASSERT(asInsetMath());
+       return asInsetMath()->row(idx_);
 }
 
 
 CursorSlice::col_type CursorSlice::col() const
 {
-       BOOST_ASSERT(asMathInset());
-       return asMathInset()->col(idx_);
-}
-
-
-MathInset * CursorSlice::asMathInset() const
-{
-       BOOST_ASSERT(inset_);
-       return inset_->asMathInset();
-}
-
-
-UpdatableInset * CursorSlice::asUpdatableInset() const
-{
-       BOOST_ASSERT(inset_);
-       return inset_->asUpdatableInset();
-}
-
-
-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_);
+       BOOST_ASSERT(asInsetMath());
+       return asInsetMath()->col(idx_);
 }
 
 
 bool operator==(CursorSlice const & p, CursorSlice const & q)
 {
-       return &p.inset() == &q.inset()
+       return p.inset_ == q.inset_
               && p.idx() == q.idx()
               && p.pit() == q.pit()
               && p.pos() == q.pos();
@@ -144,7 +91,7 @@ bool operator==(CursorSlice const & p, CursorSlice const & q)
 
 bool operator!=(CursorSlice const & p, CursorSlice const & q)
 {
-       return &p.inset() != &q.inset()
+       return p.inset_ != q.inset_
               || p.idx() != q.idx()
               || p.pit() != q.pit()
               || p.pos() != q.pos();
@@ -190,3 +137,6 @@ std::ostream & operator<<(std::ostream & os, CursorSlice const & item)
 //        << " y: " << item.inset().y()
 ;
 }
+
+
+} // namespace lyx