]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetTabular.cpp
do not use cells without decimals when calculating column widths and cell text offsets
[lyx.git] / src / insets / InsetTabular.cpp
index 0ae20f124631c7de986cb515b70fc346e794ef55..fe9b95b962bd64eb98a18a4542a1249bdc977a39 100644 (file)
@@ -961,12 +961,14 @@ bool Tabular::updateColumnWidths()
                int new_width = 0;
                for(row_type r = 0; r < nrows(); ++r) {
                        idx_type const i = cellIndex(r, c);
-                       if (columnSpan(i) == 1)
-                               if (getAlignment(i) == LYX_ALIGN_DECIMAL)
+                       if (columnSpan(i) == 1) {
+                               if (getAlignment(i) == LYX_ALIGN_DECIMAL
+                                       && cell_info[r][c].decimal_width!=0)
                                        new_width = max(new_width, cellInfo(i).width 
                                                + max_dwidth[c] - cellInfo(i).decimal_width);
                                else
                                        new_width = max(new_width, cellInfo(i).width);
+                       }
                }
 
                if (column_info[c].width != new_width) {
@@ -1270,7 +1272,8 @@ int Tabular::textHOffset(idx_type cell) const
                int max_dhoffset = 0;
                for(row_type r = 0; r < row_info.size() ; ++r) {
                        idx_type const i = cellIndex(r, c);
-                       if (getAlignment(i) == LYX_ALIGN_DECIMAL)
+                       if (getAlignment(i) == LYX_ALIGN_DECIMAL
+                               && cellInfo(i).decimal_width != 0)
                                max_dhoffset = max(max_dhoffset, cellInfo(i).decimal_hoffset);
                }
                x += max_dhoffset - cellInfo(cell).decimal_hoffset;
@@ -2137,7 +2140,7 @@ int Tabular::TeXCellPreamble(odocstream & os, idx_type cell,
 
        // we center in multicol when no decimal point
        ismulticol |= ((column_info[c].alignment == LYX_ALIGN_DECIMAL)
-               && (cellInfo(cell).decimal_width == 0) || isMultiRow(cell));
+               && (cellInfo(cell).decimal_width == 0));
 
        // up counter by 1 for each decimally aligned col since they use 2 latex cols
        int latexcolspan = columnSpan(cell);
@@ -2466,7 +2469,7 @@ int Tabular::TeXRow(odocstream & os, row_type row,
                                    : OutputParams::ALIGNED;
 
                if (getAlignment(cell) == LYX_ALIGN_DECIMAL
-                       && cellInfo(cell).decimal_width != 0 && !isMultiRow(cell)) {
+                       && cellInfo(cell).decimal_width != 0) {
                        // copy cell and split in 2
                        InsetTableCell head = InsetTableCell(*cellInset(cell).get());
                        head.getText(0)->setMacrocontextPosition(
@@ -3362,9 +3365,7 @@ void InsetTabular::metrics(MetricsInfo & mi, Dimension & dim) const
                        // determine horiz offset because of decimal align (if necessary)
                        int decimal_hoffset = 0;
                        int decimal_width = 0;
-                       if ((tabular.column_info[c].alignment == LYX_ALIGN_DECIMAL)
-                               && !tabular.isMultiColumn(cell)
-                               && !tabular.isMultiRow(cell)) {
+                       if (tabular.getAlignment(cell) == LYX_ALIGN_DECIMAL) {
                                // make a copy which we will split in 2
                                InsetTableCell head = InsetTableCell(*tabular.cellInset(cell).get());
                                head.getText(0)->setMacrocontextPosition(