+int LyXTabular::TeXLongtableHeaderFooter(ostream & os, Buffer const * buf,
+ bool fragile, bool fp) const
+{
+ if (!is_long_tabular)
+ return 0;
+
+ int ret = 0;
+ // output header info
+ if (haveLTHead()) {
+ if (endhead.topDL) {
+ os << "\\hline\n";
+ ++ret;
+ }
+ for (int i = 0; i < rows_; ++i) {
+ if (row_info[i].endhead) {
+ ret += TeXRow(os, i, buf, fragile, fp);
+ }
+ }
+ if (endhead.bottomDL) {
+ os << "\\hline\n";
+ ++ret;
+ }
+ os << "\\endhead\n";
+ ++ret;
+ if (endfirsthead.empty) {
+ os << "\\endfirsthead\n";
+ ++ret;
+ }
+ }
+ // output firstheader info
+ if (haveLTFirstHead()) {
+ if (endfirsthead.topDL) {
+ os << "\\hline\n";
+ ++ret;
+ }
+ for (int i = 0; i < rows_; ++i) {
+ if (row_info[i].endfirsthead) {
+ ret += TeXRow(os, i, buf, fragile, fp);
+ }
+ }
+ if (endfirsthead.bottomDL) {
+ os << "\\hline\n";
+ ++ret;
+ }
+ os << "\\endfirsthead\n";
+ ++ret;
+ }
+ // output footer info
+ if (haveLTFoot()) {
+ if (endfoot.topDL) {
+ os << "\\hline\n";
+ ++ret;
+ }
+ for (int i = 0; i < rows_; ++i) {
+ if (row_info[i].endfoot) {
+ ret += TeXRow(os, i, buf, fragile, fp);
+ }
+ }
+ if (endfoot.bottomDL) {
+ os << "\\hline\n";
+ ++ret;
+ }
+ os << "\\endfoot\n";
+ ++ret;
+ if (endlastfoot.empty) {
+ os << "\\endlastfoot\n";
+ ++ret;
+ }
+ }
+ // output lastfooter info
+ if (haveLTLastFoot()) {
+ if (endlastfoot.topDL) {
+ os << "\\hline\n";
+ ++ret;
+ }
+ for (int i = 0; i < rows_; ++i) {
+ if (row_info[i].endlastfoot) {
+ ret += TeXRow(os, i, buf, fragile, fp);
+ }
+ }
+ if (endlastfoot.bottomDL) {
+ os << "\\hline\n";
+ ++ret;
+ }
+ os << "\\endlastfoot\n";
+ ++ret;
+ }
+ return ret;
+}
+
+
+bool LyXTabular::isValidRow(int const row) const
+{
+ if (!is_long_tabular)
+ return true;
+ return (!row_info[row].endhead && !row_info[row].endfirsthead &&
+ !row_info[row].endfoot && !row_info[row].endlastfoot);
+}
+
+
+int LyXTabular::TeXRow(ostream & os, int const i, Buffer const * buf,
+ bool fragile, bool fp) const
+{
+ int ret = 0;
+ int cell = GetCellNumber(i, 0);
+
+ ret += TeXTopHLine(os, i);
+ for (int j = 0; j < columns_; ++j) {
+ if (IsPartOfMultiColumn(i,j))
+ continue;
+ ret += TeXCellPreamble(os, cell);
+ InsetText * inset = GetCellInset(cell);
+
+ bool rtl = inset->paragraph()->isRightToLeftPar(buf->params) &&
+ !inset->paragraph()->empty() && GetPWidth(cell).zero();
+
+ if (rtl)
+ os << "\\R{";
+ ret += inset->latex(buf, os, fragile, fp);
+ if (rtl)
+ os << "}";
+
+ ret += TeXCellPostamble(os, cell);
+ if (!IsLastCellInRow(cell)) { // not last cell in row
+ os << "&\n";
+ ++ret;
+ }
+ ++cell;
+ }
+ os << "\\tabularnewline\n";
+ ++ret;
+ ret += TeXBottomHLine(os, i);
+ return ret;
+}
+
+
+int LyXTabular::latex(Buffer const * buf,