zhao
2021-06-04 c7ec496f9e41c2227103b3ef776e4a3f91bce6b2
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
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
 
/* ====================================================================
   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:        Window1 Record
     * Description:  Stores the attributes of the workbook window.  This Is basically
     *               so the gui knows how big to make the window holding the spReadsheet
     *               document.
     * REFERENCE:  PG 421 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)
     * @author Andrew C. Oliver (acoliver at apache dot org)
     * @version 2.0-pre
     */
 
    public class WindowOneRecord
       : StandardRecord
    {
        public const short sid = 0x3d;
 
        // our variable names stolen from old TV Sets.
        private short field_1_h_hold;                  // horizontal position
        private short field_2_v_hold;                  // vertical position
        private short field_3_width;
        private short field_4_height;
        private short field_5_options;
        static private BitField hidden =
            BitFieldFactory.GetInstance(0x01);                                        // Is this window Is hidden
        static private BitField iconic =
            BitFieldFactory.GetInstance(0x02);                                        // Is this window Is an icon
        static private BitField reserved = BitFieldFactory.GetInstance(0x04);   // reserved
        static private BitField hscroll =
            BitFieldFactory.GetInstance(0x08);                                        // Display horizontal scrollbar
        static private BitField vscroll =
            BitFieldFactory.GetInstance(0x10);                                        // Display vertical scrollbar
        static private BitField tabs =
            BitFieldFactory.GetInstance(0x20);                                        // Display tabs at the bottom
 
        // all the rest are "reserved"
        private int field_6_active_sheet;
        private int field_7_first_visible_tab;
        private short field_8_num_selected_tabs;
        private short field_9_tab_width_ratio;
 
        public WindowOneRecord()
        {
        }
 
        /**
         * Constructs a WindowOne record and Sets its fields appropriately.
         * @param in the RecordInputstream to Read the record from
         */
 
        public WindowOneRecord(RecordInputStream in1)
        {
            field_1_h_hold = in1.ReadShort();
            field_2_v_hold = in1.ReadShort();
            field_3_width = in1.ReadShort();
            field_4_height = in1.ReadShort();
            field_5_options = in1.ReadShort();
            field_6_active_sheet = in1.ReadShort();
            field_7_first_visible_tab = in1.ReadShort();
            field_8_num_selected_tabs = in1.ReadShort();
            field_9_tab_width_ratio = in1.ReadShort();
        }
 
        /**
         * Get the horizontal position of the window (in 1/20ths of a point)
         * @return h - horizontal location
         */
 
        public short HorizontalHold
        {
            get { return field_1_h_hold; }
            set { field_1_h_hold = value; }
        }
 
        /**
         * Get the vertical position of the window (in 1/20ths of a point)
         * @return v - vertical location
         */
 
        public short VerticalHold
        {
            get { return field_2_v_hold; }
            set { field_2_v_hold = value; }
        }
 
        /**
         * Get the width of the window
         * @return width
         */
 
        public short Width
        {
            get { return field_3_width; }
            set { field_3_width = value; }
        }
 
        /**
         * Get the height of the window
         * @return height
         */
 
        public short Height
        {
            get { return field_4_height; }
            set { field_4_height = value; }
        }
 
        /**
         * Get the options bitmask (see bit Setters)
         *
         * @return o - the bitmask
         */
 
        public short Options
        {
            get { return field_5_options; }
            set { field_5_options = value; }
        }
 
        // bitfields for options
 
        /**
         * Get whether the window Is hidden or not
         * @return Ishidden or not
         */
 
        public bool Hidden
        {
            get { return hidden.IsSet(field_5_options); }
            set { field_5_options = hidden.SetShortBoolean(field_5_options, value); }
        }
 
        /**
         * Get whether the window has been iconized or not
         * @return iconize  or not
         */
 
        public bool Iconic
        {
            get { return iconic.IsSet(field_5_options); }
            set { field_5_options = iconic.SetShortBoolean(field_5_options, value); }
        }
 
        /**
         * Get whether to Display the horizontal scrollbar or not
         * @return Display or not
         */
 
        public bool DisplayHorizontalScrollbar
        {
            get{return hscroll.IsSet(field_5_options);}
            set { field_5_options = hscroll.SetShortBoolean(field_5_options, value); }
        }
 
        /**
         * Get whether to Display the vertical scrollbar or not
         * @return Display or not
         */
 
        public bool DisplayVerticalScrollbar
        {
            get { return vscroll.IsSet(field_5_options); }
            set { field_5_options = vscroll.SetShortBoolean(field_5_options, value); }
        }
 
        /**
         * Get whether to Display the tabs or not
         * @return Display or not
         */
 
        public bool DisplayTabs
        {
            get { return tabs.IsSet(field_5_options); }
            set { field_5_options = tabs.SetShortBoolean(field_5_options, value); }
        }
 
        // end options bitfields
 
 
        /**
         * @return the index of the currently Displayed sheet 
         */
        public int ActiveSheetIndex
        {
            get { return field_6_active_sheet; }
            set { field_6_active_sheet = value; }
        }
        /**
         * deprecated May 2008
         * @deprecated - Misleading name - use GetActiveSheetIndex() 
         */
        [Obsolete]
        public short SelectedTab
        {
            get { return (short)ActiveSheetIndex; }
            set { ActiveSheetIndex = value; }
        }
 
        /**
         * @return the first visible sheet in the worksheet tab-bar. 
         * I.E. the scroll position of the tab-bar.
         */
        public int FirstVisibleTab
        {
            get { return field_7_first_visible_tab; }
            set { field_7_first_visible_tab = value; }
        }
        /**
         * deprecated May 2008
         * @deprecated - Misleading name - use GetFirstVisibleTab() 
         */
        [Obsolete]
        public short DisplayedTab
        {
            get { return (short)FirstVisibleTab; }
            set { FirstVisibleTab=value; }
        }
 
        /**
         * Get the number of selected tabs
         * @return number of tabs
         */
 
        public short NumSelectedTabs
        {
            get { return field_8_num_selected_tabs; }
            set { field_8_num_selected_tabs = value; }
        }
 
        /**
         * ratio of the width of the tabs to the horizontal scrollbar
         * @return ratio
         */
 
        public short TabWidthRatio
        {
            get{return field_9_tab_width_ratio;}
            set { field_9_tab_width_ratio = value; }
        }
 
        public override String ToString()
        {
            StringBuilder buffer = new StringBuilder();
 
            buffer.Append("[WINDOW1]\n");
            buffer.Append("    .h_hold          = ")
                .Append(StringUtil.ToHexString(HorizontalHold)).Append("\n");
            buffer.Append("    .v_hold          = ")
                .Append(StringUtil.ToHexString(VerticalHold)).Append("\n");
            buffer.Append("    .width           = ")
                .Append(StringUtil.ToHexString(Width)).Append("\n");
            buffer.Append("    .height          = ")
                .Append(StringUtil.ToHexString(Height)).Append("\n");
            buffer.Append("    .options         = ")
                .Append(StringUtil.ToHexString(Options)).Append("\n");
            buffer.Append("        .hidden      = ").Append(Hidden)
                .Append("\n");
            buffer.Append("        .iconic      = ").Append(Iconic)
                .Append("\n");
            buffer.Append("        .hscroll     = ")
                .Append(DisplayHorizontalScrollbar).Append("\n");
            buffer.Append("        .vscroll     = ")
                .Append(DisplayVerticalScrollbar).Append("\n");
            buffer.Append("        .tabs        = ").Append(DisplayTabs)
                .Append("\n");
            buffer.Append("    .activeSheet     = ")
                .Append(StringUtil.ToHexString(ActiveSheetIndex)).Append("\n");
            buffer.Append("    .firstVisibleTab    = ")
                .Append(StringUtil.ToHexString(FirstVisibleTab)).Append("\n");
            buffer.Append("    .numselectedtabs = ")
                .Append(StringUtil.ToHexString(NumSelectedTabs)).Append("\n");
            buffer.Append("    .tabwidthratio   = ")
                .Append(StringUtil.ToHexString(TabWidthRatio)).Append("\n");
            buffer.Append("[/WINDOW1]\n");
            return buffer.ToString();
        }
 
        
        public override void Serialize(ILittleEndianOutput out1)
        {
            out1.WriteShort(HorizontalHold);
            out1.WriteShort(VerticalHold);
            out1.WriteShort(Width);
            out1.WriteShort(Height);
            out1.WriteShort(Options);
            out1.WriteShort(ActiveSheetIndex);
            out1.WriteShort(FirstVisibleTab);
            out1.WriteShort(NumSelectedTabs);
            out1.WriteShort(TabWidthRatio);
        }
 
        protected override int DataSize
        {
            get
            {
                return 18;
            }
        }
        public override short Sid
        {
            get { return sid; }
        }
    }
}