private RowRecordsAggregate(SharedValueManager svm) { _rowRecords = new SortedList(); _valuesAgg = new ValueRecordsAggregate(); _unknownRecords = new ArrayList(); _sharedValueManager = svm; }
private RowRecordsAggregate(SharedValueManager svm) { _rowRecords = new SortedList(); _valuesAgg = new ValueRecordsAggregate(); _unknownRecords = new List <Record>(); _sharedValueManager = svm; }
/** * @param rs record stream with all {@link SharedFormulaRecord} * {@link ArrayRecord}, {@link TableRecord} {@link MergeCellsRecord} Records removed */ public RowRecordsAggregate(RecordStream rs, SharedValueManager svm) : this(svm) { while (rs.HasNext()) { Record rec = rs.GetNext(); switch (rec.Sid) { case RowRecord.sid: InsertRow((RowRecord)rec); continue; case DConRefRecord.sid: AddUnknownRecord(rec); continue; case HyperlinkRecord.sid: _hyperlinkRecordRecords.Add((HyperlinkRecord)rec); continue; case DBCellRecord.sid: // end of 'Row Block'. Should only occur after cell records // ignore DBCELL records because POI generates them upon re-serialization continue; } if (rec is UnknownRecord) { // might need to keep track of where exactly these belong AddUnknownRecord((UnknownRecord)rec); while (rs.PeekNextSid() == ContinueRecord.sid) { AddUnknownRecord(rs.GetNext()); } continue; } if (rec is MulBlankRecord) { _valuesAgg.AddMultipleBlanks((MulBlankRecord)rec); continue; } if (!(rec is CellValueRecordInterface)) { //TODO: correct it, SeriesIndexRecord will appear in a separate chart sheet that contains a single chart // rule SERIESDATA = Dimensions 3(SIIndex *(Number / BoolErr / Blank / Label)) if (rec.Sid == SeriesIndexRecord.sid) { AddUnknownRecord(rec); continue; } throw new InvalidOperationException("Unexpected record type (" + rec.GetType().Name + ")"); } _valuesAgg.Construct((CellValueRecordInterface)rec, rs, svm); } }
/** * @param rs record stream with all {@link SharedFormulaRecord} * {@link ArrayRecord}, {@link TableRecord} {@link MergeCellsRecord} Records removed */ public RowRecordsAggregate(RecordStream rs, SharedValueManager svm) : this(svm) { while (rs.HasNext()) { Record rec = rs.GetNext(); switch (rec.Sid) { case RowRecord.sid: InsertRow((RowRecord)rec); continue; case DBCellRecord.sid: // end of 'Row Block'. Should only occur after cell records // ignore DBCELL records because POI generates them upon re-serialization continue; } if (rec is UnknownRecord) { // might need to keep track of where exactly these belong AddUnknownRecord((UnknownRecord)rec); while (rs.PeekNextSid() == ContinueRecord.sid) { AddUnknownRecord(rs.GetNext()); } continue; } if (rec is MulBlankRecord) { _valuesAgg.AddMultipleBlanks((MulBlankRecord)rec); continue; } if (!(rec is CellValueRecordInterface)) { throw new InvalidOperationException("Unexpected record type (" + rec.GetType().Name + ")"); } _valuesAgg.Construct((CellValueRecordInterface)rec, rs, svm); } }
/** * @param rs record stream with all {@link SharedFormulaRecord} * {@link ArrayRecord}, {@link TableRecord} {@link MergeCellsRecord} Records removed */ public RowRecordsAggregate(RecordStream rs, SharedValueManager svm) : this(svm) { while (rs.HasNext()) { Record rec = rs.GetNext(); switch (rec.Sid) { case RowRecord.sid: InsertRow((RowRecord)rec); continue; case DBCellRecord.sid: // end of 'Row Block'. Should only occur after cell records // ignore DBCELL records because POI generates them upon re-serialization continue; } if (rec is UnknownRecord) { // might need to keep track of where exactly these belong AddUnknownRecord((UnknownRecord)rec); while (rs.PeekNextSid() == ContinueRecord.sid) { AddUnknownRecord(rs.GetNext()); } continue; } if (rec is MulBlankRecord) { _valuesAgg.AddMultipleBlanks((MulBlankRecord) rec); continue; } if (!(rec is CellValueRecordInterface)) { throw new InvalidOperationException("Unexpected record type (" + rec.GetType().Name + ")"); } _valuesAgg.Construct((CellValueRecordInterface)rec, rs, svm); } }
public void Construct(CellValueRecordInterface rec, RecordStream rs, SharedValueManager sfh) { if (rec is FormulaRecord) { FormulaRecord formulaRec = (FormulaRecord)rec; // read optional cached text value StringRecord cachedText = null; Type nextClass = rs.PeekNextClass(); if (nextClass == typeof(StringRecord)) { cachedText = (StringRecord)rs.GetNext(); } else { cachedText = null; } InsertCell(new FormulaRecordAggregate(formulaRec, cachedText, sfh)); } else { InsertCell(rec); } }
/// <summary> /// Initializes a new instance of the <see cref="FormulaRecordAggregate"/> class. /// </summary> /// <param name="formulaRec">The formula rec.</param> /// <param name="stringRec">The string rec.</param> /// <param name="svm">The SVM.</param> public FormulaRecordAggregate(FormulaRecord formulaRec, StringRecord stringRec, SharedValueManager svm) { if (svm == null) { throw new ArgumentException("sfm must not be null"); } bool hasStringRec = stringRec != null; bool hasCachedStringFlag = formulaRec.HasCachedResultString; if (hasStringRec != hasCachedStringFlag) { throw new RecordFormatException("String record was " + (hasStringRec ? "" : "not ") + " supplied but formula record flag is " + (hasCachedStringFlag ? "" : "not ") + " set"); } if (formulaRec.IsSharedFormula) { svm.ConvertSharedFormulaRecord(formulaRec); } _formulaRecord = formulaRec; _sharedValueManager = svm; _stringRecord = stringRec; }
/// <summary> /// Initializes a new instance of the <see cref="FormulaRecordAggregate"/> class. /// </summary> /// <param name="formulaRec">The formula rec.</param> /// <param name="stringRec">The string rec.</param> /// <param name="svm">The SVM.</param> public FormulaRecordAggregate(FormulaRecord formulaRec, StringRecord stringRec, SharedValueManager svm) { if (svm == null) { throw new ArgumentException("sfm must not be null"); } if (formulaRec.HasCachedResultString) { if (stringRec == null) { throw new RecordFormatException("Formula record flag is set but String record was not found"); } _stringRecord = stringRec; } else { // Usually stringRec is null here (in agreement with what the formula rec says). // In the case where an extra StringRecord is erroneously present, Excel (2007) // ignores it (see bug 46213). _stringRecord = null; } _formulaRecord = formulaRec; _sharedValueManager = svm; if (formulaRec.IsSharedFormula) { CellReference firstCell = formulaRec.Formula.ExpReference; if (firstCell == null) { HandleMissingSharedFormulaRecord(formulaRec); } else { _sharedFormulaRecord = svm.LinkSharedFormulaRecord(firstCell, this); } } }
public void Construct(CellValueRecordInterface rec, RecordStream rs, SharedValueManager sfh) { if (rec is FormulaRecord) { FormulaRecord formulaRec = (FormulaRecord)rec; // read optional cached text value StringRecord cachedText=null; Type nextClass = rs.PeekNextClass(); if (nextClass == typeof(StringRecord)) { cachedText = (StringRecord)rs.GetNext(); } else { cachedText = null; } InsertCell(new FormulaRecordAggregate(formulaRec, cachedText, sfh)); } else { InsertCell(rec); } }
/** * @param rs record stream with all {@link SharedFormulaRecord} * {@link ArrayRecord}, {@link TableRecord} {@link MergeCellsRecord} Records removed */ public RowRecordsAggregate(RecordStream rs, SharedValueManager svm) : this(svm) { while (rs.HasNext()) { Record rec = rs.GetNext(); switch (rec.Sid) { case RowRecord.sid: InsertRow((RowRecord)rec); continue; case DConRefRecord.sid: AddUnknownRecord(rec); continue; case DBCellRecord.sid: // end of 'Row Block'. Should only occur after cell records // ignore DBCELL records because POI generates them upon re-serialization continue; } if (rec is UnknownRecord) { // might need to keep track of where exactly these belong AddUnknownRecord((UnknownRecord)rec); while (rs.PeekNextSid() == ContinueRecord.sid) { AddUnknownRecord(rs.GetNext()); } continue; } if (rec is MulBlankRecord) { _valuesAgg.AddMultipleBlanks((MulBlankRecord) rec); continue; } if (!(rec is CellValueRecordInterface)) { //TODO: correct it, SeriesIndexRecord will appear in a separate chart sheet that contains a single chart // rule SERIESDATA = Dimensions 3(SIIndex *(Number / BoolErr / Blank / Label)) if (rec.Sid == SeriesIndexRecord.sid) { AddUnknownRecord(rec); continue; } throw new InvalidOperationException("Unexpected record type (" + rec.GetType().Name + ")"); } _valuesAgg.Construct((CellValueRecordInterface)rec, rs, svm); } }
/** * 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]; List<ArrayRecord> arrayRecs = new List<ArrayRecord>(arrayRecords.Count); List<TableRecord> tableRecs = new List<TableRecord>(tableRecords.Count); sharedFormulaRecs = (SharedFormulaRecord[])shFrmRecords.ToArray(typeof(SharedFormulaRecord)); CellReference[] firstCells = new CellReference[firstCellRefs.Count]; firstCells=firstCellRefs.ToArray(); arrayRecs = new List<ArrayRecord>((ArrayRecord[])arrayRecords.ToArray(typeof(ArrayRecord))); tableRecs = new List<TableRecord>((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)); }
/** * 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(); 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(); IList dest; switch (rec.Sid) { case MergeCellsRecord.sid: dest = mergeCellRecords; break; case SharedFormulaRecord.sid: dest = shFrmRecords; break; case ArrayRecord.sid: dest = arrayRecords; break; case TableRecord.sid: dest = tableRecords; break; default: dest = plainRecords; break; } dest.Add(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)); arrayRecs = (ArrayRecord[])arrayRecords.ToArray(typeof(ArrayRecord)); tableRecs = (TableRecord[])tableRecords.ToArray(typeof(TableRecord)); _plainRecords = plainRecords; _sfm = SharedValueManager.Create(sharedFormulaRecs, arrayRecs, tableRecs); _mergedCellsRecords = new MergeCellsRecord[mergeCellRecords.Count]; _mergedCellsRecords = (MergeCellsRecord[])mergeCellRecords.ToArray(typeof(MergeCellsRecord)); }
/** Creates a new instance of ValueRecordsAggregate */ public RowRecordsAggregate() : this(SharedValueManager.CreateEmpty()) { }