public ChartSubstreamRecordAggregate(RecordStream rs) { _bofRec = (BOFRecord)rs.GetNext(); List<RecordBase> temp = new List<RecordBase>(); while (rs.PeekNextClass() != typeof(EOFRecord)) { Type a = rs.PeekNextClass(); if (PageSettingsBlock.IsComponentRecord(rs.PeekNextSid())) { if (_psBlock != null) { if (rs.PeekNextSid() == HeaderFooterRecord.sid) { // test samples: 45538_classic_Footer.xls, 45538_classic_Header.xls _psBlock.AddLateHeaderFooter((HeaderFooterRecord)rs.GetNext()); continue; } throw new InvalidDataException( "Found more than one PageSettingsBlock in chart sub-stream"); } _psBlock = new PageSettingsBlock(rs); temp.Add(_psBlock); continue; } temp.Add(rs.GetNext()); } _recs = temp; Record eof = rs.GetNext(); // no need to save EOF in field if (!(eof is EOFRecord)) { throw new InvalidOperationException("Bad chart EOF"); } }
public DVAxisAggregate(RecordStream rs, ChartRecordAggregate container, AxisRecord axis) : base(RuleName_DVAXIS, container) { if (axis == null) { this.axis = (AxisRecord)rs.GetNext(); rs.GetNext(); } else { this.axis = axis; } if (rs.PeekNextChartSid() == ValueRangeRecord.sid) valueRange = (ValueRangeRecord)rs.GetNext(); if (rs.PeekNextChartSid() == YMultRecord.sid) axm = new AXMAggregate(rs, this); axs = new AXSAggregate(rs, this); if (rs.PeekNextChartSid() == CrtMlFrtRecord.sid) crtmlfrt = new CrtMlFrtAggregate(rs, this); Record r = rs.GetNext();//EndRecord Debug.Assert(r.GetType() == typeof(EndRecord)); }
public void TestAbnormalPivotTableRecords_bug46280() { int SXVIEW_SID = ViewDefinitionRecord.sid; Record[] inRecs = { new RowRecord(0), new NumberRecord(), // normally MSODRAWING(0x00EC) would come here before SXVIEW new UnknownRecord(SXVIEW_SID, System.Text.Encoding.UTF8.GetBytes("dummydata (SXVIEW: View DefInition)")), new WindowTwoRecord(), }; RecordStream rs = new RecordStream(Arrays.AsList(inRecs), 0); RowBlocksReader rbr = new RowBlocksReader(rs); if (rs.PeekNextClass() == typeof(WindowTwoRecord)) { // Should have stopped at the SXVIEW record throw new AssertionException("Identified bug 46280b"); } RecordStream rbStream = rbr.PlainRecordStream; Assert.AreEqual(inRecs[0], rbStream.GetNext()); Assert.AreEqual(inRecs[1], rbStream.GetNext()); Assert.IsFalse(rbStream.HasNext()); Assert.IsTrue(rs.HasNext()); Assert.AreEqual(inRecs[2], rs.GetNext()); Assert.AreEqual(inRecs[3], rs.GetNext()); }
// 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)); }
// 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); }
private bool ReadARecord(RecordStream rs) { switch (rs.PeekNextSid()) { case ProtectRecord.sid: CheckNotPresent(_protectRecord); _protectRecord = rs.GetNext() as ProtectRecord; break; case ObjectProtectRecord.sid: CheckNotPresent(_objectProtectRecord); _objectProtectRecord = rs.GetNext() as ObjectProtectRecord; break; case ScenarioProtectRecord.sid: CheckNotPresent(_scenarioProtectRecord); _scenarioProtectRecord = rs.GetNext() as ScenarioProtectRecord; break; case PasswordRecord.sid: CheckNotPresent(_passwordRecord); _passwordRecord = rs.GetNext() as PasswordRecord; break; default: // all other record types are not part of the PageSettingsBlock return false; } return true; }
public void TestAbnormalPivotTableRecords_bug46280() { int SXVIEW_SID = ViewDefinitionRecord.sid; Record[] inRecs = { new RowRecord(0), new NumberRecord(), // normally MSODRAWING(0x00EC) would come here before SXVIEW new UnknownRecord(SXVIEW_SID,System.Text.Encoding.UTF8.GetBytes("dummydata (SXVIEW: View DefInition)")), new WindowTwoRecord(), }; RecordStream rs = new RecordStream(Arrays.AsList(inRecs), 0); RowBlocksReader rbr = new RowBlocksReader(rs); if (rs.PeekNextClass() == typeof(WindowTwoRecord)) { // Should have stopped at the SXVIEW record throw new AssertFailedException("Identified bug 46280b"); } RecordStream rbStream = rbr.PlainRecordStream; Assert.AreEqual(inRecs[0], rbStream.GetNext()); Assert.AreEqual(inRecs[1], rbStream.GetNext()); Assert.IsFalse(rbStream.HasNext()); Assert.IsTrue(rs.HasNext()); Assert.AreEqual(inRecs[2], rs.GetNext()); Assert.AreEqual(inRecs[3], rs.GetNext()); }
public AxisParentAggregate(RecordStream rs, ChartRecordAggregate container) : base(RuleName_AXISPARENT, container) { axisPraent = (AxisParentRecord)rs.GetNext(); rs.GetNext(); pos = (PosRecord)rs.GetNext(); if (ChartFormatRecord.sid != rs.PeekNextChartSid()) { try { axes = new AxesAggregate(rs, this); } catch { Debug.Print("not find axes rule records"); axes = null; } } Debug.Assert(ChartFormatRecord.sid == rs.PeekNextChartSid()); while (ChartFormatRecord.sid == rs.PeekNextChartSid()) { crtList.Add(new CRTAggregate(rs, this)); } Record r = rs.GetNext();//EndRecord Debug.Assert(r.GetType() == typeof(EndRecord)); }
public CustomViewSettingsRecordAggregate(RecordStream rs) { _begin = rs.GetNext(); if (_begin.Sid != UserSViewBegin.sid) { throw new InvalidOperationException("Bad begin record"); } List<RecordBase> temp = new List<RecordBase>(); while (rs.PeekNextSid() != UserSViewEnd.sid) { if (PageSettingsBlock.IsComponentRecord(rs.PeekNextSid())) { if (_psBlock != null) { throw new InvalidOperationException( "Found more than one PageSettingsBlock in custom view Settings sub-stream"); } _psBlock = new PageSettingsBlock(rs); temp.Add(_psBlock); continue; } temp.Add(rs.GetNext()); } _recs = temp; _end = rs.GetNext(); // no need to save EOF in field if (_end.Sid != UserSViewEnd.sid) { throw new InvalidOperationException("Bad custom view Settings end record"); } }
public GelFrameAggregate(RecordStream rs, ChartRecordAggregate container) : base(RuleName_GELFRAME, container) { gelFrame1 = (GelFrameRecord)rs.GetNext(); int sid = rs.PeekNextChartSid(); if (sid == GelFrameRecord.sid) { gelFrame2 = (GelFrameRecord)rs.GetNext(); sid = rs.PeekNextChartSid(); } if (sid == ContinueRecord.sid) { while (rs.PeekNextChartSid() == ContinueRecord.sid) { continues.Add((ContinueRecord)rs.GetNext()); } } if (rs.PeekNextChartSid() == BeginRecord.sid) { rs.GetNext(); picF = (PicFRecord)rs.GetNext(); Record r = rs.GetNext();//EndRecord Debug.Assert(r.GetType() == typeof(EndRecord)); } }
public LDAggregate(RecordStream rs, ChartRecordAggregate container) :base(RuleName_LD, container) { legend = (LegendRecord)rs.GetNext(); rs.GetNext();//BeginRecord pos = (PosRecord)rs.GetNext(); attachedLabel = new AttachedLabelAggregate(rs, this); if (rs.PeekNextChartSid() == FrameRecord.sid) { frame = new FrameAggregate(rs, this); } if (rs.PeekNextChartSid() == CrtLayout12Record.sid) { crtLayout = (CrtLayout12Record)rs.GetNext(); } if (rs.PeekNextChartSid() == TextPropsStreamRecord.sid) { textProps = new TextPropsAggregate(rs, this); } if (rs.PeekNextChartSid() == CrtMlFrtRecord.sid) { crtMlFrt = new CrtMlFrtAggregate(rs, this); } Record r = rs.GetNext();//EndRecord Debug.Assert(r.GetType() == typeof(EndRecord)); }
public ConditionalFormattingTable(RecordStream rs) { IList temp = new ArrayList(); while (rs.PeekNextClass() == typeof(CFHeaderRecord)) { temp.Add(CFRecordsAggregate.CreateCFAggregate(rs)); } _cfHeaders = temp; }
public AXMAggregate(RecordStream rs, ChartRecordAggregate container) : base(RuleName_AXM, container) { yMult = (YMultRecord)rs.GetNext(); startObject = (ChartStartObjectRecord)rs.GetNext(); attachedLabel = new AttachedLabelAggregate(rs, this); endObject = (ChartEndObjectRecord)rs.GetNext(); }
public DatAggregate(RecordStream rs, ChartRecordAggregate container) : base(RuleName_DAT, container) { dat = (DatRecord)rs.GetNext(); rs.GetNext(); ld = new LDAggregate(rs, this); Record r = rs.GetNext();//EndRecord Debug.Assert(r.GetType() == typeof(EndRecord)); }
public DataValidityTable(RecordStream rs) { _headerRec = (DVALRecord)rs.GetNext(); IList temp = new ArrayList(); while (rs.PeekNextClass() == typeof(DVRecord)) { temp.Add(rs.GetNext()); } _validationList = temp; }
public CRNBlock(RecordStream rs) { _countRecord = (CRNCountRecord)rs.GetNext(); int nCRNs = _countRecord.NumberOfCRNs; CRNRecord[] crns = new CRNRecord[nCRNs]; for (int i = 0; i < crns.Length; i++) { crns[i] = (CRNRecord)rs.GetNext(); } _crns = crns; }
public CrtMlFrtAggregate(RecordStream rs, ChartRecordAggregate container) : base(RuleName_CRTMLFRT, container) { crtmlFrt = (CrtMlFrtRecord)rs.GetNext(); if (rs.PeekNextChartSid() == CrtMlFrtContinueRecord.sid) { while (rs.PeekNextChartSid() == CrtMlFrtContinueRecord.sid) { continues.Add((CrtMlFrtContinueRecord)rs.GetNext()); } } }
public ShapePropsAggregate(RecordStream rs, ChartRecordAggregate container) : base(RuleName_SHAPEPROPS, container) { shapProps = (ShapePropsStreamRecord)rs.GetNext(); if (rs.PeekNextChartSid() == CrtMlFrtContinueRecord.sid) { while (rs.PeekNextChartSid() == CrtMlFrtContinueRecord.sid) { continues.Add((ContinueFrt12Record)rs.GetNext()); } } }
/** * 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)); }
/** * Reads zero or more consecutive {@link MergeCellsRecord}s * @param rs */ public void Read(RecordStream rs) { IList temp = _mergedRegions; while (rs.PeekNextClass() == typeof(MergeCellsRecord)) { MergeCellsRecord mcr = (MergeCellsRecord)rs.GetNext(); int nRegions = mcr.NumAreas; for (int i = 0; i < nRegions; i++) { temp.Add(mcr.GetAreaAt(i)); } } }
public SeriesFormatAggregate(RecordStream rs, ChartRecordAggregate container) : base(RuleName_SERIESFORMAT, container) { series = (SeriesRecord)rs.GetNext(); rs.GetNext(); BRAIRecord ai; SeriesTextRecord sText; while (rs.PeekNextChartSid() == BRAIRecord.sid) { sText = null; ai = (BRAIRecord)rs.GetNext(); if (rs.PeekNextChartSid() == SeriesTextRecord.sid) sText = (SeriesTextRecord)rs.GetNext(); dic4AI.Add(ai, sText); } if (rs.PeekNextChartSid() == DataFormatRecord.sid) { while (rs.PeekNextChartSid() == DataFormatRecord.sid) ssList.Add(new SSAggregate(rs, this)); } if (rs.PeekNextChartSid() == SerToCrtRecord.sid) { serToCrt = (SerToCrtRecord)rs.GetNext(); } else { if (rs.PeekNextChartSid() == SerParentRecord.sid) { serParent = (SerParentRecord)rs.GetNext(); if (rs.PeekNextChartSid() == SerAuxTrendRecord.sid) { serAuxTrend = (SerAuxTrendRecord)rs.GetNext(); } else { serAuxErrBar = (SerAuxErrBarRecord)rs.GetNext(); } } } if (rs.PeekNextChartSid() == LegendExceptionRecord.sid) { while (rs.PeekNextChartSid() == LegendExceptionRecord.sid) { leList.Add(new LegendExceptionAggregate(rs, this)); } } Record r = rs.GetNext();//EndRecord Debug.Assert(r.GetType() == typeof(EndRecord)); }
public DFTTextAggregate(RecordStream rs, ChartRecordAggregate container) : base(RuleName_DFTTEXT, container) { if (rs.PeekNextChartSid() == DataLabExtRecord.sid) { dataLabExt = (DataLabExtRecord)rs.GetNext(); startObject = (ChartStartObjectRecord)rs.GetNext(); } defaultText = (DefaultTextRecord)rs.GetNext(); attachedLabel = new AttachedLabelAggregate(rs, this); if (startObject != null) endObject = (ChartEndObjectRecord)rs.GetNext(); }
public AttachedLabelAggregate(RecordStream rs, ChartRecordAggregate container) : base(RuleName_ATTACHEDLABEL, container) { ChartSheetAggregate cs = GetContainer<ChartSheetAggregate>(ChartRecordAggregate.RuleName_CHARTSHEET); IsFirst = cs.AttachLabelCount == 0; cs.AttachLabelCount++; text = (TextRecord)rs.GetNext(); rs.GetNext();//BeginRecord pos = (PosRecord)rs.GetNext(); if (rs.PeekNextChartSid() == FontXRecord.sid) { fontX = (FontXRecord)rs.GetNext(); } if (rs.PeekNextChartSid() == AlRunsRecord.sid) { alRuns = (AlRunsRecord)rs.GetNext(); } brai = (BRAIRecord)rs.GetNext(); if (rs.PeekNextChartSid() == SeriesTextRecord.sid) { seriesText = (SeriesTextRecord)rs.GetNext(); } if (rs.PeekNextChartSid() == FrameRecord.sid) { frame = new FrameAggregate(rs, this); } if (rs.PeekNextChartSid() == ObjectLinkRecord.sid) { objectLink = (ObjectLinkRecord)rs.GetNext(); } if (rs.PeekNextChartSid() == DataLabExtContentsRecord.sid) { dataLab = (DataLabExtContentsRecord)rs.GetNext(); } if (rs.PeekNextChartSid() == CrtLayout12Record.sid) { crtLayout = (CrtLayout12Record)rs.GetNext(); } if (rs.PeekNextChartSid() == TextPropsStreamRecord.sid) { textProps = new TextPropsAggregate(rs, this); } if (rs.PeekNextChartSid() == CrtMlFrtRecord.sid) { crtMlFrt = new CrtMlFrtAggregate(rs, this); } Record r = rs.GetNext();//EndRecord Debug.Assert(r.GetType() == typeof(EndRecord)); }
public SeriesDataAggregate(RecordStream rs) { dimensions = (DimensionsRecord)rs.GetNext(); while (rs.PeekNextChartSid() == SeriesIndexRecord.sid) { SeriesIndexRecord siIndex = (SeriesIndexRecord)rs.GetNext(); int sid = rs.PeekNextChartSid(); List<Record> dataList = new List<Record>(); while (sid == NumberRecord.sid || sid == BoolErrRecord.sid || sid == BlankRecord.sid || sid == LabelRecord.sid) { dataList.Add(rs.GetNext()); } dicData.Add(siIndex, dataList); } }
private WorkbookRecordList _workbookRecordList; // TODO - would be nice to Remove this public LinkTable(List <Record> inputList, int startIndex, WorkbookRecordList workbookRecordList) { _workbookRecordList = workbookRecordList; RecordStream rs = new RecordStream(inputList, startIndex); ArrayList temp = new ArrayList(); while (rs.PeekNextClass() == typeof(SupBookRecord)) { temp.Add(new ExternalBookBlock(rs)); } //_externalBookBlocks = new ExternalBookBlock[temp.Count]; _externalBookBlocks = (ExternalBookBlock[])temp.ToArray(typeof(ExternalBookBlock)); 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 (rs.PeekNextClass() == typeof(NameRecord)) { NameRecord nr = (NameRecord)rs.GetNext(); _definedNames.Add(nr); } _recordCount = rs.GetCountRead(); for (int i = startIndex; i < startIndex + _recordCount; i++) { _workbookRecordList.Records.Add(inputList[i]); } }
public SeriesAxisAggregate(RecordStream rs, ChartRecordAggregate container) : base("SERIESAXIS", container) { axis = (AxisRecord)rs.GetNext(); rs.GetNext(); if (rs.PeekNextChartSid() == CatSerRangeRecord.sid) catSerRange = (CatSerRangeRecord)rs.GetNext(); axs = new AXSAggregate(rs, this); if (rs.PeekNextChartSid() == CrtMlFrtRecord.sid) crtmlfrt = new CrtMlFrtAggregate(rs, this); Record r = rs.GetNext();//EndRecord Debug.Assert(r.GetType() == typeof(EndRecord)); }
public TextPropsAggregate(RecordStream rs, ChartRecordAggregate container) : base(RuleName_TEXTPROPS, container) { if (rs.PeekNextChartSid() == TextPropsStreamRecord.sid) textPropsStream = (TextPropsStreamRecord)rs.GetNext(); else richTextStream = (RichTextStreamRecord)rs.GetNext(); if (rs.PeekNextChartSid() == ContinueFrt12Record.sid) { while (rs.PeekNextChartSid() == ContinueFrt12Record.sid) { continues.Add((ContinueFrt12Record)rs.GetNext()); } } }
public ChartSheetAggregate(RecordStream rs, ChartRecordAggregate container) : base(RuleName_CHARTSHEET, container) { _bofRec = (BOFRecord)rs.GetNext(); List<RecordBase> temp = new List<RecordBase>(); while (rs.PeekNextClass() != typeof(EOFRecord)) { Type a = rs.PeekNextClass(); if (PageSettingsBlock.IsComponentRecord(rs.PeekNextChartSid())) { if (_psBlock != null) { if (rs.PeekNextChartSid() == HeaderFooterRecord.sid) { // test samples: 45538_classic_Footer.xls, 45538_classic_Header.xls _psBlock.AddLateHeaderFooter((HeaderFooterRecord)rs.GetNext()); continue; } throw new InvalidDataException( "Found more than one PageSettingsBlock in chart sub-stream"); } _psBlock = new PageSettingsBlock(rs); temp.Add(_psBlock); continue; } if (rs.PeekNextChartSid() == ChartRecord.sid) { chartFormats = new ChartFormatsAggregate(rs, this); temp.Add(chartFormats); continue; } if (rs.PeekNextChartSid() == DimensionsRecord.sid) { seriesData = new SeriesDataAggregate(rs); temp.Add(seriesData); continue; } temp.Add(rs.GetNext()); } _recs = temp; Record eof = rs.GetNext(); // no need to save EOF in field if (!(eof is EOFRecord)) { throw new InvalidOperationException("Bad chart EOF"); } }
public CRTAggregate(RecordStream rs, ChartRecordAggregate container) : base(RuleName_CRT, container) { chartForamt = (ChartFormatRecord)rs.GetNext(); rs.GetNext(); chartTypeRecord = rs.GetNext(); if (rs.PeekNextChartSid() == BopPopCustomRecord.sid) bopPopCustom = (BopPopCustomRecord)rs.GetNext(); crtLink = (CrtLinkRecord)rs.GetNext(); if (rs.PeekNextChartSid() == SeriesListRecord.sid) seriesList = (SeriesListRecord)rs.GetNext(); if (rs.PeekNextChartSid() == Chart3dRecord.sid) chart3d = (Chart3dRecord)rs.GetNext(); if (rs.PeekNextChartSid() == LegendRecord.sid) ld = new LDAggregate(rs, this); if (rs.PeekNextChartSid() == DropBarRecord.sid) { dropBar1 = new DropBarAggregate(rs, this); dropBar2 = new DropBarAggregate(rs, this); } while (rs.PeekNextChartSid() == CrtLineRecord.sid) { dicLines.Add((CrtLineRecord)rs.GetNext(), (LineFormatRecord)rs.GetNext()); } if (rs.PeekNextChartSid() == DataLabExtRecord.sid || rs.PeekNextChartSid() == DefaultTextRecord.sid) { dft1 = new DFTTextAggregate(rs, this); if (rs.PeekNextChartSid() == DataLabExtRecord.sid || rs.PeekNextChartSid() == DefaultTextRecord.sid) { dft2 = new DFTTextAggregate(rs, this); } } if (rs.PeekNextChartSid() == DataLabExtContentsRecord.sid) dataLabExtContents = (DataLabExtContentsRecord)rs.GetNext(); if (rs.PeekNextChartSid() == DataFormatRecord.sid) ss = new SSAggregate(rs, this); while (rs.PeekNextChartSid() == ShapePropsStreamRecord.sid) shapeList.Add(new ShapePropsAggregate(rs, this)); rs.GetNext(); }
public PLSAggregate(RecordStream rs) { _pls = rs.GetNext(); if (rs.PeekNextSid() == ContinueRecord.sid) { List<ContinueRecord> temp = new List<ContinueRecord>(); while (rs.PeekNextSid() == ContinueRecord.sid) { temp.Add((ContinueRecord)rs.GetNext()); } _plsContinues = new ContinueRecord[temp.Count]; _plsContinues = temp.ToArray(); } else { _plsContinues = EMPTY_CONTINUE_RECORD_ARRAY; } }
public void TestStartBlock_EndBlock_Write() { HSSFWorkbook wb = HSSFTestDataSamples.OpenSampleWorkbook("chartdemo.xls"); Record[] sheetRecs = RecordInspector.GetRecords(wb.GetSheetAt(0), 0); RecordStream rs = new RecordStream(Arrays.AsList(sheetRecs), 0); rs.FindChartSubStream(); int pos = rs.GetCountRead(); ChartSheetAggregate csAgg = new ChartSheetAggregate(rs, null); RecordInspector.RecordCollector rv = new RecordInspector.RecordCollector(); csAgg.VisitContainedRecords(rv); Record[] outRecs = rv.Records; for (int i = 0; i < outRecs.Length; i++) { Assert.AreEqual(sheetRecs[pos + i].GetType(), outRecs[i].GetType()); } }
public void testMCTable_bug46009() { MergedCellsTable mct = new MergedCellsTable(); ArrayList recList = new ArrayList(); CellRangeAddress[] cras = new CellRangeAddress[] { new CellRangeAddress(0, 0, 0, 3), }; recList.Add(new MergeCellsRecord(cras, 0, 1)); RecordStream rs = new RecordStream(recList, 0); mct.Read(rs); try { mct.VisitContainedRecords(dummyRecordVisitor); } catch (Exception) { throw new AssertionException("Identified bug 46009"); } }
public ExternalBookBlock(RecordStream rs) { _externalBookRecord = (SupBookRecord)rs.GetNext(); ArrayList temp = new ArrayList(); while (rs.PeekNextClass() == typeof(ExternalNameRecord)) { temp.Add(rs.GetNext()); } _externalNameRecords = (ExternalNameRecord[])temp.ToArray(typeof(ExternalNameRecord)); temp.Clear(); while (rs.PeekNextClass() == typeof(CRNCountRecord)) { temp.Add(new CRNBlock(rs)); } _crnBlocks = (CRNBlock[])temp.ToArray(typeof(CRNBlock)); }
public FrameAggregate(RecordStream rs, ChartRecordAggregate container) : base(RuleName_FRAME, container) { frame = (FrameRecord)rs.GetNext(); rs.GetNext();//BeginRecord lineFormat = (LineFormatRecord)rs.GetNext(); areaFormat = (AreaFormatRecord)rs.GetNext(); if (rs.PeekNextChartSid() == GelFrameRecord.sid) { gelFrame = new GelFrameAggregate(rs, this); } if (rs.PeekNextChartSid() == ShapePropsStreamRecord.sid) { shapeProps = new ShapePropsAggregate(rs, this); } Record r = rs.GetNext();//EndRecord Debug.Assert(r.GetType() == typeof(EndRecord)); }
public InternalChart(RecordStream rs) { _plsRecords = new List <PLSAggregate>(); records = new List <RecordBase>(128); if (rs.PeekNextSid() != BOFRecord.sid) { throw new Exception("BOF record expected"); } BOFRecord bof = (BOFRecord)rs.GetNext(); if (bof.Type != BOFRecordType.Chart) { throw new RuntimeException("Bad BOF record type"); } records.Add(bof); while (rs.HasNext()) { int recSid = rs.PeekNextSid(); Record.Record rec = rs.GetNext(); if (recSid == EOFRecord.sid) { records.Add(rec); break; } if (recSid == ChartRecord.sid) { continue; } if (recSid == ChartFRTInfoRecord.sid) { _chartFrtInfo = (ChartFRTInfoRecord)rec; } else if (recSid == HeaderRecord.sid) { header = (HeaderRecord)rec; } else if (recSid == FooterRecord.sid) { footer = (FooterRecord)rec; } else if (recSid == HCenterRecord.sid) { _hCenter = (HCenterRecord)rec; } else if (recSid == VCenterRecord.sid) { _vCenter = (VCenterRecord)rec; } else if (recSid == LeftMarginRecord.sid) { _leftMargin = (LeftMarginRecord)rec; } else if (recSid == RightMarginRecord.sid) { _rightMargin = (RightMarginRecord)rec; } else if (recSid == TopMarginRecord.sid) { _topMargin = (TopMarginRecord)rec; } else if (recSid == BottomMarginRecord.sid) { _bottomMargin = (BottomMarginRecord)rec; } else if (recSid == UnknownRecord.PLS_004D) // PLS { PLSAggregate pls = new PLSAggregate(rs); PLSAggregateVisitor rv = new PLSAggregateVisitor(records); pls.VisitContainedRecords(rv); _plsRecords.Add(pls); continue; } else if (recSid == PrintSetupRecord.sid) { printSetup = (PrintSetupRecord)rec; } else if (recSid == PrintSizeRecord.sid) { _printSize = (PrintSizeRecord)rec; } else if (recSid == HeaderFooterRecord.sid) { HeaderFooterRecord hf = (HeaderFooterRecord)rec; if (hf.IsCurrentSheet) { _headerFooter = hf; } else { _sviewHeaderFooters.Add(hf); } } else if (recSid == ProtectRecord.sid) { _protect = (ProtectRecord)rec; } records.Add(rec); } }
/** * 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)); }