npoi

Форк
0
700 строк · 16.0 Кб
1
using NPOI.OpenXml4Net.Util;
2
using System;
3
using System.Collections.Generic;
4
using System.IO;
5
using System.Xml;
6
using System.Xml.Serialization;
7

8
namespace NPOI.OpenXmlFormats.Wordprocessing
9
{
10

11
    [Serializable]
12

13
    [XmlType(Namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main")]
14
    [XmlRoot("fonts", Namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", IsNullable = false)]
15
    public class CT_FontsList
16
    {
17

18
        private List<CT_Font> fontField;
19

20
        public CT_FontsList()
21
        {
22
            this.fontField = new List<CT_Font>();
23
        }
24

25
        [XmlElement("font", Order = 0)]
26
        public List<CT_Font> font
27
        {
28
            get
29
            {
30
                return this.fontField;
31
            }
32
            set
33
            {
34
                this.fontField = value;
35
            }
36
        }
37
    }
38

39

40
    [Serializable]
41

42
    [XmlType(Namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main")]
43
    [XmlRoot(Namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", IsNullable = true)]
44
    public class CT_Font
45
    {
46

47
        private CT_String altNameField;
48

49
        private CT_Panose panose1Field;
50

51
        private CT_UcharHexNumber charsetField;
52

53
        private CT_FontFamily familyField;
54

55
        private CT_OnOff notTrueTypeField;
56

57
        private CT_Pitch pitchField;
58

59
        private CT_FontSig sigField;
60

61
        private CT_FontRel embedRegularField;
62

63
        private CT_FontRel embedBoldField;
64

65
        private CT_FontRel embedItalicField;
66

67
        private CT_FontRel embedBoldItalicField;
68

69
        private string nameField;
70

71
        public CT_Font()
72
        {
73
            this.embedBoldItalicField = new CT_FontRel();
74
            this.embedItalicField = new CT_FontRel();
75
            this.embedBoldField = new CT_FontRel();
76
            this.embedRegularField = new CT_FontRel();
77
            this.sigField = new CT_FontSig();
78
            this.pitchField = new CT_Pitch();
79
            this.notTrueTypeField = new CT_OnOff();
80
            this.familyField = new CT_FontFamily();
81
            this.charsetField = new CT_UcharHexNumber();
82
            this.panose1Field = new CT_Panose();
83
            this.altNameField = new CT_String();
84
        }
85

86
        [XmlElement(Order = 0)]
87
        public CT_String altName
88
        {
89
            get
90
            {
91
                return this.altNameField;
92
            }
93
            set
94
            {
95
                this.altNameField = value;
96
            }
97
        }
98

99
        [XmlElement(Order = 1)]
100
        public CT_Panose panose1
101
        {
102
            get
103
            {
104
                return this.panose1Field;
105
            }
106
            set
107
            {
108
                this.panose1Field = value;
109
            }
110
        }
111

112
        [XmlElement(Order = 2)]
113
        public CT_UcharHexNumber charset
114
        {
115
            get
116
            {
117
                return this.charsetField;
118
            }
119
            set
120
            {
121
                this.charsetField = value;
122
            }
123
        }
124

125
        [XmlElement(Order = 3)]
126
        public CT_FontFamily family
127
        {
128
            get
129
            {
130
                return this.familyField;
131
            }
132
            set
133
            {
134
                this.familyField = value;
135
            }
136
        }
137

138
        [XmlElement(Order = 4)]
139
        public CT_OnOff notTrueType
140
        {
141
            get
142
            {
143
                return this.notTrueTypeField;
144
            }
145
            set
146
            {
147
                this.notTrueTypeField = value;
148
            }
149
        }
150

151
        [XmlElement(Order = 5)]
152
        public CT_Pitch pitch
153
        {
154
            get
155
            {
156
                return this.pitchField;
157
            }
158
            set
159
            {
160
                this.pitchField = value;
161
            }
162
        }
163

164
        [XmlElement(Order = 6)]
165
        public CT_FontSig sig
166
        {
167
            get
168
            {
169
                return this.sigField;
170
            }
171
            set
172
            {
173
                this.sigField = value;
174
            }
175
        }
176

177
        [XmlElement(Order = 7)]
178
        public CT_FontRel embedRegular
179
        {
180
            get
181
            {
182
                return this.embedRegularField;
183
            }
184
            set
185
            {
186
                this.embedRegularField = value;
187
            }
188
        }
189

190
        [XmlElement(Order = 8)]
191
        public CT_FontRel embedBold
192
        {
193
            get
194
            {
195
                return this.embedBoldField;
196
            }
197
            set
198
            {
199
                this.embedBoldField = value;
200
            }
201
        }
202

203
        [XmlElement(Order = 9)]
204
        public CT_FontRel embedItalic
205
        {
206
            get
207
            {
208
                return this.embedItalicField;
209
            }
210
            set
211
            {
212
                this.embedItalicField = value;
213
            }
214
        }
215

216
        [XmlElement(Order = 10)]
217
        public CT_FontRel embedBoldItalic
218
        {
219
            get
220
            {
221
                return this.embedBoldItalicField;
222
            }
223
            set
224
            {
225
                this.embedBoldItalicField = value;
226
            }
227
        }
228

229
        [XmlAttribute(Form = System.Xml.Schema.XmlSchemaForm.Qualified)]
230
        public string name
231
        {
232
            get
233
            {
234
                return this.nameField;
235
            }
236
            set
237
            {
238
                this.nameField = value;
239
            }
240
        }
241
    }
242

243
    [Serializable]
244

245
    [XmlType(Namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main")]
246
    [XmlRoot(Namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", IsNullable = true)]
247
    public class CT_FontFamily
248
    {
249

250
        private ST_FontFamily valField;
251

252
        [XmlAttribute(Form = System.Xml.Schema.XmlSchemaForm.Qualified)]
253
        public ST_FontFamily val
254
        {
255
            get
256
            {
257
                return this.valField;
258
            }
259
            set
260
            {
261
                this.valField = value;
262
            }
263
        }
264
    }
265

266

267
    [Serializable]
268
    [XmlType(Namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main")]
269
    public enum ST_FontFamily
270
    {
271

272
    
273
        decorative,
274

275
    
276
        modern,
277

278
    
279
        roman,
280

281
    
282
        script,
283

284
    
285
        swiss,
286

287
    
288
        auto,
289
    }
290

291

292
    [Serializable]
293

294
    [XmlType(Namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main")]
295
    [XmlRoot(Namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", IsNullable = true)]
296
    public class CT_Pitch
297
    {
298

299
        private ST_Pitch valField;
300

301
        [XmlAttribute(Form = System.Xml.Schema.XmlSchemaForm.Qualified)]
302
        public ST_Pitch val
303
        {
304
            get
305
            {
306
                return this.valField;
307
            }
308
            set
309
            {
310
                this.valField = value;
311
            }
312
        }
313
    }
314

315

316
    [Serializable]
317
    [XmlType(Namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main")]
318
    public enum ST_Pitch
319
    {
320

321
    
322
        @fixed,
323

324
    
325
        variable,
326

327
    
328
        @default,
329
    }
330

331

332
    [Serializable]
333

334
    [XmlType(Namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main")]
335
    [XmlRoot(Namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", IsNullable = true)]
336
    public class CT_FontSig
337
    {
338

339
        private byte[] usb0Field;
340

341
        private byte[] usb1Field;
342

343
        private byte[] usb2Field;
344

345
        private byte[] usb3Field;
346

347
        private byte[] csb0Field;
348

349
        private byte[] csb1Field;
350

351
        [XmlAttribute(Form = System.Xml.Schema.XmlSchemaForm.Qualified, DataType = "hexBinary")]
352
        public byte[] usb0
353
        {
354
            get
355
            {
356
                return this.usb0Field;
357
            }
358
            set
359
            {
360
                this.usb0Field = value;
361
            }
362
        }
363

364
        [XmlAttribute(Form = System.Xml.Schema.XmlSchemaForm.Qualified, DataType = "hexBinary")]
365
        public byte[] usb1
366
        {
367
            get
368
            {
369
                return this.usb1Field;
370
            }
371
            set
372
            {
373
                this.usb1Field = value;
374
            }
375
        }
376

377
        [XmlAttribute(Form = System.Xml.Schema.XmlSchemaForm.Qualified, DataType = "hexBinary")]
378
        public byte[] usb2
379
        {
380
            get
381
            {
382
                return this.usb2Field;
383
            }
384
            set
385
            {
386
                this.usb2Field = value;
387
            }
388
        }
389

390
        [XmlAttribute(Form = System.Xml.Schema.XmlSchemaForm.Qualified, DataType = "hexBinary")]
391
        public byte[] usb3
392
        {
393
            get
394
            {
395
                return this.usb3Field;
396
            }
397
            set
398
            {
399
                this.usb3Field = value;
400
            }
401
        }
402

403
        [XmlAttribute(Form = System.Xml.Schema.XmlSchemaForm.Qualified, DataType = "hexBinary")]
404
        public byte[] csb0
405
        {
406
            get
407
            {
408
                return this.csb0Field;
409
            }
410
            set
411
            {
412
                this.csb0Field = value;
413
            }
414
        }
415

416
        [XmlAttribute(Form = System.Xml.Schema.XmlSchemaForm.Qualified, DataType = "hexBinary")]
417
        public byte[] csb1
418
        {
419
            get
420
            {
421
                return this.csb1Field;
422
            }
423
            set
424
            {
425
                this.csb1Field = value;
426
            }
427
        }
428
    }
429

430
    [Serializable]
431

432
    [XmlType(Namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main")]
433
    [XmlRoot(Namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", IsNullable = true)]
434
    public class CT_Fonts
435
    {
436

437
        private ST_Hint hintField;
438

439
        private bool hintFieldSpecified;
440

441
        private string asciiField;
442

443
        private string hAnsiField;
444

445
        private string eastAsiaField;
446

447
        private string csField;
448

449
        private ST_Theme? asciiThemeField;
450

451
        private ST_Theme? hAnsiThemeField;
452

453
        private ST_Theme? eastAsiaThemeField;
454

455
        private ST_Theme? csthemeField;
456

457
        public CT_Fonts()
458
        {
459
            this.hintField = ST_Hint.@default;
460
        }
461

462

463
        public static CT_Fonts Parse(XmlNode node, XmlNamespaceManager namespaceManager)
464
        {
465
            if (node == null)
466
                return null;
467
            CT_Fonts ctObj = new CT_Fonts();
468
            ctObj.ascii = XmlHelper.ReadString(node.Attributes["w:ascii"]);
469
            ctObj.hAnsi = XmlHelper.ReadString(node.Attributes["w:hAnsi"]);
470
            ctObj.eastAsia = XmlHelper.ReadString(node.Attributes["w:eastAsia"]);
471
            ctObj.cs = XmlHelper.ReadString(node.Attributes["w:cs"]);
472
            if (node.Attributes["w:hint"] != null)
473
            {
474
                ctObj.hint = (ST_Hint)Enum.Parse(typeof(ST_Hint), node.Attributes["w:hint"].Value);
475
                ctObj.hintFieldSpecified = true;
476
            }
477
            if (node.Attributes["w:asciiTheme"] != null)
478
                ctObj.asciiTheme = (ST_Theme)Enum.Parse(typeof(ST_Theme), node.Attributes["w:asciiTheme"].Value);
479
            if (node.Attributes["w:hAnsiTheme"] != null)
480
                ctObj.hAnsiTheme = (ST_Theme)Enum.Parse(typeof(ST_Theme), node.Attributes["w:hAnsiTheme"].Value);
481
            if (node.Attributes["w:eastAsiaTheme"] != null)
482
                ctObj.eastAsiaTheme = (ST_Theme)Enum.Parse(typeof(ST_Theme), node.Attributes["w:eastAsiaTheme"].Value);
483
            if (node.Attributes["w:cstheme"] != null)
484
                ctObj.cstheme = (ST_Theme)Enum.Parse(typeof(ST_Theme), node.Attributes["w:cstheme"].Value);
485
            return ctObj;
486
        }
487

488
        internal void Write(StreamWriter sw, string nodeName)
489
        {
490
            sw.Write(string.Format("<w:{0}", nodeName));
491
            XmlHelper.WriteAttribute(sw, "w:ascii", this.ascii);
492
            if(this.eastAsiaTheme !=null)
493
                XmlHelper.WriteAttribute(sw, "w:eastAsiaTheme", this.eastAsiaTheme.ToString());
494
            XmlHelper.WriteAttribute(sw, "w:eastAsia", this.eastAsia);
495
            XmlHelper.WriteAttribute(sw, "w:hAnsi", this.hAnsi);
496
            XmlHelper.WriteAttribute(sw, "w:cs", this.cs);
497
            if(this.hint != ST_Hint.@default || this.hintFieldSpecified)
498
                XmlHelper.WriteAttribute(sw, "w:hint", this.hint.ToString());
499

500
            if(this.asciiTheme != null)
501
                XmlHelper.WriteAttribute(sw, "w:asciiTheme", this.asciiTheme.ToString());
502
            if (this.hAnsiTheme != ST_Theme.majorEastAsia)
503
                XmlHelper.WriteAttribute(sw, "w:hAnsiTheme", this.hAnsiTheme.ToString());
504
            if (this.cstheme != null)
505
                XmlHelper.WriteAttribute(sw, "w:cstheme", this.cstheme.ToString());
506
            sw.Write("/>");
507
        }
508

509

510
        [XmlAttribute(Form = System.Xml.Schema.XmlSchemaForm.Qualified)]
511
        public ST_Hint hint
512
        {
513
            get
514
            {
515
                return this.hintField;
516
            }
517
            set
518
            {
519
                this.hintField = value;
520
                this.hintFieldSpecified = true;
521
            }
522
        }
523

524
        [XmlIgnore]
525
        public bool hintSpecified
526
        {
527
            get
528
            {
529
                return this.hintFieldSpecified;
530
            }
531
            set
532
            {
533
                this.hintFieldSpecified = value;
534
            }
535
        }
536

537
        [XmlAttribute(Form = System.Xml.Schema.XmlSchemaForm.Qualified)]
538
        public string ascii
539
        {
540
            get
541
            {
542
                return this.asciiField;
543
            }
544
            set
545
            {
546
                this.asciiField = value;
547
            }
548
        }
549

550
        [XmlAttribute(Form = System.Xml.Schema.XmlSchemaForm.Qualified)]
551
        public string hAnsi
552
        {
553
            get
554
            {
555
                return this.hAnsiField;
556
            }
557
            set
558
            {
559
                this.hAnsiField = value;
560
            }
561
        }
562

563
        [XmlAttribute(Form = System.Xml.Schema.XmlSchemaForm.Qualified)]
564
        public string eastAsia
565
        {
566
            get
567
            {
568
                return this.eastAsiaField;
569
            }
570
            set
571
            {
572
                this.eastAsiaField = value;
573
            }
574
        }
575

576
        [XmlAttribute(Form = System.Xml.Schema.XmlSchemaForm.Qualified)]
577
        public string cs
578
        {
579
            get
580
            {
581
                return this.csField;
582
            }
583
            set
584
            {
585
                this.csField = value;
586
            }
587
        }
588

589
        public ST_Theme? asciiTheme
590
        {
591
            get
592
            {
593
                return this.asciiThemeField;
594
            }
595
            set
596
            {
597
                this.asciiThemeField = value;
598
            }
599
        }
600

601
        public ST_Theme? hAnsiTheme
602
        {
603
            get
604
            {
605
                return this.hAnsiThemeField;
606
            }
607
            set
608
            {
609
                this.hAnsiThemeField = value;
610
            }
611
        }
612

613

614
        public ST_Theme? eastAsiaTheme
615
        {
616
            get
617
            {
618
                return this.eastAsiaThemeField;
619
            }
620
            set
621
            {
622
                this.eastAsiaThemeField = value;
623
            }
624
        }
625

626

627
        public ST_Theme? cstheme
628
        {
629
            get
630
            {
631
                return this.csthemeField;
632
            }
633
            set
634
            {
635
                this.csthemeField = value;
636
            }
637
        }
638

639
        public bool IsSetHAnsi()
640
        {
641
            return !string.IsNullOrEmpty(this.hAnsiField);
642
        }
643

644
        public bool IsSetCs()
645
        {
646
            return !string.IsNullOrEmpty(this.csField);
647
        }
648

649
        public bool IsSetEastAsia()
650
        {
651
            return !string.IsNullOrEmpty(this.eastAsiaField);
652
        }
653
    }
654

655

656
    [Serializable]
657
    [XmlType(Namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main")]
658
    public enum ST_Hint
659
    {
660

661
    
662
        @default,
663

664
    
665
        eastAsia,
666

667
    
668
        cs,
669
    }
670
    [Serializable]
671
    [XmlType(Namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main")]
672
    public enum ST_Theme
673
    {
674

675
    
676
        majorEastAsia,
677

678
    
679
        majorBidi,
680

681
    
682
        majorAscii,
683

684
    
685
        majorHAnsi,
686

687
    
688
        minorEastAsia,
689

690
    
691
        minorBidi,
692

693
    
694
        minorAscii,
695

696
    
697
        minorHAnsi,
698
    }
699

700
}

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.