Пример #1
0
        internal static void ArrangeSharedFormulas(TParsedTokenList Data, int Row, int Col, bool FromBiff8)
        {
            Data.ResetPositionToLast();
            while (!Data.Bof())
            {
                TBaseParsedToken r = Data.LightPop();

                switch (r.GetBaseId)
                {
                case ptg.RefN:
                case ptg.AreaN:
                    Data.UnShare(Row, Col, FromBiff8);
                    break;
                }
            }
        }
Пример #2
0
        private void CheckFutureFunction(TParsedTokenListBuilder TokenBuilder, ref int np, TNameRecordList Names, ref TCellFunctionData fd2, TTokenOffset TokenOffset, ref bool HasAggregate)
        {
            //We need to recursively read parameters in back order to find out the name, which is stored as far as possible from the function :(
            TParsedTokenList ParsedList = TokenBuilder.ToParsedTokenList();

            ParsedList.ResetPositionToLast();
            for (int i = 0; i < np; i++) //np is +1. But we will move below the name, then inc 1, so we know there isn't a "neutral" token like parent or memarea, intead of the real thing.
            {
                ParsedList.Flush();
            }

            ParsedList.MoveBack();
            TNameToken bp = ParsedList.ForwardPop() as TNameToken;

            if (bp is TNameXToken)
            {
                return;                    //This name isn't an internal 2007 name.
            }
            if (bp == null)
            {
                return;
            }
            if (bp.NameIndex <= 0 || bp.NameIndex > Names.Count)
            {
                return;
            }
            string FunctionName = Names[bp.NameIndex - 1].Name;

            if (FunctionName.StartsWith("_xlfn.", StringComparison.InvariantCultureIgnoreCase))
            {
                TCellFunctionData fn = TXlsFunction.GetData(FunctionName.Substring("_xlfn.".Length));
                if (fn != null)
                {
                    if (fn.Index == (int)TFutureFunctions.Aggregate)
                    {
                        HasAggregate = true;
                    }

                    fd2 = fn;
                    int tPos = ParsedList.SavePosition();
                    TokenBuilder.RemoveAt(tPos);
                    TokenOffset.RemoveToken(tPos);
                    np--;
                }
            }
        }
Пример #3
0
        internal static bool HasExternRefs(TParsedTokenList Data)
        {
            Data.ResetPositionToLast();
            while (!Data.Bof())
            {
                TBaseParsedToken r = Data.LightPop();
                ptg id             = r.GetBaseId;
                // This check is a little simplistic because an Area3d or Ref3d might in fact refer to the same sheet. But then, the externsheet is not copied so
                // the reference will be invalid anyway. The "right" thing to do would be to convert external refs to the same sheet to external refs on the new sheet.
                if (id == ptg.Area3d || id == ptg.Ref3d || id == ptg.NameX)
                {
                    return(true);
                }
            }

            return(false);
        }
Пример #4
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);
                }
            }
        }
Пример #5
0
        internal static bool HasExternLinks(TParsedTokenList Data, TReferences References)
        {
            Data.ResetPositionToLast();
            while (!Data.Bof())
            {
                TBaseParsedToken r = Data.LightPop();
                ptg id             = r.GetBaseId;

                if (id == ptg.Area3d || id == ptg.Ref3d || id == ptg.NameX)
                {
                    if (References != null)
                    {
                        int ExternSheet = r.ExternSheet;
                        if (!References.IsLocalSheet(ExternSheet))
                        {
                            return(true);
                        }
                    }
                }
            }

            return(false);
        }