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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
 
/* ====================================================================
   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;
 
 
    /**
     * Title:        WSBool Record.
     * Description:  stores workbook Settings  (aka its a big "everything we didn't
     *               put somewhere else")
     * REFERENCE:  PG 425 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)
     * @author Andrew C. Oliver (acoliver at apache dot org)
     * @author Glen Stampoultzis (gstamp@iprimus.com.au)
     * @author Jason Height (jheight at chariot dot net dot au)
     * @version 2.0-pre
     */
 
    public class WSBoolRecord
       : StandardRecord
    {
        public const short sid = 0x81;
        private byte field_1_wsbool;         // crappy names are because this is really one big short field (2byte)
        private byte field_2_wsbool;         // but the docs inconsistantly use it as 2 seperate bytes
 
        // I decided to be consistant in this way.
        static private BitField autobreaks =
            BitFieldFactory.GetInstance(0x01);                               // are automatic page breaks visible
 
        // bits 1 to 3 Unused
        static private BitField dialog = BitFieldFactory.GetInstance(0x10);                               // is sheet dialog sheet
        static private BitField applystyles = BitFieldFactory.GetInstance(0x20);                               // whether to apply automatic styles to outlines
        static private BitField rowsumsbelow = BitFieldFactory.GetInstance(0x40);                                            // whether summary rows will appear below detail in outlines
        static private BitField rowsumsright = BitFieldFactory.GetInstance(0x80);                                            // whether summary rows will appear right of the detail in outlines
        static private BitField fittopage = BitFieldFactory.GetInstance(0x01);                               // whether to fit stuff to the page
 
        // bit 2 reserved
        static private BitField Displayguts = BitFieldFactory.GetInstance(0x06);                                            // whether to Display outline symbols (in the gutters)
 
        // bits 4-5 reserved
        static private BitField alternateexpression = BitFieldFactory.GetInstance(0x40); // whether to use alternate expression eval
 
        static private BitField alternateformula = BitFieldFactory.GetInstance(0x80); // whether to use alternate formula entry
 
 
        public WSBoolRecord()
        {
        }
 
        /**
         * Constructs a WSBool record and Sets its fields appropriately.
         * @param in the RecordInputstream to Read the record from
         */
 
        public WSBoolRecord(RecordInputStream in1)
        {
            byte[] data = in1.ReadRemainder();
            field_1_wsbool =
                data[0];
            field_2_wsbool =
                data[1];
        }
 
 
        /**
         * Get first byte (see bit Getters)
         */
 
        public byte WSBool1
        {
            get
            {
                return field_1_wsbool;
            }
            set { field_1_wsbool = value; }
        }
 
        // bool1 bitfields
 
        /// <summary>
        /// Whether to show automatic page breaks or not
        /// </summary>
        public bool Autobreaks
        {
            get
            {
                return autobreaks.IsSet(field_1_wsbool);
            }
            set { field_1_wsbool = autobreaks.SetByteBoolean(field_1_wsbool, value); }
        }
 
        /// <summary>
        /// Whether sheet is a dialog sheet or not
        /// </summary>
        public bool Dialog
        {
            get
            {
                return dialog.IsSet(field_1_wsbool);
            }
            set { field_1_wsbool = dialog.SetByteBoolean(field_1_wsbool, value); }
        }
 
        /// <summary>
        /// Get if row summaries appear below detail in the outline
        /// </summary>
        public bool RowSumsBelow
        {
            get
            {
                return rowsumsbelow.IsSet(field_1_wsbool);
            }
            set { field_1_wsbool = rowsumsbelow.SetByteBoolean(field_1_wsbool, value); }
        }
 
        /// <summary>
        /// Get if col summaries appear right of the detail in the outline
        /// </summary>
        public bool RowSumsRight
        {
            get
            {
                return rowsumsright.IsSet(field_1_wsbool);
            }
            set { field_1_wsbool = rowsumsright.SetByteBoolean(field_1_wsbool, value); }
        }
 
 
        /// <summary>
        /// Get the second byte (see bit Getters)
        /// </summary>
        public byte WSBool2
        {
            get
            {
                return field_2_wsbool;
            }
            set { field_2_wsbool = value; }
        }
 
 
        /// <summary>
        /// fit to page option is on
        /// </summary>
        public bool FitToPage
        {
            get
            {
                return fittopage.IsSet(field_2_wsbool);
            }
            set { field_2_wsbool = fittopage.SetByteBoolean(field_2_wsbool, value); }
        }
 
        /// <summary>
        /// Whether to display the guts or not
        /// </summary>
        public bool DisplayGuts
        {
            get
            {
                return Displayguts.IsSet(field_2_wsbool);
            }
            set { field_2_wsbool = Displayguts.SetByteBoolean(field_2_wsbool, value); }
        }
 
        /// <summary>
        /// whether alternate expression evaluation is on
        /// </summary>
        public bool AlternateExpression
        {
            get
            {
                return alternateexpression.IsSet(field_2_wsbool);
            }
            set
            {
                field_2_wsbool = alternateexpression.SetByteBoolean(field_2_wsbool,
                    value);
            }
        }
 
        /// <summary>
        /// whether alternative formula entry is on
        /// </summary>
        public bool AlternateFormula
        {
            get
            {
                return alternateformula.IsSet(field_2_wsbool);
            }
            set
            {
                field_2_wsbool = alternateformula.SetByteBoolean(field_2_wsbool,
                    value);
            }
        }
 
        public override String ToString()
        {
            StringBuilder buffer = new StringBuilder();
 
            buffer.Append("[WSBOOL]\n");
            buffer.Append("    .wsbool1        = ")
                .Append(StringUtil.ToHexString(WSBool1)).Append("\n");
            buffer.Append("        .autobreaks = ").Append(Autobreaks)
                .Append("\n");
            buffer.Append("        .dialog     = ").Append(Dialog)
                .Append("\n");
            buffer.Append("        .rowsumsbelw= ").Append(RowSumsBelow)
                .Append("\n");
            buffer.Append("        .rowsumsrigt= ").Append(RowSumsRight)
                .Append("\n");
            buffer.Append("    .wsbool2        = ")
                .Append(StringUtil.ToHexString(WSBool2)).Append("\n");
            buffer.Append("        .fittopage  = ").Append(FitToPage)
                .Append("\n");
            buffer.Append("        .Displayguts= ").Append(DisplayGuts)
                .Append("\n");
            buffer.Append("        .alternateex= ")
                .Append(AlternateExpression).Append("\n");
            buffer.Append("        .alternatefo= ").Append(AlternateFormula)
                .Append("\n");
            buffer.Append("[/WSBOOL]\n");
            return buffer.ToString();
        }
 
        public override void Serialize(ILittleEndianOutput out1)
        {
            out1.WriteByte(WSBool1);
            out1.WriteByte(WSBool2);
        }
 
        protected override int DataSize
        {
            get { return 2; }
        }
 
        public override short Sid
        {
            get { return sid; }
        }
 
        public override Object Clone()
        {
            WSBoolRecord rec = new WSBoolRecord();
            rec.field_1_wsbool = field_1_wsbool;
            rec.field_2_wsbool = field_2_wsbool;
            return rec;
        }
    }
}