+ os << "]{" << GetPWidth(cell) << "}\n";
+ ++ret;
+ }
+ return ret;
+}
+
+
+int LyXTabular::TeXCellPostamble(ostream & os, int cell) const
+{
+ int ret = 0;
+
+ // usual cells
+ if (GetUsebox(cell) == BOX_PARBOX)
+ os << "}";
+ else if (GetUsebox(cell) == BOX_MINIPAGE) {
+ os << "%\n\\end{minipage}";
+ ret += 2;
+ }
+ if (IsMultiColumn(cell)){
+ os << '}';
+ }
+ if (GetRotateCell(cell)) {
+ os << "%\n\\end{sideways}";
+ ++ret;
+ }
+ return ret;
+}
+
+
+int LyXTabular::Latex(Buffer const * buf,
+ ostream & os, bool fragile, bool fp) const
+{
+ int ret = 0;
+ int cell = 0;
+
+ //+---------------------------------------------------------------------
+ //+ first the opening preamble +
+ //+---------------------------------------------------------------------
+
+ if (rotate) {
+ os << "\\begin{sideways}\n";
+ ++ret;
+ }
+ if (is_long_tabular)
+ os << "\\begin{longtable}{";
+ else
+ os << "\\begin{tabular}{";
+ for (int i = 0; i < columns_; ++i) {
+ if (!column_info[i].align_special.empty()) {
+ os << column_info[i].align_special;
+ } else {
+ if (column_info[i].left_line)
+ os << '|';
+ if (!column_info[i].p_width.empty()) {
+ switch (column_info[i].valignment) {
+ case LYX_VALIGN_TOP:
+ os << "p";
+ break;
+ case LYX_VALIGN_CENTER:
+ os << "m";
+ break;
+ case LYX_VALIGN_BOTTOM:
+ os << "b";
+ break;
+ }
+ os << "{"
+ << column_info[i].p_width
+ << '}';
+ } else {
+ switch (column_info[i].alignment) {
+ case LYX_ALIGN_LEFT:
+ os << 'l';
+ break;
+ case LYX_ALIGN_RIGHT:
+ os << 'r';
+ break;
+ default:
+ os << 'c';
+ break;
+ }
+ }
+ if (column_info[i].right_line)
+ os << '|';
+ }
+ }
+ os << "}\n";
+ ++ret;
+
+ //+---------------------------------------------------------------------
+ //+ the single row and columns (cells) +
+ //+---------------------------------------------------------------------
+
+ for (int i = 0; i < rows_; ++i) {
+ ret += TeXTopHLine(os, i);
+#warning Implement top double lines for LT Header/Footers
+#if 0
+ if (ret > bret) {
+ ret += TeXBottomHLine(os, i-1);
+ ret += TeXTopHLine(os, i);
+ }
+#endif
+ 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()->size() > 0 && GetPWidth(cell).empty();
+
+ 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 << "\\\\\n";
+ ++ret;
+ ret += TeXBottomHLine(os, i);
+ if (IsLongTabular()) {
+ if (i == (endhead.row - 1)) {
+ if (endhead.bottomDL)
+ ret += TeXBottomHLine(os, i);
+ os << "\\endhead\n";
+ ++ret;
+ }
+ if (i == (endfirsthead.row - 1)) {
+ if (endfirsthead.bottomDL)
+ ret += TeXBottomHLine(os, i);
+ os << "\\endfirsthead\n";
+ ++ret;
+ }
+ if (i == (endfoot.row - 1)) {
+ if (endfoot.bottomDL)
+ ret += TeXBottomHLine(os, i);
+ os << "\\endfoot\n";
+ ++ret;
+ }
+ if (i == (endlastfoot.row - 1)) {
+ if (endlastfoot.bottomDL)
+ ret += TeXBottomHLine(os, i);
+ os << "\\endlastfoot\n";
+ ++ret;
+ }
+ if (row_info[i].newpage) {
+ os << "\\newpage\n";
+ ++ret;
+ }
+ }
+ }
+
+ //+---------------------------------------------------------------------
+ //+ the closing of the tabular +
+ //+---------------------------------------------------------------------
+
+ if (is_long_tabular)
+ os << "\\end{longtable}";
+ else
+ os << "\\end{tabular}";
+ if (rotate) {
+ os << "\n\\end{sideways}";
+ ++ret;
+ }
+
+ return ret;
+}
+
+
+int LyXTabular::docbookRow(Buffer const * buf, ostream & os, int row) const
+{
+ int ret = 0;
+ int cell = GetFirstCellInRow(row);
+
+ os << "<row>\n";
+ for (int j = 0; j < columns_; ++j) {
+ if (IsPartOfMultiColumn(row, j))
+ continue;
+
+ os << "<entry align=\"";