]> git.lyx.org Git - lyx.git/blobdiff - src/tabular.C
don't draw invisible things...
[lyx.git] / src / tabular.C
index e72d5ae0b626bfd1088f39da95d03f0eaa7615a6..abb382168577d9165bb522675e81536b90d0cfea 100644 (file)
@@ -35,6 +35,7 @@
 #include "frontends/Alert.h"
 #include "gettext.h"
 #include "tabular_funcs.h"
+#include "lyxtextclasslist.h"
 
 #include <algorithm>
 #include <cstdlib>
@@ -197,7 +198,7 @@ LyXTabular * LyXTabular::clone(BufferParams const & bp,
 
 /* activates all lines and sets all widths to 0 */ 
 void LyXTabular::Init(BufferParams const & bp,
-                     int rows_arg, int columns_arg, LyXTabular const * lt)
+                      int rows_arg, int columns_arg, LyXTabular const * lt)
 {
        rows_ = rows_arg;
        columns_ = columns_arg;
@@ -644,7 +645,9 @@ bool LyXTabular::SetWidthOfMulticolCell(int cell, int new_width)
        if (old_val != cell_info[row][column2].width_of_cell) {
                // in this case we have to recalculate all multicolumn cells which
                // have this column as one of theirs but not as last one
+               calculate_width_of_column_NMC(i);
                recalculateMulticolumnsOfColumn(i);
+               calculate_width_of_column(i);
        }
        return true;
 }
@@ -955,16 +958,21 @@ bool LyXTabular::calculate_width_of_column(int column)
 
 
 //
-// calculate the with of the column without regarding REAL MultiColumn
-// cells. This means MultiColumn-cells spanning more than 1 column.
+// Calculate the columns regarding ONLY the normal cells and if this
+// column is inside a multicolumn cell then use it only if its the last
+// column of this multicolumn cell as this gives an added with to the
+// column, all the rest should be adapted!
 //
 bool LyXTabular::calculate_width_of_column_NMC(int column)
 {
        int const old_column_width = column_info[column].width_of_column;
        int max = 0;
        for (int i = 0; i < rows_; ++i) {
-               if (!IsMultiColumn(GetCellNumber(i, column), true) &&
-                       (cell_info[i][column].width_of_cell > max)) {
+               int cell = GetCellNumber(i, column);
+               bool ismulti = IsMultiColumn(cell, true);
+               if ((!ismulti || (column == right_column_of_cell(cell))) &&
+                       (cell_info[i][column].width_of_cell > max))
+               {
                        max = cell_info[i][column].width_of_cell;
                }
        }
@@ -1302,7 +1310,7 @@ void LyXTabular::ReadNew(Buffer const * buf, istream & is,
 
 
 void LyXTabular::OldFormatRead(BufferParams const & bp,
-                              LyXLex & lex, string const & fl)
+                               LyXLex & lex, string const & fl)
 {
        int version;
        int i;
@@ -1436,6 +1444,7 @@ void LyXTabular::OldFormatRead(BufferParams const & bp,
        Paragraph * par = new Paragraph;
        Paragraph * return_par = 0;
 
+       par->layout(textclasslist[bp.textclass].defaultLayoutName());
        string tmptok;
        int pos = 0;
        Paragraph::depth_type depth = 0;