npoi
700 строк · 16.0 Кб
1using NPOI.OpenXml4Net.Util;2using System;3using System.Collections.Generic;4using System.IO;5using System.Xml;6using System.Xml.Serialization;7
8namespace NPOI.OpenXmlFormats.Wordprocessing9{
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)]15public class CT_FontsList16{17
18private List<CT_Font> fontField;19
20public CT_FontsList()21{22this.fontField = new List<CT_Font>();23}24
25[XmlElement("font", Order = 0)]26public List<CT_Font> font27{28get29{30return this.fontField;31}32set33{34this.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)]44public class CT_Font45{46
47private CT_String altNameField;48
49private CT_Panose panose1Field;50
51private CT_UcharHexNumber charsetField;52
53private CT_FontFamily familyField;54
55private CT_OnOff notTrueTypeField;56
57private CT_Pitch pitchField;58
59private CT_FontSig sigField;60
61private CT_FontRel embedRegularField;62
63private CT_FontRel embedBoldField;64
65private CT_FontRel embedItalicField;66
67private CT_FontRel embedBoldItalicField;68
69private string nameField;70
71public CT_Font()72{73this.embedBoldItalicField = new CT_FontRel();74this.embedItalicField = new CT_FontRel();75this.embedBoldField = new CT_FontRel();76this.embedRegularField = new CT_FontRel();77this.sigField = new CT_FontSig();78this.pitchField = new CT_Pitch();79this.notTrueTypeField = new CT_OnOff();80this.familyField = new CT_FontFamily();81this.charsetField = new CT_UcharHexNumber();82this.panose1Field = new CT_Panose();83this.altNameField = new CT_String();84}85
86[XmlElement(Order = 0)]87public CT_String altName88{89get90{91return this.altNameField;92}93set94{95this.altNameField = value;96}97}98
99[XmlElement(Order = 1)]100public CT_Panose panose1101{102get103{104return this.panose1Field;105}106set107{108this.panose1Field = value;109}110}111
112[XmlElement(Order = 2)]113public CT_UcharHexNumber charset114{115get116{117return this.charsetField;118}119set120{121this.charsetField = value;122}123}124
125[XmlElement(Order = 3)]126public CT_FontFamily family127{128get129{130return this.familyField;131}132set133{134this.familyField = value;135}136}137
138[XmlElement(Order = 4)]139public CT_OnOff notTrueType140{141get142{143return this.notTrueTypeField;144}145set146{147this.notTrueTypeField = value;148}149}150
151[XmlElement(Order = 5)]152public CT_Pitch pitch153{154get155{156return this.pitchField;157}158set159{160this.pitchField = value;161}162}163
164[XmlElement(Order = 6)]165public CT_FontSig sig166{167get168{169return this.sigField;170}171set172{173this.sigField = value;174}175}176
177[XmlElement(Order = 7)]178public CT_FontRel embedRegular179{180get181{182return this.embedRegularField;183}184set185{186this.embedRegularField = value;187}188}189
190[XmlElement(Order = 8)]191public CT_FontRel embedBold192{193get194{195return this.embedBoldField;196}197set198{199this.embedBoldField = value;200}201}202
203[XmlElement(Order = 9)]204public CT_FontRel embedItalic205{206get207{208return this.embedItalicField;209}210set211{212this.embedItalicField = value;213}214}215
216[XmlElement(Order = 10)]217public CT_FontRel embedBoldItalic218{219get220{221return this.embedBoldItalicField;222}223set224{225this.embedBoldItalicField = value;226}227}228
229[XmlAttribute(Form = System.Xml.Schema.XmlSchemaForm.Qualified)]230public string name231{232get233{234return this.nameField;235}236set237{238this.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)]247public class CT_FontFamily248{249
250private ST_FontFamily valField;251
252[XmlAttribute(Form = System.Xml.Schema.XmlSchemaForm.Qualified)]253public ST_FontFamily val254{255get256{257return this.valField;258}259set260{261this.valField = value;262}263}264}265
266
267[Serializable]268[XmlType(Namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main")]269public enum ST_FontFamily270{271
272
273decorative,274
275
276modern,277
278
279roman,280
281
282script,283
284
285swiss,286
287
288auto,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)]296public class CT_Pitch297{298
299private ST_Pitch valField;300
301[XmlAttribute(Form = System.Xml.Schema.XmlSchemaForm.Qualified)]302public ST_Pitch val303{304get305{306return this.valField;307}308set309{310this.valField = value;311}312}313}314
315
316[Serializable]317[XmlType(Namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main")]318public enum ST_Pitch319{320
321
322@fixed,323
324
325variable,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)]336public class CT_FontSig337{338
339private byte[] usb0Field;340
341private byte[] usb1Field;342
343private byte[] usb2Field;344
345private byte[] usb3Field;346
347private byte[] csb0Field;348
349private byte[] csb1Field;350
351[XmlAttribute(Form = System.Xml.Schema.XmlSchemaForm.Qualified, DataType = "hexBinary")]352public byte[] usb0353{354get355{356return this.usb0Field;357}358set359{360this.usb0Field = value;361}362}363
364[XmlAttribute(Form = System.Xml.Schema.XmlSchemaForm.Qualified, DataType = "hexBinary")]365public byte[] usb1366{367get368{369return this.usb1Field;370}371set372{373this.usb1Field = value;374}375}376
377[XmlAttribute(Form = System.Xml.Schema.XmlSchemaForm.Qualified, DataType = "hexBinary")]378public byte[] usb2379{380get381{382return this.usb2Field;383}384set385{386this.usb2Field = value;387}388}389
390[XmlAttribute(Form = System.Xml.Schema.XmlSchemaForm.Qualified, DataType = "hexBinary")]391public byte[] usb3392{393get394{395return this.usb3Field;396}397set398{399this.usb3Field = value;400}401}402
403[XmlAttribute(Form = System.Xml.Schema.XmlSchemaForm.Qualified, DataType = "hexBinary")]404public byte[] csb0405{406get407{408return this.csb0Field;409}410set411{412this.csb0Field = value;413}414}415
416[XmlAttribute(Form = System.Xml.Schema.XmlSchemaForm.Qualified, DataType = "hexBinary")]417public byte[] csb1418{419get420{421return this.csb1Field;422}423set424{425this.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)]434public class CT_Fonts435{436
437private ST_Hint hintField;438
439private bool hintFieldSpecified;440
441private string asciiField;442
443private string hAnsiField;444
445private string eastAsiaField;446
447private string csField;448
449private ST_Theme? asciiThemeField;450
451private ST_Theme? hAnsiThemeField;452
453private ST_Theme? eastAsiaThemeField;454
455private ST_Theme? csthemeField;456
457public CT_Fonts()458{459this.hintField = ST_Hint.@default;460}461
462
463public static CT_Fonts Parse(XmlNode node, XmlNamespaceManager namespaceManager)464{465if (node == null)466return null;467CT_Fonts ctObj = new CT_Fonts();468ctObj.ascii = XmlHelper.ReadString(node.Attributes["w:ascii"]);469ctObj.hAnsi = XmlHelper.ReadString(node.Attributes["w:hAnsi"]);470ctObj.eastAsia = XmlHelper.ReadString(node.Attributes["w:eastAsia"]);471ctObj.cs = XmlHelper.ReadString(node.Attributes["w:cs"]);472if (node.Attributes["w:hint"] != null)473{474ctObj.hint = (ST_Hint)Enum.Parse(typeof(ST_Hint), node.Attributes["w:hint"].Value);475ctObj.hintFieldSpecified = true;476}477if (node.Attributes["w:asciiTheme"] != null)478ctObj.asciiTheme = (ST_Theme)Enum.Parse(typeof(ST_Theme), node.Attributes["w:asciiTheme"].Value);479if (node.Attributes["w:hAnsiTheme"] != null)480ctObj.hAnsiTheme = (ST_Theme)Enum.Parse(typeof(ST_Theme), node.Attributes["w:hAnsiTheme"].Value);481if (node.Attributes["w:eastAsiaTheme"] != null)482ctObj.eastAsiaTheme = (ST_Theme)Enum.Parse(typeof(ST_Theme), node.Attributes["w:eastAsiaTheme"].Value);483if (node.Attributes["w:cstheme"] != null)484ctObj.cstheme = (ST_Theme)Enum.Parse(typeof(ST_Theme), node.Attributes["w:cstheme"].Value);485return ctObj;486}487
488internal void Write(StreamWriter sw, string nodeName)489{490sw.Write(string.Format("<w:{0}", nodeName));491XmlHelper.WriteAttribute(sw, "w:ascii", this.ascii);492if(this.eastAsiaTheme !=null)493XmlHelper.WriteAttribute(sw, "w:eastAsiaTheme", this.eastAsiaTheme.ToString());494XmlHelper.WriteAttribute(sw, "w:eastAsia", this.eastAsia);495XmlHelper.WriteAttribute(sw, "w:hAnsi", this.hAnsi);496XmlHelper.WriteAttribute(sw, "w:cs", this.cs);497if(this.hint != ST_Hint.@default || this.hintFieldSpecified)498XmlHelper.WriteAttribute(sw, "w:hint", this.hint.ToString());499
500if(this.asciiTheme != null)501XmlHelper.WriteAttribute(sw, "w:asciiTheme", this.asciiTheme.ToString());502if (this.hAnsiTheme != ST_Theme.majorEastAsia)503XmlHelper.WriteAttribute(sw, "w:hAnsiTheme", this.hAnsiTheme.ToString());504if (this.cstheme != null)505XmlHelper.WriteAttribute(sw, "w:cstheme", this.cstheme.ToString());506sw.Write("/>");507}508
509
510[XmlAttribute(Form = System.Xml.Schema.XmlSchemaForm.Qualified)]511public ST_Hint hint512{513get514{515return this.hintField;516}517set518{519this.hintField = value;520this.hintFieldSpecified = true;521}522}523
524[XmlIgnore]525public bool hintSpecified526{527get528{529return this.hintFieldSpecified;530}531set532{533this.hintFieldSpecified = value;534}535}536
537[XmlAttribute(Form = System.Xml.Schema.XmlSchemaForm.Qualified)]538public string ascii539{540get541{542return this.asciiField;543}544set545{546this.asciiField = value;547}548}549
550[XmlAttribute(Form = System.Xml.Schema.XmlSchemaForm.Qualified)]551public string hAnsi552{553get554{555return this.hAnsiField;556}557set558{559this.hAnsiField = value;560}561}562
563[XmlAttribute(Form = System.Xml.Schema.XmlSchemaForm.Qualified)]564public string eastAsia565{566get567{568return this.eastAsiaField;569}570set571{572this.eastAsiaField = value;573}574}575
576[XmlAttribute(Form = System.Xml.Schema.XmlSchemaForm.Qualified)]577public string cs578{579get580{581return this.csField;582}583set584{585this.csField = value;586}587}588
589public ST_Theme? asciiTheme590{591get592{593return this.asciiThemeField;594}595set596{597this.asciiThemeField = value;598}599}600
601public ST_Theme? hAnsiTheme602{603get604{605return this.hAnsiThemeField;606}607set608{609this.hAnsiThemeField = value;610}611}612
613
614public ST_Theme? eastAsiaTheme615{616get617{618return this.eastAsiaThemeField;619}620set621{622this.eastAsiaThemeField = value;623}624}625
626
627public ST_Theme? cstheme628{629get630{631return this.csthemeField;632}633set634{635this.csthemeField = value;636}637}638
639public bool IsSetHAnsi()640{641return !string.IsNullOrEmpty(this.hAnsiField);642}643
644public bool IsSetCs()645{646return !string.IsNullOrEmpty(this.csField);647}648
649public bool IsSetEastAsia()650{651return !string.IsNullOrEmpty(this.eastAsiaField);652}653}654
655
656[Serializable]657[XmlType(Namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main")]658public enum ST_Hint659{660
661
662@default,663
664
665eastAsia,666
667
668cs,669}670[Serializable]671[XmlType(Namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main")]672public enum ST_Theme673{674
675
676majorEastAsia,677
678
679majorBidi,680
681
682majorAscii,683
684
685majorHAnsi,686
687
688minorEastAsia,689
690
691minorBidi,692
693
694minorAscii,695
696
697minorHAnsi,698}699
700}