コード例 #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
ファイル: UXlsHyperLink.cs プロジェクト: mwilian/demos
        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
ファイル: UExcelRecords.cs プロジェクト: mwilian/demos
        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
ファイル: UXlsWorkbookGlobals.cs プロジェクト: mwilian/demos
        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
ファイル: UEscherOtherRecords.cs プロジェクト: mwilian/demos
 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
ファイル: UEscherLists.cs プロジェクト: mwilian/demos
 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
ファイル: UXlsHyperLink.cs プロジェクト: mwilian/demos
        protected override TBaseRecord DoCopyTo(TSheetInfo SheetInfo)
        {
            THLinkRecord b = (THLinkRecord)MemberwiseClone();

            if (Hint != null)
            {
                b.Hint = (TScreenTipRecord)TScreenTipRecord.Clone(Hint, SheetInfo);
            }
            return(b);
        }
コード例 #13
0
ファイル: UCalc.cs プロジェクト: mwilian/demos
        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
ファイル: USST.cs プロジェクト: mwilian/demos
        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
ファイル: UCalc.cs プロジェクト: mwilian/demos
        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
ファイル: UXlsNotes.cs プロジェクト: mwilian/demos
        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
ファイル: UExcelRecords.cs プロジェクト: mwilian/demos
        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
ファイル: UXlsHyperLink.cs プロジェクト: mwilian/demos
 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
ファイル: UXlsBaseClientData.cs プロジェクト: mwilian/demos
 internal static TBaseClientData Clone(TBaseClientData Self, TSheetInfo SheetInfo)
 {
     if (Self != null)
     {
         return(Self.DoCopyTo(SheetInfo));
     }
     else
     {
         return(null);
     }
 }
コード例 #21
0
ファイル: UExcelRecords.cs プロジェクト: mwilian/demos
 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
ファイル: UXlsProtect.cs プロジェクト: mwilian/demos
        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
ファイル: UExcelRecords.cs プロジェクト: mwilian/demos
        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
ファイル: UXlsNotes.cs プロジェクト: mwilian/demos
 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
ファイル: UExcelRecords.cs プロジェクト: mwilian/demos
        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)
 {
 }