]> git.lyx.org Git - lyx.git/blobdiff - src/text2.C
More ascii-export fixes and when making copy of single tabular cells now the
[lyx.git] / src / text2.C
index 4ddf68cae9e2b6fe881073596a901347c4e79ba8..06fd74d68ddbb947ac5c105b8262ec894ad4c0da 100644 (file)
@@ -790,11 +790,11 @@ void LyXText::setFont(BufferView * bview, LyXFont const & font, bool toggleall)
        redoParagraphs(bview, selection.start, selection.end.par()->next());
    
        // we have to reset the selection, because the
-       // geometry could have changed
+       // geometry could have changed, but we keep
+       // it for user convenience
        setCursor(bview, selection.start.par(), selection.start.pos());
        selection.cursor = cursor;
        setCursor(bview, selection.end.par(), selection.end.pos());
-       clearSelection();
        setSelection(bview);
        setCursor(bview, tmpcursor.par(), tmpcursor.pos(), true,
                  tmpcursor.boundary());
@@ -862,8 +862,9 @@ void LyXText::redoParagraphs(BufferView * bview, LyXCursor const & cur,
 
        if (!tmprow->previous()) {
                // a trick/hack for UNDO
-               // Can somebody please tell me _why_ this solves
-               // anything. (Lgb)
+               // This is needed because in an UNDO/REDO we could have changed
+               // the firstParagrah() so the paragraph inside the row is NOT
+               // my really first par anymore. Got it Lars ;) (Jug 20011206)
                first_phys_par = firstParagraph();
        } else {
                first_phys_par = tmprow->par();
@@ -874,7 +875,7 @@ void LyXText::redoParagraphs(BufferView * bview, LyXCursor const & cur,
                        y -= tmprow->height();
                }
        }
-       
+
        // we can set the refreshing parameters now
        status(bview, LyXText::NEED_MORE_REFRESH);
        refresh_y = y;
@@ -886,13 +887,14 @@ void LyXText::redoParagraphs(BufferView * bview, LyXCursor const & cur,
                tmppar = tmprow->next()->par();
        else
                tmppar = 0;
-       while (tmppar != endpar) {
+       while (tmprow->next() && tmppar != endpar) {
                removeRow(tmprow->next());
-               if (tmprow->next())
+               if (tmprow->next()) {
                        tmppar = tmprow->next()->par();
-               else
+               } else {
                        tmppar = 0;
-       }  
+               }
+       }
    
        // remove the first one
        tmprow2 = tmprow;     /* this is because tmprow->previous()
@@ -1011,7 +1013,7 @@ void LyXText::setSelection(BufferView * bview)
 
 
 string const LyXText::selectionAsString(Buffer const * buffer,
-                                       bool label) const
+                                        bool label) const
 {
        if (!selection.set()) return string();
        string result;
@@ -2184,8 +2186,7 @@ void LyXText::setCursor(BufferView *bview, LyXCursor & cur, Paragraph * par,
 
 
 void LyXText::setCursorIntern(BufferView * bview, Paragraph * par,
-                             pos_type pos,
-                             bool setfont, bool boundary) const
+                              pos_type pos, bool setfont, bool boundary) const
 {
        InsetText * it = static_cast<InsetText *>(par->inInset());
        if (it) {
@@ -2204,8 +2205,7 @@ void LyXText::setCursorIntern(BufferView * bview, Paragraph * par,
                        // I moved the lyxerr stuff in here so we can see if
                        // this is actually really needed and where!
                        // (Jug)
-                       it->getLyXText(bview)->setCursorIntern(bview, par, pos, setfont,
-                                                              boundary);
+                       // it->getLyXText(bview)->setCursorIntern(bview, par, pos, setfont, boundary);
                        return;
                }
        }
@@ -2369,17 +2369,13 @@ void LyXText::fixCursorAfterDelete(BufferView * bview,
 void LyXText::deleteEmptyParagraphMechanism(BufferView * bview,
                                            LyXCursor const & old_cursor) const
 {
-       // don't delete anything if this is the ONLY paragraph!
-       if (!old_cursor.par()->next() && !old_cursor.par()->previous())
-               return;
-       
        // Would be wrong to delete anything if we have a selection.
        if (selection.set()) return;
 
        // We allow all kinds of "mumbo-jumbo" when freespacing.
        if (textclasslist.Style(bview->buffer()->params.textclass,
-                                                       old_cursor.par()->getLayout()).free_spacing ||
-               old_cursor.par()->isFreeSpacing())
+                               old_cursor.par()->getLayout()).free_spacing
+           || old_cursor.par()->isFreeSpacing())
        {
                return;
        }
@@ -2410,7 +2406,8 @@ void LyXText::deleteEmptyParagraphMechanism(BufferView * bview,
        // MISSING
 
        // If the pos around the old_cursor were spaces, delete one of them.
-       if (old_cursor.par() != cursor.par() || old_cursor.pos() != cursor.pos()) { 
+       if (old_cursor.par() != cursor.par()
+           || old_cursor.pos() != cursor.pos()) { 
                // Only if the cursor has really moved
                
                if (old_cursor.pos() > 0
@@ -2442,6 +2439,10 @@ void LyXText::deleteEmptyParagraphMechanism(BufferView * bview,
                }
        }
 
+       // don't delete anything if this is the ONLY paragraph!
+       if (!old_cursor.par()->next() && !old_cursor.par()->previous())
+               return;
+       
        // Do not delete empty paragraphs with keepempty set.
        if ((textclasslist.Style(bview->buffer()->params.textclass,
                                 old_cursor.par()->getLayout())).keepempty)
@@ -2594,11 +2595,7 @@ void LyXText::ownerParagraph(int id, Paragraph * p) const
        if (op && op->inInset()) {
                static_cast<InsetText *>(op->inInset())->paragraph(p);
        } else {
-               if (inset_owner) {
-                       inset_owner->paragraph(p);
-               } else {
-                       bv_owner->buffer()->paragraph = p;
-               }
+               ownerParagraph(p);
        }
 }