From 3ff3b95d3c7fdc814cb774221370964da4e283ce Mon Sep 17 00:00:00 2001 From: =?utf8?q?Lars=20Gullik=20Bj=C3=B8nnes?= Date: Sat, 23 Sep 2000 04:57:18 +0000 Subject: [PATCH] remove almost all traces of old table git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1034 a592a061-630c-0410-9148-cb99ea01b6c8 --- ChangeLog | 7 + po/POTFILES.in | 3 +- src/BufferView2.C | 10 - src/BufferView_pimpl.C | 56 +- src/CutAndPaste.C | 83 +-- src/LyXAction.C | 2 +- src/Makefile.am | 1 - src/TableLayout.C | 491 -------------- src/ToolbarDefaults.C | 2 +- src/buffer.C | 156 +---- src/layout_forms.C | 7 +- src/layout_forms.h | 8 + src/lyx_cb.C | 23 +- src/lyx_gui.C | 32 - src/lyx_gui_misc.C | 18 - src/lyxfunc.C | 17 +- src/lyxparagraph.h | 31 - src/lyxtext.h | 25 - src/paragraph.C | 756 +-------------------- src/text.C | 1438 +++++----------------------------------- src/text2.C | 474 +++---------- 21 files changed, 316 insertions(+), 3324 deletions(-) delete mode 100644 src/TableLayout.C diff --git a/ChangeLog b/ChangeLog index 440ab03e1b..9e75660b71 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2000-09-23 Lars Gullik Bjønnes + + * several files: removed almost all traces of the old table + (tabular) code. + + * src/TableLayout.C: removed file + 2000-09-22 Juergen Vigna * src/frontends/kde/Dialogs.C: added credits forms. diff --git a/po/POTFILES.in b/po/POTFILES.in index f16e40e1c1..325bf1569c 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -51,6 +51,8 @@ src/frontends/xforms/FormCopyright.C src/frontends/xforms/form_copyright.C src/frontends/xforms/FormDocument.C src/frontends/xforms/form_document.C +src/frontends/xforms/FormError.C +src/frontends/xforms/form_error.C src/frontends/xforms/FormGraphics.C src/frontends/xforms/form_graphics.C src/frontends/xforms/FormIndex.C @@ -133,7 +135,6 @@ src/support/filetools.C src/support/getUserName.C src/support/path.C src/support/path.h -src/TableLayout.C src/tabular.C src/text2.C src/text.C diff --git a/src/BufferView2.C b/src/BufferView2.C index d51763dcf8..55e1a8a335 100644 --- a/src/BufferView2.C +++ b/src/BufferView2.C @@ -209,16 +209,6 @@ bool BufferView::insertInset(Inset * inset, string const & lout, return false; } -#ifndef NEW_TABULAR - // check for table/list in tables - if (no_table && text->cursor.par()->table){ - WriteAlert(_("Impossible Operation!"), - _("Cannot insert table/list in table."), - _("Sorry.")); - return false; - } -#endif - // not quite sure if we want this... text->SetCursorParUndo(buffer()); text->FreezeUndo(); diff --git a/src/BufferView_pimpl.C b/src/BufferView_pimpl.C index 17039740e0..53fdc53cc0 100644 --- a/src/BufferView_pimpl.C +++ b/src/BufferView_pimpl.C @@ -591,46 +591,7 @@ void BufferView::Pimpl::workAreaButtonPress(int xpos, int ypos, selection_possible = true; screen_->HideCursor(); -#ifndef NEW_TABULAR - // Right button mouse click on a table - if (button == 3 && - (bv_->text->cursor.par()->table || - bv_->text->MouseHitInTable(bv_, xpos, ypos + bv_->text->first))) { - // Set the cursor to the press-position - bv_->text->SetCursorFromCoordinates(bv_, xpos, ypos + bv_->text->first); - bool doit = true; - - // Only show the table popup if the hit is in - // the table, too - if (!bv_->text->HitInTable(bv_, - bv_->text->cursor.row(), xpos)) - doit = false; - - // Hit above or below the table? - if (doit) { - if (!bv_->text->selection) { - screen_->ToggleSelection(bv_->text); - bv_->text->ClearSelection(); - bv_->text->FullRebreak(bv_); - screen_->Update(bv_->text); - updateScrollbar(); - } - // Popup table popup when on a table. - // This is obviously temporary, since we - // should be able to popup various - // context-sensitive-menus with the - // the right mouse. So this should be done more - // general in the future. Matthias. - selection_possible = false; - owner_->getLyXFunc() - ->Dispatch(LFUN_LAYOUT_TABLE, - "true"); - return; - } - } -#endif - - int screen_first = bv_->text->first; + int const screen_first = bv_->text->first; // Middle button press pastes if we have a selection bool paste_internally = false; @@ -705,7 +666,7 @@ void BufferView::Pimpl::doubleClick(int /*x*/, int /*y*/, unsigned int button) * if necessary */ update(BufferView::SELECT|BufferView::FITCUR); } - } + } } @@ -767,19 +728,6 @@ void BufferView::Pimpl::workAreaButtonRelease(int x, int y, } selection_possible = false; -#ifndef NEW_TABULAR - if (bv_->text->cursor.par()->table) { - int cell = bv_->text-> - NumberOfCell(bv_->text->cursor.par(), - bv_->text->cursor.pos()); - if (bv_->text->cursor.par()->table->IsContRow(cell) && - bv_->text->cursor.par()->table-> - CellHasContRow(bv_->text->cursor.par()->table-> - GetCellAbove(cell))<0) { - bv_->text->CursorUp(bv_); - } - } -#endif if (button >= 2) return; diff --git a/src/CutAndPaste.C b/src/CutAndPaste.C index c56ff81dfe..6687504150 100644 --- a/src/CutAndPaste.C +++ b/src/CutAndPaste.C @@ -94,17 +94,8 @@ bool CutAndPaste::cutSelection(LyXParagraph * startpar, LyXParagraph ** endpar, for (; i < end; ++i) { startpar->CopyIntoMinibuffer(current_view->buffer()->params, start); -#ifndef NEW_TABULAR - /* table stuff -- begin */ - if (startpar->table && startpar->IsNewline(start)) { - ++start; - } else { - /* table stuff -- end */ -#endif - startpar->Erase(start); -#ifndef NEW_TABULAR - } -#endif + startpar->Erase(start); + buf->InsertFromMinibuffer(buf->Last()); } end = start-1; @@ -276,59 +267,25 @@ bool CutAndPaste::pasteSelection(LyXParagraph ** par, LyXParagraph ** endpar, if (!buf->next) { // only within a paragraph tmpbuf = buf->Clone(); -#ifndef NEW_TABULAR - /* table stuff -- begin */ - bool table_too_small = false; - if ((*par)->table) { - while (buf->size() && !table_too_small) { - if (buf->IsNewline(0)){ - while((tmppos < tmppar->Last()) && - !tmppar->IsNewline(tmppos)) - ++tmppos; - buf->Erase(0); - if (tmppos < tmppar->Last()) - ++tmppos; - else - table_too_small = true; - } else { - // This is an attempt to fix the - // "never insert a space at the - // beginning of a paragraph" problem. - if (!tmppos && buf->IsLineSeparator(0)) { - buf->Erase(0); - } else { - buf->CutIntoMinibuffer(current_view->buffer()->params, 0); - buf->Erase(0); - if (tmppar->InsertFromMinibuffer(tmppos)) - ++tmppos; - } - } - } - } else { - /* table stuff -- end */ -#endif - // Some provisions should be done here for checking - // if we are inserting at the beginning of a - // paragraph. If there are a space at the beginning - // of the text to insert and we are inserting at - // the beginning of the paragraph the space should - // be removed. - while (buf->size()) { + // Some provisions should be done here for checking + // if we are inserting at the beginning of a + // paragraph. If there are a space at the beginning + // of the text to insert and we are inserting at + // the beginning of the paragraph the space should + // be removed. + while (buf->size()) { // This is an attempt to fix the // "never insert a space at the // beginning of a paragraph" problem. if (!tmppos && buf->IsLineSeparator(0)) { - buf->Erase(0); + buf->Erase(0); } else { - buf->CutIntoMinibuffer(current_view->buffer()->params, 0); - buf->Erase(0); - if (tmppar->InsertFromMinibuffer(tmppos)) - ++tmppos; + buf->CutIntoMinibuffer(current_view->buffer()->params, 0); + buf->Erase(0); + if (tmppar->InsertFromMinibuffer(tmppos)) + ++tmppos; } - } -#ifndef NEW_TABULAR } -#endif delete buf; buf = tmpbuf; *endpar = tmppar->Next(); @@ -523,18 +480,6 @@ bool CutAndPaste::checkPastePossible(LyXParagraph * par, int) return false; } } -#endif -#ifndef NEW_TABULAR - /* table stuff -- begin */ - if (par->table) { - if (buf->next) { - WriteAlert(_("Impossible operation"), - _("Table cell cannot include more than one paragraph!"), - _("Sorry.")); - return false; - } - } - /* table stuff -- end */ #endif return true; } diff --git a/src/LyXAction.C b/src/LyXAction.C index 6df70fef84..5347503888 100644 --- a/src/LyXAction.C +++ b/src/LyXAction.C @@ -19,7 +19,7 @@ #include "gettext.h" #include "support/lstrings.h" #if 1 -// only to get access to NEW_INSETS and NEW_TABULAR +// only to get access to NEW_INSETS #include "lyxparagraph.h" #endif #if 1 diff --git a/src/Makefile.am b/src/Makefile.am index 83ef229a09..419fdb1986 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -76,7 +76,6 @@ lyx_SOURCES = \ Sectioning.C \ Spacing.C \ Spacing.h \ - TableLayout.C \ TextCache.C \ TextCache.h \ Timeout.C \ diff --git a/src/TableLayout.C b/src/TableLayout.C deleted file mode 100644 index 06f3f138fc..0000000000 --- a/src/TableLayout.C +++ /dev/null @@ -1,491 +0,0 @@ -#include - -#include -#include FORMS_H_LOCATION - -#include "layout_forms.h" -#include "lyx_main.h" -#include "lyxrc.h" -#include "LString.h" -#include "support/filetools.h" -#include "buffer.h" -#include "vspace.h" -#include "lyx_gui_misc.h" -#include "BufferView.h" -#include "gettext.h" -#include "lyxtext.h" -#include "layout.h" -#include "insets/lyxinset.h" - -// Prototypes -extern FD_form_table_options * fd_form_table_options; -extern FD_form_table_extra * fd_form_table_extra; -extern BufferView * current_view; - -#ifndef NEW_TABULAR -static int Confirmed = false; -static int ActCell; - -// hack to keep the cursor from jumping to the end of the text in the Extra -// form input fields during editing. The values in LyXTable itself is -// changed in real-time, but we have no callbacks for the input fields, -// so I simply store and restore the cursor position for now. -// (too much of a hazzle to do it proper; we'll trash all this code -// in 1.1 anyway) -static int extra_col_cursor_x; // need no y's, one-line input fields -static int extra_multicol_cursor_x; -#endif -// Joacim - - -bool UpdateLayoutTable(int flag) -{ - bool update = true; - if (!current_view->available()) - update = false; - -#ifndef NEW_TABULAR - if (update && current_view->text->cursor.par()->table) { - char buf[12]; - string pwidth, special; - - LyXTable * table = current_view->text->cursor.par()->table; - - int cell = current_view->text-> - NumberOfCell(current_view->text->cursor.par(), - current_view->text->cursor.pos()); - ActCell = cell; - int column = table->column_of_cell(cell)+1; - fl_set_object_label(fd_form_table_options->text_warning, ""); - Confirmed = false; - fl_activate_object(fd_form_table_extra->input_special_alignment); - fl_activate_object(fd_form_table_extra->input_special_multialign); - fl_activate_object(fd_form_table_options->input_column_width); - sprintf(buf, "%d", column); - fl_set_input(fd_form_table_options->input_table_column, buf); - fl_deactivate_object(fd_form_table_options->input_table_column); - int row = table->row_of_cell(cell)+1; - sprintf(buf, "%d", row); - fl_set_input(fd_form_table_options->input_table_row, buf); - fl_deactivate_object(fd_form_table_options->input_table_row); - if (table->IsMultiColumn(cell)) - fl_set_button(fd_form_table_options->radio_multicolumn, 1); - else - fl_set_button(fd_form_table_options->radio_multicolumn, 0); - if (table->RotateCell(cell)) - fl_set_button(fd_form_table_options->radio_rotate_cell, 1); - else - fl_set_button(fd_form_table_options->radio_rotate_cell, 0); - if (table->TopLine(cell)) - fl_set_button(fd_form_table_options->radio_border_top, 1); - else - fl_set_button(fd_form_table_options->radio_border_top, 0); - if (table->BottomLine(cell)) - fl_set_button(fd_form_table_options->radio_border_bottom, 1); - else - fl_set_button(fd_form_table_options->radio_border_bottom, 0); - if (table->LeftLine(cell)) - fl_set_button(fd_form_table_options->radio_border_left, 1); - else - fl_set_button(fd_form_table_options->radio_border_left, 0); - if (table->RightLine(cell)) - fl_set_button(fd_form_table_options->radio_border_right, 1); - else - fl_set_button(fd_form_table_options->radio_border_right, 0); - int align = table->GetAlignment(cell); - fl_set_button(fd_form_table_options->radio_align_left, 0); - fl_set_button(fd_form_table_options->radio_align_right, 0); - fl_set_button(fd_form_table_options->radio_align_center, 0); - special = table->GetAlignSpecial(cell, LyXTable::SET_SPECIAL_COLUMN); - if (flag) - { - fl_set_input(fd_form_table_extra->input_special_alignment, - special.c_str()); - fl_set_input_cursorpos(fd_form_table_extra->input_special_alignment, - extra_col_cursor_x, 0); // restore the cursor - } - if (current_view->buffer()->isReadonly()) - fl_deactivate_object(fd_form_table_extra->input_special_alignment); - special = table->GetAlignSpecial(cell, LyXTable::SET_SPECIAL_MULTI); - if (flag) - { - fl_set_input(fd_form_table_extra->input_special_multialign, - special.c_str()); - fl_set_input_cursorpos(fd_form_table_extra->input_special_multialign, - extra_multicol_cursor_x, 0); // restore the cursor - } - if (current_view->buffer()->isReadonly()) - fl_deactivate_object(fd_form_table_extra->input_special_multialign); - pwidth = table->GetPWidth(cell); - if (flag) - fl_set_input(fd_form_table_options->input_column_width, pwidth.c_str()); - if (current_view->buffer()->isReadonly()) - fl_deactivate_object(fd_form_table_options->input_column_width); - if (!pwidth.empty()) { - fl_activate_object(fd_form_table_options->radio_linebreak_cell); - fl_set_object_lcol(fd_form_table_options->radio_linebreak_cell, - FL_BLACK); - fl_set_button(fd_form_table_options->radio_linebreak_cell, - table->Linebreaks(table->FirstVirtualCell(cell))); - } else { - fl_deactivate_object(fd_form_table_options->radio_linebreak_cell); - fl_set_object_lcol(fd_form_table_options->radio_linebreak_cell, - FL_INACTIVE); - fl_set_button(fd_form_table_options->radio_linebreak_cell, 0); - } - if ((!pwidth.empty() && !table->IsMultiColumn(cell)) || - (align == LYX_ALIGN_LEFT)) - fl_set_button(fd_form_table_options->radio_align_left, 1); - else if (align == LYX_ALIGN_RIGHT) - fl_set_button(fd_form_table_options->radio_align_right, 1); - else - fl_set_button(fd_form_table_options->radio_align_center, 1); - if (!pwidth.empty() && !table->IsMultiColumn(cell)) { - fl_deactivate_object(fd_form_table_options->radio_align_left); - fl_deactivate_object(fd_form_table_options->radio_align_right); - fl_deactivate_object(fd_form_table_options->radio_align_center); - fl_set_object_lcol(fd_form_table_options->radio_align_left, - FL_INACTIVE); - fl_set_object_lcol(fd_form_table_options->radio_align_right, - FL_INACTIVE); - fl_set_object_lcol(fd_form_table_options->radio_align_center, - FL_INACTIVE); - } else { - fl_activate_object(fd_form_table_options->radio_align_left); - fl_activate_object(fd_form_table_options->radio_align_right); - fl_activate_object(fd_form_table_options->radio_align_center); - fl_set_object_lcol(fd_form_table_options->radio_align_left, - FL_BLACK); - fl_set_object_lcol(fd_form_table_options->radio_align_right, - FL_BLACK); - fl_set_object_lcol(fd_form_table_options->radio_align_center, - FL_BLACK); - } - fl_set_button(fd_form_table_options->radio_longtable, table->IsLongTable()); - if (table->IsLongTable()) { - fl_activate_object(fd_form_table_options->radio_lt_firsthead); - fl_activate_object(fd_form_table_options->radio_lt_head); - fl_activate_object(fd_form_table_options->radio_lt_foot); - fl_activate_object(fd_form_table_options->radio_lt_lastfoot); - fl_activate_object(fd_form_table_options->radio_lt_newpage); - fl_set_object_lcol(fd_form_table_options->radio_lt_firsthead, - FL_BLACK); - fl_set_object_lcol(fd_form_table_options->radio_lt_head, - FL_BLACK); - fl_set_object_lcol(fd_form_table_options->radio_lt_foot, - FL_BLACK); - fl_set_object_lcol(fd_form_table_options->radio_lt_lastfoot, - FL_BLACK); - fl_set_object_lcol(fd_form_table_options->radio_lt_newpage, - FL_BLACK); - fl_set_button(fd_form_table_options->radio_lt_firsthead, - table->RowOfLTFirstHead(cell)); - fl_set_button(fd_form_table_options->radio_lt_head, - table->RowOfLTHead(cell)); - fl_set_button(fd_form_table_options->radio_lt_foot, - table->RowOfLTFoot(cell)); - fl_set_button(fd_form_table_options->radio_lt_lastfoot, - table->RowOfLTLastFoot(cell)); - fl_set_button(fd_form_table_options->radio_lt_newpage, - table->LTNewPage(cell)); - } else { - fl_deactivate_object(fd_form_table_options->radio_lt_firsthead); - fl_deactivate_object(fd_form_table_options->radio_lt_head); - fl_deactivate_object(fd_form_table_options->radio_lt_foot); - fl_deactivate_object(fd_form_table_options->radio_lt_lastfoot); - fl_deactivate_object(fd_form_table_options->radio_lt_newpage); - fl_set_button(fd_form_table_options->radio_lt_firsthead, 0); - fl_set_button(fd_form_table_options->radio_lt_head, 0); - fl_set_button(fd_form_table_options->radio_lt_foot, 0); - fl_set_button(fd_form_table_options->radio_lt_lastfoot, 0); - fl_set_button(fd_form_table_options->radio_lt_newpage, 0); - fl_set_object_lcol(fd_form_table_options->radio_lt_firsthead, - FL_INACTIVE); - fl_set_object_lcol(fd_form_table_options->radio_lt_head, - FL_INACTIVE); - fl_set_object_lcol(fd_form_table_options->radio_lt_foot, - FL_INACTIVE); - fl_set_object_lcol(fd_form_table_options->radio_lt_lastfoot, - FL_INACTIVE); - fl_set_object_lcol(fd_form_table_options->radio_lt_newpage, - FL_INACTIVE); - } - fl_set_button(fd_form_table_options->radio_rotate_table, - table->RotateTable()); - fl_set_focus_object(fd_form_table_options->form_table_options, - fd_form_table_options->button_table_delete); - } else -#endif - if (fd_form_table_options->form_table_options->visible) { - fl_set_focus_object(fd_form_table_options->form_table_options, - fd_form_table_options->button_table_delete); - fl_hide_form(fd_form_table_options->form_table_options); - } - return update; -} - - -void OpenLayoutTableExtra() -{ - - if (fd_form_table_extra->form_table_extra->visible) { - fl_raise_form(fd_form_table_extra->form_table_extra); - } else { - static int ow = -1, oh; - fl_show_form(fd_form_table_extra->form_table_extra, - FL_PLACE_MOUSE | FL_FREE_SIZE, FL_FULLBORDER, - _("Table Extra Form")); - if (ow < 0) { - ow = fd_form_table_extra->form_table_extra->w; - oh = fd_form_table_extra->form_table_extra->h; - } - fl_set_form_minsize(fd_form_table_extra->form_table_extra, - ow, oh); - } -} - -void MenuLayoutTable(int flag) -{ - if (UpdateLayoutTable(flag)) { - if (fd_form_table_options->form_table_options->visible) { - fl_raise_form(fd_form_table_options->form_table_options); - } - else { - fl_show_form(fd_form_table_options->form_table_options, - FL_PLACE_MOUSE, FL_FULLBORDER, - _("Table Layout")); - } - } -} - - -void TableOptionsCB(FL_OBJECT * ob, long) -{ -#ifndef NEW_TABULAR - LyXTable * table = 0; - int s, num = 0; - string special, str; - - if (!current_view->available() - || !(table = current_view->text->cursor.par()->table)) { - MenuLayoutTable(0); - return; - } - int cell = current_view->text-> - NumberOfCell(current_view->text->cursor.par(), - current_view->text->cursor.pos()); - if (ActCell != cell) { - MenuLayoutTable(0); - fl_set_object_label(fd_form_table_options->text_warning, - _("Warning: Wrong Cursor position, updated window")); - fl_show_object(fd_form_table_options->text_warning); - extra_col_cursor_x = 0; // would rather place it at the end, but... - extra_multicol_cursor_x = 0; - return; - } - - // No point in processing directives that you can't do anything with - // anyhow, so exit now if the buffer is read-only. - if (current_view->buffer()->isReadonly()) { - MenuLayoutTable(0); - return; - } - - if (ob != fd_form_table_options->button_table_delete) { - fl_set_object_label(fd_form_table_options->text_warning, ""); - Confirmed = false; - } - str = fl_get_input(fd_form_table_options->input_column_width); - if (!str.empty() && !isValidLength(str)) { - fl_set_object_label(fd_form_table_options->text_warning, - _("Warning: Invalid Length (valid example: 10mm)")); - fl_show_object(fd_form_table_options->text_warning); - return; - } - if (((ob == fd_form_table_options->button_delete_row) && (table->rows<= 1)) || - ((ob == fd_form_table_options->button_delete_column) && (table->columns<= 1))) - ob = fd_form_table_options->button_table_delete; - if (ob == fd_form_table_options->button_append_row) - num = LyXTable::APPEND_ROW; - else if (ob == fd_form_table_options->button_append_column) - num = LyXTable::APPEND_COLUMN; - else if (ob == fd_form_table_options->button_delete_row) - num = LyXTable::DELETE_ROW; - else if (ob == fd_form_table_options->button_delete_column) - num = LyXTable::DELETE_COLUMN; - else if (ob == fd_form_table_options->button_set_borders) - num = LyXTable::SET_ALL_LINES; - else if (ob == fd_form_table_options->button_unset_borders) - num = LyXTable::UNSET_ALL_LINES; - else if (ob == fd_form_table_options->radio_border_top) - num = LyXTable::TOGGLE_LINE_TOP; - else if (ob == fd_form_table_options->radio_border_bottom) - num = LyXTable::TOGGLE_LINE_BOTTOM; - else if (ob == fd_form_table_options->radio_border_left) - num = LyXTable::TOGGLE_LINE_LEFT; - else if (ob == fd_form_table_options->radio_border_right) - num = LyXTable::TOGGLE_LINE_RIGHT; - else if (ob == fd_form_table_options->radio_align_left) - num = LyXTable::ALIGN_LEFT; - else if (ob == fd_form_table_options->radio_align_right) - num = LyXTable::ALIGN_RIGHT; - else if (ob == fd_form_table_options->radio_align_center) - num = LyXTable::ALIGN_CENTER; - else if ((ob == fd_form_table_options->button_table_delete) && !Confirmed) { - fl_set_object_label(fd_form_table_options->text_warning, - _("Confirm: press Delete-Button again")); - Confirmed = true; - return; - } else if ((ob == fd_form_table_options->button_table_delete) - && Confirmed) { - num = LyXTable::DELETE_TABLE; - Confirmed = false; - } else if (ob == fd_form_table_options->radio_multicolumn) - num = LyXTable::MULTICOLUMN; - else if (ob == fd_form_table_options->radio_longtable) { - s = fl_get_button(fd_form_table_options->radio_longtable); - if (s) { - num = LyXTable::SET_LONGTABLE; - fl_activate_object(fd_form_table_options->radio_lt_firsthead); - fl_activate_object(fd_form_table_options->radio_lt_head); - fl_activate_object(fd_form_table_options->radio_lt_foot); - fl_activate_object(fd_form_table_options->radio_lt_lastfoot); - fl_activate_object(fd_form_table_options->radio_lt_newpage); - fl_set_button(fd_form_table_options->radio_lt_firsthead, - table->RowOfLTFirstHead(cell)); - fl_set_button(fd_form_table_options->radio_lt_head, - table->RowOfLTHead(cell)); - fl_set_button(fd_form_table_options->radio_lt_foot, - table->RowOfLTFoot(cell)); - fl_set_button(fd_form_table_options->radio_lt_lastfoot, - table->RowOfLTLastFoot(cell)); - fl_set_button(fd_form_table_options->radio_lt_firsthead, - table->LTNewPage(cell)); - } else { - num = LyXTable::UNSET_LONGTABLE; - fl_deactivate_object(fd_form_table_options->radio_lt_firsthead); - fl_deactivate_object(fd_form_table_options->radio_lt_head); - fl_deactivate_object(fd_form_table_options->radio_lt_foot); - fl_deactivate_object(fd_form_table_options->radio_lt_lastfoot); - fl_deactivate_object(fd_form_table_options->radio_lt_newpage); - fl_set_button(fd_form_table_options->radio_lt_firsthead, 0); - fl_set_button(fd_form_table_options->radio_lt_firsthead, 0); - fl_set_button(fd_form_table_options->radio_lt_firsthead, 0); - fl_set_button(fd_form_table_options->radio_lt_firsthead, 0); - fl_set_button(fd_form_table_options->radio_lt_firsthead, 0); - fl_set_object_lcol(fd_form_table_options->radio_lt_firsthead, - FL_INACTIVE); - fl_set_object_lcol(fd_form_table_options->radio_lt_head, - FL_INACTIVE); - fl_set_object_lcol(fd_form_table_options->radio_lt_foot, - FL_INACTIVE); - fl_set_object_lcol(fd_form_table_options->radio_lt_lastfoot, - FL_INACTIVE); - fl_set_object_lcol(fd_form_table_options->radio_lt_newpage, - FL_INACTIVE); - } - } else if (ob == fd_form_table_options->radio_rotate_table) { - s = fl_get_button(fd_form_table_options->radio_rotate_table); - if (s) - num = LyXTable::SET_ROTATE_TABLE; - else - num = LyXTable::UNSET_ROTATE_TABLE; - } else if (ob == fd_form_table_options->radio_rotate_cell) { - s = fl_get_button(fd_form_table_options->radio_rotate_cell); - if (s) - num = LyXTable::SET_ROTATE_CELL; - else - num = LyXTable::UNSET_ROTATE_CELL; - } else if (ob == fd_form_table_options->radio_linebreak_cell) { - num = LyXTable::SET_LINEBREAKS; - } else if (ob == fd_form_table_options->radio_lt_firsthead) { - num = LyXTable::SET_LTFIRSTHEAD; - } else if (ob == fd_form_table_options->radio_lt_head) { - num = LyXTable::SET_LTHEAD; - } else if (ob == fd_form_table_options->radio_lt_foot) { - num = LyXTable::SET_LTFOOT; - } else if (ob == fd_form_table_options->radio_lt_lastfoot) { - num = LyXTable::SET_LTLASTFOOT; - } else if (ob == fd_form_table_options->radio_lt_newpage) { - num = LyXTable::SET_LTNEWPAGE; - } else if (ob == fd_form_table_options->button_table_extra) { - OpenLayoutTableExtra(); - return; - } else if (ob == fd_form_table_extra->input_special_alignment) { - special = fl_get_input(fd_form_table_extra->input_special_alignment); - int dummy; - fl_get_input_cursorpos(ob, &extra_col_cursor_x, &dummy); - num = LyXTable::SET_SPECIAL_COLUMN; - } else if (ob == fd_form_table_extra->input_special_multialign) { - special = fl_get_input(fd_form_table_extra->input_special_multialign); - int dummy; - fl_get_input_cursorpos(ob, &extra_multicol_cursor_x, &dummy); - num = LyXTable::SET_SPECIAL_MULTI; - } else - return; - if (current_view->available()) { - current_view->hideCursor(); - if (!current_view->text->selection){ - current_view->beforeChange(); - current_view->update(BufferView::SELECT|BufferView::FITCUR); - } - if ((num == LyXTable::SET_SPECIAL_COLUMN) || - (num == LyXTable::SET_SPECIAL_MULTI)) - current_view->text->TableFeatures(current_view, num, special); - else - current_view->text->TableFeatures(current_view, num); - current_view->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); - } - if (num == LyXTable::DELETE_TABLE) { - fl_set_focus_object(fd_form_table_options->form_table_options, - fd_form_table_options->button_table_delete); - fl_hide_form(fd_form_table_options->form_table_options); - } else - UpdateLayoutTable(true); - return; -#endif -} - - -void TableOptCloseCB(FL_OBJECT *, long) -{ - fl_set_focus_object(fd_form_table_options->form_table_options, - fd_form_table_options->button_table_delete); - fl_hide_form(fd_form_table_options->form_table_options); - return; -} - -void TableSpeCloseCB(FL_OBJECT *, long) -{ - fl_set_focus_object(fd_form_table_options->form_table_options, - fd_form_table_options->button_table_delete); - fl_hide_form(fd_form_table_extra->form_table_extra); - return; -} - -void SetPWidthCB(FL_OBJECT * ob, long) -{ -#ifndef NEW_TABULAR - fl_set_object_label(fd_form_table_options->text_warning, ""); - Confirmed = false; - if (ob == fd_form_table_options->input_column_width) { - string str = fl_get_input(ob); - if (!str.empty() && !isValidLength(str)) { - fl_set_object_label(fd_form_table_options->text_warning, - _("Warning: Invalid Length (valid example: 10mm)")); - fl_show_object(fd_form_table_options->text_warning); - return; - } - if (current_view->available()){ - current_view->hideCursor(); - if (!current_view->text->selection) { - current_view->beforeChange(); - current_view->update(BufferView::SELECT|BufferView::FITCUR); - } - current_view->text->TableFeatures(current_view, LyXTable::SET_PWIDTH, str); - current_view->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE); - } - MenuLayoutTable(0); // update for alignment - } -#endif -} diff --git a/src/ToolbarDefaults.C b/src/ToolbarDefaults.C index 7b98891ee6..9e42b8c67b 100644 --- a/src/ToolbarDefaults.C +++ b/src/ToolbarDefaults.C @@ -21,7 +21,7 @@ #include "debug.h" #include "lyxlex.h" #if 1 -// only until we don't need access to the NEW_INSETS or NEW_TABULAR anymore +// only until we don't need access to the NEW_INSETS anymore #include "lyxparagraph.h" #endif diff --git a/src/buffer.C b/src/buffer.C index 6f76dc578e..486030271e 100644 --- a/src/buffer.C +++ b/src/buffer.C @@ -884,14 +884,10 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, LyXParagraph *& par, par->InsertChar(pos, LyXParagraph::META_NEWLINE, font); ++pos; } else if (token == "\\LyXTable") { -#ifdef NEW_TABULAR Inset * inset = new InsetTabular(this); inset->Read(this, lex); par->InsertInset(pos, inset, font); ++pos; -#else - par->table = new LyXTable(lex); -#endif } else if (token == "\\hfill") { par->InsertChar(pos, LyXParagraph::META_HFILL, font); ++pos; @@ -1309,12 +1305,6 @@ void Buffer::writeFileAscii(string const & fname, int linelen) int ltype_depth = 0; int actcell = 0; int actpos = 0; -#ifndef NEW_TABULAR - int h; - int * clen = 0; - int cell = 0; - int cells = 0; -#endif int currlinelen = 0; long fpos = 0; bool ref_printed = false; @@ -1419,40 +1409,6 @@ void Buffer::writeFileAscii(string const & fname, int linelen) #endif } - //LyXLayout const & layout = - // textclasslist.Style(params.textclass, - // par->GetLayout()); // unused - //bool free_spc = layout.free_spacing; //unused - -#ifndef NEW_TABULAR - /* It might be a table */ - if (par->table){ - cell = 1; - actcell = 0; - cells = par->table->columns; - clen = new int [cells]; - memset(clen, 0, sizeof(int) * cells); - - for (i = 0, j = 0, h = 1; i < par->size(); ++i, ++h) { - c = par->GetChar(i); - if (c == LyXParagraph::META_INSET) { - if ((inset = par->GetInset(i))) { - std::ostringstream ost; - inset->Ascii(this, ost); - h += ost.str().length(); - } - } else if (c == LyXParagraph::META_NEWLINE) { - if (clen[j] < h) - clen[j] = h; - h = 0; - j = (++j) % par->table->NumberOfCellsInRow(actcell); - ++actcell; - } - } - if (clen[j] < h) - clen[j] = h; - } -#endif font1 = LyXFont(LyXFont::ALL_INHERIT, params.language_info); actcell = 0; for (i = 0, actpos = 1; i < par->size(); ++i, ++actpos) { @@ -1484,27 +1440,6 @@ void Buffer::writeFileAscii(string const & fname, int linelen) ofs << " "; currlinelen += (ltype_depth-depth)*2; } -#ifndef NEW_TABULAR - if (par->table) { - for(j = 0; j < cells; ++j) { - ofs << '+'; - for(h = 0; h < (clen[j] + 1); - ++h) - ofs << '-'; - } - ofs << "+\n"; - for(j = 0; j < depth; ++j) - ofs << " "; - currlinelen = depth * 2; - if (ltype_depth > depth) { - for(j = ltype_depth; - j > depth; --j) - ofs << " "; - currlinelen += (ltype_depth-depth)*2; - } - ofs << "| "; - } -#endif } font2 = par->GetFontSettings(params, i); if (font1.latex() != font2.latex()) { @@ -1528,61 +1463,16 @@ void Buffer::writeFileAscii(string const & fname, int linelen) } break; case LyXParagraph::META_NEWLINE: -#ifndef NEW_TABULAR - if (par->table) { - if (par->table->NumberOfCellsInRow(actcell) <= cell) { - for(j = actpos; j < clen[cell - 1]; ++j) - ofs << ' '; - ofs << " |\n"; - for(j = 0; j < depth; ++j) - ofs << " "; - currlinelen = depth*2; - if (ltype_depth > depth) { - for(j = ltype_depth; j > depth; --j) - ofs << " "; - currlinelen += (ltype_depth-depth) * 2; - } - for(j = 0; j < cells; ++j) { - ofs << '+'; - for(h = 0; h < (clen[j] + 1); ++h) - ofs << '-'; - } - ofs << "+\n"; - for(j = 0; j < depth; ++j) - ofs << " "; - currlinelen = depth * 2; - if (ltype_depth > depth) { - for(j = ltype_depth; - j > depth; --j) - ofs << " "; - currlinelen += (ltype_depth-depth)*2; - } - ofs << "| "; - cell = 1; - } else { - for(j = actpos; - j < clen[cell - 1]; ++j) - ofs << ' '; - ofs << " | "; - ++cell; - } - ++actcell; - currlinelen = actpos = 0; - } else { -#endif - ofs << "\n"; - for(j = 0; j < depth; ++j) + ofs << "\n"; + for(j = 0; j < depth; ++j) + ofs << " "; + currlinelen = depth * 2; + if (ltype_depth > depth) { + for(j = ltype_depth; + j > depth; --j) ofs << " "; - currlinelen = depth * 2; - if (ltype_depth > depth) { - for(j = ltype_depth; - j > depth; --j) - ofs << " "; - currlinelen += (ltype_depth - depth) * 2; - } -#ifndef NEW_TABULAR + currlinelen += (ltype_depth - depth) * 2; } -#endif break; case LyXParagraph::META_HFILL: ofs << "\t"; @@ -1611,28 +1501,6 @@ void Buffer::writeFileAscii(string const & fname, int linelen) break; } } -#ifndef NEW_TABULAR - if (par->table) { - for(j = actpos; j < clen[cell - 1]; ++j) - ofs << ' '; - ofs << " |\n"; - for(j = 0; j < depth; ++j) - ofs << " "; - currlinelen = depth * 2; - if (ltype_depth > depth) { - for(j = ltype_depth; j > depth; --j) - ofs << " "; - currlinelen += (ltype_depth - depth) * 2; - } - for(j = 0; j < cells; ++j) { - ofs << '+'; - for(h = 0; h < (clen[j] + 1); ++h) - ofs << '-'; - } - ofs << "+\n"; - delete [] clen; - } -#endif par = par->next; } @@ -3165,14 +3033,6 @@ void Buffer::SimpleDocBookOnePar(ostream & os, string & extra, LyXParagraph * par, int & desc_on, int const depth) { -#ifndef NEW_TABULAR - if (par->table) { - par->SimpleDocBookOneTablePar(this, - os, extra, desc_on, depth); - return; - } -#endif - bool emph_flag = false; LyXLayout const & style = textclasslist.Style(params.textclass, diff --git a/src/layout_forms.C b/src/layout_forms.C index 7f88ea6f9d..f128410c9c 100644 --- a/src/layout_forms.C +++ b/src/layout_forms.C @@ -549,7 +549,7 @@ FD_form_paper *create_form_form_paper(void) return fdui; } /*---------------------------------------*/ - +#if 0 FD_form_table_options *create_form_form_table_options(void) { FL_OBJECT *obj; @@ -678,6 +678,7 @@ FD_form_table_options *create_form_form_table_options(void) return fdui; } /*---------------------------------------*/ +#endif FD_form_paragraph_extra *create_form_form_paragraph_extra(void) { @@ -764,7 +765,7 @@ FD_form_paragraph_extra *create_form_form_paragraph_extra(void) return fdui; } /*---------------------------------------*/ - +#if 0 FD_form_table_extra *create_form_form_table_extra(void) { FL_OBJECT *obj; @@ -815,4 +816,4 @@ FD_form_table_extra *create_form_form_table_extra(void) return fdui; } /*---------------------------------------*/ - +#endif diff --git a/src/layout_forms.h b/src/layout_forms.h index e27a000b2d..aaa4123446 100644 --- a/src/layout_forms.h +++ b/src/layout_forms.h @@ -36,17 +36,21 @@ extern "C" void PaperCancelCB(FL_OBJECT *, long); extern "C" void PaperApplyCB(FL_OBJECT *, long); extern "C" void PaperOKCB(FL_OBJECT *, long); +#if 0 extern "C" void TableOptCloseCB(FL_OBJECT *, long); extern "C" void TableOptionsCB(FL_OBJECT *, long); extern "C" void SetPWidthCB(FL_OBJECT *, long); +#endif extern "C" void CheckPExtraOptCB(FL_OBJECT *, long); extern "C" void ParagraphExtraOKCB(FL_OBJECT *, long); extern "C" void ParagraphExtraApplyCB(FL_OBJECT *, long); extern "C" void ParagraphExtraCancelCB(FL_OBJECT *, long); +#if 0 extern "C" void TableOptionsCB(FL_OBJECT *, long); extern "C" void TableSpeCloseCB(FL_OBJECT *, long); +#endif } @@ -60,7 +64,9 @@ extern bool UpdateLayoutPaper(); extern bool UpdateLayoutQuotes(); extern bool UpdateLayoutParagraph(); extern bool UpdateParagraphExtra(); +#if 0 extern bool UpdateLayoutTable(int); +#endif extern void MenuLayoutCharacter(); extern void MenuLayoutDocument(); @@ -68,7 +74,9 @@ extern void MenuLayoutPreamble(); extern void MenuLayoutPaper(); extern void MenuLayoutQuotes(); extern void MenuLayoutParagraph(); +#if 0 extern void MenuLayoutTable(int); +#endif extern "C" { diff --git a/src/lyx_cb.C b/src/lyx_cb.C index 9c30a7931f..d767737d2c 100644 --- a/src/lyx_cb.C +++ b/src/lyx_cb.C @@ -2626,19 +2626,10 @@ void TableApplyCB(FL_OBJECT *, long) if (!current_view->available()) return; -#ifndef NEW_TABULAR - // check for tables in tables - if (current_view->text->cursor.par()->table){ - WriteAlert(_("Impossible Operation!"), - _("Cannot insert table in table."), - _("Sorry.")); - return; - } -#endif current_view->owner()->getMiniBuffer()->Set(_("Inserting table...")); - int ysize = int(fl_get_slider_value(fd_form_table->slider_columns) + 0.5); - int xsize = int(fl_get_slider_value(fd_form_table->slider_rows) + 0.5); + int const ysize = int(fl_get_slider_value(fd_form_table->slider_columns) + 0.5); + int const xsize = int(fl_get_slider_value(fd_form_table->slider_rows) + 0.5); current_view->hideCursor(); @@ -2689,10 +2680,6 @@ void TableApplyCB(FL_OBJECT *, long) string(), 0); } -#endif -#ifndef NEW_TABULAR - current_view->text->cursor.par()->table = - new LyXTable(xsize, ysize); #endif Language const * lang = current_view->text->cursor.par()->getParLanguage(current_view->buffer()->params); @@ -2762,11 +2749,7 @@ void FigureApplyCB(FL_OBJECT *, long) return; current_view->owner()->getMiniBuffer()->Set(_("Inserting figure...")); - if (fl_get_button(fd_form_figure->radio_inline) -#ifndef NEW_TABULAR - || current_view->text->cursor.par()->table -#endif - ) { + if (fl_get_button(fd_form_figure->radio_inline)) { InsetFig * new_inset = new InsetFig(100, 20, buffer); current_view->insertInset(new_inset); current_view->owner()->getMiniBuffer()->Set(_("Figure inserted")); diff --git a/src/lyx_gui.C b/src/lyx_gui.C index 1b090fc065..bc088c945e 100644 --- a/src/lyx_gui.C +++ b/src/lyx_gui.C @@ -457,25 +457,6 @@ void LyXGUI::create_forms() lyxerr[Debug::INIT] << "Initializing form_paper...done" << endl; #endif -#ifndef NEW_TABULAR - // the table_options form - fd_form_table_options = create_form_form_table_options(); - fl_set_form_atclose(fd_form_table_options->form_table_options, - CancelCloseBoxCB, 0); - fl_set_input_return(fd_form_table_options->input_column_width, - FL_RETURN_ALWAYS); - - // the table_extra form - fd_form_table_extra = create_form_form_table_extra(); - fl_set_form_atclose(fd_form_table_extra->form_table_extra, - CancelCloseBoxCB, 0); - fl_set_input_return(fd_form_table_extra->input_special_alignment, - FL_RETURN_ALWAYS); - fl_set_input_return(fd_form_table_extra->input_special_multialign, - FL_RETURN_ALWAYS); - lyxerr[Debug::INIT] << "Initializing form_table_extra...done" << endl; -#endif - #ifdef USE_OLD_DOCUMENT_LAYOUT // the quotes form fd_form_quotes = create_form_form_quotes(); @@ -492,19 +473,6 @@ void LyXGUI::create_forms() fl_set_form_atclose(fd_form_preamble->form_preamble, CancelCloseBoxCB, 0); -#ifndef NEW_TABULAR - // the table form - fd_form_table = create_form_form_table(); - fl_set_form_atclose(fd_form_table->form_table, CancelCloseBoxCB, 0); - fl_set_slider_bounds(fd_form_table->slider_rows, 1, 50); - fl_set_slider_bounds(fd_form_table->slider_columns, 1, 50); - fl_set_slider_value(fd_form_table->slider_rows, 5); - fl_set_slider_value(fd_form_table->slider_columns, 5); - fl_set_slider_precision(fd_form_table->slider_rows, 0); - fl_set_slider_precision(fd_form_table->slider_columns, 0); - lyxerr[Debug::INIT] << "Initializing form_table...done" << endl; -#endif - // the sendto form fd_form_sendto = create_form_form_sendto(); fl_set_form_atclose(fd_form_sendto->form_sendto, CancelCloseBoxCB, 0); diff --git a/src/lyx_gui_misc.C b/src/lyx_gui_misc.C index 449c9b6442..612276c4c7 100644 --- a/src/lyx_gui_misc.C +++ b/src/lyx_gui_misc.C @@ -122,14 +122,6 @@ void CloseAllBufferRelatedDialogs() if (fd_form_figure->form_figure->visible) { fl_hide_form(fd_form_figure->form_figure); } -#ifndef NEW_TABULAR - if (fd_form_table->form_table->visible) { - fl_hide_form(fd_form_table->form_table); - } - if (fd_form_table_options->form_table_options->visible) { - fl_hide_form(fd_form_table_options->form_table_options); - } -#endif if (fd_form_sendto->form_sendto->visible) { fl_hide_form(fd_form_sendto->form_sendto); } @@ -203,11 +195,6 @@ void updateAllVisibleBufferRelatedDialogs() if (fd_form_paragraph_extra->form_paragraph_extra->visible) { UpdateParagraphExtra(); } -#ifndef NEW_TABULAR - if (fd_form_table_options->form_table_options->visible) { - UpdateLayoutTable(1); // just like a right mouse click - } -#endif if (fd_form_bullet) { if (fd_form_bullet->form_bullet->visible) { updateBulletForm(); @@ -221,11 +208,6 @@ void updateAllVisibleBufferRelatedDialogs() if (fd_form_character->form_character->visible) { fl_hide_form(fd_form_character->form_character); } -#ifndef NEW_TABULAR - if (fd_form_table->form_table->visible) { - fl_hide_form(fd_form_table->form_table); - } -#endif #ifndef ALWAYS_CLOSE_MATH_PANELS // The math popups should be closed only if we switch // to a readonly buffer diff --git a/src/lyxfunc.C b/src/lyxfunc.C index 80e2de3a0e..0fc79b7858 100644 --- a/src/lyxfunc.C +++ b/src/lyxfunc.C @@ -133,7 +133,9 @@ extern void MenuLayoutCharacter(); extern void MenuLayoutParagraph(); extern void MenuLayoutDocument(); extern void MenuLayoutPaper(); +#if 0 extern void MenuLayoutTable(int flag); +#endif extern void MenuLayoutQuotes(); extern void MenuLayoutPreamble(); extern void MenuLayoutSave(); @@ -546,11 +548,6 @@ LyXFunc::func_status LyXFunc::getStatus(int ac) const || ! buf->isLiterate()); break; -#ifndef NEW_TABULAR - case LFUN_LAYOUT_TABLE: - disable = ! owner->view()->text->cursor.par()->table; - break; -#endif case LFUN_LAYOUT_TABULAR: disable = true; if (owner->view()->the_locking_inset) { @@ -1070,11 +1067,7 @@ string const LyXFunc::Dispatch(int ac, } case LFUN_DIALOG_TABULAR_INSERT: -#ifndef NEW_TABULAR - Table(); -#else owner->getDialogs()->showTabularCreate(); -#endif break; case LFUN_TABULAR_FEATURE: @@ -1449,7 +1442,8 @@ string const LyXFunc::Dispatch(int ac, case LFUN_LAYOUT_CHARACTER: MenuLayoutCharacter(); break; - + +#if 0 case LFUN_LAYOUT_TABLE: { int flag = 0; @@ -1457,7 +1451,8 @@ string const LyXFunc::Dispatch(int ac, MenuLayoutTable(flag); } break; - +#endif + case LFUN_LAYOUT_TABULAR: if (owner->view()->the_locking_inset) { if (owner->view()->the_locking_inset->LyxCode()==Inset::TABULAR_CODE) { diff --git a/src/lyxparagraph.h b/src/lyxparagraph.h index 9a7abc872a..48476bd5ae 100644 --- a/src/lyxparagraph.h +++ b/src/lyxparagraph.h @@ -36,10 +36,6 @@ class BufferView; // up. (Lgb) //#define NEW_INSETS 1 -// I dare you to try this one too. It is ortogonal with NEW_INSETS so you -// can try both or just one of them. -#define NEW_TABULAR 1 - /// A LyXParagraph holds all text, attributes and insets in a text paragraph class LyXParagraph { public: @@ -335,12 +331,6 @@ public: /// LyXParagraph * previous; -#ifndef NEW_TABULAR - /* table stuff -- begin*/ - /// - LyXTable * table; - /* table stuff -- end*/ -#endif /// InsetBibKey * bibkey; // ale970302 @@ -539,17 +529,6 @@ public: void UnsetPExtraType(BufferParams const &); /// bool linuxDocConvertChar(char c, string & sgml_string); -#ifndef NEW_TABULAR - /// - void DocBookContTableRows(Buffer const *, - std::ostream &, string & extra, - int & desc_on, size_type i, - int current_cell_number, int & column); - /// - void SimpleDocBookOneTablePar(Buffer const *, - std::ostream &, string & extra, - int & desc_on, int depth); -#endif private: /// struct InsetTable { @@ -633,16 +612,6 @@ private: std::ostream & foot, TexRow & foot_texrow, int & foot_count, bool parent_is_rtl); -#endif -#ifndef NEW_TABULAR - /// - bool SimpleTeXOneTablePar(Buffer const *, BufferParams const &, - std::ostream &, TexRow & texrow); - /// - bool TeXContTableRows(Buffer const *, BufferParams const &, - std::ostream &, size_type i, - int current_cell_number, - int & column, TexRow & texrow); #endif /// void SimpleTeXBlanks(std::ostream &, TexRow & texrow, diff --git a/src/lyxtext.h b/src/lyxtext.h index 05ffe20fd1..548d035c45 100644 --- a/src/lyxtext.h +++ b/src/lyxtext.h @@ -444,31 +444,6 @@ public: /// int NumberOfCell(LyXParagraph * par, LyXParagraph::size_type pos) const; - /* table stuff -- begin*/ - - /** all table features of the text-class are put together in - this function. Possible values of feature are defined in table.h - */ - void TableFeatures(BufferView *, int feature, string const & val) const; - /// - void TableFeatures(BufferView *, int feature) const; - - /** pos points at the beginning of the next cell (if there is one) - */ - int WidthOfCell(BufferView *, LyXParagraph * par, - LyXParagraph::size_type & pos) const; - /// - void CheckParagraphInTable(BufferView *, LyXParagraph * par, - LyXParagraph::size_type pos); - /// - void InsertCharInTable(BufferView *, char c); - /// - void BackspaceInTable(BufferView *); - /// - bool HitInTable(BufferView *, Row * row, int x) const; - /// - bool MouseHitInTable(BufferView *, int x, long y) const; - /* table stuff -- end*/ /// LyXParagraph * GetParFromID(int id); diff --git a/src/paragraph.C b/src/paragraph.C index d3c1161ff1..24796fd0f7 100644 --- a/src/paragraph.C +++ b/src/paragraph.C @@ -80,11 +80,6 @@ LyXParagraph::LyXParagraph() #endif align = LYX_ALIGN_BLOCK; -#ifndef NEW_TABULAR - /* table stuff -- begin*/ - table = 0; - /* table stuff -- end*/ -#endif inset_owner = 0; id_ = paragraph_id++; bibkey = 0; // ale970302 @@ -112,11 +107,6 @@ LyXParagraph::LyXParagraph(LyXParagraph * par) #ifndef NEW_INSETS footnoteflag = LyXParagraph::NO_FOOTNOTE; footnotekind = LyXParagraph::FOOTNOTE; -#endif -#ifndef NEW_TABULAR - /* table stuff -- begin*/ - table = 0; - /* table stuff -- end*/ #endif inset_owner = 0; id_ = paragraph_id++; @@ -247,13 +237,7 @@ void LyXParagraph::writeFile(Buffer const * buf, ostream & os, footflag = LyXParagraph::NO_FOOTNOTE; } #endif -#ifndef NEW_TABULAR - // It might be a table. - if (table){ - os << "\\LyXTable\n"; - table->Write(os); - } -#endif + // bibitem ale970302 if (bibkey) bibkey->Write(buf, os); @@ -398,10 +382,6 @@ void LyXParagraph::validate(LaTeXFeatures & features) const (*cit).inset->Validate(features); } -#ifndef NEW_TABULAR - if (table && table->IsLongTable()) - features.longtable = true; -#endif if (pextra_type == PEXTRA_INDENT) features.LyXParagraphIndent = true; if (pextra_type == PEXTRA_FLOATFLT) @@ -414,10 +394,6 @@ void LyXParagraph::validate(LaTeXFeatures & features) const if (params.paragraph_separation == BufferParams::PARSEP_INDENT && pextra_type == LyXParagraph::PEXTRA_MINIPAGE) features.NeedLyXMinipageIndent = true; -#ifndef NEW_TABULAR - if (table && table->NeedRotating()) - features.rotating = true; -#endif #ifndef NEW_INSETS if (footnoteflag != NO_FOOTNOTE && footnotekind == ALGORITHM) features.algorithm = true; @@ -536,11 +512,6 @@ LyXParagraph::~LyXParagraph() it != insetlist.end(); ++it) { delete (*it).inset; } -#ifndef NEW_TABULAR - /* table stuff -- begin*/ - delete table; - /* table stuff -- end*/ -#endif // ale970302 delete bibkey; @@ -1609,22 +1580,17 @@ int LyXParagraph::StripLeadingSpaces(LyXTextClassList::size_type tclass) return 0; int i = 0; - if ( #ifndef NEW_INSETS - !IsDummy() && -#endif -#ifndef NEW_TABULAR - !table -#else - true + if (!IsDummy()) { #endif - ){ while (Last() && (IsNewline(0) || IsLineSeparator(0))){ Erase(0); ++i; } +#ifndef NEW_INSETS } +#endif return i; } @@ -1640,14 +1606,6 @@ LyXParagraph * LyXParagraph::Clone() const // follow footnotes result->layout = layout; -#ifndef NEW_TABULAR - /* table stuff -- begin*/ - if (table) - result->table = table->Clone(); - else - result->table = 0; - /* table stuff -- end*/ -#endif result->inset_owner = inset_owner; // ale970302 @@ -1699,10 +1657,6 @@ bool LyXParagraph::HasSameLayout(LyXParagraph const * par) const par->pextra_alignment == pextra_alignment && par->pextra_hfill == pextra_hfill && par->pextra_start_minipage == pextra_start_minipage && -#ifndef NEW_TABULAR - par->table == table && // what means: NO TABLE AT ALL -#endif - par->noindent == noindent && par->depth == depth); } @@ -1842,7 +1796,7 @@ int LyXParagraph::GetEndLabel(BufferParams const & bparams) const int par_depth = GetDepth(); while (par) { LyXTextClass::LayoutList::size_type layout = par->GetLayout(); - int endlabeltype = + int const endlabeltype = textclasslist.Style(bparams.textclass, layout).endlabeltype; if (endlabeltype != END_LABEL_NO_LABEL) { @@ -1964,12 +1918,7 @@ void LyXParagraph::SetOnlyLayout(BufferParams const & bparams, LyXParagraph * npar = 0; par->layout = new_layout; -#ifndef NEW_TABULAR - /* table stuff -- begin*/ - if (table) - par->layout = 0; - /* table stuff -- end*/ -#endif + if (par->pextra_type == PEXTRA_NONE) { if (par->Previous()) { #ifndef NEW_INSETS @@ -2039,12 +1988,6 @@ void LyXParagraph::SetLayout(BufferParams const & bparams, par->added_space_bottom = VSpace(VSpace::NONE); par->spacing.set(Spacing::Default); -#ifndef NEW_TABULAR - /* table stuff -- begin*/ - if (table) - par->layout = 0; - /* table stuff -- end*/ -#endif if (par->pextra_type == PEXTRA_NONE) { if (par->Previous()) { #ifndef NEW_INSETS @@ -2465,11 +2408,6 @@ LyXParagraph * LyXParagraph::TeXOnePar(Buffer const * buf, && !( footnoteflag != LyXParagraph::NO_FOOTNOTE && footnotekind != LyXParagraph::FOOTNOTE && footnotekind != LyXParagraph::MARGIN) -#endif -#ifndef NEW_TABULAR - && !(table - || (par - && par->table)) #endif ) { // don't insert this if we would be adding it @@ -2532,11 +2470,6 @@ bool LyXParagraph::SimpleTeXOnePar(Buffer const * buf, { lyxerr[Debug::LATEX] << "SimpleTeXOnePar... " << this << endl; -#ifndef NEW_TABULAR - if (table) - return SimpleTeXOneTablePar(buf, bparams, os, texrow); -#endif - bool return_value = false; LyXLayout const & style = @@ -2757,308 +2690,6 @@ bool LyXParagraph::SimpleTeXOnePar(Buffer const * buf, } -#ifndef NEW_TABULAR -// This one spits out the text of a table paragraph -bool LyXParagraph::SimpleTeXOneTablePar(Buffer const * buf, - BufferParams const & bparams, - ostream & os, TexRow & texrow) -{ - lyxerr[Debug::LATEX] << "SimpleTeXOneTablePar... " << this << endl; - - bool return_value = false; - - LyXLayout const & style = - textclasslist.Style(bparams.textclass, GetLayout()); - - int column = 0; -#ifndef NEW_INSETS - if (!IsDummy()) { // it is dummy if it is in a float!!! -#endif - if (style.isCommand()) { - os << '{'; - ++column; - } else if (align != LYX_ALIGN_LAYOUT) { - os << '{'; - ++column; - return_value = true; - } - if (noindent) { - os << "\\noindent "; - column += 10; - } - switch (align) { - case LYX_ALIGN_NONE: - case LYX_ALIGN_BLOCK: - case LYX_ALIGN_LAYOUT: - case LYX_ALIGN_SPECIAL: break; - case LYX_ALIGN_LEFT: - os << "\\raggedright "; - column+= 13; - break; - case LYX_ALIGN_RIGHT: - os << "\\raggedleft "; - column+= 12; - break; - case LYX_ALIGN_CENTER: - os << "\\centering "; - column+= 11; - break; - } -#ifndef NEW_INSETS - } -#endif - - LyXFont basefont = getFont(bparams, -1); // Get layout font - // Which font is currently active? - LyXFont running_font = basefont; - LyXFont last_font; - // Do we have an open font change? - bool open_font = false; - int current_cell_number = -1; - int tmp = table->TexEndOfCell(os, current_cell_number); - for (; tmp > 0 ; --tmp) - texrow.newline(); - - texrow.start(this, 0); - - bool is_rtl = getParLanguage(bparams)->RightToLeft(); - bool first_in_cell = true; - - for (size_type i = 0; i < size(); ++i) { - value_type c = GetChar(i); - if (table->IsContRow(current_cell_number + 1)) { - if (c == LyXParagraph::META_NEWLINE) - ++current_cell_number; - continue; - } - ++column; - - if (first_in_cell && is_rtl) { - os << "\\R{"; - column += 3; - first_in_cell = false; - } - - // Fully instantiated font - LyXFont font = getFont(bparams, i); - last_font = running_font; - - // Spaces at end of font change are simulated to be - // outside font change. - // i.e. we write "\textXX{text} " rather than - // "\textXX{text }". (Asger) - if (open_font && c == ' ' && i <= size() - 2 - && getFont(bparams, i + 1) != running_font - && getFont(bparams, i + 1) != font) { - font = getFont(bparams, i + 1); - } - - // We end font definition before blanks - if (font != running_font && open_font) { - column += running_font.latexWriteEndChanges(os, - basefont, - font); - running_font = basefont; - open_font = false; - } - // Blanks are printed before start of fontswitch - if (c == ' ') { - SimpleTeXBlanks(os, texrow, i, column, font, style); - } - // Do we need to change font? - if (font != running_font) { - column += font.latexWriteStartChanges(os, basefont, - last_font); - running_font = font; - open_font = true; - } - // Do we need to turn on LaTeX mode? - if (font.latex() != running_font.latex()) { - if (font.latex() == LyXFont::ON - && style.needprotect) { - os << "\\protect "; - column += 9; - } - } - if (c == LyXParagraph::META_NEWLINE) { - // special case for inside a table - // different from default case in - // SimpleTeXSpecialChars() - if (open_font) { - column += running_font - .latexWriteEndChanges(os, basefont, - basefont); - open_font = false; - } - basefont = getFont(bparams, -1); - running_font = basefont; - ++current_cell_number; - if (table->CellHasContRow(current_cell_number) >= 0) { - TeXContTableRows(buf, bparams, os, i + 1, - current_cell_number, - column, texrow); - } - if (is_rtl && !first_in_cell) { - os << "}"; - first_in_cell = true; - } - - // if this cell follow only ContRows till end don't - // put the EndOfCell because it is put after the - // for(...) - if (table->ShouldBeVeryLastCell(current_cell_number)) { - --current_cell_number; - break; - } - int tmp = table->TexEndOfCell(os, - current_cell_number); - if (tmp > 0) { - column = 0; - } else if (tmp < 0) { - tmp = -tmp; - } - for (; tmp--;) { - texrow.newline(); - } - texrow.start(this, i + 1); - } else { - SimpleTeXSpecialChars(buf, bparams, - os, texrow, false, - font, running_font, basefont, - open_font, style, i, column, c); - } - } - - // If we have an open font definition, we have to close it - if (open_font) { - running_font.latexWriteEndChanges(os, basefont, basefont); - } - ++current_cell_number; - if (is_rtl && !first_in_cell) - os << "}"; - tmp = table->TexEndOfCell(os, current_cell_number); - for (; tmp > 0; --tmp) - texrow.newline(); - lyxerr[Debug::LATEX] << "SimpleTeXOneTablePar...done " << this << endl; - return return_value; -} -#endif - - -#ifndef NEW_TABULAR -// This one spits out the text off ContRows in tables -bool LyXParagraph::TeXContTableRows(Buffer const * buf, - BufferParams const & bparams, - ostream & os, - LyXParagraph::size_type i, - int current_cell_number, - int & column, TexRow & texrow) -{ - lyxerr[Debug::LATEX] << "TeXContTableRows... " << this << endl; - if (!table) - return false; - - bool return_value = false; - LyXLayout const & style = - textclasslist.Style(bparams.textclass, - GetLayout()); - LyXFont basefont = getFont(bparams, -1); // Get layout font - LyXFont last_font; - // Which font is currently active? - LyXFont running_font = basefont; - // Do we have an open font change? - bool open_font = false; - - size_type lastpos = i; - int cell = table->CellHasContRow(current_cell_number); - ++current_cell_number; - value_type c; - while(cell >= 0) { - // first find the right position - i = lastpos; - for (; (i < size()) && (current_cell_number < cell); ++i) { - c = GetChar(i); - if (c == LyXParagraph::META_NEWLINE) - ++current_cell_number; - } - lastpos = i; - c = GetChar(i); - if (table->Linebreaks(table->FirstVirtualCell(cell))) { - os << " \\\\\n"; - texrow.newline(); - column = 0; - } else if ((c != ' ') && (c != LyXParagraph::META_NEWLINE)) { - os << ' '; - } - - for (; i < size() - && (c = GetChar(i)) != LyXParagraph::META_NEWLINE; - ++i) { - ++column; - - // Fully instantiated font - LyXFont font = getFont(bparams, i); - last_font = running_font; - - // Spaces at end of font change are simulated to - // be outside font change. i.e. we write - // "\textXX{text} " rather than "\textXX{text }". - // (Asger) - if (open_font && c == ' ' && i <= size() - 2 - && getFont(bparams, i + 1) != running_font - && getFont(bparams, i + 1) != font) { - font = getFont(bparams, i + 1); - } - - // We end font definition before blanks - if (font != running_font && open_font) { - column += running_font.latexWriteEndChanges(os, basefont, font); - running_font = basefont; - open_font = false; - } - // Blanks are printed before start of fontswitch - if (c == ' '){ - SimpleTeXBlanks(os, texrow, i, - column, font, style); - } - // Do we need to change font? - if (font != running_font) { - column += - font.latexWriteStartChanges(os, - basefont, - last_font); - running_font = font; - open_font = true; - } - // Do we need to turn on LaTeX mode? - if (font.latex() != running_font.latex()) { - if (font.latex() == LyXFont::ON - && style.needprotect) { - os << "\\protect "; - column += 9; - } - } - SimpleTeXSpecialChars(buf, bparams, - os, texrow, false, font, - running_font, basefont, - open_font, style, i, column, c); - } - // If we have an open font definition, we have to close it - if (open_font) { - running_font.latexWriteEndChanges(os, basefont, - basefont); - open_font = false; - } - basefont = getFont(bparams, -1); - running_font = basefont; - cell = table->CellHasContRow(current_cell_number); - } - lyxerr[Debug::LATEX] << "TeXContTableRows...done " << this << endl; - return return_value; -} -#endif - - bool LyXParagraph::linuxDocConvertChar(char c, string & sgml_string) { bool retval = false; @@ -3123,329 +2754,6 @@ bool LyXParagraph::linuxDocConvertChar(char c, string & sgml_string) } -#ifndef NEW_TABULAR -void LyXParagraph::SimpleDocBookOneTablePar(Buffer const * buffer, - ostream & os, string & extra, - int & desc_on, int depth) -{ - BufferParams const & bparams = buffer->params; - if (!table) return; - lyxerr[Debug::LATEX] << "SimpleDocbookOneTablePar... " << this << endl; - int column = 0; - LyXFont font1, font2; - char c; - Inset * inset; - size_type main_body; - bool emph_flag = false; - - LyXLayout const & style = - textclasslist.Style(bparams.textclass, - GetLayout()); - - if (style.labeltype != LABEL_MANUAL) - main_body = 0; - else - main_body = BeginningOfMainBody(); - - // Gets paragraph main font. - if (main_body > 0) - font1 = style.labelfont; - else - font1 = style.font; - - int char_line_count = depth; - os << newlineAndDepth(depth); -#ifndef NEW_INSETS - if (footnoteflag == LyXParagraph::NO_FOOTNOTE) { - os << "" - << newlineAndDepth(++depth); - } -#else - os << "" - << newlineAndDepth(++depth); -#endif - int current_cell_number = -1; - int tmp = table->DocBookEndOfCell(os, current_cell_number, depth); - - // Parsing main loop. - for (size_type i = 0; i < size(); ++i) { - c = GetChar(i); - if (table->IsContRow(current_cell_number+1)) { - if (c == LyXParagraph::META_NEWLINE) - ++current_cell_number; - continue; - } - ++column; - - // Fully instantiated font - font2 = getFont(bparams, i); - - // Handle tag. - if (font1.emph() != font2.emph() && i) { - if (font2.emph() == LyXFont::ON) { - os << ""; - emph_flag= true; - } else if (emph_flag) { - os << ""; - emph_flag= false; - } - } - if (c == LyXParagraph::META_NEWLINE) { - // We have only to control for emphasis open here! - if (emph_flag) { - os << ""; - emph_flag= false; - } - font1 = font2 = getFont(bparams, -1); - ++current_cell_number; - if (table->CellHasContRow(current_cell_number) >= 0) { - DocBookContTableRows(buffer, - os, extra, desc_on, i + 1, - current_cell_number, - column); - } - // if this cell follow only ContRows till end don't - // put the EndOfCell because it is put after the - // for(...) - if (table->ShouldBeVeryLastCell(current_cell_number)) { - --current_cell_number; - break; - } - tmp = table->DocBookEndOfCell(os, - current_cell_number, - depth); - - if (tmp > 0) - column = 0; - } else if (c == LyXParagraph::META_INSET) { - inset = GetInset(i); - std::ostringstream ost; - inset->DocBook(buffer, ost); - string tmp_out = ost.str().c_str(); - - // - // This code needs some explanation: - // Two insets are treated specially - // label if it is the first element in a - // command paragraph - // desc_on == 3 - // graphics inside tables or figure floats - // can't go on - // title (the equivalente in latex for this - // case is caption - // and title should come first - // desc_on == 4 - // - if(desc_on != 3 || i != 0) { - if(tmp_out[0] == '@') { - if(desc_on == 4) - extra += frontStrip(tmp_out, - '@'); - else - os << frontStrip(tmp_out, - '@'); - } else - os << tmp_out; - } - } else if (font2.latex() == LyXFont::ON) { - // "TeX"-Mode on == > SGML-Mode on. - if (c != '\0') - os << c; - ++char_line_count; - } else { - string sgml_string; - if (linuxDocConvertChar(c, sgml_string) - && !style.free_spacing) { - // in freespacing mode, spaces are - // non-breaking characters - // char is ' ' - if (desc_on == 1) { - ++char_line_count; - os << '\n' - << ""; - desc_on = 2; - } else { - os << c; - } - } else { - os << sgml_string; - } - } - font1 = font2; - } - - // Needed if there is an optional argument but no contents. - if (main_body > 0 && main_body == size()) { - font1 = style.font; - } - - if (emph_flag) { - os << ""; - } - - ++current_cell_number; - tmp = table->DocBookEndOfCell(os, current_cell_number, depth); - // Resets description flag correctly. - switch(desc_on){ - case 1: - // not closed... - os << ""; - break; - } -#ifndef NEW_INSETS - if (footnoteflag == LyXParagraph::NO_FOOTNOTE) -#endif - os << ""; - os << '\n'; - lyxerr[Debug::LATEX] << "SimpleDocbookOneTablePar...done " - << this << endl; -} -#endif - - -#ifndef NEW_TABULAR -void LyXParagraph::DocBookContTableRows(Buffer const * buffer, - ostream & os, string & extra, - int & desc_on, - LyXParagraph::size_type i, - int current_cell_number, int &column) - -{ - if (!table) return; - - BufferParams const & bparams = buffer->params; - - lyxerr[Debug::LATEX] << "DocBookContTableRows... " << this << endl; - - LyXFont font2; - char c; - Inset * inset; - //string emph = "emphasis"; - bool emph_flag = false; - int char_line_count = 0; - - LyXLayout const & style = - textclasslist.Style(bparams.textclass, - GetLayout()); - - size_type main_body; - if (style.labeltype != LABEL_MANUAL) - main_body = 0; - else - main_body = BeginningOfMainBody(); - - // Gets paragraph main font. - LyXFont font1; - if (main_body > 0) - font1 = style.labelfont; - else - font1 = style.font; - - size_type lastpos = i; - int cell = table->CellHasContRow(current_cell_number); - ++current_cell_number; - while(cell >= 0) { - // first find the right position - i = lastpos; - for (; i < size() && current_cell_number < cell; ++i) { - c = GetChar(i); - if (c == LyXParagraph::META_NEWLINE) - ++current_cell_number; - } - lastpos = i; - c = GetChar(i); - // I don't know how to handle this so I comment it - // for the moment (Jug) -// if (table->Linebreaks(table->FirstVirtualCell(cell))) { -// file += " \\\\\n"; -// column = 0; -// } else - if ((c != ' ') && (c != LyXParagraph::META_NEWLINE)) { - os << ' '; - } - - for (; i < size() - && (c = GetChar(i)) != LyXParagraph::META_NEWLINE; - ++i) { - ++column; - - // Fully instantiated font - font2 = getFont(bparams, i); - - // Handle tag. - if (font1.emph() != font2.emph() && i) { - if (font2.emph() == LyXFont::ON) { - os << ""; - emph_flag= true; - } else if (emph_flag) { - os << ""; - emph_flag= false; - } - } - if (c == LyXParagraph::META_INSET) { - inset = GetInset(i); - std::ostringstream ost; - inset->DocBook(buffer, ost); - string tmp_out = ost.str().c_str(); - - // This code needs some explanation: - // Two insets are treated specially - // label if it is the first element in a - // command paragraph - // desc_on == 3 - // graphics inside tables or figure floats - // can't go on title (the equivalente in - // latex for this case is caption and title - // should come first - // desc_on == 4 - // - if(desc_on != 3 || i != 0) { - if(tmp_out[0] == '@') { - if(desc_on == 4) - extra += frontStrip(tmp_out, '@'); - else - os << frontStrip(tmp_out, '@'); - } else - os << tmp_out; - } - } else if (font2.latex() == LyXFont::ON) { - // "TeX"-Mode on == > SGML-Mode on. - if (c!= '\0') - os << c; - ++char_line_count; - } else { - string sgml_string; - if (linuxDocConvertChar(c, sgml_string) - && !style.free_spacing) { - // in freespacing mode, spaces are - // non-breaking characters - // char is ' ' - if (desc_on == 1) { - ++char_line_count; - os << '\n' - << ""; - desc_on = 2; - } else { - os << c; - } - } else { - os << sgml_string; - } - } - } - // we have only to control for emphasis open here! - if (emph_flag) { - os << ""; - emph_flag= false; - } - font1 = font2 = getFont(bparams, -1); - cell = table->CellHasContRow(current_cell_number); - } - lyxerr[Debug::LATEX] << "DocBookContTableRows...done " << this << endl; -} -#endif - - void LyXParagraph::SimpleTeXBlanks(ostream & os, TexRow & texrow, LyXParagraph::size_type const i, int & column, LyXFont const & font, @@ -3971,9 +3279,6 @@ LyXParagraph * LyXParagraph::TeXEnvironment(Buffer const * buf, if (par && par->depth > depth) { if (textclasslist.Style(bparams.textclass, par->layout).isParagraph() -#ifndef NEW_TABULAR - && !par->table -#endif // Thinko! // How to handle this? (Lgb) //&& !suffixIs(os, "\n\n") @@ -4571,29 +3876,14 @@ LyXParagraph::getParLanguage(BufferParams const & bparams) const else #endif if (size() > 0) { - Language const * lang = 0; -#ifndef NEW_TABULAR - if (!table) -#endif - lang = GetFirstFontSettings().language(); -#ifndef NEW_TABULAR - else { - for (size_type pos = 0; pos < size(); ++pos) { - if (IsNewline(pos)) { - lang = GetFontSettings(bparams, pos).language(); - break; - } - } - if (!lang) - lang = GetFirstFontSettings().language(); - } -#endif + Language const * lang = GetFirstFontSettings().language(); + if (lang->lang() == "default") return bparams.language_info; return lang; } else if (previous) return previous->getParLanguage(bparams); - //else + return bparams.language_info; } @@ -4601,9 +3891,6 @@ LyXParagraph::getParLanguage(BufferParams const & bparams) const bool LyXParagraph::isRightToLeftPar(BufferParams const & bparams) const { return lyxrc.rtl_support -#ifndef NEW_TABULAR - && !table -#endif && getParLanguage(bparams)->RightToLeft(); } @@ -4679,19 +3966,6 @@ string const LyXParagraph::String(Buffer const * buffer, LyXParagraph::size_type end) { string s; -#ifndef NEW_TABULAR - int actcell = 0; - int cell = 1; - if (table) - for (LyXParagraph::size_type i = 0; i < beg; ++i) - if (IsNewline(i)) { - if (cell >= table->NumberOfCellsInRow(actcell)) - cell = 1; - else - ++cell; - ++actcell; - } -#endif #ifndef NEW_INSETS if (beg == 0 && !IsDummy() && !labelstring.empty()) @@ -4709,18 +3983,6 @@ string const LyXParagraph::String(Buffer const * buffer, GetInset(i)->Ascii(buffer, ost); s += ost.str(); } -#ifndef NEW_TABULAR - else if (table && IsNewlineChar(c)) { - if (cell >= table->NumberOfCellsInRow(actcell)) { - s += '\n'; - cell = 1; - } else { - s += ' '; - ++cell; - } - ++actcell; - } -#endif } return s; diff --git a/src/text.C b/src/text.C index e37af166df..cf12ba24af 100644 --- a/src/text.C +++ b/src/text.C @@ -261,26 +261,16 @@ void LyXText::ComputeBidiTables(Buffer const * buf, Row * row) const LyXParagraph::size_type pos = (is_space && lpos + 1 <= bidi_end && !row->par()->IsLineSeparator(lpos + 1) && - ( -#ifndef NEW_TABULAR - !row->par()->table || -#endif - !row->par()->IsNewline(lpos + 1)) ) + !row->par()->IsNewline(lpos + 1)) ? lpos + 1 : lpos; LyXFont font = row->par()->GetFontSettings(buf->params, pos); bool new_rtl = font.isVisibleRightToLeft(); bool new_rtl0 = font.isRightToLeft(); int new_level; -#ifndef NEW_TABULAR - if (row->par()->table && row->par()->IsNewline(lpos)) { - new_level = 0; - new_rtl = new_rtl0 = false; - } else -#endif - if (lpos == main_body - 1 - && row->pos() < main_body - 1 - && row->par()->IsLineSeparator(lpos)) { + if (lpos == main_body - 1 + && row->pos() < main_body - 1 + && row->par()->IsLineSeparator(lpos)) { new_level = (rtl_par) ? 1 : 0; new_rtl = new_rtl0 = rtl_par; } else if (new_rtl0) @@ -347,20 +337,12 @@ bool LyXText::IsBoundary(Buffer const * buf, LyXParagraph * par, if (!lyxrc.rtl_support) return false; // This is just for speedup - if (!bidi_InRange(pos - 1) -#ifndef NEW_TABULAR - || (par->table && par->IsNewline(pos-1)) -#endif - ) + if (!bidi_InRange(pos - 1)) return false; bool rtl = bidi_level(pos - 1) % 2; bool rtl2 = rtl; - if (pos == par->Last() -#ifndef NEW_TABULAR - || (par->table && par->IsNewline(pos)) -#endif - ) + if (pos == par->Last()) rtl2 = par->isRightToLeftPar(buf->params); else if (bidi_InRange(pos)) rtl2 = bidi_level(pos) % 2; @@ -377,11 +359,7 @@ bool LyXText::IsBoundary(Buffer const * buf, LyXParagraph * par, bool rtl = font.isVisibleRightToLeft(); bool rtl2 = rtl; - if (pos == par->Last() -#ifndef NEW_TABULAR - || (par->table && par->IsNewline(pos)) -#endif - ) + if (pos == par->Last()) rtl2 = par->isRightToLeftPar(buf->params); else if (bidi_InRange(pos)) rtl2 = bidi_level(pos) % 2; @@ -663,12 +641,6 @@ int LyXText::LeftMargin(BufferView * bview, Row const * row) const string parindent = layout.parindent; -#ifndef NEW_TABULAR - /* table stuff -- begin */ - if (row->par()->table) - parindent.erase(); - /* table stuff -- end */ -#endif int x = LYX_PAPER_MARGIN; x += lyxfont::signedWidth(textclasslist @@ -996,59 +968,6 @@ int LyXText::LabelEnd (BufferView * bview, Row const * row) const } -#ifndef NEW_TABULAR -/* table stuff -- begin*/ -int LyXText::NumberOfCell(LyXParagraph * par, - LyXParagraph::size_type pos) const -{ - int cell = 0; - LyXParagraph::size_type tmp_pos = 0; - while (tmp_pos < pos) { - if (par->IsNewline(tmp_pos)) - ++cell; - ++tmp_pos; - } - return cell; -} - - -int LyXText::WidthOfCell(BufferView * bview, LyXParagraph * par, - LyXParagraph::size_type & pos) const -{ - int w = 0; - while (pos < par->Last() && !par->IsNewline(pos)) { - w += SingleWidth(bview, par, pos); - ++pos; - } - if (par->IsNewline(pos)) - ++pos; - return w; -} - - -bool LyXText::HitInTable(BufferView * bview, Row * row, int x) const -{ - float tmpx; - float fill_separator, fill_hfill, fill_label_hfill; - if (!row->par()->table) - return false; - PrepareToPrint(bview, row, tmpx, fill_separator, - fill_hfill, fill_label_hfill, false); - return (x > tmpx && x < tmpx + row->par()->table->WidthOfTable()); -} - - -bool LyXText::MouseHitInTable(BufferView * bview, int x, long y) const -{ - Row * row = GetRowNearY(y); - return HitInTable(bview, row, x); -} - - -/* table stuff -- end*/ -#endif - - // get the next breakpoint in a given paragraph LyXParagraph::size_type LyXText::NextBreakPoint(BufferView * bview, Row const * row, int width) const @@ -1058,22 +977,7 @@ LyXText::NextBreakPoint(BufferView * bview, Row const * row, int width) const if (width < 0) return par->Last(); -#ifndef NEW_TABULAR - /* table stuff -- begin*/ - if (par->table) { - while (pos < par->size() - && (!par->IsNewline(pos) - || !par->table->IsFirstCell(NumberOfCell(par, pos + 1)))) { - if (par->GetChar(pos) == LyXParagraph::META_INSET && - par->GetInset(pos) && par->GetInset(pos)->display()){ - par->GetInset(pos)->display(false); - } - ++pos; - } - return pos; - } - /* table stuff -- end*/ -#endif + // position of the last possible breakpoint // -1 isn't a suitable value, but a flag LyXParagraph::size_type last_separator = -1; @@ -1188,34 +1092,6 @@ int LyXText::Fill(BufferView * bview, Row * row, int paper_width) const int w, fill; // get the pure distance LyXParagraph::size_type last = RowLastPrintable(row); -#ifndef NEW_TABULAR - /* table stuff -- begin */ - if (row->par()->table) { - // for tables FILL does calculate the widthes of each cell in - // the row - LyXParagraph::size_type pos = row->pos(); - int cell = NumberOfCell(row->par(), pos); - w = 0; - do { - row->par()->table->SetWidthOfCell(cell, - WidthOfCell(bview, - row->par(), - pos)); - ++cell; - } while (pos <= last && !row->par()->table->IsFirstCell(cell)); - // don't forget the very last table cell without characters - if (cell == row->par()->table->GetNumberOfCells() - 1) - row->par()->table->SetWidthOfCell(cell, - WidthOfCell(bview, - row->par(), - pos)); - - return 0; /* width of table cannot be returned since - * we cannot guarantee its correct value at - * this point. */ - } - /* table stuff -- end*/ -#endif // special handling of the right address boxes if (textclasslist.Style(bview->buffer()->params.textclass, @@ -1489,16 +1365,6 @@ void LyXText::SetHeightOfRow(BufferView * bview, Row * row_ptr) const maxdesc = desc; } -#ifndef NEW_TABULAR - /* table stuff -- begin*/ - if (row_ptr->par()->table){ - // stretch the rows a bit - maxasc += 1; - maxdesc += 1; - } - /* table stuff -- end*/ -#endif - // This is nicer with box insets: ++maxasc; ++maxdesc; @@ -1695,14 +1561,6 @@ void LyXText::SetHeightOfRow(BufferView * bview, Row * row_ptr) const maxasc += int(layoutasc * 2 / (2 + firstpar->GetDepth())); maxdesc += int(layoutdesc * 2 / (2 + firstpar->GetDepth())); -#ifndef NEW_TABULAR - /* table stuff -- begin*/ - if (row_ptr->par()->table){ - maxasc += row_ptr->par()->table-> - AdditionalHeight(NumberOfCell(row_ptr->par(), row_ptr->pos())); - } - /* table stuff -- end*/ -#endif /* calculate the new height of the text */ height -= row_ptr->height(); @@ -1850,16 +1708,7 @@ void LyXText::BreakParagraph(BufferView * bview, char keep_layout) { LyXLayout const & layout = textclasslist.Style(bview->buffer()->params.textclass, cursor.par()->GetLayout()); -#ifndef NEW_TABULAR - /* table stuff -- begin */ - if (cursor.par()->table) { - // breaking of tables is only allowed at the beginning or the end */ - if (cursor.pos() && cursor.pos() < cursor.par()->size() && - !cursor.par()->table->ShouldBeVeryLastCell(NumberOfCell(cursor.par(), cursor.pos()))) - return; // no breaking of tables allowed - } - /* table stuff -- end */ -#endif + // this is only allowed, if the current paragraph is not empty or caption if ((cursor.par()->Last() <= 0 #ifndef NEW_INSETS @@ -1880,15 +1729,6 @@ void LyXText::BreakParagraph(BufferView * bview, char keep_layout) #endif ); -#ifndef NEW_TABULAR - /* table stuff -- begin */ - if (cursor.par()->table) { - int cell = NumberOfCell(cursor.par(), cursor.pos()); - if (cursor.par()->table->ShouldBeVeryLastCell(cell)) - SetCursor(bview, cursor.par(), cursor.par()->size()); - } - /* table stuff -- end */ -#endif // please break always behind a space if (cursor.pos() < cursor.par()->Last() && cursor.par()->IsLineSeparator(cursor.pos())) @@ -1901,17 +1741,7 @@ void LyXText::BreakParagraph(BufferView * bview, char keep_layout) keep_layout = layout.isEnvironment(); cursor.par()->BreakParagraph(bview->buffer()->params, cursor.pos(), keep_layout); -#ifndef NEW_TABULAR - /* table stuff -- begin */ - if (cursor.par()->table){ - // the table should stay with the contents - if (!cursor.pos()){ - cursor.par()->Next()->table = cursor.par()->table; - cursor.par()->table = 0; - } - } - /* table stuff -- end */ -#endif + // well this is the caption hack since one caption is really enough if (layout.labeltype == LABEL_SENSITIVE) { if (!cursor.pos()) @@ -1950,11 +1780,7 @@ void LyXText::BreakParagraph(BufferView * bview, char keep_layout) SetHeightOfRow(bview, cursor.row()); - while ( -#ifndef NEW_TABULAR - !cursor.par()->Next()->table && -#endif - cursor.par()->Next()->Last() + while (cursor.par()->Next()->Last() && cursor.par()->Next()->IsNewline(0)) cursor.par()->Next()->Erase(0); @@ -2034,685 +1860,6 @@ void LyXText::OpenFootnote(BufferView * bview) #endif -#ifndef NEW_TABULAR -/* table stuff -- begin*/ - -void LyXText::TableFeatures(BufferView * bview, int feature, string const & val) const -{ - if (!cursor.par()->table) - return; /* this should never happen */ - - int actCell = NumberOfCell(cursor.par(), cursor.pos()); - SetUndo(bview->buffer(), Undo::FINISH, - cursor.par()->ParFromPos(cursor.pos())->previous, - cursor.par()->ParFromPos(cursor.pos())->next); - - switch (feature){ - case LyXTable::SET_PWIDTH: - cursor.par()->table->SetPWidth(actCell, val); - break; - case LyXTable::SET_SPECIAL_COLUMN: - case LyXTable::SET_SPECIAL_MULTI: - cursor.par()->table->SetAlignSpecial(actCell, val, feature); - break; - default: - break; - } - RedoParagraph(bview); -} - - -void LyXText::TableFeatures(BufferView * bview, int feature) const -{ - int setLines = 0; - int setAlign = LYX_ALIGN_LEFT; - int lineSet; - bool what; - - if (!cursor.par()->table) - return; /* this should never happen */ - - int actCell = NumberOfCell(cursor.par(), cursor.pos()); - SetUndo(bview->buffer(), Undo::FINISH, - cursor.par()->ParFromPos(cursor.pos())->previous, - cursor.par()->ParFromPos(cursor.pos())->next); - - switch (feature){ - case LyXTable::ALIGN_LEFT: - setAlign= LYX_ALIGN_LEFT; - break; - case LyXTable::ALIGN_RIGHT: - setAlign= LYX_ALIGN_RIGHT; - break; - case LyXTable::ALIGN_CENTER: - setAlign= LYX_ALIGN_CENTER; - break; - default: - break; - } - switch (feature){ - case LyXTable::APPEND_ROW: { - LyXParagraph::size_type pos = cursor.pos(); - - /* move to the next row */ - int cell_org = actCell; - int cell = cell_org; - - // if there is a ContRow following this row I have to add - // the row after the ContRow's - if ((pos < cursor.par()->Last()) && - cursor.par()->table->RowHasContRow(cell_org)) { - while((pos < cursor.par()->Last()) && - !cursor.par()->table->IsContRow(cell)) { - while (pos < cursor.par()->Last() && - !cursor.par()->IsNewline(pos)) - ++pos; - if (pos < cursor.par()->Last()) - ++pos; - ++cell; - } - while((pos < cursor.par()->Last()) && - cursor.par()->table->IsContRow(cell)) { - while (pos < cursor.par()->Last() && - !cursor.par()->IsNewline(pos)) - ++pos; - if (pos < cursor.par()->Last()) - ++pos; - ++cell; - } - cell_org = --cell; - if (pos < cursor.par()->Last()) - --pos; - } - while (pos < cursor.par()->Last() && - (cell == cell_org || !cursor.par()->table->IsFirstCell(cell))){ - while (pos < cursor.par()->Last() && !cursor.par()->IsNewline(pos)) - ++pos; - if (pos < cursor.par()->Last()) - ++pos; - ++cell; - } - - /* insert the new cells */ - int number = cursor.par()->table->NumberOfCellsInRow(cell_org); - Language const * lang = cursor.par()->getParLanguage(bview->buffer()->params); - LyXFont font(LyXFont::ALL_INHERIT,lang); - for (int i = 0; i < number; ++i) { - cursor.par()->InsertChar(pos, LyXParagraph::META_NEWLINE, font); - } - - /* append the row into the table */ - cursor.par()->table->AppendRow(cell_org); - RedoParagraph(bview); - return; - } - case LyXTable::APPEND_CONT_ROW: { - LyXParagraph::size_type pos = cursor.pos(); - /* move to the next row */ - int cell_org = actCell; - int cell = cell_org; - - // if there is already a controw but not for this cell - // the AppendContRow sets only the right values but does - // not actually add a row - if (cursor.par()->table->RowHasContRow(cell_org) && - (cursor.par()->table->CellHasContRow(cell_org)<0)) { - cursor.par()->table->AppendContRow(cell_org); - RedoParagraph(bview); - return; - } - while (pos < cursor.par()->Last() && - (cell == cell_org - || !cursor.par()->table->IsFirstCell(cell))){ - while (pos < cursor.par()->Last() && !cursor.par()->IsNewline(pos)) - ++pos; - if (pos < cursor.par()->Last()) - ++pos; - ++cell; - } - - /* insert the new cells */ - int number = cursor.par()->table->NumberOfCellsInRow(cell_org); - Language const * lang = cursor.par()->getParLanguage(bview->buffer()->params); - LyXFont font(LyXFont::ALL_INHERIT,lang); - for (int i = 0; i < number; ++i) { - cursor.par()->InsertChar(pos, LyXParagraph::META_NEWLINE, font); - } - - /* append the row into the table */ - cursor.par()->table->AppendContRow(cell_org); - RedoParagraph(bview); - return; - } - case LyXTable::APPEND_COLUMN: { - LyXParagraph::size_type pos = 0; - int cell_org = actCell; - int cell = 0; - Language const * lang = cursor.par()->getParLanguage(bview->buffer()->params); - LyXFont font(LyXFont::ALL_INHERIT,lang); - do{ - if (pos && (cursor.par()->IsNewline(pos-1))){ - if (cursor.par()->table->AppendCellAfterCell(cell_org, cell)) { - cursor.par()->InsertChar(pos, - LyXParagraph::META_NEWLINE, - font); - if (pos <= cursor.pos()) - cursor.pos(cursor.pos() + 1); - ++pos; - } - ++cell; - } - ++pos; - } while (pos <= cursor.par()->Last()); - /* remember that the very last cell doesn't end with a newline. - This saves one byte memory per table ;-) */ - if (cursor.par()->table->AppendCellAfterCell(cell_org, cell)) { - LyXParagraph::size_type last = cursor.par()->Last(); - cursor.par()->InsertChar(last, - LyXParagraph::META_NEWLINE, font); - } - - /* append the column into the table */ - cursor.par()->table->AppendColumn(cell_org); - - RedoParagraph(bview); - return; - } - case LyXTable::DELETE_ROW: - if (bview->the_locking_inset) - bview->unlockInset(bview->the_locking_inset); - RemoveTableRow(cursor); - RedoParagraph(bview); - return; - - case LyXTable::DELETE_COLUMN: { - LyXParagraph::size_type pos = 0; - int cell_org = actCell; - int cell = 0; - if (bview->the_locking_inset) - bview->unlockInset(bview->the_locking_inset); - do { - if (!pos || (cursor.par()->IsNewline(pos-1))){ - if (cursor.par()->table->DeleteCellIfColumnIsDeleted(cell, cell_org)){ - // delete one cell - while (pos < cursor.par()->Last() && !cursor.par()->IsNewline(pos)) - cursor.par()->Erase(pos); - if (pos < cursor.par()->Last()) - cursor.par()->Erase(pos); - else - cursor.par()->Erase(pos - 1); // the missing newline at the end of a table - --pos; // because of pos++ below - } - ++cell; - } - ++pos; - } while (pos <= cursor.par()->Last()); - - /* delete the column from the table */ - cursor.par()->table->DeleteColumn(cell_org); - - /* set the cursor to the beginning of the table, where else? */ - cursor.pos(0); - RedoParagraph(bview); - return; - } - case LyXTable::TOGGLE_LINE_TOP: - lineSet = !cursor.par()->table->TopLine(actCell); - if (!selection){ - cursor.par()->table->SetTopLine(actCell, lineSet); - } else { - LyXParagraph::size_type i; - int n = -1, m = -2; - for (i = sel_start_cursor.pos(); i <= sel_end_cursor.pos(); ++i){ - if ((n = NumberOfCell(sel_start_cursor.par(), i)) != m) { - cursor.par()->table->SetTopLine(n, lineSet); - m = n; - } - } - } - RedoParagraph(bview); - return; - - case LyXTable::TOGGLE_LINE_BOTTOM: - lineSet = !cursor.par()->table->BottomLine(actCell); - if (!selection){ - cursor.par()->table->SetBottomLine(actCell, lineSet); - } else { - LyXParagraph::size_type i; - int n = -1, m = -2; - for (i = sel_start_cursor.pos(); i <= sel_end_cursor.pos(); ++i) { - if ((n = NumberOfCell(sel_start_cursor.par(), i)) != m) { - cursor.par()->table->SetBottomLine(n, lineSet); - m = n; - } - } - } - RedoParagraph(bview); - return; - - case LyXTable::TOGGLE_LINE_LEFT: - lineSet = !cursor.par()->table->LeftLine(actCell); - if (!selection){ - cursor.par()->table->SetLeftLine(actCell, lineSet); - } else { - LyXParagraph::size_type i; - int n = -1, m = -2; - for (i = sel_start_cursor.pos(); i <= sel_end_cursor.pos(); ++i){ - if ((n= NumberOfCell(sel_start_cursor.par(), i)) != m) { - cursor.par()->table->SetLeftLine(n, lineSet); - m = n; - } - } - } - RedoParagraph(bview); - return; - - case LyXTable::TOGGLE_LINE_RIGHT: - lineSet = !cursor.par()->table->RightLine(actCell); - if (!selection){ - cursor.par()->table->SetRightLine(actCell, lineSet); - } else { - int n = -1, m = -2; - LyXParagraph::size_type i = sel_start_cursor.pos(); - for (; i <= sel_end_cursor.pos(); ++i) { - if ((n= NumberOfCell(sel_start_cursor.par(), i)) != m) { - cursor.par()->table->SetRightLine(n, lineSet); - m = n; - } - } - } - RedoParagraph(bview); - return; - - case LyXTable::ALIGN_LEFT: - case LyXTable::ALIGN_RIGHT: - case LyXTable::ALIGN_CENTER: - if (!selection){ - cursor.par()->table->SetAlignment(actCell, setAlign); - } else { - int n = -1, m = -2; - LyXParagraph::size_type i = sel_start_cursor.pos(); - for (; i <= sel_end_cursor.pos(); ++i) { - if ((n= NumberOfCell(sel_start_cursor.par(), i)) != m) { - cursor.par()->table->SetAlignment(n, setAlign); - m = n; - } - } - } - RedoParagraph(bview); - return; - - case LyXTable::DELETE_TABLE: - SetCursorIntern(bview, cursor.par(), 0); - delete cursor.par()->table; - cursor.par()->table = 0; - // temporary: Should put table in simple_cut_buffer (with before and after - // dummy-paragraph !! - // not necessar anymore with UNDO :) - for (LyXParagraph::size_type i = - cursor.par()->size() - 1; i >= 0; --i) - cursor.par()->Erase(i); - RedoParagraph(bview); - return; - - case LyXTable::MULTICOLUMN: { - int number = 0; - // check wether we are completly in a multicol - int multicol = cursor.par()->table->IsMultiColumn(actCell); - if (multicol && selection && sel_start_cursor.row() == sel_end_cursor.row()) { - multicol = NumberOfCell(sel_start_cursor.par(), sel_start_cursor.pos()) - == NumberOfCell(sel_end_cursor.par(), sel_end_cursor.pos()); - } - - if (multicol){ - int newlines = cursor.par()->table->UnsetMultiColumn(actCell); - LyXParagraph::size_type pos = cursor.pos(); - while (pos < cursor.par()->Last() && !cursor.par()->IsNewline(pos)) - ++pos; - for (; newlines; --newlines) - cursor.par()->InsertChar(pos, LyXParagraph::META_NEWLINE); - RedoParagraph(bview); - return; - } - else { - // selection must be in one row (or no selection) - if (!selection){ - cursor.par()->table->SetMultiColumn(NumberOfCell(cursor.par(), - cursor.pos()), - 1); - RedoParagraph(bview); - return; - } - else { - if (sel_start_cursor.row() == sel_end_cursor.row()){ - LyXParagraph::size_type i; - number = 1; - for (i = sel_start_cursor.pos(); - i < sel_end_cursor.pos(); ++i){ - if (sel_start_cursor.par()->IsNewline(i)){ - sel_start_cursor.par()->Erase(i); - // check for double-blanks - if ((i && !sel_start_cursor.par()->IsLineSeparator(i-1)) - && - (i < sel_start_cursor.par()->Last() - && !sel_start_cursor.par()->IsLineSeparator(i))) - sel_start_cursor.par()->InsertChar(i, ' '); - else { - sel_end_cursor.pos(sel_end_cursor.pos() - 1); - --i; - } - ++number; - } - } - cursor.par()->table-> - SetMultiColumn(NumberOfCell(sel_start_cursor.par(), - sel_start_cursor.pos()), - number); - cursor.pos(sel_start_cursor.pos()); - RedoParagraph(bview); - return; - } - else { - WriteAlert(_("Impossible Operation!"), - _("Multicolumns can only be horizontally."), - _("Sorry.")); - } - } - } - break; - } - case LyXTable::SET_ALL_LINES: - setLines = 1; - case LyXTable::UNSET_ALL_LINES: - if (!selection){ - cursor.par()->table->SetAllLines(NumberOfCell(cursor.par(), - cursor.pos()), - setLines); - } else { - LyXParagraph::size_type i; - int n = -1, m = -2; - for (i = sel_start_cursor.pos(); i <= sel_end_cursor.pos(); ++i) { - if ((n= NumberOfCell(sel_start_cursor.par(), i)) != m) { - cursor.par()->table->SetAllLines(n, setLines); - m = n; - } - } - } - RedoParagraph(bview); - return; - case LyXTable::SET_LONGTABLE: - cursor.par()->table->SetLongTable(true); - return; - case LyXTable::UNSET_LONGTABLE: - cursor.par()->table->SetLongTable(false); - return; - case LyXTable::SET_ROTATE_TABLE: - cursor.par()->table->SetRotateTable(true); - return; - case LyXTable::UNSET_ROTATE_TABLE: - cursor.par()->table->SetRotateTable(false); - return; - case LyXTable::SET_ROTATE_CELL: - if (!selection){ - cursor.par()->table->SetRotateCell(actCell, true); - } else { - LyXParagraph::size_type i; - int n = -1, m = -2; - for (i = sel_start_cursor.pos(); i <= sel_end_cursor.pos(); ++i){ - if ((n = NumberOfCell(sel_start_cursor.par(), i)) != m) { - cursor.par()->table->SetRotateCell(n, true); - m = n; - } - } - } - return; - case LyXTable::UNSET_ROTATE_CELL: - if (!selection){ - cursor.par()->table->SetRotateCell(actCell, false); - } else { - int n = -1, m = -2; - LyXParagraph::size_type i = sel_start_cursor.pos(); - for (; i <= sel_end_cursor.pos(); ++i) { - if ((n= NumberOfCell(sel_start_cursor.par(), i)) != m) { - cursor.par()->table->SetRotateCell(n, false); - m = n; - } - } - } - return; - case LyXTable::SET_LINEBREAKS: - what = !cursor.par()->table->Linebreaks(cursor.par()->table->FirstVirtualCell(actCell)); - if (!selection){ - cursor.par()->table->SetLinebreaks(actCell, what); - } else { - LyXParagraph::size_type i; - int n = -1, m = -2; - for (i = sel_start_cursor.pos(); i <= sel_end_cursor.pos(); ++i) { - if ((n = NumberOfCell(sel_start_cursor.par(), i)) != m) { - cursor.par()->table->SetLinebreaks(n, what); - m = n; - } - } - } - return; - case LyXTable::SET_LTFIRSTHEAD: - cursor.par()->table->SetLTHead(actCell, true); - return; - case LyXTable::SET_LTHEAD: - cursor.par()->table->SetLTHead(actCell, false); - return; - case LyXTable::SET_LTFOOT: - cursor.par()->table->SetLTFoot(actCell, false); - return; - case LyXTable::SET_LTLASTFOOT: - cursor.par()->table->SetLTFoot(actCell, true); - return; - case LyXTable::SET_LTNEWPAGE: - what = !cursor.par()->table->LTNewPage(actCell); - cursor.par()->table->SetLTNewPage(actCell, what); - return; - } -} - - -void LyXText::InsertCharInTable(BufferView * bview, char c) -{ - Row * row = 0; - Row * tmprow = 0; - long y; - bool jumped_over_space; - - /* first check, if there will be two blanks together or a blank at - * the beginning of a paragraph. - * I decided to handle blanks like normal characters, the main - * difference are the special checks when calculating the row.fill - * (blank does not count at the end of a row) and the check here */ - - LyXFont realtmpfont = real_current_font; - LyXFont rawtmpfont = current_font; /* store the current font. - * This is because of the use - * of cursor movements. The moving - * cursor would refresh the - * current font */ - - // Get the font that is used to calculate the baselineskip - LyXParagraph::size_type const lastpos = - cursor.par()->Last(); - LyXFont rawparfont = cursor.par()->GetFontSettings(bview->buffer()->params, - lastpos - 1); - - jumped_over_space = false; - if (IsLineSeparatorChar(c)) { - if ((cursor.pos() > 0 && - cursor.par()->IsLineSeparator(cursor.pos() - 1)) - || (cursor.pos() > 0 && cursor.par()->IsNewline(cursor.pos() - 1)) - || (cursor.pos() == 0 -#ifndef NEW_INSETS - && !(cursor.par()->Previous() - && cursor.par()->Previous()->footnoteflag - == LyXParagraph::OPEN_FOOTNOTE) -#endif - )) - return; - } else if (IsNewlineChar(c)) { - if (!IsEmptyTableCell()) { - TableFeatures(bview, LyXTable::APPEND_CONT_ROW); - CursorDown(bview); - } - return; - } - - row = cursor.row(); - y = cursor.y() - row->baseline(); - if (c != LyXParagraph::META_INSET) /* in this case LyXText::InsertInset - * already inserted the character */ - cursor.par()->InsertChar(cursor.pos(), c); - SetCharFont(bview->buffer(), cursor.par(), cursor.pos(), rawtmpfont); - - if (!jumped_over_space) { - /* refresh the positions */ - tmprow = row; - while (tmprow->next() && tmprow->next()->par() == row->par()) { - tmprow = tmprow->next(); - tmprow->pos(tmprow->pos() + 1); - } - } - - cursor.pos(cursor.pos() + 1); - - CheckParagraphInTable(bview, cursor.par(), cursor.pos()); - - current_font = rawtmpfont; - real_current_font = realtmpfont; - - /* check, whether the last character's font has changed. */ - if (cursor.pos() && cursor.pos() == cursor.par()->Last() - && rawparfont != rawtmpfont) - RedoHeightOfParagraph(bview, cursor); -} - - -void LyXText::CheckParagraphInTable(BufferView * bview, LyXParagraph * par, - LyXParagraph::size_type pos) -{ - - if (par->GetChar(pos) == LyXParagraph::META_INSET && - par->GetInset(pos) && par->GetInset(pos)->display()){ - par->GetInset(pos)->display(false); - } - - long y; - Row * row = GetRow(par, pos, y); - - int tmpheight = row->height(); - SetHeightOfRow(bview, row); - - LyXParagraph::size_type tmp_pos = pos; - /* update the table information */ - while (tmp_pos && !par->IsNewline(tmp_pos - 1)) - --tmp_pos; - if (par->table->SetWidthOfCell(NumberOfCell(par, pos), - WidthOfCell(bview, par, tmp_pos))) { - LyXCursor tmpcursor = cursor; - SetCursorIntern(bview, par, pos, false); - /* make a complete redraw */ - RedoDrawingOfParagraph(bview, cursor); - cursor = tmpcursor; - } - else { - /* redraw only the row */ - LyXCursor tmpcursor = cursor; - SetCursorIntern(bview, par, pos); - //CHECK See comment on top of text.C - refresh_y = y; - refresh_x = cursor.x(); - refresh_row = row; - refresh_pos = cursor.pos(); - cursor = tmpcursor; - - if (tmpheight == row->height()) - status = LyXText::NEED_VERY_LITTLE_REFRESH; - else - status = LyXText::NEED_MORE_REFRESH; - } - SetCursorIntern(bview, cursor.par(), cursor.pos(), false, - cursor.boundary()); -} - - -void LyXText::BackspaceInTable(BufferView * bview) -{ - Row * tmprow, * row; - long y; - - LyXFont rawtmpfont = current_font; - LyXFont realtmpfont = real_current_font; - - // Get the font that is used to calculate the baselineskip - int const lastpos = cursor.par()->Last(); - LyXFont rawparfont = cursor.par()->GetFontSettings(bview->buffer()->params, - lastpos - 1); - - if (cursor.pos() == 0) { - /* no pasting of table paragraphs */ - - CursorLeft(bview); - } else { - /* this is the code for a normal backspace, not pasting - * any paragraphs */ - SetUndo(bview->buffer(), Undo::DELETE, - cursor.par()->ParFromPos(cursor.pos())->previous, - cursor.par()->ParFromPos(cursor.pos())->next); - - CursorLeftIntern(bview); - - /* some insets are undeletable here */ - if (cursor.par()->GetChar(cursor.pos()) == LyXParagraph::META_INSET) { - if (!cursor.par()->GetInset(cursor.pos())->Deletable()) - return; - } - - row = cursor.row(); - y = cursor.y() - row->baseline(); - - /* some special code when deleting a newline. */ - if (cursor.par()->IsNewline(cursor.pos())) { - /* nothing :-) */ - return; - } else { - cursor.par()->Erase(cursor.pos()); - - /* refresh the positions */ - tmprow = row; - while (tmprow->next() - && tmprow->next()->par() == row->par()) { - tmprow = tmprow->next(); - tmprow->pos(tmprow->pos() - 1); - } - } - - CheckParagraphInTable(bview, cursor.par(), cursor.pos()); - - /* check, wether the last characters font has changed. */ - if (cursor.pos() && cursor.pos() == cursor.par()->Last() - && rawparfont != rawtmpfont) - RedoHeightOfParagraph(bview, cursor); - - /* restore the current font - * That is what a user expects! */ - current_font = rawtmpfont; - real_current_font = realtmpfont; - } - SetCursorIntern(bview, cursor.par(), cursor.pos(), true, - cursor.boundary()); - if (IsBoundary(bview->buffer(), cursor.par(), cursor.pos()) != cursor.boundary()) - SetCursor(bview, cursor.par(), cursor.pos(), false, !cursor.boundary()); -} - -/* table stuff -- end*/ -#endif - - // Just a macro to make some thing easier. void LyXText::RedoParagraph(BufferView * bview) const { @@ -2743,15 +1890,6 @@ void LyXText::InsertChar(BufferView * bview, char c) textclasslist.Style(bview->buffer()->params.textclass, cursor.row()->par()->GetLayout()).free_spacing; -#ifndef NEW_TABULAR - /* table stuff -- begin*/ - if (cursor.par()->table) { - InsertCharInTable(bview, c); - charInserted(); - return; - } - /* table stuff -- end*/ -#endif /* First check, if there will be two blanks together or a blank at the beginning of a paragraph. I decided to handle blanks like normal characters, the main @@ -3011,19 +2149,10 @@ void LyXText::PrepareToPrint(BufferView * bview, } // are there any hfills in the row? - float nh = NumberOfHfills(bview->buffer(), row); - -#ifndef NEW_TABULAR -/* table stuff -- begin*/ - if (row->par()->table) { - w = workWidth(bview) - row->par()->table->WidthOfTable() - - x - RightMargin(bview->buffer(), row); - nh = 0; /* ignore hfills in tables */ - } -/* table stuff -- end*/ -#endif + float const nh = NumberOfHfills(bview->buffer(), row); + if (nh) - fill_hfill = w /nh; + fill_hfill = w / nh; else { // is it block, flushleft or flushright? // set x how you need it @@ -3134,17 +2263,6 @@ void LyXText::CursorRightOneWord(BufferView * bview) const void LyXText::CursorTab(BufferView * bview) const { -#ifndef NEW_TABULAR - if (cursor.par()->table) { - int cell = NumberOfCell(cursor.par(), cursor.pos()); - while(cursor.par()->table->IsContRow(cell)) { - CursorUp(bview); - cell = NumberOfCell(cursor.par(), cursor.pos()); - } - if (cursor.par()->table->ShouldBeVeryLastCell(cell)) - TableFeatures(bview, LyXTable::APPEND_ROW); - } -#endif LyXCursor tmpcursor = cursor; while (tmpcursor.pos() < tmpcursor.par()->Last() && !tmpcursor.par()->IsNewline(tmpcursor.pos())) @@ -3158,28 +2276,6 @@ void LyXText::CursorTab(BufferView * bview) const } else tmpcursor.pos(tmpcursor.pos() + 1); SetCursor(bview, tmpcursor.par(), tmpcursor.pos()); -#ifndef NEW_TABULAR - if (cursor.par()->table) { - int cell = NumberOfCell(cursor.par(), cursor.pos()); - while (cursor.par()->table->IsContRow(cell) && - !cursor.par()->table->ShouldBeVeryLastCell(cell)) { - tmpcursor = cursor; - while (tmpcursor.pos() < tmpcursor.par()->Last() - && !tmpcursor.par()->IsNewline(tmpcursor.pos())) - tmpcursor.pos(tmpcursor.pos() + 1); - - if (tmpcursor.pos() == tmpcursor.par()->Last()){ - if (tmpcursor.par()->Next()) { - tmpcursor.par(tmpcursor.par()->Next()); - tmpcursor.pos(0); - } - } else - tmpcursor.pos(tmpcursor.pos() + 1); - SetCursor(bview, tmpcursor.par(), tmpcursor.pos()); - cell = NumberOfCell(cursor.par(), cursor.pos()); - } - } -#endif } @@ -3518,27 +2614,14 @@ void LyXText::Delete(BufferView * bview) void LyXText::Backspace(BufferView * bview) { -#ifndef NEW_TABULAR - /* table stuff -- begin */ - if (cursor.par()->table) { - BackspaceInTable(bview); - return; - } - /* table stuff -- end */ -#endif - // LyXFont rawtmpfont = current_font; - // LyXFont realtmpfont = real_current_font; - // We don't need the above variables as calling to SetCursor() with third - // argument eqaul to false, will not change current_font & real_current_font - // Get the font that is used to calculate the baselineskip LyXParagraph::size_type lastpos = cursor.par()->Last(); LyXFont rawparfont = cursor.par()->GetFontSettings(bview->buffer()->params, lastpos - 1); if (cursor.pos() == 0) { - // The cursor is at the beginning of a paragraph, so the the backspace - // will collapse two paragraphs into one. + // The cursor is at the beginning of a paragraph, + // so the the backspace will collapse two paragraphs into one. // we may paste some paragraphs @@ -3630,11 +2713,6 @@ void LyXText::Backspace(BufferView * bview) || tmppar->GetLayout() == 0 /*standard*/) #ifndef NEW_INSETS && cursor.par()->footnoteflag == tmppar->footnoteflag -#endif -#ifndef NEW_TABULAR - /* table stuff -- begin*/ - && !cursor.par()->table /* no pasting of tables */ - /* table stuff -- end*/ #endif && cursor.par()->GetAlign() == tmppar->GetAlign()) { @@ -3996,87 +3074,52 @@ void LyXText::GetVisibleRow(BufferView * bview, int y_offset, int x_offset, } else if (sel_start_cursor.row() == row_ptr || sel_end_cursor.row() == row_ptr) { float tmpx = x; -#ifndef NEW_TABULAR - int cell = 0; - if (row_ptr->par()->table) { - cell = NumberOfCell(row_ptr->par(), row_ptr->pos()); - tmpx += row_ptr->par()->table->GetBeginningOfTextInCell(cell); - } -#endif if ( (sel_start_cursor.row() != row_ptr && !is_rtl) || (sel_end_cursor.row() != row_ptr && is_rtl)) pain.fillRectangle(x_offset, y_offset, int(tmpx), row_ptr->height(), LColor::selection); -#ifndef NEW_TABULAR - if (row_ptr->par()->table) { - float x_old = x; - for (vpos = row_ptr->pos(); vpos <= last; ++vpos) { - pos = vis2log(vpos); - float old_tmpx = tmpx; - if (row_ptr->par()->IsNewline(pos)) { - tmpx = x_old + row_ptr->par()->table->WidthOfColumn(cell); - x_old = tmpx; - ++cell; - tmpx += row_ptr->par()->table->GetBeginningOfTextInCell(cell); - } else { - tmpx += SingleWidth(bview, row_ptr->par(), pos); - } - if ( (sel_start_cursor.row() != row_ptr || - sel_start_cursor.pos() <= pos) && - (sel_end_cursor.row() != row_ptr || - pos < sel_end_cursor.pos()) ) - pain.fillRectangle(x_offset + int(old_tmpx), - y_offset, - int(tmpx - old_tmpx + 1), - row_ptr->height(), - LColor::selection); + LyXParagraph::size_type main_body = + BeginningOfMainBody(bview->buffer(), + row_ptr->par()); + + for (vpos = row_ptr->pos(); vpos <= last; ++vpos) { + pos = vis2log(vpos); + float old_tmpx = tmpx; + if (main_body > 0 && pos == main_body-1) { + tmpx += fill_label_hfill + + lyxfont::width(textclasslist.Style(bview->buffer()->params.textclass, + row_ptr->par()->GetLayout()).labelsep, + GetFont(bview->buffer(),row_ptr->par(), -2)); + if (row_ptr->par()->IsLineSeparator(main_body-1)) + tmpx -= SingleWidth(bview, row_ptr->par(), main_body-1); } - } else { -#endif - LyXParagraph::size_type main_body = - BeginningOfMainBody(bview->buffer(), - row_ptr->par()); - - for (vpos = row_ptr->pos(); vpos <= last; ++vpos) { - pos = vis2log(vpos); - float old_tmpx = tmpx; - if (main_body > 0 && pos == main_body-1) { - tmpx += fill_label_hfill + - lyxfont::width(textclasslist.Style(bview->buffer()->params.textclass, - row_ptr->par()->GetLayout()).labelsep, - GetFont(bview->buffer(),row_ptr->par(), -2)); - if (row_ptr->par()->IsLineSeparator(main_body-1)) - tmpx -= SingleWidth(bview, row_ptr->par(), main_body-1); - } - if (HfillExpansion(bview->buffer(), row_ptr, pos)) { - tmpx += SingleWidth(bview, row_ptr->par(), pos); - if (pos >= main_body) - tmpx += fill_hfill; - else - tmpx += fill_label_hfill; - } - else if (row_ptr->par()->IsSeparator(pos)) { - tmpx += SingleWidth(bview, row_ptr->par(), pos); - if (pos >= main_body) - tmpx += fill_separator; - } else - tmpx += SingleWidth(bview, row_ptr->par(), pos); - - if ( (sel_start_cursor.row() != row_ptr || - sel_start_cursor.pos() <= pos) && - (sel_end_cursor.row() != row_ptr || - pos < sel_end_cursor.pos()) ) - pain.fillRectangle(x_offset + int(old_tmpx), - y_offset, - int(tmpx - old_tmpx + 1), - row_ptr->height(), - LColor::selection); + if (HfillExpansion(bview->buffer(), row_ptr, pos)) { + tmpx += SingleWidth(bview, row_ptr->par(), pos); + if (pos >= main_body) + tmpx += fill_hfill; + else + tmpx += fill_label_hfill; } -#ifndef NEW_TABULAR + else if (row_ptr->par()->IsSeparator(pos)) { + tmpx += SingleWidth(bview, row_ptr->par(), pos); + if (pos >= main_body) + tmpx += fill_separator; + } else + tmpx += SingleWidth(bview, row_ptr->par(), pos); + + if ( (sel_start_cursor.row() != row_ptr || + sel_start_cursor.pos() <= pos) && + (sel_end_cursor.row() != row_ptr || + pos < sel_end_cursor.pos()) ) + pain.fillRectangle(x_offset + int(old_tmpx), + y_offset, + int(tmpx - old_tmpx + 1), + row_ptr->height(), + LColor::selection); } -#endif + if ( (sel_start_cursor.row() != row_ptr && is_rtl) || (sel_end_cursor.row() != row_ptr && !is_rtl) ) pain.fillRectangle(x_offset + int(tmpx), @@ -4604,201 +3647,71 @@ void LyXText::GetVisibleRow(BufferView * bview, int y_offset, int x_offset, /* draw the text in the pixmap */ vpos = row_ptr->pos(); -#ifndef NEW_TABULAR - /* table stuff -- begin*/ - if (row_ptr->par()->table) { - bool on_off; - int cell = NumberOfCell(row_ptr->par(), row_ptr->pos()); - float x_old = x; - x += row_ptr->par()->table->GetBeginningOfTextInCell(cell); - - while (vpos <= last) { - pos = vis2log(vpos); - if (row_ptr->par()->IsNewline(pos)) { - - x = x_old + row_ptr->par()->table->WidthOfColumn(cell); - /* draw the table lines, still very simple */ - on_off = !row_ptr->par()->table->TopLine(cell); - if ((!on_off || - !row_ptr->par()->table->TopAlreadyDrawed(cell)) && - !row_ptr->par()->table->IsContRow(cell)) - pain.line(int(x_old), - y_offset + row_ptr->baseline() - row_ptr->ascent_of_text(), - int(x), - y_offset + row_ptr->baseline() - row_ptr->ascent_of_text(), - LColor::tableline, - on_off ? Painter::line_onoffdash : Painter::line_solid); - - on_off = !row_ptr->par()->table->BottomLine(cell); - if ((!on_off && !row_ptr->par()->table->RowHasContRow(cell)) || - row_ptr->par()->table->VeryLastRow(cell)) + + LyXParagraph::size_type main_body = + BeginningOfMainBody(bview->buffer(), row_ptr->par()); + if (main_body > 0 && + (main_body-1 > last || + !row_ptr->par()->IsLineSeparator(main_body - 1))) + main_body = 0; + + while (vpos <= last) { + pos = vis2log(vpos); + if (main_body > 0 && pos == main_body - 1) { + x += fill_label_hfill + + lyxfont::width(layout.labelsep, + GetFont(bview->buffer(), + row_ptr->par(), -2)) + - SingleWidth(bview, + row_ptr->par(), + main_body - 1); + } + + if (row_ptr->par() ->IsHfill(pos)) { + x += 1; + pain.line(int(x), + y_offset + row_ptr->baseline() - DefaultHeight() / 2, + int(x), + y_offset + row_ptr->baseline(), + LColor::vfillline); + + if (HfillExpansion(bview->buffer(), + row_ptr, pos)) { + if (pos >= main_body) { + pain.line(int(x), + y_offset + row_ptr->baseline() - DefaultHeight() / 4, + int(x + fill_hfill), + y_offset + row_ptr->baseline() - DefaultHeight() / 4, + LColor::vfillline, + Painter::line_onoffdash); + x += fill_hfill; + } else { + pain.line(int(x), + y_offset + row_ptr->baseline() - DefaultHeight() / 4, + int(x + fill_label_hfill), + y_offset + row_ptr->baseline() - DefaultHeight() / 4, + LColor::vfillline, + Painter::line_onoffdash); - pain.line(int(x_old), - y_offset + y_bottom - 1, - int(x), - y_offset + y_bottom - 1, - LColor::tableline, - on_off ? Painter::line_onoffdash : Painter::line_solid); - - on_off = !row_ptr->par()->table->LeftLine(cell); - - pain.line(int(x_old), - y_offset + row_ptr->baseline() - row_ptr->ascent_of_text(), - int(x_old), - y_offset + y_bottom - 1, - LColor::tableline, - on_off ? Painter::line_onoffdash : Painter::line_solid); - - on_off = !row_ptr->par()->table->RightLine(cell); - - pain.line(int(x) - row_ptr->par()->table->AdditionalWidth(cell), - y_offset + row_ptr->baseline() - row_ptr->ascent_of_text(), - int(x) - row_ptr->par()->table->AdditionalWidth(cell), - y_offset + y_bottom - 1, - LColor::tableline, - on_off ? Painter::line_onoffdash : Painter::line_solid); - - x_old = x; - /* take care about the alignment and other spaces */ - ++cell; - x += row_ptr->par()->table->GetBeginningOfTextInCell(cell); - if (row_ptr->par()->table->IsFirstCell(cell)) - --cell; // little hack, sorry - ++vpos; - } else if (row_ptr->par()->IsHfill(pos)) { - x += 1; - + x += fill_label_hfill; + } pain.line(int(x), y_offset + row_ptr->baseline() - DefaultHeight() / 2, int(x), y_offset + row_ptr->baseline(), LColor::vfillline); - - x += 2; - ++vpos; - } else if (row_ptr->par()->IsSeparator(pos)) { - tmpx = x; - x+= SingleWidth(bview, - row_ptr->par(), pos); - ++vpos; - } else - draw(bview, row_ptr, vpos, y_offset, x, clear_area); - } - - /* do not forget the very last cell. This has no NEWLINE so - * ignored by the code above*/ - if (cell == row_ptr->par()->table->GetNumberOfCells() - 1) { - x = x_old + row_ptr->par()->table->WidthOfColumn(cell); - on_off = !row_ptr->par()->table->TopLine(cell); - if ((!on_off || - !row_ptr->par()->table->TopAlreadyDrawed(cell)) && - !row_ptr->par()->table->IsContRow(cell)) - - pain.line(int(x_old), - y_offset + row_ptr->baseline() - row_ptr->ascent_of_text(), - int(x), - y_offset + row_ptr->baseline() - row_ptr->ascent_of_text(), - LColor::tableline, - on_off ? Painter::line_onoffdash : Painter::line_solid); - on_off = !row_ptr->par()->table->BottomLine(cell); - if ((!on_off && !row_ptr->par()->table->RowHasContRow(cell)) || - row_ptr->par()->table->VeryLastRow(cell)) - - pain.line(int(x_old), - y_offset + y_bottom - 1, - int(x), - y_offset + y_bottom - 1, - LColor::tableline, - on_off ? Painter::line_onoffdash : Painter::line_solid); - - on_off = !row_ptr->par()->table->LeftLine(cell); - - pain.line(int(x_old), - y_offset + row_ptr->baseline() - row_ptr->ascent_of_text(), - int(x_old), - y_offset + y_bottom - 1, - LColor::tableline, - on_off ? Painter::line_onoffdash : Painter::line_solid); - - on_off = !row_ptr->par()->table->RightLine(cell); - - pain.line(int(x) - row_ptr->par()->table->AdditionalWidth(cell), - y_offset + row_ptr->baseline() - row_ptr->ascent_of_text(), - int(x) - row_ptr->par()->table->AdditionalWidth(cell), - y_offset + y_bottom - 1, - LColor::tableline, - on_off ? Painter::line_onoffdash : Painter::line_solid); - } - } else { - /* table stuff -- end*/ -#endif - LyXParagraph::size_type main_body = - BeginningOfMainBody(bview->buffer(), row_ptr->par()); - if (main_body > 0 && - (main_body-1 > last || - !row_ptr->par()->IsLineSeparator(main_body - 1))) - main_body = 0; - - while (vpos <= last) { - pos = vis2log(vpos); - if (main_body > 0 && pos == main_body - 1) { - x += fill_label_hfill - + lyxfont::width(layout.labelsep, - GetFont(bview->buffer(), - row_ptr->par(), -2)) - - SingleWidth(bview, - row_ptr->par(), - main_body - 1); } - - if (row_ptr->par() ->IsHfill(pos)) { - x += 1; - pain.line(int(x), - y_offset + row_ptr->baseline() - DefaultHeight() / 2, - int(x), - y_offset + row_ptr->baseline(), - LColor::vfillline); - - if (HfillExpansion(bview->buffer(), - row_ptr, pos)) { - if (pos >= main_body) { - pain.line(int(x), - y_offset + row_ptr->baseline() - DefaultHeight() / 4, - int(x + fill_hfill), - y_offset + row_ptr->baseline() - DefaultHeight() / 4, - LColor::vfillline, - Painter::line_onoffdash); - x += fill_hfill; - } else { - pain.line(int(x), - y_offset + row_ptr->baseline() - DefaultHeight() / 4, - int(x + fill_label_hfill), - y_offset + row_ptr->baseline() - DefaultHeight() / 4, - LColor::vfillline, - Painter::line_onoffdash); - - x += fill_label_hfill; - } - pain.line(int(x), - y_offset + row_ptr->baseline() - DefaultHeight() / 2, - int(x), - y_offset + row_ptr->baseline(), - LColor::vfillline); - } - x += 2; - ++vpos; - } else if (row_ptr->par()->IsSeparator(pos)) { - x += SingleWidth(bview, - row_ptr->par(), pos); - if (pos >= main_body) - x += fill_separator; - ++vpos; - } else - draw(bview, row_ptr, vpos, y_offset, x, clear_area); - } -#ifndef NEW_TABULAR + x += 2; + ++vpos; + } else if (row_ptr->par()->IsSeparator(pos)) { + x += SingleWidth(bview, + row_ptr->par(), pos); + if (pos >= main_body) + x += fill_separator; + ++vpos; + } else + draw(bview, row_ptr, vpos, y_offset, x, clear_area); } -#endif } @@ -4828,84 +3741,46 @@ int LyXText::GetColumnNearX(BufferView * bview, Row * row, int & x, row->par()->GetLayout()); bool left_side = false; -#ifndef NEW_TABULAR - /* table stuff -- begin */ - if (row->par()->table) { - //the last row doesn't need a newline at the end - if (row->next() && row->next()->par() == row->par() - && row->par()->IsNewline(last)) - --last; - int cell = NumberOfCell(row->par(), row->pos()); - float cell_x = tmpx + row->par()->table->WidthOfColumn(cell); - tmpx += row->par()->table->GetBeginningOfTextInCell(cell); - float last_tmpx = tmpx; - while (vc <= last && tmpx <= x) { - c = vis2log(vc); - last_tmpx = tmpx; - if (row->par()->IsNewline(c)) { - if (cell_x <= x){ - ++cell; - tmpx = cell_x + row->par()->table->GetBeginningOfTextInCell(cell); - cell_x += row->par()->table->WidthOfColumn(cell); - ++vc; - } else - break; - } else { - tmpx += SingleWidth(bview, row->par(), c); - ++vc; - } - } - if (vc > row->pos() && !row->par()->IsNewline(c) && - (tmpx + last_tmpx) / 2 > x) { - tmpx = last_tmpx; - left_side = true; - } - } else { - /* table stuff -- end*/ -#endif - LyXParagraph::size_type - main_body = BeginningOfMainBody(bview->buffer(), row->par()); - float last_tmpx = tmpx; - - if (main_body > 0 && - (main_body-1 > last || - !row->par()->IsLineSeparator(main_body - 1))) - main_body = 0; - - while (vc <= last && tmpx <= x) { - c = vis2log(vc); - last_tmpx = tmpx; - if (main_body > 0 && c == main_body-1) { - tmpx += fill_label_hfill + - lyxfont::width(layout.labelsep, + LyXParagraph::size_type + main_body = BeginningOfMainBody(bview->buffer(), row->par()); + float last_tmpx = tmpx; + + if (main_body > 0 && + (main_body-1 > last || + !row->par()->IsLineSeparator(main_body - 1))) + main_body = 0; + + while (vc <= last && tmpx <= x) { + c = vis2log(vc); + last_tmpx = tmpx; + if (main_body > 0 && c == main_body-1) { + tmpx += fill_label_hfill + + lyxfont::width(layout.labelsep, GetFont(bview->buffer(), row->par(), -2)); - if (row->par()->IsLineSeparator(main_body - 1)) - tmpx -= SingleWidth(bview, row->par(), main_body-1); - } - - if (HfillExpansion(bview->buffer(), row, c)) { - x += SingleWidth(bview, row->par(), c); - if (c >= main_body) - tmpx += fill_hfill; - else - tmpx += fill_label_hfill; - } - else if (row->par()->IsSeparator(c)) { - tmpx += SingleWidth(bview, row->par(), c); - if (c >= main_body) - tmpx+= fill_separator; - } else - tmpx += SingleWidth(bview, row->par(), c); - ++vc; + if (row->par()->IsLineSeparator(main_body - 1)) + tmpx -= SingleWidth(bview, row->par(), main_body-1); } - - if (vc > row->pos() && (tmpx + last_tmpx) / 2 > x) { - tmpx = last_tmpx; - left_side = true; + + if (HfillExpansion(bview->buffer(), row, c)) { + x += SingleWidth(bview, row->par(), c); + if (c >= main_body) + tmpx += fill_hfill; + else + tmpx += fill_label_hfill; } -#ifndef NEW_TABULAR + else if (row->par()->IsSeparator(c)) { + tmpx += SingleWidth(bview, row->par(), c); + if (c >= main_body) + tmpx+= fill_separator; + } else + tmpx += SingleWidth(bview, row->par(), c); + ++vc; + } + + if (vc > row->pos() && (tmpx + last_tmpx) / 2 > x) { + tmpx = last_tmpx; + left_side = true; } -#endif if (vc > last + 1) // This shouldn't happen. vc = last + 1; @@ -4927,12 +3802,7 @@ int LyXText::GetColumnNearX(BufferView * bview, Row * row, int & x, (!rtl && vc == last + 1 && x > tmpx + 5) )) c = last + 1; #endif - else if (vc == row->pos() -#ifndef NEW_TABULAR - || (row->par()->table - && vc <= last && row->par()->IsNewline(vc-1)) -#endif - ) { + else if (vc == row->pos()) { c = vis2log(vc); if (bidi_level(c) % 2 == 1) ++c; @@ -4945,12 +3815,8 @@ int LyXText::GetColumnNearX(BufferView * bview, Row * row, int & x, } } - if ( -#ifndef NEW_TABULAR - !row->par()->table && -#endif - row->pos() <= last && c > last - && row->par()->IsNewline(last)) { + if (row->pos() <= last && c > last + && row->par()->IsNewline(last)) { if (bidi_level(last) % 2 == 0) tmpx -= SingleWidth(bview, row->par(), last); else @@ -4996,12 +3862,6 @@ void LyXText::InsertFootnoteEnvironment(BufferView * bview, LyXParagraph * tmppar; -#ifndef NEW_TABULAR - if (sel_start_cursor.par()->table || sel_end_cursor.par()->table){ - WriteAlert(_("Impossible operation"), _("Cannot cut table."), _("Sorry.")); - return; - } -#endif /* a test to make sure there is not already a footnote * in the selection. */ diff --git a/src/text2.C b/src/text2.C index ca3c854da9..d20c3ecc1c 100644 --- a/src/text2.C +++ b/src/text2.C @@ -1225,24 +1225,6 @@ void LyXText::CursorEnd(BufferView * bview) const else SetCursor(bview,cursor.par(), RowLast(cursor.row()) + 1); } -#ifndef NEW_TABULAR - if (cursor.par()->table) { - int cell = NumberOfCell(cursor.par(), cursor.pos()); - if (cursor.par()->table->RowHasContRow(cell) && - cursor.par()->table->CellHasContRow(cell)<0) { - if (!cursor.row()->next() || cursor.row()->next()->par() != cursor.row()->par()) - SetCursor(bview, cursor.par(), RowLast(cursor.row()) + 1); - else { - if (cursor.par()->Last() && - (cursor.par()->GetChar(RowLast(cursor.row())) == ' ' - || cursor.par()->IsNewline(RowLast(cursor.row())))) - SetCursor(bview, cursor.par(), RowLast(cursor.row())); - else - SetCursor(bview, cursor.par(), RowLast(cursor.row()) + 1); - } - } - } -#endif } @@ -1379,11 +1361,7 @@ void LyXText::MeltFootnoteEnvironment(BufferView * bview) tmppar->next->MakeSameLayout(cursor.par()); // first the end - if ((!tmppar->GetLayout() -#ifndef NEW_TABULAR - && !tmppar->table -#endif - ) + if (!tmppar->GetLayout() || (tmppar->Next() && (!tmppar->Next()->Last() || tmppar->Next()->HasSameLayout(tmppar)))) { @@ -1400,11 +1378,7 @@ void LyXText::MeltFootnoteEnvironment(BufferView * bview) /* if there is no space between the text and the footnote, so we insert * a blank * (only if the previous par and the footnotepar are not empty!) */ - if ((!firsttmppar->next->GetLayout() -#ifndef NEW_TABULAR - && !firsttmppar->next->table -#endif - ) + if (!firsttmppar->next->GetLayout() || firsttmppar->HasSameLayout(firsttmppar->next)) { if (firsttmppar->size() && !firsttmppar->IsSeparator(firsttmppar->size() - 1) @@ -2213,19 +2187,7 @@ void LyXText::CutSelection(BufferView * bview, bool doclear) } } #endif -#ifndef NEW_TABULAR - /* table stuff -- begin */ - if (sel_start_cursor.par()->table || sel_end_cursor.par()->table) { - if ( sel_start_cursor.par() != sel_end_cursor.par()) { - WriteAlert(_("Impossible operation"), - _("Don't know what to do with half tables."), - _("sorry.")); - return; - } - sel_start_cursor.par()->table->Reinit(); - } - /* table stuff -- end */ -#endif + // make sure that the depth behind the selection are restored, too #ifndef NEW_INSETS LyXParagraph * endpar = sel_end_cursor.par()->LastPhysicalPar()->Next(); @@ -2339,18 +2301,6 @@ void LyXText::CopySelection(BufferView * bview) } } #endif -#ifndef NEW_TABULAR - /* table stuff -- begin */ - if (sel_start_cursor.par()->table || sel_end_cursor.par()->table){ - if ( sel_start_cursor.par() != sel_end_cursor.par()){ - WriteAlert(_("Impossible operation"), - _("Don't know what to do with half tables."), - _("sorry.")); - return; - } - } - /* table stuff -- end */ -#endif // copy behind a space if there is one while (sel_start_cursor.par()->Last() > sel_start_cursor.pos() @@ -2543,23 +2493,6 @@ void LyXText::InsertStringA(BufferView * bview, string const & str) && pos && par->GetChar(pos - 1)!= ' ') { par->InsertChar(pos, ' ', current_font); ++pos; -#ifndef NEW_TABULAR - } else if (par->table) { - if (str[i] == '\t') { - while((pos < par->size()) && - (par->GetChar(pos) != LyXParagraph::META_NEWLINE)) - ++pos; - if (pos < par->size()) - ++pos; - else // no more fields to fill skip the rest - break; - } else if ((str[i] != 13) && - ((str[i] & 127) >= ' ')) { - par->InsertChar(pos, str[i], - current_font); - ++pos; - } -#endif } else if (str[i] == ' ') { InsetSpecialChar * new_inset = new InsetSpecialChar(InsetSpecialChar::PROTECTED_SEPARATOR); @@ -2589,50 +2522,21 @@ void LyXText::InsertStringA(BufferView * bview, string const & str) ++pos; } } else { -#ifndef NEW_TABULAR - if (par->table) { - if ((i + 1) >= str.length()) { - if (pos < par->size()) - ++pos; - break; - } - while((pos < par->size()) && - (par->GetChar(pos) != LyXParagraph::META_NEWLINE)) - ++pos; - ++pos; - int cell = NumberOfCell(par, pos); - while((pos < par->size()) && - !(par->table->IsFirstCell(cell))) { - - while((pos < par->size()) && - (par->GetChar(pos) != LyXParagraph::META_NEWLINE)) - ++pos; - ++pos; - cell = NumberOfCell(par, pos); - } - if (pos >= par->size()) - // no more fields to fill skip the rest - break; - } else { -#endif - if (!par->size()) { // par is empty - InsetSpecialChar * new_inset = - new InsetSpecialChar(InsetSpecialChar::PROTECTED_SEPARATOR); - if (par->InsertInsetAllowed(new_inset)) { - par->InsertInset(pos, - new_inset, - current_font); - } else { - delete new_inset; - } - ++pos; - } - par->BreakParagraph(bview->buffer()->params, pos, flag); - par = par->Next(); - pos = 0; -#ifndef NEW_TABULAR - } -#endif + if (!par->size()) { // par is empty + InsetSpecialChar * new_inset = + new InsetSpecialChar(InsetSpecialChar::PROTECTED_SEPARATOR); + if (par->InsertInsetAllowed(new_inset)) { + par->InsertInset(pos, + new_inset, + current_font); + } else { + delete new_inset; + } + ++pos; + } + par->BreakParagraph(bview->buffer()->params, pos, flag); + par = par->Next(); + pos = 0; } ++i; } @@ -2652,24 +2556,13 @@ void LyXText::InsertStringA(BufferView * bview, string const & str) void LyXText::InsertStringB(BufferView * bview, string const & s) { string str(s); -#ifndef NEW_TABULAR - LyXParagraph * par = cursor.par(); -#endif string::size_type i = 1; while (i < str.length()) { - if (str[i] == '\t' -#ifndef NEW_TABULAR - && !par->table -#endif - ) + if (str[i] == '\t') str[i] = ' '; if (str[i] == ' ' && i + 1 < str.length() && str[i + 1] == ' ') str[i] = 13; - if (str[i] == '\n' && i + 1 < str.length() -#ifndef NEW_TABULAR - && !par->table -#endif - ){ + if (str[i] == '\n' && i + 1 < str.length()) { if (str[i + 1] != '\n') { if (str[i - 1] != ' ') str[i] = ' '; @@ -2742,66 +2635,53 @@ void LyXText::CheckParagraph(BufferView * bview, LyXParagraph * par, { LyXCursor tmpcursor; -#ifndef NEW_TABULAR - /* table stuff -- begin*/ - - if (par->table) { - CheckParagraphInTable(bview, par, pos); - } - else { -#endif - /* table stuff -- end*/ - - long y = 0; - LyXParagraph::size_type z; - Row * row = GetRow(par, pos, y); - - // is there a break one row above - if (row->previous() && row->previous()->par() == row->par()) { - z = NextBreakPoint(bview, row->previous(), workWidth(bview)); - if ( z >= row->pos()) { - // set the dimensions of the row above - y -= row->previous()->height(); - refresh_y = y; - refresh_row = row->previous(); - status = LyXText::NEED_MORE_REFRESH; - - BreakAgain(bview, row->previous()); - - // set the cursor again. Otherwise - // dangling pointers are possible - SetCursor(bview, cursor.par(), cursor.pos()); - sel_cursor = cursor; - return; - } + long y = 0; + LyXParagraph::size_type z; + Row * row = GetRow(par, pos, y); + + // is there a break one row above + if (row->previous() && row->previous()->par() == row->par()) { + z = NextBreakPoint(bview, row->previous(), workWidth(bview)); + if ( z >= row->pos()) { + // set the dimensions of the row above + y -= row->previous()->height(); + refresh_y = y; + refresh_row = row->previous(); + status = LyXText::NEED_MORE_REFRESH; + + BreakAgain(bview, row->previous()); + + // set the cursor again. Otherwise + // dangling pointers are possible + SetCursor(bview, cursor.par(), cursor.pos()); + sel_cursor = cursor; + return; } + } - int tmpheight = row->height(); - LyXParagraph::size_type tmplast = RowLast(row); - refresh_y = y; - refresh_row = row; - - BreakAgain(bview, row); - if (row->height() == tmpheight && RowLast(row) == tmplast) - status = LyXText::NEED_VERY_LITTLE_REFRESH; - else - status = LyXText::NEED_MORE_REFRESH; - - // check the special right address boxes - if (textclasslist.Style(bview->buffer()->params.textclass, - par->GetLayout()).margintype - == MARGIN_RIGHT_ADDRESS_BOX) { - tmpcursor.par(par); - tmpcursor.row(row); - tmpcursor.y(y); - tmpcursor.x(0); - tmpcursor.x_fix(0); - tmpcursor.pos(pos); - RedoDrawingOfParagraph(bview, tmpcursor); - } -#ifndef NEW_TABULAR + int const tmpheight = row->height(); + LyXParagraph::size_type const tmplast = RowLast(row); + refresh_y = y; + refresh_row = row; + + BreakAgain(bview, row); + if (row->height() == tmpheight && RowLast(row) == tmplast) + status = LyXText::NEED_VERY_LITTLE_REFRESH; + else + status = LyXText::NEED_MORE_REFRESH; + + // check the special right address boxes + if (textclasslist.Style(bview->buffer()->params.textclass, + par->GetLayout()).margintype + == MARGIN_RIGHT_ADDRESS_BOX) { + tmpcursor.par(par); + tmpcursor.row(row); + tmpcursor.y(y); + tmpcursor.x(0); + tmpcursor.x_fix(0); + tmpcursor.pos(pos); + RedoDrawingOfParagraph(bview, tmpcursor); } -#endif // set the cursor again. Otherwise dangling pointers are possible // also set the selection @@ -2929,11 +2809,7 @@ void LyXText::SetCursor(BufferView *bview, LyXCursor & cur, LyXParagraph * par, cursor_vpos = (row->par()->isRightToLeftPar(bview->buffer()->params)) ? row->pos() : last + 1; else if (pos > row->pos() && - (pos > last || boundary -#ifndef NEW_TABULAR - || (row->par()->table && row->par()->IsNewline(pos)) -#endif - )) + (pos > last || boundary)) /// Place cursor after char at (logical) position pos - 1 cursor_vpos = (bidi_level(pos - 1) % 2 == 0) ? log2vis(pos - 1) + 1 : log2vis(pos - 1); @@ -2941,65 +2817,41 @@ void LyXText::SetCursor(BufferView *bview, LyXCursor & cur, LyXParagraph * par, /// Place cursor before char at (logical) position pos cursor_vpos = (bidi_level(pos) % 2 == 0) ? log2vis(pos) : log2vis(pos) + 1; - -#ifndef NEW_TABULAR - /* table stuff -- begin*/ - if (row->par()->table) { - int cell = NumberOfCell(row->par(), row->pos()); - float x_old = x; - x += row->par()->table->GetBeginningOfTextInCell(cell); - for (LyXParagraph::size_type vpos = row->pos(); - vpos < cursor_vpos; ++vpos) { - pos = vis2log(vpos); - if (row->par()->IsNewline(pos)) { - x = x_old + row->par()->table->WidthOfColumn(cell); - x_old = x; - ++cell; - x += row->par()->table->GetBeginningOfTextInCell(cell); - } else { - x += SingleWidth(bview, row->par(), pos); - } - } - } else { - /* table stuff -- end*/ -#endif - LyXParagraph::size_type main_body = - BeginningOfMainBody(bview->buffer(), row->par()); - if ((main_body > 0) && - ((main_body-1 > last) || - !row->par()->IsLineSeparator(main_body-1))) - main_body = 0; - - for (LyXParagraph::size_type vpos = row->pos(); - vpos < cursor_vpos; ++vpos) { - pos = vis2log(vpos); - if (main_body > 0 && pos == main_body-1) { - x += fill_label_hfill + - lyxfont::width(textclasslist.Style( - bview->buffer()->params.textclass, - row->par()->GetLayout()) - .labelsep, - GetFont(bview->buffer(), row->par(), -2)); - if (row->par()->IsLineSeparator(main_body-1)) - x -= SingleWidth(bview, row->par(),main_body-1); - } - if (HfillExpansion(bview->buffer(), row, pos)) { - x += SingleWidth(bview, row->par(), pos); - if (pos >= main_body) - x += fill_hfill; - else - x += fill_label_hfill; - } else if (row->par()->IsSeparator(pos)) { - x += SingleWidth(bview, row->par(), pos); - if (pos >= main_body) - x += fill_separator; - } else - x += SingleWidth(bview, row->par(), pos); - } -#ifndef NEW_TABULAR + + LyXParagraph::size_type main_body = + BeginningOfMainBody(bview->buffer(), row->par()); + if ((main_body > 0) && + ((main_body-1 > last) || + !row->par()->IsLineSeparator(main_body-1))) + main_body = 0; + + for (LyXParagraph::size_type vpos = row->pos(); + vpos < cursor_vpos; ++vpos) { + pos = vis2log(vpos); + if (main_body > 0 && pos == main_body - 1) { + x += fill_label_hfill + + lyxfont::width(textclasslist.Style( + bview->buffer()->params.textclass, + row->par()->GetLayout()) + .labelsep, + GetFont(bview->buffer(), row->par(), -2)); + if (row->par()->IsLineSeparator(main_body-1)) + x -= SingleWidth(bview, row->par(),main_body-1); + } + if (HfillExpansion(bview->buffer(), row, pos)) { + x += SingleWidth(bview, row->par(), pos); + if (pos >= main_body) + x += fill_hfill; + else + x += fill_label_hfill; + } else if (row->par()->IsSeparator(pos)) { + x += SingleWidth(bview, row->par(), pos); + if (pos >= main_body) + x += fill_separator; + } else + x += SingleWidth(bview, row->par(), pos); } -#endif - + cur.x(int(x)); cur.x_fix(cur.x()); cur.row(row); @@ -3015,6 +2867,7 @@ void LyXText::SetCursorIntern(BufferView * bview, LyXParagraph * par, SetCurrentFont(bview); } + void LyXText::SetCurrentFont(BufferView * bview) const { LyXParagraph::size_type pos = cursor.pos(); @@ -3022,11 +2875,7 @@ void LyXText::SetCurrentFont(BufferView * bview) const --pos; if (pos > 0) { - if (pos == cursor.par()->Last() -#ifndef NEW_TABULAR - || (cursor.par()->table && cursor.par()->IsNewline(pos)) -#endif - ) + if (pos == cursor.par()->Last()) --pos; else if (cursor.par()->IsSeparator(pos)) { if (pos > cursor.row()->pos() && @@ -3095,15 +2944,6 @@ void LyXText::SetCursorFromCoordinates(BufferView * bview, LyXCursor & cur, void LyXText::CursorLeft(BufferView * bview, bool internal) const { CursorLeftIntern(bview, internal); -#ifndef NEW_TABULAR - if (cursor.par()->table) { - int cell = NumberOfCell(cursor.par(), cursor.pos()); - if (cursor.par()->table->IsContRow(cell) - && cursor.par()->table->CellHasContRow(cursor.par()->table->GetCellAbove(cell)) < 0) { - CursorUp(bview); - } - } -#endif } @@ -3125,26 +2965,13 @@ void LyXText::CursorLeftIntern(BufferView * bview, bool internal) const void LyXText::CursorRight(BufferView * bview, bool internal) const { CursorRightIntern(bview, internal); -#ifndef NEW_TABULAR - if (cursor.par()->table) { - int cell = NumberOfCell(cursor.par(), cursor.pos()); - if (cursor.par()->table->IsContRow(cell) && - cursor.par()->table->CellHasContRow(cursor.par()->table->GetCellAbove(cell))<0) { - CursorUp(bview); - } - } -#endif } void LyXText::CursorRightIntern(BufferView * bview, bool internal) const { if (!internal && cursor.boundary() && - ( -#ifndef NEW_TABULAR - !cursor.par()->table || -#endif - !cursor.par()->IsNewline(cursor.pos()))) + !cursor.par()->IsNewline(cursor.pos())) SetCursor(bview, cursor.par(), cursor.pos(), true, false); else if (cursor.pos() < cursor.par()->Last()) { SetCursor(bview, cursor.par(), cursor.pos() + 1, true, false); @@ -3160,47 +2987,14 @@ void LyXText::CursorUp(BufferView * bview) const { SetCursorFromCoordinates(bview, cursor.x_fix(), cursor.y() - cursor.row()->baseline() - 1); -#ifndef NEW_TABULAR - if (cursor.par()->table) { - int cell = NumberOfCell(cursor.par(), cursor.pos()); - if (cursor.par()->table->IsContRow(cell) && - cursor.par()->table->CellHasContRow(cursor.par()->table->GetCellAbove(cell))<0) { - CursorUp(bview); - } - } -#endif } void LyXText::CursorDown(BufferView * bview) const { -#ifndef NEW_TABULAR - if (cursor.par()->table && - cursor.par()->table->ShouldBeVeryLastRow(NumberOfCell(cursor.par(), cursor.pos())) && - !cursor.par()->next) - return; -#endif - SetCursorFromCoordinates(bview, cursor.x_fix(), cursor.y() - cursor.row()->baseline() + cursor.row()->height() + 1); -#ifndef NEW_TABULAR - if (cursor.par()->table) { - int cell = NumberOfCell(cursor.par(), cursor.pos()); - int cell_above = cursor.par()->table->GetCellAbove(cell); - while(cursor.par()->table && - cursor.par()->table->IsContRow(cell) && - (cursor.par()->table->CellHasContRow(cell_above)<0)) { - SetCursorFromCoordinates(bview, cursor.x_fix(), - cursor.y() - cursor.row()->baseline() - + cursor.row()->height() + 1); - if (cursor.par()->table) { - cell = NumberOfCell(cursor.par(), cursor.pos()); - cell_above = cursor.par()->table->GetCellAbove(cell); - } - } - } -#endif } @@ -3765,70 +3559,6 @@ void LyXText::SetCursorParUndo(Buffer * buf) } -#ifndef NEW_TABULAR -void LyXText::RemoveTableRow(LyXCursor & cur) const -{ - int cell = -1; - int cell_org = 0; - int ocell = 0; - - // move to the previous row - int cell_act = NumberOfCell(cur.par(), cur.pos()); - if (cell < 0) - cell = cell_act; - while (cur.pos() && !cur.par()->IsNewline(cur.pos() - 1)) - cur.pos(cur.pos() - 1); - while (cur.pos() && - !cur.par()->table->IsFirstCell(cell_act)) { - cur.pos(cur.pos() - 1); - while (cur.pos() && !cur.par()->IsNewline(cur.pos() - 1)) - cur.pos(cur.pos() - 1); - --cell; - --cell_act; - } - // now we have to pay attention if the actual table is the - // main row of TableContRows and if yes to delete all of them - if (!cell_org) - cell_org = cell; - do { - ocell = cell; - // delete up to the next row - while (cur.pos() < cur.par()->Last() && - (cell_act == ocell - || !cur.par()->table->IsFirstCell(cell_act))) { - while (cur.pos() < cur.par()->Last() && - !cur.par()->IsNewline(cur.pos())) - cur.par()->Erase(cur.pos()); - ++cell; - ++cell_act; - if (cur.pos() < cur.par()->Last()) - cur.par()->Erase(cur.pos()); - } - if (cur.pos() && cur.pos() == cur.par()->Last()) { - cur.pos(cur.pos() - 1); - cur.par()->Erase(cur.pos()); // no newline at very end! - } - } while (((cell + 1) < cur.par()->table->GetNumberOfCells()) && - !cur.par()->table->IsContRow(cell_org) && - cur.par()->table->IsContRow(cell)); - cur.par()->table->DeleteRow(cell_org); - return; -} -#endif - - -#ifndef NEW_TABULAR -bool LyXText::IsEmptyTableCell() const -{ - LyXParagraph::size_type pos = cursor.pos() - 1; - while (pos >= 0 && pos < cursor.par()->Last() - && !cursor.par()->IsNewline(pos)) - --pos; - return cursor.par()->IsNewline(pos + 1); -} -#endif - - void LyXText::toggleAppendix(BufferView * bview) { #ifndef NEW_INSETS -- 2.39.2