zhao
2021-07-02 23ee356c6f260ecc1a48bbb8bd60932b979e4698
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:        Print Setup Record
     * Description:  Stores print Setup options -- bogus for HSSF (and marked as such)
     * REFERENCE:  PG 385 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
     */
 
    public class PrintSetupRecord
       : StandardRecord
    {
 
        public const short sid = 0xa1;
        private short field_1_paper_size;
        private short field_2_scale;
        private short field_3_page_start;
        private short field_4_fit_width;
        private short field_5_fit_height;
        private short field_6_options;
        
        private BitField lefttoright =
        BitFieldFactory.GetInstance(0x01);   // print over then down
        private BitField landscape =
        BitFieldFactory.GetInstance(0x02);   // landscape mode
        private BitField validSettings = BitFieldFactory.GetInstance(
        0x04);                // if papersize, scale, resolution, copies, landscape weren't obtained from the print consider them mere bunk
        private BitField nocolor =
        BitFieldFactory.GetInstance(0x08);   // print mono/b&w, colorless
        private BitField draft =
        BitFieldFactory.GetInstance(0x10);   // print draft quality
        private BitField notes =
        BitFieldFactory.GetInstance(0x20);   // print the notes
        private BitField noOrientation =
        BitFieldFactory.GetInstance(0x40);   // the orientation Is not Set
        private BitField usepage =
        BitFieldFactory.GetInstance(0x80);   // use a user Set page no, instead of auto
        private BitField endnote =
        BitFieldFactory.GetInstance(0x200);   // note is printed at the end
        private BitField ierror =
        BitFieldFactory.GetInstance(0xC00);   // printed style of cell errors
       
 
        private short field_7_hresolution;
        private short field_8_vresolution;
        private double field_9_headermargin;
        private double field_10_footermargin;
        private short field_11_copies;
 
        public PrintSetupRecord()
        {
            
        }
 
        /**
         * Constructs a PrintSetup (SetUP) record and Sets its fields appropriately.
         * @param in the RecordInputstream to Read the record from
         */
 
        public PrintSetupRecord(RecordInputStream in1)
        {
            field_1_paper_size = in1.ReadShort();
            field_2_scale = in1.ReadShort();
            field_3_page_start = in1.ReadShort();
            field_4_fit_width = in1.ReadShort();
            field_5_fit_height = in1.ReadShort();
            field_6_options = in1.ReadShort();
            field_7_hresolution = in1.ReadShort();
            field_8_vresolution = in1.ReadShort();
            field_9_headermargin = in1.ReadDouble();
            field_10_footermargin = in1.ReadDouble();
            field_11_copies = in1.ReadShort();
        }
        public short PaperSize
        {
            get
            {
                return field_1_paper_size;
            }
            set { field_1_paper_size = value; }
        }
 
        public short Scale
        {
            get{return field_2_scale;}
            set { field_2_scale = value; }
        }
 
        public short PageStart
        {
            get { return field_3_page_start; }
            set { field_3_page_start = value; }
        }
 
        public short FitWidth
        {
            get { return field_4_fit_width; }
            set { field_4_fit_width = value; }
        }
 
        public short FitHeight
        {
            get { return field_5_fit_height; }
            set { field_5_fit_height = value; }
        }
 
        public short Options
        {
            get { return field_6_options; }
            set { field_6_options = value; }
        }
 
        // option bitfields
        public bool LeftToRight
        {
            get { return lefttoright.IsSet(field_6_options); }
            set { field_6_options = lefttoright.SetShortBoolean(field_6_options, value); }
        }
 
        public bool Landscape
        {
            get { return landscape.IsSet(field_6_options); }
            set { field_6_options = landscape.SetShortBoolean(field_6_options, value); }
        }
 
        public bool ValidSettings
        {
            get { return validSettings.IsSet(field_6_options); }
            set { field_6_options = validSettings.SetShortBoolean(field_6_options, value); }
        }
 
        public bool NoColor
        {
            get { return nocolor.IsSet(field_6_options); }
            set { field_6_options = nocolor.SetShortBoolean(field_6_options, value); }
        }
 
        public bool Draft
        {
            get { return draft.IsSet(field_6_options); }
            set { field_6_options = draft.SetShortBoolean(field_6_options, value); }
        }
 
        public bool Notes
        {
            get
            {
                return notes.IsSet(field_6_options);
            }
            set { field_6_options = notes.SetShortBoolean(field_6_options, value); }
        }
 
        public bool NoOrientation
        {
            get { return noOrientation.IsSet(field_6_options); }
            set { field_6_options = noOrientation.SetShortBoolean(field_6_options, value); }
        }
 
        public bool UsePage
        {
            get{return usepage.IsSet(field_6_options);}
            set { field_6_options = usepage.SetShortBoolean(field_6_options, value); }
        }
 
        // end option bitfields
        public short HResolution
        {
            get { return field_7_hresolution; }
            set { field_7_hresolution = value; }
        }
 
        public short VResolution
        {
            get { return field_8_vresolution; }
            set { field_8_vresolution = value; }
        }
 
        public double HeaderMargin
        {
            get { return field_9_headermargin; }
            set { field_9_headermargin = value; }
        }
 
        public double FooterMargin
        {
            get { return field_10_footermargin; }
            set { field_10_footermargin = value; }
        }
 
        public bool EndNote
        {
            get { return endnote.IsSet(field_6_options); }
            set { field_6_options = endnote.SetShortBoolean(field_6_options, value); }
        }
 
        public short CellError
        {
            get { return ierror.GetShortValue(field_6_options); }
            set 
            {
                field_6_options = ierror.SetShortValue(field_6_options, value);
            }
        }
 
        public short Copies
        {
            get { return field_11_copies; }
            set { field_11_copies = value; }
        }
 
        public override String ToString()
        {
            StringBuilder buffer = new StringBuilder();
 
            buffer.Append("[PRINTSetUP]\n");
            buffer.Append("    .papersize      = ").Append(PaperSize)
                .Append("\n");
            buffer.Append("    .scale          = ").Append(Scale)
                .Append("\n");
            buffer.Append("    .pagestart      = ").Append(PageStart)
                .Append("\n");
            buffer.Append("    .fitwidth       = ").Append(FitWidth)
                .Append("\n");
            buffer.Append("    .fitheight      = ").Append(FitHeight)
                .Append("\n");
            buffer.Append("    .options        = ").Append(Options)
                .Append("\n");
            buffer.Append("        .ltor       = ").Append(LeftToRight)
                .Append("\n");
            buffer.Append("        .landscape  = ").Append(Landscape)
                .Append("\n");
            buffer.Append("        .valid      = ").Append(ValidSettings)
                .Append("\n");
            buffer.Append("        .mono       = ").Append(NoColor)
                .Append("\n");
            buffer.Append("        .draft      = ").Append(Draft)
                .Append("\n");
            buffer.Append("        .notes      = ").Append(Notes)
                .Append("\n");
            buffer.Append("        .noOrientat = ").Append(NoOrientation)
                .Append("\n");
            buffer.Append("        .usepage    = ").Append(UsePage)
                .Append("\n");
            buffer.Append("    .hresolution    = ").Append(HResolution)
                .Append("\n");
            buffer.Append("    .vresolution    = ").Append(VResolution)
                .Append("\n");
            buffer.Append("    .headermargin   = ").Append(HeaderMargin)
                .Append("\n");
            buffer.Append("    .footermargin   = ").Append(FooterMargin)
                .Append("\n");
            buffer.Append("    .copies         = ").Append(Copies)
                .Append("\n");
            buffer.Append("[/PRINTSetUP]\n");
            return buffer.ToString();
        }
 
        public override void Serialize(ILittleEndianOutput out1)
        {
            out1.WriteShort(PaperSize);
            out1.WriteShort(Scale);
            out1.WriteShort(PageStart);
            out1.WriteShort(FitWidth);
            out1.WriteShort(FitHeight);
            out1.WriteShort(Options);
            out1.WriteShort(HResolution);
            out1.WriteShort(VResolution);
            out1.WriteDouble(HeaderMargin);
            out1.WriteDouble(FooterMargin);
            out1.WriteShort(Copies);
        }
 
        protected override int DataSize
        {
            get { return 34; }
        }
 
        public override short Sid
        {
            get { return sid; }
        }
 
        public override Object Clone()
        {
            PrintSetupRecord rec = new PrintSetupRecord();
            rec.field_1_paper_size = field_1_paper_size;
            rec.field_2_scale = field_2_scale;
            rec.field_3_page_start = field_3_page_start;
            rec.field_4_fit_width = field_4_fit_width;
            rec.field_5_fit_height = field_5_fit_height;
            rec.field_6_options = field_6_options;
            rec.field_7_hresolution = field_7_hresolution;
            rec.field_8_vresolution = field_8_vresolution;
            rec.field_9_headermargin = field_9_headermargin;
            rec.field_10_footermargin = field_10_footermargin;
            rec.field_11_copies = field_11_copies;
            return rec;
        }
    }
}