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 " linebreaks=" << cell_info[i][j].linebreaks <<
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, "linebreaks", cell_info[i][j].linebreaks);
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].linebreaks = 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;
1261 LyXParagraph::footnote_flag footnoteflag = LyXParagraph::NO_FOOTNOTE;
1262 LyXParagraph::footnote_kind footnotekind = LyXParagraph::FOOTNOTE;
1263 string token, tmptok;
1266 LyXFont font(LyXFont::ALL_SANE);
1268 while (lex.IsOK()) {
1270 token = lex.GetString();
1273 if ((token == "\\layout") || (token == "\\end_float") ||
1274 (token == "\\end_deeper"))
1276 lex.pushToken(token);
1279 if (owner_->BufferOwner()->parseSingleLyXformat2Token(lex, par,
1287 lex.pushToken(token);
1291 lex.printError("New Paragraph allocated! This should not happen!");
1292 lex.pushToken(token);
1298 // now we have the par we should fill the insets with this!
1300 InsetText * inset = GetCellInset(cell);
1303 for(int i = 0; i < par->Last(); ++i) {
1304 if (par->IsNewline(i)) {
1306 if (cell > GetNumberOfCells()) {
1307 lyxerr << "Some error in reading old table format occured!" <<
1308 endl << "Terminating when reading cell[" << cell << "]!" <<
1312 row = row_of_cell(cell);
1313 if (cont_row_info[row]) {
1315 cont_row_info.erase(cont_row_info.begin() + row); //&cont_row_info[row]);
1316 while(!IsFirstCellInRow(--cell));
1318 inset = GetCellInset(cell);
1321 inset = GetCellInset(cell);
1322 row = row_of_cell(cell);
1323 if (!cell_info[row_of_cell(cell)][column_of_cell(cell)].linebreaks)
1325 // insert a space instead
1327 par->InsertChar(i, ' ');
1330 par->CopyIntoMinibuffer(current_view->buffer()->params, i);
1331 inset->par->InsertFromMinibuffer(inset->par->Last());
1337 char const * LyXTabular::GetDocBookAlign(int cell, bool isColumn) const
1339 int i = isColumn ? cell : column_of_cell(cell);
1344 //i = column_of_cell(cell);
1345 if (!isColumn && IsMultiColumn(cell)) {
1346 if (!cellinfo_of_cell(cell)->align_special.empty()) {
1347 return cellinfo_of_cell(cell)->align_special.c_str();
1349 switch (GetAlignment(cell)) {
1350 case LYX_ALIGN_LEFT:
1352 case LYX_ALIGN_RIGHT:
1359 if (!column_info[i].align_special.empty()) {
1360 return column_info[i].align_special.c_str();
1362 #ifdef IGNORE_THIS_FOR_NOW
1363 else if (!column_info[i].p_width.empty()) {
1365 file += column_info[i].p_width;
1370 switch (column_info[i].alignment) {
1371 case LYX_ALIGN_LEFT:
1373 case LYX_ALIGN_RIGHT:
1383 // cell <0 will tex the preamble
1384 // returns the number of printed newlines
1385 int LyXTabular::DocBookEndOfCell(ostream & os, int cell, int & depth) const
1389 //int tmp; // tmp2; // unused
1390 int nvcell; // fcell; // unused
1391 if (IsLastCell(cell)) {
1392 os << newlineAndDepth(--depth)
1394 << newlineAndDepth(--depth)
1396 << newlineAndDepth(--depth)
1398 << newlineAndDepth(--depth);
1399 if (is_long_tabular)
1403 << newlineAndDepth(--depth);
1409 if (is_long_tabular)
1415 << "' COLSEP='1' ROWSEP='1'>"
1416 << newlineAndDepth(++depth);
1418 for (i = 0; i < columns_; ++i) {
1419 os << "<COLSPEC ALIGN='"
1420 << GetDocBookAlign(i, true)
1426 if (i == (columns_-1)) {
1429 if (column_info[i].right_line ||
1430 column_info[i+1].left_line)
1436 << newlineAndDepth(depth);
1438 #ifdef NOT_HANDLED_YET_AS_I_DONT_KNOW_HOW
1439 if (column_info[i].left_line)
1444 << newlineAndDepth(++depth)
1446 << newlineAndDepth(++depth)
1448 << GetDocBookAlign(0)
1450 if (IsMultiColumn(0)) {
1451 os << " NAMEST='col1' NAMEEND='col"
1452 << cells_in_multicolumn(0)
1456 << newlineAndDepth(++depth);
1459 if (IsLastCellInRow(cell)) {
1460 os << newlineAndDepth(--depth)
1462 << newlineAndDepth(--depth)
1464 << newlineAndDepth(depth)
1466 << newlineAndDepth(++depth)
1468 << GetDocBookAlign(cell + 1)
1469 << "' VALIGN='middle'";
1470 if (IsMultiColumn(cell + 1)) {
1471 os << " NAMEST='col"
1472 << column_of_cell(cell+1) + 1
1474 << column_of_cell(cell + 1) +
1475 cells_in_multicolumn(cell + 1)
1479 << newlineAndDepth(++depth);
1482 os << newlineAndDepth(--depth)
1484 << newlineAndDepth(depth)
1486 << GetDocBookAlign(cell + 1)
1487 << "' VALIGN='middle'";
1488 if (IsMultiColumn(cell + 1)) {
1489 os << " NAMEST='col"
1490 << column_of_cell(cell+1) + 1
1492 << column_of_cell(cell+1) +
1493 cells_in_multicolumn(cell+1)
1497 << newlineAndDepth(++depth);
1506 bool LyXTabular::IsMultiColumn(int cell) const
1508 return (cellinfo_of_cell(cell)->multicolumn != LyXTabular::CELL_NORMAL);
1512 LyXTabular::cellstruct * LyXTabular::cellinfo_of_cell(int cell) const
1514 int row = row_of_cell(cell);
1515 int column = column_of_cell(cell);
1516 return &cell_info[row][column];
1520 void LyXTabular::SetMultiColumn(int cell, int number)
1522 cellinfo_of_cell(cell)->multicolumn = CELL_BEGIN_OF_MULTICOLUMN;
1523 cellinfo_of_cell(cell)->alignment = column_info[column_of_cell(cell)].alignment;
1524 cellinfo_of_cell(cell)->top_line = row_info[row_of_cell(cell)].top_line;
1525 cellinfo_of_cell(cell)->bottom_line = row_info[row_of_cell(cell)].bottom_line;
1526 for (number--; number > 0; --number) {
1527 cellinfo_of_cell(cell+number)->multicolumn = CELL_PART_OF_MULTICOLUMN;
1529 set_row_column_number_info();
1533 int LyXTabular::cells_in_multicolumn(int cell) const
1535 int row = row_of_cell(cell);
1536 int column = column_of_cell(cell);
1539 while ((column < columns_) &&
1540 cell_info[row][column].multicolumn == CELL_PART_OF_MULTICOLUMN)
1549 int LyXTabular::UnsetMultiColumn(int cell)
1551 int row = row_of_cell(cell);
1552 int column = column_of_cell(cell);
1556 if (cell_info[row][column].multicolumn == CELL_BEGIN_OF_MULTICOLUMN) {
1557 cell_info[row][column].multicolumn = CELL_NORMAL;
1559 while ((column < columns_) &&
1560 (cell_info[row][column].multicolumn ==CELL_PART_OF_MULTICOLUMN))
1562 cell_info[row][column].multicolumn = CELL_NORMAL;
1567 set_row_column_number_info();
1572 void LyXTabular::SetLongTabular(int what)
1574 is_long_tabular = what;
1578 bool LyXTabular::IsLongTabular() const
1580 return is_long_tabular;
1584 void LyXTabular::SetRotateTabular(int what)
1590 bool LyXTabular::GetRotateTabular() const
1596 void LyXTabular::SetRotateCell(int cell, int what)
1598 cellinfo_of_cell(cell)->rotate = what;
1602 bool LyXTabular::GetRotateCell(int cell) const
1604 return cellinfo_of_cell(cell)->rotate;
1608 bool LyXTabular::NeedRotating() const
1612 for (int i = 0; i < rows_; ++i) {
1613 for (int j = 0; j < columns_; ++j) {
1614 if (cell_info[i][j].rotate)
1622 bool LyXTabular::IsLastCell(int cell) const
1624 if ((cell+1) < GetNumberOfCells())
1630 int LyXTabular::GetCellAbove(int cell) const
1632 if (row_of_cell(cell) > 0)
1633 return cell_info[row_of_cell(cell)-1][column_of_cell(cell)].cellno;
1638 int LyXTabular::GetCellBelow(int cell) const
1640 if (row_of_cell(cell)+1 < rows_)
1641 return cell_info[row_of_cell(cell)+1][column_of_cell(cell)].cellno;
1646 int LyXTabular::GetLastCellAbove(int cell) const
1648 if (row_of_cell(cell) <= 0)
1650 if (!IsMultiColumn(cell))
1651 return GetCellAbove(cell);
1652 return cell_info[row_of_cell(cell)-1][right_column_of_cell(cell)].cellno;
1656 int LyXTabular::GetLastCellBelow(int cell) const
1658 if (row_of_cell(cell)+1 >= rows_)
1660 if (!IsMultiColumn(cell))
1661 return GetCellBelow(cell);
1662 return cell_info[row_of_cell(cell)+1][right_column_of_cell(cell)].cellno;
1666 int LyXTabular::GetCellNumber(int row, int column) const
1668 if (column >= columns_)
1669 column = columns_ - 1;
1670 else if (column < 0)
1677 return cell_info[row][column].cellno;
1681 void LyXTabular::SetLinebreaks(int cell, bool what)
1683 cellinfo_of_cell(cell)->linebreaks = what;
1687 bool LyXTabular::GetLinebreaks(int cell) const
1689 if (column_info[column_of_cell(cell)].p_width.empty() &&
1690 !(IsMultiColumn(cell) && !cellinfo_of_cell(cell)->p_width.empty()))
1692 return cellinfo_of_cell(cell)->linebreaks;
1696 void LyXTabular::SetLTHead(int cell, bool first)
1698 int row = row_of_cell(cell);
1699 int val = (row+1) * (column_of_cell(cell)? 1:-1);
1702 if (endfirsthead == val)
1715 bool LyXTabular::GetRowOfLTHead(int cell, int & row) const
1718 if (abs(endhead) > rows_)
1720 return (row_of_cell(cell) == (abs(endhead)-1));
1724 bool LyXTabular::GetRowOfLTFirstHead(int cell, int & row) const
1727 if (abs(endfirsthead) > rows_)
1729 return (row_of_cell(cell) == (abs(endfirsthead)-1));
1733 void LyXTabular::SetLTFoot(int cell, bool last)
1735 int row = row_of_cell(cell);
1736 int val = (row + 1) * (column_of_cell(cell)? 1:-1);
1739 if (endlastfoot == val)
1752 bool LyXTabular::GetRowOfLTFoot(int cell, int & row) const
1755 if ((endfoot+1) > rows_)
1757 return (row_of_cell(cell) == (abs(endfoot)-1));
1760 bool LyXTabular::GetRowOfLTLastFoot(int cell, int & row) const
1763 if (abs(endlastfoot) > rows_)
1765 return (row_of_cell(cell) == (abs(endlastfoot)-1));
1769 void LyXTabular::SetLTNewPage(int cell, bool what)
1771 row_info[row_of_cell(cell)].newpage = what;
1775 bool LyXTabular::GetLTNewPage(int cell) const
1777 return row_info[row_of_cell(cell)].newpage;
1781 bool LyXTabular::SetAscentOfRow(int row, int height)
1783 if ((row >= rows_) || (row_info[row].ascent_of_row == height))
1785 row_info[row].ascent_of_row = height;
1790 bool LyXTabular::SetDescentOfRow(int row, int height)
1792 if ((row >= rows_) || (row_info[row].descent_of_row == height))
1794 row_info[row].descent_of_row = height;
1799 int LyXTabular::GetAscentOfRow(int row) const
1803 return row_info[row].ascent_of_row;
1807 int LyXTabular::GetDescentOfRow(int row) const
1811 return row_info[row].descent_of_row;
1815 int LyXTabular::GetHeightOfTabular() const
1819 for(int row = 0; row < rows_; ++row)
1820 height += GetAscentOfRow(row) + GetDescentOfRow(row) +
1821 GetAdditionalHeight(GetCellNumber(row, 0));
1826 bool LyXTabular::IsPartOfMultiColumn(int row, int column) const
1828 if ((row >= rows_) || (column >= columns_))
1830 return (cell_info[row][column].multicolumn==CELL_PART_OF_MULTICOLUMN);
1834 int LyXTabular::TeXTopHLine(ostream & os, int row) const
1836 int fcell = GetFirstCellInRow(row);
1837 int n = NumberOfCellsInRow(fcell) + fcell;
1841 for (i = fcell; i < n; ++i) {
1845 if (tmp == (n - fcell)){
1848 for (i = fcell; i < n; ++i) {
1851 << column_of_cell(i) + 1
1853 << right_column_of_cell(i) + 1
1866 int LyXTabular::TeXBottomHLine(ostream & os, int row) const
1868 int fcell = GetFirstCellInRow(row);
1869 int n = NumberOfCellsInRow(fcell) + fcell;
1873 for (i = fcell; i < n; ++i) {
1877 if (tmp == (n-fcell)){
1880 for (i = fcell; i < n; ++i) {
1881 if (BottomLine(i)) {
1883 << column_of_cell(i) + 1
1885 << right_column_of_cell(i) + 1
1898 int LyXTabular::TeXCellPreamble(ostream & os, int cell) const
1902 if (GetRotateCell(cell)) {
1903 os << "\\begin{sideways}" << endl;
1906 if (IsMultiColumn(cell)) {
1907 os << "\\multicolumn{" << cells_in_multicolumn(cell) << "}{";
1908 if (!cellinfo_of_cell(cell+1)->align_special.empty()) {
1909 os << cellinfo_of_cell(cell+1)->align_special << "}{";
1913 if (!GetPWidth(cell).empty()) {
1914 switch(GetVAlignment(cell)) {
1915 case LYX_VALIGN_TOP:
1918 case LYX_VALIGN_CENTER:
1921 case LYX_VALIGN_BOTTOM:
1925 os << "{" << GetPWidth(cell) << '}';
1927 switch (GetAlignment(cell)) {
1928 case LYX_ALIGN_LEFT:
1931 case LYX_ALIGN_RIGHT:
1939 if (RightLine(cell))
1941 if (((cell + 1) < numberofcells) && !IsFirstCellInRow(cell+1) &&
1947 if (GetLinebreaks(cell)) {
1949 switch(GetVAlignment(cell)) {
1950 case LYX_VALIGN_TOP:
1953 case LYX_VALIGN_CENTER:
1956 case LYX_VALIGN_BOTTOM:
1960 os << "]{" << GetPWidth(cell) << "}{\\smallskip{}";
1966 int LyXTabular::TeXCellPostamble(ostream & os, int cell) const
1971 if (GetLinebreaks(cell))
1972 os << "\\smallskip{}}";
1973 if (IsMultiColumn(cell)){
1976 if (GetRotateCell(cell)) {
1977 os << endl << "\\end{sideways}";
1984 int LyXTabular::Latex(Buffer const * buf, ostream & os, bool fragile, bool fp) const
1990 //+---------------------------------------------------------------------
1991 //+ first the opening preamble +
1992 //+---------------------------------------------------------------------
1995 os << "\\begin{sideways}" << endl;
1998 if (is_long_tabular)
1999 os << "\\begin{longtable}{";
2001 os << "\\begin{tabular}{";
2002 for (i = 0; i < columns_; ++i) {
2003 if (column_info[i].left_line)
2005 if (!column_info[i].align_special.empty()) {
2006 os << column_info[i].align_special;
2007 } else if (!column_info[i].p_width.empty()) {
2008 switch(column_info[i].valignment) {
2009 case LYX_VALIGN_TOP:
2012 case LYX_VALIGN_CENTER:
2015 case LYX_VALIGN_BOTTOM:
2020 << column_info[i].p_width
2023 switch (column_info[i].alignment) {
2024 case LYX_ALIGN_LEFT:
2027 case LYX_ALIGN_RIGHT:
2035 if (column_info[i].right_line)
2041 //+---------------------------------------------------------------------
2042 //+ the single row and columns (cells) +
2043 //+---------------------------------------------------------------------
2046 for(i=0; i < rows_; ++i) {
2047 ret += TeXTopHLine(os, i);
2049 if (IsLongTabular()) {
2050 if ((endhead < 0) && (i == (abs(endhead)-1))) {
2051 os << "\\endhead\n";
2054 if ((endfirsthead < 0) && (i == (abs(endfirsthead)-1))) {
2055 os << "\\endfirsthead\n";
2058 if ((endfoot < 0) && (i == (abs(endfoot)-1))) {
2059 os << "\\endfoot\n";
2062 if ((endlastfoot < 0) && (i == (abs(endlastfoot)-1))) {
2063 os << "\\endlastfoot\n";
2069 ret += TeXBottomHLine(os, i-1);
2070 ret += TeXTopHLine(os, i);
2072 for(j=0; j < columns_; ++j) {
2073 if (IsPartOfMultiColumn(i,j))
2075 ret += TeXCellPreamble(os, cell);
2076 ret += GetCellInset(cell)->Latex(buf, os, fragile, fp);
2077 ret += TeXCellPostamble(os, cell);
2078 if (!IsLastCellInRow(cell)) { // not last cell in row
2084 os << "\\\\" << endl;
2085 ret += TeXBottomHLine(os, i);
2087 if (IsLongTabular()) {
2088 if ((endhead > 0) && (i == (endhead-1))) {
2089 os << "\\endhead\n";
2092 if ((endfirsthead > 0) && (i == (endfirsthead-1))) {
2093 os << "\\endfirsthead\n";
2096 if ((endfoot > 0) && (i == (endfoot-1))) {
2097 os << "\\endfoot\n";
2100 if ((endlastfoot > 0) && (i == (endlastfoot-1))) {
2101 os << "\\endlastfoot\n";
2105 ret += TeXBottomHLine(os, i);
2106 if (row_info[i].newpage) {
2107 os << "\\newpage\n";
2113 //+---------------------------------------------------------------------
2114 //+ the closing of the tabular +
2115 //+---------------------------------------------------------------------
2117 if (is_long_tabular)
2118 os << "\\end{longtable}";
2120 os << "\\end{tabular}";
2122 os << "\n\\end{sideways}";
2130 InsetText * LyXTabular::GetCellInset(int cell) const
2132 return & cell_info[row_of_cell(cell)][column_of_cell(cell)].inset;
2135 void LyXTabular::Validate(LaTeXFeatures & features) const
2137 if (IsLongTabular())
2138 features.longtable = true;
2140 features.rotating = true;
2141 for(int cell = 0; cell < numberofcells; ++cell) {
2142 if (GetVAlignment(cell) != LYX_VALIGN_TOP)
2143 features.array = true;
2144 GetCellInset(cell)->Validate(features);