private static bool Convert3D8To7(TReferences References, byte Token, byte[] Data, byte[] ResultData, ref int tPos, ref int rPos) { BitOps.SetWord(ResultData, rPos, 0xFFFF); rPos += 2; Array.Clear(ResultData, rPos, 8); //reserved. rPos += 8; int Sheet1, Sheet2; bool HasExternal; string ExternBookName; References.GetSheetsFromExternSheet(BitOps.GetWord(Data, tPos), out Sheet1, out Sheet2, out HasExternal, out ExternBookName); tPos += 2; if (Sheet1 > FlxConsts.Max_PxlSheets || Sheet2 > FlxConsts.Max_PxlSheets) { return(false); } if (HasExternal) { return(false); } BitOps.SetWord(ResultData, rPos, Sheet1); rPos += 2; BitOps.SetWord(ResultData, rPos, Sheet2); rPos += 2; return(true); }
internal bool Update; //We will contemplate 2 ways of working for this. When Update is true, ranges will be modified, else we will just build the list. internal TDeletedRanges(int NameCount, TReferences aReferences, TNameRecordList aNames) { Refs = new bool[NameCount]; Offs = new int[NameCount]; Length = NameCount; References = aReferences; Names = aNames; Update = false; }
internal TCopiedGen DrawingGen; //used when copying to make sure we don't repeat. #endregion #region Constructor internal TWorkbookGlobals(ExcelFile aWorkbook) { FWorkbook = aWorkbook; FFileEncryption = new TFileEncryption(); FLel = new TMiscRecordList(); FBoundSheets = new TBoundSheetList(); FFnGroups = new TMiscRecordList(); FWorkbookProtection = new TWorkbookProtection(); FFonts = new TFontRecordList(); FFormats = TFormatRecordList.Create(); FStyleXF = new TXFRecordList(); FCellXF = new TXFRecordList(); FDXF = new TDXFRecordList(); FStyles = new TStyleRecordList(); FTableStyles = new TTableStyleRecordList(); FPivotCache = new TMiscRecordList(); #if (FRAMEWORK30 && !COMPACTFRAMEWORK) FXlsxPivotCache = new TXlsxPivotCacheList(); FXlsxConnections = null; #endif FDocRoute = new TMiscRecordList(); FUserBView = new TMiscRecordList(); FMetaData = new TMiscRecordList(); FNames = new TNameRecordList(); FRealTimeData = new TMiscRecordList(); FReferences = new TReferences(); FHeaderImages = new TDrawingGroup(xlr.HEADERIMG, 14); FDrawingGroup = new TDrawingGroup(xlr.MSODRAWINGGROUP, 0); FSST = new TSST(); FWebPub = new TMiscRecordList(); FFeatHdr = new TMiscRecordList(); FDConn = new TMiscRecordList(); FBorders = new TBorderList(); FPatterns = new TPatternList(); FFutureRecords = new TMiscRecordList(); StylesFutureStorage = null; CalcOptions = new TCalcOptions(); ThemeRecord = new TThemeRecord(); #if (FRAMEWORK30 && !COMPACTFRAMEWORK) CustomXMLData = new TCustomXMLDataStorageList(); #endif }
internal void MergeFromPxlGlobals(TWorkbookGlobals SourceGlobals) { sBOF = SourceGlobals.sBOF; FSST = SourceGlobals.FSST; FReferences = SourceGlobals.FReferences; FBoundSheets = SourceGlobals.FBoundSheets; //Pxl doesn't have styles. CellXF.MergeFromPxlXF(SourceGlobals.CellXF, Fonts.Count - 1, this, SourceGlobals); //-1 because fonts[0] will be merged FFonts.MergeFromPxlFont(SourceGlobals.Fonts); //Formats are added in FXF.Merge FNames = SourceGlobals.FNames; Window1 = SourceGlobals.Window1; CodePage = SourceGlobals.CodePage; Country = SourceGlobals.Country; }
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); }
internal TFormulaErrorValue LoadBiff8(byte[] Data, int Pos, TReferences References) { return(Load(Data, Pos, TFmlaConvert.Biff8To7, TPxlVersion.Undefined, null, References)); //No ExternSheetList to load Biff8 }
private TFormulaErrorValue Load(byte[] Data, int Pos, TFmlaConvert ConvertType, TPxlVersion PxlVersion, TExternSheetList ExternSheetList, TReferences References) { int tPos = Pos; int bPos = Pos; int fPos = Data.Length; while (tPos < fPos) { byte Token = Data[tPos]; if (Token >= 0x3 && Token <= 0x16) { tPos++; //XlsTokens.IsUnaryOp(Token)||XlsTokens.IsBinaryOp(Token) || Token==XlsTokens.tk_MissArg ; } else if (XlsTokens.Is_tk_Operand(Token)) { tPos++; Flush(Data, ref bPos, tPos); if (ConvertType == TFmlaConvert.Biff7To8) { ParsedTokens.Add(ConvertToBiff8(ExternSheetList, Token, Data, ref tPos)); } else { byte[] ConvertedData = ConvertToBiff7(References, Token, Data, ref tPos); if (ConvertedData == null) { return(new TFormulaErrorValue(Token)); } ParsedTokens.Add(ConvertedData); } bPos = tPos; } else { switch (Token) { case XlsTokens.tk_Str: if (PxlVersion == TPxlVersion.v10) { tPos++; Flush(Data, ref bPos, tPos); byte[] StrValue = new byte[Data[tPos] + 2]; StrValue[0] = Data[tPos]; //String len. StrValue[1] = 0; //Not wide string. Array.Copy(Data, tPos + 1, StrValue, 2, StrValue.Length - 2); ParsedTokens.Add(StrValue); tPos += Data[tPos] + 1; bPos = tPos; } else { tPos += 1 + (int)StrOps.GetStrLen(false, Data, tPos + 1, false, 0); } break; case XlsTokens.tk_Err: case XlsTokens.tk_Bool: tPos += 1 + 1; break; case XlsTokens.tk_Int: case 0x21: //XlsTokens.Is_tk_Func(Token): case 0x41: case 0x61: tPos += 1 + 2; break; case 0x22: //XlsTokens.Is_tk_FuncVar(Token): case 0x42: case 0x62: tPos += 1 + 3; break; case XlsTokens.tk_Num: tPos += 1 + 8; break; case XlsTokens.tk_Attr: bool IgnoreAttr = false; if ((Data[tPos + 1] & (0x2 | 0x4 | 0x8)) != 0) //optimized if, goto, optimized chose. { Flush(Data, ref bPos, tPos); IgnoreAttr = true; } if ((Data[tPos + 1] & 0x04) == 0x04) { tPos += (BitOps.GetWord(Data, tPos + 2) + 1) * 2; } tPos += 1 + 3; if (IgnoreAttr) { bPos = tPos; //ignore the attribute, as it contains offsets to the formula that will change. } break; case XlsTokens.tk_Table: return(new TFormulaErrorValue(Token)); case XlsTokens.tk_MemFunc: case XlsTokens.tk_MemFunc + 0x20: case XlsTokens.tk_MemFunc + 0x40: tPos += 1 + 2; //+ GetWord(Data, tPos+1); break; case XlsTokens.tk_MemArea: case XlsTokens.tk_MemArea + 0x20: case XlsTokens.tk_MemArea + 0x40: case XlsTokens.tk_MemErr: case XlsTokens.tk_MemErr + 0x20: case XlsTokens.tk_MemErr + 0x40: case XlsTokens.tk_MemNoMem: case XlsTokens.tk_MemNoMem + 0x20: case XlsTokens.tk_MemNoMem + 0x40: tPos += 1 + 6; //+ GetWord(Data, tPos+1); break; default: return(new TFormulaErrorValue(Token)); } } }//while Flush(Data, ref bPos, tPos); return(null); }
private static byte[] ConvertToBiff7(TReferences References, byte Token, byte[] Data, ref int tPos) { byte[] Result; int rPos = 0; switch (TBaseParsedToken.CalcBaseToken((ptg)Token)) { case ptg.Name: Result = new byte[14]; BitOps.SetWord(Result, 0, BitOps.GetWord(Data, tPos)); tPos += 4; //Biff8 Name is Wrong on Excel docs! return(Result); case ptg.NameX: Result = new byte[24]; BitOps.SetWord(Result, 0, 0xFFFF); BitOps.SetWord(Result, 10, BitOps.GetWord(Data, tPos + 2)); tPos += 6; //This is actually 6 return(Result); case ptg.Ref: case ptg.RefN: Result = new byte[3]; if (!ConvertRowsAndColumns8To7(Data, Result, ref tPos, ref rPos, false)) { return(null); } return(Result); case ptg.Area: case ptg.AreaN: Result = new byte[6]; if (!ConvertRowsAndColumns8To7(Data, Result, ref tPos, ref rPos, true)) { return(null); } return(Result); case ptg.RefErr: tPos += 4; return(new byte[3]); case ptg.AreaErr: tPos += 8; return(new byte[6]); case ptg.Ref3d: case ptg.Ref3dErr: Result = new byte[17]; if (!Convert3D8To7(References, Token, Data, Result, ref tPos, ref rPos)) { return(null); } if (!ConvertRowsAndColumns8To7(Data, Result, ref tPos, ref rPos, false)) { return(null); } return(Result); case ptg.Area3d: case ptg.Area3dErr: Result = new byte[20]; if (!Convert3D8To7(References, Token, Data, Result, ref tPos, ref rPos)) { return(null); } if (!ConvertRowsAndColumns8To7(Data, Result, ref tPos, ref rPos, true)) { return(null); } return(Result); } return(null); }