]> git.lyx.org Git - lyx.git/commitdiff
Implement copying of rows and columns in tables
authorGeorg Baum <Georg.Baum@post.rwth-aachen.de>
Wed, 27 Sep 2006 16:28:09 +0000 (16:28 +0000)
committerGeorg Baum <Georg.Baum@post.rwth-aachen.de>
Wed, 27 Sep 2006 16:28:09 +0000 (16:28 +0000)
* src/insets/insettabular.C
(InsetTabular::getStatus): enable COPY_ROW and COPY_COLUMN features
(InsetTabular::tabularFeatures): handle COPY_ROW and COPY_COLUMN

* src/tabular.h
(TabularFeature): add COPY_ROW and COPY_COLUMN

* src/tabular.[Ch]
(LyXTabular::copyRow): new method, copy a row
(LyXTabular::copyColumn): new method, copy a column

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

src/insets/insettabular.C
src/tabular.C
src/tabular.h

index 3b36294d40c83b246e3f411fa56b2716f6ab2439..0774f66c3fd38245f1c2ff6437992557ffc5e80d 100644 (file)
@@ -95,6 +95,8 @@ TabularFeature tabularFeature[] =
        { LyXTabular::APPEND_COLUMN, "append-column" },
        { LyXTabular::DELETE_ROW, "delete-row" },
        { LyXTabular::DELETE_COLUMN, "delete-column" },
+       { LyXTabular::COPY_ROW, "copy-row" },
+       { LyXTabular::COPY_COLUMN, "copy-column" },
        { LyXTabular::TOGGLE_LINE_TOP, "toggle-line-top" },
        { LyXTabular::TOGGLE_LINE_BOTTOM, "toggle-line-bottom" },
        { LyXTabular::TOGGLE_LINE_LEFT, "toggle-line-left" },
@@ -826,6 +828,8 @@ bool InsetTabular::getStatus(LCursor & cur, FuncRequest const & cmd,
                case LyXTabular::APPEND_COLUMN:
                case LyXTabular::DELETE_ROW:
                case LyXTabular::DELETE_COLUMN:
+               case LyXTabular::COPY_ROW:
+               case LyXTabular::COPY_COLUMN:
                case LyXTabular::SET_ALL_LINES:
                case LyXTabular::UNSET_ALL_LINES:
                case LyXTabular::SET_TOP_SPACE:
@@ -1461,6 +1465,15 @@ void InsetTabular::tabularFeatures(LCursor & cur,
                cur.selection() = false;
                break;
 
+       case LyXTabular::COPY_ROW:
+               tabular.copyRow(bv.buffer()->params(), row);
+               break;
+
+       case LyXTabular::COPY_COLUMN:
+               tabular.copyColumn(bv.buffer()->params(), column);
+               cur.idx() = tabular.getCellNumber(row, column);
+               break;
+
        case LyXTabular::M_TOGGLE_LINE_TOP:
                flag = false;
        case LyXTabular::TOGGLE_LINE_TOP: {
index 60c20f9d55c6b5973153283f58d26c10a9912bd6..25aea3843b06198128f6c6fa1804d36ab1dd4456 100644 (file)
@@ -516,6 +516,21 @@ void LyXTabular::deleteRow(row_type const row)
 }
 
 
+void LyXTabular::copyRow(BufferParams const & bp, row_type const row)
+{
+       ++rows_;
+
+       row_info.insert(row_info.begin() + row, row_info[row]);
+       cell_info.insert(cell_info.begin() + row, cell_info[row]);
+
+       if (bp.tracking_changes)
+               for (col_type j = 0; j < columns_; ++j)
+                       cell_info[row + 1][j].inset->markNew(true);
+
+       set_row_column_number_info();
+}
+
+
 void LyXTabular::appendColumn(BufferParams const & bp, idx_type const cell)
 {
        ++columns_;
@@ -561,6 +576,22 @@ void LyXTabular::deleteColumn(col_type const column)
 }
 
 
+void LyXTabular::copyColumn(BufferParams const & bp, col_type const column)
+{
+       ++columns_;
+
+       column_info.insert(column_info.begin() + column, column_info[column]);
+
+       for (row_type i = 0; i < rows_; ++i)
+               cell_info[i].insert(cell_info[i].begin() + column, cell_info[i][column]);
+
+       if (bp.tracking_changes)
+               for (row_type i = 0; i < rows_; ++i)
+                       cell_info[i][column + 1].inset->markNew(true);
+       fixCellNums();
+}
+
+
 void LyXTabular::set_row_column_number_info()
 {
        numberofcells = 0;
index 6b2fb6afde9a3be5e239dc8f14314500a46f90ae..e3fe328fe8706c509609320397449cb310d6672c 100644 (file)
@@ -43,6 +43,10 @@ public:
                ///
                DELETE_COLUMN,
                ///
+               COPY_ROW,
+               ///
+               COPY_COLUMN,
+               ///
                TOGGLE_LINE_TOP,
                ///
                TOGGLE_LINE_BOTTOM,
@@ -282,10 +286,14 @@ public:
        ///
        void deleteRow(row_type row);
        ///
+       void copyRow(BufferParams const &, row_type);
+       ///
        void appendColumn(BufferParams const &, idx_type cell);
        ///
        void deleteColumn(col_type column);
        ///
+       void copyColumn(BufferParams const &, col_type);
+       ///
        bool isFirstCellInRow(idx_type cell) const;
        ///
        idx_type getFirstCellInRow(row_type row) const;