+2000-09-23 Lars Gullik Bjønnes <larsbj@lyx.org>
+
+ * several files: removed almost all traces of the old table
+ (tabular) code.
+
+ * src/TableLayout.C: removed file
+
2000-09-22 Juergen Vigna <jug@sad.it>
* src/frontends/kde/Dialogs.C: added credits forms.
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
src/support/getUserName.C
src/support/path.C
src/support/path.h
-src/TableLayout.C
src/tabular.C
src/text2.C
src/text.C
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();
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;
* if necessary */
update(BufferView::SELECT|BufferView::FITCUR);
}
- }
+ }
}
}
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;
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;
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();
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;
}
#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
Sectioning.C \
Spacing.C \
Spacing.h \
- TableLayout.C \
TextCache.C \
TextCache.h \
Timeout.C \
+++ /dev/null
-#include <config.h>
-
-#include <cstdlib>
-#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
-}
#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
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;
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;
#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) {
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()) {
}
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";
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;
}
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,
return fdui;
}
/*---------------------------------------*/
-
+#if 0
FD_form_table_options *create_form_form_table_options(void)
{
FL_OBJECT *obj;
return fdui;
}
/*---------------------------------------*/
+#endif
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;
return fdui;
}
/*---------------------------------------*/
-
+#endif
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
}
extern bool UpdateLayoutQuotes();
extern bool UpdateLayoutParagraph();
extern bool UpdateParagraphExtra();
+#if 0
extern bool UpdateLayoutTable(int);
+#endif
extern void MenuLayoutCharacter();
extern void MenuLayoutDocument();
extern void MenuLayoutPaper();
extern void MenuLayoutQuotes();
extern void MenuLayoutParagraph();
+#if 0
extern void MenuLayoutTable(int);
+#endif
extern "C" {
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();
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);
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"));
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();
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);
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);
}
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();
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
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();
|| ! 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) {
}
case LFUN_DIALOG_TABULAR_INSERT:
-#ifndef NEW_TABULAR
- Table();
-#else
owner->getDialogs()->showTabularCreate();
-#endif
break;
case LFUN_TABULAR_FEATURE:
case LFUN_LAYOUT_CHARACTER:
MenuLayoutCharacter();
break;
-
+
+#if 0
case LFUN_LAYOUT_TABLE:
{
int flag = 0;
MenuLayoutTable(flag);
}
break;
-
+#endif
+
case LFUN_LAYOUT_TABULAR:
if (owner->view()->the_locking_inset) {
if (owner->view()->the_locking_inset->LyxCode()==Inset::TABULAR_CODE) {
// 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:
///
LyXParagraph * previous;
-#ifndef NEW_TABULAR
- /* table stuff -- begin*/
- ///
- LyXTable * table;
- /* table stuff -- end*/
-#endif
///
InsetBibKey * bibkey; // ale970302
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 {
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,
///
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);
#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
#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++;
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);
(*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)
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;
it != insetlist.end(); ++it) {
delete (*it).inset;
}
-#ifndef NEW_TABULAR
- /* table stuff -- begin*/
- delete table;
- /* table stuff -- end*/
-#endif
// ale970302
delete bibkey;
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;
}
// 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
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);
}
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) {
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
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
&& !( 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
{
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 =
}
-#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;
}
-#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 << "<INFORMALTABLE>"
- << newlineAndDepth(++depth);
- }
-#else
- os << "<INFORMALTABLE>"
- << 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 <emphasis> tag.
- if (font1.emph() != font2.emph() && i) {
- if (font2.emph() == LyXFont::ON) {
- os << "<emphasis>";
- emph_flag= true;
- } else if (emph_flag) {
- os << "</emphasis>";
- emph_flag= false;
- }
- }
- if (c == LyXParagraph::META_NEWLINE) {
- // We have only to control for emphasis open here!
- if (emph_flag) {
- os << "</emphasis>";
- 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'
- << "</term><listitem><para>";
- 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 << "</emphasis>";
- }
-
- ++current_cell_number;
- tmp = table->DocBookEndOfCell(os, current_cell_number, depth);
- // Resets description flag correctly.
- switch(desc_on){
- case 1:
- // <term> not closed...
- os << "</term>";
- break;
- }
-#ifndef NEW_INSETS
- if (footnoteflag == LyXParagraph::NO_FOOTNOTE)
-#endif
- os << "</INFORMALTABLE>";
- 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 <emphasis> tag.
- if (font1.emph() != font2.emph() && i) {
- if (font2.emph() == LyXFont::ON) {
- os << "<emphasis>";
- emph_flag= true;
- } else if (emph_flag) {
- os << "</emphasis>";
- 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'
- << "</term><listitem><para>";
- desc_on = 2;
- } else {
- os << c;
- }
- } else {
- os << sgml_string;
- }
- }
- }
- // we have only to control for emphasis open here!
- if (emph_flag) {
- os << "</emphasis>";
- 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,
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")
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;
}
bool LyXParagraph::isRightToLeftPar(BufferParams const & bparams) const
{
return lyxrc.rtl_support
-#ifndef NEW_TABULAR
- && !table
-#endif
&& getParLanguage(bparams)->RightToLeft();
}
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())
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;
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)
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;
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;
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
}
-#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
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;
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,
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;
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();
{
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
#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()))
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())
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);
#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
{
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
}
// 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
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()))
} 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
}
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
|| 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()) {
} 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),
/* 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
}
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;
(!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;
}
}
- 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
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. */
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
}
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)))) {
/* 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)
}
}
#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();
}
}
#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()
&& 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);
++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;
}
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] = ' ';
{
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
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);
/// 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);
SetCurrentFont(bview);
}
+
void LyXText::SetCurrentFont(BufferView * bview) const
{
LyXParagraph::size_type pos = cursor.pos();
--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() &&
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
}
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);
{
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
}
}
-#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