/** * called by the class that Is responsible for writing this sucker. * Subclasses should implement this so that their data Is passed back in a * byte array. * * @param offset to begin writing at * @param data byte array containing instance data * @return number of bytes written */ public override void Serialize(ILittleEndianOutput out1) { int formula1Len = GetFormulaSize(field_17_formula1); int formula2Len = GetFormulaSize(field_18_formula2); out1.WriteByte(field_1_condition_type); out1.WriteByte(field_2_comparison_operator); out1.WriteShort(formula1Len); out1.WriteShort(formula2Len); out1.WriteInt(field_5_options); out1.WriteShort(field_6_not_used); if (ContainsFontFormattingBlock) { byte[] fontFormattingRawRecord = fontFormatting.GetRawRecord(); out1.Write(fontFormattingRawRecord); } if (ContainsBorderFormattingBlock) { borderFormatting.Serialize(out1); } if (ContainsPatternFormattingBlock) { patternFormatting.Serialize(out1); } field_17_formula1.SerializeTokens(out1); field_18_formula2.SerializeTokens(out1); }
/** * called by the class that Is responsible for writing this sucker. * Subclasses should implement this so that their data Is passed back in a * byte array. * * @param offset to begin writing at * @param data byte array containing instance data * @return number of bytes written */ public override int Serialize(int pOffset, byte[] data) { int formula1Len = GetFormulaSize(field_17_formula1); int formula2Len = GetFormulaSize(field_18_formula2); int offset = pOffset; int recordsize = RecordSize; LittleEndian.PutShort(data, 0 + offset, sid); LittleEndian.PutShort(data, 2 + offset, (short)(recordsize - 4)); LittleEndian.PutByte(data, 4 + offset, field_1_condition_type); LittleEndian.PutByte(data, 5 + offset, field_2_comparison_operator); LittleEndian.PutUShort(data, 6 + offset, formula1Len); LittleEndian.PutUShort(data, 8 + offset, formula2Len); LittleEndian.PutInt(data, 10 + offset, field_5_options); LittleEndian.PutShort(data, 14 + offset, field_6_not_used); offset += 16; if (ContainsFontFormattingBlock) { byte[] fontFormattingRawRecord = fontFormatting.GetRawRecord(); Array.Copy(fontFormattingRawRecord, 0, data, offset, fontFormattingRawRecord.Length); offset += fontFormattingRawRecord.Length; } if (ContainsBorderFormattingBlock) { offset += borderFormatting.Serialize(offset, data); } if (ContainsPatternFormattingBlock) { offset += patternFormatting.Serialize(offset, data); } if (field_17_formula1 != null) { offset += Ptg.SerializePtgs(field_17_formula1, data, offset); } if (field_18_formula2 != null) { offset += Ptg.SerializePtgs(field_18_formula2, data, offset); } if (offset - pOffset != recordsize) { throw new InvalidOperationException("Write mismatch (" + (offset - pOffset) + "!=" + recordsize + ")"); } return(recordsize); }
/** * @return * @see org.apache.poi.hssf.record.cf.FontFormatting#GetRawRecord() */ protected byte[] GetRawRecord() { return(fontFormatting.GetRawRecord()); }