private SharedValueManager(SharedFormulaRecord[] sharedFormulaRecords, ArrayRecord[] arrayRecords, TableRecord[] tableRecords) { _sfrs = sharedFormulaRecords; _arrayRecords = arrayRecords; _tableRecords = tableRecords; }
public override Object Clone() { SharedFormulaRecord result = new SharedFormulaRecord(Range); result.field_5_reserved = field_5_reserved; result.field_7_parsed_expr = field_7_parsed_expr.Copy(); return(result); }
/** * @param recs list of sheet records (possibly contains records for other parts of the Excel file) * @param startIx index of first row/cell record for current sheet * @param endIx one past index of last row/cell record for current sheet. It is important * that this code does not inadvertently collect <tt>SharedFormulaRecord</tt>s from any other * sheet (which could happen if endIx is chosen poorly). (see bug 44449) */ public static SharedValueManager Create(SharedFormulaRecord[] sharedFormulaRecords, ArrayRecord[] arrayRecords, TableRecord[] tableRecords) { if (sharedFormulaRecords.Length + arrayRecords.Length + tableRecords.Length < 1) { return EMPTY; } return new SharedValueManager(sharedFormulaRecords, arrayRecords, tableRecords); }
/** * 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)); }
/// <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 UnlinkSharedFormula() { SharedFormulaRecord sfr = _sharedFormulaRecord; if (sfr == null) { throw new InvalidOperationException("Formula not linked to shared formula"); } Ptg[] ptgs = sfr.GetFormulaTokens(_formulaRecord); _formulaRecord.SetParsedExpression(ptgs); //Now its not shared! _formulaRecord.SetSharedFormula(false); _sharedFormulaRecord = null; }
public bool IsFormulaSame(SharedFormulaRecord other) { return(field_7_parsed_expr.IsSame(other.field_7_parsed_expr)); }
/** * 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)); }
public bool IsFormulaSame(SharedFormulaRecord other) { return field_7_parsed_expr.IsSame(other.field_7_parsed_expr); }
public override Object Clone() { SharedFormulaRecord result = new SharedFormulaRecord(Range); result.field_5_reserved = field_5_reserved; result.field_7_parsed_expr = field_7_parsed_expr.Copy(); return result; }