zhao
2021-07-19 8347f2fbddbd25369359dcb2da1233ac48a19fdc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
using System;
using System.Collections.Generic;
using System.Text;
 
namespace HH.WMS.Utils.NPOI.SS.Util
{
    using HH.WMS.Utils.NPOI.Util;
    using HH.WMS.Utils.NPOI.HSSF.Record;
 
    public class CellRangeAddress8Bit : CellRangeAddressBase
    {
        public static int ENCODED_SIZE = 6;
 
        public CellRangeAddress8Bit(int firstRow, int lastRow, int firstCol, int lastCol)
            : base(firstRow, lastRow, firstCol, lastCol)
        {
 
        }
 
        public CellRangeAddress8Bit(RecordInputStream in1)
            : base(ReadUShortAndCheck(in1), in1.ReadUShort(), in1.ReadUByte(), in1.ReadUByte())
        {
 
        }
 
        private static int ReadUShortAndCheck(RecordInputStream in1)
        {
            if (in1.Remaining < ENCODED_SIZE)
            {
                // Ran out of data
                throw new Exception("Ran out of data reading CellRangeAddress");
            }
            return in1.ReadUShort();
        }
 
        public int Serialize(int offset, byte[] data)
        {
            LittleEndian.PutUShort(data, offset + 0, FirstRow);
            LittleEndian.PutUShort(data, offset + 2, LastRow);
            LittleEndian.PutByte(data, offset + 4, FirstColumn);
            LittleEndian.PutByte(data, offset + 5, LastColumn);
            return ENCODED_SIZE;
        }
        public void Serialize(ILittleEndianOutput out1)
        {
            out1.WriteShort(FirstRow);
            out1.WriteShort(LastRow);
            out1.WriteByte(FirstColumn);
            out1.WriteByte(LastColumn);
        }
        public CellRangeAddress8Bit Copy()
        {
            return new CellRangeAddress8Bit(FirstRow, LastRow, FirstColumn, LastColumn);
        }
 
        public static int GetEncodedSize(int numberOfItems)
        {
            return numberOfItems * ENCODED_SIZE;
        }
    }
}