@Override
public void insert(int shift, int copyOrigin) {
synchronized(_sheet) {
if (_refs != null && !_refs.isEmpty()) {
final Ref ref = _refs.iterator().next();
final RefSheet refSheet = ref.getOwnerSheet();
final RefBook refBook = refSheet.getOwnerBook();
final Worksheet sheet = BookHelper.getSheet(_sheet, refSheet);
if (!((SheetCtrl)sheet).isEvalAll()) {
((SheetCtrl)sheet).evalAll();
}
switch(shift) {
default:
case SHIFT_DEFAULT:
if (ref.isWholeRow()) {
final ChangeInfo info = BookHelper.insertRows(sheet, ref.getTopRow(), ref.getRowCount(), copyOrigin);
notifyMergeChange(refBook, info, ref, SSDataEvent.ON_RANGE_INSERT, SSDataEvent.MOVE_V);
} else if (ref.isWholeColumn()) {
final ChangeInfo info = BookHelper.insertColumns(sheet, ref.getLeftCol(), ref.getColumnCount(), copyOrigin);
notifyMergeChange(refBook, info, ref, SSDataEvent.ON_RANGE_INSERT, SSDataEvent.MOVE_H);
}
break;
case SHIFT_RIGHT:
if (ref.isWholeRow() || ref.isWholeColumn()) {
insert(SHIFT_DEFAULT, copyOrigin);
} else {
final ChangeInfo info = BookHelper.insertRange(sheet, ref.getTopRow(), ref.getLeftCol(), ref.getBottomRow(), ref.getRightCol(), true, copyOrigin);
notifyMergeChange(refBook, info, ref, SSDataEvent.ON_RANGE_INSERT, SSDataEvent.MOVE_H);
}
break;
case SHIFT_DOWN:
if (ref.isWholeRow() || ref.isWholeColumn()) {
insert(SHIFT_DEFAULT, copyOrigin);
} else {
final ChangeInfo info = BookHelper.insertRange(sheet, ref.getTopRow(), ref.getLeftCol(), ref.getBottomRow(), ref.getRightCol(), false, copyOrigin);
notifyMergeChange(refBook, info, ref, SSDataEvent.ON_RANGE_INSERT, SSDataEvent.MOVE_V);
}
break;
}
}