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(Buffer * buf)
41 cellno = 0; //should be initilaized correctly later.
43 multicolumn = LyXTabular::CELL_NORMAL;
44 alignment = LYX_ALIGN_CENTER;
49 inset = new InsetText(buf);
52 LyXTabular::cellstruct::~cellstruct()
58 LyXTabular::cellstruct &
59 LyXTabular::cellstruct::operator=(cellstruct const & cs)
62 width_of_cell = cs.width_of_cell;
63 multicolumn = cs.multicolumn;
64 alignment = cs.alignment;
65 top_line = cs.top_line;
66 bottom_line = cs.bottom_line;
68 linebreaks = cs.linebreaks;
72 LyXTabular::rowstruct::rowstruct()
81 // Nothing to do, but gcc 2.7.2.3 wants one... (JMarc)
82 LyXTabular::rowstruct::~rowstruct()
86 LyXTabular::rowstruct &
87 LyXTabular::rowstruct::operator=(rowstruct const & rs)
89 top_line = rs.top_line;
90 bottom_line = rs.bottom_line;
91 ascent_of_row = rs.ascent_of_row;
92 descent_of_row = rs.descent_of_row;
97 LyXTabular::columnstruct::columnstruct()
101 alignment = LYX_ALIGN_CENTER;
105 LyXTabular::columnstruct::~columnstruct()
109 LyXTabular::columnstruct &
110 LyXTabular::columnstruct::operator=(columnstruct const & cs)
112 left_line = cs.left_line;
113 right_line = cs.right_line;
114 alignment = cs.alignment;
115 width_of_column = cs.width_of_column;
116 p_width = cs.p_width;
117 align_special = cs.align_special;
122 LyXTabular::LyXTabular(int rows_arg, int columns_arg, Buffer *buf)
125 Init(rows_arg, columns_arg);
129 LyXTabular::LyXTabular(LyXTabular const & lt, Buffer * buf)
132 Init(lt.rows_, lt.columns_);
137 LyXTabular::LyXTabular(LyXLex & lex, Buffer *buf)
144 LyXTabular::~LyXTabular()
147 delete[] columnofcell;
148 delete[] column_info;
150 for (int i = 0; i < rows_; ++i) {
151 delete[] cell_info[i];
157 LyXTabular & LyXTabular::operator=(LyXTabular const & lt)
159 // If this and lt is not of the same size we have a serious bug
160 // So then it is ok to throw an exception, or for now
162 Assert(rows_ == lt.rows_ && columns_ == lt.columns_);
164 int row = 0, column = 0;
166 for (row = 0; row < rows_; ++row) {
167 for (column = 0; column < columns_; ++column) {
168 cell_info[row][column] = lt.cell_info[row][column];
172 for (row = 0; row < rows_; ++row) {
173 row_info[row] = lt.row_info[row];
176 for (column = 0; column < columns_; ++column) {
177 column_info[column] = lt.column_info[column];
180 SetLongTabular(lt.is_long_tabular);
187 LyXTabular * LyXTabular::Clone(Buffer * buf)
189 LyXTabular * result = new LyXTabular(rows_, columns_, buf);
192 for (row = 0; row < rows_; ++row) {
193 for (column = 0; column < columns_; ++column) {
194 result->cell_info[row][column] = cell_info[row][column];
198 for (row = 0; row < rows_; ++row) {
199 result->row_info[row] = row_info[row];
202 for (column = 0; column < columns_; ++column) {
203 result->column_info[column].left_line = column_info[column].left_line;
204 result->column_info[column].right_line = column_info[column].right_line;
205 result->column_info[column].alignment = column_info[column].alignment;
206 result->column_info[column].p_width = column_info[column].p_width;
207 result->column_info[column].align_special = column_info[column].align_special;
210 result->SetLongTabular(is_long_tabular);
211 result->rotate = rotate;
217 /* activates all lines and sets all widths to 0 */
218 void LyXTabular::Init(int rows_arg, int columns_arg)
222 columns_ = columns_arg;
223 column_info = new columnstruct[columns_];
224 row_info = new rowstruct[rows_];
225 cell_info = new cellstruct*[rows_];
228 for (i = 0; i < rows_; ++i) {
229 cell_info[i] = new cellstruct[columns_](buffer);
230 for (j = 0; j < columns_; ++j) {
231 cell_info[i][j].cellno = cellno++;
234 row_info[i-1].bottom_line = true;
235 row_info[0].bottom_line = true;
237 for (i = 0; i < columns_; ++i) {
238 calculate_width_of_column(i);
240 column_info[columns_-1].right_line = true;
242 calculate_width_of_tabular();
246 set_row_column_number_info();
247 is_long_tabular = false;
256 void LyXTabular::AppendRow(int cell)
258 int row = row_of_cell(cell);
259 rowstruct * row_info2 = new rowstruct[rows_ + 1];
260 cellstruct ** cell_info2 = new cellstruct * [rows_ + 1];
263 for (i = 0; i <= row; ++i) {
264 cell_info2[i] = cell_info[i];
265 row_info2[i] = row_info[i];
267 for (i = rows_ - 1; i >= row; --i) {
268 cell_info2[i + 1] = cell_info[i];
269 row_info2[i + 1] = row_info[i];
271 row_info2[row + 1].top_line = row_info[i].top_line;
272 cell_info2[row + 1] = new cellstruct[columns_](buffer);
273 for (i = 0; i < columns_; ++i) {
274 cell_info2[row + 1][i].width_of_cell = 0;
275 cell_info2[row + 1][i] = cell_info2[row][i];
279 cell_info = cell_info2;
281 row_info = row_info2;
289 void LyXTabular::DeleteRow(int cell)
291 int row = row_of_cell(cell);
292 rowstruct * row_info2 = new rowstruct[rows_ - 1];
293 cellstruct ** cell_info2 = new cellstruct * [rows_ - 1];
295 delete[] cell_info[row];
297 for (; i < row; ++i) {
298 cell_info2[i] = cell_info[i];
299 row_info2[i] = row_info[i];
301 for (i = row; i < rows_ - 1; ++i) {
302 cell_info2[i] = cell_info[i + 1];
303 row_info2[i] = row_info[i + 1];
307 cell_info = cell_info2;
309 row_info = row_info2;
317 void LyXTabular::AppendColumn(int cell)
320 columnstruct * column_info2 = new columnstruct[columns_ + 1];
321 int column = right_column_of_cell(cell);
324 for (; i <= column; ++i) {
325 column_info2[i] = column_info[i];
327 for (i = columns_ - 1; i >= column; --i) {
328 column_info2[i + 1] = column_info[i];
331 delete[] column_info;
332 column_info = column_info2;
334 for (i = 0; i < rows_; ++i) {
335 cellstruct * tmp = cell_info[i];
336 cell_info[i] = new cellstruct[columns_ + 1](buffer);
337 for (j = 0; j <= column; ++j) {
338 cell_info[i][j] = tmp[j];
340 for (j = column; j < columns_; ++j) {
341 cell_info[i][j + 1] = tmp[j];
343 // care about multicolumns
344 if (cell_info[i][column + 1].multicolumn
345 == LyXTabular::CELL_BEGIN_OF_MULTICOLUMN){
346 cell_info[i][column + 1].multicolumn =
347 LyXTabular::CELL_PART_OF_MULTICOLUMN;
349 if (column + 1 == columns_
350 || cell_info[i][column + 2].multicolumn
351 != LyXTabular::CELL_PART_OF_MULTICOLUMN){
352 cell_info[i][column + 1].multicolumn =
353 LyXTabular::CELL_NORMAL;
363 void LyXTabular::Reinit()
368 for (; i < rows_; ++i) {
369 for (j = 0; j < columns_; ++j) {
370 cell_info[i][j].width_of_cell = 0;
374 for (i = 0; i < columns_; ++i) {
375 calculate_width_of_column(i);
377 calculate_width_of_tabular();
379 set_row_column_number_info();
383 void LyXTabular::set_row_column_number_info()
389 for (; row < rows_; ++row) {
390 for (column = 0; column<columns_; ++column) {
391 if (cell_info[row][column].multicolumn
392 != LyXTabular::CELL_PART_OF_MULTICOLUMN)
394 cell_info[row][column].cellno = numberofcells;
397 ++numberofcells; // because this is one more than as we start from 0
402 rowofcell = new int[numberofcells];
403 delete [] columnofcell;
404 columnofcell = new int[numberofcells];
406 while (c < numberofcells && row < rows_ && column < columns_) {
408 columnofcell[c] = column;
412 } while (column < columns_ &&
413 cell_info[row][column].multicolumn
414 == LyXTabular::CELL_PART_OF_MULTICOLUMN);
415 if (column == columns_) {
423 void LyXTabular::DeleteColumn(int cell)
425 int column1 = column_of_cell(cell);
426 int column2 = right_column_of_cell(cell);
428 if (column1 == 0 && column2 == columns_ - 1)
431 for (int column = column1; column <= column2; ++column) {
432 delete_column(column1);
438 int LyXTabular::GetNumberOfCells() const
440 return numberofcells;
444 int LyXTabular::NumberOfCellsInRow(int cell) const
446 int row = row_of_cell(cell);
448 for (int i = 0; i < columns_; ++i) {
449 if (cell_info[row][i].multicolumn != LyXTabular::CELL_PART_OF_MULTICOLUMN)
456 int LyXTabular::AppendCellAfterCell(int append_cell, int question_cell)
458 return (right_column_of_cell(append_cell) ==
459 right_column_of_cell(question_cell));
463 int LyXTabular::DeleteCellIfColumnIsDeleted(int cell, int delete_column_cell)
465 if (column_of_cell(delete_column_cell) == 0 &&
466 right_column_of_cell(delete_column_cell) == columns_ - 1)
470 (column_of_cell(cell) >= column_of_cell(delete_column_cell) &&
471 column_of_cell(cell) <= right_column_of_cell(delete_column_cell));
475 /* returns 1 if there is a topline, returns 0 if not */
476 bool LyXTabular::TopLine(int cell) const
478 int row = row_of_cell(cell);
480 if (IsMultiColumn(cell))
481 return cellinfo_of_cell(cell)->top_line;
482 return row_info[row].top_line;
486 bool LyXTabular::BottomLine(int cell) const
488 //no bottom line underneath non-existent cells if you please
489 if(cell >= numberofcells)
492 if (IsMultiColumn(cell))
493 return cellinfo_of_cell(cell)->bottom_line;
494 return row_info[row_of_cell(cell)].bottom_line;
498 bool LyXTabular::LeftLine(int cell) const
500 return column_info[column_of_cell(cell)].left_line;
504 bool LyXTabular::RightLine(int cell) const
506 return column_info[right_column_of_cell(cell)].right_line;
510 bool LyXTabular::TopAlreadyDrawed(int cell) const
512 if (GetAdditionalHeight(cell))
514 int row = row_of_cell(cell);
516 int column = column_of_cell(cell);
519 && cell_info[row][column].multicolumn
520 == LyXTabular::CELL_PART_OF_MULTICOLUMN)
522 if (cell_info[row][column].multicolumn == LyXTabular::CELL_NORMAL)
523 return row_info[row].bottom_line;
525 return cell_info[row][column].bottom_line;
531 bool LyXTabular::LeftAlreadyDrawed(int cell) const
533 int column = column_of_cell(cell);
535 int row = row_of_cell(cell);
537 (cell_info[row][column].multicolumn ==
538 LyXTabular::CELL_PART_OF_MULTICOLUMN));
539 if (GetAdditionalWidth(cell_info[row][column].cellno))
541 return column_info[column].right_line;
547 bool LyXTabular::IsLastRow(int cell) const
549 return (row_of_cell(cell) == rows_ - 1);
553 int LyXTabular::GetAdditionalHeight(int cell) const
555 int row = row_of_cell(cell);
558 int top = 1; // bool top = true; ??
559 int bottom = 1; // bool bottom = true; ??
562 for (column = 0; column < columns_ - 1 && bottom; ++column) {
563 switch (cell_info[row - 1][column].multicolumn) {
564 case LyXTabular::CELL_BEGIN_OF_MULTICOLUMN:
565 bottom = cell_info[row - 1][column].bottom_line;
567 case LyXTabular::CELL_NORMAL:
568 bottom = row_info[row - 1].bottom_line;
571 for (column = 0; column < columns_ - 1 && top; ++column) {
572 switch (cell_info[row][column].multicolumn){
573 case LyXTabular::CELL_BEGIN_OF_MULTICOLUMN:
574 top = cell_info[row][column].top_line;
576 case LyXTabular::CELL_NORMAL:
577 top = row_info[row].top_line;
581 return WIDTH_OF_LINE;
586 int LyXTabular::GetAdditionalWidth(int cell) const
588 // internally already set in SetWidthOfCell
589 // used to get it back in text.C
590 int col = right_column_of_cell(cell);
591 if (col < columns_ - 1 && column_info[col].right_line &&
592 column_info[col+1].left_line)
593 return WIDTH_OF_LINE;
599 // returns the maximum over all rows
600 int LyXTabular::GetWidthOfColumn(int cell) const
602 int column1 = column_of_cell(cell);
603 int column2 = right_column_of_cell(cell);
606 for (; i <= column2; ++i) {
607 result += column_info[i].width_of_column;
613 int LyXTabular::GetWidthOfTabular() const
615 return width_of_tabular;
618 /* returns 1 if a complete update is necessary, otherwise 0 */
619 bool LyXTabular::SetWidthOfMulticolCell(int cell, int new_width)
621 if (!IsMultiColumn(cell))
624 int row = row_of_cell(cell);
625 int column1 = column_of_cell(cell);
626 int column2 = right_column_of_cell(cell);
628 // first set columns to 0 so we can calculate the right width
630 for (; i <= column2; ++i) {
631 cell_info[row][i].width_of_cell = 0;
633 // set the width to MAX_WIDTH until width > 0
634 int width = (new_width + 2 * WIDTH_OF_LINE);
635 for (i = column1; (i < column2) && (width > 0); ++i) {
636 cell_info[row][i].width_of_cell = column_info[i].width_of_column;
637 width -= column_info[i].width_of_column;
640 cell_info[row][i].width_of_cell = width;
646 void LyXTabular::recalculateMulticolCells(int cell, int new_width)
648 int row = row_of_cell(cell);
649 int column1 = column_of_cell(cell);
650 int column2 = right_column_of_cell(cell);
652 // first set columns to 0 so we can calculate the right width
654 for (; i <= column2; ++i)
655 cell_info[row][i].width_of_cell = 0;
656 for(i = cell + 1; (i < numberofcells) && (!IsMultiColumn(i)); ++i)
658 if (i < numberofcells)
659 recalculateMulticolCells(i, GetWidthOfCell(i) - (2 * WIDTH_OF_LINE));
660 SetWidthOfMulticolCell(cell, new_width);
664 /* returns 1 if a complete update is necessary, otherwise 0 */
665 bool LyXTabular::SetWidthOfCell(int cell, int new_width)
667 int row = row_of_cell(cell);
668 int column1 = column_of_cell(cell);
672 if (IsMultiColumn(cell)) {
673 tmp = SetWidthOfMulticolCell(cell, new_width);
675 width = (new_width + 2*WIDTH_OF_LINE);
676 cell_info[row][column1].width_of_cell = width;
677 if (column_info[column1].right_line && (column1 < columns_-1) &&
678 column_info[column1+1].left_line) // additional width
679 cell_info[row][column1].width_of_cell += WIDTH_OF_LINE;
680 tmp = calculate_width_of_column_NMC(column1);
684 for(i = 0; i<columns_;++i)
685 calculate_width_of_column_NMC(i);
686 for(i = 0; (i<numberofcells) && !IsMultiColumn(i); ++i)
689 recalculateMulticolCells(i, GetWidthOfCell(i)-(2*WIDTH_OF_LINE));
690 for(i = 0; i<columns_;++i)
691 calculate_width_of_column(i);
692 calculate_width_of_tabular();
699 bool LyXTabular::SetAlignment(int cell, char align)
701 if (!IsMultiColumn(cell))
702 column_info[column_of_cell(cell)].alignment = align;
703 cellinfo_of_cell(cell)->alignment = align;
707 bool LyXTabular::SetPWidth(int cell, string width)
709 if (IsMultiColumn(cell)) {
710 cellinfo_of_cell(cell)->p_width = width;
712 column_info[column_of_cell(cell)].p_width = width;
713 if (!width.empty()) // do this only if there is a width
714 SetAlignment(cell, LYX_ALIGN_LEFT);
719 bool LyXTabular::SetAlignSpecial(int cell, string special, int what)
721 if (what == SET_SPECIAL_MULTI)
722 cellinfo_of_cell(cell)->align_special = special;
724 column_info[column_of_cell(cell)].align_special = special;
728 bool LyXTabular::SetAllLines(int cell, bool line)
730 SetTopLine(cell, line);
731 SetBottomLine(cell, line);
732 SetRightLine(cell, line);
733 SetLeftLine(cell, line);
737 bool LyXTabular::SetTopLine(int cell, bool line)
739 int row = row_of_cell(cell);
741 if (!IsMultiColumn(cell))
742 row_info[row].top_line = line;
744 cellinfo_of_cell(cell)->top_line = line;
749 bool LyXTabular::SetBottomLine(int cell, bool line)
751 if (!IsMultiColumn(cell))
752 row_info[row_of_cell(cell)].bottom_line = line;
754 cellinfo_of_cell(cell)->bottom_line = line;
759 bool LyXTabular::SetLeftLine(int cell, bool line)
761 column_info[column_of_cell(cell)].left_line = line;
766 bool LyXTabular::SetRightLine(int cell, bool line)
768 column_info[right_column_of_cell(cell)].right_line = line;
773 char LyXTabular::GetAlignment(int cell) const
775 if (IsMultiColumn(cell))
776 return cellinfo_of_cell(cell)->alignment;
778 return column_info[column_of_cell(cell)].alignment;
781 string LyXTabular::GetPWidth(int cell) const
783 if (IsMultiColumn(cell))
784 return cellinfo_of_cell(cell)->p_width;
785 return column_info[column_of_cell(cell)].p_width;
788 string LyXTabular::GetAlignSpecial(int cell, int what) const
790 if (what == SET_SPECIAL_MULTI)
791 return cellinfo_of_cell(cell)->align_special;
792 return column_info[column_of_cell(cell)].align_special;
795 int LyXTabular::GetWidthOfCell(int cell) const
797 int row = row_of_cell(cell);
798 int column1 = column_of_cell(cell);
799 int column2 = right_column_of_cell(cell);
802 for (; i <= column2; ++i) {
803 result += cell_info[row][i].width_of_cell;
806 // result += GetAdditionalWidth(cell);
812 int LyXTabular::GetBeginningOfTextInCell(int cell) const
816 switch (GetAlignment(cell)){
817 case LYX_ALIGN_CENTER:
818 x += (GetWidthOfColumn(cell) - GetWidthOfCell(cell)) / 2;
820 case LYX_ALIGN_RIGHT:
821 x += GetWidthOfColumn(cell) - GetWidthOfCell(cell);
822 // + GetAdditionalWidth(cell);
824 default: /* LYX_ALIGN_LEFT: nothing :-) */
834 bool LyXTabular::IsFirstCellInRow(int cell) const
836 return (column_of_cell(cell) == 0);
839 bool LyXTabular::IsLastCellInRow(int cell) const
841 return (right_column_of_cell(cell) == (columns_ - 1));
845 bool LyXTabular::calculate_width_of_column(int column)
847 int old_column_width = column_info[column].width_of_column;
850 for (int i = 0; i < rows_; ++i) {
851 maximum = max(cell_info[i][column].width_of_cell, maximum);
853 column_info[column].width_of_column = maximum;
854 return (column_info[column].width_of_column != old_column_width);
857 bool LyXTabular::calculate_width_of_column_NMC(int column)
859 int old_column_width = column_info[column].width_of_column;
861 for (int i = 0; i < rows_; ++i) {
862 if (!IsMultiColumn(GetCellNumber(column, i)) &&
863 (cell_info[i][column].width_of_cell > max)) {
864 max = cell_info[i][column].width_of_cell;
867 column_info[column].width_of_column = max;
868 return (column_info[column].width_of_column != old_column_width);
871 void LyXTabular::calculate_width_of_tabular()
873 width_of_tabular = 0;
874 for (int i = 0; i < columns_; ++i) {
875 width_of_tabular += column_info[i].width_of_column;
880 int LyXTabular::row_of_cell(int cell) const
882 if (cell >= numberofcells)
886 return rowofcell[cell];
890 int LyXTabular::column_of_cell(int cell) const
892 if (cell >= numberofcells)
896 return columnofcell[cell];
900 int LyXTabular::right_column_of_cell(int cell) const
902 int row = row_of_cell(cell);
903 int column = column_of_cell(cell);
904 while (column < (columns_ - 1) &&
905 cell_info[row][column+1].multicolumn == LyXTabular::CELL_PART_OF_MULTICOLUMN)
911 void LyXTabular::Write(ostream & os) const
916 os << "<LyXTabular version=1 rows=" << rows_ << " columns=" << columns_ <<
918 // global longtable options
919 os << "<Features rotate=" << rotate <<
920 " islongtable=" << is_long_tabular <<
921 " endhead=" << endhead << " endfirsthead=" << endfirsthead <<
922 " endfoot=" << endfoot << " endlastfoot=" << endlastfoot <<
924 for (i = 0; i < rows_; ++i) {
925 os << "<Row topline=" << row_info[i].top_line <<
926 " bottomline=" << row_info[i].bottom_line <<
927 " newpage=" << row_info[i].newpage <<
929 for (j = 0; j < columns_; ++j) {
931 os << "<Column alignment=" << column_info[j].alignment <<
932 " leftline=" << column_info[j].left_line <<
933 " rightline=" << column_info[j].right_line <<
934 " width=\"" << VSpace(column_info[j].p_width).asLyXCommand() <<
935 "\" special=\"" << column_info[j].align_special <<
938 os << "<Column>" << endl;
940 os << "<Cell multicolumn=" << cell_info[i][j].multicolumn <<
941 " alignment=" << cell_info[i][j].alignment <<
942 " topline=" << cell_info[i][j].top_line <<
943 " bottomline=" << cell_info[i][j].bottom_line <<
944 " rotate=" << cell_info[i][j].rotate <<
945 " linebreaks=" << cell_info[i][j].linebreaks <<
946 " width=\"" << cell_info[i][j].p_width <<
947 "\" special=\"" << cell_info[i][j].align_special <<
949 os << "\\begin_inset ";
950 cell_info[i][j].inset->Write(os);
951 os << "\n\\end_inset " << endl;
952 os << "</Cell>" << endl;
953 os << "</Column>" << endl;
955 os << "</Row>" << endl;
957 os << "</LyXTabular>" << endl;
960 static bool getTokenValue(string const str, const char * token, string & ret)
962 int pos = str.find(token);
963 char ch = str[pos+strlen(token)];
965 if ((pos < 0) || (ch != '='))
968 pos += strlen(token)+1;
970 if ((ch != '"') && (ch != '\'')) { // only read till next space
974 while((pos < int(str.length()-1)) && (str[++pos] != ch))
980 static bool getTokenValue(string const str, const char * token, int & num)
983 int pos = str.find(token);
984 char ch = str[pos+strlen(token)];
986 if ((pos < 0) || (ch != '='))
989 pos += strlen(token)+1;
991 if ((ch != '"') && (ch != '\'')) { // only read till next space
997 while((pos < int(str.length()-1)) && isdigit(str[pos]))
1000 num = strToInt(ret);
1004 static bool getTokenValue(string const str, const char * token, bool & flag)
1007 int pos = str.find(token);
1008 char ch = str[pos+strlen(token)];
1010 if ((pos < 0) || (ch != '='))
1013 pos += strlen(token)+1;
1015 if ((ch != '"') && (ch != '\'')) { // only read till next space
1021 while((pos < int(str.length()-1)) && isdigit(str[pos]))
1024 flag = strToInt(ret);
1028 void l_getline(istream & is, string & str)
1035 void LyXTabular::Read(LyXLex & lex)
1038 istream & is = lex.getStream();
1040 l_getline(is, line);
1041 if (!prefixIs(line, "<LyXTabular ")) {
1042 OldFormatRead(is, line);
1049 if (!getTokenValue(line, "version", version))
1051 if (!getTokenValue(line, "rows", rows_arg))
1053 if (!getTokenValue(line, "columns", columns_arg))
1055 Init(rows_arg, columns_arg);
1056 l_getline(is, line);
1057 if (!prefixIs(line, "<Features ")) {
1058 lyxerr << "Wrong tabular format (expected <Feture ...> got" <<
1059 line << ")" << endl;
1062 (void)getTokenValue(line, "islongtable", is_long_tabular);
1063 (void)getTokenValue(line, "endhead", endhead);
1064 (void)getTokenValue(line, "endfirsthead", endfirsthead);
1065 (void)getTokenValue(line, "endfoot", endfoot);
1066 (void)getTokenValue(line, "endlastfoot", endlastfoot);
1068 for(i = 0; i < rows_; ++i) {
1069 l_getline(is, line);
1070 if (!prefixIs(line, "<Row ")) {
1071 lyxerr << "Wrong tabular format (expected <Row ...> got" <<
1072 line << ")" << endl;
1075 (void)getTokenValue(line, "topline", row_info[i].top_line);
1076 (void)getTokenValue(line, "bottomline", row_info[i].bottom_line);
1077 (void)getTokenValue(line, "newpage", row_info[i].newpage);
1078 for (j = 0; j < columns_; ++j) {
1080 if (!prefixIs(line,"<Column")) {
1081 lyxerr << "Wrong tabular format (expected <Column ...> got" <<
1082 line << ")" << endl;
1086 (void)getTokenValue(line, "alignment", column_info[j].alignment);
1087 (void)getTokenValue(line, "leftline", column_info[j].left_line);
1088 (void)getTokenValue(line, "rightline", column_info[j].right_line);
1089 (void)getTokenValue(line, "width", column_info[j].p_width);
1090 (void)getTokenValue(line, "special", column_info[j].align_special);
1092 l_getline(is, line);
1093 if (!prefixIs(line, "<Cell")) {
1094 lyxerr << "Wrong tabular format (expected <Cell ...> got" <<
1095 line << ")" << endl;
1098 (void)getTokenValue(line, "multicolumn", cell_info[i][j].multicolumn);
1099 (void)getTokenValue(line, "alignment", cell_info[i][j].alignment);
1100 (void)getTokenValue(line, "topline", cell_info[i][j].top_line);
1101 (void)getTokenValue(line, "bottomline", cell_info[i][j].bottom_line);
1102 (void)getTokenValue(line, "rotate", cell_info[i][j].rotate);
1103 (void)getTokenValue(line, "linebreaks", cell_info[i][j].linebreaks);
1104 (void)getTokenValue(line, "width", cell_info[i][j].p_width);
1105 (void)getTokenValue(line, "special", cell_info[i][j].align_special);
1106 l_getline(is, line);
1107 if (prefixIs(line, "\\begin_inset")) {
1108 cell_info[i][j].inset->Read(lex);
1109 l_getline(is, line);
1111 if (line != "</Cell>") {
1112 lyxerr << "Wrong tabular format (expected </Cell> got" <<
1113 line << ")" << endl;
1116 l_getline(is, line);
1117 if (line != "</Column>") {
1118 lyxerr << "Wrong tabular format (expected </Column> got" <<
1119 line << ")" << endl;
1123 l_getline(is, line);
1124 if (line != "</Row>") {
1125 lyxerr << "Wrong tabular format (expected </Row> got" <<
1126 line << ")" << endl;
1130 while (line != "</LyXTabular>") {
1131 l_getline(is, line);
1133 set_row_column_number_info();
1136 void LyXTabular::OldFormatRead(istream & is, string fl)
1141 int columns_arg = 0;
1142 int is_long_tabular_arg = false;
1143 int rotate_arg = false;
1156 version = atoi(s.c_str() + 8);
1160 lyxerr << "Tabular format < 5 is not supported anymore\n"
1161 "Get an older version of LyX (< 1.1.x) for conversion!"
1163 WriteAlert(_("Warning:"),
1164 _("Tabular format < 5 is not supported anymore\n"),
1165 _("Get an older version of LyX (< 1.1.x) for conversion!"));
1167 is >> rows_arg >> columns_arg >> is_long_tabular_arg
1168 >> rotate_arg >> a >> b >> c >> d;
1170 is >> rows_arg >> columns_arg;
1171 Init(rows_arg, columns_arg);
1172 SetLongTabular(is_long_tabular_arg);
1173 SetRotateTabular(rotate_arg);
1175 for (i = 0; i < rows_; ++i) {
1178 for (i = 0; i < columns_; ++i) {
1181 for (i = 0; i < rows_; ++i) {
1182 for (j = 0; j < columns_; ++j) {
1186 set_row_column_number_info();
1189 is >> rows_arg >> columns_arg >> is_long_tabular_arg
1190 >> rotate_arg >> a >> b >> c >> d;
1191 Init(rows_arg, columns_arg);
1192 SetLongTabular(is_long_tabular_arg);
1193 SetRotateTabular(rotate_arg);
1198 for (i = 0; i < rows_; ++i) {
1199 a = b = c = d = e = f = g = h = 0;
1200 is >> a >> b >> c >> d;
1201 row_info[i].top_line = a;
1202 row_info[i].bottom_line = b;
1203 // row_info[i].is_cont_row = c;
1204 row_info[i].newpage = d;
1206 for (i = 0; i < columns_; ++i) {
1210 char ch; // skip '"'
1212 getline(is, s1, '"');
1213 is >> ch; // skip '"'
1214 getline(is, s2, '"');
1215 column_info[i].alignment = static_cast<char>(a);
1216 column_info[i].left_line = b;
1217 column_info[i].right_line = c;
1218 column_info[i].p_width = s1;
1219 column_info[i].align_special = s2;
1221 for (i = 0; i < rows_; ++i) {
1222 for (j = 0; j < columns_; ++j) {
1225 is >> a >> b >> c >> d >> e >> f >> g;
1227 is >> ch; // skip '"'
1228 getline(is, s1, '"');
1229 is >> ch; // skip '"'
1230 getline(is, s2, '"');
1231 cell_info[i][j].multicolumn = static_cast<char>(a);
1232 cell_info[i][j].alignment = static_cast<char>(b);
1233 cell_info[i][j].top_line = static_cast<char>(c);
1234 cell_info[i][j].bottom_line = static_cast<char>(d);
1235 // cell_info[i][j].has_cont_row = static_cast<bool>(e);
1236 cell_info[i][j].rotate = static_cast<bool>(f);
1237 cell_info[i][j].linebreaks = static_cast<bool>(g);
1238 cell_info[i][j].align_special = s1;
1239 cell_info[i][j].p_width = s2;
1242 set_row_column_number_info();
1246 // cell < 0 will tex the preamble
1247 // returns the number of printed newlines
1248 int LyXTabular::TexEndOfCell(ostream & os, int cell) const
1254 if (IsLastCell(cell)) {
1255 // the very end at the very beginning
1256 if (GetLinebreaks(cell))
1257 os << "\\smallskip{}}";
1258 if (IsMultiColumn(cell))
1260 if (GetRotateCell(cell)) {
1261 os << "\n\\end{sideways}";
1269 while (!IsFirstCellInRow(fcell)) --fcell;
1270 for (i = 0; i < NumberOfCellsInRow(fcell); ++i) {
1271 if (BottomLine(fcell + i))
1274 if (tmp == NumberOfCellsInRow(fcell)) {
1278 for (i = 0; i < NumberOfCellsInRow(fcell); ++i) {
1279 if (BottomLine(fcell + i)) {
1281 << column_of_cell(fcell + i) + 1
1283 << right_column_of_cell(fcell + i) + 1
1293 if (is_long_tabular)
1294 os << "\\end{longtable}";
1296 os << "\\end{tabular}";
1298 os << "\n\\end{sideways}";
1306 os << "\\begin{sideways}\n";
1309 if (is_long_tabular)
1310 os << "\\begin{longtable}{";
1312 os << "\\begin{tabular}{";
1313 for (i = 0; i < columns_; ++i) {
1314 if (column_info[i].left_line)
1316 if (!column_info[i].align_special.empty()) {
1317 os << column_info[i].align_special;
1318 } else if (!column_info[i].p_width.empty()) {
1320 << column_info[i].p_width
1323 switch (column_info[i].alignment) {
1324 case LYX_ALIGN_LEFT:
1327 case LYX_ALIGN_RIGHT:
1335 if (column_info[i].right_line)
1341 if (GetNumberOfCells()) {
1343 for (i = 0; i < NumberOfCellsInRow(fcell); ++i) {
1344 if (TopLine(fcell + i))
1347 if (tmp == NumberOfCellsInRow(fcell)){
1351 for (i = 0; i < NumberOfCellsInRow(fcell); ++i) {
1352 if (TopLine(fcell + i)) {
1354 << column_of_cell(fcell + i) + 1
1356 << right_column_of_cell(fcell + i) + 1
1367 if (GetRotateCell(0)) {
1368 os << "\\begin{sideways}\n";
1373 if (GetLinebreaks(cell))
1374 os << "\\smallskip{}}";
1375 if (IsMultiColumn(cell)){
1378 if (GetRotateCell(cell)) {
1379 os << "\n\\end{sideways}";
1382 if (IsLastCellInRow(cell)) {
1383 int row = row_of_cell(cell);
1384 string hline1, hline2;
1385 bool print_hline = true;
1386 bool flag1 = IsLongTabular() &&
1387 ((row == endhead) || (row == endfirsthead) ||
1388 (row == endfoot) || (row == endlastfoot));
1390 bool flag2 = IsLongTabular() &&
1391 ((row <= endhead) || (row <= endfirsthead) ||
1392 (row <= endfoot) || (row <= endlastfoot));
1394 // print the bottom hline only if (otherwise it is doubled):
1395 // - is no LongTabular
1396 // - there IS a first-header
1397 // - the next row is no special header/footer
1398 // & this row is no special header/footer
1399 // - the next row is a special header/footer
1400 // & this row is a special header/footer
1401 bool pr_top_hline = (flag1 && flag2) || (!flag1 && !flag2) ||
1402 (endfirsthead == endhead);
1407 while (!IsFirstCellInRow(fcell))
1409 for (i = 0; i < NumberOfCellsInRow(cell); ++i) {
1410 if (BottomLine(fcell + i))
1413 if (tmp == NumberOfCellsInRow(cell)){
1415 hline1 = "\\hline ";
1418 for (i = 0; i < NumberOfCellsInRow(fcell); ++i) {
1419 if (BottomLine(fcell + i)){
1421 << column_of_cell(fcell + i) + 1
1423 << right_column_of_cell(fcell + i) + 1
1425 hline1 += "\\cline{";
1426 hline1 += tostr(column_of_cell(fcell + i) + 1);
1428 hline1 += tostr(right_column_of_cell(fcell + i) + 1);
1438 if (IsLongTabular() && (row == endfoot)) {
1439 os << "\\endfoot\n";
1441 print_hline = false; // no double line below footer
1443 if (IsLongTabular() && (row == endlastfoot)) {
1444 os << "\\endlastfoot\n";
1446 print_hline = false; // no double line below footer
1448 if (IsLongTabular() && row_info[row].newpage) {
1449 os << "\\newpage\n";
1451 print_hline = false; // no line below a \\newpage-command
1454 if ((nvcell < numberofcells) &&
1455 (cell < GetNumberOfCells() - 1) && !IsLastCell(cell)) {
1457 for (i = 0; i < NumberOfCellsInRow(fcell); ++i) {
1458 if (TopLine(fcell + i))
1461 if (tmp == NumberOfCellsInRow(fcell)) {
1464 hline2 = "\\hline ";
1467 for (i = 0; i < NumberOfCellsInRow(fcell); ++i) {
1468 if (TopLine(fcell + i)) {
1471 << column_of_cell(fcell + i) + 1
1473 << right_column_of_cell(fcell + i) + 1
1476 hline2 += "\\cline{";
1477 hline2 += tostr(column_of_cell(fcell+i)+1);
1479 hline2 += tostr(right_column_of_cell(fcell+i)+1);
1485 if (tmp && print_hline){
1490 // the order here is important as if one defines two
1491 // or more things in one line only the first entry is
1492 // displayed the other are set to an empty-row. This
1493 // is important if I have a footer and want that the
1494 // lastfooter is NOT displayed!!!
1495 bool sflag2 = (row == endhead) || (row == endfirsthead) ||
1496 (row == endfoot) || (row == endlastfoot);
1499 bool sflag1 = IsLongTabular() && (row != endhead) &&
1500 (row != endfirsthead) &&
1501 ((row == endfoot) || (row == endlastfoot));
1503 if (IsLongTabular() && (row == endhead)) {
1504 os << "\\endhead\n";
1507 if (IsLongTabular() && (row == endfirsthead)) {
1508 os << "\\endfirsthead\n";
1511 if (sflag1) { // add the \hline for next foot row
1512 if (!hline1.empty()) {
1513 os << hline1 + '\n';
1517 // add the \hline for the first row
1518 if (pr_top_hline && sflag2) {
1519 if (!hline2.empty()) {
1520 os << hline2 + '\n';
1524 if (nvcell < numberofcells && GetRotateCell(nvcell)) {
1525 os << "\\begin{sideways}\n";
1531 if (nvcell < numberofcells && GetRotateCell(nvcell)) {
1532 os << "\\begin{sideways}\n";
1537 if (nvcell < numberofcells && IsMultiColumn(nvcell)) {
1538 os << "\\multicolumn{"
1539 << cells_in_multicolumn(nvcell)
1541 if (!cellinfo_of_cell(cell+1)->align_special.empty()) {
1542 os << cellinfo_of_cell(cell+1)->align_special
1545 if (LeftLine(nvcell))
1547 if (!GetPWidth(nvcell).empty()) {
1549 << GetPWidth(nvcell)
1552 switch (GetAlignment(nvcell)) {
1553 case LYX_ALIGN_LEFT: os << 'l'; break;
1554 case LYX_ALIGN_RIGHT: os << 'r'; break;
1555 default: os << 'c'; break;
1558 if (RightLine(nvcell))
1560 //if (column_of_cell(cell+2)!= 0 && LeftLine(cell+2))
1561 if (((nvcell + 1) < numberofcells) &&
1562 ((nvcell+1) < numberofcells) &&
1563 (column_of_cell(nvcell+1)!= 0) &&
1570 if (nvcell < numberofcells && GetLinebreaks(nvcell)) {
1571 os << "\\parbox[t]{"
1572 << GetPWidth(nvcell)
1573 << "}{\\smallskip{}";
1581 // cell <0 will tex the preamble
1582 // returns the number of printed newlines
1583 int LyXTabular::RoffEndOfCell(ostream & os, int cell)
1587 if (cell == GetNumberOfCells() - 1){
1588 // the very end at the very beginning
1589 // if (CellHasContRow(cell) >= 0) {
1595 if (row_info[row_of_cell(cell)].bottom_line) {
1599 os << ".TE\n.pl 1c";
1604 os << "\n.pl 500c\n.TS\n";
1605 for (int j = 0; j < rows_; ++j) {
1606 for (int i = 0; i < columns_; ++i, ++fcell) {
1607 if (column_info[i].left_line)
1609 if (cell_info[j][i].multicolumn == CELL_PART_OF_MULTICOLUMN)
1612 switch (column_info[i].alignment) {
1613 case LYX_ALIGN_LEFT:
1616 case LYX_ALIGN_RIGHT:
1624 if (!column_info[i].p_width.empty())
1625 os << "w(" << column_info[i].p_width << ")";
1626 if (column_info[i].right_line)
1629 if ((j + 1) < rows_) {
1636 if (row_info[0].top_line) {
1640 // if (CellHasContRow(0) >= 0) {
1646 // if (CellHasContRow(cell) >= 0) {
1650 if (right_column_of_cell(cell) == columns_ -1){
1653 int row = row_of_cell(cell);
1654 if (row_info[row++].bottom_line) {
1658 if ((row < rows_) && row_info[row].top_line) {
1664 // if ((cell < GetNumberOfCells() - 1) &&
1665 // (CellHasContRow(cell+1) >= 0)) {
1676 char const *LyXTabular::GetDocBookAlign(int cell, bool isColumn) const
1682 i = column_of_cell(cell);
1683 if (!isColumn && IsMultiColumn(cell)) {
1684 if (!cellinfo_of_cell(cell)->align_special.empty()) {
1685 return cellinfo_of_cell(cell)->align_special.c_str();
1687 switch (GetAlignment(cell)) {
1688 case LYX_ALIGN_LEFT:
1690 case LYX_ALIGN_RIGHT:
1697 if (!column_info[i].align_special.empty()) {
1698 return column_info[i].align_special.c_str();
1700 #ifdef IGNORE_THIS_FOR_NOW
1701 else if (!column_info[i].p_width.empty()) {
1703 file += column_info[i].p_width;
1708 switch (column_info[i].alignment) {
1709 case LYX_ALIGN_LEFT:
1711 case LYX_ALIGN_RIGHT:
1721 // cell <0 will tex the preamble
1722 // returns the number of printed newlines
1723 int LyXTabular::DocBookEndOfCell(ostream & os, int cell, int & depth) const
1727 //int tmp; // tmp2; //Â unused
1728 int nvcell; // fcell; //Â unused
1729 if (IsLastCell(cell)) {
1730 os << newlineAndDepth(--depth)
1732 << newlineAndDepth(--depth)
1734 << newlineAndDepth(--depth)
1736 << newlineAndDepth(--depth);
1737 if (is_long_tabular)
1741 << newlineAndDepth(--depth);
1747 if (is_long_tabular)
1753 << "' COLSEP='1' ROWSEP='1'>"
1754 << newlineAndDepth(++depth);
1756 for (i = 0; i < columns_; ++i) {
1757 os << "<COLSPEC ALIGN='"
1758 << GetDocBookAlign(i, true)
1764 if (i == (columns_-1)) {
1767 if (column_info[i].right_line ||
1768 column_info[i+1].left_line)
1774 << newlineAndDepth(depth);
1776 #ifdef NOT_HANDLED_YET_AS_I_DONT_KNOW_HOW
1777 if (column_info[i].left_line)
1782 << newlineAndDepth(++depth)
1784 << newlineAndDepth(++depth)
1786 << GetDocBookAlign(0)
1788 if (IsMultiColumn(0)) {
1789 os << " NAMEST='col1' NAMEEND='col"
1790 << cells_in_multicolumn(0)
1794 << newlineAndDepth(++depth);
1797 if (IsLastCellInRow(cell)) {
1798 os << newlineAndDepth(--depth)
1800 << newlineAndDepth(--depth)
1802 << newlineAndDepth(depth)
1804 << newlineAndDepth(++depth)
1806 << GetDocBookAlign(cell + 1)
1807 << "' VALIGN='middle'";
1808 if (IsMultiColumn(cell + 1)) {
1809 os << " NAMEST='col"
1810 << column_of_cell(cell+1) + 1
1812 << column_of_cell(cell + 1) +
1813 cells_in_multicolumn(cell + 1)
1817 << newlineAndDepth(++depth);
1820 os << newlineAndDepth(--depth)
1822 << newlineAndDepth(depth)
1824 << GetDocBookAlign(cell + 1)
1825 << "' VALIGN='middle'";
1826 if (IsMultiColumn(cell + 1)) {
1827 os << " NAMEST='col"
1828 << column_of_cell(cell+1) + 1
1830 << column_of_cell(cell+1) +
1831 cells_in_multicolumn(cell+1)
1835 << newlineAndDepth(++depth);
1844 bool LyXTabular::IsMultiColumn(int cell) const
1846 return (cellinfo_of_cell(cell)->multicolumn != LyXTabular::CELL_NORMAL);
1850 LyXTabular::cellstruct* LyXTabular::cellinfo_of_cell(int cell) const
1852 int row = row_of_cell(cell);
1853 int column = column_of_cell(cell);
1854 return &cell_info[row][column];
1858 void LyXTabular::SetMultiColumn(int cell, int number)
1860 int new_width = cellinfo_of_cell(cell)->width_of_cell;
1862 cellinfo_of_cell(cell)->multicolumn = LyXTabular::CELL_BEGIN_OF_MULTICOLUMN;
1863 cellinfo_of_cell(cell)->alignment = column_info[column_of_cell(cell)].alignment;
1864 cellinfo_of_cell(cell)->top_line = row_info[row_of_cell(cell)].top_line;
1865 cellinfo_of_cell(cell)->bottom_line = row_info[row_of_cell(cell)].bottom_line;
1866 for (number--; number > 0; --number) {
1867 cellinfo_of_cell(cell+number)->multicolumn =
1868 LyXTabular::CELL_PART_OF_MULTICOLUMN;
1869 new_width += cellinfo_of_cell(cell+number)->width_of_cell;
1871 set_row_column_number_info();
1872 SetWidthOfCell(cell, new_width);
1876 int LyXTabular::cells_in_multicolumn(int cell) const
1878 int row = row_of_cell(cell);
1879 int column = column_of_cell(cell);
1882 while (column < columns_ && cell_info[row][column].multicolumn
1883 == LyXTabular::CELL_PART_OF_MULTICOLUMN){
1891 int LyXTabular::UnsetMultiColumn(int cell)
1893 int row = row_of_cell(cell);
1894 int column = column_of_cell(cell);
1898 if (cell_info[row][column].multicolumn
1899 == LyXTabular::CELL_BEGIN_OF_MULTICOLUMN){
1900 cell_info[row][column].multicolumn = LyXTabular::CELL_NORMAL;
1902 while (column < columns_ &&
1903 cell_info[row][column].multicolumn
1904 == LyXTabular::CELL_PART_OF_MULTICOLUMN){
1905 cell_info[row][column].multicolumn =
1906 LyXTabular::CELL_NORMAL;
1911 set_row_column_number_info();
1916 void LyXTabular::delete_column(int column)
1919 columnstruct * column_info2 = new columnstruct[columns_-1];
1921 for (i = 0; i < column; ++i) {
1922 column_info2[i] = column_info[i];
1924 for (i = column; i < columns_ - 1; ++i) {
1925 column_info2[i] = column_info[i + 1];
1928 delete[] column_info;
1929 column_info = column_info2;
1931 for (i = 0; i < rows_; ++i) {
1932 cellstruct * tmp = cell_info[i];
1933 cell_info[i] = new cellstruct[columns_ - 1](buffer);
1934 for (j = 0; j < column; ++j) {
1935 cell_info[i][j] = tmp[j];
1937 for (j = column; j < columns_ - 1; ++j) {
1938 cell_info[i][j] = tmp[j + 1];
1948 void LyXTabular::SetLongTabular(int what)
1950 is_long_tabular = what;
1954 bool LyXTabular::IsLongTabular() const
1956 return is_long_tabular;
1959 void LyXTabular::SetRotateTabular(int what)
1964 bool LyXTabular::GetRotateTabular() const
1969 void LyXTabular::SetRotateCell(int cell, int what)
1971 cellinfo_of_cell(cell)->rotate = what;
1974 bool LyXTabular::GetRotateCell(int cell) const
1976 return cellinfo_of_cell(cell)->rotate;
1979 bool LyXTabular::NeedRotating() const
1983 for (int i = 0; i < rows_; ++i) {
1984 for (int j = 0; j < columns_; ++j) {
1985 if (cell_info[i][j].rotate)
1993 bool LyXTabular::IsLastCell(int cell) const
1995 if (cell < GetNumberOfCells())
2000 int LyXTabular::GetCellAbove(int cell) const
2002 if (row_of_cell(cell) > 0)
2003 return cell_info[row_of_cell(cell)-1][column_of_cell(cell)].cellno;
2007 int LyXTabular::GetCellNumber(int column, int row) const
2009 if (column >= columns_)
2010 column = columns_ - 1;
2011 else if (column < 0)
2018 return cell_info[row][column].cellno;
2021 void LyXTabular::SetLinebreaks(int cell, bool what)
2023 cellinfo_of_cell(cell)->linebreaks = what;
2026 bool LyXTabular::GetLinebreaks(int cell) const
2028 if (column_info[column_of_cell(cell)].p_width.empty() &&
2029 !(IsMultiColumn(cell) && !cellinfo_of_cell(cell)->p_width.empty()))
2031 return cellinfo_of_cell(cell)->linebreaks;
2034 void LyXTabular::SetLTHead(int cell, bool first)
2036 int row = row_of_cell(cell);
2039 if (row == endfirsthead)
2051 bool LyXTabular::GetRowOfLTHead(int cell) const
2053 if ((endhead+1) > rows_)
2055 return (row_of_cell(cell) == endhead);
2058 bool LyXTabular::GetRowOfLTFirstHead(int cell) const
2060 if ((endfirsthead+1) > rows_)
2062 return (row_of_cell(cell) == endfirsthead);
2065 void LyXTabular::SetLTFoot(int cell, bool last)
2067 int row = row_of_cell(cell);
2070 if (row == endlastfoot)
2082 bool LyXTabular::GetRowOfLTFoot(int cell) const
2084 if ((endfoot+1) > rows_)
2086 return (row_of_cell(cell) == endfoot);
2089 bool LyXTabular::GetRowOfLTLastFoot(int cell) const
2091 if ((endlastfoot+1) > rows_)
2093 return (row_of_cell(cell) == endlastfoot);
2096 void LyXTabular::SetLTNewPage(int cell, bool what)
2098 row_info[row_of_cell(cell)].newpage = what;
2101 bool LyXTabular::GetLTNewPage(int cell) const
2103 return row_info[row_of_cell(cell)].newpage;
2106 void LyXTabular::SetAscentOfRow(int row, int height)
2110 row_info[row].ascent_of_row = height;
2113 void LyXTabular::SetDescentOfRow(int row, int height)
2117 row_info[row].descent_of_row = height;
2120 int LyXTabular::GetAscentOfRow(int row) const
2124 return row_info[row].ascent_of_row;
2127 int LyXTabular::GetDescentOfRow(int row) const
2131 return row_info[row].descent_of_row;
2134 int LyXTabular::GetHeightOfTabular() const
2140 for(row=0,height=0;(row<rows_); ++row)
2141 height += GetAscentOfRow(row) + GetDescentOfRow(row) +
2142 GetAdditionalHeight(GetCellNumber(0,row));
2146 bool LyXTabular::IsPartOfMultiColumn(int row, int column) const
2148 if ((row >= rows_) || (column >= columns_))
2150 return (cell_info[row][column].multicolumn==CELL_PART_OF_MULTICOLUMN);
2153 int LyXTabular::Latex(ostream &) const
2158 InsetText * LyXTabular::GetCellInset(int cell) const
2160 return cell_info[row_of_cell(cell)][column_of_cell(cell)].inset;