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");
     }
 }
Ejemplo n.º 2
0
        // 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 ConditionalFormattingTable(RecordStream rs)
        {

            IList temp = new ArrayList();
            while (rs.PeekNextClass() == typeof(CFHeaderRecord))
            {
                temp.Add(CFRecordsAggregate.CreateCFAggregate(rs));
            }
            _cfHeaders = temp;
        }
Ejemplo n.º 4
0
 public DataValidityTable(RecordStream rs)
 {
     _headerRec = (DVALRecord)rs.GetNext();
     IList temp = new ArrayList();
     while (rs.PeekNextClass() == typeof(DVRecord))
     {
         temp.Add(rs.GetNext());
     }
     _validationList = temp;
 }
Ejemplo n.º 5
0
 /**
  * Reads zero or more consecutive {@link MergeCellsRecord}s
  * @param rs
  */
 public void Read(RecordStream rs)
 {
     
     while (rs.PeekNextClass() == typeof(MergeCellsRecord))
     {
         MergeCellsRecord mcr = (MergeCellsRecord)rs.GetNext();
         int nRegions = mcr.NumAreas;
         for (int i = 0; i < nRegions; i++)
         {
             _mergedRegions.Add(mcr.GetAreaAt(i));
         }
     }
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ColumnInfoRecordsAggregate"/> class.
 /// </summary>
 /// <param name="rs">The rs.</param>
 public ColumnInfoRecordsAggregate(RecordStream rs): this()
 {
     bool isInOrder = true;
     ColumnInfoRecord cirPrev = null;
     while (rs.PeekNextClass() == typeof(ColumnInfoRecord))
     {
         ColumnInfoRecord cir = (ColumnInfoRecord)rs.GetNext();
         records.Add(cir);
         if (cirPrev != null && CIRComparator.CompareColInfos(cirPrev, cir) > 0)
         {
             isInOrder = false;
         }
         cirPrev = cir;
     }
     if (records.Count < 1)
     {
         throw new InvalidOperationException("No column info records found");
     }
     if (!isInOrder)
     {
         records.Sort(CIRComparator.instance);
     }
 }
Ejemplo n.º 7
0
 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);
     }
 }
Ejemplo n.º 8
0
        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);

            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 (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);
                }
                else
                {
                    break;
                }
            }

            _recordCount = rs.GetCountRead();
            for (int i = startIndex; i < startIndex + _recordCount; i++)
            {
                _workbookRecordList.Records.Add(inputList[i]);
            }

        }
Ejemplo n.º 9
0
            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));
            }