]> git.lyx.org Git - features.git/commitdiff
- make line-lovers happy (fix bug 4677)
authorEdwin Leuven <e.leuven@gmail.com>
Sat, 19 Apr 2008 08:53:24 +0000 (08:53 +0000)
committerEdwin Leuven <e.leuven@gmail.com>
Sat, 19 Apr 2008 08:53:24 +0000 (08:53 +0000)
- don't break multicol cells when appending a column
- disable multicol when selection spans >1 row

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@24339 a592a061-630c-0410-9148-cb99ea01b6c8

src/insets/InsetTabular.cpp

index ff55f12708ea6d99beb67e9d5ba9801a5a5112d4..dcf05281495e986455afcfcec7156cb91a2e5a09 100644 (file)
@@ -632,14 +632,13 @@ void Tabular::appendRow(idx_type const cell)
                // inherit line settings
                idx_type const i = cellIndex(row + 1, c);
                idx_type const j = cellIndex(row, c);
-               setLeftLine(i, isPartOfMultiColumn(row, c) ? false : leftLine(j));
-               if (cell_info[row][c].multicolumn == CELL_NORMAL || c == ncols - 1
-                       || (c + 1 < ncols 
-                       && cell_info[row][c].multicolumn != CELL_NORMAL
-                       && cell_info[row][c + 1].multicolumn == CELL_NORMAL))
-                       setRightLine(i, rightLine(j));
-               else
-                       setRightLine(i, false);
+               setLeftLine(i, leftLine(j));
+               setRightLine(i, rightLine(j));
+               setTopLine(i, topLine(j));
+               if (topLine(j) && bottomLine(j)) {
+                       setBottomLine(i, true);
+                       setBottomLine(j, false);
+               }
                // mark track changes
                if (bp.trackChanges)
                        cellInfo(i).inset->setChange(Change(Change::INSERTED));
@@ -674,31 +673,34 @@ void Tabular::copyRow(row_type const row)
 
 void Tabular::appendColumn(idx_type const cell)
 {
-       col_type const column = cellColumn(cell);
-       column_vector::iterator cit = column_info.begin() + column + 1;
+       col_type const c = cellColumn(cell);
+       column_vector::iterator cit = column_info.begin() + c + 1;
        column_info.insert(cit, ColumnData());
        row_type const nrows = rowCount();
-       col_type const ncols = columnCount();
+       //col_type const ncols = columnCount();
        // set the column values of the column before
-       column_info[column + 1] = column_info[column];
+       column_info[c + 1] = column_info[c];
 
        for (row_type r = 0; r < nrows; ++r) {
-               cell_info[r].insert(cell_info[r].begin() + column + 1, 
+               cell_info[r].insert(cell_info[r].begin() + c + 1, 
                        CellData(buffer(), *this));
-               col_type c = column + 2;
-               while (c < ncols 
-                       && cell_info[r][c].multicolumn == CELL_PART_OF_MULTICOLUMN) {
-                       cell_info[r][c].multicolumn = CELL_NORMAL;
-                       ++c;
-               }
+               if (cell_info[r][c].multicolumn == CELL_BEGIN_OF_MULTICOLUMN)
+                       cell_info[r][c + 1].multicolumn = CELL_PART_OF_MULTICOLUMN;
+               else
+                       cell_info[r][c + 1].multicolumn = cell_info[r][c].multicolumn;
        }
        updateIndexes();
        for (row_type r = 0; r < nrows; ++r) {
                // inherit line settings
-               idx_type const i = cellIndex(r, column + 1);
-               idx_type const j = cellIndex(r, column);
+               idx_type const i = cellIndex(r, c + 1);
+               idx_type const j = cellIndex(r, c);
                setBottomLine(i, bottomLine(j));
                setTopLine(i, topLine(j));
+               setLeftLine(i, leftLine(j));
+               if (rightLine(j) && rightLine(j)) {
+                       setRightLine(i, true);
+                       setRightLine(j, false);
+               }
                //
                cellInfo(i).inset->clear();
                if (buffer().params().trackChanges)
@@ -3565,6 +3567,7 @@ bool InsetTabular::getStatus(Cursor & cur, FuncRequest const & cmd,
                        return true;
 
                case Tabular::MULTICOLUMN:
+                       status.enabled(sel_row_start == sel_row_end);
                        status.setOnOff(tabular.isMultiColumn(cur.idx()));
                        break;
 
@@ -4294,13 +4297,6 @@ void InsetTabular::tabularFeatures(Cursor & cur,
                break;
 
        case Tabular::MULTICOLUMN: {
-               if (sel_row_start != sel_row_end) {
-                       // FIXME: Need I say it ? This is horrible.
-                       // FIXME UNICODE
-                       Alert::error(_("Error setting multicolumn"),
-                                    _("You cannot set multicolumn vertically."));
-                       return;
-               }
                if (!cur.selection()) {
                        // just multicol for one single cell
                        // check whether we are completely in a multicol