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"
34 static int const WIDTH_OF_LINE = 5;
36 /// Define a few methods for the inner structs
38 LyXTabular::cellstruct::cellstruct(Buffer * buf)
40 cellno = 0; //should be initilaized correctly later.
42 multicolumn = LyXTabular::CELL_NORMAL;
43 alignment = LYX_ALIGN_CENTER;
48 inset = new InsetText(buf);
51 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(rows_arg, columns_arg);
128 LyXTabular::LyXTabular(LyXTabular const & lt, Buffer * buf)
131 Init(lt.rows_, lt.columns_);
136 LyXTabular::LyXTabular(LyXLex & lex, Buffer *buf)
143 LyXTabular::~LyXTabular()
146 delete[] columnofcell;
147 delete[] column_info;
149 for (int i = 0; i < rows_; ++i) {
150 delete[] cell_info[i];
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(int rows_arg, int columns_arg)
221 columns_ = columns_arg;
222 column_info = new columnstruct[columns_];
223 row_info = new rowstruct[rows_];
224 cell_info = new cellstruct*[rows_];
227 for (i = 0; i < rows_; ++i) {
228 cell_info[i] = new cellstruct[columns_](buffer);
229 for (j = 0; j < columns_; ++j) {
230 cell_info[i][j].cellno = cellno++;
233 row_info[i-1].bottom_line = true;
234 row_info[0].bottom_line = true;
236 for (i = 0; i < columns_; ++i) {
237 calculate_width_of_column(i);
239 column_info[columns_-1].right_line = true;
241 calculate_width_of_tabular();
245 set_row_column_number_info();
246 is_long_tabular = false;
255 void LyXTabular::AppendRow(int cell)
257 int row = row_of_cell(cell);
258 rowstruct * row_info2 = new rowstruct[rows_ + 1];
259 cellstruct ** cell_info2 = new cellstruct * [rows_ + 1];
262 for (i = 0; i <= row; ++i) {
263 cell_info2[i] = cell_info[i];
264 row_info2[i] = row_info[i];
266 for (i = rows_ - 1; i >= row; --i) {
267 cell_info2[i + 1] = cell_info[i];
268 row_info2[i + 1] = row_info[i];
270 row_info2[row + 1].top_line = row_info[i].top_line;
271 cell_info2[row + 1] = new cellstruct[columns_](buffer);
272 for (i = 0; i < columns_; ++i) {
273 cell_info2[row + 1][i].width_of_cell = 0;
274 cell_info2[row + 1][i] = cell_info2[row][i];
278 cell_info = cell_info2;
280 row_info = row_info2;
288 void LyXTabular::DeleteRow(int cell)
290 int row = row_of_cell(cell);
291 rowstruct * row_info2 = new rowstruct[rows_ - 1];
292 cellstruct ** cell_info2 = new cellstruct * [rows_ - 1];
294 delete[] cell_info[row];
296 for (; i < row; ++i) {
297 cell_info2[i] = cell_info[i];
298 row_info2[i] = row_info[i];
300 for (i = row; i < rows_ - 1; ++i) {
301 cell_info2[i] = cell_info[i + 1];
302 row_info2[i] = row_info[i + 1];
306 cell_info = cell_info2;
308 row_info = row_info2;
316 void LyXTabular::AppendColumn(int cell)
319 columnstruct * column_info2 = new columnstruct[columns_ + 1];
320 int column = right_column_of_cell(cell);
323 for (; i <= column; ++i) {
324 column_info2[i] = column_info[i];
326 for (i = columns_ - 1; i >= column; --i) {
327 column_info2[i + 1] = column_info[i];
330 delete[] column_info;
331 column_info = column_info2;
333 for (i = 0; i < rows_; ++i) {
334 cellstruct * tmp = cell_info[i];
335 cell_info[i] = new cellstruct[columns_ + 1](buffer);
336 for (j = 0; j <= column; ++j) {
337 cell_info[i][j] = tmp[j];
339 for (j = column; j < columns_; ++j) {
340 cell_info[i][j + 1] = tmp[j];
342 // care about multicolumns
343 if (cell_info[i][column + 1].multicolumn
344 == LyXTabular::CELL_BEGIN_OF_MULTICOLUMN){
345 cell_info[i][column + 1].multicolumn =
346 LyXTabular::CELL_PART_OF_MULTICOLUMN;
348 if (column + 1 == columns_
349 || cell_info[i][column + 2].multicolumn
350 != LyXTabular::CELL_PART_OF_MULTICOLUMN){
351 cell_info[i][column + 1].multicolumn =
352 LyXTabular::CELL_NORMAL;
362 void LyXTabular::Reinit()
367 for (; i < rows_; ++i) {
368 for (j = 0; j < columns_; ++j) {
369 cell_info[i][j].width_of_cell = 0;
373 for (i = 0; i < columns_; ++i) {
374 calculate_width_of_column(i);
376 calculate_width_of_tabular();
378 set_row_column_number_info();
382 void LyXTabular::set_row_column_number_info()
388 for (; row < rows_; ++row) {
389 for (column = 0; column<columns_; ++column) {
390 if (cell_info[row][column].multicolumn
391 != LyXTabular::CELL_PART_OF_MULTICOLUMN)
393 cell_info[row][column].cellno = numberofcells;
396 ++numberofcells; // because this is one more than as we start from 0
401 rowofcell = new int[numberofcells];
402 delete [] columnofcell;
403 columnofcell = new int[numberofcells];
405 while (c < numberofcells && row < rows_ && column < columns_) {
407 columnofcell[c] = column;
411 } while (column < columns_ &&
412 cell_info[row][column].multicolumn
413 == LyXTabular::CELL_PART_OF_MULTICOLUMN);
414 if (column == columns_) {
422 void LyXTabular::DeleteColumn(int cell)
424 int column1 = column_of_cell(cell);
425 int column2 = right_column_of_cell(cell);
427 if (column1 == 0 && column2 == columns_ - 1)
430 for (int column = column1; column <= column2; ++column) {
431 delete_column(column1);
437 int LyXTabular::GetNumberOfCells() const
439 return numberofcells;
443 int LyXTabular::NumberOfCellsInRow(int cell) const
445 int row = row_of_cell(cell);
447 for (int i = 0; i < columns_; ++i) {
448 if (cell_info[row][i].multicolumn != LyXTabular::CELL_PART_OF_MULTICOLUMN)
455 int LyXTabular::AppendCellAfterCell(int append_cell, int question_cell)
457 return (right_column_of_cell(append_cell) ==
458 right_column_of_cell(question_cell));
462 int LyXTabular::DeleteCellIfColumnIsDeleted(int cell, int delete_column_cell)
464 if (column_of_cell(delete_column_cell) == 0 &&
465 right_column_of_cell(delete_column_cell) == columns_ - 1)
469 (column_of_cell(cell) >= column_of_cell(delete_column_cell) &&
470 column_of_cell(cell) <= right_column_of_cell(delete_column_cell));
474 /* returns 1 if there is a topline, returns 0 if not */
475 bool LyXTabular::TopLine(int cell) const
477 int row = row_of_cell(cell);
479 if (IsMultiColumn(cell))
480 return cellinfo_of_cell(cell)->top_line;
481 return row_info[row].top_line;
485 bool LyXTabular::BottomLine(int cell) const
487 //no bottom line underneath non-existent cells if you please
488 if(cell >= numberofcells)
491 if (IsMultiColumn(cell))
492 return cellinfo_of_cell(cell)->bottom_line;
493 return row_info[row_of_cell(cell)].bottom_line;
497 bool LyXTabular::LeftLine(int cell) const
499 return column_info[column_of_cell(cell)].left_line;
503 bool LyXTabular::RightLine(int cell) const
505 return column_info[right_column_of_cell(cell)].right_line;
509 bool LyXTabular::TopAlreadyDrawed(int cell) const
511 if (GetAdditionalHeight(cell))
513 int row = row_of_cell(cell);
515 int column = column_of_cell(cell);
518 && cell_info[row][column].multicolumn
519 == LyXTabular::CELL_PART_OF_MULTICOLUMN)
521 if (cell_info[row][column].multicolumn == LyXTabular::CELL_NORMAL)
522 return row_info[row].bottom_line;
524 return cell_info[row][column].bottom_line;
530 bool LyXTabular::LeftAlreadyDrawed(int cell) const
532 int column = column_of_cell(cell);
534 int row = row_of_cell(cell);
536 (cell_info[row][column].multicolumn ==
537 LyXTabular::CELL_PART_OF_MULTICOLUMN));
538 if (GetAdditionalWidth(cell_info[row][column].cellno))
540 return column_info[column].right_line;
546 bool LyXTabular::IsLastRow(int cell) const
548 return (row_of_cell(cell) == rows_ - 1);
552 int LyXTabular::GetAdditionalHeight(int cell) const
554 int row = row_of_cell(cell);
557 int top = 1; // bool top = true; ??
558 int bottom = 1; // bool bottom = true; ??
561 for (column = 0; column < columns_ - 1 && bottom; ++column) {
562 switch (cell_info[row - 1][column].multicolumn) {
563 case LyXTabular::CELL_BEGIN_OF_MULTICOLUMN:
564 bottom = cell_info[row - 1][column].bottom_line;
566 case LyXTabular::CELL_NORMAL:
567 bottom = row_info[row - 1].bottom_line;
570 for (column = 0; column < columns_ - 1 && top; ++column) {
571 switch (cell_info[row][column].multicolumn){
572 case LyXTabular::CELL_BEGIN_OF_MULTICOLUMN:
573 top = cell_info[row][column].top_line;
575 case LyXTabular::CELL_NORMAL:
576 top = row_info[row].top_line;
580 return WIDTH_OF_LINE;
585 int LyXTabular::GetAdditionalWidth(int cell) const
587 // internally already set in SetWidthOfCell
588 // used to get it back in text.C
589 int col = right_column_of_cell(cell);
590 if (col < columns_ - 1 && column_info[col].right_line &&
591 column_info[col+1].left_line)
592 return WIDTH_OF_LINE;
598 // returns the maximum over all rows
599 int LyXTabular::GetWidthOfColumn(int cell) const
601 int column1 = column_of_cell(cell);
602 int column2 = right_column_of_cell(cell);
605 for (; i <= column2; ++i) {
606 result += column_info[i].width_of_column;
612 int LyXTabular::GetWidthOfTabular() const
614 return width_of_tabular;
617 /* returns 1 if a complete update is necessary, otherwise 0 */
618 bool LyXTabular::SetWidthOfMulticolCell(int cell, int new_width)
620 if (!IsMultiColumn(cell))
623 int row = row_of_cell(cell);
624 int column1 = column_of_cell(cell);
625 int column2 = right_column_of_cell(cell);
627 // first set columns to 0 so we can calculate the right width
629 for (; i <= column2; ++i) {
630 cell_info[row][i].width_of_cell = 0;
632 // set the width to MAX_WIDTH until width > 0
633 int width = (new_width + 2 * WIDTH_OF_LINE);
634 for (i = column1; (i < column2) && (width > 0); ++i) {
635 cell_info[row][i].width_of_cell = column_info[i].width_of_column;
636 width -= column_info[i].width_of_column;
639 cell_info[row][i].width_of_cell = width;
645 void LyXTabular::recalculateMulticolCells(int cell, int new_width)
647 int row = row_of_cell(cell);
648 int column1 = column_of_cell(cell);
649 int column2 = right_column_of_cell(cell);
651 // first set columns to 0 so we can calculate the right width
653 for (; i <= column2; ++i)
654 cell_info[row][i].width_of_cell = 0;
655 for(i = cell + 1; (i < numberofcells) && (!IsMultiColumn(i)); ++i)
657 if (i < numberofcells)
658 recalculateMulticolCells(i, GetWidthOfCell(i) - (2 * WIDTH_OF_LINE));
659 SetWidthOfMulticolCell(cell, new_width);
663 /* returns 1 if a complete update is necessary, otherwise 0 */
664 bool LyXTabular::SetWidthOfCell(int cell, int new_width)
666 int row = row_of_cell(cell);
667 int column1 = column_of_cell(cell);
671 if (IsMultiColumn(cell)) {
672 tmp = SetWidthOfMulticolCell(cell, new_width);
674 width = (new_width + 2*WIDTH_OF_LINE);
675 cell_info[row][column1].width_of_cell = width;
676 if (column_info[column1].right_line && (column1 < columns_-1) &&
677 column_info[column1+1].left_line) // additional width
678 cell_info[row][column1].width_of_cell += WIDTH_OF_LINE;
679 tmp = calculate_width_of_column_NMC(column1);
683 for(i = 0; i<columns_;++i)
684 calculate_width_of_column_NMC(i);
685 for(i = 0; (i<numberofcells) && !IsMultiColumn(i); ++i)
688 recalculateMulticolCells(i, GetWidthOfCell(i)-(2*WIDTH_OF_LINE));
689 for(i = 0; i<columns_;++i)
690 calculate_width_of_column(i);
691 calculate_width_of_tabular();
698 bool LyXTabular::SetAlignment(int cell, char align)
700 if (!IsMultiColumn(cell))
701 column_info[column_of_cell(cell)].alignment = align;
702 cellinfo_of_cell(cell)->alignment = align;
706 bool LyXTabular::SetPWidth(int cell, string width)
708 if (IsMultiColumn(cell)) {
709 cellinfo_of_cell(cell)->p_width = width;
711 column_info[column_of_cell(cell)].p_width = width;
712 if (!width.empty()) // do this only if there is a width
713 SetAlignment(cell, LYX_ALIGN_LEFT);
718 bool LyXTabular::SetAlignSpecial(int cell, string special, int what)
720 if (what == SET_SPECIAL_MULTI)
721 cellinfo_of_cell(cell)->align_special = special;
723 column_info[column_of_cell(cell)].align_special = special;
727 bool LyXTabular::SetAllLines(int cell, bool line)
729 SetTopLine(cell, line);
730 SetBottomLine(cell, line);
731 SetRightLine(cell, line);
732 SetLeftLine(cell, line);
736 bool LyXTabular::SetTopLine(int cell, bool line)
738 int row = row_of_cell(cell);
740 if (!IsMultiColumn(cell))
741 row_info[row].top_line = line;
743 cellinfo_of_cell(cell)->top_line = line;
748 bool LyXTabular::SetBottomLine(int cell, bool line)
750 if (!IsMultiColumn(cell))
751 row_info[row_of_cell(cell)].bottom_line = line;
753 cellinfo_of_cell(cell)->bottom_line = line;
758 bool LyXTabular::SetLeftLine(int cell, bool line)
760 column_info[column_of_cell(cell)].left_line = line;
765 bool LyXTabular::SetRightLine(int cell, bool line)
767 column_info[right_column_of_cell(cell)].right_line = line;
772 char LyXTabular::GetAlignment(int cell) const
774 if (IsMultiColumn(cell))
775 return cellinfo_of_cell(cell)->alignment;
777 return column_info[column_of_cell(cell)].alignment;
780 string LyXTabular::GetPWidth(int cell) const
782 if (IsMultiColumn(cell))
783 return cellinfo_of_cell(cell)->p_width;
784 return column_info[column_of_cell(cell)].p_width;
787 string LyXTabular::GetAlignSpecial(int cell, int what) const
789 if (what == SET_SPECIAL_MULTI)
790 return cellinfo_of_cell(cell)->align_special;
791 return column_info[column_of_cell(cell)].align_special;
794 int LyXTabular::GetWidthOfCell(int cell) const
796 int row = row_of_cell(cell);
797 int column1 = column_of_cell(cell);
798 int column2 = right_column_of_cell(cell);
801 for (; i <= column2; ++i) {
802 result += cell_info[row][i].width_of_cell;
805 // result += GetAdditionalWidth(cell);
811 int LyXTabular::GetBeginningOfTextInCell(int cell) const
815 switch (GetAlignment(cell)){
816 case LYX_ALIGN_CENTER:
817 x += (GetWidthOfColumn(cell) - GetWidthOfCell(cell)) / 2;
819 case LYX_ALIGN_RIGHT:
820 x += GetWidthOfColumn(cell) - GetWidthOfCell(cell);
821 // + GetAdditionalWidth(cell);
823 default: /* LYX_ALIGN_LEFT: nothing :-) */
833 bool LyXTabular::IsFirstCellInRow(int cell) const
835 return (column_of_cell(cell) == 0);
838 bool LyXTabular::IsLastCellInRow(int cell) const
840 return (right_column_of_cell(cell) == (columns_ - 1));
844 bool LyXTabular::calculate_width_of_column(int column)
846 int old_column_width = column_info[column].width_of_column;
849 for (int i = 0; i < rows_; ++i) {
850 maximum = max(cell_info[i][column].width_of_cell, maximum);
852 column_info[column].width_of_column = maximum;
853 return (column_info[column].width_of_column != old_column_width);
856 bool LyXTabular::calculate_width_of_column_NMC(int column)
858 int old_column_width = column_info[column].width_of_column;
860 for (int i = 0; i < rows_; ++i) {
861 if (!IsMultiColumn(GetCellNumber(column, i)) &&
862 (cell_info[i][column].width_of_cell > max)) {
863 max = cell_info[i][column].width_of_cell;
866 column_info[column].width_of_column = max;
867 return (column_info[column].width_of_column != old_column_width);
870 void LyXTabular::calculate_width_of_tabular()
872 width_of_tabular = 0;
873 for (int i = 0; i < columns_; ++i) {
874 width_of_tabular += column_info[i].width_of_column;
879 int LyXTabular::row_of_cell(int cell) const
881 if (cell >= numberofcells)
885 return rowofcell[cell];
889 int LyXTabular::column_of_cell(int cell) const
891 if (cell >= numberofcells)
895 return columnofcell[cell];
899 int LyXTabular::right_column_of_cell(int cell) const
901 int row = row_of_cell(cell);
902 int column = column_of_cell(cell);
903 while (column < (columns_ - 1) &&
904 cell_info[row][column+1].multicolumn == LyXTabular::CELL_PART_OF_MULTICOLUMN)
910 void LyXTabular::Write(ostream & os) const
915 os << "<LyXTabular version=1 rows=" << rows_ << " columns=" << columns_ <<
917 // global longtable options
918 os << "<Features rotate=" << rotate <<
919 " islongtable=" << is_long_tabular <<
920 " endhead=" << endhead << " endfirsthead=" << endfirsthead <<
921 " endfoot=" << endfoot << " endlastfoot=" << endlastfoot <<
923 for (i = 0; i < rows_; ++i) {
924 os << "<Row topline=" << row_info[i].top_line <<
925 " bottomline=" << row_info[i].bottom_line <<
926 " newpage=" << row_info[i].newpage <<
928 for (j = 0; j < columns_; ++j) {
930 os << "<Column alignment=" << column_info[j].alignment <<
931 " leftline=" << column_info[j].left_line <<
932 " rightline=" << column_info[j].right_line <<
933 " width=\"" << VSpace(column_info[j].p_width).asLyXCommand() <<
934 "\" special=\"" << column_info[j].align_special <<
937 os << "<Column>" << endl;
939 os << "<Cell multicolumn=" << cell_info[i][j].multicolumn <<
940 " alignment=" << cell_info[i][j].alignment <<
941 " topline=" << cell_info[i][j].top_line <<
942 " bottomline=" << cell_info[i][j].bottom_line <<
943 " rotate=" << cell_info[i][j].rotate <<
944 " linebreaks=" << cell_info[i][j].linebreaks <<
945 " width=\"" << cell_info[i][j].p_width <<
946 "\" special=\"" << cell_info[i][j].align_special <<
948 os << "\\begin_inset ";
949 cell_info[i][j].inset->Write(os);
950 os << "\n\\end_inset " << endl;
951 os << "</Cell>" << endl;
952 os << "</Column>" << endl;
954 os << "</Row>" << endl;
956 os << "</LyXTabular>" << endl;
959 static bool getTokenValue(string const str, const char * token, string & ret)
961 int pos = str.find(token);
962 char ch = str[pos+strlen(token)];
964 if ((pos < 0) || (ch != '='))
967 pos += strlen(token)+1;
969 if ((ch != '"') && (ch != '\'')) { // only read till next space
973 while((pos < int(str.length()-1)) && (str[++pos] != ch))
979 static bool getTokenValue(string const str, const char * token, int & num)
982 int pos = str.find(token);
983 char ch = str[pos+strlen(token)];
985 if ((pos < 0) || (ch != '='))
988 pos += strlen(token)+1;
990 if ((ch != '"') && (ch != '\'')) { // only read till next space
996 while((pos < int(str.length()-1)) && isdigit(str[pos]))
1003 static bool getTokenValue(string const str, const char * token, bool & flag)
1006 int pos = str.find(token);
1007 char ch = str[pos+strlen(token)];
1009 if ((pos < 0) || (ch != '='))
1012 pos += strlen(token)+1;
1014 if ((ch != '"') && (ch != '\'')) { // only read till next space
1020 while((pos < int(str.length()-1)) && isdigit(str[pos]))
1023 flag = strToInt(ret);
1027 void l_getline(istream & is, string & str)
1034 void LyXTabular::Read(LyXLex & lex)
1037 istream & is = lex.getStream();
1039 l_getline(is, line);
1040 if (!prefixIs(line, "<LyXTabular ")) {
1041 OldFormatRead(is, line);
1048 if (!getTokenValue(line, "version", version))
1050 if (!getTokenValue(line, "rows", rows_arg))
1052 if (!getTokenValue(line, "columns", columns_arg))
1054 Init(rows_arg, columns_arg);
1055 l_getline(is, line);
1056 if (!prefixIs(line, "<Features ")) {
1057 lyxerr << "Wrong tabular format (expected <Feture ...> got" <<
1058 line << ")" << endl;
1061 (void)getTokenValue(line, "islongtable", is_long_tabular);
1062 (void)getTokenValue(line, "endhead", endhead);
1063 (void)getTokenValue(line, "endfirsthead", endfirsthead);
1064 (void)getTokenValue(line, "endfoot", endfoot);
1065 (void)getTokenValue(line, "endlastfoot", endlastfoot);
1067 for(i = 0; i < rows_; ++i) {
1068 l_getline(is, line);
1069 if (!prefixIs(line, "<Row ")) {
1070 lyxerr << "Wrong tabular format (expected <Row ...> got" <<
1071 line << ")" << endl;
1074 (void)getTokenValue(line, "topline", row_info[i].top_line);
1075 (void)getTokenValue(line, "bottomline", row_info[i].bottom_line);
1076 (void)getTokenValue(line, "newpage", row_info[i].newpage);
1077 for (j = 0; j < columns_; ++j) {
1079 if (!prefixIs(line,"<Column")) {
1080 lyxerr << "Wrong tabular format (expected <Column ...> got" <<
1081 line << ")" << endl;
1085 (void)getTokenValue(line, "alignment", column_info[j].alignment);
1086 (void)getTokenValue(line, "leftline", column_info[j].left_line);
1087 (void)getTokenValue(line, "rightline", column_info[j].right_line);
1088 (void)getTokenValue(line, "width", column_info[j].p_width);
1089 (void)getTokenValue(line, "special", column_info[j].align_special);
1091 l_getline(is, line);
1092 if (!prefixIs(line, "<Cell")) {
1093 lyxerr << "Wrong tabular format (expected <Cell ...> got" <<
1094 line << ")" << endl;
1097 (void)getTokenValue(line, "multicolumn", cell_info[i][j].multicolumn);
1098 (void)getTokenValue(line, "alignment", cell_info[i][j].alignment);
1099 (void)getTokenValue(line, "topline", cell_info[i][j].top_line);
1100 (void)getTokenValue(line, "bottomline", cell_info[i][j].bottom_line);
1101 (void)getTokenValue(line, "rotate", cell_info[i][j].rotate);
1102 (void)getTokenValue(line, "linebreaks", cell_info[i][j].linebreaks);
1103 (void)getTokenValue(line, "width", cell_info[i][j].p_width);
1104 (void)getTokenValue(line, "special", cell_info[i][j].align_special);
1105 l_getline(is, line);
1106 if (prefixIs(line, "\\begin_inset")) {
1107 cell_info[i][j].inset->Read(lex);
1108 l_getline(is, line);
1110 if (line != "</Cell>") {
1111 lyxerr << "Wrong tabular format (expected </Cell> got" <<
1112 line << ")" << endl;
1115 l_getline(is, line);
1116 if (line != "</Column>") {
1117 lyxerr << "Wrong tabular format (expected </Column> got" <<
1118 line << ")" << endl;
1122 l_getline(is, line);
1123 if (line != "</Row>") {
1124 lyxerr << "Wrong tabular format (expected </Row> got" <<
1125 line << ")" << endl;
1129 while (line != "</LyXTabular>") {
1130 l_getline(is, line);
1132 set_row_column_number_info();
1135 void LyXTabular::OldFormatRead(istream & is, string fl)
1140 int columns_arg = 0;
1141 int is_long_tabular_arg = false;
1142 int rotate_arg = false;
1155 version = atoi(s.c_str() + 8);
1159 lyxerr << "Tabular format < 5 is not supported anymore\n"
1160 "Get an older version of LyX (< 1.1.x) for conversion!"
1162 WriteAlert(_("Warning:"),
1163 _("Tabular format < 5 is not supported anymore\n"),
1164 _("Get an older version of LyX (< 1.1.x) for conversion!"));
1166 is >> rows_arg >> columns_arg >> is_long_tabular_arg
1167 >> rotate_arg >> a >> b >> c >> d;
1169 is >> rows_arg >> columns_arg;
1170 Init(rows_arg, columns_arg);
1171 SetLongTabular(is_long_tabular_arg);
1172 SetRotateTabular(rotate_arg);
1174 for (i = 0; i < rows_; ++i) {
1177 for (i = 0; i < columns_; ++i) {
1180 for (i = 0; i < rows_; ++i) {
1181 for (j = 0; j < columns_; ++j) {
1185 set_row_column_number_info();
1188 is >> rows_arg >> columns_arg >> is_long_tabular_arg
1189 >> rotate_arg >> a >> b >> c >> d;
1190 Init(rows_arg, columns_arg);
1191 SetLongTabular(is_long_tabular_arg);
1192 SetRotateTabular(rotate_arg);
1197 for (i = 0; i < rows_; ++i) {
1198 a = b = c = d = e = f = g = h = 0;
1199 is >> a >> b >> c >> d;
1200 row_info[i].top_line = a;
1201 row_info[i].bottom_line = b;
1202 // row_info[i].is_cont_row = c;
1203 row_info[i].newpage = d;
1205 for (i = 0; i < columns_; ++i) {
1209 char ch; // skip '"'
1211 getline(is, s1, '"');
1212 is >> ch; // skip '"'
1213 getline(is, s2, '"');
1214 column_info[i].alignment = static_cast<char>(a);
1215 column_info[i].left_line = b;
1216 column_info[i].right_line = c;
1217 column_info[i].p_width = s1;
1218 column_info[i].align_special = s2;
1220 for (i = 0; i < rows_; ++i) {
1221 for (j = 0; j < columns_; ++j) {
1224 is >> a >> b >> c >> d >> e >> f >> g;
1226 is >> ch; // skip '"'
1227 getline(is, s1, '"');
1228 is >> ch; // skip '"'
1229 getline(is, s2, '"');
1230 cell_info[i][j].multicolumn = static_cast<char>(a);
1231 cell_info[i][j].alignment = static_cast<char>(b);
1232 cell_info[i][j].top_line = static_cast<char>(c);
1233 cell_info[i][j].bottom_line = static_cast<char>(d);
1234 // cell_info[i][j].has_cont_row = static_cast<bool>(e);
1235 cell_info[i][j].rotate = static_cast<bool>(f);
1236 cell_info[i][j].linebreaks = static_cast<bool>(g);
1237 cell_info[i][j].align_special = s1;
1238 cell_info[i][j].p_width = s2;
1241 set_row_column_number_info();
1245 // cell < 0 will tex the preamble
1246 // returns the number of printed newlines
1247 int LyXTabular::TexEndOfCell(ostream & os, int cell) const
1253 if (IsLastCell(cell)) {
1254 // the very end at the very beginning
1255 if (GetLinebreaks(cell))
1256 os << "\\smallskip{}}";
1257 if (IsMultiColumn(cell))
1259 if (GetRotateCell(cell)) {
1260 os << "\n\\end{sideways}";
1268 while (!IsFirstCellInRow(fcell)) --fcell;
1269 for (i = 0; i < NumberOfCellsInRow(fcell); ++i) {
1270 if (BottomLine(fcell + i))
1273 if (tmp == NumberOfCellsInRow(fcell)) {
1277 for (i = 0; i < NumberOfCellsInRow(fcell); ++i) {
1278 if (BottomLine(fcell + i)) {
1280 << column_of_cell(fcell + i) + 1
1282 << right_column_of_cell(fcell + i) + 1
1292 if (is_long_tabular)
1293 os << "\\end{longtable}";
1295 os << "\\end{tabular}";
1297 os << "\n\\end{sideways}";
1305 os << "\\begin{sideways}\n";
1308 if (is_long_tabular)
1309 os << "\\begin{longtable}{";
1311 os << "\\begin{tabular}{";
1312 for (i = 0; i < columns_; ++i) {
1313 if (column_info[i].left_line)
1315 if (!column_info[i].align_special.empty()) {
1316 os << column_info[i].align_special;
1317 } else if (!column_info[i].p_width.empty()) {
1319 << column_info[i].p_width
1322 switch (column_info[i].alignment) {
1323 case LYX_ALIGN_LEFT:
1326 case LYX_ALIGN_RIGHT:
1334 if (column_info[i].right_line)
1340 if (GetNumberOfCells()) {
1342 for (i = 0; i < NumberOfCellsInRow(fcell); ++i) {
1343 if (TopLine(fcell + i))
1346 if (tmp == NumberOfCellsInRow(fcell)){
1350 for (i = 0; i < NumberOfCellsInRow(fcell); ++i) {
1351 if (TopLine(fcell + i)) {
1353 << column_of_cell(fcell + i) + 1
1355 << right_column_of_cell(fcell + i) + 1
1366 if (GetRotateCell(0)) {
1367 os << "\\begin{sideways}\n";
1372 if (GetLinebreaks(cell))
1373 os << "\\smallskip{}}";
1374 if (IsMultiColumn(cell)){
1377 if (GetRotateCell(cell)) {
1378 os << "\n\\end{sideways}";
1381 if (IsLastCellInRow(cell)) {
1382 int row = row_of_cell(cell);
1383 string hline1, hline2;
1384 bool print_hline = true;
1385 bool flag1 = IsLongTabular() &&
1386 ((row == endhead) || (row == endfirsthead) ||
1387 (row == endfoot) || (row == endlastfoot));
1389 bool flag2 = IsLongTabular() &&
1390 ((row <= endhead) || (row <= endfirsthead) ||
1391 (row <= endfoot) || (row <= endlastfoot));
1393 // print the bottom hline only if (otherwise it is doubled):
1394 // - is no LongTabular
1395 // - there IS a first-header
1396 // - the next row is no special header/footer
1397 // & this row is no special header/footer
1398 // - the next row is a special header/footer
1399 // & this row is a special header/footer
1400 bool pr_top_hline = (flag1 && flag2) || (!flag1 && !flag2) ||
1401 (endfirsthead == endhead);
1406 while (!IsFirstCellInRow(fcell))
1408 for (i = 0; i < NumberOfCellsInRow(cell); ++i) {
1409 if (BottomLine(fcell + i))
1412 if (tmp == NumberOfCellsInRow(cell)){
1414 hline1 = "\\hline ";
1417 for (i = 0; i < NumberOfCellsInRow(fcell); ++i) {
1418 if (BottomLine(fcell + i)){
1420 << column_of_cell(fcell + i) + 1
1422 << right_column_of_cell(fcell + i) + 1
1424 hline1 += "\\cline{";
1425 hline1 += tostr(column_of_cell(fcell + i) + 1);
1427 hline1 += tostr(right_column_of_cell(fcell + i) + 1);
1437 if (IsLongTabular() && (row == endfoot)) {
1438 os << "\\endfoot\n";
1440 print_hline = false; // no double line below footer
1442 if (IsLongTabular() && (row == endlastfoot)) {
1443 os << "\\endlastfoot\n";
1445 print_hline = false; // no double line below footer
1447 if (IsLongTabular() && row_info[row].newpage) {
1448 os << "\\newpage\n";
1450 print_hline = false; // no line below a \\newpage-command
1453 if ((nvcell < numberofcells) &&
1454 (cell < GetNumberOfCells() - 1) && !IsLastCell(cell)) {
1456 for (i = 0; i < NumberOfCellsInRow(fcell); ++i) {
1457 if (TopLine(fcell + i))
1460 if (tmp == NumberOfCellsInRow(fcell)) {
1463 hline2 = "\\hline ";
1466 for (i = 0; i < NumberOfCellsInRow(fcell); ++i) {
1467 if (TopLine(fcell + i)) {
1470 << column_of_cell(fcell + i) + 1
1472 << right_column_of_cell(fcell + i) + 1
1475 hline2 += "\\cline{";
1476 hline2 += tostr(column_of_cell(fcell+i)+1);
1478 hline2 += tostr(right_column_of_cell(fcell+i)+1);
1484 if (tmp && print_hline){
1489 // the order here is important as if one defines two
1490 // or more things in one line only the first entry is
1491 // displayed the other are set to an empty-row. This
1492 // is important if I have a footer and want that the
1493 // lastfooter is NOT displayed!!!
1494 bool sflag2 = (row == endhead) || (row == endfirsthead) ||
1495 (row == endfoot) || (row == endlastfoot);
1498 bool sflag1 = IsLongTabular() && (row != endhead) &&
1499 (row != endfirsthead) &&
1500 ((row == endfoot) || (row == endlastfoot));
1502 if (IsLongTabular() && (row == endhead)) {
1503 os << "\\endhead\n";
1506 if (IsLongTabular() && (row == endfirsthead)) {
1507 os << "\\endfirsthead\n";
1510 if (sflag1) { // add the \hline for next foot row
1511 if (!hline1.empty()) {
1512 os << hline1 + '\n';
1516 // add the \hline for the first row
1517 if (pr_top_hline && sflag2) {
1518 if (!hline2.empty()) {
1519 os << hline2 + '\n';
1523 if (nvcell < numberofcells && GetRotateCell(nvcell)) {
1524 os << "\\begin{sideways}\n";
1530 if (nvcell < numberofcells && GetRotateCell(nvcell)) {
1531 os << "\\begin{sideways}\n";
1536 if (nvcell < numberofcells && IsMultiColumn(nvcell)) {
1537 os << "\\multicolumn{"
1538 << cells_in_multicolumn(nvcell)
1540 if (!cellinfo_of_cell(cell+1)->align_special.empty()) {
1541 os << cellinfo_of_cell(cell+1)->align_special
1544 if (LeftLine(nvcell))
1546 if (!GetPWidth(nvcell).empty()) {
1548 << GetPWidth(nvcell)
1551 switch (GetAlignment(nvcell)) {
1552 case LYX_ALIGN_LEFT: os << 'l'; break;
1553 case LYX_ALIGN_RIGHT: os << 'r'; break;
1554 default: os << 'c'; break;
1557 if (RightLine(nvcell))
1559 //if (column_of_cell(cell+2)!= 0 && LeftLine(cell+2))
1560 if (((nvcell + 1) < numberofcells) &&
1561 ((nvcell+1) < numberofcells) &&
1562 (column_of_cell(nvcell+1)!= 0) &&
1569 if (nvcell < numberofcells && GetLinebreaks(nvcell)) {
1570 os << "\\parbox[t]{"
1571 << GetPWidth(nvcell)
1572 << "}{\\smallskip{}";
1580 // cell <0 will tex the preamble
1581 // returns the number of printed newlines
1582 int LyXTabular::RoffEndOfCell(ostream & os, int cell)
1586 if (cell == GetNumberOfCells() - 1){
1587 // the very end at the very beginning
1588 // if (CellHasContRow(cell) >= 0) {
1594 if (row_info[row_of_cell(cell)].bottom_line) {
1598 os << ".TE\n.pl 1c";
1603 os << "\n.pl 500c\n.TS\n";
1604 for (int j = 0; j < rows_; ++j) {
1605 for (int i = 0; i < columns_; ++i, ++fcell) {
1606 if (column_info[i].left_line)
1608 if (cell_info[j][i].multicolumn == CELL_PART_OF_MULTICOLUMN)
1611 switch (column_info[i].alignment) {
1612 case LYX_ALIGN_LEFT:
1615 case LYX_ALIGN_RIGHT:
1623 if (!column_info[i].p_width.empty())
1624 os << "w(" << column_info[i].p_width << ")";
1625 if (column_info[i].right_line)
1628 if ((j + 1) < rows_) {
1635 if (row_info[0].top_line) {
1639 // if (CellHasContRow(0) >= 0) {
1645 // if (CellHasContRow(cell) >= 0) {
1649 if (right_column_of_cell(cell) == columns_ -1){
1652 int row = row_of_cell(cell);
1653 if (row_info[row++].bottom_line) {
1657 if ((row < rows_) && row_info[row].top_line) {
1663 // if ((cell < GetNumberOfCells() - 1) &&
1664 // (CellHasContRow(cell+1) >= 0)) {
1675 char const *LyXTabular::GetDocBookAlign(int cell, bool isColumn) const
1681 i = column_of_cell(cell);
1682 if (!isColumn && IsMultiColumn(cell)) {
1683 if (!cellinfo_of_cell(cell)->align_special.empty()) {
1684 return cellinfo_of_cell(cell)->align_special.c_str();
1686 switch (GetAlignment(cell)) {
1687 case LYX_ALIGN_LEFT:
1689 case LYX_ALIGN_RIGHT:
1696 if (!column_info[i].align_special.empty()) {
1697 return column_info[i].align_special.c_str();
1699 #ifdef IGNORE_THIS_FOR_NOW
1700 else if (!column_info[i].p_width.empty()) {
1702 file += column_info[i].p_width;
1707 switch (column_info[i].alignment) {
1708 case LYX_ALIGN_LEFT:
1710 case LYX_ALIGN_RIGHT:
1720 // cell <0 will tex the preamble
1721 // returns the number of printed newlines
1722 int LyXTabular::DocBookEndOfCell(ostream & os, int cell, int & depth) const
1726 //int tmp; // tmp2; //Â unused
1727 int nvcell; // fcell; //Â unused
1728 if (IsLastCell(cell)) {
1729 os << newlineAndDepth(--depth)
1731 << newlineAndDepth(--depth)
1733 << newlineAndDepth(--depth)
1735 << newlineAndDepth(--depth);
1736 if (is_long_tabular)
1740 << newlineAndDepth(--depth);
1746 if (is_long_tabular)
1752 << "' COLSEP='1' ROWSEP='1'>"
1753 << newlineAndDepth(++depth);
1755 for (i = 0; i < columns_; ++i) {
1756 os << "<COLSPEC ALIGN='"
1757 << GetDocBookAlign(i, true)
1763 if (i == (columns_-1)) {
1766 if (column_info[i].right_line ||
1767 column_info[i+1].left_line)
1773 << newlineAndDepth(depth);
1775 #ifdef NOT_HANDLED_YET_AS_I_DONT_KNOW_HOW
1776 if (column_info[i].left_line)
1781 << newlineAndDepth(++depth)
1783 << newlineAndDepth(++depth)
1785 << GetDocBookAlign(0)
1787 if (IsMultiColumn(0)) {
1788 os << " NAMEST='col1' NAMEEND='col"
1789 << cells_in_multicolumn(0)
1793 << newlineAndDepth(++depth);
1796 if (IsLastCellInRow(cell)) {
1797 os << newlineAndDepth(--depth)
1799 << newlineAndDepth(--depth)
1801 << newlineAndDepth(depth)
1803 << newlineAndDepth(++depth)
1805 << GetDocBookAlign(cell + 1)
1806 << "' VALIGN='middle'";
1807 if (IsMultiColumn(cell + 1)) {
1808 os << " NAMEST='col"
1809 << column_of_cell(cell+1) + 1
1811 << column_of_cell(cell + 1) +
1812 cells_in_multicolumn(cell + 1)
1816 << newlineAndDepth(++depth);
1819 os << newlineAndDepth(--depth)
1821 << newlineAndDepth(depth)
1823 << GetDocBookAlign(cell + 1)
1824 << "' VALIGN='middle'";
1825 if (IsMultiColumn(cell + 1)) {
1826 os << " NAMEST='col"
1827 << column_of_cell(cell+1) + 1
1829 << column_of_cell(cell+1) +
1830 cells_in_multicolumn(cell+1)
1834 << newlineAndDepth(++depth);
1843 bool LyXTabular::IsMultiColumn(int cell) const
1845 return (cellinfo_of_cell(cell)->multicolumn != LyXTabular::CELL_NORMAL);
1849 LyXTabular::cellstruct* LyXTabular::cellinfo_of_cell(int cell) const
1851 int row = row_of_cell(cell);
1852 int column = column_of_cell(cell);
1853 return &cell_info[row][column];
1857 void LyXTabular::SetMultiColumn(int cell, int number)
1859 int new_width = cellinfo_of_cell(cell)->width_of_cell;
1861 cellinfo_of_cell(cell)->multicolumn = LyXTabular::CELL_BEGIN_OF_MULTICOLUMN;
1862 cellinfo_of_cell(cell)->alignment = column_info[column_of_cell(cell)].alignment;
1863 cellinfo_of_cell(cell)->top_line = row_info[row_of_cell(cell)].top_line;
1864 cellinfo_of_cell(cell)->bottom_line = row_info[row_of_cell(cell)].bottom_line;
1865 for (number--; number > 0; --number) {
1866 cellinfo_of_cell(cell+number)->multicolumn =
1867 LyXTabular::CELL_PART_OF_MULTICOLUMN;
1868 new_width += cellinfo_of_cell(cell+number)->width_of_cell;
1870 set_row_column_number_info();
1871 SetWidthOfCell(cell, new_width);
1875 int LyXTabular::cells_in_multicolumn(int cell) const
1877 int row = row_of_cell(cell);
1878 int column = column_of_cell(cell);
1881 while (column < columns_ && cell_info[row][column].multicolumn
1882 == LyXTabular::CELL_PART_OF_MULTICOLUMN){
1890 int LyXTabular::UnsetMultiColumn(int cell)
1892 int row = row_of_cell(cell);
1893 int column = column_of_cell(cell);
1897 if (cell_info[row][column].multicolumn
1898 == LyXTabular::CELL_BEGIN_OF_MULTICOLUMN){
1899 cell_info[row][column].multicolumn = LyXTabular::CELL_NORMAL;
1901 while (column < columns_ &&
1902 cell_info[row][column].multicolumn
1903 == LyXTabular::CELL_PART_OF_MULTICOLUMN){
1904 cell_info[row][column].multicolumn =
1905 LyXTabular::CELL_NORMAL;
1910 set_row_column_number_info();
1915 void LyXTabular::delete_column(int column)
1918 columnstruct * column_info2 = new columnstruct[columns_-1];
1920 for (i = 0; i < column; ++i) {
1921 column_info2[i] = column_info[i];
1923 for (i = column; i < columns_ - 1; ++i) {
1924 column_info2[i] = column_info[i + 1];
1927 delete[] column_info;
1928 column_info = column_info2;
1930 for (i = 0; i < rows_; ++i) {
1931 cellstruct * tmp = cell_info[i];
1932 cell_info[i] = new cellstruct[columns_ - 1](buffer);
1933 for (j = 0; j < column; ++j) {
1934 cell_info[i][j] = tmp[j];
1936 for (j = column; j < columns_ - 1; ++j) {
1937 cell_info[i][j] = tmp[j + 1];
1947 void LyXTabular::SetLongTabular(int what)
1949 is_long_tabular = what;
1953 bool LyXTabular::IsLongTabular() const
1955 return is_long_tabular;
1958 void LyXTabular::SetRotateTabular(int what)
1963 bool LyXTabular::GetRotateTabular() const
1968 void LyXTabular::SetRotateCell(int cell, int what)
1970 cellinfo_of_cell(cell)->rotate = what;
1973 bool LyXTabular::GetRotateCell(int cell) const
1975 return cellinfo_of_cell(cell)->rotate;
1978 bool LyXTabular::NeedRotating() const
1982 for (int i = 0; i < rows_; ++i) {
1983 for (int j = 0; j < columns_; ++j) {
1984 if (cell_info[i][j].rotate)
1992 bool LyXTabular::IsLastCell(int cell) const
1994 if (cell < GetNumberOfCells())
1999 int LyXTabular::GetCellAbove(int cell) const
2001 if (row_of_cell(cell) > 0)
2002 return cell_info[row_of_cell(cell)-1][column_of_cell(cell)].cellno;
2006 int LyXTabular::GetCellNumber(int column, int row) const
2008 if (column >= columns_)
2009 column = columns_ - 1;
2010 else if (column < 0)
2017 return cell_info[row][column].cellno;
2020 void LyXTabular::SetLinebreaks(int cell, bool what)
2022 cellinfo_of_cell(cell)->linebreaks = what;
2025 bool LyXTabular::GetLinebreaks(int cell) const
2027 if (column_info[column_of_cell(cell)].p_width.empty() &&
2028 !(IsMultiColumn(cell) && !cellinfo_of_cell(cell)->p_width.empty()))
2030 return cellinfo_of_cell(cell)->linebreaks;
2033 void LyXTabular::SetLTHead(int cell, bool first)
2035 int row = row_of_cell(cell);
2038 if (row == endfirsthead)
2050 bool LyXTabular::GetRowOfLTHead(int cell) const
2052 if ((endhead+1) > rows_)
2054 return (row_of_cell(cell) == endhead);
2057 bool LyXTabular::GetRowOfLTFirstHead(int cell) const
2059 if ((endfirsthead+1) > rows_)
2061 return (row_of_cell(cell) == endfirsthead);
2064 void LyXTabular::SetLTFoot(int cell, bool last)
2066 int row = row_of_cell(cell);
2069 if (row == endlastfoot)
2081 bool LyXTabular::GetRowOfLTFoot(int cell) const
2083 if ((endfoot+1) > rows_)
2085 return (row_of_cell(cell) == endfoot);
2088 bool LyXTabular::GetRowOfLTLastFoot(int cell) const
2090 if ((endlastfoot+1) > rows_)
2092 return (row_of_cell(cell) == endlastfoot);
2095 void LyXTabular::SetLTNewPage(int cell, bool what)
2097 row_info[row_of_cell(cell)].newpage = what;
2100 bool LyXTabular::GetLTNewPage(int cell) const
2102 return row_info[row_of_cell(cell)].newpage;
2105 void LyXTabular::SetAscentOfRow(int row, int height)
2109 row_info[row].ascent_of_row = height;
2112 void LyXTabular::SetDescentOfRow(int row, int height)
2116 row_info[row].descent_of_row = height;
2119 int LyXTabular::GetAscentOfRow(int row) const
2123 return row_info[row].ascent_of_row;
2126 int LyXTabular::GetDescentOfRow(int row) const
2130 return row_info[row].descent_of_row;
2133 int LyXTabular::GetHeightOfTabular() const
2139 for(row=0,height=0;(row<rows_); ++row)
2140 height += GetAscentOfRow(row) + GetDescentOfRow(row) +
2141 GetAdditionalHeight(GetCellNumber(0,row));
2145 bool LyXTabular::IsPartOfMultiColumn(int row, int column) const
2147 if ((row >= rows_) || (column >= columns_))
2149 return (cell_info[row][column].multicolumn==CELL_PART_OF_MULTICOLUMN);
2152 int LyXTabular::Latex(ostream &) const
2157 InsetText * LyXTabular::GetCellInset(int cell) const
2159 return cell_info[row_of_cell(cell)][column_of_cell(cell)].inset;