// TODO make this class into a record aggregate private static ExternSheetRecord ReadExtSheetRecord(RecordStream rs) { List <ExternSheetRecord> temp = new List <ExternSheetRecord>(2); while (rs.PeekNextClass() == typeof(ExternSheetRecord)) { temp.Add((ExternSheetRecord)rs.GetNext()); } int nItems = temp.Count; if (nItems < 1) { throw new Exception("Expected an EXTERNSHEET record but got (" + rs.PeekNextClass().Name + ")"); } if (nItems == 1) { // this is the normal case. There should be just one ExternSheetRecord return(temp[0]); } // Some apps generate multiple ExternSheetRecords (see bug 45698). // It seems like the best thing to do might be to combine these into one ExternSheetRecord[] esrs = new ExternSheetRecord[nItems]; esrs = temp.ToArray(); return(ExternSheetRecord.Combine(esrs)); }
public ExternalBookBlock(RecordStream rs) { _externalBookRecord = (SupBookRecord)rs.GetNext(); List <object> temp = new List <object>(); while (rs.PeekNextClass() == typeof(ExternalNameRecord)) { temp.Add(rs.GetNext()); } _externalNameRecords = (ExternalNameRecord[])temp.ToArray(); temp.Clear(); while (rs.PeekNextClass() == typeof(CRNCountRecord)) { temp.Add(new CRNBlock(rs)); } _crnBlocks = (CRNBlock[])temp.ToArray(); }
private WorkbookRecordList _workbookRecordList; // TODO - would be nice to Remove this public LinkTable(List <Record> inputList, int startIndex, WorkbookRecordList workbookRecordList, Dictionary <String, NameCommentRecord> commentRecords) { _workbookRecordList = workbookRecordList; RecordStream rs = new RecordStream(inputList, startIndex); List <object> temp = new List <object>(); while (rs.PeekNextClass() == typeof(SupBookRecord)) { temp.Add(new ExternalBookBlock(rs)); } //_externalBookBlocks = new ExternalBookBlock[temp.Count]; _externalBookBlocks = (ExternalBookBlock[])temp.ToArray(); temp.Clear(); if (_externalBookBlocks.Length > 0) { // If any ExternalBookBlock present, there is always 1 of ExternSheetRecord if (rs.PeekNextClass() != typeof(ExternSheetRecord)) { // not quite - if written by google docs _externSheetRecord = null; } else { _externSheetRecord = ReadExtSheetRecord(rs); } } else { _externSheetRecord = null; } _definedNames = new List <NameRecord>(); // collect zero or more DEFINEDNAMEs id=0x18 while (true) { Type nextClass = rs.PeekNextClass(); if (nextClass == typeof(NameRecord)) { NameRecord nr = (NameRecord)rs.GetNext(); _definedNames.Add(nr); } else if (nextClass == typeof(NameCommentRecord)) { NameCommentRecord ncr = (NameCommentRecord)rs.GetNext(); //commentRecords.Add(ncr.NameText, ncr); commentRecords[ncr.NameText] = ncr; } else { break; } } _recordCount = rs.GetCountRead(); for (int i = startIndex; i < startIndex + _recordCount; i++) { _workbookRecordList.Records.Add(inputList[i]); } }