mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-23 10:18:50 +00:00
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 git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15173 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
864515f3a3
commit
70d57a2300
@ -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: {
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user