zhao
2021-07-02 081df17b8cc4a6e7e4f4e1e1887f24810e3ec2f9
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
/* ====================================================================
   Licensed to the Apache Software Foundation (ASF) Under one or more
   contributor license agreements.  See the NOTICE file distributed with
   this work for Additional information regarding copyright ownership.
   The ASF licenses this file to You Under the Apache License, Version 2.0
   (the "License"); you may not use this file except in compliance with
   the License.  You may obtain a copy of the License at
 
       http://www.apache.org/licenses/LICENSE-2.0
 
   Unless required by applicable law or agreed to in writing, software
   distributed Under the License is distributed on an "AS Is" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations Under the License.
==================================================================== */
 
namespace HH.WMS.Utils.NPOI.HSSF.Record
{
 
    using System;
    using System.Text;
    using HH.WMS.Utils.NPOI.Util;
 
    /**
     * Label Record - Read only support for strings stored directly in the cell..  Don't
     * use this (except to Read), use LabelSST instead 
     * REFERENCE:  PG 325 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)
     * @author Andrew C. Oliver (acoliver at apache dot org)
     * @author Jason Height (jheight at chariot dot net dot au)
     * @version 2.0-pre
     * @see org.apache.poi.hssf.record.LabelSSTRecord
     */
    public class LabelRecord : Record, CellValueRecordInterface
    {
        public const short sid = 0x204;
 
        private int field_1_row;
        private int field_2_column;
        private short field_3_xf_index;
        private short field_4_string_len;
        private byte field_5_unicode_flag;
        private String field_6_value;
 
        /** Creates new LabelRecord */
 
        public LabelRecord()
        {
        }
 
        /**
         * Constructs an Label record and Sets its fields appropriately.
         *
         * @param in the RecordInputstream to Read the record from
         */
 
        public LabelRecord(RecordInputStream in1)
        {
            field_1_row = in1.ReadUShort();
            field_2_column = in1.ReadUShort();
            field_3_xf_index = in1.ReadShort();
            field_4_string_len = in1.ReadShort();
            field_5_unicode_flag = (byte)in1.ReadByte();
            if (field_4_string_len > 0)
            {
                if (IsUncompressedUnicode)
                {
                    field_6_value = in1.ReadUnicodeLEString(field_4_string_len);
                }
                else
                {
                    field_6_value = in1.ReadCompressedUnicode(field_4_string_len);
                }
            }
            else
            {
                field_6_value = "";
            }
        }
 
        /*
         * Read ONLY ACCESS... THIS Is FOR COMPATIBILITY ONLY...USE LABELSST! public
         * void SetRow(short row) { field_1_row = row; }
         * 
         * public void SetColumn(short col) { field_2_column = col; }
         * 
         * public void SetXFIndex(short index) { field_3_xf_index = index; }
         */
        public int Row
        {
            get{return field_1_row;}
            set { throw new NotSupportedException("Use LabelSST instead"); }
        }
 
        public int Column
        {
            get{return field_2_column;}
            set { throw new NotSupportedException("Use LabelSST instead"); }
        }
 
        public short XFIndex
        {
            get { return field_3_xf_index; }
            set { throw new NotSupportedException("Use LabelSST instead"); }
        }
 
        /**
         * Get the number of Chars this string Contains
         * @return number of Chars
         */
 
        public short StringLength
        {
            get { return field_4_string_len; }
        }
 
        /**
         * Is this Uncompressed Unicode (16bit)?  Or just 8-bit compressed?
         * @return IsUnicode - True for 16bit- false for 8bit
         */
 
        public bool IsUncompressedUnicode
        {
            get { return (field_5_unicode_flag == 1); }
        }
 
        /**
         * Get the value
         *
         * @return the text string
         * @see #GetStringLength
         */
 
        public String Value
        {
            get { return field_6_value; }
        }
 
        /**
         * THROWS A RUNTIME EXCEPTION..  USE LABELSSTRecords.  YOU HAVE NO REASON to use LABELRecord!!
         */
 
        public override int Serialize(int offset, byte [] data)
        {
            throw new RecordFormatException(
                "Label Records are supported Read ONLY...Convert to LabelSST");
        }
        public override int RecordSize
        {
            get
            {
                throw new RecordFormatException("Label Records are supported READ ONLY...convert to LabelSST");
            }
        }
 
        public override short Sid
        {
            get { return sid; }
        }
 
        public override String ToString()
        {
            StringBuilder buffer = new StringBuilder();
            buffer.Append("[LABEL]\n");
            buffer.Append("    .row            = ")
                .Append(StringUtil.ToHexString(Row)).Append("\n");
            buffer.Append("    .column         = ")
                .Append(StringUtil.ToHexString(Column)).Append("\n");
            buffer.Append("    .xfindex        = ")
                .Append(StringUtil.ToHexString(XFIndex)).Append("\n");
            buffer.Append("    .string_len       = ")
                .Append(StringUtil.ToHexString(field_4_string_len)).Append("\n");
            buffer.Append("    .unicode_flag       = ")
                .Append(StringUtil.ToHexString(field_5_unicode_flag)).Append("\n");
            buffer.Append("    .value       = ")
                .Append(Value).Append("\n");
            buffer.Append("[/LABEL]\n");
            return buffer.ToString();
        }
 
 
        public override Object Clone()
        {
            LabelRecord rec = new LabelRecord();
            rec.field_1_row = field_1_row;
            rec.field_2_column = field_2_column;
            rec.field_3_xf_index = field_3_xf_index;
            rec.field_4_string_len = field_4_string_len;
            rec.field_5_unicode_flag = field_5_unicode_flag;
            rec.field_6_value = field_6_value;
            return rec;
        }
    }
}