Esempio n. 1
0
        public override object Clone()
        {
            CFHeaderRecord result = new CFHeaderRecord();

            base.CopyTo(result);
            return(result);
        }
Esempio n. 2
0
        public void TestCFRecordsAggregate1()
        {
            HSSFWorkbook workbook = new HSSFWorkbook();
            HSSFSheet sheet = (HSSFSheet)workbook.CreateSheet();
            IList recs = new ArrayList();
            CFHeaderRecord header = new CFHeaderRecord();
            CFRuleRecord rule1 = CFRuleRecord.Create(sheet, "7");
            CFRuleRecord rule2 = CFRuleRecord.Create(sheet, (byte)ComparisonOperator.BETWEEN, "2", "5");
            CFRuleRecord rule3 = CFRuleRecord.Create(sheet, (byte)ComparisonOperator.GE, "100", null);
            header.NumberOfConditionalFormats = (3);
            CellRangeAddress[] cellRanges = {
				new CellRangeAddress(0,1,0,0),
				new CellRangeAddress(0,1,2,2),
		    };
            header.CellRanges = (cellRanges);
            recs.Add(header);
            recs.Add(rule1);
            recs.Add(rule2);
            recs.Add(rule3);
            CFRecordsAggregate record;
            record = CFRecordsAggregate.CreateCFAggregate(recs, 0);

            // Serialize
		    byte [] serializedRecord = new byte[record.RecordSize];
		    record.Serialize(0, serializedRecord);
		    Stream in1 = new MemoryStream(serializedRecord);

            //Parse
            recs = RecordFactory.CreateRecords(in1);

            // Verify
            Assert.IsNotNull(recs);
            Assert.AreEqual(4, recs.Count);

            header = (CFHeaderRecord)recs[0];
            rule1 = (CFRuleRecord)recs[1];
            rule2 = (CFRuleRecord)recs[2];
            rule3 = (CFRuleRecord)recs[3];
            cellRanges = header.CellRanges;

            Assert.AreEqual(2, cellRanges.Length);
            Assert.AreEqual(3, header.NumberOfConditionalFormats);

            record = CFRecordsAggregate.CreateCFAggregate(recs, 0);

            record = record.CloneCFAggregate();

            Assert.IsNotNull(record.Header);
            Assert.AreEqual(3, record.NumberOfRules);

            header = record.Header;
            rule1 = record.GetRule(0);
            rule2 = record.GetRule(1);
            rule3 = record.GetRule(2);
            cellRanges = header.CellRanges;

            Assert.AreEqual(2, cellRanges.Length);
            Assert.AreEqual(3, header.NumberOfConditionalFormats);
        }
Esempio n. 3
0
        public override Object Clone()
        {
            CFHeaderRecord result = new CFHeaderRecord();

            result.field_1_numcf = field_1_numcf;
            result.field_2_need_recalculation   = field_2_need_recalculation;
            result.field_3_enclosing_cell_range = field_3_enclosing_cell_range;
            result.field_4_cell_ranges          = field_4_cell_ranges.Copy();
            return(result);
        }
 private CFRecordsAggregate(CFHeaderRecord pHeader, CFRuleRecord[] pRules)
 {
     if (pHeader == null)
     {
         throw new ArgumentException("header must not be null");
     }
     if (pRules == null)
     {
         throw new ArgumentException("rules must not be null");
     }
     if (pRules.Length > MAX_CONDTIONAL_FORMAT_RULES)
     {
         throw new ArgumentException("No more than "
                 + MAX_CONDTIONAL_FORMAT_RULES + " rules may be specified");
     }
     header = pHeader;
     rules = new ArrayList(3);
     for (int i = 0; i < pRules.Length; i++)
     {
         rules.Add(pRules[i]);
     }
 }
Esempio n. 5
0
 private CFRecordsAggregate(CFHeaderRecord pHeader, CFRuleRecord[] pRules)
 {
     if (pHeader == null)
     {
         throw new ArgumentException("header must not be null");
     }
     if (pRules == null)
     {
         throw new ArgumentException("rules must not be null");
     }
     if (pRules.Length > MAX_97_2003_CONDTIONAL_FORMAT_RULES)
     {
         Console.WriteLine("Excel versions before 2007 require that "
             + "No more than " + MAX_97_2003_CONDTIONAL_FORMAT_RULES
             + " rules may be specified, " + pRules.Length + " were found,"
             + " this file will cause problems with old Excel versions");
     }
     header = pHeader;
     rules = new List<CFRuleRecord>(3);
     for (int i = 0; i < pRules.Length; i++)
     {
         rules.Add(pRules[i]);
     }
 }
Esempio n. 6
0
        public void TestCreateCFHeaderRecord()
        {
            CFHeaderRecord record = new CFHeaderRecord();
            CellRangeAddress[] ranges = {
			    new CellRangeAddress(0,0xFFFF,5,5),
			    new CellRangeAddress(0,0xFFFF,6,6),
			    new CellRangeAddress(0,1,0,1),
			    new CellRangeAddress(0,1,2,3),
			    new CellRangeAddress(2,3,0,1),
			    new CellRangeAddress(2,3,2,3),
		    };
            record.CellRanges = (ranges);
            ranges = record.CellRanges;
            Assert.AreEqual(6, ranges.Length);
            CellRangeAddress enclosingCellRange = record.EnclosingCellRange;
            Assert.AreEqual(0, enclosingCellRange.FirstRow);
            Assert.AreEqual(65535, enclosingCellRange.LastRow);
            Assert.AreEqual(0, enclosingCellRange.FirstColumn);
            Assert.AreEqual(6, enclosingCellRange.LastColumn);
            record.NeedRecalculation = (true);
            Assert.IsTrue(record.NeedRecalculation);
            record.NeedRecalculation = (false);
            Assert.IsFalse(record.NeedRecalculation);
        }
Esempio n. 7
0
 public override Object Clone()
 {
     CFHeaderRecord result = new CFHeaderRecord();
     result.field_1_numcf = field_1_numcf;
     result.field_2_need_recalculation = field_2_need_recalculation;
     result.field_3_enclosing_cell_range = field_3_enclosing_cell_range;
     result.field_4_cell_ranges = field_4_cell_ranges.Copy();
     return result;
 }
Esempio n. 8
0
        public void TestSerialization()
        {
            byte[] recordData = 
		    {
			    (byte)0x03, (byte)0x00,
			    (byte)0x01,	(byte)0x00,
    			
			    (byte)0x00,	(byte)0x00,
			    (byte)0x03,	(byte)0x00,
			    (byte)0x00,	(byte)0x00,
			    (byte)0x03,	(byte)0x00,
    			
			    (byte)0x04,	(byte)0x00, // nRegions
    			
			    (byte)0x00,	(byte)0x00,
			    (byte)0x01,	(byte)0x00,
			    (byte)0x00,	(byte)0x00,
			    (byte)0x01,	(byte)0x00,
    			
			    (byte)0x00,	(byte)0x00,
			    (byte)0x01,	(byte)0x00,
			    (byte)0x02,	(byte)0x00,
			    (byte)0x03,	(byte)0x00,
    			
			    (byte)0x02,	(byte)0x00,
			    (byte)0x03,	(byte)0x00,
			    (byte)0x00,	(byte)0x00,
			    (byte)0x01,	(byte)0x00,
    			
			    (byte)0x02,	(byte)0x00,
			    (byte)0x03,	(byte)0x00,
			    (byte)0x02,	(byte)0x00,
			    (byte)0x03,	(byte)0x00,
		    };

            CFHeaderRecord record = new CFHeaderRecord(TestcaseRecordInputStream.Create(CFHeaderRecord.sid, recordData));

            Assert.AreEqual(3, record.NumberOfConditionalFormats, "#CFRULES");
            Assert.IsTrue(record.NeedRecalculation);
            Confirm(record.EnclosingCellRange, 0, 3, 0, 3);
            CellRangeAddress[] ranges = record.CellRanges;
            Assert.AreEqual(4, ranges.Length);
            Confirm(ranges[0], 0, 1, 0, 1);
            Confirm(ranges[1], 0, 1, 2, 3);
            Confirm(ranges[2], 2, 3, 0, 1);
            Confirm(ranges[3], 2, 3, 2, 3);
            Assert.AreEqual(recordData.Length + 4, record.RecordSize);

            byte[] output = record.Serialize();

            Assert.AreEqual(recordData.Length + 4, output.Length, "Output size"); //includes sid+recordlength

            for (int i = 0; i < recordData.Length; i++)
            {
                Assert.AreEqual(recordData[i], output[i + 4], "CFHeaderRecord doesn't match");
            }
        }
Esempio n. 9
0
        public void TestExtremeRows()
        {
            byte[] recordData = {
			    (byte)0x13, (byte)0x00, // nFormats
			    (byte)0x00,	(byte)0x00,
    			
			    (byte)0x00,	(byte)0x00,
			    (byte)0xFF,	(byte)0xFF,
			    (byte)0x00,	(byte)0x00,
			    (byte)0xFF,	(byte)0x00,
    			
			    (byte)0x03,	(byte)0x00, // nRegions
    			
			    (byte)0x40,	(byte)0x9C,
			    (byte)0x50,	(byte)0xC3,
			    (byte)0x02,	(byte)0x00,
			    (byte)0x02,	(byte)0x00,
    			
			    (byte)0x00,	(byte)0x00,
			    (byte)0xFF,	(byte)0xFF,
			    (byte)0x05,	(byte)0x00,
			    (byte)0x05,	(byte)0x00,
    			
			    (byte)0x07,	(byte)0x00,
			    (byte)0x07,	(byte)0x00,
			    (byte)0x00,	(byte)0x00,
			    (byte)0xFF,	(byte)0x00,
		    };

            CFHeaderRecord record;
            try
            {
                record = new CFHeaderRecord(TestcaseRecordInputStream.Create(CFHeaderRecord.sid, recordData));
            }
            catch (ArgumentException e)
            {
                if (e.Message.Equals("invalid cell range (-25536, 2, -15536, 2)"))
                {
                    throw new AssertionException("Identified bug 44739b");
                }
                throw e;
            }

            Assert.AreEqual(19, record.NumberOfConditionalFormats, "#CFRULES");
            Assert.IsFalse(record.NeedRecalculation);
            Confirm(record.EnclosingCellRange, 0, 65535, 0, 255);
            CellRangeAddress[] ranges = record.CellRanges;
            Assert.AreEqual(3, ranges.Length);
            Confirm(ranges[0], 40000, 50000, 2, 2);
            Confirm(ranges[1], 0, 65535, 5, 5);
            Confirm(ranges[2], 7, 7, 0, 255);

            byte[] output = record.Serialize();

            Assert.AreEqual(recordData.Length + 4, output.Length, "Output size"); //includes sid+recordlength

            for (int i = 0; i < recordData.Length; i++)
            {
                Assert.AreEqual(recordData[i], output[i + 4], "CFHeaderRecord doesn't match");
            }
        }
Esempio n. 10
0
 public override void Dispose()
 {
     header = null;
     rules = null;
 }