private SharedValueManager(SharedFormulaRecord[] sharedFormulaRecords,
         ArrayRecord[] arrayRecords, TableRecord[] tableRecords)
 {
     _sfrs = sharedFormulaRecords;
     _arrayRecords = arrayRecords;
     _tableRecords = tableRecords;
 }
 /**
  * @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);
 }
Esempio n. 3
0
        /**
         * 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));
        }
Esempio n. 4
0
        public void TestLoad()
        {

            TableRecord record = new TableRecord(TestcaseRecordInputStream.Create(0x236, data));

            CellRangeAddress8Bit range = record.Range;
            Assert.AreEqual(3, range.FirstRow);
            Assert.AreEqual(8, range.LastRow);
            Assert.AreEqual(4, range.FirstColumn);
            Assert.AreEqual(6, range.LastColumn);
            Assert.AreEqual(0, record.Flags);
            Assert.AreEqual(4, record.RowInputRow);
            Assert.AreEqual(1, record.ColInputRow);
            Assert.AreEqual(0x4076, record.RowInputCol);
            Assert.AreEqual(0, record.ColInputCol);

            Assert.AreEqual(16 + 4, record.RecordSize);
        }
Esempio n. 5
0
        public void TestStore()
        {
            //    	Offset 0x3bd9 (15321)
            //    	recordid = 0x236, size = 16
            //    	[TABLE]
            //    	    .row from      = 3
            //    	    .row to        = 8
            //    	    .column from   = 4
            //    	    .column to     = 6
            //    	    .flags         = 0
            //    	        .always calc     =false
            //    	    .reserved      = 0
            //    	    .row input row = 4
            //    	    .col input row = 1
            //    	    .row input col = 4076
            //    	    .col input col = 0
            //    	[/TABLE]

            CellRangeAddress8Bit crab = new CellRangeAddress8Bit(3, 8, 4, 6);
            TableRecord record = new TableRecord(crab);
            record.Flags = (/*setter*/(byte)0);
            record.RowInputRow = (/*setter*/4);
            record.ColInputRow = (/*setter*/1);
            record.RowInputCol = (/*setter*/0x4076);
            record.ColInputCol = (/*setter*/0);

            byte[] recordBytes = record.Serialize();
            Assert.AreEqual(recordBytes.Length - 4, data.Length);
            for (int i = 0; i < data.Length; i++)
                Assert.AreEqual(data[i], recordBytes[i + 4], "At offset " + i);
        }