- if (old_cursor.par() != cursor.par()) {
- if ((old_cursor.par()->Last() == 0
- || (old_cursor.par()->Last() == 1
- && old_cursor.par()->IsLineSeparator(0)))
-#ifndef NEW_INSETS
- && old_cursor.par()->FirstPhysicalPar()
- == old_cursor.par()->LastPhysicalPar()
-#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
- LyXParagraph * endpar = old_cursor.par()->next;
- if (endpar && endpar->GetDepth()) {
- while (endpar && endpar->GetDepth()) {
-#ifndef NEW_INSETS
- endpar = endpar->LastPhysicalPar()->Next();
-#else
- endpar = endpar->Next();
-#endif
- }
- }
- 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);
- }
- // 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
- LyXParagraph * endpar = old_cursor.par()->next;
- if (endpar && endpar->GetDepth()) {
- while (endpar && endpar->GetDepth()) {
-#ifndef NEW_INSETS
- endpar = endpar->LastPhysicalPar()->Next();
-#else
- endpar = endpar->Next();
-#endif
- }
- }
- 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);
- }
- 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());
- }
- }