zhao
2021-07-09 0821715ebc11d3934d0594a1cc2c39686d808906
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
327
328
329
330
331
332
333
334
/* ====================================================================
   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.UserModel
{
    using System;
    using HH.WMS.Utils.NPOI.HSSF.Record;
    using HH.WMS.Utils.NPOI.HSSF.Record.CF;
    using HH.WMS.Utils.NPOI.SS.UserModel;
 
    /**
     * High level representation for Font Formatting component
     * of Conditional Formatting Settings
     * 
     * @author Dmitriy Kumshayev
     *
     */
    public class HSSFFontFormatting : IFontFormatting
    {
 
        private FontFormatting fontFormatting;
 
        public HSSFFontFormatting(CFRuleRecord cfRuleRecord)
        {
            this.fontFormatting = cfRuleRecord.FontFormatting;
        }
 
        protected FontFormatting GetFontFormattingBlock()
        {
            return fontFormatting;
        }
 
        /**
         * Get the type of base or subscript for the font
         *
         * @return base or subscript option
         * @see #SS_NONE
         * @see #SS_SUPER
         * @see #SS_SUB
         */
        public FontSuperScript EscapementType
        {
            get
            {
                return (FontSuperScript)fontFormatting.EscapementType;
            }
            set
            {
                switch (value)
                {
                    case FontSuperScript.SUB:
                    case FontSuperScript.SUPER:
                        fontFormatting.EscapementType = value;
                        fontFormatting.IsEscapementTypeModified = true;
                        break;
                    case FontSuperScript.NONE:
                        fontFormatting.EscapementType = value;
                        fontFormatting.IsEscapementTypeModified = false;
                        break;
                }
            }
        }
 
        /**
         * @return font color index
         */
        public short FontColorIndex
        {
            get
            {
                return fontFormatting.FontColorIndex;
            }
            set { fontFormatting.FontColorIndex=(value); }
        }
 
        /**
         * Gets the height of the font in 1/20th point Units
         *
         * @return fontheight (in points/20); or -1 if not modified
         */
        public int FontHeight
        {
            get { return fontFormatting.FontHeight; }
            set { fontFormatting.FontHeight=(value); }
        }
 
        /**
         * Get the font weight for this font (100-1000dec or 0x64-0x3e8).  Default Is
         * 0x190 for normal and 0x2bc for bold
         *
         * @return bw - a number between 100-1000 for the fonts "boldness"
         */
 
        public short FontWeight
        {
            get { return fontFormatting.FontWeight; }
        }
 
        /**
         * @return
         * @see org.apache.poi.hssf.record.cf.FontFormatting#GetRawRecord()
         */
        protected byte[] GetRawRecord()
        {
            return fontFormatting.GetRawRecord();
        }
 
        /**
         * Get the type of Underlining for the font
         *
         * @return font Underlining type
         *
         * @see #U_NONE
         * @see #U_SINGLE
         * @see #U_DOUBLE
         * @see #U_SINGLE_ACCOUNTING
         * @see #U_DOUBLE_ACCOUNTING
         */
        public FontUnderlineType UnderlineType
        {
            get
            {
                return (FontUnderlineType)fontFormatting.UnderlineType;
            }
            set
            {
                switch (value)
                {
                    case FontUnderlineType.SINGLE:
                    case FontUnderlineType.DOUBLE:
                    case FontUnderlineType.SINGLE_ACCOUNTING:
                    case FontUnderlineType.DOUBLE_ACCOUNTING:
                        fontFormatting.UnderlineType = value;
                        IsUnderlineTypeModified = true;
                        break;
 
                    case FontUnderlineType.NONE:
                        fontFormatting.UnderlineType = value;
                        IsUnderlineTypeModified = false;
                        break;
 
                }
            }
        }
 
        /**
         * Get whether the font weight Is Set to bold or not
         *
         * @return bold - whether the font Is bold or not
         */
        public bool IsBold
        {
            get
            {
                return fontFormatting.IsFontWeightModified && fontFormatting.IsBold;
            }
        }
 
        /**
         * @return true if escapement type was modified from default   
         */
        public bool IsEscapementTypeModified
        {
            get{
                return fontFormatting.IsEscapementTypeModified;
            }
            set { fontFormatting.IsEscapementTypeModified=value; }
        }
 
        /**
         * @return true if font cancellation was modified from default   
         */
        public bool IsFontCancellationModified
        {
            get{
            return fontFormatting.IsFontCancellationModified;
            }
            set { fontFormatting.IsFontCancellationModified=(value); }
        }
 
        /**
         * @return true if font outline type was modified from default   
         */
        public bool IsFontOutlineModified
        {
            get
            {
                return fontFormatting.IsFontOutlineModified;
            }
            set { fontFormatting.IsFontOutlineModified=(value); }
        }
 
        /**
         * @return true if font shadow type was modified from default   
         */
        public bool IsFontShadowModified
        {
            get
            {
                return fontFormatting.IsFontShadowModified;
            }
            set { fontFormatting.IsFontShadowModified=value; }
        }
 
        /**
         * @return true if font style was modified from default   
         */
        public bool IsFontStyleModified
        {
            get
            {
                return fontFormatting.IsFontStyleModified;
            }
            set { fontFormatting.IsFontStyleModified=value; }
        }
 
        /**
         * @return true if font style was Set to <i>italic</i> 
         */
        public bool IsItalic
        {
            get { return fontFormatting.IsFontStyleModified && fontFormatting.IsItalic; }
        }
 
        /**
         * @return true if font outline Is on
         */
        public bool IsOutlineOn
        {
            get
            {
                return fontFormatting.IsFontOutlineModified && fontFormatting.IsOutlineOn;
            }
            set
            {
                fontFormatting.IsOutlineOn=value;
                fontFormatting.IsFontOutlineModified=value;
            }
        }
 
        /**
         * @return true if font shadow Is on
         */
        public bool IsShadowOn
        {
            get{return fontFormatting.IsFontOutlineModified && fontFormatting.IsShadowOn;}
            set
            {
                fontFormatting.IsShadowOn=value;
                fontFormatting.IsFontShadowModified=value;
            }
        }
 
        /**
         * @return true if font strikeout Is on
         */
        public bool IsStrikeout
        {
            get
            {
                return fontFormatting.IsFontCancellationModified && fontFormatting.IsStruckout;
 
            }
            set
            {
                fontFormatting.IsStruckout = (value);
                fontFormatting.IsFontCancellationModified = (value);
            }
        }
 
        /**
         * @return true if font Underline type was modified from default   
         */
        public bool IsUnderlineTypeModified
        {
            get{return fontFormatting.IsUnderlineTypeModified;}
            set { fontFormatting.IsUnderlineTypeModified=value; }
        }
 
        /**
         * @return true if font weight was modified from default   
         */
        public bool IsFontWeightModified
        {
            get{
                return fontFormatting.IsFontWeightModified;
            }
 
        }
 
        /**
         * Set font style options.
         * 
         * @param italic - if true, Set posture style to italic, otherwise to normal 
         * @param bold- if true, Set font weight to bold, otherwise to normal
         */
 
        public void SetFontStyle(bool italic, bool bold)
        {
            bool modified = italic || bold;
            fontFormatting.IsItalic=italic;
            fontFormatting.IsBold=bold;
            fontFormatting.IsFontStyleModified=modified;
            fontFormatting.IsFontWeightModified=modified;
        }
 
        /**
         * Set font style options to default values (non-italic, non-bold)
         */
        public void ResetFontStyle()
        {
            SetFontStyle(false, false);
        }
 
 
 
 
 
    }
}