Copying table rows and columns is possible in mathed, but not in text
tables. This patch implements that and goes in trunk now.
Georg
Log:
Implement copying of rows and columns in tables
* 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
Index: src/insets/insettabular.C
===================================================================
--- src/insets/insettabular.C (Revision 15165)
+++ src/insets/insettabular.C (Arbeitskopie)
@@ -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 & c
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(LCurs
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: src/tabular.C
===================================================================
--- src/tabular.C (Revision 15165)
+++ src/tabular.C (Arbeitskopie)
@@ -516,6 +516,21 @@ void LyXTabular::deleteRow(row_type cons
}
+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 c
}
+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: src/tabular.h
===================================================================
--- src/tabular.h (Revision 15165)
+++ src/tabular.h (Arbeitskopie)
@@ -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;