private static List<Record> ReadRecords(Stream stream, out MSODRAWING drawingRecord) { List<Record> records = new List<Record>(); drawingRecord = null; Record record = Record.Read(stream); Record last_record = record; Record last_formula_record = null; last_record.Decode(); if (record is BOF && ((BOF)record).StreamType == StreamType.Worksheet) { while (record.Type != RecordType.EOF) { if (record.Type == RecordType.CONTINUE) { last_record.ContinuedRecords.Add(record); } else { switch (record.Type) { case RecordType.STRING: // jetcat_au: use last_formula_record instead of last_record if (last_formula_record is FORMULA) { record.Decode(); (last_formula_record as FORMULA).StringRecord = record as STRING; } break; case RecordType.MSODRAWING: if (drawingRecord == null) { drawingRecord = record as MSODRAWING; records.Add(record); } else { drawingRecord.ContinuedRecords.Add(record); } break; default: records.Add(record); break; } // jetcat_au: see 4.8 Array Formulas and Shared Formulas if (record.Type == RecordType.FORMULA) { last_formula_record = record; } else if (record.Type != RecordType.SHRFMLA && record.Type != RecordType.ARRAY) { last_formula_record = null; } last_record = record; } record = Record.Read(stream); } records.Add(record); } return records; }
private static Record EncodePictures(Dictionary <Pair <int, int>, Picture> pictures, SharedResource sharedResource, Worksheet worksheet) { MSODRAWING mSODRAWING = new MSODRAWING(); MsofbtDgContainer msofbtDgContainer = new MsofbtDgContainer(); mSODRAWING.EscherRecords.Add(msofbtDgContainer); MsofbtDg msofbtDg = new MsofbtDg(); msofbtDg.Instance = 1; checked { msofbtDg.NumShapes = pictures.Count + 1; msofbtDg.LastShapeID = 1024 + pictures.Count; msofbtDgContainer.EscherRecords.Add(msofbtDg); MsofbtSpgrContainer msofbtSpgrContainer = new MsofbtSpgrContainer(); msofbtDgContainer.EscherRecords.Add(msofbtSpgrContainer); MsofbtSpContainer msofbtSpContainer = new MsofbtSpContainer(); msofbtSpContainer.EscherRecords.Add(new MsofbtSpgr()); MsofbtSp msofbtSp = new MsofbtSp(); msofbtSp.ShapeId = 1024; msofbtSp.Flags = 5; msofbtSp.Version = 2; msofbtSpContainer.EscherRecords.Add(msofbtSp); msofbtSpgrContainer.EscherRecords.Add(msofbtSpContainer); foreach (Picture current in pictures.Values) { if (!sharedResource.Images.Contains(current.Image)) { sharedResource.Images.Add(current.Image); } MsofbtSpContainer msofbtSpContainer2 = new MsofbtSpContainer(); MsofbtSp msofbtSp2 = new MsofbtSp(); msofbtSp2.Version = 2; msofbtSp2.ShapeType = ShapeType.PictureFrame; msofbtSp2.ShapeId = 1024 + msofbtSpgrContainer.EscherRecords.Count; msofbtSp2.Flags = 2560; msofbtSpContainer2.EscherRecords.Add(msofbtSp2); MsofbtOPT msofbtOPT = new MsofbtOPT(); msofbtOPT.Add(PropertyIDs.LockAgainstGrouping, 33226880u); msofbtOPT.Add(PropertyIDs.FitTextToShape, 262148u); msofbtOPT.Add(PropertyIDs.BlipId, (uint)sharedResource.Images.IndexOf(current.Image) + 1u); msofbtSpContainer2.EscherRecords.Add(msofbtOPT); MsofbtClientAnchor msofbtClientAnchor = new MsofbtClientAnchor(); msofbtClientAnchor.Row1 = current.TopLeftCorner.RowIndex; msofbtClientAnchor.Col1 = current.TopLeftCorner.ColIndex; msofbtClientAnchor.DX1 = current.TopLeftCorner.DX; msofbtClientAnchor.DY1 = current.TopLeftCorner.DY; msofbtClientAnchor.Row2 = current.BottomRightCorner.RowIndex; msofbtClientAnchor.Col2 = current.BottomRightCorner.ColIndex; msofbtClientAnchor.DX2 = current.BottomRightCorner.DX; msofbtClientAnchor.DY2 = current.BottomRightCorner.DY; msofbtClientAnchor.ExtraData = new byte[0]; msofbtSpContainer2.EscherRecords.Add(msofbtClientAnchor); msofbtSpContainer2.EscherRecords.Add(new MsofbtClientData()); msofbtSpgrContainer.EscherRecords.Add(msofbtSpContainer2); } return(mSODRAWING); } }
private static Record EncodePictures(Dictionary<Pair<int, int>, Picture> pictures, SharedResource sharedResource, Worksheet worksheet) { MSODRAWING msoDrawing = new MSODRAWING(); MsofbtDgContainer dgContainer = new MsofbtDgContainer(); msoDrawing.EscherRecords.Add(dgContainer); MsofbtDg dg = new MsofbtDg(); dg.Instance = 1; dg.NumShapes = pictures.Count + 1; dg.LastShapeID = 1024 + pictures.Count; dgContainer.EscherRecords.Add(dg); MsofbtSpgrContainer spgrContainer = new MsofbtSpgrContainer(); dgContainer.EscherRecords.Add(spgrContainer); MsofbtSpContainer spContainer0 = new MsofbtSpContainer(); spContainer0.EscherRecords.Add(new MsofbtSpgr()); MsofbtSp shape0 = new MsofbtSp(); shape0.ShapeId = 1024; shape0.Flags = ShapeFlag.Group | ShapeFlag.Patriarch; shape0.Version = 2; spContainer0.EscherRecords.Add(shape0); spgrContainer.EscherRecords.Add(spContainer0); foreach (Picture pic in pictures.Values) { if (!sharedResource.Images.Contains(pic.Image)) { sharedResource.Images.Add(pic.Image); } MsofbtSpContainer spContainer = new MsofbtSpContainer(); MsofbtSp shape = new MsofbtSp(); shape.Version = 2; shape.ShapeType = ShapeType.PictureFrame; shape.ShapeId = 1024 + spgrContainer.EscherRecords.Count; shape.Flags = ShapeFlag.Haveanchor | ShapeFlag.Hasshapetype; spContainer.EscherRecords.Add(shape); MsofbtOPT opt = new MsofbtOPT(); opt.Add(PropertyIDs.LockAgainstGrouping, 33226880); opt.Add(PropertyIDs.FitTextToShape, 262148); opt.Add(PropertyIDs.BlipId, (uint)sharedResource.Images.IndexOf(pic.Image) + 1); spContainer.EscherRecords.Add(opt); MsofbtClientAnchor anchor = new MsofbtClientAnchor(); anchor.Row1 = pic.TopLeftCorner.RowIndex; anchor.Col1 = pic.TopLeftCorner.ColIndex; anchor.DX1 = pic.TopLeftCorner.DX; anchor.DY1 = pic.TopLeftCorner.DY; anchor.Row2 = pic.BottomRightCorner.RowIndex; anchor.Col2 = pic.BottomRightCorner.ColIndex; anchor.DX2 = pic.BottomRightCorner.DX; anchor.DY2 = pic.BottomRightCorner.DY; anchor.ExtraData = new byte[0]; spContainer.EscherRecords.Add(anchor); spContainer.EscherRecords.Add(new MsofbtClientData()); spgrContainer.EscherRecords.Add(spContainer); } return msoDrawing; }
private static List <Record> ReadRecords(Stream stream, out MSODRAWING drawingRecord) { List <Record> records = new List <Record>(); drawingRecord = null; Record record = Record.Read(stream); Record last_record = record; Record last_formula_record = null; last_record.Decode(); if (record is BOF && ((BOF)record).StreamType == StreamType.Worksheet) { while (record.Type != RecordType.EOF) { if (record.Type == RecordType.CONTINUE) { last_record.ContinuedRecords.Add(record); } else { switch (record.Type) { case RecordType.STRING: // jetcat_au: use last_formula_record instead of last_record if (last_formula_record is FORMULA) { record.Decode(); (last_formula_record as FORMULA).StringRecord = record as STRING; } break; case RecordType.MSODRAWING: if (drawingRecord == null) { drawingRecord = record as MSODRAWING; records.Add(record); } else { drawingRecord.ContinuedRecords.Add(record); } break; default: records.Add(record); break; } // jetcat_au: see 4.8 Array Formulas and Shared Formulas if (record.Type == RecordType.FORMULA) { last_formula_record = record; } else if (record.Type != RecordType.SHRFMLA && record.Type != RecordType.ARRAY) { last_formula_record = null; } last_record = record; } record = Record.Read(stream); } records.Add(record); } return(records); }
private static Record EncodePictures(Dictionary <Pair <int, int>, Picture> pictures, SharedResource sharedResource, Worksheet worksheet) { MSODRAWING msoDrawing = new MSODRAWING(); MsofbtDgContainer dgContainer = new MsofbtDgContainer(); msoDrawing.EscherRecords.Add(dgContainer); MsofbtDg dg = new MsofbtDg(); dg.Instance = 1; dg.NumShapes = pictures.Count + 1; dg.LastShapeID = 1024 + pictures.Count; dgContainer.EscherRecords.Add(dg); MsofbtSpgrContainer spgrContainer = new MsofbtSpgrContainer(); dgContainer.EscherRecords.Add(spgrContainer); MsofbtSpContainer spContainer0 = new MsofbtSpContainer(); spContainer0.EscherRecords.Add(new MsofbtSpgr()); MsofbtSp shape0 = new MsofbtSp(); shape0.ShapeId = 1024; shape0.Flags = ShapeFlag.Group | ShapeFlag.Patriarch; shape0.Version = 2; spContainer0.EscherRecords.Add(shape0); spgrContainer.EscherRecords.Add(spContainer0); foreach (Picture pic in pictures.Values) { if (!sharedResource.Images.Contains(pic.Image)) { sharedResource.Images.Add(pic.Image); } MsofbtSpContainer spContainer = new MsofbtSpContainer(); MsofbtSp shape = new MsofbtSp(); shape.Version = 2; shape.ShapeType = ShapeType.PictureFrame; shape.ShapeId = 1024 + spgrContainer.EscherRecords.Count; shape.Flags = ShapeFlag.Haveanchor | ShapeFlag.Hasshapetype; spContainer.EscherRecords.Add(shape); MsofbtOPT opt = new MsofbtOPT(); opt.Add(PropertyIDs.LockAgainstGrouping, 33226880); opt.Add(PropertyIDs.FitTextToShape, 262148); opt.Add(PropertyIDs.BlipId, (uint)sharedResource.Images.IndexOf(pic.Image) + 1); spContainer.EscherRecords.Add(opt); MsofbtClientAnchor anchor = new MsofbtClientAnchor(); anchor.Row1 = pic.TopLeftCorner.RowIndex; anchor.Col1 = pic.TopLeftCorner.ColIndex; anchor.DX1 = pic.TopLeftCorner.DX; anchor.DY1 = pic.TopLeftCorner.DY; anchor.Row2 = pic.BottomRightCorner.RowIndex; anchor.Col2 = pic.BottomRightCorner.ColIndex; anchor.DX2 = pic.BottomRightCorner.DX; anchor.DY2 = pic.BottomRightCorner.DY; anchor.ExtraData = new byte[0]; spContainer.EscherRecords.Add(anchor); spContainer.EscherRecords.Add(new MsofbtClientData()); spgrContainer.EscherRecords.Add(spContainer); } return(msoDrawing); }
public static Record Read(Stream stream) { Record record = Record.ReadBase(stream); ushort type = record.Type; Record result; if (type <= 146) { if (type <= 49) { if (type <= 13) { if (type == 6) { result = new FORMULA(record); return(result); } switch (type) { case 10: result = new EOF(record); return(result); case 12: result = new CALCCOUNT(record); return(result); case 13: result = new CALCMODE(record); return(result); } } else { if (type == 34) { result = new DATEMODE(record); return(result); } if (type == 41) { result = new BOTTOMMARGIN(record); return(result); } if (type == 49) { result = new FONT(record); return(result); } } } else { if (type <= 93) { switch (type) { case 60: result = new CONTINUE(record); return(result); case 61: result = new WINDOW1(record); return(result); case 62: case 63: case 65: break; case 64: result = new BACKUP(record); return(result); case 66: result = new CODEPAGE(record); return(result); default: if (type == 85) { result = new DEFCOLWIDTH(record); return(result); } if (type == 93) { result = new OBJ(record); return(result); } break; } } else { if (type == 125) { result = new COLINFO(record); return(result); } if (type == 133) { result = new BOUNDSHEET(record); return(result); } if (type == 146) { result = new PALETTE(record); return(result); } } } } else { if (type <= 237) { if (type <= 190) { if (type == 153) { result = new STANDARDWIDTH(record); return(result); } switch (type) { case 189: result = new MULRK(record); return(result); case 190: result = new MULBLANK(record); return(result); } } else { switch (type) { case 214: result = new RSTRING(record); return(result); case 215: result = new DBCELL(record); return(result); case 216: case 217: break; case 218: result = new BOOKBOOL(record); return(result); default: if (type == 224) { result = new XF(record); return(result); } switch (type) { case 233: result = new BITMAP(record); return(result); case 235: result = new MSODRAWINGGROUP(record); return(result); case 236: result = new MSODRAWING(record); return(result); case 237: result = new MSODRAWINGSELECTION(record); return(result); } break; } } } else { if (type <= 545) { switch (type) { case 252: result = new SST(record); return(result); case 253: result = new LABELSST(record); return(result); case 254: break; case 255: result = new EXTSST(record); return(result); default: switch (type) { case 512: result = new DIMENSIONS(record); return(result); case 513: result = new BLANK(record); return(result); case 514: case 516: case 518: break; case 515: result = new NUMBER(record); return(result); case 517: result = new BOOLERR(record); return(result); case 519: result = new STRING(record); return(result); case 520: result = new ROW(record); return(result); default: if (type == 545) { result = new ARRAY(record); return(result); } break; } break; } } else { if (type == 638) { result = new RK(record); return(result); } if (type == 1054) { result = new FORMAT(record); return(result); } if (type == 2057) { result = new BOF(record); return(result); } } } } result = record; return(result); }
private static List <Record> ReadRecords(Stream stream, out MSODRAWING drawingRecord) { List <Record> list = new List <Record>(); drawingRecord = null; Record record = Record.Read(stream); Record record2 = record; Record record3 = null; record2.Decode(); if (record is BOF && ((BOF)record).StreamType == 16) { while (record.Type != 10) { if (record.Type == 60) { record2.ContinuedRecords.Add(record); } else { ushort type = record.Type; if (type != 236) { if (type != 519) { list.Add(record); } else { if (record3 is FORMULA) { record.Decode(); (record3 as FORMULA).StringRecord = (record as STRING); } } } else { if (drawingRecord == null) { drawingRecord = (record as MSODRAWING); list.Add(record); } else { drawingRecord.ContinuedRecords.Add(record); } } if (record.Type == 6) { record3 = record; } else { if (record.Type != 1212 && record.Type != 545) { record3 = null; } } record2 = record; } record = Record.Read(stream); } list.Add(record); } return(list); }