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"
35 static int const WIDTH_OF_LINE = 5;
37 /// Define a few methods for the inner structs
39 LyXTabular::cellstruct::cellstruct()
41 cellno = 0; //should be initilaized correctly later.
43 multicolumn = LyXTabular::CELL_NORMAL;
44 alignment = LYX_ALIGN_CENTER;
52 LyXTabular::cellstruct::~cellstruct()
57 LyXTabular::cellstruct &
58 LyXTabular::cellstruct::operator=(cellstruct const & cs)
61 width_of_cell = cs.width_of_cell;
62 multicolumn = cs.multicolumn;
63 alignment = cs.alignment;
64 top_line = cs.top_line;
65 bottom_line = cs.bottom_line;
67 linebreaks = cs.linebreaks;
71 LyXTabular::rowstruct::rowstruct()
80 // Nothing to do, but gcc 2.7.2.3 wants one... (JMarc)
81 LyXTabular::rowstruct::~rowstruct()
85 LyXTabular::rowstruct &
86 LyXTabular::rowstruct::operator=(rowstruct const & rs)
88 top_line = rs.top_line;
89 bottom_line = rs.bottom_line;
90 ascent_of_row = rs.ascent_of_row;
91 descent_of_row = rs.descent_of_row;
96 LyXTabular::columnstruct::columnstruct()
100 alignment = LYX_ALIGN_CENTER;
104 LyXTabular::columnstruct::~columnstruct()
108 LyXTabular::columnstruct &
109 LyXTabular::columnstruct::operator=(columnstruct const & cs)
111 left_line = cs.left_line;
112 right_line = cs.right_line;
113 alignment = cs.alignment;
114 width_of_column = cs.width_of_column;
115 p_width = cs.p_width;
116 align_special = cs.align_special;
121 LyXTabular::LyXTabular(int rows_arg, int columns_arg, Buffer *buf)
124 Init(buf, rows_arg, columns_arg);
128 LyXTabular::LyXTabular(LyXTabular const & lt, Buffer * buf)
131 Init(buf, lt.rows_, lt.columns_);
136 LyXTabular::LyXTabular(LyXLex & lex, Buffer *buf)
143 LyXTabular::~LyXTabular()
146 delete[] columnofcell;
147 // delete[] column_info;
148 // delete[] row_info;
149 // for (int i = 0; i < rows_; ++i) {
150 // delete[] cell_info[i];
152 // delete[] cell_info;
156 LyXTabular & LyXTabular::operator=(LyXTabular const & lt)
158 // If this and lt is not of the same size we have a serious bug
159 // So then it is ok to throw an exception, or for now
161 Assert(rows_ == lt.rows_ && columns_ == lt.columns_);
163 int row = 0, column = 0;
165 for (row = 0; row < rows_; ++row) {
166 for (column = 0; column < columns_; ++column) {
167 cell_info[row][column] = lt.cell_info[row][column];
171 for (row = 0; row < rows_; ++row) {
172 row_info[row] = lt.row_info[row];
175 for (column = 0; column < columns_; ++column) {
176 column_info[column] = lt.column_info[column];
179 SetLongTabular(lt.is_long_tabular);
186 LyXTabular * LyXTabular::Clone(Buffer * buf)
188 LyXTabular * result = new LyXTabular(rows_, columns_, buf);
191 for (row = 0; row < rows_; ++row) {
192 for (column = 0; column < columns_; ++column) {
193 result->cell_info[row][column] = cell_info[row][column];
197 for (row = 0; row < rows_; ++row) {
198 result->row_info[row] = row_info[row];
201 for (column = 0; column < columns_; ++column) {
202 result->column_info[column].left_line = column_info[column].left_line;
203 result->column_info[column].right_line = column_info[column].right_line;
204 result->column_info[column].alignment = column_info[column].alignment;
205 result->column_info[column].p_width = column_info[column].p_width;
206 result->column_info[column].align_special = column_info[column].align_special;
209 result->SetLongTabular(is_long_tabular);
210 result->rotate = rotate;
216 /* activates all lines and sets all widths to 0 */
217 void LyXTabular::Init(Buffer * buf, int rows_arg, int columns_arg)
223 columns_ = columns_arg;
224 row_info = vector<rowstruct>(rows_, rowstruct());
225 column_info = vector<columnstruct>(columns_, columnstruct());
226 cell_info = vector<vector<cellstruct> >
227 (rows_, vector<cellstruct>(columns_, cellstruct()));
229 for (i = 0; i < rows_; ++i) {
230 for (j = 0; j < columns_; ++j) {
231 cell_info[i][j].inset = new InsetText(buf);
232 cell_info[i][j].cellno = cellno++;
235 row_info[i-1].bottom_line = true;
236 row_info[0].bottom_line = true;
238 for (i = 0; i < columns_; ++i) {
239 calculate_width_of_column(i);
241 column_info[columns_-1].right_line = true;
243 calculate_width_of_tabular();
247 set_row_column_number_info();
248 is_long_tabular = false;
257 void LyXTabular::AppendRow(int /* cell */)
260 int row = row_of_cell(cell);
261 rowstruct * row_info2 = new rowstruct[rows_ + 1];
262 cellstruct ** cell_info2 = new cellstruct * [rows_ + 1];
265 for (i = 0; i <= row; ++i) {
266 cell_info2[i] = cell_info[i];
267 row_info2[i] = row_info[i];
269 for (i = rows_ - 1; i >= row; --i) {
270 cell_info2[i + 1] = cell_info[i];
271 row_info2[i + 1] = row_info[i];
273 row_info2[row + 1].top_line = row_info[i].top_line;
274 cell_info2[row + 1] = new cellstruct[columns_](buffer);
275 for (i = 0; i < columns_; ++i) {
276 cell_info2[row + 1][i].width_of_cell = 0;
277 cell_info2[row + 1][i] = cell_info2[row][i];
281 cell_info = cell_info2;
283 row_info = row_info2;
292 void LyXTabular::DeleteRow(int /*cell*/)
295 int row = row_of_cell(cell);
296 rowstruct * row_info2 = new rowstruct[rows_ - 1];
297 cellstruct ** cell_info2 = new cellstruct * [rows_ - 1];
299 delete[] cell_info[row];
301 for (; i < row; ++i) {
302 cell_info2[i] = cell_info[i];
303 row_info2[i] = row_info[i];
305 for (i = row; i < rows_ - 1; ++i) {
306 cell_info2[i] = cell_info[i + 1];
307 row_info2[i] = row_info[i + 1];
311 cell_info = cell_info2;
313 row_info = row_info2;
322 void LyXTabular::AppendColumn(int /*cell*/)
326 columnstruct * column_info2 = new columnstruct[columns_ + 1];
327 int column = right_column_of_cell(cell);
330 for (; i <= column; ++i) {
331 column_info2[i] = column_info[i];
333 for (i = columns_ - 1; i >= column; --i) {
334 column_info2[i + 1] = column_info[i];
337 delete[] column_info;
338 column_info = column_info2;
340 for (i = 0; i < rows_; ++i) {
341 cellstruct * tmp = cell_info[i];
342 cell_info[i] = new cellstruct[columns_ + 1](buffer);
343 for (j = 0; j <= column; ++j) {
344 cell_info[i][j] = tmp[j];
346 for (j = column; j < columns_; ++j) {
347 cell_info[i][j + 1] = tmp[j];
349 // care about multicolumns
350 if (cell_info[i][column + 1].multicolumn
351 == LyXTabular::CELL_BEGIN_OF_MULTICOLUMN){
352 cell_info[i][column + 1].multicolumn =
353 LyXTabular::CELL_PART_OF_MULTICOLUMN;
355 if (column + 1 == columns_
356 || cell_info[i][column + 2].multicolumn
357 != LyXTabular::CELL_PART_OF_MULTICOLUMN){
358 cell_info[i][column + 1].multicolumn =
359 LyXTabular::CELL_NORMAL;
370 void LyXTabular::DeleteColumn(int /*cell*/)
373 int column1 = column_of_cell(cell);
374 int column2 = right_column_of_cell(cell);
376 if (column1 == 0 && column2 == columns_ - 1)
379 for (int column = column1; column <= column2; ++column) {
380 delete_column(column1);
387 void LyXTabular::delete_column(int /*column*/)
391 columnstruct * column_info2 = new columnstruct[columns_-1];
393 for (i = 0; i < column; ++i) {
394 column_info2[i] = column_info[i];
396 for (i = column; i < columns_ - 1; ++i) {
397 column_info2[i] = column_info[i + 1];
400 delete[] column_info;
401 column_info = column_info2;
403 for (i = 0; i < rows_; ++i) {
404 cellstruct * tmp = cell_info[i];
405 cell_info[i] = new cellstruct[columns_ - 1](buffer);
406 for (j = 0; j < column; ++j) {
407 cell_info[i][j] = tmp[j];
409 for (j = column; j < columns_ - 1; ++j) {
410 cell_info[i][j] = tmp[j + 1];
421 void LyXTabular::Reinit()
426 for (; i < rows_; ++i) {
427 for (j = 0; j < columns_; ++j) {
428 cell_info[i][j].width_of_cell = 0;
432 for (i = 0; i < columns_; ++i) {
433 calculate_width_of_column(i);
435 calculate_width_of_tabular();
437 set_row_column_number_info();
441 void LyXTabular::set_row_column_number_info()
447 for (; row < rows_; ++row) {
448 for (column = 0; column<columns_; ++column) {
449 if (cell_info[row][column].multicolumn
450 != LyXTabular::CELL_PART_OF_MULTICOLUMN)
452 cell_info[row][column].cellno = numberofcells;
455 ++numberofcells; // because this is one more than as we start from 0
460 rowofcell = new int[numberofcells];
461 delete [] columnofcell;
462 columnofcell = new int[numberofcells];
464 while (c < numberofcells && row < rows_ && column < columns_) {
466 columnofcell[c] = column;
470 } while (column < columns_ &&
471 cell_info[row][column].multicolumn
472 == LyXTabular::CELL_PART_OF_MULTICOLUMN);
473 if (column == columns_) {
480 int LyXTabular::GetNumberOfCells() const
482 return numberofcells;
486 int LyXTabular::NumberOfCellsInRow(int cell) const
488 int row = row_of_cell(cell);
490 for (int i = 0; i < columns_; ++i) {
491 if (cell_info[row][i].multicolumn != LyXTabular::CELL_PART_OF_MULTICOLUMN)
498 int LyXTabular::AppendCellAfterCell(int append_cell, int question_cell)
500 return (right_column_of_cell(append_cell) ==
501 right_column_of_cell(question_cell));
505 int LyXTabular::DeleteCellIfColumnIsDeleted(int cell, int delete_column_cell)
507 if (column_of_cell(delete_column_cell) == 0 &&
508 right_column_of_cell(delete_column_cell) == columns_ - 1)
512 (column_of_cell(cell) >= column_of_cell(delete_column_cell) &&
513 column_of_cell(cell) <= right_column_of_cell(delete_column_cell));
517 /* returns 1 if there is a topline, returns 0 if not */
518 bool LyXTabular::TopLine(int cell) const
520 int row = row_of_cell(cell);
522 if (IsMultiColumn(cell))
523 return cellinfo_of_cell(cell)->top_line;
524 return row_info[row].top_line;
528 bool LyXTabular::BottomLine(int cell) const
530 //no bottom line underneath non-existent cells if you please
531 if(cell >= numberofcells)
534 if (IsMultiColumn(cell))
535 return cellinfo_of_cell(cell)->bottom_line;
536 return row_info[row_of_cell(cell)].bottom_line;
540 bool LyXTabular::LeftLine(int cell) const
542 return column_info[column_of_cell(cell)].left_line;
546 bool LyXTabular::RightLine(int cell) const
548 return column_info[right_column_of_cell(cell)].right_line;
552 bool LyXTabular::TopAlreadyDrawed(int cell) const
554 if (GetAdditionalHeight(cell))
556 int row = row_of_cell(cell);
558 int column = column_of_cell(cell);
561 && cell_info[row][column].multicolumn
562 == LyXTabular::CELL_PART_OF_MULTICOLUMN)
564 if (cell_info[row][column].multicolumn == LyXTabular::CELL_NORMAL)
565 return row_info[row].bottom_line;
567 return cell_info[row][column].bottom_line;
573 bool LyXTabular::LeftAlreadyDrawed(int cell) const
575 int column = column_of_cell(cell);
577 int row = row_of_cell(cell);
579 (cell_info[row][column].multicolumn ==
580 LyXTabular::CELL_PART_OF_MULTICOLUMN));
581 if (GetAdditionalWidth(cell_info[row][column].cellno))
583 return column_info[column].right_line;
589 bool LyXTabular::IsLastRow(int cell) const
591 return (row_of_cell(cell) == rows_ - 1);
595 int LyXTabular::GetAdditionalHeight(int cell) const
597 int row = row_of_cell(cell);
600 int top = 1; // bool top = true; ??
601 int bottom = 1; // bool bottom = true; ??
604 for (column = 0; column < columns_ - 1 && bottom; ++column) {
605 switch (cell_info[row - 1][column].multicolumn) {
606 case LyXTabular::CELL_BEGIN_OF_MULTICOLUMN:
607 bottom = cell_info[row - 1][column].bottom_line;
609 case LyXTabular::CELL_NORMAL:
610 bottom = row_info[row - 1].bottom_line;
613 for (column = 0; column < columns_ - 1 && top; ++column) {
614 switch (cell_info[row][column].multicolumn){
615 case LyXTabular::CELL_BEGIN_OF_MULTICOLUMN:
616 top = cell_info[row][column].top_line;
618 case LyXTabular::CELL_NORMAL:
619 top = row_info[row].top_line;
623 return WIDTH_OF_LINE;
628 int LyXTabular::GetAdditionalWidth(int cell) const
630 // internally already set in SetWidthOfCell
631 // used to get it back in text.C
632 int col = right_column_of_cell(cell);
633 if (col < columns_ - 1 && column_info[col].right_line &&
634 column_info[col+1].left_line)
635 return WIDTH_OF_LINE;
641 // returns the maximum over all rows
642 int LyXTabular::GetWidthOfColumn(int cell) const
644 int column1 = column_of_cell(cell);
645 int column2 = right_column_of_cell(cell);
648 for (; i <= column2; ++i) {
649 result += column_info[i].width_of_column;
655 int LyXTabular::GetWidthOfTabular() const
657 return width_of_tabular;
660 /* returns 1 if a complete update is necessary, otherwise 0 */
661 bool LyXTabular::SetWidthOfMulticolCell(int cell, int new_width)
663 if (!IsMultiColumn(cell))
666 int row = row_of_cell(cell);
667 int column1 = column_of_cell(cell);
668 int column2 = right_column_of_cell(cell);
670 // first set columns to 0 so we can calculate the right width
672 for (; i <= column2; ++i) {
673 cell_info[row][i].width_of_cell = 0;
675 // set the width to MAX_WIDTH until width > 0
676 int width = (new_width + 2 * WIDTH_OF_LINE);
677 for (i = column1; (i < column2) && (width > 0); ++i) {
678 cell_info[row][i].width_of_cell = column_info[i].width_of_column;
679 width -= column_info[i].width_of_column;
682 cell_info[row][i].width_of_cell = width;
688 void LyXTabular::recalculateMulticolCells(int cell, int new_width)
690 int row = row_of_cell(cell);
691 int column1 = column_of_cell(cell);
692 int column2 = right_column_of_cell(cell);
694 // first set columns to 0 so we can calculate the right width
696 for (; i <= column2; ++i)
697 cell_info[row][i].width_of_cell = 0;
698 for(i = cell + 1; (i < numberofcells) && (!IsMultiColumn(i)); ++i)
700 if (i < numberofcells)
701 recalculateMulticolCells(i, GetWidthOfCell(i) - (2 * WIDTH_OF_LINE));
702 SetWidthOfMulticolCell(cell, new_width);
706 /* returns 1 if a complete update is necessary, otherwise 0 */
707 bool LyXTabular::SetWidthOfCell(int cell, int new_width)
709 int row = row_of_cell(cell);
710 int column1 = column_of_cell(cell);
714 if (IsMultiColumn(cell)) {
715 tmp = SetWidthOfMulticolCell(cell, new_width);
717 width = (new_width + 2*WIDTH_OF_LINE);
718 cell_info[row][column1].width_of_cell = width;
719 if (column_info[column1].right_line && (column1 < columns_-1) &&
720 column_info[column1+1].left_line) // additional width
721 cell_info[row][column1].width_of_cell += WIDTH_OF_LINE;
722 tmp = calculate_width_of_column_NMC(column1);
726 for(i = 0; i<columns_;++i)
727 calculate_width_of_column_NMC(i);
728 for(i = 0; (i<numberofcells) && !IsMultiColumn(i); ++i)
731 recalculateMulticolCells(i, GetWidthOfCell(i)-(2*WIDTH_OF_LINE));
732 for(i = 0; i<columns_;++i)
733 calculate_width_of_column(i);
734 calculate_width_of_tabular();
741 bool LyXTabular::SetAlignment(int cell, char align)
743 if (!IsMultiColumn(cell))
744 column_info[column_of_cell(cell)].alignment = align;
745 cellinfo_of_cell(cell)->alignment = align;
749 bool LyXTabular::SetPWidth(int cell, string width)
751 if (IsMultiColumn(cell)) {
752 cellinfo_of_cell(cell)->p_width = width;
754 column_info[column_of_cell(cell)].p_width = width;
755 if (!width.empty()) // do this only if there is a width
756 SetAlignment(cell, LYX_ALIGN_LEFT);
761 bool LyXTabular::SetAlignSpecial(int cell, string special, int what)
763 if (what == SET_SPECIAL_MULTI)
764 cellinfo_of_cell(cell)->align_special = special;
766 column_info[column_of_cell(cell)].align_special = special;
770 bool LyXTabular::SetAllLines(int cell, bool line)
772 SetTopLine(cell, line);
773 SetBottomLine(cell, line);
774 SetRightLine(cell, line);
775 SetLeftLine(cell, line);
779 bool LyXTabular::SetTopLine(int cell, bool line)
781 int row = row_of_cell(cell);
783 if (!IsMultiColumn(cell))
784 row_info[row].top_line = line;
786 cellinfo_of_cell(cell)->top_line = line;
791 bool LyXTabular::SetBottomLine(int cell, bool line)
793 if (!IsMultiColumn(cell))
794 row_info[row_of_cell(cell)].bottom_line = line;
796 cellinfo_of_cell(cell)->bottom_line = line;
801 bool LyXTabular::SetLeftLine(int cell, bool line)
803 column_info[column_of_cell(cell)].left_line = line;
808 bool LyXTabular::SetRightLine(int cell, bool line)
810 column_info[right_column_of_cell(cell)].right_line = line;
815 char LyXTabular::GetAlignment(int cell) const
817 if (IsMultiColumn(cell))
818 return cellinfo_of_cell(cell)->alignment;
820 return column_info[column_of_cell(cell)].alignment;
823 string LyXTabular::GetPWidth(int cell) const
825 if (IsMultiColumn(cell))
826 return cellinfo_of_cell(cell)->p_width;
827 return column_info[column_of_cell(cell)].p_width;
830 string LyXTabular::GetAlignSpecial(int cell, int what) const
832 if (what == SET_SPECIAL_MULTI)
833 return cellinfo_of_cell(cell)->align_special;
834 return column_info[column_of_cell(cell)].align_special;
837 int LyXTabular::GetWidthOfCell(int cell) const
839 int row = row_of_cell(cell);
840 int column1 = column_of_cell(cell);
841 int column2 = right_column_of_cell(cell);
844 for (; i <= column2; ++i) {
845 result += cell_info[row][i].width_of_cell;
848 // result += GetAdditionalWidth(cell);
854 int LyXTabular::GetBeginningOfTextInCell(int cell) const
858 switch (GetAlignment(cell)){
859 case LYX_ALIGN_CENTER:
860 x += (GetWidthOfColumn(cell) - GetWidthOfCell(cell)) / 2;
862 case LYX_ALIGN_RIGHT:
863 x += GetWidthOfColumn(cell) - GetWidthOfCell(cell);
864 // + GetAdditionalWidth(cell);
866 default: /* LYX_ALIGN_LEFT: nothing :-) */
876 bool LyXTabular::IsFirstCellInRow(int cell) const
878 return (column_of_cell(cell) == 0);
881 bool LyXTabular::IsLastCellInRow(int cell) const
883 return (right_column_of_cell(cell) == (columns_ - 1));
887 bool LyXTabular::calculate_width_of_column(int column)
889 int old_column_width = column_info[column].width_of_column;
892 for (int i = 0; i < rows_; ++i) {
893 maximum = max(cell_info[i][column].width_of_cell, maximum);
895 column_info[column].width_of_column = maximum;
896 return (column_info[column].width_of_column != old_column_width);
899 bool LyXTabular::calculate_width_of_column_NMC(int column)
901 int old_column_width = column_info[column].width_of_column;
903 for (int i = 0; i < rows_; ++i) {
904 if (!IsMultiColumn(GetCellNumber(column, i)) &&
905 (cell_info[i][column].width_of_cell > max)) {
906 max = cell_info[i][column].width_of_cell;
909 column_info[column].width_of_column = max;
910 return (column_info[column].width_of_column != old_column_width);
913 void LyXTabular::calculate_width_of_tabular()
915 width_of_tabular = 0;
916 for (int i = 0; i < columns_; ++i) {
917 width_of_tabular += column_info[i].width_of_column;
922 int LyXTabular::row_of_cell(int cell) const
924 if (cell >= numberofcells)
928 return rowofcell[cell];
932 int LyXTabular::column_of_cell(int cell) const
934 if (cell >= numberofcells)
938 return columnofcell[cell];
942 int LyXTabular::right_column_of_cell(int cell) const
944 int row = row_of_cell(cell);
945 int column = column_of_cell(cell);
946 while (column < (columns_ - 1) &&
947 cell_info[row][column+1].multicolumn == LyXTabular::CELL_PART_OF_MULTICOLUMN)
953 void LyXTabular::Write(ostream & os) const
958 os << "<LyXTabular version=1 rows=" << rows_ << " columns=" << columns_ <<
960 // global longtable options
961 os << "<Features rotate=" << rotate <<
962 " islongtable=" << is_long_tabular <<
963 " endhead=" << endhead << " endfirsthead=" << endfirsthead <<
964 " endfoot=" << endfoot << " endlastfoot=" << endlastfoot <<
966 for (i = 0; i < rows_; ++i) {
967 os << "<Row topline=" << row_info[i].top_line <<
968 " bottomline=" << row_info[i].bottom_line <<
969 " newpage=" << row_info[i].newpage <<
971 for (j = 0; j < columns_; ++j) {
973 os << "<Column alignment=" << column_info[j].alignment <<
974 " leftline=" << column_info[j].left_line <<
975 " rightline=" << column_info[j].right_line <<
976 " width=\"" << VSpace(column_info[j].p_width).asLyXCommand() <<
977 "\" special=\"" << column_info[j].align_special <<
980 os << "<Column>" << endl;
982 os << "<Cell multicolumn=" << cell_info[i][j].multicolumn <<
983 " alignment=" << cell_info[i][j].alignment <<
984 " topline=" << cell_info[i][j].top_line <<
985 " bottomline=" << cell_info[i][j].bottom_line <<
986 " rotate=" << cell_info[i][j].rotate <<
987 " linebreaks=" << cell_info[i][j].linebreaks <<
988 " width=\"" << cell_info[i][j].p_width <<
989 "\" special=\"" << cell_info[i][j].align_special <<
991 os << "\\begin_inset ";
992 cell_info[i][j].inset->Write(os);
993 os << "\n\\end_inset " << endl;
994 os << "</Cell>" << endl;
995 os << "</Column>" << endl;
997 os << "</Row>" << endl;
999 os << "</LyXTabular>" << endl;
1002 static bool getTokenValue(string const str, const char * token, string & ret)
1004 int pos = str.find(token);
1005 char ch = str[pos+strlen(token)];
1007 if ((pos < 0) || (ch != '='))
1010 pos += strlen(token)+1;
1012 if ((ch != '"') && (ch != '\'')) { // only read till next space
1016 while((pos < int(str.length()-1)) && (str[++pos] != ch))
1022 static bool getTokenValue(string const str, const char * token, int & num)
1025 int pos = str.find(token);
1026 char ch = str[pos+strlen(token)];
1028 if ((pos < 0) || (ch != '='))
1031 pos += strlen(token)+1;
1033 if ((ch != '"') && (ch != '\'')) { // only read till next space
1039 while((pos < int(str.length()-1)) && isdigit(str[pos]))
1042 num = strToInt(ret);
1046 static bool getTokenValue(string const str, const char * token, bool & flag)
1049 int pos = str.find(token);
1050 char ch = str[pos+strlen(token)];
1052 if ((pos < 0) || (ch != '='))
1055 pos += strlen(token)+1;
1057 if ((ch != '"') && (ch != '\'')) { // only read till next space
1063 while((pos < int(str.length()-1)) && isdigit(str[pos]))
1066 flag = strToInt(ret);
1070 void l_getline(istream & is, string & str)
1077 void LyXTabular::Read(LyXLex & lex)
1080 istream & is = lex.getStream();
1082 l_getline(is, line);
1083 if (!prefixIs(line, "<LyXTabular ")) {
1084 OldFormatRead(is, line);
1091 if (!getTokenValue(line, "version", version))
1093 if (!getTokenValue(line, "rows", rows_arg))
1095 if (!getTokenValue(line, "columns", columns_arg))
1097 Init(buffer, rows_arg, columns_arg);
1098 l_getline(is, line);
1099 if (!prefixIs(line, "<Features ")) {
1100 lyxerr << "Wrong tabular format (expected <Feture ...> got" <<
1101 line << ")" << endl;
1104 (void)getTokenValue(line, "islongtable", is_long_tabular);
1105 (void)getTokenValue(line, "endhead", endhead);
1106 (void)getTokenValue(line, "endfirsthead", endfirsthead);
1107 (void)getTokenValue(line, "endfoot", endfoot);
1108 (void)getTokenValue(line, "endlastfoot", endlastfoot);
1110 for(i = 0; i < rows_; ++i) {
1111 l_getline(is, line);
1112 if (!prefixIs(line, "<Row ")) {
1113 lyxerr << "Wrong tabular format (expected <Row ...> got" <<
1114 line << ")" << endl;
1117 (void)getTokenValue(line, "topline", row_info[i].top_line);
1118 (void)getTokenValue(line, "bottomline", row_info[i].bottom_line);
1119 (void)getTokenValue(line, "newpage", row_info[i].newpage);
1120 for (j = 0; j < columns_; ++j) {
1122 if (!prefixIs(line,"<Column")) {
1123 lyxerr << "Wrong tabular format (expected <Column ...> got" <<
1124 line << ")" << endl;
1128 (void)getTokenValue(line, "alignment", column_info[j].alignment);
1129 (void)getTokenValue(line, "leftline", column_info[j].left_line);
1130 (void)getTokenValue(line, "rightline", column_info[j].right_line);
1131 (void)getTokenValue(line, "width", column_info[j].p_width);
1132 (void)getTokenValue(line, "special", column_info[j].align_special);
1134 l_getline(is, line);
1135 if (!prefixIs(line, "<Cell")) {
1136 lyxerr << "Wrong tabular format (expected <Cell ...> got" <<
1137 line << ")" << endl;
1140 (void)getTokenValue(line, "multicolumn", cell_info[i][j].multicolumn);
1141 (void)getTokenValue(line, "alignment", cell_info[i][j].alignment);
1142 (void)getTokenValue(line, "topline", cell_info[i][j].top_line);
1143 (void)getTokenValue(line, "bottomline", cell_info[i][j].bottom_line);
1144 (void)getTokenValue(line, "rotate", cell_info[i][j].rotate);
1145 (void)getTokenValue(line, "linebreaks", cell_info[i][j].linebreaks);
1146 (void)getTokenValue(line, "width", cell_info[i][j].p_width);
1147 (void)getTokenValue(line, "special", cell_info[i][j].align_special);
1148 l_getline(is, line);
1149 if (prefixIs(line, "\\begin_inset")) {
1150 cell_info[i][j].inset->Read(lex);
1151 l_getline(is, line);
1153 if (line != "</Cell>") {
1154 lyxerr << "Wrong tabular format (expected </Cell> got" <<
1155 line << ")" << endl;
1158 l_getline(is, line);
1159 if (line != "</Column>") {
1160 lyxerr << "Wrong tabular format (expected </Column> got" <<
1161 line << ")" << endl;
1165 l_getline(is, line);
1166 if (line != "</Row>") {
1167 lyxerr << "Wrong tabular format (expected </Row> got" <<
1168 line << ")" << endl;
1172 while (line != "</LyXTabular>") {
1173 l_getline(is, line);
1175 set_row_column_number_info();
1178 void LyXTabular::OldFormatRead(istream & is, string fl)
1183 int columns_arg = 0;
1184 int is_long_tabular_arg = false;
1185 int rotate_arg = false;
1198 version = atoi(s.c_str() + 8);
1202 lyxerr << "Tabular format < 5 is not supported anymore\n"
1203 "Get an older version of LyX (< 1.1.x) for conversion!"
1205 WriteAlert(_("Warning:"),
1206 _("Tabular format < 5 is not supported anymore\n"),
1207 _("Get an older version of LyX (< 1.1.x) for conversion!"));
1209 is >> rows_arg >> columns_arg >> is_long_tabular_arg
1210 >> rotate_arg >> a >> b >> c >> d;
1212 is >> rows_arg >> columns_arg;
1213 Init(buffer, rows_arg, columns_arg);
1214 SetLongTabular(is_long_tabular_arg);
1215 SetRotateTabular(rotate_arg);
1217 for (i = 0; i < rows_; ++i) {
1220 for (i = 0; i < columns_; ++i) {
1223 for (i = 0; i < rows_; ++i) {
1224 for (j = 0; j < columns_; ++j) {
1228 set_row_column_number_info();
1231 is >> rows_arg >> columns_arg >> is_long_tabular_arg
1232 >> rotate_arg >> a >> b >> c >> d;
1233 Init(buffer, rows_arg, columns_arg);
1234 SetLongTabular(is_long_tabular_arg);
1235 SetRotateTabular(rotate_arg);
1240 for (i = 0; i < rows_; ++i) {
1241 a = b = c = d = e = f = g = h = 0;
1242 is >> a >> b >> c >> d;
1243 row_info[i].top_line = a;
1244 row_info[i].bottom_line = b;
1245 // row_info[i].is_cont_row = c;
1246 row_info[i].newpage = d;
1248 for (i = 0; i < columns_; ++i) {
1252 char ch; // skip '"'
1254 getline(is, s1, '"');
1255 is >> ch; // skip '"'
1256 getline(is, s2, '"');
1257 column_info[i].alignment = static_cast<char>(a);
1258 column_info[i].left_line = b;
1259 column_info[i].right_line = c;
1260 column_info[i].p_width = s1;
1261 column_info[i].align_special = s2;
1263 for (i = 0; i < rows_; ++i) {
1264 for (j = 0; j < columns_; ++j) {
1267 is >> a >> b >> c >> d >> e >> f >> g;
1269 is >> ch; // skip '"'
1270 getline(is, s1, '"');
1271 is >> ch; // skip '"'
1272 getline(is, s2, '"');
1273 cell_info[i][j].multicolumn = static_cast<char>(a);
1274 cell_info[i][j].alignment = static_cast<char>(b);
1275 cell_info[i][j].top_line = static_cast<char>(c);
1276 cell_info[i][j].bottom_line = static_cast<char>(d);
1277 // cell_info[i][j].has_cont_row = static_cast<bool>(e);
1278 cell_info[i][j].rotate = static_cast<bool>(f);
1279 cell_info[i][j].linebreaks = static_cast<bool>(g);
1280 cell_info[i][j].align_special = s1;
1281 cell_info[i][j].p_width = s2;
1284 set_row_column_number_info();
1288 // cell < 0 will tex the preamble
1289 // returns the number of printed newlines
1290 int LyXTabular::TexEndOfCell(ostream & os, int cell) const
1296 if (IsLastCell(cell)) {
1297 // the very end at the very beginning
1298 if (GetLinebreaks(cell))
1299 os << "\\smallskip{}}";
1300 if (IsMultiColumn(cell))
1302 if (GetRotateCell(cell)) {
1303 os << "\n\\end{sideways}";
1311 while (!IsFirstCellInRow(fcell)) --fcell;
1312 for (i = 0; i < NumberOfCellsInRow(fcell); ++i) {
1313 if (BottomLine(fcell + i))
1316 if (tmp == NumberOfCellsInRow(fcell)) {
1320 for (i = 0; i < NumberOfCellsInRow(fcell); ++i) {
1321 if (BottomLine(fcell + i)) {
1323 << column_of_cell(fcell + i) + 1
1325 << right_column_of_cell(fcell + i) + 1
1335 if (is_long_tabular)
1336 os << "\\end{longtable}";
1338 os << "\\end{tabular}";
1340 os << "\n\\end{sideways}";
1348 os << "\\begin{sideways}\n";
1351 if (is_long_tabular)
1352 os << "\\begin{longtable}{";
1354 os << "\\begin{tabular}{";
1355 for (i = 0; i < columns_; ++i) {
1356 if (column_info[i].left_line)
1358 if (!column_info[i].align_special.empty()) {
1359 os << column_info[i].align_special;
1360 } else if (!column_info[i].p_width.empty()) {
1362 << column_info[i].p_width
1365 switch (column_info[i].alignment) {
1366 case LYX_ALIGN_LEFT:
1369 case LYX_ALIGN_RIGHT:
1377 if (column_info[i].right_line)
1383 if (GetNumberOfCells()) {
1385 for (i = 0; i < NumberOfCellsInRow(fcell); ++i) {
1386 if (TopLine(fcell + i))
1389 if (tmp == NumberOfCellsInRow(fcell)){
1393 for (i = 0; i < NumberOfCellsInRow(fcell); ++i) {
1394 if (TopLine(fcell + i)) {
1396 << column_of_cell(fcell + i) + 1
1398 << right_column_of_cell(fcell + i) + 1
1409 if (GetRotateCell(0)) {
1410 os << "\\begin{sideways}\n";
1415 if (GetLinebreaks(cell))
1416 os << "\\smallskip{}}";
1417 if (IsMultiColumn(cell)){
1420 if (GetRotateCell(cell)) {
1421 os << "\n\\end{sideways}";
1424 if (IsLastCellInRow(cell)) {
1425 int row = row_of_cell(cell);
1426 string hline1, hline2;
1427 bool print_hline = true;
1428 bool flag1 = IsLongTabular() &&
1429 ((row == endhead) || (row == endfirsthead) ||
1430 (row == endfoot) || (row == endlastfoot));
1432 bool flag2 = IsLongTabular() &&
1433 ((row <= endhead) || (row <= endfirsthead) ||
1434 (row <= endfoot) || (row <= endlastfoot));
1436 // print the bottom hline only if (otherwise it is doubled):
1437 // - is no LongTabular
1438 // - there IS a first-header
1439 // - the next row is no special header/footer
1440 // & this row is no special header/footer
1441 // - the next row is a special header/footer
1442 // & this row is a special header/footer
1443 bool pr_top_hline = (flag1 && flag2) || (!flag1 && !flag2) ||
1444 (endfirsthead == endhead);
1449 while (!IsFirstCellInRow(fcell))
1451 for (i = 0; i < NumberOfCellsInRow(cell); ++i) {
1452 if (BottomLine(fcell + i))
1455 if (tmp == NumberOfCellsInRow(cell)){
1457 hline1 = "\\hline ";
1460 for (i = 0; i < NumberOfCellsInRow(fcell); ++i) {
1461 if (BottomLine(fcell + i)){
1463 << column_of_cell(fcell + i) + 1
1465 << right_column_of_cell(fcell + i) + 1
1467 hline1 += "\\cline{";
1468 hline1 += tostr(column_of_cell(fcell + i) + 1);
1470 hline1 += tostr(right_column_of_cell(fcell + i) + 1);
1480 if (IsLongTabular() && (row == endfoot)) {
1481 os << "\\endfoot\n";
1483 print_hline = false; // no double line below footer
1485 if (IsLongTabular() && (row == endlastfoot)) {
1486 os << "\\endlastfoot\n";
1488 print_hline = false; // no double line below footer
1490 if (IsLongTabular() && row_info[row].newpage) {
1491 os << "\\newpage\n";
1493 print_hline = false; // no line below a \\newpage-command
1496 if ((nvcell < numberofcells) &&
1497 (cell < GetNumberOfCells() - 1) && !IsLastCell(cell)) {
1499 for (i = 0; i < NumberOfCellsInRow(fcell); ++i) {
1500 if (TopLine(fcell + i))
1503 if (tmp == NumberOfCellsInRow(fcell)) {
1506 hline2 = "\\hline ";
1509 for (i = 0; i < NumberOfCellsInRow(fcell); ++i) {
1510 if (TopLine(fcell + i)) {
1513 << column_of_cell(fcell + i) + 1
1515 << right_column_of_cell(fcell + i) + 1
1518 hline2 += "\\cline{";
1519 hline2 += tostr(column_of_cell(fcell+i)+1);
1521 hline2 += tostr(right_column_of_cell(fcell+i)+1);
1527 if (tmp && print_hline){
1532 // the order here is important as if one defines two
1533 // or more things in one line only the first entry is
1534 // displayed the other are set to an empty-row. This
1535 // is important if I have a footer and want that the
1536 // lastfooter is NOT displayed!!!
1537 bool sflag2 = (row == endhead) || (row == endfirsthead) ||
1538 (row == endfoot) || (row == endlastfoot);
1541 bool sflag1 = IsLongTabular() && (row != endhead) &&
1542 (row != endfirsthead) &&
1543 ((row == endfoot) || (row == endlastfoot));
1545 if (IsLongTabular() && (row == endhead)) {
1546 os << "\\endhead\n";
1549 if (IsLongTabular() && (row == endfirsthead)) {
1550 os << "\\endfirsthead\n";
1553 if (sflag1) { // add the \hline for next foot row
1554 if (!hline1.empty()) {
1555 os << hline1 + '\n';
1559 // add the \hline for the first row
1560 if (pr_top_hline && sflag2) {
1561 if (!hline2.empty()) {
1562 os << hline2 + '\n';
1566 if (nvcell < numberofcells && GetRotateCell(nvcell)) {
1567 os << "\\begin{sideways}\n";
1573 if (nvcell < numberofcells && GetRotateCell(nvcell)) {
1574 os << "\\begin{sideways}\n";
1579 if (nvcell < numberofcells && IsMultiColumn(nvcell)) {
1580 os << "\\multicolumn{"
1581 << cells_in_multicolumn(nvcell)
1583 if (!cellinfo_of_cell(cell+1)->align_special.empty()) {
1584 os << cellinfo_of_cell(cell+1)->align_special
1587 if (LeftLine(nvcell))
1589 if (!GetPWidth(nvcell).empty()) {
1591 << GetPWidth(nvcell)
1594 switch (GetAlignment(nvcell)) {
1595 case LYX_ALIGN_LEFT: os << 'l'; break;
1596 case LYX_ALIGN_RIGHT: os << 'r'; break;
1597 default: os << 'c'; break;
1600 if (RightLine(nvcell))
1602 //if (column_of_cell(cell+2)!= 0 && LeftLine(cell+2))
1603 if (((nvcell + 1) < numberofcells) &&
1604 ((nvcell+1) < numberofcells) &&
1605 (column_of_cell(nvcell+1)!= 0) &&
1612 if (nvcell < numberofcells && GetLinebreaks(nvcell)) {
1613 os << "\\parbox[t]{"
1614 << GetPWidth(nvcell)
1615 << "}{\\smallskip{}";
1623 // cell <0 will tex the preamble
1624 // returns the number of printed newlines
1625 int LyXTabular::RoffEndOfCell(ostream & os, int cell)
1629 if (cell == GetNumberOfCells() - 1){
1630 // the very end at the very beginning
1631 // if (CellHasContRow(cell) >= 0) {
1637 if (row_info[row_of_cell(cell)].bottom_line) {
1641 os << ".TE\n.pl 1c";
1646 os << "\n.pl 500c\n.TS\n";
1647 for (int j = 0; j < rows_; ++j) {
1648 for (int i = 0; i < columns_; ++i, ++fcell) {
1649 if (column_info[i].left_line)
1651 if (cell_info[j][i].multicolumn == CELL_PART_OF_MULTICOLUMN)
1654 switch (column_info[i].alignment) {
1655 case LYX_ALIGN_LEFT:
1658 case LYX_ALIGN_RIGHT:
1666 if (!column_info[i].p_width.empty())
1667 os << "w(" << column_info[i].p_width << ")";
1668 if (column_info[i].right_line)
1671 if ((j + 1) < rows_) {
1678 if (row_info[0].top_line) {
1682 // if (CellHasContRow(0) >= 0) {
1688 // if (CellHasContRow(cell) >= 0) {
1692 if (right_column_of_cell(cell) == columns_ -1){
1695 int row = row_of_cell(cell);
1696 if (row_info[row++].bottom_line) {
1700 if ((row < rows_) && row_info[row].top_line) {
1706 // if ((cell < GetNumberOfCells() - 1) &&
1707 // (CellHasContRow(cell+1) >= 0)) {
1718 char const *LyXTabular::GetDocBookAlign(int cell, bool isColumn) const
1724 i = column_of_cell(cell);
1725 if (!isColumn && IsMultiColumn(cell)) {
1726 if (!cellinfo_of_cell(cell)->align_special.empty()) {
1727 return cellinfo_of_cell(cell)->align_special.c_str();
1729 switch (GetAlignment(cell)) {
1730 case LYX_ALIGN_LEFT:
1732 case LYX_ALIGN_RIGHT:
1739 if (!column_info[i].align_special.empty()) {
1740 return column_info[i].align_special.c_str();
1742 #ifdef IGNORE_THIS_FOR_NOW
1743 else if (!column_info[i].p_width.empty()) {
1745 file += column_info[i].p_width;
1750 switch (column_info[i].alignment) {
1751 case LYX_ALIGN_LEFT:
1753 case LYX_ALIGN_RIGHT:
1763 // cell <0 will tex the preamble
1764 // returns the number of printed newlines
1765 int LyXTabular::DocBookEndOfCell(ostream & os, int cell, int & depth) const
1769 //int tmp; // tmp2; //Â unused
1770 int nvcell; // fcell; //Â unused
1771 if (IsLastCell(cell)) {
1772 os << newlineAndDepth(--depth)
1774 << newlineAndDepth(--depth)
1776 << newlineAndDepth(--depth)
1778 << newlineAndDepth(--depth);
1779 if (is_long_tabular)
1783 << newlineAndDepth(--depth);
1789 if (is_long_tabular)
1795 << "' COLSEP='1' ROWSEP='1'>"
1796 << newlineAndDepth(++depth);
1798 for (i = 0; i < columns_; ++i) {
1799 os << "<COLSPEC ALIGN='"
1800 << GetDocBookAlign(i, true)
1806 if (i == (columns_-1)) {
1809 if (column_info[i].right_line ||
1810 column_info[i+1].left_line)
1816 << newlineAndDepth(depth);
1818 #ifdef NOT_HANDLED_YET_AS_I_DONT_KNOW_HOW
1819 if (column_info[i].left_line)
1824 << newlineAndDepth(++depth)
1826 << newlineAndDepth(++depth)
1828 << GetDocBookAlign(0)
1830 if (IsMultiColumn(0)) {
1831 os << " NAMEST='col1' NAMEEND='col"
1832 << cells_in_multicolumn(0)
1836 << newlineAndDepth(++depth);
1839 if (IsLastCellInRow(cell)) {
1840 os << newlineAndDepth(--depth)
1842 << newlineAndDepth(--depth)
1844 << newlineAndDepth(depth)
1846 << newlineAndDepth(++depth)
1848 << GetDocBookAlign(cell + 1)
1849 << "' VALIGN='middle'";
1850 if (IsMultiColumn(cell + 1)) {
1851 os << " NAMEST='col"
1852 << column_of_cell(cell+1) + 1
1854 << column_of_cell(cell + 1) +
1855 cells_in_multicolumn(cell + 1)
1859 << newlineAndDepth(++depth);
1862 os << newlineAndDepth(--depth)
1864 << newlineAndDepth(depth)
1866 << GetDocBookAlign(cell + 1)
1867 << "' VALIGN='middle'";
1868 if (IsMultiColumn(cell + 1)) {
1869 os << " NAMEST='col"
1870 << column_of_cell(cell+1) + 1
1872 << column_of_cell(cell+1) +
1873 cells_in_multicolumn(cell+1)
1877 << newlineAndDepth(++depth);
1886 bool LyXTabular::IsMultiColumn(int cell) const
1888 return (cellinfo_of_cell(cell)->multicolumn != LyXTabular::CELL_NORMAL);
1892 LyXTabular::cellstruct* LyXTabular::cellinfo_of_cell(int cell) const
1894 int row = row_of_cell(cell);
1895 int column = column_of_cell(cell);
1896 return &cell_info[row][column];
1900 void LyXTabular::SetMultiColumn(int cell, int number)
1902 int new_width = cellinfo_of_cell(cell)->width_of_cell;
1904 cellinfo_of_cell(cell)->multicolumn = LyXTabular::CELL_BEGIN_OF_MULTICOLUMN;
1905 cellinfo_of_cell(cell)->alignment = column_info[column_of_cell(cell)].alignment;
1906 cellinfo_of_cell(cell)->top_line = row_info[row_of_cell(cell)].top_line;
1907 cellinfo_of_cell(cell)->bottom_line = row_info[row_of_cell(cell)].bottom_line;
1908 for (number--; number > 0; --number) {
1909 cellinfo_of_cell(cell+number)->multicolumn =
1910 LyXTabular::CELL_PART_OF_MULTICOLUMN;
1911 new_width += cellinfo_of_cell(cell+number)->width_of_cell;
1913 set_row_column_number_info();
1914 SetWidthOfCell(cell, new_width);
1918 int LyXTabular::cells_in_multicolumn(int cell) const
1920 int row = row_of_cell(cell);
1921 int column = column_of_cell(cell);
1924 while (column < columns_ && cell_info[row][column].multicolumn
1925 == LyXTabular::CELL_PART_OF_MULTICOLUMN){
1933 int LyXTabular::UnsetMultiColumn(int cell)
1935 int row = row_of_cell(cell);
1936 int column = column_of_cell(cell);
1940 if (cell_info[row][column].multicolumn
1941 == LyXTabular::CELL_BEGIN_OF_MULTICOLUMN){
1942 cell_info[row][column].multicolumn = LyXTabular::CELL_NORMAL;
1944 while (column < columns_ &&
1945 cell_info[row][column].multicolumn
1946 == LyXTabular::CELL_PART_OF_MULTICOLUMN){
1947 cell_info[row][column].multicolumn =
1948 LyXTabular::CELL_NORMAL;
1953 set_row_column_number_info();
1958 void LyXTabular::SetLongTabular(int what)
1960 is_long_tabular = what;
1964 bool LyXTabular::IsLongTabular() const
1966 return is_long_tabular;
1969 void LyXTabular::SetRotateTabular(int what)
1974 bool LyXTabular::GetRotateTabular() const
1979 void LyXTabular::SetRotateCell(int cell, int what)
1981 cellinfo_of_cell(cell)->rotate = what;
1984 bool LyXTabular::GetRotateCell(int cell) const
1986 return cellinfo_of_cell(cell)->rotate;
1989 bool LyXTabular::NeedRotating() const
1993 for (int i = 0; i < rows_; ++i) {
1994 for (int j = 0; j < columns_; ++j) {
1995 if (cell_info[i][j].rotate)
2003 bool LyXTabular::IsLastCell(int cell) const
2005 if (cell < GetNumberOfCells())
2010 int LyXTabular::GetCellAbove(int cell) const
2012 if (row_of_cell(cell) > 0)
2013 return cell_info[row_of_cell(cell)-1][column_of_cell(cell)].cellno;
2017 int LyXTabular::GetCellNumber(int column, int row) const
2019 if (column >= columns_)
2020 column = columns_ - 1;
2021 else if (column < 0)
2028 return cell_info[row][column].cellno;
2031 void LyXTabular::SetLinebreaks(int cell, bool what)
2033 cellinfo_of_cell(cell)->linebreaks = what;
2036 bool LyXTabular::GetLinebreaks(int cell) const
2038 if (column_info[column_of_cell(cell)].p_width.empty() &&
2039 !(IsMultiColumn(cell) && !cellinfo_of_cell(cell)->p_width.empty()))
2041 return cellinfo_of_cell(cell)->linebreaks;
2044 void LyXTabular::SetLTHead(int cell, bool first)
2046 int row = row_of_cell(cell);
2049 if (row == endfirsthead)
2061 bool LyXTabular::GetRowOfLTHead(int cell) const
2063 if ((endhead+1) > rows_)
2065 return (row_of_cell(cell) == endhead);
2068 bool LyXTabular::GetRowOfLTFirstHead(int cell) const
2070 if ((endfirsthead+1) > rows_)
2072 return (row_of_cell(cell) == endfirsthead);
2075 void LyXTabular::SetLTFoot(int cell, bool last)
2077 int row = row_of_cell(cell);
2080 if (row == endlastfoot)
2092 bool LyXTabular::GetRowOfLTFoot(int cell) const
2094 if ((endfoot+1) > rows_)
2096 return (row_of_cell(cell) == endfoot);
2099 bool LyXTabular::GetRowOfLTLastFoot(int cell) const
2101 if ((endlastfoot+1) > rows_)
2103 return (row_of_cell(cell) == endlastfoot);
2106 void LyXTabular::SetLTNewPage(int cell, bool what)
2108 row_info[row_of_cell(cell)].newpage = what;
2111 bool LyXTabular::GetLTNewPage(int cell) const
2113 return row_info[row_of_cell(cell)].newpage;
2116 void LyXTabular::SetAscentOfRow(int row, int height)
2120 row_info[row].ascent_of_row = height;
2123 void LyXTabular::SetDescentOfRow(int row, int height)
2127 row_info[row].descent_of_row = height;
2130 int LyXTabular::GetAscentOfRow(int row) const
2134 return row_info[row].ascent_of_row;
2137 int LyXTabular::GetDescentOfRow(int row) const
2141 return row_info[row].descent_of_row;
2144 int LyXTabular::GetHeightOfTabular() const
2150 for(row=0,height=0;(row<rows_); ++row)
2151 height += GetAscentOfRow(row) + GetDescentOfRow(row) +
2152 GetAdditionalHeight(GetCellNumber(0,row));
2156 bool LyXTabular::IsPartOfMultiColumn(int row, int column) const
2158 if ((row >= rows_) || (column >= columns_))
2160 return (cell_info[row][column].multicolumn==CELL_PART_OF_MULTICOLUMN);
2163 int LyXTabular::Latex(ostream &) const
2168 InsetText * LyXTabular::GetCellInset(int cell) const
2170 return cell_info[row_of_cell(cell)][column_of_cell(cell)].inset;