1 /* This file is part of
2 * ======================================================
4 * LyX, The Document Processor
6 * Copyright 2000 The LyX Team.
8 * ======================================================
17 #pragma implementation
24 #include "support/lstrings.h"
25 #include "support/lyxmanip.h"
26 #include "lyx_gui_misc.h"
27 #include "insets/insettext.h"
36 static int const WIDTH_OF_LINE = 5;
38 /// Define a few methods for the inner structs
40 LyXTabular::cellstruct::cellstruct()
42 cellno = 0; //should be initilaized correctly later.
44 multicolumn = LyXTabular::CELL_NORMAL;
45 alignment = LYX_ALIGN_CENTER;
54 LyXTabular::cellstruct::~cellstruct()
60 LyXTabular::cellstruct::cellstruct(cellstruct const & cs)
63 width_of_cell = cs.width_of_cell;
64 multicolumn = cs.multicolumn;
65 alignment = cs.alignment;
66 top_line = cs.top_line;
67 bottom_line = cs.bottom_line;
69 linebreaks = cs.linebreaks;
74 LyXTabular::cellstruct &
75 LyXTabular::cellstruct::operator=(cellstruct const & cs)
78 width_of_cell = cs.width_of_cell;
79 multicolumn = cs.multicolumn;
80 alignment = cs.alignment;
81 top_line = cs.top_line;
82 bottom_line = cs.bottom_line;
84 linebreaks = cs.linebreaks;
89 LyXTabular::rowstruct::rowstruct()
99 // Nothing to do, but gcc 2.7.2.3 wants one... (JMarc)
100 //LyXTabular::rowstruct::~rowstruct()
104 //LyXTabular::rowstruct &
105 // LyXTabular::rowstruct::operator=(rowstruct const & rs)
107 // top_line = rs.top_line;
108 // bottom_line = rs.bottom_line;
109 // ascent_of_row = rs.ascent_of_row;
110 // descent_of_row = rs.descent_of_row;
111 // newpage = rs.newpage;
116 LyXTabular::columnstruct::columnstruct()
120 alignment = LYX_ALIGN_CENTER;
125 //LyXTabular::columnstruct::~columnstruct()
130 //LyXTabular::columnstruct &
131 // LyXTabular::columnstruct::operator=(columnstruct const & cs)
133 // left_line = cs.left_line;
134 // right_line = cs.right_line;
135 // alignment = cs.alignment;
136 // width_of_column = cs.width_of_column;
137 // p_width = cs.p_width;
138 // align_special = cs.align_special;
144 LyXTabular::LyXTabular(int rows_arg, int columns_arg, Buffer *buf)
147 Init(buf, rows_arg, columns_arg);
151 LyXTabular::LyXTabular(LyXTabular const & lt, Buffer * buf)
154 Init(buf, lt.rows_, lt.columns_);
160 LyXTabular::LyXTabular(LyXLex & lex, Buffer *buf)
167 LyXTabular::~LyXTabular()
170 delete[] columnofcell;
171 // delete[] column_info;
172 // delete[] row_info;
173 // for (int i = 0; i < rows_; ++i) {
174 // delete[] cell_info[i];
176 // delete[] cell_info;
180 LyXTabular & LyXTabular::operator=(LyXTabular const & lt)
182 // If this and lt is not of the same size we have a serious bug
183 // So then it is ok to throw an exception, or for now
185 Assert(rows_ == lt.rows_ && columns_ == lt.columns_);
187 int row = 0, column = 0;
190 // cell_info = lt.cell_info;
191 for (row = 0; row < rows_; ++row) {
192 for (column = 0; column < columns_; ++column) {
193 cell_info[row][column] = lt.cell_info[row][column];
198 // row_info = lt.row_info;
199 for (row = 0; row < rows_; ++row) {
200 row_info[row] = lt.row_info[row];
204 // column_info = lt.column_info;
205 for (column = 0; column < columns_; ++column) {
206 column_info[column] = lt.column_info[column];
209 SetLongTabular(lt.is_long_tabular);
217 LyXTabular * LyXTabular::Clone(Buffer * buf)
219 LyXTabular * result = new LyXTabular(rows_, columns_, buf);
222 for (row = 0; row < rows_; ++row) {
223 for (column = 0; column < columns_; ++column) {
224 result->cell_info[row][column] = cell_info[row][column];
228 for (row = 0; row < rows_; ++row) {
229 result->row_info[row] = row_info[row];
232 for (column = 0; column < columns_; ++column) {
233 result->column_info[column].left_line = column_info[column].left_line;
234 result->column_info[column].right_line = column_info[column].right_line;
235 result->column_info[column].alignment = column_info[column].alignment;
236 result->column_info[column].p_width = column_info[column].p_width;
237 result->column_info[column].align_special = column_info[column].align_special;
240 result->SetLongTabular(is_long_tabular);
241 result->rotate = rotate;
247 /* activates all lines and sets all widths to 0 */
248 void LyXTabular::Init(Buffer * buf, int rows_arg, int columns_arg)
254 columns_ = columns_arg;
255 row_info = vector<rowstruct>(rows_, rowstruct());
256 column_info = vector<columnstruct>(columns_, columnstruct());
257 cell_info = vector<vector<cellstruct> >
258 (rows_, vector<cellstruct>(columns_, cellstruct()));
260 // Jürgen, use iterators.
261 for (i = 0; i < rows_; ++i) {
262 for (j = 0; j < columns_; ++j) {
263 cell_info[i][j].inset = new InsetText(buf);
264 cell_info[i][j].cellno = cellno++;
267 row_info[i-1].bottom_line = true;
268 row_info[0].bottom_line = true;
270 for (i = 0; i < columns_; ++i) {
271 calculate_width_of_column(i);
273 column_info[columns_-1].right_line = true;
275 calculate_width_of_tabular();
279 set_row_column_number_info();
280 is_long_tabular = false;
289 void LyXTabular::AppendRow(int /* cell */)
292 int row = row_of_cell(cell);
293 rowstruct * row_info2 = new rowstruct[rows_ + 1];
294 cellstruct ** cell_info2 = new cellstruct * [rows_ + 1];
297 for (i = 0; i <= row; ++i) {
298 cell_info2[i] = cell_info[i];
299 row_info2[i] = row_info[i];
301 for (i = rows_ - 1; i >= row; --i) {
302 cell_info2[i + 1] = cell_info[i];
303 row_info2[i + 1] = row_info[i];
305 row_info2[row + 1].top_line = row_info[i].top_line;
306 cell_info2[row + 1] = new cellstruct[columns_](buffer);
307 for (i = 0; i < columns_; ++i) {
308 cell_info2[row + 1][i].width_of_cell = 0;
309 cell_info2[row + 1][i] = cell_info2[row][i];
313 cell_info = cell_info2;
315 row_info = row_info2;
324 void LyXTabular::DeleteRow(int /*cell*/)
327 int row = row_of_cell(cell);
328 rowstruct * row_info2 = new rowstruct[rows_ - 1];
329 cellstruct ** cell_info2 = new cellstruct * [rows_ - 1];
331 delete[] cell_info[row];
333 for (; i < row; ++i) {
334 cell_info2[i] = cell_info[i];
335 row_info2[i] = row_info[i];
337 for (i = row; i < rows_ - 1; ++i) {
338 cell_info2[i] = cell_info[i + 1];
339 row_info2[i] = row_info[i + 1];
343 cell_info = cell_info2;
345 row_info = row_info2;
354 void LyXTabular::AppendColumn(int /*cell*/)
358 columnstruct * column_info2 = new columnstruct[columns_ + 1];
359 int column = right_column_of_cell(cell);
362 for (; i <= column; ++i) {
363 column_info2[i] = column_info[i];
365 for (i = columns_ - 1; i >= column; --i) {
366 column_info2[i + 1] = column_info[i];
369 delete[] column_info;
370 column_info = column_info2;
372 for (i = 0; i < rows_; ++i) {
373 cellstruct * tmp = cell_info[i];
374 cell_info[i] = new cellstruct[columns_ + 1](buffer);
375 for (j = 0; j <= column; ++j) {
376 cell_info[i][j] = tmp[j];
378 for (j = column; j < columns_; ++j) {
379 cell_info[i][j + 1] = tmp[j];
381 // care about multicolumns
382 if (cell_info[i][column + 1].multicolumn
383 == LyXTabular::CELL_BEGIN_OF_MULTICOLUMN){
384 cell_info[i][column + 1].multicolumn =
385 LyXTabular::CELL_PART_OF_MULTICOLUMN;
387 if (column + 1 == columns_
388 || cell_info[i][column + 2].multicolumn
389 != LyXTabular::CELL_PART_OF_MULTICOLUMN){
390 cell_info[i][column + 1].multicolumn =
391 LyXTabular::CELL_NORMAL;
402 void LyXTabular::DeleteColumn(int /*cell*/)
405 int column1 = column_of_cell(cell);
406 int column2 = right_column_of_cell(cell);
408 if (column1 == 0 && column2 == columns_ - 1)
411 for (int column = column1; column <= column2; ++column) {
412 delete_column(column1);
419 void LyXTabular::delete_column(int /*column*/)
423 columnstruct * column_info2 = new columnstruct[columns_-1];
425 for (i = 0; i < column; ++i) {
426 column_info2[i] = column_info[i];
428 for (i = column; i < columns_ - 1; ++i) {
429 column_info2[i] = column_info[i + 1];
432 delete[] column_info;
433 column_info = column_info2;
435 for (i = 0; i < rows_; ++i) {
436 cellstruct * tmp = cell_info[i];
437 cell_info[i] = new cellstruct[columns_ - 1](buffer);
438 for (j = 0; j < column; ++j) {
439 cell_info[i][j] = tmp[j];
441 for (j = column; j < columns_ - 1; ++j) {
442 cell_info[i][j] = tmp[j + 1];
453 void LyXTabular::Reinit()
459 // Jürgen, use iterators.
460 for (; i < rows_; ++i) {
461 for (j = 0; j < columns_; ++j) {
462 cell_info[i][j].width_of_cell = 0;
466 for (i = 0; i < columns_; ++i) {
467 calculate_width_of_column(i);
469 calculate_width_of_tabular();
471 set_row_column_number_info();
475 void LyXTabular::set_row_column_number_info()
481 for (; row < rows_; ++row) {
482 for (column = 0; column<columns_; ++column) {
483 if (cell_info[row][column].multicolumn
484 != LyXTabular::CELL_PART_OF_MULTICOLUMN)
486 cell_info[row][column].cellno = numberofcells;
489 ++numberofcells; // because this is one more than as we start from 0
494 rowofcell = new int[numberofcells];
495 delete [] columnofcell;
496 columnofcell = new int[numberofcells];
498 while (c < numberofcells && row < rows_ && column < columns_) {
500 columnofcell[c] = column;
504 } while (column < columns_ &&
505 cell_info[row][column].multicolumn
506 == LyXTabular::CELL_PART_OF_MULTICOLUMN);
507 if (column == columns_) {
515 int LyXTabular::GetNumberOfCells() const
517 return numberofcells;
521 int LyXTabular::NumberOfCellsInRow(int cell) const
523 int row = row_of_cell(cell);
525 for (int i = 0; i < columns_; ++i) {
526 if (cell_info[row][i].multicolumn != LyXTabular::CELL_PART_OF_MULTICOLUMN)
533 int LyXTabular::AppendCellAfterCell(int append_cell, int question_cell)
535 return (right_column_of_cell(append_cell) ==
536 right_column_of_cell(question_cell));
540 int LyXTabular::DeleteCellIfColumnIsDeleted(int cell, int delete_column_cell)
542 if (column_of_cell(delete_column_cell) == 0 &&
543 right_column_of_cell(delete_column_cell) == columns_ - 1)
547 (column_of_cell(cell) >= column_of_cell(delete_column_cell) &&
548 column_of_cell(cell) <= right_column_of_cell(delete_column_cell));
552 /* returns 1 if there is a topline, returns 0 if not */
553 bool LyXTabular::TopLine(int cell) const
555 int row = row_of_cell(cell);
557 if (IsMultiColumn(cell))
558 return cellinfo_of_cell(cell)->top_line;
559 return row_info[row].top_line;
563 bool LyXTabular::BottomLine(int cell) const
565 //no bottom line underneath non-existent cells if you please
566 if(cell >= numberofcells)
569 if (IsMultiColumn(cell))
570 return cellinfo_of_cell(cell)->bottom_line;
571 return row_info[row_of_cell(cell)].bottom_line;
575 bool LyXTabular::LeftLine(int cell) const
577 return column_info[column_of_cell(cell)].left_line;
581 bool LyXTabular::RightLine(int cell) const
583 return column_info[right_column_of_cell(cell)].right_line;
587 bool LyXTabular::TopAlreadyDrawed(int cell) const
589 if (GetAdditionalHeight(cell))
591 int row = row_of_cell(cell);
593 int column = column_of_cell(cell);
596 && cell_info[row][column].multicolumn
597 == LyXTabular::CELL_PART_OF_MULTICOLUMN)
599 if (cell_info[row][column].multicolumn == LyXTabular::CELL_NORMAL)
600 return row_info[row].bottom_line;
602 return cell_info[row][column].bottom_line;
608 bool LyXTabular::LeftAlreadyDrawed(int cell) const
610 int column = column_of_cell(cell);
612 int row = row_of_cell(cell);
614 (cell_info[row][column].multicolumn ==
615 LyXTabular::CELL_PART_OF_MULTICOLUMN));
616 if (GetAdditionalWidth(cell_info[row][column].cellno))
618 return column_info[column].right_line;
624 bool LyXTabular::IsLastRow(int cell) const
626 return (row_of_cell(cell) == rows_ - 1);
630 int LyXTabular::GetAdditionalHeight(int cell) const
632 int row = row_of_cell(cell);
635 int top = 1; // bool top = true; ??
636 int bottom = 1; // bool bottom = true; ??
639 for (column = 0; column < columns_ - 1 && bottom; ++column) {
640 switch (cell_info[row - 1][column].multicolumn) {
641 case LyXTabular::CELL_BEGIN_OF_MULTICOLUMN:
642 bottom = cell_info[row - 1][column].bottom_line;
644 case LyXTabular::CELL_NORMAL:
645 bottom = row_info[row - 1].bottom_line;
648 for (column = 0; column < columns_ - 1 && top; ++column) {
649 switch (cell_info[row][column].multicolumn){
650 case LyXTabular::CELL_BEGIN_OF_MULTICOLUMN:
651 top = cell_info[row][column].top_line;
653 case LyXTabular::CELL_NORMAL:
654 top = row_info[row].top_line;
658 return WIDTH_OF_LINE;
663 int LyXTabular::GetAdditionalWidth(int cell) const
665 // internally already set in SetWidthOfCell
666 // used to get it back in text.C
667 int col = right_column_of_cell(cell);
668 if (col < columns_ - 1 && column_info[col].right_line &&
669 column_info[col+1].left_line)
670 return WIDTH_OF_LINE;
676 // returns the maximum over all rows
677 int LyXTabular::GetWidthOfColumn(int cell) const
679 int column1 = column_of_cell(cell);
680 int column2 = right_column_of_cell(cell);
683 for (; i <= column2; ++i) {
684 result += column_info[i].width_of_column;
690 int LyXTabular::GetWidthOfTabular() const
692 return width_of_tabular;
696 /* returns 1 if a complete update is necessary, otherwise 0 */
697 bool LyXTabular::SetWidthOfMulticolCell(int cell, int new_width)
699 if (!IsMultiColumn(cell))
702 int row = row_of_cell(cell);
703 int column1 = column_of_cell(cell);
704 int column2 = right_column_of_cell(cell);
706 // first set columns to 0 so we can calculate the right width
708 for (; i <= column2; ++i) {
709 cell_info[row][i].width_of_cell = 0;
711 // set the width to MAX_WIDTH until width > 0
712 int width = (new_width + 2 * WIDTH_OF_LINE);
713 for (i = column1; (i < column2) && (width > 0); ++i) {
714 cell_info[row][i].width_of_cell = column_info[i].width_of_column;
715 width -= column_info[i].width_of_column;
718 cell_info[row][i].width_of_cell = width;
724 void LyXTabular::recalculateMulticolCells(int cell, int new_width)
726 int row = row_of_cell(cell);
727 int column1 = column_of_cell(cell);
728 int column2 = right_column_of_cell(cell);
730 // first set columns to 0 so we can calculate the right width
732 for (; i <= column2; ++i)
733 cell_info[row][i].width_of_cell = 0;
734 for(i = cell + 1; (i < numberofcells) && (!IsMultiColumn(i)); ++i)
736 if (i < numberofcells)
737 recalculateMulticolCells(i, GetWidthOfCell(i) - (2 * WIDTH_OF_LINE));
738 SetWidthOfMulticolCell(cell, new_width);
742 /* returns 1 if a complete update is necessary, otherwise 0 */
743 bool LyXTabular::SetWidthOfCell(int cell, int new_width)
745 int row = row_of_cell(cell);
746 int column1 = column_of_cell(cell);
750 if (IsMultiColumn(cell)) {
751 tmp = SetWidthOfMulticolCell(cell, new_width);
753 width = (new_width + 2*WIDTH_OF_LINE);
754 cell_info[row][column1].width_of_cell = width;
755 if (column_info[column1].right_line && (column1 < columns_-1) &&
756 column_info[column1+1].left_line) // additional width
757 cell_info[row][column1].width_of_cell += WIDTH_OF_LINE;
758 tmp = calculate_width_of_column_NMC(column1);
762 for(i = 0; i<columns_;++i)
763 calculate_width_of_column_NMC(i);
764 for(i = 0; (i<numberofcells) && !IsMultiColumn(i); ++i)
767 recalculateMulticolCells(i, GetWidthOfCell(i)-(2*WIDTH_OF_LINE));
768 for(i = 0; i<columns_;++i)
769 calculate_width_of_column(i);
770 calculate_width_of_tabular();
777 bool LyXTabular::SetAlignment(int cell, char align)
779 if (!IsMultiColumn(cell))
780 column_info[column_of_cell(cell)].alignment = align;
781 cellinfo_of_cell(cell)->alignment = align;
786 bool LyXTabular::SetPWidth(int cell, string width)
788 if (IsMultiColumn(cell)) {
789 cellinfo_of_cell(cell)->p_width = width;
791 column_info[column_of_cell(cell)].p_width = width;
792 if (!width.empty()) // do this only if there is a width
793 SetAlignment(cell, LYX_ALIGN_LEFT);
799 bool LyXTabular::SetAlignSpecial(int cell, string special, int what)
801 if (what == SET_SPECIAL_MULTI)
802 cellinfo_of_cell(cell)->align_special = special;
804 column_info[column_of_cell(cell)].align_special = special;
809 bool LyXTabular::SetAllLines(int cell, bool line)
811 SetTopLine(cell, line);
812 SetBottomLine(cell, line);
813 SetRightLine(cell, line);
814 SetLeftLine(cell, line);
819 bool LyXTabular::SetTopLine(int cell, bool line)
821 int row = row_of_cell(cell);
823 if (!IsMultiColumn(cell))
824 row_info[row].top_line = line;
826 cellinfo_of_cell(cell)->top_line = line;
831 bool LyXTabular::SetBottomLine(int cell, bool line)
833 if (!IsMultiColumn(cell))
834 row_info[row_of_cell(cell)].bottom_line = line;
836 cellinfo_of_cell(cell)->bottom_line = line;
841 bool LyXTabular::SetLeftLine(int cell, bool line)
843 column_info[column_of_cell(cell)].left_line = line;
848 bool LyXTabular::SetRightLine(int cell, bool line)
850 column_info[right_column_of_cell(cell)].right_line = line;
855 char LyXTabular::GetAlignment(int cell) const
857 if (IsMultiColumn(cell))
858 return cellinfo_of_cell(cell)->alignment;
860 return column_info[column_of_cell(cell)].alignment;
864 string LyXTabular::GetPWidth(int cell) const
866 if (IsMultiColumn(cell))
867 return cellinfo_of_cell(cell)->p_width;
868 return column_info[column_of_cell(cell)].p_width;
872 string LyXTabular::GetAlignSpecial(int cell, int what) const
874 if (what == SET_SPECIAL_MULTI)
875 return cellinfo_of_cell(cell)->align_special;
876 return column_info[column_of_cell(cell)].align_special;
880 int LyXTabular::GetWidthOfCell(int cell) const
882 int row = row_of_cell(cell);
883 int column1 = column_of_cell(cell);
884 int column2 = right_column_of_cell(cell);
887 for (; i <= column2; ++i) {
888 result += cell_info[row][i].width_of_cell;
891 // result += GetAdditionalWidth(cell);
897 int LyXTabular::GetBeginningOfTextInCell(int cell) const
901 switch (GetAlignment(cell)){
902 case LYX_ALIGN_CENTER:
903 x += (GetWidthOfColumn(cell) - GetWidthOfCell(cell)) / 2;
905 case LYX_ALIGN_RIGHT:
906 x += GetWidthOfColumn(cell) - GetWidthOfCell(cell);
907 // + GetAdditionalWidth(cell);
909 default: /* LYX_ALIGN_LEFT: nothing :-) */
919 bool LyXTabular::IsFirstCellInRow(int cell) const
921 return (column_of_cell(cell) == 0);
925 bool LyXTabular::IsLastCellInRow(int cell) const
927 return (right_column_of_cell(cell) == (columns_ - 1));
931 bool LyXTabular::calculate_width_of_column(int column)
933 int old_column_width = column_info[column].width_of_column;
936 for (int i = 0; i < rows_; ++i) {
937 maximum = max(cell_info[i][column].width_of_cell, maximum);
939 column_info[column].width_of_column = maximum;
940 return (column_info[column].width_of_column != old_column_width);
944 bool LyXTabular::calculate_width_of_column_NMC(int column)
946 int old_column_width = column_info[column].width_of_column;
948 for (int i = 0; i < rows_; ++i) {
949 if (!IsMultiColumn(GetCellNumber(column, i)) &&
950 (cell_info[i][column].width_of_cell > max)) {
951 max = cell_info[i][column].width_of_cell;
954 column_info[column].width_of_column = max;
955 return (column_info[column].width_of_column != old_column_width);
959 void LyXTabular::calculate_width_of_tabular()
961 width_of_tabular = 0;
962 for (int i = 0; i < columns_; ++i) {
963 width_of_tabular += column_info[i].width_of_column;
968 int LyXTabular::row_of_cell(int cell) const
970 if (cell >= numberofcells)
974 return rowofcell[cell];
978 int LyXTabular::column_of_cell(int cell) const
980 if (cell >= numberofcells)
984 return columnofcell[cell];
988 int LyXTabular::right_column_of_cell(int cell) const
990 int row = row_of_cell(cell);
991 int column = column_of_cell(cell);
992 while (column < (columns_ - 1) &&
993 cell_info[row][column+1].multicolumn == LyXTabular::CELL_PART_OF_MULTICOLUMN)
999 void LyXTabular::Write(ostream & os) const
1004 os << "<LyXTabular version=1 rows=" << rows_ << " columns=" << columns_ <<
1006 // global longtable options
1007 os << "<Features rotate=" << rotate <<
1008 " islongtable=" << is_long_tabular <<
1009 " endhead=" << endhead << " endfirsthead=" << endfirsthead <<
1010 " endfoot=" << endfoot << " endlastfoot=" << endlastfoot <<
1011 ">" << endl << endl;
1012 for (i = 0; i < rows_; ++i) {
1013 os << "<Row topline=" << row_info[i].top_line <<
1014 " bottomline=" << row_info[i].bottom_line <<
1015 " newpage=" << row_info[i].newpage <<
1017 for (j = 0; j < columns_; ++j) {
1019 os << "<Column alignment=" << column_info[j].alignment <<
1020 " leftline=" << column_info[j].left_line <<
1021 " rightline=" << column_info[j].right_line <<
1022 " width=\"" << VSpace(column_info[j].p_width).asLyXCommand() <<
1023 "\" special=\"" << column_info[j].align_special <<
1026 os << "<Column>" << endl;
1028 os << "<Cell multicolumn=" << cell_info[i][j].multicolumn <<
1029 " alignment=" << cell_info[i][j].alignment <<
1030 " topline=" << cell_info[i][j].top_line <<
1031 " bottomline=" << cell_info[i][j].bottom_line <<
1032 " rotate=" << cell_info[i][j].rotate <<
1033 " linebreaks=" << cell_info[i][j].linebreaks <<
1034 " width=\"" << cell_info[i][j].p_width <<
1035 "\" special=\"" << cell_info[i][j].align_special <<
1037 os << "\\begin_inset ";
1038 cell_info[i][j].inset->Write(os);
1039 os << "\n\\end_inset " << endl;
1040 os << "</Cell>" << endl;
1041 os << "</Column>" << endl;
1043 os << "</Row>" << endl;
1045 os << "</LyXTabular>" << endl;
1050 bool getTokenValue(string const str, const char * token, string & ret)
1052 int pos = str.find(token);
1053 char ch = str[pos+strlen(token)];
1055 if ((pos < 0) || (ch != '='))
1058 pos += strlen(token)+1;
1060 if ((ch != '"') && (ch != '\'')) { // only read till next space
1064 while((pos < int(str.length()-1)) && (str[++pos] != ch))
1072 bool getTokenValue(string const str, const char * token, int & num)
1075 int pos = str.find(token);
1076 char ch = str[pos+strlen(token)];
1078 if ((pos < 0) || (ch != '='))
1081 pos += strlen(token)+1;
1083 if ((ch != '"') && (ch != '\'')) { // only read till next space
1089 while((pos < int(str.length()-1)) && isdigit(str[pos]))
1092 num = strToInt(ret);
1098 bool getTokenValue(string const str, const char * token, bool & flag)
1101 int pos = str.find(token);
1102 char ch = str[pos+strlen(token)];
1104 if ((pos < 0) || (ch != '='))
1107 pos += strlen(token)+1;
1109 if ((ch != '"') && (ch != '\'')) { // only read till next space
1115 while((pos < int(str.length()-1)) && isdigit(str[pos]))
1118 flag = strToInt(ret);
1123 void l_getline(istream & is, string & str)
1131 void LyXTabular::Read(LyXLex & lex)
1134 istream & is = lex.getStream();
1136 l_getline(is, line);
1137 if (!prefixIs(line, "<LyXTabular ")) {
1138 OldFormatRead(is, line);
1145 if (!getTokenValue(line, "version", version))
1147 if (!getTokenValue(line, "rows", rows_arg))
1149 if (!getTokenValue(line, "columns", columns_arg))
1151 Init(buffer, rows_arg, columns_arg);
1152 l_getline(is, line);
1153 if (!prefixIs(line, "<Features ")) {
1154 lyxerr << "Wrong tabular format (expected <Feture ...> got" <<
1155 line << ")" << endl;
1158 (void)getTokenValue(line, "islongtable", is_long_tabular);
1159 (void)getTokenValue(line, "endhead", endhead);
1160 (void)getTokenValue(line, "endfirsthead", endfirsthead);
1161 (void)getTokenValue(line, "endfoot", endfoot);
1162 (void)getTokenValue(line, "endlastfoot", endlastfoot);
1164 for(i = 0; i < rows_; ++i) {
1165 l_getline(is, line);
1166 if (!prefixIs(line, "<Row ")) {
1167 lyxerr << "Wrong tabular format (expected <Row ...> got" <<
1168 line << ")" << endl;
1171 (void)getTokenValue(line, "topline", row_info[i].top_line);
1172 (void)getTokenValue(line, "bottomline", row_info[i].bottom_line);
1173 (void)getTokenValue(line, "newpage", row_info[i].newpage);
1174 for (j = 0; j < columns_; ++j) {
1176 if (!prefixIs(line,"<Column")) {
1177 lyxerr << "Wrong tabular format (expected <Column ...> got" <<
1178 line << ")" << endl;
1182 (void)getTokenValue(line, "alignment", column_info[j].alignment);
1183 (void)getTokenValue(line, "leftline", column_info[j].left_line);
1184 (void)getTokenValue(line, "rightline", column_info[j].right_line);
1185 (void)getTokenValue(line, "width", column_info[j].p_width);
1186 (void)getTokenValue(line, "special", column_info[j].align_special);
1188 l_getline(is, line);
1189 if (!prefixIs(line, "<Cell")) {
1190 lyxerr << "Wrong tabular format (expected <Cell ...> got" <<
1191 line << ")" << endl;
1194 (void)getTokenValue(line, "multicolumn", cell_info[i][j].multicolumn);
1195 (void)getTokenValue(line, "alignment", cell_info[i][j].alignment);
1196 (void)getTokenValue(line, "topline", cell_info[i][j].top_line);
1197 (void)getTokenValue(line, "bottomline", cell_info[i][j].bottom_line);
1198 (void)getTokenValue(line, "rotate", cell_info[i][j].rotate);
1199 (void)getTokenValue(line, "linebreaks", cell_info[i][j].linebreaks);
1200 (void)getTokenValue(line, "width", cell_info[i][j].p_width);
1201 (void)getTokenValue(line, "special", cell_info[i][j].align_special);
1202 l_getline(is, line);
1203 if (prefixIs(line, "\\begin_inset")) {
1204 cell_info[i][j].inset->Read(lex);
1205 l_getline(is, line);
1207 if (line != "</Cell>") {
1208 lyxerr << "Wrong tabular format (expected </Cell> got" <<
1209 line << ")" << endl;
1212 l_getline(is, line);
1213 if (line != "</Column>") {
1214 lyxerr << "Wrong tabular format (expected </Column> got" <<
1215 line << ")" << endl;
1219 l_getline(is, line);
1220 if (line != "</Row>") {
1221 lyxerr << "Wrong tabular format (expected </Row> got" <<
1222 line << ")" << endl;
1226 while (line != "</LyXTabular>") {
1227 l_getline(is, line);
1229 set_row_column_number_info();
1233 void LyXTabular::OldFormatRead(istream & is, string fl)
1238 int columns_arg = 0;
1239 int is_long_tabular_arg = false;
1240 int rotate_arg = false;
1253 version = atoi(s.c_str() + 8);
1257 lyxerr << "Tabular format < 5 is not supported anymore\n"
1258 "Get an older version of LyX (< 1.1.x) for conversion!"
1260 WriteAlert(_("Warning:"),
1261 _("Tabular format < 5 is not supported anymore\n"),
1262 _("Get an older version of LyX (< 1.1.x) for conversion!"));
1264 is >> rows_arg >> columns_arg >> is_long_tabular_arg
1265 >> rotate_arg >> a >> b >> c >> d;
1267 is >> rows_arg >> columns_arg;
1268 Init(buffer, rows_arg, columns_arg);
1269 SetLongTabular(is_long_tabular_arg);
1270 SetRotateTabular(rotate_arg);
1272 for (i = 0; i < rows_; ++i) {
1275 for (i = 0; i < columns_; ++i) {
1278 for (i = 0; i < rows_; ++i) {
1279 for (j = 0; j < columns_; ++j) {
1283 set_row_column_number_info();
1286 is >> rows_arg >> columns_arg >> is_long_tabular_arg
1287 >> rotate_arg >> a >> b >> c >> d;
1288 Init(buffer, rows_arg, columns_arg);
1289 SetLongTabular(is_long_tabular_arg);
1290 SetRotateTabular(rotate_arg);
1295 for (i = 0; i < rows_; ++i) {
1296 a = b = c = d = e = f = g = h = 0;
1297 is >> a >> b >> c >> d;
1298 row_info[i].top_line = a;
1299 row_info[i].bottom_line = b;
1300 // row_info[i].is_cont_row = c;
1301 row_info[i].newpage = d;
1303 for (i = 0; i < columns_; ++i) {
1307 char ch; // skip '"'
1309 getline(is, s1, '"');
1310 is >> ch; // skip '"'
1311 getline(is, s2, '"');
1312 column_info[i].alignment = static_cast<char>(a);
1313 column_info[i].left_line = b;
1314 column_info[i].right_line = c;
1315 column_info[i].p_width = s1;
1316 column_info[i].align_special = s2;
1318 for (i = 0; i < rows_; ++i) {
1319 for (j = 0; j < columns_; ++j) {
1322 is >> a >> b >> c >> d >> e >> f >> g;
1324 is >> ch; // skip '"'
1325 getline(is, s1, '"');
1326 is >> ch; // skip '"'
1327 getline(is, s2, '"');
1328 cell_info[i][j].multicolumn = static_cast<char>(a);
1329 cell_info[i][j].alignment = static_cast<char>(b);
1330 cell_info[i][j].top_line = static_cast<char>(c);
1331 cell_info[i][j].bottom_line = static_cast<char>(d);
1332 // cell_info[i][j].has_cont_row = static_cast<bool>(e);
1333 cell_info[i][j].rotate = static_cast<bool>(f);
1334 cell_info[i][j].linebreaks = static_cast<bool>(g);
1335 cell_info[i][j].align_special = s1;
1336 cell_info[i][j].p_width = s2;
1339 set_row_column_number_info();
1343 // cell < 0 will tex the preamble
1344 // returns the number of printed newlines
1345 int LyXTabular::TexEndOfCell(ostream & os, int cell) const
1351 if (IsLastCell(cell)) {
1352 // the very end at the very beginning
1353 if (GetLinebreaks(cell))
1354 os << "\\smallskip{}}";
1355 if (IsMultiColumn(cell))
1357 if (GetRotateCell(cell)) {
1358 os << "\n\\end{sideways}";
1366 while (!IsFirstCellInRow(fcell)) --fcell;
1367 for (i = 0; i < NumberOfCellsInRow(fcell); ++i) {
1368 if (BottomLine(fcell + i))
1371 if (tmp == NumberOfCellsInRow(fcell)) {
1375 for (i = 0; i < NumberOfCellsInRow(fcell); ++i) {
1376 if (BottomLine(fcell + i)) {
1378 << column_of_cell(fcell + i) + 1
1380 << right_column_of_cell(fcell + i) + 1
1390 if (is_long_tabular)
1391 os << "\\end{longtable}";
1393 os << "\\end{tabular}";
1395 os << "\n\\end{sideways}";
1403 os << "\\begin{sideways}\n";
1406 if (is_long_tabular)
1407 os << "\\begin{longtable}{";
1409 os << "\\begin{tabular}{";
1410 for (i = 0; i < columns_; ++i) {
1411 if (column_info[i].left_line)
1413 if (!column_info[i].align_special.empty()) {
1414 os << column_info[i].align_special;
1415 } else if (!column_info[i].p_width.empty()) {
1417 << column_info[i].p_width
1420 switch (column_info[i].alignment) {
1421 case LYX_ALIGN_LEFT:
1424 case LYX_ALIGN_RIGHT:
1432 if (column_info[i].right_line)
1438 if (GetNumberOfCells()) {
1440 for (i = 0; i < NumberOfCellsInRow(fcell); ++i) {
1441 if (TopLine(fcell + i))
1444 if (tmp == NumberOfCellsInRow(fcell)){
1448 for (i = 0; i < NumberOfCellsInRow(fcell); ++i) {
1449 if (TopLine(fcell + i)) {
1451 << column_of_cell(fcell + i) + 1
1453 << right_column_of_cell(fcell + i) + 1
1464 if (GetRotateCell(0)) {
1465 os << "\\begin{sideways}\n";
1470 if (GetLinebreaks(cell))
1471 os << "\\smallskip{}}";
1472 if (IsMultiColumn(cell)){
1475 if (GetRotateCell(cell)) {
1476 os << "\n\\end{sideways}";
1479 if (IsLastCellInRow(cell)) {
1480 int row = row_of_cell(cell);
1481 string hline1, hline2;
1482 bool print_hline = true;
1483 bool flag1 = IsLongTabular() &&
1484 ((row == endhead) || (row == endfirsthead) ||
1485 (row == endfoot) || (row == endlastfoot));
1487 bool flag2 = IsLongTabular() &&
1488 ((row <= endhead) || (row <= endfirsthead) ||
1489 (row <= endfoot) || (row <= endlastfoot));
1491 // print the bottom hline only if (otherwise it is doubled):
1492 // - is no LongTabular
1493 // - there IS a first-header
1494 // - the next row is no special header/footer
1495 // & this row is no special header/footer
1496 // - the next row is a special header/footer
1497 // & this row is a special header/footer
1498 bool pr_top_hline = (flag1 && flag2) || (!flag1 && !flag2) ||
1499 (endfirsthead == endhead);
1504 while (!IsFirstCellInRow(fcell))
1506 for (i = 0; i < NumberOfCellsInRow(cell); ++i) {
1507 if (BottomLine(fcell + i))
1510 if (tmp == NumberOfCellsInRow(cell)){
1512 hline1 = "\\hline ";
1515 for (i = 0; i < NumberOfCellsInRow(fcell); ++i) {
1516 if (BottomLine(fcell + i)){
1518 << column_of_cell(fcell + i) + 1
1520 << right_column_of_cell(fcell + i) + 1
1522 hline1 += "\\cline{";
1523 hline1 += tostr(column_of_cell(fcell + i) + 1);
1525 hline1 += tostr(right_column_of_cell(fcell + i) + 1);
1535 if (IsLongTabular() && (row == endfoot)) {
1536 os << "\\endfoot\n";
1538 print_hline = false; // no double line below footer
1540 if (IsLongTabular() && (row == endlastfoot)) {
1541 os << "\\endlastfoot\n";
1543 print_hline = false; // no double line below footer
1545 if (IsLongTabular() && row_info[row].newpage) {
1546 os << "\\newpage\n";
1548 print_hline = false; // no line below a \\newpage-command
1551 if ((nvcell < numberofcells) &&
1552 (cell < GetNumberOfCells() - 1) && !IsLastCell(cell)) {
1554 for (i = 0; i < NumberOfCellsInRow(fcell); ++i) {
1555 if (TopLine(fcell + i))
1558 if (tmp == NumberOfCellsInRow(fcell)) {
1561 hline2 = "\\hline ";
1564 for (i = 0; i < NumberOfCellsInRow(fcell); ++i) {
1565 if (TopLine(fcell + i)) {
1568 << column_of_cell(fcell + i) + 1
1570 << right_column_of_cell(fcell + i) + 1
1573 hline2 += "\\cline{";
1574 hline2 += tostr(column_of_cell(fcell+i)+1);
1576 hline2 += tostr(right_column_of_cell(fcell+i)+1);
1582 if (tmp && print_hline){
1587 // the order here is important as if one defines two
1588 // or more things in one line only the first entry is
1589 // displayed the other are set to an empty-row. This
1590 // is important if I have a footer and want that the
1591 // lastfooter is NOT displayed!!!
1592 bool sflag2 = (row == endhead) || (row == endfirsthead) ||
1593 (row == endfoot) || (row == endlastfoot);
1596 bool sflag1 = IsLongTabular() && (row != endhead) &&
1597 (row != endfirsthead) &&
1598 ((row == endfoot) || (row == endlastfoot));
1600 if (IsLongTabular() && (row == endhead)) {
1601 os << "\\endhead\n";
1604 if (IsLongTabular() && (row == endfirsthead)) {
1605 os << "\\endfirsthead\n";
1608 if (sflag1) { // add the \hline for next foot row
1609 if (!hline1.empty()) {
1610 os << hline1 + '\n';
1614 // add the \hline for the first row
1615 if (pr_top_hline && sflag2) {
1616 if (!hline2.empty()) {
1617 os << hline2 + '\n';
1621 if (nvcell < numberofcells && GetRotateCell(nvcell)) {
1622 os << "\\begin{sideways}\n";
1628 if (nvcell < numberofcells && GetRotateCell(nvcell)) {
1629 os << "\\begin{sideways}\n";
1634 if (nvcell < numberofcells && IsMultiColumn(nvcell)) {
1635 os << "\\multicolumn{"
1636 << cells_in_multicolumn(nvcell)
1638 if (!cellinfo_of_cell(cell+1)->align_special.empty()) {
1639 os << cellinfo_of_cell(cell+1)->align_special
1642 if (LeftLine(nvcell))
1644 if (!GetPWidth(nvcell).empty()) {
1646 << GetPWidth(nvcell)
1649 switch (GetAlignment(nvcell)) {
1650 case LYX_ALIGN_LEFT: os << 'l'; break;
1651 case LYX_ALIGN_RIGHT: os << 'r'; break;
1652 default: os << 'c'; break;
1655 if (RightLine(nvcell))
1657 //if (column_of_cell(cell+2)!= 0 && LeftLine(cell+2))
1658 if (((nvcell + 1) < numberofcells) &&
1659 ((nvcell+1) < numberofcells) &&
1660 (column_of_cell(nvcell+1)!= 0) &&
1667 if (nvcell < numberofcells && GetLinebreaks(nvcell)) {
1668 os << "\\parbox[t]{"
1669 << GetPWidth(nvcell)
1670 << "}{\\smallskip{}";
1678 // cell <0 will tex the preamble
1679 // returns the number of printed newlines
1680 int LyXTabular::RoffEndOfCell(ostream & os, int cell)
1684 if (cell == GetNumberOfCells() - 1){
1685 // the very end at the very beginning
1686 // if (CellHasContRow(cell) >= 0) {
1692 if (row_info[row_of_cell(cell)].bottom_line) {
1696 os << ".TE\n.pl 1c";
1701 os << "\n.pl 500c\n.TS\n";
1702 for (int j = 0; j < rows_; ++j) {
1703 for (int i = 0; i < columns_; ++i, ++fcell) {
1704 if (column_info[i].left_line)
1706 if (cell_info[j][i].multicolumn == CELL_PART_OF_MULTICOLUMN)
1709 switch (column_info[i].alignment) {
1710 case LYX_ALIGN_LEFT:
1713 case LYX_ALIGN_RIGHT:
1721 if (!column_info[i].p_width.empty())
1722 os << "w(" << column_info[i].p_width << ")";
1723 if (column_info[i].right_line)
1726 if ((j + 1) < rows_) {
1733 if (row_info[0].top_line) {
1737 // if (CellHasContRow(0) >= 0) {
1743 // if (CellHasContRow(cell) >= 0) {
1747 if (right_column_of_cell(cell) == columns_ -1){
1750 int row = row_of_cell(cell);
1751 if (row_info[row++].bottom_line) {
1755 if ((row < rows_) && row_info[row].top_line) {
1761 // if ((cell < GetNumberOfCells() - 1) &&
1762 // (CellHasContRow(cell+1) >= 0)) {
1773 char const * LyXTabular::GetDocBookAlign(int cell, bool isColumn) const
1775 int i = isColumn ? cell : column_of_cell(cell);
1780 //i = column_of_cell(cell);
1781 if (!isColumn && IsMultiColumn(cell)) {
1782 if (!cellinfo_of_cell(cell)->align_special.empty()) {
1783 return cellinfo_of_cell(cell)->align_special.c_str();
1785 switch (GetAlignment(cell)) {
1786 case LYX_ALIGN_LEFT:
1788 case LYX_ALIGN_RIGHT:
1795 if (!column_info[i].align_special.empty()) {
1796 return column_info[i].align_special.c_str();
1798 #ifdef IGNORE_THIS_FOR_NOW
1799 else if (!column_info[i].p_width.empty()) {
1801 file += column_info[i].p_width;
1806 switch (column_info[i].alignment) {
1807 case LYX_ALIGN_LEFT:
1809 case LYX_ALIGN_RIGHT:
1819 // cell <0 will tex the preamble
1820 // returns the number of printed newlines
1821 int LyXTabular::DocBookEndOfCell(ostream & os, int cell, int & depth) const
1825 //int tmp; // tmp2; // unused
1826 int nvcell; // fcell; // unused
1827 if (IsLastCell(cell)) {
1828 os << newlineAndDepth(--depth)
1830 << newlineAndDepth(--depth)
1832 << newlineAndDepth(--depth)
1834 << newlineAndDepth(--depth);
1835 if (is_long_tabular)
1839 << newlineAndDepth(--depth);
1845 if (is_long_tabular)
1851 << "' COLSEP='1' ROWSEP='1'>"
1852 << newlineAndDepth(++depth);
1854 for (i = 0; i < columns_; ++i) {
1855 os << "<COLSPEC ALIGN='"
1856 << GetDocBookAlign(i, true)
1862 if (i == (columns_-1)) {
1865 if (column_info[i].right_line ||
1866 column_info[i+1].left_line)
1872 << newlineAndDepth(depth);
1874 #ifdef NOT_HANDLED_YET_AS_I_DONT_KNOW_HOW
1875 if (column_info[i].left_line)
1880 << newlineAndDepth(++depth)
1882 << newlineAndDepth(++depth)
1884 << GetDocBookAlign(0)
1886 if (IsMultiColumn(0)) {
1887 os << " NAMEST='col1' NAMEEND='col"
1888 << cells_in_multicolumn(0)
1892 << newlineAndDepth(++depth);
1895 if (IsLastCellInRow(cell)) {
1896 os << newlineAndDepth(--depth)
1898 << newlineAndDepth(--depth)
1900 << newlineAndDepth(depth)
1902 << newlineAndDepth(++depth)
1904 << GetDocBookAlign(cell + 1)
1905 << "' VALIGN='middle'";
1906 if (IsMultiColumn(cell + 1)) {
1907 os << " NAMEST='col"
1908 << column_of_cell(cell+1) + 1
1910 << column_of_cell(cell + 1) +
1911 cells_in_multicolumn(cell + 1)
1915 << newlineAndDepth(++depth);
1918 os << newlineAndDepth(--depth)
1920 << newlineAndDepth(depth)
1922 << GetDocBookAlign(cell + 1)
1923 << "' VALIGN='middle'";
1924 if (IsMultiColumn(cell + 1)) {
1925 os << " NAMEST='col"
1926 << column_of_cell(cell+1) + 1
1928 << column_of_cell(cell+1) +
1929 cells_in_multicolumn(cell+1)
1933 << newlineAndDepth(++depth);
1942 bool LyXTabular::IsMultiColumn(int cell) const
1944 return (cellinfo_of_cell(cell)->multicolumn != LyXTabular::CELL_NORMAL);
1948 LyXTabular::cellstruct * LyXTabular::cellinfo_of_cell(int cell) const
1950 int row = row_of_cell(cell);
1951 int column = column_of_cell(cell);
1952 return &cell_info[row][column];
1956 void LyXTabular::SetMultiColumn(int cell, int number)
1958 int new_width = cellinfo_of_cell(cell)->width_of_cell;
1960 cellinfo_of_cell(cell)->multicolumn = LyXTabular::CELL_BEGIN_OF_MULTICOLUMN;
1961 cellinfo_of_cell(cell)->alignment = column_info[column_of_cell(cell)].alignment;
1962 cellinfo_of_cell(cell)->top_line = row_info[row_of_cell(cell)].top_line;
1963 cellinfo_of_cell(cell)->bottom_line = row_info[row_of_cell(cell)].bottom_line;
1964 for (number--; number > 0; --number) {
1965 cellinfo_of_cell(cell+number)->multicolumn =
1966 LyXTabular::CELL_PART_OF_MULTICOLUMN;
1967 new_width += cellinfo_of_cell(cell+number)->width_of_cell;
1969 set_row_column_number_info();
1970 SetWidthOfCell(cell, new_width);
1974 int LyXTabular::cells_in_multicolumn(int cell) const
1976 int row = row_of_cell(cell);
1977 int column = column_of_cell(cell);
1980 while (column < columns_ && cell_info[row][column].multicolumn
1981 == LyXTabular::CELL_PART_OF_MULTICOLUMN){
1989 int LyXTabular::UnsetMultiColumn(int cell)
1991 int row = row_of_cell(cell);
1992 int column = column_of_cell(cell);
1996 if (cell_info[row][column].multicolumn
1997 == LyXTabular::CELL_BEGIN_OF_MULTICOLUMN){
1998 cell_info[row][column].multicolumn = LyXTabular::CELL_NORMAL;
2000 while (column < columns_ &&
2001 cell_info[row][column].multicolumn
2002 == LyXTabular::CELL_PART_OF_MULTICOLUMN){
2003 cell_info[row][column].multicolumn =
2004 LyXTabular::CELL_NORMAL;
2009 set_row_column_number_info();
2014 void LyXTabular::SetLongTabular(int what)
2016 is_long_tabular = what;
2020 bool LyXTabular::IsLongTabular() const
2022 return is_long_tabular;
2026 void LyXTabular::SetRotateTabular(int what)
2032 bool LyXTabular::GetRotateTabular() const
2038 void LyXTabular::SetRotateCell(int cell, int what)
2040 cellinfo_of_cell(cell)->rotate = what;
2044 bool LyXTabular::GetRotateCell(int cell) const
2046 return cellinfo_of_cell(cell)->rotate;
2050 bool LyXTabular::NeedRotating() const
2054 for (int i = 0; i < rows_; ++i) {
2055 for (int j = 0; j < columns_; ++j) {
2056 if (cell_info[i][j].rotate)
2064 bool LyXTabular::IsLastCell(int cell) const
2066 if (cell < GetNumberOfCells())
2072 int LyXTabular::GetCellAbove(int cell) const
2074 if (row_of_cell(cell) > 0)
2075 return cell_info[row_of_cell(cell)-1][column_of_cell(cell)].cellno;
2080 int LyXTabular::GetCellNumber(int column, int row) const
2082 if (column >= columns_)
2083 column = columns_ - 1;
2084 else if (column < 0)
2091 return cell_info[row][column].cellno;
2095 void LyXTabular::SetLinebreaks(int cell, bool what)
2097 cellinfo_of_cell(cell)->linebreaks = what;
2101 bool LyXTabular::GetLinebreaks(int cell) const
2103 if (column_info[column_of_cell(cell)].p_width.empty() &&
2104 !(IsMultiColumn(cell) && !cellinfo_of_cell(cell)->p_width.empty()))
2106 return cellinfo_of_cell(cell)->linebreaks;
2110 void LyXTabular::SetLTHead(int cell, bool first)
2112 int row = row_of_cell(cell);
2115 if (row == endfirsthead)
2128 bool LyXTabular::GetRowOfLTHead(int cell) const
2130 if ((endhead+1) > rows_)
2132 return (row_of_cell(cell) == endhead);
2136 bool LyXTabular::GetRowOfLTFirstHead(int cell) const
2138 if ((endfirsthead+1) > rows_)
2140 return (row_of_cell(cell) == endfirsthead);
2144 void LyXTabular::SetLTFoot(int cell, bool last)
2146 int row = row_of_cell(cell);
2149 if (row == endlastfoot)
2162 bool LyXTabular::GetRowOfLTFoot(int cell) const
2164 if ((endfoot+1) > rows_)
2166 return (row_of_cell(cell) == endfoot);
2169 bool LyXTabular::GetRowOfLTLastFoot(int cell) const
2171 if ((endlastfoot+1) > rows_)
2173 return (row_of_cell(cell) == endlastfoot);
2177 void LyXTabular::SetLTNewPage(int cell, bool what)
2179 row_info[row_of_cell(cell)].newpage = what;
2183 bool LyXTabular::GetLTNewPage(int cell) const
2185 return row_info[row_of_cell(cell)].newpage;
2189 void LyXTabular::SetAscentOfRow(int row, int height)
2193 row_info[row].ascent_of_row = height;
2197 void LyXTabular::SetDescentOfRow(int row, int height)
2201 row_info[row].descent_of_row = height;
2205 int LyXTabular::GetAscentOfRow(int row) const
2209 return row_info[row].ascent_of_row;
2213 int LyXTabular::GetDescentOfRow(int row) const
2217 return row_info[row].descent_of_row;
2221 int LyXTabular::GetHeightOfTabular() const
2225 for(int row = 0; row < rows_; ++row)
2226 height += GetAscentOfRow(row) + GetDescentOfRow(row) +
2227 GetAdditionalHeight(GetCellNumber(0, row));
2232 bool LyXTabular::IsPartOfMultiColumn(int row, int column) const
2234 if ((row >= rows_) || (column >= columns_))
2236 return (cell_info[row][column].multicolumn==CELL_PART_OF_MULTICOLUMN);
2240 int LyXTabular::Latex(ostream &) const
2246 InsetText * LyXTabular::GetCellInset(int cell) const
2248 return cell_info[row_of_cell(cell)][column_of_cell(cell)].inset;