+
+
+bool InsetTabular::copySelection()
+{
+ if (!hasSelection())
+ return false;
+ delete paste_tabular;
+
+ int sel_col_start, sel_col_end;
+ int sel_row_start, sel_row_end;
+
+ sel_col_start = tabular->column_of_cell(sel_cell_start);
+ sel_col_end = tabular->column_of_cell(sel_cell_end);
+ if (sel_col_start > sel_col_end) {
+ sel_col_start = sel_col_end;
+ sel_col_end = tabular->right_column_of_cell(sel_cell_start);
+ } else {
+ sel_col_end = tabular->right_column_of_cell(sel_cell_end);
+ }
+ int columns = sel_col_end - sel_col_start + 1;
+
+ sel_row_start = tabular->row_of_cell(sel_cell_start);
+ sel_row_end = tabular->row_of_cell(sel_cell_end);
+ if (sel_row_start > sel_row_end) {
+ int tmp;
+ tmp = sel_row_start;
+ sel_row_start = sel_row_end;
+ sel_row_end = tmp;
+ }
+ int rows = sel_row_end - sel_row_start + 1;
+
+ paste_tabular = new LyXTabular(this, rows, columns);
+
+ if (sel_cell_start > sel_cell_end) {
+ int tmp = sel_cell_start;
+ sel_cell_start = sel_cell_end;
+ sel_cell_end = tmp;
+ }
+ for(int i=sel_cell_start, j=0; i <= sel_cell_end; ++i, ++j) {
+ while(paste_tabular->row_of_cell(j) <
+ (tabular->row_of_cell(i)-sel_row_start)) {
+ ++j;
+ }
+ while(paste_tabular->row_of_cell(j) >
+ (tabular->row_of_cell(i)-sel_row_start)) {
+ ++i;
+ }
+ *(paste_tabular->GetCellInset(j)) = *(tabular->GetCellInset(i));
+ }
+ return true;
+}
+
+
+bool InsetTabular::pasteSelection(BufferView * bv)
+{
+ if (!paste_tabular)
+ return false;
+ for(int j=0, i=actcell; j<paste_tabular->GetNumberOfCells(); ++j,++i) {
+ while (paste_tabular->row_of_cell(j) > tabular->row_of_cell(i)-actrow)
+ ++i;
+ if (tabular->GetNumberOfCells() <= i)
+ break;
+ while (paste_tabular->row_of_cell(j) < tabular->row_of_cell(i)-actrow)
+ ++j;
+ if (paste_tabular->GetNumberOfCells() <= j)
+ break;
+ *(tabular->GetCellInset(i)) = *(paste_tabular->GetCellInset(j));
+ tabular->GetCellInset(i)->setOwner(this);
+ tabular->GetCellInset(i)->deleteLyXText(bv);
+ }
+ return true;
+}
+
+
+bool InsetTabular::cutSelection()
+{
+ if (!hasSelection())
+ return false;
+ for(int i=sel_cell_start; i < sel_cell_end; ++i) {
+ tabular->GetCellInset(i)->clear();
+ }
+ return true;
+}
+