1 /* This file is part of
2 * ======================================================
4 * LyX, The Document Processor
6 * Copyright 2000 The LyX Team.
8 * ======================================================
17 #pragma implementation
24 #include "lyx_gui_misc.h"
26 #include "BufferView.h"
28 #include "LaTeXFeatures.h"
29 #include "support/lstrings.h"
30 #include "support/lyxmanip.h"
31 #include "insets/insettabular.h"
32 #include "insets/insettext.h"
41 static int const WIDTH_OF_LINE = 5;
43 extern BufferView * current_view;
45 /// Define a few methods for the inner structs
47 LyXTabular::cellstruct::cellstruct()
49 cellno = 0; //should be initilaized correctly later.
51 multicolumn = LyXTabular::CELL_NORMAL;
52 alignment = LYX_ALIGN_CENTER;
60 LyXTabular::rowstruct::rowstruct()
70 LyXTabular::columnstruct::columnstruct()
74 alignment = LYX_ALIGN_CENTER;
80 LyXTabular::LyXTabular(InsetTabular * inset, int rows_arg, int columns_arg)
83 Init(rows_arg, columns_arg);
87 LyXTabular::LyXTabular(InsetTabular * inset, LyXTabular const & lt)
90 Init(lt.rows_, lt.columns_);
96 LyXTabular::LyXTabular(Buffer const * buf, InsetTabular * inset, LyXLex & lex)
103 LyXTabular::~LyXTabular()
106 delete[] columnofcell;
110 LyXTabular & LyXTabular::operator=(LyXTabular const & lt)
112 // If this and lt is not of the same size we have a serious bug
113 // So then it is ok to throw an exception, or for now
115 Assert(rows_ == lt.rows_ && columns_ == lt.columns_);
117 cell_info = lt.cell_info;
118 row_info = lt.row_info;
119 column_info = lt.column_info;
121 // long tabular stuff
122 SetLongTabular(lt.is_long_tabular);
123 endhead = lt.endhead;
124 endfoot = lt.endfoot;
125 endfirsthead = lt.endfirsthead;
126 endlastfoot = lt.endlastfoot;
136 LyXTabular * LyXTabular::Clone(InsetTabular * inset)
138 LyXTabular * result = new LyXTabular(inset, *this);
140 // don't know if this is good but I need to Clone also
141 // the text-insets here, this is for the Undo-facility!
144 for(i=0; i < rows_; ++i) {
145 for(j=0; j < columns_; ++j) {
146 result->cell_info[i][j].inset = cell_info[i][j].inset;
147 result->cell_info[i][j].inset.setOwner(inset);
154 /* activates all lines and sets all widths to 0 */
155 void LyXTabular::Init(int rows_arg, int columns_arg)
161 columns_ = columns_arg;
162 row_info = vector<rowstruct>(rows_, rowstruct());
163 column_info = vector<columnstruct>(columns_, columnstruct());
164 cell_info = vector<vector<cellstruct> >
165 (rows_, vector<cellstruct>(columns_, cellstruct()));
167 // Jürgen, use iterators.
168 for (i = 0; i < rows_; ++i) {
169 for (j = 0; j < columns_; ++j) {
170 cell_info[i][j].inset.setOwner(owner_);
171 cell_info[i][j].inset.SetDrawFrame(0, InsetText::LOCKED);
172 cell_info[i][j].cellno = cellno++;
175 row_info[i-1].bottom_line = true;
176 row_info[0].bottom_line = true;
178 for (i = 0; i < columns_; ++i) {
179 calculate_width_of_column(i);
181 column_info[columns_-1].right_line = true;
183 calculate_width_of_tabular();
187 set_row_column_number_info();
188 is_long_tabular = false;
197 void LyXTabular::AppendRow(int cell )
201 int row = row_of_cell(cell);
203 row_vector::iterator rit = row_info.begin() + row;
204 row_info.insert(rit, rowstruct());
207 cell_vvector::iterator cit = cell_info.begin() + row;
208 cell_info.insert(cit, vector<cellstruct>(columns_, cellstruct()));
210 cell_vvector c_info = cell_vvector(rows_, cell_vector(columns_,
213 for(int i = 0; i <= row; ++i) {
214 for(int j = 0; j < columns_; ++j) {
215 c_info[i][j] = cell_info[i][j];
218 for(int i = row+1; i < rows_; ++i) {
219 for(int j = 0; j < columns_; ++j) {
220 c_info[i][j] = cell_info[i-1][j];
225 for (int j = 0; j < columns_; ++j) {
226 cell_info[row][j].inset.clear();
233 void LyXTabular::DeleteRow(int row)
237 row_info.erase(row_info.begin() + row); //&row_info[row]);
238 cell_info.erase(cell_info.begin() + row); //&cell_info[row]);
244 void LyXTabular::AppendColumn(int cell)
248 cell_vvector c_info = cell_vvector(rows_, cell_vector(columns_,
250 int column = column_of_cell(cell);
252 column_vector::iterator cit = column_info.begin() + column;
253 column_info.insert(cit, columnstruct());
255 for (i = 0; i < rows_; ++i) {
256 for (j = 0; j <= column; ++j) {
257 c_info[i][j] = cell_info[i][j];
259 for (j = column+1; j < columns_; ++j) {
260 c_info[i][j] = cell_info[i][j-1];
262 // care about multicolumns
263 if (cell_info[i][column+1].multicolumn == CELL_BEGIN_OF_MULTICOLUMN) {
264 cell_info[i][column+1].multicolumn = CELL_PART_OF_MULTICOLUMN;
266 if (((column+1) == columns_) ||
267 (cell_info[i][column+2].multicolumn != CELL_PART_OF_MULTICOLUMN)) {
268 cell_info[i][column+1].multicolumn = LyXTabular::CELL_NORMAL;
273 for (i = 0; i < rows_; ++i) {
274 cell_info[i][column].inset.clear();
280 void LyXTabular::DeleteColumn(int column)
284 column_info.erase(column_info.begin() + column);
285 for (int i = 0; i < rows_; ++i) {
286 cell_info[i].erase(cell_info[i].begin() + column);
293 void LyXTabular::Reinit()
299 // Jürgen, use iterators.
300 for (; i < rows_; ++i) {
301 for (j = 0; j < columns_; ++j) {
302 cell_info[i][j].width_of_cell = 0;
303 cell_info[i][j].inset.setOwner(owner_);
307 for (i = 0; i < columns_; ++i) {
308 calculate_width_of_column(i);
310 calculate_width_of_tabular();
312 set_row_column_number_info();
316 void LyXTabular::set_row_column_number_info()
322 for (; row < rows_; ++row) {
323 for (column = 0; column<columns_; ++column) {
324 if (cell_info[row][column].multicolumn
325 != LyXTabular::CELL_PART_OF_MULTICOLUMN)
327 cell_info[row][column].cellno = numberofcells;
330 ++numberofcells; // because this is one more than as we start from 0
335 rowofcell = new int[numberofcells];
336 delete [] columnofcell;
337 columnofcell = new int[numberofcells];
339 while (c < numberofcells && row < rows_ && column < columns_) {
341 columnofcell[c] = column;
345 } while (column < columns_ &&
346 cell_info[row][column].multicolumn
347 == LyXTabular::CELL_PART_OF_MULTICOLUMN);
348 if (column == columns_) {
353 for (row = 0; row < rows_; ++row) {
354 for (column = 0; column<columns_; ++column) {
355 if (IsPartOfMultiColumn(row,column))
357 cell_info[row][column].inset.SetAutoBreakRows(
358 !GetPWidth(GetCellNumber(row, column)).empty());
364 int LyXTabular::GetNumberOfCells() const
366 return numberofcells;
370 int LyXTabular::NumberOfCellsInRow(int cell) const
372 int row = row_of_cell(cell);
374 for (int i = 0; i < columns_; ++i) {
375 if (cell_info[row][i].multicolumn != LyXTabular::CELL_PART_OF_MULTICOLUMN)
382 /* returns 1 if there is a topline, returns 0 if not */
383 bool LyXTabular::TopLine(int cell, bool onlycolumn) const
385 int row = row_of_cell(cell);
387 if (!onlycolumn && IsMultiColumn(cell))
388 return cellinfo_of_cell(cell)->top_line;
389 return row_info[row].top_line;
393 bool LyXTabular::BottomLine(int cell, bool onlycolumn) const
395 //no bottom line underneath non-existent cells if you please
396 if(cell >= numberofcells)
399 if (!onlycolumn && IsMultiColumn(cell))
400 return cellinfo_of_cell(cell)->bottom_line;
401 return row_info[row_of_cell(cell)].bottom_line;
405 bool LyXTabular::LeftLine(int cell, bool onlycolumn) const
407 if (!onlycolumn && IsMultiColumn(cell))
408 return cellinfo_of_cell(cell)->left_line;
409 return column_info[column_of_cell(cell)].left_line;
413 bool LyXTabular::RightLine(int cell, bool onlycolumn) const
415 if (!onlycolumn && IsMultiColumn(cell))
416 return cellinfo_of_cell(cell)->right_line;
417 return column_info[right_column_of_cell(cell)].right_line;
421 bool LyXTabular::TopAlreadyDrawed(int cell) const
423 if (GetAdditionalHeight(cell))
425 int row = row_of_cell(cell);
427 int column = column_of_cell(cell);
430 && cell_info[row][column].multicolumn
431 == LyXTabular::CELL_PART_OF_MULTICOLUMN)
433 if (cell_info[row][column].multicolumn == LyXTabular::CELL_NORMAL)
434 return row_info[row].bottom_line;
436 return cell_info[row][column].bottom_line;
442 bool LyXTabular::LeftAlreadyDrawed(int cell) const
444 int column = column_of_cell(cell);
446 int row = row_of_cell(cell);
448 (cell_info[row][column].multicolumn ==
449 LyXTabular::CELL_PART_OF_MULTICOLUMN));
450 if (GetAdditionalWidth(cell_info[row][column].cellno))
452 return column_info[column].right_line;
458 bool LyXTabular::IsLastRow(int cell) const
460 return (row_of_cell(cell) == rows_ - 1);
464 int LyXTabular::GetAdditionalHeight(int cell) const
466 int row = row_of_cell(cell);
469 int top = 1; // bool top = true; ??
470 int bottom = 1; // bool bottom = true; ??
473 for (column = 0; column < columns_ - 1 && bottom; ++column) {
474 switch (cell_info[row - 1][column].multicolumn) {
475 case LyXTabular::CELL_BEGIN_OF_MULTICOLUMN:
476 bottom = cell_info[row - 1][column].bottom_line;
478 case LyXTabular::CELL_NORMAL:
479 bottom = row_info[row - 1].bottom_line;
482 for (column = 0; column < columns_ - 1 && top; ++column) {
483 switch (cell_info[row][column].multicolumn){
484 case LyXTabular::CELL_BEGIN_OF_MULTICOLUMN:
485 top = cell_info[row][column].top_line;
487 case LyXTabular::CELL_NORMAL:
488 top = row_info[row].top_line;
492 return WIDTH_OF_LINE;
497 int LyXTabular::GetAdditionalWidth(int cell) const
499 // internally already set in SetWidthOfCell
500 // used to get it back in text.C
501 int col = right_column_of_cell(cell);
502 if (col < columns_ - 1 && column_info[col].right_line &&
503 column_info[col+1].left_line)
504 return WIDTH_OF_LINE;
510 // returns the maximum over all rows
511 int LyXTabular::GetWidthOfColumn(int cell) const
513 int column1 = column_of_cell(cell);
514 int column2 = right_column_of_cell(cell);
517 for (; i <= column2; ++i) {
518 result += column_info[i].width_of_column;
524 int LyXTabular::GetWidthOfTabular() const
526 return width_of_tabular;
530 /* returns 1 if a complete update is necessary, otherwise 0 */
531 bool LyXTabular::SetWidthOfMulticolCell(int cell, int new_width)
533 if (!IsMultiColumn(cell))
536 int row = row_of_cell(cell);
537 int column1 = column_of_cell(cell);
538 int column2 = right_column_of_cell(cell);
540 // first set columns to 0 so we can calculate the right width
542 for (; i <= column2; ++i) {
543 cell_info[row][i].width_of_cell = 0;
545 // set the width to MAX_WIDTH until width > 0
546 int width = (new_width + 2 * WIDTH_OF_LINE);
547 for (i = column1; (i < column2) && (width > 0); ++i) {
548 cell_info[row][i].width_of_cell = column_info[i].width_of_column;
549 width -= column_info[i].width_of_column;
552 cell_info[row][i].width_of_cell = width;
558 void LyXTabular::recalculateMulticolCells(int cell, int new_width)
560 int row = row_of_cell(cell);
561 int column1 = column_of_cell(cell);
562 int column2 = right_column_of_cell(cell);
564 // first set columns to 0 so we can calculate the right width
566 for (; i <= column2; ++i)
567 cell_info[row][i].width_of_cell = 0;
568 for(i = cell + 1; (i < numberofcells) && (!IsMultiColumn(i)); ++i)
570 if (i < numberofcells)
571 recalculateMulticolCells(i, GetWidthOfCell(i) - (2 * WIDTH_OF_LINE));
572 SetWidthOfMulticolCell(cell, new_width);
576 /* returns 1 if a complete update is necessary, otherwise 0 */
577 bool LyXTabular::SetWidthOfCell(int cell, int new_width)
579 int row = row_of_cell(cell);
580 int column1 = column_of_cell(cell);
584 if (IsMultiColumn(cell)) {
585 tmp = SetWidthOfMulticolCell(cell, new_width);
587 width = (new_width + 2*WIDTH_OF_LINE);
588 cell_info[row][column1].width_of_cell = width;
589 if (column_info[column1].right_line && (column1 < columns_-1) &&
590 column_info[column1+1].left_line) // additional width
591 cell_info[row][column1].width_of_cell += WIDTH_OF_LINE;
592 tmp = calculate_width_of_column_NMC(column1);
596 for(i = 0; i<columns_;++i)
597 calculate_width_of_column_NMC(i);
598 for(i = 0; (i<numberofcells) && !IsMultiColumn(i); ++i)
601 recalculateMulticolCells(i, GetWidthOfCell(i)-(2*WIDTH_OF_LINE));
602 for(i = 0; i<columns_;++i)
603 calculate_width_of_column(i);
604 calculate_width_of_tabular();
611 bool LyXTabular::SetAlignment(int cell, char align, bool onlycolumn)
613 if (!IsMultiColumn(cell) || onlycolumn)
614 column_info[column_of_cell(cell)].alignment = align;
616 cellinfo_of_cell(cell)->alignment = align;
621 bool LyXTabular::SetVAlignment(int cell, char align, bool onlycolumn)
623 if (!IsMultiColumn(cell) || onlycolumn)
624 column_info[column_of_cell(cell)].valignment = align;
626 cellinfo_of_cell(cell)->valignment = align;
631 bool LyXTabular::SetColumnPWidth(int cell, string const & width)
633 bool flag = !width.empty();
635 int j = column_of_cell(cell);
637 column_info[j].p_width = width;
638 if (flag) // do this only if there is a width
639 SetAlignment(cell, LYX_ALIGN_LEFT);
640 for(int i=0; i < rows_; ++i) {
641 c = GetCellNumber(i, j);
642 flag = !GetPWidth(c).empty(); // because of multicolumns!
643 GetCellInset(c)->SetAutoBreakRows(flag);
649 bool LyXTabular::SetMColumnPWidth(int cell, string const & width)
651 bool flag = !width.empty();
653 cellinfo_of_cell(cell)->p_width = width;
654 if (IsMultiColumn(cell)) {
655 GetCellInset(cell)->SetAutoBreakRows(flag);
662 bool LyXTabular::SetAlignSpecial(int cell, string const & special, int what)
664 if (what == SET_SPECIAL_MULTI)
665 cellinfo_of_cell(cell)->align_special = special;
667 column_info[column_of_cell(cell)].align_special = special;
672 bool LyXTabular::SetAllLines(int cell, bool line)
674 SetTopLine(cell, line);
675 SetBottomLine(cell, line);
676 SetRightLine(cell, line);
677 SetLeftLine(cell, line);
682 bool LyXTabular::SetTopLine(int cell, bool line, bool onlycolumn)
684 int row = row_of_cell(cell);
686 if (onlycolumn || !IsMultiColumn(cell))
687 row_info[row].top_line = line;
689 cellinfo_of_cell(cell)->top_line = line;
694 bool LyXTabular::SetBottomLine(int cell, bool line, bool onlycolumn)
696 if (onlycolumn || !IsMultiColumn(cell))
697 row_info[row_of_cell(cell)].bottom_line = line;
699 cellinfo_of_cell(cell)->bottom_line = line;
704 bool LyXTabular::SetLeftLine(int cell, bool line, bool onlycolumn)
706 if (onlycolumn || !IsMultiColumn(cell))
707 column_info[column_of_cell(cell)].left_line = line;
709 cellinfo_of_cell(cell)->left_line = line;
714 bool LyXTabular::SetRightLine(int cell, bool line, bool onlycolumn)
716 if (onlycolumn || !IsMultiColumn(cell))
717 column_info[right_column_of_cell(cell)].right_line = line;
719 cellinfo_of_cell(cell)->right_line = line;
724 char LyXTabular::GetAlignment(int cell, bool onlycolumn) const
726 if (!onlycolumn && IsMultiColumn(cell))
727 return cellinfo_of_cell(cell)->alignment;
729 return column_info[column_of_cell(cell)].alignment;
733 char LyXTabular::GetVAlignment(int cell, bool onlycolumn) const
735 if (!onlycolumn && IsMultiColumn(cell))
736 return cellinfo_of_cell(cell)->valignment;
738 return column_info[column_of_cell(cell)].valignment;
742 string LyXTabular::GetPWidth(int cell) const
744 if (IsMultiColumn(cell))
745 return cellinfo_of_cell(cell)->p_width;
746 return column_info[column_of_cell(cell)].p_width;
750 string LyXTabular::GetColumnPWidth(int cell) const
752 return column_info[column_of_cell(cell)].p_width;
756 string LyXTabular::GetMColumnPWidth(int cell) const
758 if (IsMultiColumn(cell))
759 return cellinfo_of_cell(cell)->p_width;
764 string LyXTabular::GetAlignSpecial(int cell, int what) const
766 if (what == SET_SPECIAL_MULTI)
767 return cellinfo_of_cell(cell)->align_special;
768 return column_info[column_of_cell(cell)].align_special;
772 int LyXTabular::GetWidthOfCell(int cell) const
774 int row = row_of_cell(cell);
775 int column1 = column_of_cell(cell);
776 int column2 = right_column_of_cell(cell);
779 for (; i <= column2; ++i) {
780 result += cell_info[row][i].width_of_cell;
783 // result += GetAdditionalWidth(cell);
788 int LyXTabular::GetBeginningOfTextInCell(int cell) const
792 switch (GetAlignment(cell)){
793 case LYX_ALIGN_CENTER:
794 x += (GetWidthOfColumn(cell) - GetWidthOfCell(cell)) / 2;
796 case LYX_ALIGN_RIGHT:
797 x += GetWidthOfColumn(cell) - GetWidthOfCell(cell);
798 // + GetAdditionalWidth(cell);
800 default: /* LYX_ALIGN_LEFT: nothing :-) */
810 bool LyXTabular::IsFirstCellInRow(int cell) const
812 return (column_of_cell(cell) == 0);
816 int LyXTabular::GetFirstCellInRow(int row) const
820 return cell_info[row][0].cellno;
823 bool LyXTabular::IsLastCellInRow(int cell) const
825 return (right_column_of_cell(cell) == (columns_ - 1));
829 int LyXTabular::GetLastCellInRow(int row) const
833 return cell_info[row][columns_-1].cellno;
837 bool LyXTabular::calculate_width_of_column(int column)
839 int old_column_width = column_info[column].width_of_column;
842 for (int i = 0; i < rows_; ++i) {
843 maximum = max(cell_info[i][column].width_of_cell, maximum);
845 column_info[column].width_of_column = maximum;
846 return (column_info[column].width_of_column != old_column_width);
850 bool LyXTabular::calculate_width_of_column_NMC(int column)
852 int old_column_width = column_info[column].width_of_column;
854 for (int i = 0; i < rows_; ++i) {
855 if (!IsMultiColumn(GetCellNumber(i, column)) &&
856 (cell_info[i][column].width_of_cell > max)) {
857 max = cell_info[i][column].width_of_cell;
860 column_info[column].width_of_column = max;
861 return (column_info[column].width_of_column != old_column_width);
865 void LyXTabular::calculate_width_of_tabular()
867 width_of_tabular = 0;
868 for (int i = 0; i < columns_; ++i) {
869 width_of_tabular += column_info[i].width_of_column;
874 int LyXTabular::row_of_cell(int cell) const
876 if (cell >= numberofcells)
880 return rowofcell[cell];
884 int LyXTabular::column_of_cell(int cell) const
886 if (cell >= numberofcells)
890 return columnofcell[cell];
894 int LyXTabular::right_column_of_cell(int cell) const
896 int row = row_of_cell(cell);
897 int column = column_of_cell(cell);
898 while (column < (columns_ - 1) &&
899 cell_info[row][column+1].multicolumn == LyXTabular::CELL_PART_OF_MULTICOLUMN)
905 void LyXTabular::Write(Buffer const * buf, ostream & os) const
910 os << "<LyXTabular version=1 rows=" << rows_ << " columns=" << columns_ <<
912 // global longtable options
913 os << "<Features rotate=" << rotate <<
914 " islongtable=" << is_long_tabular <<
915 " endhead=" << endhead << " endfirsthead=" << endfirsthead <<
916 " endfoot=" << endfoot << " endlastfoot=" << endlastfoot <<
918 for (i = 0; i < rows_; ++i) {
919 os << "<Row topline=" << row_info[i].top_line <<
920 " bottomline=" << row_info[i].bottom_line <<
921 " newpage=" << row_info[i].newpage <<
923 for (j = 0; j < columns_; ++j) {
925 os << "<Column alignment=" << column_info[j].alignment <<
926 " valignment=" << column_info[j].valignment <<
927 " leftline=" << column_info[j].left_line <<
928 " rightline=" << column_info[j].right_line <<
929 " width=\"" << VSpace(column_info[j].p_width).asLyXCommand() <<
930 "\" special=\"" << column_info[j].align_special <<
933 os << "<Column>" << endl;
935 os << "<Cell multicolumn=" << cell_info[i][j].multicolumn <<
936 " alignment=" << cell_info[i][j].alignment <<
937 " valignment=" << cell_info[i][j].valignment <<
938 " topline=" << cell_info[i][j].top_line <<
939 " bottomline=" << cell_info[i][j].bottom_line <<
940 " leftline=" << cell_info[i][j].left_line <<
941 " rightline=" << cell_info[i][j].right_line <<
942 " rotate=" << cell_info[i][j].rotate <<
943 " usebox=" << cell_info[i][j].usebox <<
944 " width=\"" << cell_info[i][j].p_width <<
945 "\" special=\"" << cell_info[i][j].align_special <<
947 os << "\\begin_inset ";
948 cell_info[i][j].inset.Write(buf, os);
949 os << "\n\\end_inset " << endl;
950 os << "</Cell>" << endl;
951 os << "</Column>" << endl;
953 os << "</Row>" << endl;
955 os << "</LyXTabular>" << endl;
960 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))
982 bool getTokenValue(string const str, const char * token, int & num)
985 int pos = str.find(token);
986 char ch = str[pos+strlen(token)];
988 if ((pos < 0) || (ch != '='))
991 pos += strlen(token)+1;
993 if ((ch != '"') && (ch != '\'')) { // only read till next space
999 while((pos < int(str.length()-1)) && isdigit(str[pos]))
1002 num = strToInt(ret);
1008 bool getTokenValue(string const str, const char * token, bool & flag)
1011 int pos = str.find(token);
1012 char ch = str[pos+strlen(token)];
1014 if ((pos < 0) || (ch != '='))
1017 pos += strlen(token)+1;
1019 if ((ch != '"') && (ch != '\'')) { // only read till next space
1025 while((pos < int(str.length()-1)) && isdigit(str[pos]))
1028 flag = strToInt(ret);
1033 void l_getline(istream & is, string & str)
1041 void LyXTabular::Read(Buffer const * buf, LyXLex & lex)
1044 istream & is = lex.getStream();
1046 l_getline(is, line);
1047 if (!prefixIs(line, "<LyXTabular ")) {
1048 OldFormatRead(lex, line);
1055 if (!getTokenValue(line, "version", version))
1057 if (!getTokenValue(line, "rows", rows_arg))
1059 if (!getTokenValue(line, "columns", columns_arg))
1061 Init(rows_arg, columns_arg);
1062 l_getline(is, line);
1063 if (!prefixIs(line, "<Features ")) {
1064 lyxerr << "Wrong tabular format (expected <Feture ...> got" <<
1065 line << ")" << endl;
1068 (void)getTokenValue(line, "islongtable", is_long_tabular);
1069 (void)getTokenValue(line, "endhead", endhead);
1070 (void)getTokenValue(line, "endfirsthead", endfirsthead);
1071 (void)getTokenValue(line, "endfoot", endfoot);
1072 (void)getTokenValue(line, "endlastfoot", endlastfoot);
1074 for(i = 0; i < rows_; ++i) {
1075 l_getline(is, line);
1076 if (!prefixIs(line, "<Row ")) {
1077 lyxerr << "Wrong tabular format (expected <Row ...> got" <<
1078 line << ")" << endl;
1081 (void)getTokenValue(line, "topline", row_info[i].top_line);
1082 (void)getTokenValue(line, "bottomline", row_info[i].bottom_line);
1083 (void)getTokenValue(line, "newpage", row_info[i].newpage);
1084 for (j = 0; j < columns_; ++j) {
1086 if (!prefixIs(line,"<Column")) {
1087 lyxerr << "Wrong tabular format (expected <Column ...> got" <<
1088 line << ")" << endl;
1092 (void)getTokenValue(line, "alignment", column_info[j].alignment);
1093 (void)getTokenValue(line, "valignment", column_info[j].valignment);
1094 (void)getTokenValue(line, "leftline", column_info[j].left_line);
1095 (void)getTokenValue(line, "rightline", column_info[j].right_line);
1096 (void)getTokenValue(line, "width", column_info[j].p_width);
1097 (void)getTokenValue(line, "special", column_info[j].align_special);
1099 l_getline(is, line);
1100 if (!prefixIs(line, "<Cell")) {
1101 lyxerr << "Wrong tabular format (expected <Cell ...> got" <<
1102 line << ")" << endl;
1105 (void)getTokenValue(line, "multicolumn", cell_info[i][j].multicolumn);
1106 (void)getTokenValue(line, "alignment", cell_info[i][j].alignment);
1107 (void)getTokenValue(line, "valignment", cell_info[i][j].valignment);
1108 (void)getTokenValue(line, "topline", cell_info[i][j].top_line);
1109 (void)getTokenValue(line, "bottomline", cell_info[i][j].bottom_line);
1110 (void)getTokenValue(line, "leftline", cell_info[i][j].left_line);
1111 (void)getTokenValue(line, "rightline", cell_info[i][j].right_line);
1112 (void)getTokenValue(line, "rotate", cell_info[i][j].rotate);
1113 (void)getTokenValue(line, "usebox", cell_info[i][j].usebox);
1114 (void)getTokenValue(line, "width", cell_info[i][j].p_width);
1115 (void)getTokenValue(line, "special", cell_info[i][j].align_special);
1116 l_getline(is, line);
1117 if (prefixIs(line, "\\begin_inset")) {
1118 cell_info[i][j].inset.Read(buf, lex);
1119 l_getline(is, line);
1121 if (line != "</Cell>") {
1122 lyxerr << "Wrong tabular format (expected </Cell> got" <<
1123 line << ")" << endl;
1126 l_getline(is, line);
1127 if (line != "</Column>") {
1128 lyxerr << "Wrong tabular format (expected </Column> got" <<
1129 line << ")" << endl;
1133 l_getline(is, line);
1134 if (line != "</Row>") {
1135 lyxerr << "Wrong tabular format (expected </Row> got" <<
1136 line << ")" << endl;
1140 while (line != "</LyXTabular>") {
1141 l_getline(is, line);
1143 set_row_column_number_info();
1147 void LyXTabular::OldFormatRead(LyXLex & lex, string const & fl)
1152 int columns_arg = 0;
1153 int is_long_tabular_arg = false;
1154 int rotate_arg = false;
1164 istream & is = lex.getStream();
1167 version = atoi(s.c_str() + 8);
1171 vector<int> cont_row_info;
1174 lyxerr << "Tabular format < 5 is not supported anymore\n"
1175 "Get an older version of LyX (< 1.1.x) for conversion!"
1177 WriteAlert(_("Warning:"),
1178 _("Tabular format < 5 is not supported anymore\n"),
1179 _("Get an older version of LyX (< 1.1.x) for conversion!"));
1181 is >> rows_arg >> columns_arg >> is_long_tabular_arg
1182 >> rotate_arg >> a >> b >> c >> d;
1184 is >> rows_arg >> columns_arg;
1185 Init(rows_arg, columns_arg);
1186 cont_row_info = vector<int>(rows_arg);
1187 SetLongTabular(is_long_tabular_arg);
1188 SetRotateTabular(rotate_arg);
1190 for (i = 0; i < rows_; ++i) {
1192 cont_row_info[i] = false;
1194 for (i = 0; i < columns_; ++i) {
1197 for (i = 0; i < rows_; ++i) {
1198 for (j = 0; j < columns_; ++j) {
1203 is >> rows_arg >> columns_arg >> is_long_tabular_arg
1204 >> rotate_arg >> a >> b >> c >> d;
1205 Init(rows_arg, columns_arg);
1206 cont_row_info = vector<int>(rows_arg);
1207 SetLongTabular(is_long_tabular_arg);
1208 SetRotateTabular(rotate_arg);
1213 for (i = 0; i < rows_; ++i) {
1214 a = b = c = d = e = f = g = h = 0;
1215 is >> a >> b >> c >> d;
1216 row_info[i].top_line = a;
1217 row_info[i].bottom_line = b;
1218 cont_row_info[i] = c;
1219 row_info[i].newpage = d;
1221 for (i = 0; i < columns_; ++i) {
1225 char ch; // skip '"'
1227 getline(is, s1, '"');
1228 is >> ch; // skip '"'
1229 getline(is, s2, '"');
1230 column_info[i].alignment = static_cast<char>(a);
1231 column_info[i].left_line = b;
1232 column_info[i].right_line = c;
1233 column_info[i].p_width = s1;
1234 column_info[i].align_special = s2;
1236 for (i = 0; i < rows_; ++i) {
1237 for (j = 0; j < columns_; ++j) {
1240 is >> a >> b >> c >> d >> e >> f >> g;
1242 is >> ch; // skip '"'
1243 getline(is, s1, '"');
1244 is >> ch; // skip '"'
1245 getline(is, s2, '"');
1246 cell_info[i][j].multicolumn = static_cast<char>(a);
1247 cell_info[i][j].alignment = static_cast<char>(b);
1248 cell_info[i][j].top_line = static_cast<char>(c);
1249 cell_info[i][j].bottom_line = static_cast<char>(d);
1250 cell_info[i][j].rotate = static_cast<bool>(f);
1251 cell_info[i][j].usebox = static_cast<bool>(g);
1252 cell_info[i][j].align_special = s1;
1253 cell_info[i][j].p_width = s2;
1257 set_row_column_number_info();
1259 LyXParagraph * par = new LyXParagraph;
1260 LyXParagraph * return_par = 0;
1262 LyXParagraph::footnote_flag footnoteflag = LyXParagraph::NO_FOOTNOTE;
1263 LyXParagraph::footnote_kind footnotekind = LyXParagraph::FOOTNOTE;
1265 string token, tmptok;
1268 LyXFont font(LyXFont::ALL_SANE);
1270 while (lex.IsOK()) {
1272 token = lex.GetString();
1275 if ((token == "\\layout") || (token == "\\end_float") ||
1276 (token == "\\end_deeper"))
1278 lex.pushToken(token);
1281 if (owner_->BufferOwner()->parseSingleLyXformat2Token(lex, par,
1293 lex.pushToken(token);
1297 lex.printError("New Paragraph allocated! This should not happen!");
1298 lex.pushToken(token);
1304 // now we have the par we should fill the insets with this!
1306 InsetText * inset = GetCellInset(cell);
1309 for(int i = 0; i < par->Last(); ++i) {
1310 if (par->IsNewline(i)) {
1312 if (cell > GetNumberOfCells()) {
1313 lyxerr << "Some error in reading old table format occured!" <<
1314 endl << "Terminating when reading cell[" << cell << "]!" <<
1318 row = row_of_cell(cell);
1319 if (cont_row_info[row]) {
1321 cont_row_info.erase(cont_row_info.begin() + row); //&cont_row_info[row]);
1322 while(!IsFirstCellInRow(--cell));
1324 inset = GetCellInset(cell);
1327 inset = GetCellInset(cell);
1328 row = row_of_cell(cell);
1329 if (!cell_info[row_of_cell(cell)][column_of_cell(cell)].usebox)
1331 // insert a space instead
1333 par->InsertChar(i, ' ');
1336 par->CopyIntoMinibuffer(current_view->buffer()->params, i);
1337 inset->par->InsertFromMinibuffer(inset->par->Last());
1343 char const * LyXTabular::GetDocBookAlign(int cell, bool isColumn) const
1345 int i = isColumn ? cell : column_of_cell(cell);
1350 //i = column_of_cell(cell);
1351 if (!isColumn && IsMultiColumn(cell)) {
1352 if (!cellinfo_of_cell(cell)->align_special.empty()) {
1353 return cellinfo_of_cell(cell)->align_special.c_str();
1355 switch (GetAlignment(cell)) {
1356 case LYX_ALIGN_LEFT:
1358 case LYX_ALIGN_RIGHT:
1365 if (!column_info[i].align_special.empty()) {
1366 return column_info[i].align_special.c_str();
1368 #ifdef IGNORE_THIS_FOR_NOW
1369 else if (!column_info[i].p_width.empty()) {
1371 file += column_info[i].p_width;
1376 switch (column_info[i].alignment) {
1377 case LYX_ALIGN_LEFT:
1379 case LYX_ALIGN_RIGHT:
1389 // cell <0 will tex the preamble
1390 // returns the number of printed newlines
1391 int LyXTabular::DocBookEndOfCell(ostream & os, int cell, int & depth) const
1395 //int tmp; // tmp2; // unused
1396 int nvcell; // fcell; // unused
1397 if (IsLastCell(cell)) {
1398 os << newlineAndDepth(--depth)
1400 << newlineAndDepth(--depth)
1402 << newlineAndDepth(--depth)
1404 << newlineAndDepth(--depth);
1405 if (is_long_tabular)
1409 << newlineAndDepth(--depth);
1415 if (is_long_tabular)
1421 << "' COLSEP='1' ROWSEP='1'>"
1422 << newlineAndDepth(++depth);
1424 for (i = 0; i < columns_; ++i) {
1425 os << "<COLSPEC ALIGN='"
1426 << GetDocBookAlign(i, true)
1432 if (i == (columns_-1)) {
1435 if (column_info[i].right_line ||
1436 column_info[i+1].left_line)
1442 << newlineAndDepth(depth);
1444 #ifdef NOT_HANDLED_YET_AS_I_DONT_KNOW_HOW
1445 if (column_info[i].left_line)
1450 << newlineAndDepth(++depth)
1452 << newlineAndDepth(++depth)
1454 << GetDocBookAlign(0)
1456 if (IsMultiColumn(0)) {
1457 os << " NAMEST='col1' NAMEEND='col"
1458 << cells_in_multicolumn(0)
1462 << newlineAndDepth(++depth);
1465 if (IsLastCellInRow(cell)) {
1466 os << newlineAndDepth(--depth)
1468 << newlineAndDepth(--depth)
1470 << newlineAndDepth(depth)
1472 << newlineAndDepth(++depth)
1474 << GetDocBookAlign(cell + 1)
1475 << "' VALIGN='middle'";
1476 if (IsMultiColumn(cell + 1)) {
1477 os << " NAMEST='col"
1478 << column_of_cell(cell+1) + 1
1480 << column_of_cell(cell + 1) +
1481 cells_in_multicolumn(cell + 1)
1485 << newlineAndDepth(++depth);
1488 os << newlineAndDepth(--depth)
1490 << newlineAndDepth(depth)
1492 << GetDocBookAlign(cell + 1)
1493 << "' VALIGN='middle'";
1494 if (IsMultiColumn(cell + 1)) {
1495 os << " NAMEST='col"
1496 << column_of_cell(cell+1) + 1
1498 << column_of_cell(cell+1) +
1499 cells_in_multicolumn(cell+1)
1503 << newlineAndDepth(++depth);
1512 bool LyXTabular::IsMultiColumn(int cell) const
1514 return (cellinfo_of_cell(cell)->multicolumn != LyXTabular::CELL_NORMAL);
1518 LyXTabular::cellstruct * LyXTabular::cellinfo_of_cell(int cell) const
1520 int row = row_of_cell(cell);
1521 int column = column_of_cell(cell);
1522 return &cell_info[row][column];
1526 void LyXTabular::SetMultiColumn(int cell, int number)
1528 cellinfo_of_cell(cell)->multicolumn = CELL_BEGIN_OF_MULTICOLUMN;
1529 cellinfo_of_cell(cell)->alignment = column_info[column_of_cell(cell)].alignment;
1530 cellinfo_of_cell(cell)->top_line = row_info[row_of_cell(cell)].top_line;
1531 cellinfo_of_cell(cell)->bottom_line = row_info[row_of_cell(cell)].bottom_line;
1532 for (number--; number > 0; --number) {
1533 cellinfo_of_cell(cell+number)->multicolumn = CELL_PART_OF_MULTICOLUMN;
1535 set_row_column_number_info();
1539 int LyXTabular::cells_in_multicolumn(int cell) const
1541 int row = row_of_cell(cell);
1542 int column = column_of_cell(cell);
1545 while ((column < columns_) &&
1546 cell_info[row][column].multicolumn == CELL_PART_OF_MULTICOLUMN)
1555 int LyXTabular::UnsetMultiColumn(int cell)
1557 int row = row_of_cell(cell);
1558 int column = column_of_cell(cell);
1562 if (cell_info[row][column].multicolumn == CELL_BEGIN_OF_MULTICOLUMN) {
1563 cell_info[row][column].multicolumn = CELL_NORMAL;
1565 while ((column < columns_) &&
1566 (cell_info[row][column].multicolumn ==CELL_PART_OF_MULTICOLUMN))
1568 cell_info[row][column].multicolumn = CELL_NORMAL;
1573 set_row_column_number_info();
1578 void LyXTabular::SetLongTabular(int what)
1580 is_long_tabular = what;
1584 bool LyXTabular::IsLongTabular() const
1586 return is_long_tabular;
1590 void LyXTabular::SetRotateTabular(int what)
1596 bool LyXTabular::GetRotateTabular() const
1602 void LyXTabular::SetRotateCell(int cell, int what)
1604 cellinfo_of_cell(cell)->rotate = what;
1608 bool LyXTabular::GetRotateCell(int cell) const
1610 return cellinfo_of_cell(cell)->rotate;
1614 bool LyXTabular::NeedRotating() const
1618 for (int i = 0; i < rows_; ++i) {
1619 for (int j = 0; j < columns_; ++j) {
1620 if (cell_info[i][j].rotate)
1628 bool LyXTabular::IsLastCell(int cell) const
1630 if ((cell+1) < GetNumberOfCells())
1636 int LyXTabular::GetCellAbove(int cell) const
1638 if (row_of_cell(cell) > 0)
1639 return cell_info[row_of_cell(cell)-1][column_of_cell(cell)].cellno;
1644 int LyXTabular::GetCellBelow(int cell) const
1646 if (row_of_cell(cell)+1 < rows_)
1647 return cell_info[row_of_cell(cell)+1][column_of_cell(cell)].cellno;
1652 int LyXTabular::GetLastCellAbove(int cell) const
1654 if (row_of_cell(cell) <= 0)
1656 if (!IsMultiColumn(cell))
1657 return GetCellAbove(cell);
1658 return cell_info[row_of_cell(cell)-1][right_column_of_cell(cell)].cellno;
1662 int LyXTabular::GetLastCellBelow(int cell) const
1664 if (row_of_cell(cell)+1 >= rows_)
1666 if (!IsMultiColumn(cell))
1667 return GetCellBelow(cell);
1668 return cell_info[row_of_cell(cell)+1][right_column_of_cell(cell)].cellno;
1672 int LyXTabular::GetCellNumber(int row, int column) const
1674 if (column >= columns_)
1675 column = columns_ - 1;
1676 else if (column < 0)
1683 return cell_info[row][column].cellno;
1687 void LyXTabular::SetUsebox(int cell, int what)
1689 cellinfo_of_cell(cell)->usebox = what;
1693 int LyXTabular::GetUsebox(int cell) const
1695 if (column_info[column_of_cell(cell)].p_width.empty() &&
1696 !(IsMultiColumn(cell) && !cellinfo_of_cell(cell)->p_width.empty()))
1698 return cellinfo_of_cell(cell)->usebox;
1702 void LyXTabular::SetLTHead(int cell, bool first)
1704 int row = row_of_cell(cell);
1705 int val = (row+1) * (column_of_cell(cell)? 1:-1);
1708 if (endfirsthead == val)
1721 bool LyXTabular::GetRowOfLTHead(int cell, int & row) const
1724 if (abs(endhead) > rows_)
1726 return (row_of_cell(cell) == (abs(endhead)-1));
1730 bool LyXTabular::GetRowOfLTFirstHead(int cell, int & row) const
1733 if (abs(endfirsthead) > rows_)
1735 return (row_of_cell(cell) == (abs(endfirsthead)-1));
1739 void LyXTabular::SetLTFoot(int cell, bool last)
1741 int row = row_of_cell(cell);
1742 int val = (row + 1) * (column_of_cell(cell)? 1:-1);
1745 if (endlastfoot == val)
1758 bool LyXTabular::GetRowOfLTFoot(int cell, int & row) const
1761 if ((endfoot+1) > rows_)
1763 return (row_of_cell(cell) == (abs(endfoot)-1));
1766 bool LyXTabular::GetRowOfLTLastFoot(int cell, int & row) const
1769 if (abs(endlastfoot) > rows_)
1771 return (row_of_cell(cell) == (abs(endlastfoot)-1));
1775 void LyXTabular::SetLTNewPage(int cell, bool what)
1777 row_info[row_of_cell(cell)].newpage = what;
1781 bool LyXTabular::GetLTNewPage(int cell) const
1783 return row_info[row_of_cell(cell)].newpage;
1787 bool LyXTabular::SetAscentOfRow(int row, int height)
1789 if ((row >= rows_) || (row_info[row].ascent_of_row == height))
1791 row_info[row].ascent_of_row = height;
1796 bool LyXTabular::SetDescentOfRow(int row, int height)
1798 if ((row >= rows_) || (row_info[row].descent_of_row == height))
1800 row_info[row].descent_of_row = height;
1805 int LyXTabular::GetAscentOfRow(int row) const
1809 return row_info[row].ascent_of_row;
1813 int LyXTabular::GetDescentOfRow(int row) const
1817 return row_info[row].descent_of_row;
1821 int LyXTabular::GetHeightOfTabular() const
1825 for(int row = 0; row < rows_; ++row)
1826 height += GetAscentOfRow(row) + GetDescentOfRow(row) +
1827 GetAdditionalHeight(GetCellNumber(row, 0));
1832 bool LyXTabular::IsPartOfMultiColumn(int row, int column) const
1834 if ((row >= rows_) || (column >= columns_))
1836 return (cell_info[row][column].multicolumn==CELL_PART_OF_MULTICOLUMN);
1840 int LyXTabular::TeXTopHLine(ostream & os, int row) const
1842 int fcell = GetFirstCellInRow(row);
1843 int n = NumberOfCellsInRow(fcell) + fcell;
1847 for (i = fcell; i < n; ++i) {
1851 if (tmp == (n - fcell)){
1854 for (i = fcell; i < n; ++i) {
1857 << column_of_cell(i) + 1
1859 << right_column_of_cell(i) + 1
1872 int LyXTabular::TeXBottomHLine(ostream & os, int row) const
1874 int fcell = GetFirstCellInRow(row);
1875 int n = NumberOfCellsInRow(fcell) + fcell;
1879 for (i = fcell; i < n; ++i) {
1883 if (tmp == (n-fcell)){
1886 for (i = fcell; i < n; ++i) {
1887 if (BottomLine(i)) {
1889 << column_of_cell(i) + 1
1891 << right_column_of_cell(i) + 1
1904 int LyXTabular::TeXCellPreamble(ostream & os, int cell) const
1908 if (GetRotateCell(cell)) {
1909 os << "\\begin{sideways}" << endl;
1912 if (IsMultiColumn(cell)) {
1913 os << "\\multicolumn{" << cells_in_multicolumn(cell) << "}{";
1914 if (!cellinfo_of_cell(cell+1)->align_special.empty()) {
1915 os << cellinfo_of_cell(cell+1)->align_special << "}{";
1919 if (!GetPWidth(cell).empty()) {
1920 switch(GetVAlignment(cell)) {
1921 case LYX_VALIGN_TOP:
1924 case LYX_VALIGN_CENTER:
1927 case LYX_VALIGN_BOTTOM:
1931 os << "{" << GetPWidth(cell) << '}';
1933 switch (GetAlignment(cell)) {
1934 case LYX_ALIGN_LEFT:
1937 case LYX_ALIGN_RIGHT:
1945 if (RightLine(cell))
1947 if (((cell + 1) < numberofcells) && !IsFirstCellInRow(cell+1) &&
1953 if (GetUsebox(cell) == 1) {
1955 switch(GetVAlignment(cell)) {
1956 case LYX_VALIGN_TOP:
1959 case LYX_VALIGN_CENTER:
1962 case LYX_VALIGN_BOTTOM:
1966 os << "]{" << GetPWidth(cell) << "}{";
1967 } else if (GetUsebox(cell) == 2) {
1968 os << "\\begin{minipage}[";
1969 switch(GetVAlignment(cell)) {
1970 case LYX_VALIGN_TOP:
1973 case LYX_VALIGN_CENTER:
1976 case LYX_VALIGN_BOTTOM:
1980 os << "]{" << GetPWidth(cell) << "}\n";
1987 int LyXTabular::TeXCellPostamble(ostream & os, int cell) const
1992 if (GetUsebox(cell) == 1)
1994 else if (GetUsebox(cell) == 2) {
1995 os << "%\n\\end{minipage}";
1998 if (IsMultiColumn(cell)){
2001 if (GetRotateCell(cell)) {
2002 os << "%\n\\end{sideways}";
2009 int LyXTabular::Latex(Buffer const * buf, ostream & os, bool fragile, bool fp) const
2015 //+---------------------------------------------------------------------
2016 //+ first the opening preamble +
2017 //+---------------------------------------------------------------------
2020 os << "\\begin{sideways}" << endl;
2023 if (is_long_tabular)
2024 os << "\\begin{longtable}{";
2026 os << "\\begin{tabular}{";
2027 for (i = 0; i < columns_; ++i) {
2028 if (column_info[i].left_line)
2030 if (!column_info[i].align_special.empty()) {
2031 os << column_info[i].align_special;
2032 } else if (!column_info[i].p_width.empty()) {
2033 switch(column_info[i].valignment) {
2034 case LYX_VALIGN_TOP:
2037 case LYX_VALIGN_CENTER:
2040 case LYX_VALIGN_BOTTOM:
2045 << column_info[i].p_width
2048 switch (column_info[i].alignment) {
2049 case LYX_ALIGN_LEFT:
2052 case LYX_ALIGN_RIGHT:
2060 if (column_info[i].right_line)
2066 //+---------------------------------------------------------------------
2067 //+ the single row and columns (cells) +
2068 //+---------------------------------------------------------------------
2071 for(i=0; i < rows_; ++i) {
2072 ret += TeXTopHLine(os, i);
2074 if (IsLongTabular()) {
2075 if ((endhead < 0) && (i == (abs(endhead)-1))) {
2076 os << "\\endhead\n";
2079 if ((endfirsthead < 0) && (i == (abs(endfirsthead)-1))) {
2080 os << "\\endfirsthead\n";
2083 if ((endfoot < 0) && (i == (abs(endfoot)-1))) {
2084 os << "\\endfoot\n";
2087 if ((endlastfoot < 0) && (i == (abs(endlastfoot)-1))) {
2088 os << "\\endlastfoot\n";
2094 ret += TeXBottomHLine(os, i-1);
2095 ret += TeXTopHLine(os, i);
2097 for(j=0; j < columns_; ++j) {
2098 if (IsPartOfMultiColumn(i,j))
2100 ret += TeXCellPreamble(os, cell);
2101 ret += GetCellInset(cell)->Latex(buf, os, fragile, fp);
2102 ret += TeXCellPostamble(os, cell);
2103 if (!IsLastCellInRow(cell)) { // not last cell in row
2109 os << "\\\\" << endl;
2110 ret += TeXBottomHLine(os, i);
2112 if (IsLongTabular()) {
2113 if ((endhead > 0) && (i == (endhead-1))) {
2114 os << "\\endhead\n";
2117 if ((endfirsthead > 0) && (i == (endfirsthead-1))) {
2118 os << "\\endfirsthead\n";
2121 if ((endfoot > 0) && (i == (endfoot-1))) {
2122 os << "\\endfoot\n";
2125 if ((endlastfoot > 0) && (i == (endlastfoot-1))) {
2126 os << "\\endlastfoot\n";
2130 ret += TeXBottomHLine(os, i);
2131 if (row_info[i].newpage) {
2132 os << "\\newpage\n";
2138 //+---------------------------------------------------------------------
2139 //+ the closing of the tabular +
2140 //+---------------------------------------------------------------------
2142 if (is_long_tabular)
2143 os << "\\end{longtable}";
2145 os << "\\end{tabular}";
2147 os << "\n\\end{sideways}";
2155 InsetText * LyXTabular::GetCellInset(int cell) const
2157 return & cell_info[row_of_cell(cell)][column_of_cell(cell)].inset;
2160 void LyXTabular::Validate(LaTeXFeatures & features) const
2162 if (IsLongTabular())
2163 features.longtable = true;
2165 features.rotating = true;
2166 for(int cell = 0; cell < numberofcells; ++cell) {
2167 if (GetVAlignment(cell) != LYX_VALIGN_TOP)
2168 features.array = true;
2169 GetCellInset(cell)->Validate(features);