Пример #1
0
        internal void InsertSheets(int CopyFrom, int BeforeSheet, int SheetCount, TSheetInfo SheetInfo, bool CopyFilterDatabase)
        {
            int aCount    = SheetInfo.SourceNames.Count;
            int DestCount = Count; //Get this before adding the new sheets.

            for (int i = DestCount - 1; i >= 0; i--)
            {
                this[i].ArrangeInsertSheets(BeforeSheet, SheetCount);
            }


            for (int i = 0; i < aCount; i++)
            {
                if (
                    CopyFrom >= 0 &&
                    NameMustBeCopiedToSheet(CopyFrom, SheetInfo, i) &&
                    (CopyFilterDatabase || SheetInfo.SourceNames[i].Name != TXlsNamedRange.GetInternalName(InternalNameRange.Filter_DataBase))    //filterdatabase will be copied when copying autofilters.
                    )
                {
                    for (int k = 0; k < SheetCount; k++)
                    {
                        SheetInfo.InsSheet = BeforeSheet + k;
                        TNameRecord name = (TNameRecord.Clone(SheetInfo.SourceNames[i], SheetInfo) as TNameRecord).ArrangeCopySheet(SheetInfo); //this could add its own names, so we need to recheck name wasn't added in next line.
                        if (!NameAlreadyExistsInLocal(SheetInfo.DestFormulaSheet, name.Name))
                        {
                            Add(name);
                        }
                        CheckInternalNames(SheetInfo.SourceNames[i].OptionFlags, SheetInfo.SourceGlobals);
                    }
                }
            }
        }
Пример #2
0
        protected override TBaseRecord DoCopyTo(TSheetInfo SheetInfo)
        {
            TRKRecord Result = (TRKRecord)base.DoCopyTo(SheetInfo);

            Result.RK = RK;
            return(Result);
        }
Пример #3
0
        protected override TBaseRecord DoCopyTo(TSheetInfo SheetInfo)
        {
            TNumberRecord Result = (TNumberRecord)base.DoCopyTo(SheetInfo);

            Result.NumValue = NumValue;
            return(Result);
        }
Пример #4
0
        internal void ArrangeInsertCols(TXlsCellRange CellRange, int aColCount, TSheetInfo SheetInfo)
        {
            if (SheetInfo.SourceFormulaSheet != SheetInfo.InsSheet)
            {
                return;
            }
            int ColOffset = CellRange.ColCount * aColCount;

            if (aColCount < 0)           //Deleting columns. ColOffset is < 0.
            {
                DeleteColumns(CellRange.Left, -ColOffset);
            }
            else
            {
                //the check below might throw unwanted exceptions when all columns are formatted (even with fake formatting)
                //and disallow to insert columns on some sheets. (for example all pxl files have the full 255 columns formatted)
                //so we will allow to "lose" formatted columns if there is no data on them.
                //if (LastColumn+ColOffset>FlxConsts.Max_Columns) XlsMessages.ThrowException(XlsErr.ErrTooManyColumns, LastColumn + ColOffset + 1, FlxConsts.Max_Columns+1);

                if (CellRange.Left + ColOffset > FlxConsts.Max_Columns)
                {
                    XlsMessages.ThrowException(XlsErr.ErrTooManyColumns, CellRange.Left + ColOffset + 1, FlxConsts.Max_Columns + 1);
                }

                InsertColumns(CellRange.Left, ColOffset);
            }
        }
Пример #5
0
        internal void MoveRange(TXlsCellRange CellRange, int NewRow, int NewCol, TSheetInfo SheetInfo)
        {
            if ((SheetInfo.InsSheet < 0) || (SheetInfo.SourceFormulaSheet != SheetInfo.InsSheet))
            {
                return;
            }

            int aCount = Count;

            for (int i = aCount - 1; i >= 0; i--)
            {
                THLinkRecord r = this[i];
                if (r.FirstRow >= CellRange.Top && r.LastRow <= CellRange.Bottom &&
                    r.FirstCol >= CellRange.Left && r.LastCol <= CellRange.Right)
                {
                    //Hyperlink data doesn't move when you insert/copy cells or sheets. It is a static text.
                    r.Offset(NewRow - CellRange.Top, NewCol - CellRange.Left);
                }
                else
                {
                    if (r.FirstRow >= NewRow && r.LastRow <= NewRow + CellRange.RowCount - 1 &&
                        r.FirstCol >= NewCol && r.LastCol <= NewCol + CellRange.ColCount - 1)
                    {
                        //Hyperlink data doesn't move when you insert/copy cells or sheets. It is a static text.
                        FList.RemoveAt(i);
                    }
                }
            }
        }
Пример #6
0
        internal void MoveRange(int SheetNo, TXlsCellRange CellRange, int NewRow, int NewCol)
        {
            //Some error handling
            if (
                (CellRange.Top > CellRange.Bottom) || (CellRange.Top < 0) || (NewRow + CellRange.RowCount - 1 > FlxConsts.Max_Rows)
                )
            {
                XlsMessages.ThrowException(XlsErr.ErrBadMoveCall);
            }

            if (
                (CellRange.Left > CellRange.Right) || (CellRange.Left < 0) || (NewCol + CellRange.ColCount - 1 > FlxConsts.Max_Columns)
                )
            {
                XlsMessages.ThrowException(XlsErr.ErrBadMoveCall);
            }


            if ((SheetNo >= Sheets.Count) || (SheetNo < 0))
            {
                XlsMessages.ThrowException(XlsErr.ErrInvalidSheetNo, SheetNo, 0, Sheets.Count - 1);
            }

            TSheetInfo SheetInfo = new TSheetInfo(SheetNo, SheetNo, SheetNo, Globals, Globals, Sheets, Sheets, false);

            FSheets.MoveRange(CellRange, NewRow, NewCol, SheetInfo);
            Globals.MoveRange(CellRange, NewRow, NewCol, SheetInfo);
        }
Пример #7
0
        internal void MoveRange(TXlsCellRange CellRange, int NewRow, int NewCol, TSheetInfo SheetInfo)
        {
            FNames.ArrangeMoveRange(CellRange, NewRow, NewCol, SheetInfo);
#if (FRAMEWORK30 && !COMPACTFRAMEWORK)
            FXlsxPivotCache.ArrangeMoveRange(CellRange, NewRow, NewCol, SheetInfo);
#endif
        }
Пример #8
0
 internal override void ArrangeCopyRange(int RowOfs, int ColOfs, TSheetInfo SheetInfo)
 {
     if ((Shape != null) && (Shape.CopiedTo(SheetInfo.CopiedGen) != null))
     {
         DwgCache.Solver.ContainedRecords.Add(TEscherCallOutRuleRecord.Clone(this, RowOfs, ColOfs, DwgCache, DwgGroupCache, SheetInfo));
     }
 }
Пример #9
0
 internal void ArrangeCopySheet(TSheetInfo SheetInfo)
 {
     for (int i = 0; i < Count; i++)
     {
         FList[i].ClientData.ArrangeCopySheet(SheetInfo);
     }
 }
Пример #10
0
        protected override TBaseRecord DoCopyTo(TSheetInfo SheetInfo)
        {
            TBoolErrRecord Result = (TBoolErrRecord)base.DoCopyTo(SheetInfo);

            Result.ErrFlag = ErrFlag;
            Result.BoolErr = BoolErr;
            return(Result);
        }
Пример #11
0
 private bool NameMustBeCopiedToSheet(int CopyFrom, TSheetInfo SheetInfo, int i)
 {
     return
         (SheetInfo.SourceNames[i].RangeSheet == CopyFrom ||
          (
              (SheetInfo.SourceNames[i].RangeSheet == -1) && (SheetInfo.SourceNames[i].RefersToSheet(SheetInfo.SourceReferences) == SheetInfo.SourceFormulaSheet) &&
              !NameAlreadyExistsInLocal(SheetInfo.DestFormulaSheet, SheetInfo.SourceNames[i].Name)
          ));
 }
Пример #12
0
        protected override TBaseRecord DoCopyTo(TSheetInfo SheetInfo)
        {
            THLinkRecord b = (THLinkRecord)MemberwiseClone();

            if (Hint != null)
            {
                b.Hint = (TScreenTipRecord)TScreenTipRecord.Clone(Hint, SheetInfo);
            }
            return(b);
        }
Пример #13
0
        internal void ArrangeInsertRangeCols(TXlsCellRange CellRange, int aColCount, TSheetInfo SheetInfo)
        {
            TFormulaRecord r = FirstFormula;

            while (r != null)
            {
                r.ArrangeInsertRange(r.FRow, CellRange, 0, aColCount, SheetInfo);
                r = r.Next;
            }
        }
Пример #14
0
        protected override TBaseRecord DoCopyTo(TSheetInfo SheetInfo)
        {
            TLabelSSTRecord Result = (TLabelSSTRecord)base.DoCopyTo(SheetInfo);

            Result.SST       = SST;
            Result.FontList  = FontList;
            Result.pSSTEntry = pSSTEntry;
            pSSTEntry.AddRef();
            return(Result);
        }
Пример #15
0
        internal void ArrangeInsertSheet(TSheetInfo SheetInfo)
        {
            TFormulaRecord r = FirstFormula;

            while (r != null)
            {
                r.ArrangeInsertSheet(SheetInfo);
                r = r.Next;
            }
        }
Пример #16
0
 internal TMoveTokens(TXlsCellRange aCellRange, int aFmlaRow, int aFmlaCol, int aNewRow, int aNewCol, TSheetInfo aSheetInfo, TFormulaBounds aBounds)
 {
     CellRange = aCellRange;
     FmlaRow   = aFmlaRow;
     FmlaCol   = aFmlaCol;
     NewRow    = aNewRow;
     NewCol    = aNewCol;
     SheetInfo = aSheetInfo;
     Bounds    = aBounds;
 }
Пример #17
0
        protected override TBaseRecord DoCopyTo(TSheetInfo SheetInfo)
        {
            TNoteRecord Result = (TNoteRecord)base.DoCopyTo(SheetInfo);

            Result.Dwg         = Dwg;
            Result.OptionFlags = OptionFlags;
            Result.ObjId       = 0; // we will fix this later.
            Result.Author      = Author;
            return(Result);
        }
Пример #18
0
        internal void InsertSheets(int CopyFrom, int InsertBefore, int SheetCount, TWorkbook SourceWorkbook)
        {
            if (SourceWorkbook == null)
            {
                SourceWorkbook = this;
            }
            if (CopyFrom >= SourceWorkbook.Sheets.Count)
            {
                XlsMessages.ThrowException(XlsErr.ErrInvalidSheetNo, CopyFrom, -1, SourceWorkbook.Sheets.Count - 1);
            }
            if (InsertBefore > Sheets.Count)
            {
                XlsMessages.ThrowException(XlsErr.ErrInvalidSheetNo, InsertBefore, 0, Sheets.Count);
            }

            TSheet aSheet      = null;
            int    OptionFlags = 0;

            if (CopyFrom >= 0)
            {
                aSheet      = SourceWorkbook.Sheets[CopyFrom];
                OptionFlags = SourceWorkbook.Globals.SheetOptionFlags(CopyFrom);
            }

            int NewCopyFrom = CopyFrom;

            if (SourceWorkbook == this && CopyFrom >= InsertBefore)
            {
                NewCopyFrom += SheetCount;
            }
            Globals.InsertSheets(CopyFrom, InsertBefore, OptionFlags, XlsMessages.GetString(XlsErr.BaseSheetName), SheetCount, SourceWorkbook.Sheets);

            TSheetInfo SheetInfo = new TSheetInfo(-1, -1, -1, SourceWorkbook.Globals, Globals, aSheet, null, false);

            for (int i = 0; i < SheetCount; i++)
            {
                SheetInfo.InsSheet           = InsertBefore + i;
                SheetInfo.SourceFormulaSheet = NewCopyFrom;
                SheetInfo.DestFormulaSheet   = InsertBefore;
                SheetInfo.DestSheet          = null; //keep it null, since the reference does not exist yet.

                if (aSheet == null)
                {
                    Sheets.Insert(InsertBefore, TWorkSheet.CreateFromData(Globals, Globals.Workbook.XlsBiffVersion, Globals.Workbook.ExcelFileFormat));
                }
                else
                {
                    SheetInfo.DestFormulaSheet = InsertBefore + i;
                    Globals.Names.InsertSheets(NewCopyFrom, InsertBefore + i, 1, SheetInfo, SourceWorkbook == this); //names must be inserted before the sheet is cloned, so formulas can refer to them.
                    Sheets.Insert(InsertBefore + i, TSheet.Clone(aSheet, SheetInfo));
                    SheetInfo.DestSheet = Sheets[InsertBefore + i];
                    Sheets[InsertBefore + i].ArrangeCopySheet(SheetInfo);
                }
            }
        }
Пример #19
0
 internal void CopyFrom(THLinkList aHLinkList, TSheetInfo SheetInfo)
 {
     if (aHLinkList.FList == FList)
     {
         XlsMessages.ThrowException(XlsErr.ErrInternal);                            //Should be different objects
     }
     for (int i = 0; i < aHLinkList.Count; i++)
     {
         Add((THLinkRecord)THLinkRecord.Clone(aHLinkList[i], SheetInfo));
     }
 }
Пример #20
0
 internal static TBaseClientData Clone(TBaseClientData Self, TSheetInfo SheetInfo)
 {
     if (Self != null)
     {
         return(Self.DoCopyTo(SheetInfo));
     }
     else
     {
         return(null);
     }
 }
Пример #21
0
 internal void MoveRange(TXlsCellRange CellRange, int NewRow, int NewCol, TSheetInfo SheetInfo)
 {
     FList[SheetInfo.InsSheet].MoveRange(CellRange, NewRow, NewCol, SheetInfo);
     for (int i = 0; i < Count; i++)
     {
         if (i != SheetInfo.InsSheet)
         {
             SheetInfo.SourceFormulaSheet = i;
             SheetInfo.DestFormulaSheet   = i;
             FList[i].ArrangeMoveRange(CellRange, NewRow, NewCol, SheetInfo);
         }
     }
 }
Пример #22
0
        internal static TSheetProtection Clone(TSheetProtection Source, TSheetInfo SheetInfo)
        {
            TSheetProtection Result = new TSheetProtection();

            if (Source != null)
            {
                Result.Protect      = (TProtectRecord)TBaseRecord.Clone(Source.Protect, SheetInfo);
                Result.ScenProtect  = (TScenProtectRecord)TBaseRecord.Clone(Source.ScenProtect, SheetInfo);
                Result.ObjProtect   = (TObjProtectRecord)TBaseRecord.Clone(Source.ObjProtect, SheetInfo);
                Result.Password     = (TPasswordRecord)TBaseRecord.Clone(Source.Password, SheetInfo);
                Result.SheetProtect = (TSheetProtectRecord)TBaseRecord.Clone(Source.SheetProtect, SheetInfo);
            }
            return(Result);
        }
Пример #23
0
        bool SemiAbsoluteMode; //When copying in semi-absolute, absolute formulas inside the range will move.
        #endregion

        #region Constructor
        internal TInsertTokens(TXlsCellRange aCellRange, int aRowCount, int aColCount, int aCopyRowOffset, int aCopyColOffset,
                               TSheetInfo aSheetInfo, bool aInsertingSheet, bool aAllowedAbsolute, int aFmlaRow, int aFmlaCol, TFormulaBounds aBounds)
        {
            CellRange        = aCellRange;
            FmlaRow          = aFmlaRow;
            FmlaCol          = aFmlaCol;
            RowCount         = aRowCount;
            ColCount         = aColCount;
            CopyRowOffset    = aCopyRowOffset;
            CopyColOffset    = aCopyColOffset;
            SheetInfo        = aSheetInfo;
            InsertingSheet   = aInsertingSheet;
            AllowedAbsolute  = aAllowedAbsolute;
            SemiAbsoluteMode = aSheetInfo.SemiAbsoluteMode;
            Bounds           = aBounds;
        }
Пример #24
0
 internal virtual void CopyFrom(TBaseRecordList <T> aBaseRecordList, TSheetInfo SheetInfo)
 {
     if (aBaseRecordList.FList == FList)
     {
         XlsMessages.ThrowException(XlsErr.ErrInternal);                                 //If they are, the for loop will grow ad infinitum.
     }
     if (aBaseRecordList != null)
     {
         FList.Capacity += aBaseRecordList.Count;
         for (int i = 0; i < aBaseRecordList.Count; i++)
         {
             T br = CloneRecord(aBaseRecordList[i], SheetInfo);
             FList.Add(br);
             OnAdd(br, i);
         }
     }
 }
Пример #25
0
        internal void InsertAndCopyRange(int SheetNo, TXlsCellRange SourceRange,
                                         int DestRow, int DestCol, int aRowCount, int aColCount, TRangeCopyMode CopyMode, TFlxInsertMode InsertMode, bool aSemiAbsoluteMode, TExcelObjectList ObjectsInRange)
        {
            //Some error handling
            if (
                (SourceRange.Top > SourceRange.Bottom) || (SourceRange.Top < 0) || (DestRow > FlxConsts.Max_Rows) ||
                ((CopyMode != TRangeCopyMode.None) && (aRowCount > 0) && (SourceRange.Top < DestRow) && (DestRow <= SourceRange.Bottom)) ||
                (DestRow + (SourceRange.Bottom - SourceRange.Top + 1) * aRowCount - 1 > FlxConsts.Max_Rows) ||
                (DestRow < 0)
                )
            {
                XlsMessages.ThrowException(XlsErr.ErrBadCopyRows, FlxConsts.Max_Rows + 1);
            }

            if (
                (SourceRange.Left > SourceRange.Right) || (SourceRange.Left < 0) || (DestCol > FlxConsts.Max_Columns) ||
                ((CopyMode != TRangeCopyMode.None) && (aColCount > 0) && (SourceRange.Left < DestCol) && (DestCol <= SourceRange.Right)) ||
                (DestCol + (SourceRange.Right - SourceRange.Left + 1) * aColCount - 1 > FlxConsts.Max_Columns) ||
                (DestCol < 0)
                )
            {
                XlsMessages.ThrowException(XlsErr.ErrBadCopyCols, FlxConsts.Max_Columns + 1);
            }

            if ((SheetNo < 0) || (SheetNo >= Sheets.Count))
            {
                XlsMessages.ThrowException(XlsErr.ErrInvalidSheetNo, SheetNo, 0, Sheets.Count - 1);
            }

            TSheetInfo SheetInfo = new TSheetInfo(SheetNo, SheetNo, SheetNo, Globals, Globals, Sheets, Sheets, aSemiAbsoluteMode);

            SheetInfo.ObjectsInRange = ObjectsInRange;

            FSheets.InsertAndCopyRange(
                SourceRange, DestRow, DestCol, aRowCount, aColCount,
                CopyMode, InsertMode, SheetInfo);
            Globals.InsertAndCopyRange(
                SourceRange, InsertMode, DestRow, DestCol, aRowCount, aColCount,
                SheetInfo);

            //FSheets[SheetNo].FixAutoFilter(SheetNo);  Not needed now, we are going to replace it.
            if (aColCount > 0)
            {
                FSheets[SheetNo].AddNewAutoFilters(SheetNo, SourceRange.Top, SourceRange.Bottom, DestCol, DestCol);
            }
        }
Пример #26
0
 private void FixDwg(int RowOffset, int ColOffset, TSheetInfo SheetInfo)
 {
     if (Dwg != null)
     {
         if (Dwg.Patriarch() == null)
         {
             XlsMessages.ThrowException(XlsErr.ErrLoadingEscher);
         }
         SheetInfo.IncCopiedGen();
         //We only copy DWG if we are copying rows/columns, when we copy sheets we dont have to.
         //now we have to copy dwg even in different sheets.
         Dwg = (TEscherClientDataRecord)Dwg.CopyDwg(RowOffset, ColOffset, SheetInfo);
         unchecked
         {
             ObjId = (UInt16)Dwg.ObjId;   //object id
         }
     }
 }
Пример #27
0
        internal void ArrangeMoveCols(TXlsCellRange CellRange, int NewCol, TSheetInfo SheetInfo)
        {
            if (SheetInfo.SourceFormulaSheet != SheetInfo.InsSheet)
            {
                return;
            }
            if (NewCol == CellRange.Left)
            {
                return;
            }

            for (int z = CellRange.Left; z <= CellRange.Right; z++)
            {
                int c = CellRange.Left > NewCol? z: CellRange.Left - z + CellRange.Right;                 //order here is important, to not overwrite existing cells.

                this[c + NewCol - CellRange.Left] = this[c];
                this[c] = null;
            }
        }
Пример #28
0
        internal void DeleteRange(int SheetNo, TXlsCellRange CellRange, TFlxInsertMode InsertMode)
        {
            if ((SheetNo >= Sheets.Count) || (SheetNo < 0))
            {
                XlsMessages.ThrowException(XlsErr.ErrInvalidSheetNo, SheetNo, 0, Sheets.Count - 1);
            }

            TSheetInfo SheetInfo = new TSheetInfo(SheetNo, SheetNo, SheetNo, Globals, Globals, Sheets, Sheets, false);

            if (InsertMode == TFlxInsertMode.NoneDown || InsertMode == TFlxInsertMode.NoneRight)
            {
                FSheets[SheetNo].ClearRange(CellRange);
                return;
            }

            int aRowCount = 0;
            int aColCount = 0;

            if ((InsertMode == TFlxInsertMode.ShiftRangeDown) || (InsertMode == TFlxInsertMode.ShiftRowDown))
            {
                aRowCount = 1;
            }
            else
            {
                aColCount = 1;
            }

            FSheets.DeleteRange(CellRange, aRowCount, aColCount, SheetInfo);
            Globals.DeleteRange(CellRange, aRowCount, aColCount, SheetInfo);

            //FSheets[SheetNo].FixAutoFilter(SheetNo);
            //we sadly have to reconstruct the whole autofilter, or the blue arrows will not stay correct. Just fixing AUTOFILTERINFO (with the line above) is not enough.
            if (aColCount > 0)
            {
                FSheets[SheetNo].AddNewAutoFilters(SheetNo, CellRange.Top, CellRange.Bottom, CellRange.Left, CellRange.Right);
            }
        }
Пример #29
0
 protected override TBaseRecord DoCopyTo(TSheetInfo SheetInfo)
 {
     return((TBaseRecord)MemberwiseClone());
 }
Пример #30
0
 internal void ArrangeMoveRange(TXlsCellRange CellRange, int NewRow, int NewCol, TSheetInfo SheetInfo)
 {
 }