/// <summary> /// Initializes data based on the <see cref="ArrayRecord"/>. /// </summary> private void Initialize(ArrayRecord record) { Tag = Engine.CodeTypeTag.Array; BasicType = DIA.BasicType.NoType; Size = (int)record.Size; Name = ElementType.Name + "[]"; }
public void TestRead() { String hex = "21 02 25 00 01 00 01 00 01 01 00 00 00 00 00 00 " + "17 00 65 00 00 01 00 02 C0 02 C0 65 00 00 01 00 " + "03 C0 03 C0 04 62 01 07 00"; byte[] data = HexRead.ReadFromString(hex); RecordInputStream in1 = TestcaseRecordInputStream.Create(data); ArrayRecord r1 = new ArrayRecord(in1); CellRangeAddress8Bit range = r1.Range; Assert.AreEqual(1, range.FirstColumn); Assert.AreEqual(1, range.LastColumn); Assert.AreEqual(1, range.FirstRow); Assert.AreEqual(1, range.LastRow); Ptg[] ptg = r1.FormulaTokens; Assert.AreEqual(FormulaRenderer.ToFormulaString(null, ptg), "MAX(C1:C2-D1:D2)"); //construct a new ArrayRecord with the same contents as r1 Ptg[] fmlaPtg = FormulaParser.Parse("MAX(C1:C2-D1:D2)", null, FormulaType.Array, 0); ArrayRecord r2 = new ArrayRecord(Formula.Create(fmlaPtg), new CellRangeAddress8Bit(1, 1, 1, 1)); byte[] ser = r2.Serialize(); //serialize and check that the data is the same as in r1 Assert.AreEqual(HexDump.ToHex(data), HexDump.ToHex(ser)); }
/** * Gets the {@link SharedValueRecordBase} record if it should be encoded immediately after the * formula record Contained in the specified {@link FormulaRecordAggregate} agg. Note - the * shared value record always appears after the first formula record in the group. For arrays * and tables the first formula is always the in the top left cell. However, since shared * formula groups can be sparse and/or overlap, the first formula may not actually be in the * top left cell. * * @return the SHRFMLA, TABLE or ARRAY record for the formula cell, if it is the first cell of * a table or array region. <code>null</code> if the formula cell is not shared/array/table, * or if the specified formula is not the the first in the group. */ public SharedValueRecordBase GetRecordForFirstCell(FormulaRecordAggregate agg) { CellReference firstCell = agg.FormulaRecord.Formula.ExpReference; // perhaps this could be optimised by consulting the (somewhat unreliable) isShared flag // and/or distinguishing between tExp and tTbl. if (firstCell == null) { // not a shared/array/table formula return(null); } int row = firstCell.Row; int column = firstCell.Col; if (agg.Row != row || agg.Column != column) { // not the first formula cell in the group return(null); } SharedFormulaGroup[] groups = GetGroups(); for (int i = 0; i < groups.Length; i++) { // note - logic for Finding correct shared formula group is slightly // more complicated since the first cell SharedFormulaGroup sfg = groups[i]; if (sfg.IsFirstCell(row, column)) { return(sfg.SFR); } } // Since arrays and tables cannot be sparse (all cells in range participate) // The first cell will be the top left in the range. So we can match the // ARRAY/TABLE record directly. for (int i = 0; i < _tableRecords.Length; i++) { TableRecord tr = _tableRecords[i]; if (tr.IsFirstCell(row, column)) { return(tr); } } for (int i = 0; i < _arrayRecords.Length; i++) { ArrayRecord ar = _arrayRecords[i]; if (ar.IsFirstCell(row, column)) { return(ar); } } return(null); }
/// <summary> /// Gets the type name from array record. /// </summary> /// <param name="pdb">The PDB file reader.</param> /// <param name="arrayRecord">The array record.</param> private static string GetTypeName(PdbFileReader pdb, ArrayRecord arrayRecord) { PdbType elementType = pdb[arrayRecord.ElementType]; if (elementType.Size == 0) { return($"{elementType.Name}[]"); } ulong elements = arrayRecord.Size / elementType.Size; return($"{elementType.Name}[{elements}]"); }
public CellRangeAddress GetArrayFormulaRange() { if (_sharedFormulaRecord != null) { throw new InvalidOperationException("not an array formula cell."); } CellReference expRef = _formulaRecord.Formula.ExpReference; if (expRef == null) { throw new InvalidOperationException("not an array formula cell."); } ArrayRecord arec = _sharedValueManager.GetArrayRecord(expRef.Row, expRef.Col); if (arec == null) { throw new InvalidOperationException("ArrayRecord was not found for the locator " + expRef.FormatAsString()); } CellRangeAddress8Bit a = arec.Range; return(new CellRangeAddress(a.FirstRow, a.LastRow, a.FirstColumn, a.LastColumn)); }
/** * Add specified Array Record. */ public void AddArrayRecord(ArrayRecord ar) { // could do a check here to make sure none of the ranges overlap _arrayRecords.Add(ar); }
/// <summary> /// Reads type record for the specified type index. /// </summary> /// <param name="typeIndex">Type record index in <see cref="references"/> list.</param> /// <returns></returns> private TypeRecord ReadType(int typeIndex) { IBinaryReader reader = typeRecordsSubStreamPerThread.Value; RecordReference reference = references[typeIndex]; TypeRecord typeRecord; long dataEnd = reference.DataOffset + reference.DataLen; reader.Position = reference.DataOffset; switch (reference.Kind) { case TypeLeafKind.LF_MODIFIER: typeRecord = ModifierRecord.Read(reader, reference.Kind); break; case TypeLeafKind.LF_PROCEDURE: typeRecord = ProcedureRecord.Read(reader, reference.Kind); break; case TypeLeafKind.LF_MFUNCTION: typeRecord = MemberFunctionRecord.Read(reader, reference.Kind); break; case TypeLeafKind.LF_LABEL: typeRecord = LabelRecord.Read(reader, reference.Kind); break; case TypeLeafKind.LF_MFUNC_ID: typeRecord = MemberFunctionIdRecord.Read(reader, reference.Kind); break; case TypeLeafKind.LF_ARGLIST: typeRecord = ArgumentListRecord.Read(reader, reference.Kind); break; case TypeLeafKind.LF_SUBSTR_LIST: typeRecord = StringListRecord.Read(reader, reference.Kind); break; case TypeLeafKind.LF_POINTER: typeRecord = PointerRecord.Read(reader, reference.Kind); break; case TypeLeafKind.LF_NESTTYPE: typeRecord = NestedTypeRecord.Read(reader, reference.Kind); break; case TypeLeafKind.LF_FIELDLIST: typeRecord = FieldListRecord.Read(reader, reference.Kind, reference.DataLen); break; case TypeLeafKind.LF_ENUM: typeRecord = EnumRecord.Read(reader, reference.Kind); break; case TypeLeafKind.LF_CLASS: case TypeLeafKind.LF_STRUCTURE: case TypeLeafKind.LF_INTERFACE: typeRecord = ClassRecord.Read(reader, reference.Kind); break; case TypeLeafKind.LF_ARRAY: typeRecord = ArrayRecord.Read(reader, reference.Kind); break; case TypeLeafKind.LF_BITFIELD: typeRecord = BitFieldRecord.Read(reader, reference.Kind); break; case TypeLeafKind.LF_METHODLIST: typeRecord = MethodOverloadListRecord.Read(reader, reference.Kind, reference.DataLen); break; case TypeLeafKind.LF_UNION: typeRecord = UnionRecord.Read(reader, reference.Kind); break; case TypeLeafKind.LF_VTSHAPE: typeRecord = VirtualFunctionTableShapeRecord.Read(reader, reference.Kind); break; case TypeLeafKind.LF_UDT_MOD_SRC_LINE: typeRecord = UdtModuleSourceLineRecord.Read(reader, reference.Kind); break; case TypeLeafKind.LF_STRING_ID: typeRecord = StringIdRecord.Read(reader, reference.Kind); break; case TypeLeafKind.LF_BUILDINFO: typeRecord = BuildInfoRecord.Read(reader, reference.Kind); break; case TypeLeafKind.LF_FUNC_ID: typeRecord = FunctionIdRecord.Read(reader, reference.Kind); break; default: #if DEBUG throw new NotImplementedException($"Unknown reference kind: {reference.Kind}"); #else return(null); #endif } if (reader.Position + 4 < dataEnd || reader.Position > dataEnd) { throw new Exception("Parsing went wrong"); } return(typeRecord); }
public void SetArrayFormula(CellRangeAddress r, Ptg[] ptgs) { ArrayRecord arr = new ArrayRecord(NPOI.SS.Formula.Formula.Create(ptgs), new CellRangeAddress8Bit(r.FirstRow, r.LastRow, r.FirstColumn, r.LastColumn)); _sharedValueManager.AddArrayRecord(arr); }
public override void Read(ArrayRecord arrRec) { }
public void Read(ArrayRecord arrRec) { }
private Biff GetCorrectRecord(GenericBiff record, Stream stream, SstRecord sst) { Biff ret = record; switch (record.Id) { case (ushort)RecordType.Bof: BofRecord bof = new BofRecord(record); if (bof.Version < 0x0600) { throw new Exception("Versions below Excel 97/2000 are currently not supported."); } ret = bof; break; case (ushort)RecordType.Boundsheet: ret = new BoundSheetRecord(record); break; case (ushort)RecordType.Index: ret = new IndexRecord(record); break; case (ushort)RecordType.DbCell: ret = new DbCellRecord(record); break; case (ushort)RecordType.Row: ret = new RowRecord(record); break; case (ushort)RecordType.Continue: ret = new ContinueRecord(record); break; case (ushort)RecordType.Blank: ret = new BlankRecord(record); break; case (ushort)RecordType.BoolErr: ret = new BoolErrRecord(record); break; case (ushort)RecordType.Formula: ret = new FormulaRecord(record, stream); break; case (ushort)RecordType.Label: ret = new LabelRecord(record); break; case (ushort)RecordType.LabelSst: ret = new LabelSstRecord(record, sst); break; case (ushort)RecordType.MulBlank: ret = new MulBlankRecord(record); break; case (ushort)RecordType.MulRk: ret = new MulRkRecord(record); break; case (ushort)RecordType.String: ret = new StringValueRecord(record); break; case (ushort)RecordType.Xf: ret = new XfRecord(record); break; case (ushort)RecordType.Rk: ret = new RkRecord(record); break; case (ushort)RecordType.Number: ret = new NumberRecord(record); break; case (ushort)RecordType.Array: ret = new ArrayRecord(record); break; case (ushort)RecordType.ShrFmla: ret = new SharedFormulaRecord(record); break; case (ushort)RecordType.Table: ret = new TableRecord(record); break; case (ushort)RecordType.Sst: ret = new SstRecord(record, stream); break; case (ushort)RecordType.Eof: ret = new EofRecord(record); break; case (ushort)RecordType.Font: ret = new FontRecord(record); break; case (ushort)RecordType.Format: ret = new Net.SourceForge.Koogra.Excel.Records.FormatRecord(record); break; case (ushort)RecordType.Palette: ret = new PaletteRecord(record); break; case (ushort)RecordType.Hyperlink: ret = new HyperLinkRecord(record); break; } return(ret); }
public void Read(ArrayRecord arrRec) { this.VerifyArray(arrRec); }
public void VerifyArray(ArrayRecord arrRec) { Verify(RecordType.Array, arrRec.SequenceNo); }
/** * Also collects any loose MergeCellRecords and puts them in the supplied * mergedCellsTable */ public RowBlocksReader(RecordStream rs) { ArrayList plainRecords = new ArrayList(); ArrayList shFrmRecords = new ArrayList(); ArrayList arrayRecords = new ArrayList(); ArrayList tableRecords = new ArrayList(); ArrayList mergeCellRecords = new ArrayList(); List <CellReference> firstCellRefs = new List <CellReference>(); Record prevRec = null; while (!RecordOrderer.IsEndOfRowBlock(rs.PeekNextSid())) { // End of row/cell records for the current sheet // Note - It is important that this code does not inadvertently add any sheet // records from a subsequent sheet. For example, if SharedFormulaRecords // are taken from the wrong sheet, this could cause bug 44449. if (!rs.HasNext()) { throw new InvalidOperationException("Failed to find end of row/cell records"); } Record rec = rs.GetNext(); ArrayList dest; switch (rec.Sid) { case MergeCellsRecord.sid: dest = mergeCellRecords; break; case SharedFormulaRecord.sid: dest = shFrmRecords; if (!(prevRec is FormulaRecord)) { throw new Exception("Shared formula record should follow a FormulaRecord"); } FormulaRecord fr = (FormulaRecord)prevRec; firstCellRefs.Add(new CellReference(fr.Row, fr.Column)); break; case ArrayRecord.sid: dest = arrayRecords; break; case TableRecord.sid: dest = tableRecords; break; default: dest = plainRecords; break; } dest.Add(rec); prevRec = rec; } SharedFormulaRecord[] sharedFormulaRecs = new SharedFormulaRecord[shFrmRecords.Count]; ArrayRecord[] arrayRecs = new ArrayRecord[arrayRecords.Count]; TableRecord[] tableRecs = new TableRecord[tableRecords.Count]; sharedFormulaRecs = (SharedFormulaRecord[])shFrmRecords.ToArray(typeof(SharedFormulaRecord)); CellReference[] firstCells = new CellReference[firstCellRefs.Count]; firstCells = firstCellRefs.ToArray(); arrayRecs = (ArrayRecord[])arrayRecords.ToArray(typeof(ArrayRecord)); tableRecs = (TableRecord[])tableRecords.ToArray(typeof(TableRecord)); _plainRecords = plainRecords; _sfm = SharedValueManager.Create(sharedFormulaRecs, firstCells, arrayRecs, tableRecs); _mergedCellsRecords = new MergeCellsRecord[mergeCellRecords.Count]; _mergedCellsRecords = (MergeCellsRecord[])mergeCellRecords.ToArray(typeof(MergeCellsRecord)); }
/// <summary> /// Initializes a new instance of the <see cref="PdbArrayType"/> class. /// </summary> /// <param name="pdb">The PDB file reader.</param> /// <param name="typeIndex">Type index.</param> /// <param name="arrayRecord">The array record.</param> /// <param name="modifierOptions">The modifier options.</param> internal PdbArrayType(PdbFileReader pdb, TypeIndex typeIndex, ArrayRecord arrayRecord, ModifierOptions modifierOptions) : base(pdb, typeIndex, modifierOptions, GetTypeName(pdb, arrayRecord), arrayRecord.Size) { ArrayRecord = arrayRecord; }
public void Read(ArrayRecord arrRec) { Console.WriteLine("Array " + arrRec.SequenceNo); }