]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetTabular.cpp
A little more CSS for tables.
[lyx.git] / src / insets / InsetTabular.cpp
index 9d2bc33fd1de1374c7a185384bb3abf97389b4ac..4ad6ae474817ea12495c882822fd92010b1a0c56 100644 (file)
@@ -2636,26 +2636,6 @@ int Tabular::docbook(odocstream & os, OutputParams const & runparams) const
 docstring Tabular::xhtmlRow(XHTMLStream & xs, row_type row,
                           OutputParams const & runparams) const
 {
-       /* for (col_type i = 0; i < column_info.size(); ++i) {
-               os << "<colspec colname=\"col" << i << "\" align=\"";
-               switch (column_info[i].alignment) {
-               case LYX_ALIGN_LEFT:
-                       os << "left";
-                       break;
-               case LYX_ALIGN_RIGHT:
-                       os << "right";
-                       break;
-               default:
-                       os << "center";
-                       break;
-               }
-               os << '"';
-               if (runparams.flavor == OutputParams::XML)
-                       os << '/';
-               os << ">\n";
-               ++ret;
-       } */
-       
        docstring ret;
        idx_type cell = getFirstCellInRow(row);
 
@@ -2692,7 +2672,7 @@ docstring Tabular::xhtmlRow(XHTMLStream & xs, row_type row,
                attr << "'";
 
                if (isMultiColumn(cell))
-                       attr << " colspan='" << j + columnSpan(cell) - 1<< "'";
+                       attr << " colspan='" << columnSpan(cell) << "'";
 
                xs << StartTag("td", attr.str());
                ret += cellInset(cell)->xhtml(xs, runparams);
@@ -2707,8 +2687,6 @@ docstring Tabular::xhtmlRow(XHTMLStream & xs, row_type row,
 docstring Tabular::xhtml(XHTMLStream & xs, OutputParams const & runparams) const
 {
        docstring ret;
-       xs << StartTag("table");
-
        // It's unclear to me if we need to mess with the long table stuff. 
        // We can borrow that too from docbook, if so.
 
@@ -2719,8 +2697,6 @@ docstring Tabular::xhtml(XHTMLStream & xs, OutputParams const & runparams) const
                }
        }
        xs << EndTag("tbody");
-       xs << EndTag("table");
-
        return ret;
 }
 
@@ -4321,13 +4297,27 @@ int InsetTabular::docbook(odocstream & os, OutputParams const & runparams) const
 
 docstring InsetTabular::xhtml(XHTMLStream & xs, OutputParams const & rp) const
 {
-       return tabular.xhtml(xs, rp);
+       // FIXME XHTML
+       // It'd be better to be able to get this from an InsetLayout, but at present
+       // InsetLayouts do not seem really to work for things that aren't InsetTexts.
+       xs << StartTag("table");
+       docstring ret = tabular.xhtml(xs, rp);
+       xs << EndTag("table");
+       return ret;
 }
 
 
 void InsetTabular::validate(LaTeXFeatures & features) const
 {
        tabular.validate(features);
+       // FIXME XHTML
+       // It'd be better to be able to get this from an InsetLayout, but at present
+       // InsetLayouts do not seem really to work for things that aren't InsetTexts.
+       if (features.runparams().flavor == OutputParams::HTML)
+               features.addPreambleSnippet("<style type=\"text/css\">\n"
+      "table { border: 1px solid black; display: inline-block; }\n"
+      "td { border: 1px solid black; padding: 0.5ex; }\n"
+      "</style>");
 }