Esempio n. 1
0
 void InitSaveState()
 {
     _savedFromColumnHeaderCells = null;
     _savedFromColumns           = null;
     _savedFromViewportCells     = null;
     _savedFromRowHeaderCells    = null;
     _savedFromRows            = null;
     _savedFromFloatingObjects = null;
     _savedToColumnHeaderCells = null;
     _savedToColumns           = null;
     _savedToViewportCells     = null;
     _savedToRowHeaderCells    = null;
     _savedToRows                    = null;
     _savedToFloatingObjects         = null;
     _savedAcitveRowViewportIndex    = -2;
     _savedAcitveColumnViewportIndex = -2;
     _savedActiveRow                 = -1;
     _savedActiveColumn              = -1;
 }
Esempio n. 2
0
 public static void UndoFloatingObjectsInfo(Worksheet sheet, CopyMoveFloatingObjectsInfo floatingObjectsInfo)
 {
     sheet.Workbook.SuspendEvent();
     try
     {
         foreach (FloatingObject obj2 in GetFloatingObjectsInRange(floatingObjectsInfo.Range, sheet))
         {
             if (obj2 is SpreadChart)
             {
                 sheet.Charts.Remove(obj2 as SpreadChart);
             }
             else if (obj2 is Picture)
             {
                 sheet.Pictures.Remove(obj2 as Picture);
             }
             else
             {
                 sheet.FloatingObjects.Remove(obj2);
             }
         }
         foreach (FloatingObject obj3 in floatingObjectsInfo.SavedFloatingObjects)
         {
             if (obj3 is SpreadChart)
             {
                 sheet.Charts.Add(obj3 as SpreadChart);
             }
             else if (obj3 is Picture)
             {
                 sheet.Pictures.Add(obj3 as Picture);
             }
             else
             {
                 sheet.FloatingObjects.Add(obj3);
             }
         }
     }
     finally
     {
         sheet.Workbook.ResumeEvent();
     }
 }
Esempio n. 3
0
        /// <summary>
        /// Saves the state for undoing the action.
        /// </summary>
        public void SaveState()
        {
            InitSaveState();
            int baseRow     = (_dragDropExtent.FromRow < 0) ? 0 : _dragDropExtent.FromRow;
            int baseColumn  = (_dragDropExtent.FromColumn < 0) ? 0 : _dragDropExtent.FromColumn;
            int row         = (_dragDropExtent.ToRow < 0) ? 0 : _dragDropExtent.ToRow;
            int num4        = (_dragDropExtent.ToColumn < 0) ? 0 : _dragDropExtent.ToColumn;
            int rowCount    = (_dragDropExtent.FromRow < 0) ? _sheet.RowCount : _dragDropExtent.RowCount;
            int columnCount = (_dragDropExtent.FromColumn < 0) ? _sheet.ColumnCount : _dragDropExtent.ColumnCount;

            if (_insert)
            {
                if (((_dragDropExtent.FromColumn < 0) || (_dragDropExtent.FromRow < 0)) && (((_dragDropExtent.FromColumn < 0) && (_dragDropExtent.FromRow >= 0)) && (!_copy && Excel.HasTable(_sheet, row, -1, 1, -1, true))))
                {
                    CopyMoveCellsInfo headerCellsInfo = new CopyMoveCellsInfo(rowCount, _sheet.RowHeader.ColumnCount);
                    CopyMoveRowsInfo  rowsInfo        = new CopyMoveRowsInfo(rowCount);
                    CopyMoveHelper.SaveRowHeaderInfo(_sheet, headerCellsInfo, rowsInfo, baseRow, _option);
                    _savedFromRowHeaderCells = headerCellsInfo;
                    _savedFromRows           = rowsInfo;
                    CopyMoveCellsInfo cellsInfo = new CopyMoveCellsInfo(rowCount, columnCount);
                    CopyMoveHelper.SaveViewportInfo(_sheet, cellsInfo, baseRow, baseColumn, _option);
                    _savedFromViewportCells = cellsInfo;
                }
            }
            else
            {
                if (_dragDropExtent.FromRow < 0)
                {
                    CopyMoveCellsInfo   info4       = new CopyMoveCellsInfo(_sheet.ColumnHeader.RowCount, columnCount);
                    CopyMoveColumnsInfo columnsInfo = new CopyMoveColumnsInfo(columnCount);
                    CopyMoveHelper.SaveColumnHeaderInfo(_sheet, info4, columnsInfo, num4, _option);
                    _savedToColumnHeaderCells = info4;
                    _savedToColumns           = columnsInfo;
                    if (!_copy)
                    {
                        CopyMoveCellsInfo   info6 = new CopyMoveCellsInfo(_sheet.ColumnHeader.RowCount, columnCount);
                        CopyMoveColumnsInfo info7 = new CopyMoveColumnsInfo(columnCount);
                        CopyMoveHelper.SaveColumnHeaderInfo(_sheet, info6, info7, baseColumn, _option);
                        _savedFromColumnHeaderCells = info6;
                        _savedFromColumns           = info7;
                    }
                }
                if (_dragDropExtent.FromColumn < 0)
                {
                    CopyMoveCellsInfo info8 = new CopyMoveCellsInfo(rowCount, _sheet.RowHeader.ColumnCount);
                    CopyMoveRowsInfo  info9 = new CopyMoveRowsInfo(rowCount);
                    CopyMoveHelper.SaveRowHeaderInfo(_sheet, info8, info9, row, _option);
                    _savedToRowHeaderCells = info8;
                    _savedToRows           = info9;
                    if (!_copy)
                    {
                        CopyMoveCellsInfo info10 = new CopyMoveCellsInfo(rowCount, _sheet.RowHeader.ColumnCount);
                        CopyMoveRowsInfo  info11 = new CopyMoveRowsInfo(rowCount);
                        CopyMoveHelper.SaveRowHeaderInfo(_sheet, info10, info11, baseRow, _option);
                        _savedFromRowHeaderCells = info10;
                        _savedFromRows           = info11;
                    }
                }
                CopyMoveCellsInfo info12 = new CopyMoveCellsInfo(rowCount, columnCount);
                CopyMoveHelper.SaveViewportInfo(_sheet, info12, row, num4, _option);
                _savedToViewportCells = info12;
                if (!_copy)
                {
                    CopyMoveCellsInfo info13 = new CopyMoveCellsInfo(rowCount, columnCount);
                    CopyMoveHelper.SaveViewportInfo(_sheet, info13, baseRow, baseColumn, _option);
                    _savedFromViewportCells = info13;
                    if ((_option & CopyToOption.FloatingObject) > ((CopyToOption)0))
                    {
                        CellRange        range = new CellRange(_dragDropExtent.FromRow, _dragDropExtent.FromColumn, _dragDropExtent.RowCount, _dragDropExtent.ColumnCount);
                        FloatingObject[] floatingObjectsInRange = CopyMoveHelper.GetFloatingObjectsInRange(CopyMoveHelper.AdjustRange(range, _sheet.RowCount, _sheet.ColumnCount), _sheet);
                        _savedFromFloatingObjects = new CopyMoveFloatingObjectsInfo();
                        _savedFromFloatingObjects.SaveFloatingObjects(range, floatingObjectsInRange);
                    }
                }
                if ((_option & CopyToOption.FloatingObject) > ((CopyToOption)0))
                {
                    CellRange        range3          = new CellRange(_dragDropExtent.ToRow, _dragDropExtent.ToColumn, _dragDropExtent.RowCount, _dragDropExtent.ColumnCount);
                    FloatingObject[] floatingObjects = CopyMoveHelper.GetFloatingObjectsInRange(CopyMoveHelper.AdjustRange(range3, _sheet.RowCount, _sheet.ColumnCount), _sheet);
                    _savedToFloatingObjects = new CopyMoveFloatingObjectsInfo();
                    _savedToFloatingObjects.SaveFloatingObjects(range3, floatingObjects);
                }
            }
            _savedAcitveRowViewportIndex    = _sheet.GetActiveRowViewportIndex();
            _savedAcitveColumnViewportIndex = _sheet.GetActiveColumnViewportIndex();
            _savedActiveRow    = _sheet.ActiveRowIndex;
            _savedActiveColumn = _sheet.ActiveColumnIndex;
        }