Esempio n. 1
0
 internal void UpdateDeletedRanges(TDeletedRanges DeletedRanges)
 {
     for (int i = 0; i < Count; i++)
     {
         FList[i].ClientData.UpdateDeletedRanges(DeletedRanges);
     }
 }
Esempio n. 2
0
 internal override void UpdateDeletedRanges(int SheetIndex, int SheetCount, TDeletedRanges DeletedRanges)
 {
     if (WorksheetSource != null)
     {
         WorksheetSource.UpdateDeletedRanges(SheetIndex, SheetCount, DeletedRanges);
     }
 }
Esempio n. 3
0
        internal void UpdateDeletedRanges(int SheetIndex, int SheetCount, TDeletedRanges DeletedRanges)
        {
            FNames.UpdateDeletedRanges(SheetIndex, SheetCount, DeletedRanges);
#if (FRAMEWORK30 && !COMPACTFRAMEWORK)
            XlsxPivotCache.UpdateDeletedRanges(SheetIndex, SheetCount, DeletedRanges);
#endif
        }
Esempio n. 4
0
        internal TDeletedRanges FindUnreferencedRanges(int SheetIndex, int SheetCount)
        {
            TDeletedRanges Result = new TDeletedRanges(Globals.Names.Count, Globals.References, Globals.Names);

            UpdateDeletedRanges(SheetIndex, SheetCount, Result);
            Result.Update = true;
            return(Result);
        }
Esempio n. 5
0
 internal void UpdateDeletedRanges(int FirstSheet, int SheetCount, TDeletedRanges DeletedRanges)
 {
     for (int i = Count - 1; i >= 0; i--)
     {
         if (i < FirstSheet || i >= FirstSheet + SheetCount)
         {
             FList[i].UpdateDeletedRanges(DeletedRanges);
         }
     }
 }
Esempio n. 6
0
 internal void UpdateDeletedRanges(int SheetIndex, int SheetCount, TDeletedRanges DeletedRanges)
 {
     for (int i = Count - 1; i >= 0; i--)
     {
         if ((this[i].RangeSheet < SheetIndex) || (this[i].RangeSheet >= SheetIndex + SheetCount))
         {
             this[i].UpdateDeletedRanges(DeletedRanges);
         }
     }
 }
Esempio n. 7
0
        internal void UpdateDeletedRanges(TDeletedRanges DeletedRanges)
        {
            TFormulaRecord r = FirstFormula;

            while (r != null)
            {
                r.UpdateDeletedRanges(DeletedRanges);
                r = r.Next;
            }
        }
Esempio n. 8
0
 internal void UpdateDeletedRanges(int SheetIndex, int SheetCount, TDeletedRanges DeletedRanges)
 {
     for (int i = 0; i < List.Count; i++)
     {
         T it = List[i];
         if (it != null)
         {
             it.UpdateDeletedRanges(SheetIndex, SheetCount, DeletedRanges);
         }
     }
 }
Esempio n. 9
0
        internal void CleanUnusedNames(TWorkbook Workbook)
        {
            TDeletedRanges DeletedRanges = Workbook.FindUnreferencedRanges(-1, 0);

            for (int i = DeletedRanges.Count - 1; i >= 0; i--)
            {
                if (!DeletedRanges.Referenced(i) && !this[i].HasFormulaData && CanDeleteName(i))                  //don't delete internal names, or macro names.
                {
                    FList.RemoveAt(i);
                    DeletedRanges.AddNameForDelete(i);
                }
            }

            if (DeletedRanges.NeedsUpdate)
            {
                Workbook.UpdateDeletedRanges(-1, 0, DeletedRanges);
            }
        }
Esempio n. 10
0
        private static void FindReferences(TNameToken r, TDeletedRanges DeletedRanges)
        {
            int NameId = r.NameIndex - 1;

            if (NameId < 0 || NameId >= DeletedRanges.Count)
            {
                return;
            }
            if (DeletedRanges.Referenced(NameId))
            {
                return;                                   //Avoid infinite loop if one range refers to other and vice versa.
            }
            DeletedRanges.Reference(NameId);

            //We also need to recursively find all other names referenced by this name.
            TNameRecord Name = DeletedRanges.Names[NameId];

            Name.UpdateDeletedRanges(DeletedRanges);
        }
Esempio n. 11
0
        internal void DeleteName(int Index, TWorkbook Workbook)
        {
            if (Index < 0 || Index >= Count)
            {
                XlsMessages.ThrowException(XlsErr.ErrXlsIndexOutBounds, Index, "Index", 0, Count - 1);
            }

            TDeletedRanges DeletedRanges = Workbook.FindUnreferencedRanges(-1, 0);

            if (!DeletedRanges.Referenced(Index) && CanDeleteName(Index))              //don't delete internal names, or macro names.
            {
                FList.RemoveAt(Index);
                DeletedRanges.AddNameForDelete(Index);
                Workbook.UpdateDeletedRanges(-1, 0, DeletedRanges);
            }
            else
            {
                ClearName(Index);
            }
        }
Esempio n. 12
0
        internal static void UpdateDeletedRanges(TParsedTokenList Data, TDeletedRanges DeletedRanges)
        {
            Data.ResetPositionToLast();
            while (!Data.Bof())
            {
                TBaseParsedToken   tk = Data.LightPop();
                TBaseFunctionToken ft = tk as TBaseFunctionToken;
                if (ft != null)
                {
                    //we need to ensure we don't delete the used _xlfn. ranges. Used def fn don't need to check, because they use the name in the tokenlist.
                    if (ft.GetFunctionData().FutureInXls)
                    {
                        int NameId = DeletedRanges.Names.GetNamePos(-1, ft.GetFunctionData().FutureName);
                        if (NameId >= 0)
                        {
                            DeletedRanges.Reference(NameId);              //No need for recursion here, this name can't use anything else. Also, we don't need to update refs to this range.
                        }
                    }

                    continue;
                }

                TNameToken r = tk as TNameToken; //this includes namex
                if (r == null)
                {
                    continue;
                }
                if (r.GetBaseId == ptg.NameX && !DeletedRanges.References.IsLocalSheet(r.ExternSheet))
                {
                    return;                                                                                     //This name does not point to a name in the NAME table.
                }
                if (DeletedRanges.Update)
                {
                    UpdateRange(r, DeletedRanges);
                }
                else
                {
                    FindReferences(r, DeletedRanges);
                }
            }
        }
Esempio n. 13
0
        private static void UpdateRange(TNameToken r, TDeletedRanges DeletedRanges)
        {
            int NameId = r.NameIndex - 1;

            if (NameId < 0 || NameId >= DeletedRanges.Count)
            {
                return;
            }

            Debug.Assert(DeletedRanges.Referenced(NameId), "Can't delete ranges that have references. Excel does not do it, and doesn't provide a way to create invalid references for ranges.");

            int ofs = DeletedRanges.Offset(NameId);

            if (ofs == 0)
            {
                return;
            }

            NameId -= ofs;
            Debug.Assert(NameId >= 0);

            r.NameIndex = NameId + 1;
        }
Esempio n. 14
0
        internal void DeleteSheets(int SheetIndex, int SheetCount, TWorkbook Workbook)
        {
            TDeletedRanges DeletedRanges = Workbook.FindUnreferencedRanges(SheetIndex, SheetCount);

            for (int i = Count - 1; i >= 0; i--)
            {
                if ((this[i].RangeSheet >= SheetIndex) && (this[i].RangeSheet < SheetIndex + SheetCount))
                {
                    /* We cannot just delete the range, or formulas referring this range would crash (or refer to the wrong name).
                     * To actually delete here, we need to first find out whether this range is used.
                     * If it is not, go through all the formulas, charts, pivot tables, etc, and update the references to
                     * ranges less than this one to one less.
                     */

                    if (!DeletedRanges.Referenced(i) && CanDeleteName(i))  //don't delete internal names, or macro names.
                    {
                        FList.RemoveAt(i);
                        DeletedRanges.AddNameForDelete(i);
                    }
                    else
                    {
                        EnsureUniqueGlobalName(i);
                        this[i].RangeSheet = -1;
                    }
                }
                else
                {
                    this[i].ArrangeInsertSheets(SheetIndex, -SheetCount);
                }
            }

            if (DeletedRanges.NeedsUpdate)
            {
                Workbook.UpdateDeletedRanges(SheetIndex, SheetCount, DeletedRanges); //Update formulas, charts, etc.
            }
        }
Esempio n. 15
0
        internal void UpdateDeletedRanges(int SheetIndex, int SheetCount, TDeletedRanges DeletedRanges)
        {
            if (Name == null)
            {
                return;
            }
            int sheet     = -1;
            int NameIndex = DeletedRanges.Names.GetNamePos(sheet, Name);

            if (NameIndex < 0)
            {
                return;
            }
            if (DeletedRanges.Update)
            {
                //Nothing to do here, as we save the name string, not position
            }
            else
            {
                TNameRecord NameRec = DeletedRanges.Names[NameIndex];
                DeletedRanges.Reference(NameIndex);
                NameRec.UpdateDeletedRanges(DeletedRanges);
            }
        }
Esempio n. 16
0
 internal virtual void UpdateDeletedRanges(int SheetIndex, int SheetCount, TDeletedRanges DeletedRanges)
 {
 }
Esempio n. 17
0
 internal abstract void UpdateDeletedRanges(TDeletedRanges DeletedRanges);
Esempio n. 18
0
 internal void UpdateDeletedRanges(int SheetIndex, int SheetCount, TDeletedRanges DeletedRanges)
 {
     Globals.UpdateDeletedRanges(SheetIndex, SheetCount, DeletedRanges);
     Sheets.UpdateDeletedRanges(SheetIndex, SheetCount, DeletedRanges);
 }