- // Do not delete empty paragraphs with keepempty set.
- if ((textclasslist.Style(bview->buffer()->params.textclass,
- old_cursor.par()->GetLayout())).keepempty)
- return;
-
- LyXCursor tmpcursor;
-
-#ifndef NEW_INSETS
- if (old_cursor.par() != cursor.par()) {
- if ((old_cursor.par()->Last() == 0
- || (old_cursor.par()->Last() == 1
- && old_cursor.par()->IsLineSeparator(0)))
- && old_cursor.par()->FirstPhysicalPar()
- == old_cursor.par()->LastPhysicalPar()
-#else
- if (old_cursor.par() != cursor.par()) {
- if ((old_cursor.par()->size() == 0
- || (old_cursor.par()->size() == 1
- && old_cursor.par()->IsLineSeparator(0)))
-#endif
- ) {
- // ok, we will delete anything
-
- // make sure that you do not delete any environments
-#ifndef NEW_INSETS
- if ((
- old_cursor.par()->footnoteflag != LyXParagraph::OPEN_FOOTNOTE &&
- !(old_cursor.row()->previous()
- && old_cursor.row()->previous()->par()->footnoteflag == LyXParagraph::OPEN_FOOTNOTE)
- && !(old_cursor.row()->next()
- && old_cursor.row()->next()->par()->footnoteflag == LyXParagraph::OPEN_FOOTNOTE))
- || (old_cursor.par()->footnoteflag == LyXParagraph::OPEN_FOOTNOTE
- && ((old_cursor.row()->previous()
- && old_cursor.row()->previous()->par()->footnoteflag == LyXParagraph::OPEN_FOOTNOTE)
- || (old_cursor.row()->next()
- && old_cursor.row()->next()->par()->footnoteflag == LyXParagraph::OPEN_FOOTNOTE))
- )) {
-#endif
- status = LyXText::NEED_MORE_REFRESH;
- deleted = true;
-
- if (old_cursor.row()->previous()) {
- refresh_row = old_cursor.row()->previous();
- refresh_y = old_cursor.y() - old_cursor.row()->baseline() - refresh_row->height();
- tmpcursor = cursor;
- cursor = old_cursor; // that undo can restore the right cursor position
-#ifndef NEW_INSETS
- LyXParagraph * endpar = old_cursor.par()->next_;
- if (endpar && endpar->GetDepth()) {
- while (endpar && endpar->GetDepth()) {
- endpar = endpar->LastPhysicalPar()->next();
- }
- }
- SetUndo(bview->buffer(), Undo::DELETE,
- old_cursor.par()->previous_,
- endpar);
- cursor = tmpcursor;
-
- // delete old row
- RemoveRow(old_cursor.row());
- if (OwnerParagraph() == old_cursor.par()) {
- OwnerParagraph(OwnerParagraph()->next_);
- }
-#else
- LyXParagraph * endpar = old_cursor.par()->next();
- if (endpar && endpar->GetDepth()) {
- while (endpar && endpar->GetDepth()) {
- endpar = endpar->next();
- }
- }
- SetUndo(bview->buffer(), Undo::DELETE,
- old_cursor.par()->previous(),
- endpar);
- cursor = tmpcursor;
-
- // delete old row
- RemoveRow(old_cursor.row());
- if (OwnerParagraph() == old_cursor.par()) {
- OwnerParagraph(OwnerParagraph()->next());
- }
-#endif
- // delete old par
- delete old_cursor.par();
-
- /* Breakagain the next par. Needed
- * because of the parindent that
- * can occur or dissappear. The
- * next row can change its height,
- * if there is another layout before */
- if (refresh_row->next()) {
- BreakAgain(bview, refresh_row->next());
- UpdateCounters(bview, refresh_row);
- }
- SetHeightOfRow(bview, refresh_row);
- } else {
- refresh_row = old_cursor.row()->next();
- refresh_y = old_cursor.y() - old_cursor.row()->baseline();
-
- tmpcursor = cursor;
- cursor = old_cursor; // that undo can restore the right cursor position
-#ifndef NEW_INSETS
- LyXParagraph * endpar = old_cursor.par()->next_;
- if (endpar && endpar->GetDepth()) {
- while (endpar && endpar->GetDepth()) {
- endpar = endpar->LastPhysicalPar()->next();
- }
- }
- SetUndo(bview->buffer(), Undo::DELETE,
- old_cursor.par()->previous_,
- endpar);
- cursor = tmpcursor;
-
- // delete old row
- RemoveRow(old_cursor.row());
- // delete old par
- if (OwnerParagraph() == old_cursor.par()) {
- OwnerParagraph(OwnerParagraph()->next_);
- }
-#else
- LyXParagraph * endpar = old_cursor.par()->next();
- if (endpar && endpar->GetDepth()) {
- while (endpar && endpar->GetDepth()) {
- endpar = endpar->next();
- }
- }
- SetUndo(bview->buffer(), Undo::DELETE,
- old_cursor.par()->previous(),
- endpar);
- cursor = tmpcursor;
-
- // delete old row
- RemoveRow(old_cursor.row());
- // delete old par
- if (OwnerParagraph() == old_cursor.par()) {
- OwnerParagraph(OwnerParagraph()->next());
- }
-#endif
- delete old_cursor.par();
-
- /* Breakagain the next par. Needed
- because of the parindent that can
- occur or dissappear.
- The next row can change its height,
- if there is another layout before
- */
- if (refresh_row) {
- BreakAgain(bview, refresh_row);
- UpdateCounters(bview, refresh_row->previous());
- }
- }
-
- // correct cursor y
-
- SetCursorIntern(bview, cursor.par(), cursor.pos());
-
- if (sel_cursor.par() == old_cursor.par()
- && sel_cursor.pos() == sel_cursor.pos()) {
- // correct selection
- sel_cursor = cursor;
- }
-#ifndef NEW_INSETS
- }
-#endif
- }
- if (!deleted) {
- if (old_cursor.par()->StripLeadingSpaces(bview->buffer()->params.textclass)) {
- RedoParagraphs(bview, old_cursor, old_cursor.par()->next());
- // correct cursor y
- SetCursorIntern(bview, cursor.par(), cursor.pos());
- sel_cursor = cursor;
- }
- }
- }
-}
-
-
-#ifndef NEW_INSETS
-LyXParagraph * LyXText::GetParFromID(int id)
-{
- LyXParagraph * result = FirstParagraph();
- while (result && result->id() != id)
- result = result->next_;
- return result;
-}
-#else
-LyXParagraph * LyXText::GetParFromID(int id)
-{
- LyXParagraph * result = FirstParagraph();
- while (result && result->id() != id)
- result = result->next();
- return result;
-}
-#endif
-
-
-// undo functions
-bool LyXText::TextUndo(BufferView * bview)
-{
- if (inset_owner)