]> git.lyx.org Git - lyx.git/blobdiff - src/cursor_slice.C
Fix bug 886 and others not reported related with the document paper size.
[lyx.git] / src / cursor_slice.C
index 7528be9d4337a6248f5777747a4065cb43748148..086317800bf3364c3ab30ef3743c9c70c6ce328b 100644 (file)
 #include "mathed/math_inset.h"
 #include "mathed/math_data.h"
 
-#include "insets/updatableinset.h"
-
-
 #include <boost/assert.hpp>
 
 using std::endl;
 
 
 CursorSlice::CursorSlice()
-       : inset_(0), idx_(0), par_(0), pos_(0), boundary_(false)
+       : inset_(0), idx_(0), pit_(0), pos_(0)
 {}
 
 
 CursorSlice::CursorSlice(InsetBase & p)
-       : inset_(&p), idx_(0), par_(0), pos_(0), boundary_(false)
+       : inset_(&p), idx_(0), pit_(0), pos_(0)
 {
-       ///BOOST_ASSERT(inset_);
+       BOOST_ASSERT(inset_);
 }
 
 
@@ -62,42 +59,6 @@ size_t CursorSlice::ncols() const
 }
 
 
-CursorSlice::idx_type CursorSlice::idx() const
-{
-       return idx_;
-}
-
-
-CursorSlice::idx_type & CursorSlice::idx()
-{
-       return idx_;
-}
-
-
-CursorSlice::par_type CursorSlice::par() const
-{
-       return par_;
-}
-
-
-CursorSlice::par_type & CursorSlice::par()
-{
-       return par_;
-}
-
-
-CursorSlice::pos_type CursorSlice::pos() const
-{
-       return pos_;
-}
-
-
-CursorSlice::pos_type & CursorSlice::pos()
-{
-       return pos_;
-}
-
-
 CursorSlice::pos_type CursorSlice::lastpos() const
 {
        BOOST_ASSERT(inset_);
@@ -105,18 +66,6 @@ CursorSlice::pos_type CursorSlice::lastpos() const
 }
 
 
-bool CursorSlice::boundary() const
-{
-       return boundary_;
-}
-
-
-bool & CursorSlice::boundary()
-{
-       return boundary_;
-}
-
-
 CursorSlice::row_type CursorSlice::row() const
 {
        BOOST_ASSERT(asMathInset());
@@ -138,13 +87,6 @@ MathInset * CursorSlice::asMathInset() const
 }
 
 
-UpdatableInset * CursorSlice::asUpdatableInset() const
-{
-       BOOST_ASSERT(inset_);
-       return inset_->asUpdatableInset();
-}
-
-
 MathArray & CursorSlice::cell() const
 {
        BOOST_ASSERT(asMathInset());
@@ -152,7 +94,13 @@ MathArray & CursorSlice::cell() const
 }
 
 
-LyXText * CursorSlice::text() const
+LyXText * CursorSlice::text()
+{
+       BOOST_ASSERT(inset_);
+       return inset_->getText(idx_);
+}
+
+LyXText const * CursorSlice::text() const
 {
        BOOST_ASSERT(inset_);
        return inset_->getText(idx_);
@@ -163,7 +111,7 @@ Paragraph & CursorSlice::paragraph()
 {
        // access to the main lyx text must be handled in the cursor
        BOOST_ASSERT(text());
-       return *text()->getPar(par_);
+       return text()->getPar(pit_);
 }
 
 
@@ -171,40 +119,40 @@ Paragraph const & CursorSlice::paragraph() const
 {
        // access to the main lyx text must be handled in the cursor
        BOOST_ASSERT(text());
-       return *text()->getPar(par_);
+       return text()->getPar(pit_);
 }
 
 
 bool operator==(CursorSlice const & p, CursorSlice const & q)
 {
-       return p.inset_ == q.inset_
-              && p.idx_ == q.idx_
-              && p.par_ == q.par_
-              && p.pos_ == q.pos_;
+       return &p.inset() == &q.inset()
+              && p.idx() == q.idx()
+              && p.pit() == q.pit()
+              && p.pos() == q.pos();
 }
 
 
 bool operator!=(CursorSlice const & p, CursorSlice const & q)
 {
-       return p.inset_ != q.inset_
-              || p.idx_ != q.idx_
-              || p.par_ != q.par_
-              || p.pos_ != q.pos_;
+       return &p.inset() != &q.inset()
+              || p.idx() != q.idx()
+              || p.pit() != q.pit()
+              || p.pos() != q.pos();
 }
 
 
 bool operator<(CursorSlice const & p, CursorSlice const & q)
 {
-       if (p.inset_ != q.inset_) {
+       if (&p.inset() != &q.inset()) {
                lyxerr << "can't compare cursor and anchor in different insets\n"
                       << "p: " << p << '\n' << "q: " << q << endl;
-               return true;
+               BOOST_ASSERT(false);
        }
-       if (p.idx_ != q.idx_)
-               return p.idx_ < q.idx_;
-       if (p.par_ != q.par_)
-               return p.par_ < q.par_;
-       return p.pos_ < q.pos_;
+       if (p.idx() != q.idx())
+               return p.idx() < q.idx();
+       if (p.pit() != q.pit())
+               return p.pit() < q.pit();
+       return p.pos() < q.pos();
 }
 
 
@@ -214,15 +162,21 @@ bool operator>(CursorSlice const & p, CursorSlice const & q)
 }
 
 
+bool operator<=(CursorSlice const & p, CursorSlice const & q)
+{
+       return !(q < p);
+}
+
+
 std::ostream & operator<<(std::ostream & os, CursorSlice const & item)
 {
        return os
-          << "inset: " << item.inset_
+          << "inset: " << &item.inset()
 //        << " text: " << item.text()
-          << " idx: " << item.idx_
-          << " par: " << item.par_
-          << " pos: " << item.pos_
-//        << " x: " << item.inset_->x()
-//        << " y: " << item.inset_->y()
+          << " idx: " << item.idx()
+          << " par: " << item.pit()
+          << " pos: " << item.pos()
+//        << " x: " << item.inset().x()
+//        << " y: " << item.inset().y()
 ;
 }