npoi
441 строка · 9.8 Кб
1using NPOI.OpenXml4Net.Util;2using System;3using System.IO;4using System.Xml;5using System.Xml.Serialization;6
7namespace NPOI.OpenXmlFormats.Vml.Wordprocessing8{
9[Serializable]10
11[System.ComponentModel.DesignerCategory("code")]12[XmlType(Namespace="urn:schemas-microsoft-com:office:word")]13[XmlRoot(Namespace="urn:schemas-microsoft-com:office:word", IsNullable=true)]14public class CT_Border {15
16private ST_BorderType typeField;17
18private bool typeFieldSpecified;19
20private string widthField;21
22private ST_BorderShadow shadowField;23
24private bool shadowFieldSpecified;25
26public static CT_Border Parse(XmlNode node, XmlNamespaceManager namespaceManager)27{28if (node == null)29return null;30CT_Border ctObj = new CT_Border();31if (node.Attributes["type"] != null)32ctObj.type = (ST_BorderType)Enum.Parse(typeof(ST_BorderType), node.Attributes["type"].Value);33ctObj.width = XmlHelper.ReadString(node.Attributes["width"]);34
35ctObj.shadow = NPOI.OpenXmlFormats.Util.XmlHelper.ReadBorderShadow(node.Attributes["shadow"]);36return ctObj;37}38
39internal void Write(StreamWriter sw, string nodeName)40{41sw.Write(string.Format("<w:{0}", nodeName));42if(this.type!= ST_BorderType.none)43XmlHelper.WriteAttribute(sw, "type", this.type.ToString());44XmlHelper.WriteAttribute(sw, "width", this.width);45NPOI.OpenXmlFormats.Util.XmlHelper.WriteAttribute(sw, "shadow", this.shadow);46sw.Write(">");47sw.WriteEndW(nodeName);48}49
50[XmlAttribute]51public ST_BorderType type {52get {53return this.typeField;54}55set {56this.typeField = value;57}58}59
60
61[XmlIgnore]62public bool typeSpecified {63get {64return this.typeFieldSpecified;65}66set {67this.typeFieldSpecified = value;68}69}70
71
72[XmlAttribute(DataType="positiveInteger")]73public string width {74get {75return this.widthField;76}77set {78this.widthField = value;79}80}81
82
83[XmlAttribute]84public ST_BorderShadow shadow {85get {86return this.shadowField;87}88set {89this.shadowField = value;90}91}92
93
94[XmlIgnore]95public bool shadowSpecified {96get {97return this.shadowFieldSpecified;98}99set {100this.shadowFieldSpecified = value;101}102}103}104
105
106[Serializable]107[XmlType(Namespace="urn:schemas-microsoft-com:office:word")]108[XmlRoot(Namespace="urn:schemas-microsoft-com:office:word", IsNullable=false)]109public enum ST_BorderType {110
111
112none,113
114
115single,116
117
118thick,119
120
121@double,122
123
124hairline,125
126
127dot,128
129
130dash,131
132
133dotDash,134
135
136dashDotDot,137
138
139triple,140
141
142thinThickSmall,143
144
145thickThinSmall,146
147
148thickBetweenThinSmall,149
150
151thinThick,152
153
154thickThin,155
156
157thickBetweenThin,158
159
160thinThickLarge,161
162
163thickThinLarge,164
165
166thickBetweenThinLarge,167
168
169wave,170
171
172doubleWave,173
174
175dashedSmall,176
177
178dashDotStroked,179
180
181threeDEmboss,182
183
184threeDEngrave,185
186
187HTMLOutset,188
189
190HTMLInset,191}192
193
194[Serializable]195[XmlType(Namespace="urn:schemas-microsoft-com:office:word")]196[XmlRoot(Namespace="urn:schemas-microsoft-com:office:word", IsNullable=false)]197public enum ST_BorderShadow {198
199
200t,201
202
203@true,204
205
206f,207
208
209@false,210}211
212
213[Serializable]214
215[System.ComponentModel.DesignerCategory("code")]216[XmlType(Namespace="urn:schemas-microsoft-com:office:word")]217[XmlRoot(Namespace="urn:schemas-microsoft-com:office:word", IsNullable=true)]218public class CT_Wrap {219
220private ST_WrapType typeField;221
222private bool typeFieldSpecified;223
224private ST_WrapSide sideField;225
226private bool sideFieldSpecified;227
228private ST_HorizontalAnchor anchorxField;229
230private bool anchorxFieldSpecified;231
232private ST_VerticalAnchor anchoryField;233
234private bool anchoryFieldSpecified;235
236public static CT_Wrap Parse(XmlNode node, XmlNamespaceManager namespaceManager)237{238if (node == null)239return null;240CT_Wrap ctObj = new CT_Wrap();241if (node.Attributes["type"] != null)242ctObj.type = (ST_WrapType)Enum.Parse(typeof(ST_WrapType), node.Attributes["type"].Value);243if (node.Attributes["side"] != null)244ctObj.side = (ST_WrapSide)Enum.Parse(typeof(ST_WrapSide), node.Attributes["side"].Value);245if (node.Attributes["anchorx"] != null)246ctObj.anchorx = (ST_HorizontalAnchor)Enum.Parse(typeof(ST_HorizontalAnchor), node.Attributes["anchorx"].Value);247if (node.Attributes["anchory"] != null)248ctObj.anchory = (ST_VerticalAnchor)Enum.Parse(typeof(ST_VerticalAnchor), node.Attributes["anchory"].Value);249return ctObj;250}251
252
253
254internal void Write(StreamWriter sw, string nodeName)255{256sw.Write(string.Format("<w:{0}", nodeName));257if(this.type!=ST_WrapType.none)258XmlHelper.WriteAttribute(sw, "type", this.type.ToString());259XmlHelper.WriteAttribute(sw, "side", this.side.ToString());260XmlHelper.WriteAttribute(sw, "anchorx", this.anchorx.ToString());261XmlHelper.WriteAttribute(sw, "anchory", this.anchory.ToString());262sw.Write(">");263sw.WriteEndW(nodeName);264}265
266[XmlAttribute]267public ST_WrapType type {268get {269return this.typeField;270}271set {272this.typeField = value;273}274}275
276
277[XmlIgnore]278public bool typeSpecified {279get {280return this.typeFieldSpecified;281}282set {283this.typeFieldSpecified = value;284}285}286
287
288[XmlAttribute]289public ST_WrapSide side {290get {291return this.sideField;292}293set {294this.sideField = value;295}296}297
298
299[XmlIgnore]300public bool sideSpecified {301get {302return this.sideFieldSpecified;303}304set {305this.sideFieldSpecified = value;306}307}308
309
310[XmlAttribute]311public ST_HorizontalAnchor anchorx {312get {313return this.anchorxField;314}315set {316this.anchorxField = value;317}318}319
320
321[XmlIgnore]322public bool anchorxSpecified {323get {324return this.anchorxFieldSpecified;325}326set {327this.anchorxFieldSpecified = value;328}329}330
331
332[XmlAttribute]333public ST_VerticalAnchor anchory {334get {335return this.anchoryField;336}337set {338this.anchoryField = value;339}340}341
342
343[XmlIgnore]344public bool anchorySpecified {345get {346return this.anchoryFieldSpecified;347}348set {349this.anchoryFieldSpecified = value;350}351}352}353
354
355[Serializable]356[XmlType(Namespace="urn:schemas-microsoft-com:office:word")]357[XmlRoot(Namespace="urn:schemas-microsoft-com:office:word", IsNullable=false)]358public enum ST_WrapType {359
360
361topAndBottom,362
363
364square,365
366
367none,368
369
370tight,371
372
373through,374}375
376
377[Serializable]378[XmlType(Namespace="urn:schemas-microsoft-com:office:word")]379[XmlRoot(Namespace="urn:schemas-microsoft-com:office:word", IsNullable=false)]380public enum ST_WrapSide {381
382
383both,384
385
386left,387
388
389right,390
391
392largest,393}394
395
396[Serializable]397[XmlType(Namespace="urn:schemas-microsoft-com:office:word")]398[XmlRoot(Namespace="urn:schemas-microsoft-com:office:word", IsNullable=false)]399public enum ST_HorizontalAnchor {400
401
402margin,403
404
405page,406
407
408text,409
410
411@char,412}413
414
415[Serializable]416[XmlType(Namespace="urn:schemas-microsoft-com:office:word")]417[XmlRoot(Namespace="urn:schemas-microsoft-com:office:word", IsNullable=false)]418public enum ST_VerticalAnchor {419
420
421margin,422
423
424page,425
426
427text,428
429
430line,431}432
433
434[Serializable]435
436[System.ComponentModel.DesignerCategory("code")]437[XmlType(Namespace="urn:schemas-microsoft-com:office:word")]438[XmlRoot(Namespace="urn:schemas-microsoft-com:office:word", IsNullable=true)]439public class CT_AnchorLock {440}441}
442