]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetTabular.cpp
Fix bug #12795
[lyx.git] / src / insets / InsetTabular.cpp
index 265a0165f8afd61d98bd8ef06bcb3391c7bb6810..69f9e73e59f0f0f11e125f2c80e4ba5449048455 100644 (file)
@@ -3677,7 +3677,7 @@ std::string Tabular::getHAlignAsCssAttribute(idx_type cell) const
                // experimental.
                // https://www.w3.org/TR/css-text-4/#character-alignment
                Language const *lang = buffer().paragraphs().front().getParLanguage(buffer().params());
-               return "text-align: '" + to_utf8(lang->decimalSeparator()) + "'";
+               return "text-align: \"" + to_utf8(lang->decimalSeparator()) + "\"";
        }
        default:
                return "text-align: center";
@@ -3798,7 +3798,7 @@ docstring Tabular::xmlRow(XMLStream & xs, const row_type row, OutputParams const
                if (output_format == XmlOutputFormat::XHTML) {
                        // In HTML5, prefer to use CSS instead of attributes for alignment
                        // (align and valign).
-                       style << getHAlignAsCssAttribute(cell) << " "
+                       style << getHAlignAsCssAttribute(cell) << "; "
                              << getVAlignAsCssAttribute(cell);
                } else {
                        // In DocBook, both for HTML and CALS tables, stick to attributes.
@@ -3825,9 +3825,11 @@ docstring Tabular::xmlRow(XMLStream & xs, const row_type row, OutputParams const
                if (is_xhtml_table) {
                        const std::vector<std::string> styles = computeCssStylePerCell(row, c, cell);
 
-                       std::string attr_str_prefix = "style='" ;
+                       std::string attr_str_prefix = "style='" + style.str();
+                       if (!styles.empty())
+                               attr_str_prefix += "; ";
                        for (auto it = styles.begin(); it != styles.end(); ++it) {
-                               attr << *it;
+                               attr_str_prefix += *it;
                                if (it != styles.end() - 1)
                                        attr_str_prefix += "; ";
                        }
@@ -7514,10 +7516,15 @@ docstring InsetTabular::asString(idx_type stidx, idx_type enidx,
 {
        LASSERT(stidx <= enidx, return docstring());
        docstring retval;
-       col_type const col1 = tabular.cellColumn(stidx);
-       col_type const col2 = tabular.cellColumn(enidx);
-       row_type const row1 = tabular.cellRow(stidx);
-       row_type const row2 = tabular.cellRow(enidx);
+       col_type col1 = tabular.cellColumn(stidx);
+       col_type col2 = tabular.cellColumn(enidx);
+       row_type row1 = tabular.cellRow(stidx);
+       row_type row2 = tabular.cellRow(enidx);
+       // stidx might be in a later column or row than enidx
+       if (col1 > col2)
+               swap(col1, col2);
+       if (row1 > row2)
+               swap(row1, row2);
        bool first = true;
        for (col_type col = col1; col <= col2; col++)
                for (row_type row = row1; row <= row2; row++) {
@@ -7535,10 +7542,15 @@ ParagraphList InsetTabular::asParList(idx_type stidx, idx_type enidx)
 {
        LASSERT(stidx <= enidx, return ParagraphList());
        ParagraphList retval;
-       col_type const col1 = tabular.cellColumn(stidx);
-       col_type const col2 = tabular.cellColumn(enidx);
-       row_type const row1 = tabular.cellRow(stidx);
-       row_type const row2 = tabular.cellRow(enidx);
+       col_type col1 = tabular.cellColumn(stidx);
+       col_type col2 = tabular.cellColumn(enidx);
+       row_type row1 = tabular.cellRow(stidx);
+       row_type row2 = tabular.cellRow(enidx);
+       // stidx might be in a later column or row than enidx
+       if (col1 > col2)
+               swap(col1, col2);
+       if (row1 > row2)
+               swap(row1, row2);
        for (col_type col = col1; col <= col2; col++)
                for (row_type row = row1; row <= row2; row++)
                        for (auto const & par : tabular.cellInset(row, col)->paragraphs())