]> git.lyx.org Git - lyx.git/blobdiff - src/insets/insettext.C
prevent crash when inserting minipage in table cell,
[lyx.git] / src / insets / insettext.C
index 149189f908f2c58c914ee7aead2c4d320daa7be5..78bb89071e290ff205c68048b367bec53a8d7550 100644 (file)
@@ -252,8 +252,8 @@ void InsetText::read(Buffer const * buf, LyXLex & lex)
                        break;
                }
 
-               if (token == "\\the_end") {
-                       lex.printError("\\the_end read in inset! Error in document!");
+               if (token == "\\end_document") {
+                       lex.printError("\\end_document read in inset! Error in document!");
                        return;
                }
 
@@ -321,6 +321,8 @@ void InsetText::draw(PainterInfo & pi, int x, int baseline) const
                return;
        }
 
+       bv->hideCursor();
+
        if (!owner())
                x += scroll();
 
@@ -339,17 +341,17 @@ void InsetText::draw(PainterInfo & pi, int x, int baseline) const
 
        x += TEXT_TO_INSET_OFFSET;
 
-       RowList::iterator rowit = text_.rows().begin();
+       RowList::iterator rit = text_.rows().begin();
        RowList::iterator end = text_.rows().end();
 
-       int y_offset = baseline - rowit->ascent_of_text();
-       int ph = pain.paperHeight();
+       int y_offset = baseline - rit->ascent_of_text();
+       int y2 = pain.paperHeight();
        int first = 0;
        int y = y_offset;
-       while (rowit != end && y + rowit->height() <= 0) {
-               y += rowit->height();
-               first += rowit->height();
-               ++rowit;
+       while (rit != end && y + rit->height() <= 0) {
+               y += rit->height();
+               first += rit->height();
+               ++rit;
        }
        if (y_offset < 0) {
                text_.top_y(-y_offset);
@@ -360,28 +362,17 @@ void InsetText::draw(PainterInfo & pi, int x, int baseline) const
                first = 0;
        }
 
-       int yf = y_offset + first;
-       y = 0;
-
-       bv->hideCursor();
+       int yo = y_offset + first;
 
-       while (rowit != end && yf < ph) {
-               paintRows(*bv, text_, rowit,
-                       y + y_offset + first, int(x), y + text_.top_y());
-               y += rowit->height();
-               yf += rowit->height();
-               ++rowit;
-       }
+       paintRows(*bv, text_, rit, x, 0, yo, y2, yo);
 
        text_.clearPaint();
 
-       if (drawFrame_ == ALWAYS || (drawFrame_ == LOCKED && locked)) {
+       if (drawFrame_ == ALWAYS || (drawFrame_ == LOCKED && locked))
                drawFrame(pain, int(start_x));
-       }
 
-       if (need_update != INIT) {
+       if (need_update != INIT)
                need_update = NONE;
-       }
 }
 
 
@@ -515,7 +506,7 @@ void InsetText::lockInset(BufferView * bv)
 }
 
 
-void InsetText::lockInset(BufferView * bv, UpdatableInset * inset)
+void InsetText::lockInset(BufferView * /*bv*/, UpdatableInset * inset)
 {
        the_locking_inset = inset;
        inset_x = cix() - top_x + drawTextXOffset;
@@ -629,7 +620,7 @@ bool InsetText::updateInsetInInset(BufferView * bv, InsetOld * inset)
                                return false;
                        found = tl_inset->updateInsetInInset(bv, inset);
                        ustat = FULL;
-               } else { 
+               } else {
                        text_.updateInset(tl_inset);
                        setUpdateStatus(ustat);
                }
@@ -800,11 +791,7 @@ void InsetText::lfunMouseMotion(FuncRequest const & cmd)
        if (cur == text_.cursor)
                return;
        text_.setSelection();
-       bool flag = (text_.toggle_cursor.par() != text_.toggle_end_cursor.par() ||
-                                text_.toggle_cursor.pos() != text_.toggle_end_cursor.pos());
-       if (flag) {
-               updateLocal(bv, SELECTION, false);
-       }
+       updateLocal(bv, SELECTION, false);
 }
 
 
@@ -2145,19 +2132,18 @@ void InsetText::selectSelectedWord(BufferView * bv)
 
 void InsetText::toggleSelection(BufferView * bv, bool kill_selection)
 {
-       if (the_locking_inset) {
+       if (the_locking_inset)
                the_locking_inset->toggleSelection(bv, kill_selection);
-       }
 
        int x = top_x + TEXT_TO_INSET_OFFSET;
 
-       RowList::iterator rowit = text_.rows().begin();
+       RowList::iterator rit = text_.rows().begin();
        RowList::iterator end = text_.rows().end();
-       int y_offset = top_baseline - rowit->ascent_of_text();
+       int y_offset = top_baseline - rit->ascent_of_text();
        int y = y_offset;
-       while ((rowit != end) && ((y + rowit->height()) <= 0)) {
-               y += rowit->height();
-               ++rowit;
+       while (rit != end && y + rit->height() <= 0) {
+               y += rit->height();
+               ++rit;
        }
        if (y_offset < 0)
                y_offset = y;