Example #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;
 }
Example #2
0
        public static void UndoRowsInfo(Worksheet sheet, CopyMoveRowsInfo rowsInfo, int baseRow)
        {
            int rowCount = rowsInfo.RowCount;

            if (rowsInfo.IsHeightSaved())
            {
                for (int i = 0; i < rowCount; i++)
                {
                    sheet.SetRowHeight(baseRow + i, SheetArea.Cells, rowsInfo.GetHeight(i));
                }
            }
            if (rowsInfo.IsVisibleSaved())
            {
                for (int j = 0; j < rowCount; j++)
                {
                    sheet.SetRowVisible(baseRow + j, SheetArea.Cells, rowsInfo.GetVisible(j));
                }
            }
            if (rowsInfo.IsResizableSaved())
            {
                for (int k = 0; k < rowCount; k++)
                {
                    sheet.SetRowResizable(baseRow + k, SheetArea.Cells, rowsInfo.GetResizable(k));
                }
            }
            if (rowsInfo.IsTagSaved())
            {
                for (int m = 0; m < rowCount; m++)
                {
                    sheet.SetTag(baseRow + m, -1, SheetArea.Cells, rowsInfo.GetTag(m));
                }
            }
            if (rowsInfo.IsViewportRowStyleSaved())
            {
                for (int n = 0; n < rowCount; n++)
                {
                    SetStyleObject(sheet, baseRow + n, -1, SheetArea.Cells, rowsInfo.GetViewportRowStyle(n));
                }
            }
            if (rowsInfo.IsHeaderRowStyleSaved())
            {
                for (int num7 = 0; num7 < rowCount; num7++)
                {
                    SetStyleObject(sheet, baseRow + num7, -1, SheetArea.CornerHeader | SheetArea.RowHeader, rowsInfo.GetHeaderRowStyle(num7));
                }
            }
            if (rowsInfo.IsRangeGroupSaved())
            {
                RangeGroup rowRangeGroup = sheet.RowRangeGroup;
                if (rowRangeGroup != null)
                {
                    for (int num9 = 0; num9 < rowCount; num9++)
                    {
                        int  num8;
                        bool flag;
                        rowsInfo.GetRangeGroup(num9, out num8, out flag);
                        rowRangeGroup.Data.SetLevel(baseRow + num9, num8);
                        rowRangeGroup.Data.SetCollapsed(baseRow + num9, flag);
                    }
                }
            }
        }
Example #3
0
 public static void SaveRowHeaderInfo(Worksheet sheet, CopyMoveCellsInfo headerCellsInfo, CopyMoveRowsInfo rowsInfo, int baseRow, CopyToOption option)
 {
     if ((option & CopyToOption.All) > ((CopyToOption)0))
     {
         int rowCount    = headerCellsInfo.RowCount;
         int columnCount = headerCellsInfo.ColumnCount;
         for (int i = 0; i < rowCount; i++)
         {
             for (int k = 0; k < columnCount; k++)
             {
                 if ((option & CopyToOption.Value) > ((CopyToOption)0))
                 {
                     headerCellsInfo.SaveValue(i, k, sheet.GetValue(baseRow + i, k, SheetArea.CornerHeader | SheetArea.RowHeader));
                 }
                 if ((option & CopyToOption.Style) > ((CopyToOption)0))
                 {
                     headerCellsInfo.SaveStyle(i, k, GetStyleObject(sheet, baseRow + i, k, SheetArea.CornerHeader | SheetArea.RowHeader));
                 }
                 if ((option & CopyToOption.Tag) > ((CopyToOption)0))
                 {
                     headerCellsInfo.SaveTag(i, k, sheet.GetTag(baseRow + i, k, SheetArea.CornerHeader | SheetArea.RowHeader));
                 }
             }
         }
         if ((option & CopyToOption.Span) > ((CopyToOption)0))
         {
             IEnumerator enumerator = sheet.RowHeaderSpanModel.GetEnumerator(baseRow, 0, rowCount, columnCount);
             while (enumerator.MoveNext())
             {
                 headerCellsInfo.SaveSpan((CellRange)enumerator.Current);
             }
         }
         rowCount = rowsInfo.RowCount;
         for (int j = 0; j < rowCount; j++)
         {
             rowsInfo.SaveHeight(j, sheet.GetRowHeight(baseRow + j));
             rowsInfo.SaveVisible(j, sheet.GetRowVisible(baseRow + j));
             rowsInfo.SaveResizable(j, sheet.GetRowResizable(baseRow + j));
             rowsInfo.SaveTag(j, sheet.GetTag(baseRow + j, -1));
         }
         if ((option & CopyToOption.Style) > ((CopyToOption)0))
         {
             for (int m = 0; m < rowCount; m++)
             {
                 rowsInfo.SaveViewportRowStyle(m, GetStyleObject(sheet, baseRow + m, -1, SheetArea.Cells));
                 rowsInfo.SaveHeaderRowStyle(m, GetStyleObject(sheet, baseRow + m, -1, SheetArea.CornerHeader | SheetArea.RowHeader));
             }
         }
         if ((option & CopyToOption.RangeGroup) > ((CopyToOption)0))
         {
             RangeGroup rowRangeGroup = sheet.RowRangeGroup;
             if ((rowRangeGroup != null) && !rowRangeGroup.IsEmpty())
             {
                 for (int n = 0; n < rowCount; n++)
                 {
                     rowsInfo.SaveRangeGroup(n, rowRangeGroup.Data.GetLevel(baseRow + n), rowRangeGroup.Data.GetCollapsed(baseRow + n));
                 }
             }
         }
     }
 }
Example #4
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;
        }