npoi

Форк
0
1512 строк · 46.0 Кб
1
using System;
2
using System.Collections.Generic;
3
using System.Xml;
4
using System.Xml.Serialization;
5
using NPOI.OpenXmlFormats.Shared;
6
using NPOI.OpenXml4Net.Util;
7
using System.IO;
8
using System.Collections;
9
using System.Linq;
10

11
namespace NPOI.OpenXmlFormats.Wordprocessing
12
{
13
    [Serializable]
14

15
    [XmlType(Namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main")]
16
    [XmlRoot("glossaryDocument", Namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", IsNullable = false)]
17
    public class CT_GlossaryDocument : CT_DocumentBase
18
    {
19

20
        private CT_DocParts docPartsField;
21

22
        public CT_GlossaryDocument()
23
        {
24
            this.docPartsField = new CT_DocParts();
25
        }
26

27
        [XmlElement(Order = 0)]
28
        public CT_DocParts docParts
29
        {
30
            get
31
            {
32
                return this.docPartsField;
33
            }
34
            set
35
            {
36
                this.docPartsField = value;
37
            }
38
        }
39
    }
40
    [XmlInclude(typeof(CT_GlossaryDocument))]
41
    [XmlInclude(typeof(CT_Document))]
42
    [Serializable]
43
    [XmlType(Namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main")]
44
    [XmlRoot(Namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", IsNullable = true)]
45
    public class CT_DocumentBase
46
    {
47

48
        private CT_Background backgroundField;
49

50
        public CT_DocumentBase()
51
        {
52
            //this.backgroundField = new CT_Background();
53
        }
54

55
        [XmlElement(Order = 0)]
56
        public CT_Background background
57
        {
58
            get
59
            {
60
                return this.backgroundField;
61
            }
62
            set
63
            {
64
                this.backgroundField = value;
65
            }
66
        }
67
    }
68

69

70
    [Serializable]
71

72
    [XmlType(Namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main")]
73
    [XmlRoot("document", Namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", IsNullable = false)]
74
    public class CT_Document : CT_DocumentBase
75
    {
76
        public static CT_Document Parse(XmlNode node, XmlNamespaceManager namespaceManager)
77
        {
78
            if(node == null)
79
                return null;
80
            CT_Document ctObj = new CT_Document();
81
            foreach(XmlNode childNode in node.ChildNodes)
82
            {
83
                if(childNode.LocalName == "body")
84
                    ctObj.body = CT_Body.Parse(childNode, namespaceManager);
85
                else if(childNode.LocalName == "background")
86
                    ctObj.background = CT_Background.Parse(childNode, namespaceManager);
87
            }
88
            return ctObj;
89
        }
90

91

92

93
        internal void Write(StreamWriter sw)
94
        {
95
            sw.WriteLine("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>");
96
            sw.Write("<w:document xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" ");
97
            sw.Write("xmlns:cx=\"http://schemas.microsoft.com/office/drawing/2014/chartex\" xmlns:cx1=\"http://schemas.microsoft.com/office/drawing/2015/9/8/chartex\" xmlns:cx2=\"http://schemas.microsoft.com/office/drawing/2015/10/21/chartex\" xmlns:cx3=\"http://schemas.microsoft.com/office/drawing/2016/5/9/chartex\" ");
98
            sw.Write("xmlns:cx4=\"http://schemas.microsoft.com/office/drawing/2016/5/10/chartex\" xmlns:cx5=\"http://schemas.microsoft.com/office/drawing/2016/5/11/chartex\" xmlns:cx6=\"http://schemas.microsoft.com/office/drawing/2016/5/12/chartex\" ");
99
            sw.Write("xmlns:cx7=\"http://schemas.microsoft.com/office/drawing/2016/5/13/chartex\" xmlns:cx8=\"http://schemas.microsoft.com/office/drawing/2016/5/14/chartex\" ");
100
            sw.Write("xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" ");
101
            sw.Write("xmlns:aink=\"http://schemas.microsoft.com/office/drawing/2016/ink\" xmlns:am3d=\"http://schemas.microsoft.com/office/drawing/2017/model3d\" ");
102
            sw.Write("xmlns:o=\"urn:schemas-microsoft-com:office:office\" ");
103
            sw.Write("xmlns:oel=\"http://schemas.microsoft.com/office/2019/extlst\" ");
104
            sw.Write("xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" ");
105
            sw.Write("xmlns:v=\"urn:schemas-microsoft-com:vml\" xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\" xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" ");
106
            sw.Write("xmlns:w10=\"urn:schemas-microsoft-com:office:word\" xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" ");
107
            sw.Write("xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" xmlns:w15=\"http://schemas.microsoft.com/office/word/2012/wordml\" xmlns:w16cex=\"http://schemas.microsoft.com/office/word/2018/wordml/cex\" ");
108
            sw.Write("xmlns:w16cid=\"http://schemas.microsoft.com/office/word/2016/wordml/cid\" xmlns:w16=\"http://schemas.microsoft.com/office/word/2018/wordml\" xmlns:w16sdtdh=\"http://schemas.microsoft.com/office/word/2020/wordml/sdtdatahash\" ");
109
            sw.Write("xmlns:w16se=\"http://schemas.microsoft.com/office/word/2015/wordml/symex\" xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" ");
110
            sw.Write("xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\" ");
111
            sw.Write("mc:Ignorable=\"w14 w15 w16se w16cid w16 w16cex w16sdtdh wp14\">");
112
            if(this.body != null)
113
                this.body.Write(sw, "body");
114
            if(this.background != null)
115
                this.background.Write(sw, "background");
116
            sw.Write("</w:document>");
117
        }
118

119
        private CT_Body bodyField;
120

121
        public CT_Document()
122
        {
123
            this.bodyField = new CT_Body();
124
        }
125

126
        [XmlElement(Order = 0)]
127
        public CT_Body body
128
        {
129
            get
130
            {
131
                return this.bodyField;
132
            }
133
            set
134
            {
135
                this.bodyField = value;
136
            }
137
        }
138

139
        public void AddNewBody()
140
        {
141
            this.bodyField = new CT_Body();
142
        }
143
    }
144

145

146
    [Serializable]
147

148
    [XmlType(Namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main")]
149
    [XmlRoot(Namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", IsNullable = true)]
150
    public class CT_Body
151
    {
152

153
        private ArrayList itemsField;
154

155
        private List<DocumentBodyItemChoiceType> itemsElementNameField;
156

157
        private CT_SectPr sectPrField;
158

159
        public CT_Body()
160
        {
161
            this.itemsElementNameField = new List<DocumentBodyItemChoiceType>();
162
            this.itemsField = new ArrayList();
163
        }
164
        public static CT_Body Parse(XmlNode node, XmlNamespaceManager namespaceManager)
165
        {
166
            if(node == null)
167
                return null;
168
            CT_Body ctObj = new CT_Body();
169
            foreach(XmlNode childNode in node.ChildNodes)
170
            {
171
                if(childNode.LocalName == "moveTo")
172
                {
173
                    ctObj.Items.Add(CT_RunTrackChange.Parse(childNode, namespaceManager));
174
                    ctObj.ItemsElementName.Add(DocumentBodyItemChoiceType.moveTo);
175
                }
176
                else if(childNode.LocalName == "sectPr")
177
                {
178
                    ctObj.sectPr = CT_SectPr.Parse(childNode, namespaceManager);
179
                }
180
                else if(childNode.LocalName == "oMathPara")
181
                {
182
                    ctObj.Items.Add(CT_OMathPara.Parse(childNode, namespaceManager));
183
                    ctObj.ItemsElementName.Add(DocumentBodyItemChoiceType.oMathPara);
184
                }
185
                else if(childNode.LocalName == "customXml")
186
                {
187
                    ctObj.Items.Add(CT_CustomXmlBlock.Parse(childNode, namespaceManager));
188
                    ctObj.ItemsElementName.Add(DocumentBodyItemChoiceType.customXml);
189
                }
190
                else if(childNode.LocalName == "oMath")
191
                {
192
                    ctObj.Items.Add(CT_OMath.Parse(childNode, namespaceManager));
193
                    ctObj.ItemsElementName.Add(DocumentBodyItemChoiceType.oMath);
194
                }
195
                else if(childNode.LocalName == "altChunk")
196
                {
197
                    ctObj.Items.Add(CT_AltChunk.Parse(childNode, namespaceManager));
198
                    ctObj.ItemsElementName.Add(DocumentBodyItemChoiceType.altChunk);
199
                }
200
                else if(childNode.LocalName == "bookmarkEnd")
201
                {
202
                    ctObj.Items.Add(CT_MarkupRange.Parse(childNode, namespaceManager));
203
                    ctObj.ItemsElementName.Add(DocumentBodyItemChoiceType.bookmarkEnd);
204
                }
205
                else if(childNode.LocalName == "bookmarkStart")
206
                {
207
                    ctObj.Items.Add(CT_Bookmark.Parse(childNode, namespaceManager));
208
                    ctObj.ItemsElementName.Add(DocumentBodyItemChoiceType.bookmarkStart);
209
                }
210
                else if(childNode.LocalName == "commentRangeEnd")
211
                {
212
                    ctObj.Items.Add(CT_MarkupRange.Parse(childNode, namespaceManager));
213
                    ctObj.ItemsElementName.Add(DocumentBodyItemChoiceType.commentRangeEnd);
214
                }
215
                else if(childNode.LocalName == "commentRangeStart")
216
                {
217
                    ctObj.Items.Add(CT_MarkupRange.Parse(childNode, namespaceManager));
218
                    ctObj.ItemsElementName.Add(DocumentBodyItemChoiceType.commentRangeStart);
219
                }
220
                else if(childNode.LocalName == "customXmlDelRangeEnd")
221
                {
222
                    ctObj.Items.Add(CT_Markup.Parse(childNode, namespaceManager));
223
                    ctObj.ItemsElementName.Add(DocumentBodyItemChoiceType.customXmlDelRangeEnd);
224
                }
225
                else if(childNode.LocalName == "customXmlDelRangeStart")
226
                {
227
                    ctObj.Items.Add(CT_TrackChange.Parse(childNode, namespaceManager));
228
                    ctObj.ItemsElementName.Add(DocumentBodyItemChoiceType.customXmlDelRangeStart);
229
                }
230
                else if(childNode.LocalName == "customXmlInsRangeEnd")
231
                {
232
                    ctObj.Items.Add(CT_Markup.Parse(childNode, namespaceManager));
233
                    ctObj.ItemsElementName.Add(DocumentBodyItemChoiceType.customXmlInsRangeEnd);
234
                }
235
                else if(childNode.LocalName == "customXmlInsRangeStart")
236
                {
237
                    ctObj.Items.Add(CT_TrackChange.Parse(childNode, namespaceManager));
238
                    ctObj.ItemsElementName.Add(DocumentBodyItemChoiceType.customXmlInsRangeStart);
239
                }
240
                else if(childNode.LocalName == "customXmlMoveFromRangeEnd")
241
                {
242
                    ctObj.Items.Add(CT_Markup.Parse(childNode, namespaceManager));
243
                    ctObj.ItemsElementName.Add(DocumentBodyItemChoiceType.customXmlMoveFromRangeEnd);
244
                }
245
                else if(childNode.LocalName == "customXmlMoveFromRangeStart")
246
                {
247
                    ctObj.Items.Add(CT_TrackChange.Parse(childNode, namespaceManager));
248
                    ctObj.ItemsElementName.Add(DocumentBodyItemChoiceType.customXmlMoveFromRangeStart);
249
                }
250
                else if(childNode.LocalName == "customXmlMoveToRangeEnd")
251
                {
252
                    ctObj.Items.Add(CT_Markup.Parse(childNode, namespaceManager));
253
                    ctObj.ItemsElementName.Add(DocumentBodyItemChoiceType.customXmlMoveToRangeEnd);
254
                }
255
                else if(childNode.LocalName == "customXmlMoveToRangeStart")
256
                {
257
                    ctObj.Items.Add(CT_TrackChange.Parse(childNode, namespaceManager));
258
                    ctObj.ItemsElementName.Add(DocumentBodyItemChoiceType.customXmlMoveToRangeStart);
259
                }
260
                else if(childNode.LocalName == "del")
261
                {
262
                    ctObj.Items.Add(CT_RunTrackChange.Parse(childNode, namespaceManager));
263
                    ctObj.ItemsElementName.Add(DocumentBodyItemChoiceType.del);
264
                }
265
                else if(childNode.LocalName == "ins")
266
                {
267
                    ctObj.Items.Add(CT_RunTrackChange.Parse(childNode, namespaceManager));
268
                    ctObj.ItemsElementName.Add(DocumentBodyItemChoiceType.ins);
269
                }
270
                else if(childNode.LocalName == "moveFrom")
271
                {
272
                    ctObj.Items.Add(CT_RunTrackChange.Parse(childNode, namespaceManager));
273
                    ctObj.ItemsElementName.Add(DocumentBodyItemChoiceType.moveFrom);
274
                }
275
                else if(childNode.LocalName == "moveFromRangeEnd")
276
                {
277
                    ctObj.Items.Add(CT_MarkupRange.Parse(childNode, namespaceManager));
278
                    ctObj.ItemsElementName.Add(DocumentBodyItemChoiceType.moveFromRangeEnd);
279
                }
280
                else if(childNode.LocalName == "moveFromRangeStart")
281
                {
282
                    ctObj.Items.Add(CT_MoveBookmark.Parse(childNode, namespaceManager));
283
                    ctObj.ItemsElementName.Add(DocumentBodyItemChoiceType.moveFromRangeStart);
284
                }
285
                else if(childNode.LocalName == "moveToRangeEnd")
286
                {
287
                    ctObj.Items.Add(CT_MarkupRange.Parse(childNode, namespaceManager));
288
                    ctObj.ItemsElementName.Add(DocumentBodyItemChoiceType.moveToRangeEnd);
289
                }
290
                else if(childNode.LocalName == "moveToRangeStart")
291
                {
292
                    ctObj.Items.Add(CT_MoveBookmark.Parse(childNode, namespaceManager));
293
                    ctObj.ItemsElementName.Add(DocumentBodyItemChoiceType.moveToRangeStart);
294
                }
295
                else if(childNode.LocalName == "p")
296
                {
297
                    ctObj.Items.Add(CT_P.Parse(childNode, namespaceManager));
298
                    ctObj.ItemsElementName.Add(DocumentBodyItemChoiceType.p);
299
                }
300
                else if(childNode.LocalName == "permEnd")
301
                {
302
                    ctObj.Items.Add(CT_Perm.Parse(childNode, namespaceManager));
303
                    ctObj.ItemsElementName.Add(DocumentBodyItemChoiceType.permEnd);
304
                }
305
                else if(childNode.LocalName == "permStart")
306
                {
307
                    ctObj.Items.Add(CT_PermStart.Parse(childNode, namespaceManager));
308
                    ctObj.ItemsElementName.Add(DocumentBodyItemChoiceType.permStart);
309
                }
310
                else if(childNode.LocalName == "proofErr")
311
                {
312
                    ctObj.Items.Add(CT_ProofErr.Parse(childNode, namespaceManager));
313
                    ctObj.ItemsElementName.Add(DocumentBodyItemChoiceType.proofErr);
314
                }
315
                else if(childNode.LocalName == "sdt")
316
                {
317
                    ctObj.Items.Add(CT_SdtBlock.Parse(childNode, namespaceManager));
318
                    ctObj.ItemsElementName.Add(DocumentBodyItemChoiceType.sdt);
319
                }
320
                else if(childNode.LocalName == "tbl")
321
                {
322
                    ctObj.Items.Add(CT_Tbl.Parse(childNode, namespaceManager));
323
                    ctObj.ItemsElementName.Add(DocumentBodyItemChoiceType.tbl);
324
                }
325
            }
326
            return ctObj;
327
        }
328

329
        public int SizeOfPArray()
330
        {
331
            return this.itemsElementNameField.Count(p => p == DocumentBodyItemChoiceType.p);
332
        }
333

334
        internal void Write(StreamWriter sw, string nodeName)
335
        {
336
            sw.Write(string.Format("<w:{0}", nodeName));
337
            sw.Write(">");
338
            int i=0;
339
            foreach(object o in this.Items)
340
            {
341
                if(o is CT_RunTrackChange && this.itemsElementNameField[i] == DocumentBodyItemChoiceType.moveTo)
342
                    ((CT_RunTrackChange) o).Write(sw, "moveTo");
343
                else if(o is CT_OMathPara)
344
                    ((CT_OMathPara) o).Write(sw, "oMathPara");
345
                else if(o is CT_CustomXmlBlock)
346
                    ((CT_CustomXmlBlock) o).Write(sw, "customXml");
347
                else if(o is CT_OMath)
348
                    ((CT_OMath) o).Write(sw, "oMath");
349
                else if(o is CT_AltChunk)
350
                    ((CT_AltChunk) o).Write(sw, "altChunk");
351
                else if((o is CT_MarkupRange)&&this.itemsElementNameField[i]== DocumentBodyItemChoiceType.bookmarkEnd)
352
                    ((CT_MarkupRange) o).Write(sw, "bookmarkEnd");
353
                else if(o is CT_Bookmark && this.itemsElementNameField[i] == DocumentBodyItemChoiceType.bookmarkStart)
354
                    ((CT_Bookmark) o).Write(sw, "bookmarkStart");
355
                else if(o is CT_MarkupRange && this.itemsElementNameField[i] == DocumentBodyItemChoiceType.commentRangeEnd)
356
                    ((CT_MarkupRange) o).Write(sw, "commentRangeEnd");
357
                else if(o is CT_MarkupRange && this.itemsElementNameField[i] == DocumentBodyItemChoiceType.commentRangeStart)
358
                    ((CT_MarkupRange) o).Write(sw, "commentRangeStart");
359
                else if(o is CT_Markup && this.itemsElementNameField[i] == DocumentBodyItemChoiceType.customXmlDelRangeEnd)
360
                    ((CT_Markup) o).Write(sw, "customXmlDelRangeEnd");
361
                else if(o is CT_TrackChange && this.itemsElementNameField[i] == DocumentBodyItemChoiceType.customXmlDelRangeStart)
362
                    ((CT_TrackChange) o).Write(sw, "customXmlDelRangeStart");
363
                else if(o is CT_Markup && this.itemsElementNameField[i] == DocumentBodyItemChoiceType.customXmlInsRangeEnd)
364
                    ((CT_Markup) o).Write(sw, "customXmlInsRangeEnd");
365
                else if(o is CT_TrackChange && this.itemsElementNameField[i] == DocumentBodyItemChoiceType.customXmlInsRangeStart)
366
                    ((CT_TrackChange) o).Write(sw, "customXmlInsRangeStart");
367
                else if(o is CT_Markup && this.itemsElementNameField[i] == DocumentBodyItemChoiceType.customXmlMoveFromRangeEnd)
368
                    ((CT_Markup) o).Write(sw, "customXmlMoveFromRangeEnd");
369
                else if(o is CT_TrackChange && this.itemsElementNameField[i] == DocumentBodyItemChoiceType.customXmlMoveFromRangeStart)
370
                    ((CT_TrackChange) o).Write(sw, "customXmlMoveFromRangeStart");
371
                else if(o is CT_Markup && this.itemsElementNameField[i] == DocumentBodyItemChoiceType.customXmlMoveToRangeEnd)
372
                    ((CT_Markup) o).Write(sw, "customXmlMoveToRangeEnd");
373
                else if(o is CT_TrackChange && this.itemsElementNameField[i] == DocumentBodyItemChoiceType.customXmlMoveToRangeStart)
374
                    ((CT_TrackChange) o).Write(sw, "customXmlMoveToRangeStart");
375
                else if(o is CT_RunTrackChange && this.itemsElementNameField[i] == DocumentBodyItemChoiceType.del)
376
                    ((CT_RunTrackChange) o).Write(sw, "del");
377
                else if(o is CT_RunTrackChange && this.itemsElementNameField[i] == DocumentBodyItemChoiceType.ins)
378
                    ((CT_RunTrackChange) o).Write(sw, "ins");
379
                else if(o is CT_RunTrackChange && this.itemsElementNameField[i] == DocumentBodyItemChoiceType.moveFrom)
380
                    ((CT_RunTrackChange) o).Write(sw, "moveFrom");
381
                else if(o is CT_MarkupRange && this.itemsElementNameField[i] == DocumentBodyItemChoiceType.moveFromRangeEnd)
382
                    ((CT_MarkupRange) o).Write(sw, "moveFromRangeEnd");
383
                else if(o is CT_MoveBookmark && this.itemsElementNameField[i] == DocumentBodyItemChoiceType.moveFromRangeStart)
384
                    ((CT_MoveBookmark) o).Write(sw, "moveFromRangeStart");
385
                else if(o is CT_MarkupRange && this.itemsElementNameField[i] == DocumentBodyItemChoiceType.moveToRangeEnd)
386
                    ((CT_MarkupRange) o).Write(sw, "moveToRangeEnd");
387
                else if(o is CT_MoveBookmark && this.itemsElementNameField[i] == DocumentBodyItemChoiceType.moveToRangeStart)
388
                    ((CT_MoveBookmark) o).Write(sw, "moveToRangeStart");
389
                else if(o is CT_P)
390
                    ((CT_P) o).Write(sw, "p");
391
                else if(o is CT_Perm)
392
                    ((CT_Perm) o).Write(sw, "permEnd");
393
                else if(o is CT_PermStart)
394
                    ((CT_PermStart) o).Write(sw, "permStart");
395
                else if(o is CT_ProofErr)
396
                    ((CT_ProofErr) o).Write(sw, "proofErr");
397
                else if(o is CT_SdtBlock)
398
                    ((CT_SdtBlock) o).Write(sw, "sdt");
399
                else if(o is CT_Tbl)
400
                    ((CT_Tbl) o).Write(sw, "tbl");
401
                i++;
402
            }
403
            if(this.sectPr != null)
404
                this.sectPr.Write(sw, "sectPr");
405
            sw.WriteEndW(nodeName);
406
        }
407

408
        public CT_SectPr AddNewSectPr()
409
        {
410
            this.sectPrField = new CT_SectPr();
411
            return this.sectPrField;
412
        }
413

414
        public bool IsSetSectPr()
415
        {
416
            return this.sectPrField != null;
417
        }
418

419
        [XmlElement("oMath", typeof(CT_OMath), Namespace = "http://schemas.openxmlformats.org/officeDocument/2006/math", Order = 0)]
420
        [XmlElement("oMathPara", typeof(CT_OMathPara), Namespace = "http://schemas.openxmlformats.org/officeDocument/2006/math", Order = 0)]
421
        [XmlElement("altChunk", typeof(CT_AltChunk), Order = 0)]
422
        [XmlElement("bookmarkEnd", typeof(CT_MarkupRange), Order = 0)]
423
        [XmlElement("bookmarkStart", typeof(CT_Bookmark), Order = 0)]
424
        [XmlElement("commentRangeEnd", typeof(CT_MarkupRange), Order = 0)]
425
        [XmlElement("commentRangeStart", typeof(CT_MarkupRange), Order = 0)]
426
        [XmlElement("customXml", typeof(CT_CustomXmlBlock), Order = 0)]
427
        [XmlElement("customXmlDelRangeEnd", typeof(CT_Markup), Order = 0)]
428
        [XmlElement("customXmlDelRangeStart", typeof(CT_TrackChange), Order = 0)]
429
        [XmlElement("customXmlInsRangeEnd", typeof(CT_Markup), Order = 0)]
430
        [XmlElement("customXmlInsRangeStart", typeof(CT_TrackChange), Order = 0)]
431
        [XmlElement("customXmlMoveFromRangeEnd", typeof(CT_Markup), Order = 0)]
432
        [XmlElement("customXmlMoveFromRangeStart", typeof(CT_TrackChange), Order = 0)]
433
        [XmlElement("customXmlMoveToRangeEnd", typeof(CT_Markup), Order = 0)]
434
        [XmlElement("customXmlMoveToRangeStart", typeof(CT_TrackChange), Order = 0)]
435
        [XmlElement("del", Type = typeof(CT_RunTrackChange), Order = 0)]
436
        [XmlElement("ins", Type = typeof(CT_RunTrackChange), Order = 0)]
437
        [XmlElement("moveFrom", typeof(CT_RunTrackChange), Order = 0)]
438
        [XmlElement("moveFromRangeEnd", typeof(CT_MarkupRange), Order = 0)]
439
        [XmlElement("moveFromRangeStart", typeof(CT_MoveBookmark), Order = 0)]
440
        [XmlElement("moveTo", typeof(CT_RunTrackChange), Order = 0)]
441
        [XmlElement("moveToRangeEnd", typeof(CT_MarkupRange), Order = 0)]
442
        [XmlElement("moveToRangeStart", typeof(CT_MoveBookmark), Order = 0)]
443
        [XmlElement("p", typeof(CT_P), Order = 0)]
444
        [XmlElement("permEnd", typeof(CT_Perm), Order = 0)]
445
        [XmlElement("permStart", typeof(CT_PermStart), Order = 0)]
446
        [XmlElement("proofErr", typeof(CT_ProofErr), Order = 0)]
447
        [XmlElement("sdt", typeof(CT_SdtBlock), Order = 0)]
448
        [XmlElement("tbl", typeof(CT_Tbl), Order = 0)]
449
        [XmlChoiceIdentifier("ItemsElementName")]
450
        public ArrayList Items
451
        {
452
            get
453
            {
454
                return this.itemsField;
455
            }
456
            set
457
            {
458
                this.itemsField = value;
459
            }
460
        }
461

462
        public CT_P AddNewP()
463
        {
464
            CT_P p = new CT_P();
465
            lock(this)
466
            {
467
                this.itemsField.Add(p);
468
                this.itemsElementNameField.Add(DocumentBodyItemChoiceType.p);
469
            }
470
            return p;
471
        }
472

473
        [XmlElement("ItemsElementName", Order = 1)]
474
        [XmlIgnore]
475
        public List<DocumentBodyItemChoiceType> ItemsElementName
476
        {
477
            get
478
            {
479
                return this.itemsElementNameField;
480
            }
481
            set
482
            {
483
                this.itemsElementNameField = value;
484
            }
485
        }
486

487
        [XmlElement(Order = 2)]
488
        public CT_SectPr sectPr
489
        {
490
            get
491
            {
492
                return this.sectPrField;
493
            }
494
            set
495
            {
496
                this.sectPrField = value;
497
            }
498
        }
499
        public CT_Tbl AddNewTbl(int? pos = null)
500
        {
501
            CT_Tbl tbl = new CT_Tbl();
502
            lock(this)
503
            {
504
                if(pos.HasValue)
505
                {
506
                    this.itemsField.Insert(pos.Value, tbl);
507
                    this.itemsElementNameField.Insert(pos.Value, DocumentBodyItemChoiceType.tbl);
508
                }
509
                else
510
                {
511
                    this.itemsField.Add(tbl);
512
                    this.itemsElementNameField.Add(DocumentBodyItemChoiceType.tbl);
513
                }
514
            }
515
            return tbl;
516
        }
517
        public int sizeOfTblArray()
518
        {
519
            return SizeOfArray(DocumentBodyItemChoiceType.tbl);
520
        }
521
        public List<CT_Tbl> getTblArray()
522
        {
523
            return GetObjectList<CT_Tbl>(DocumentBodyItemChoiceType.tbl);
524
        }
525
        public CT_Tbl insertNewTbl(int paramInt)
526
        {
527
            throw new NotImplementedException();
528
        }
529
        public void removeTbl(int paramInt)
530
        {
531
            throw new NotImplementedException();
532
        }
533
        public CT_Tbl GetTblArray(int i)
534
        {
535
            return GetObjectArray<CT_Tbl>(i, DocumentBodyItemChoiceType.tbl);
536
        }
537

538
        public void SetTblArray(int pos, CT_Tbl cT_Tbl)
539
        {
540
            SetObject<CT_Tbl>(DocumentBodyItemChoiceType.tbl, pos, cT_Tbl);
541
        }
542

543
        public CT_Tbl[] GetTblArray()
544
        {
545
            return GetObjectList<CT_Tbl>(DocumentBodyItemChoiceType.tbl).ToArray();
546
        }
547

548
        public CT_P GetPArray(int p)
549
        {
550
            return GetObjectArray<CT_P>(p, DocumentBodyItemChoiceType.p);
551
        }
552
        public void RemoveP(int paraPos)
553
        {
554
            RemoveObject(DocumentBodyItemChoiceType.p, paraPos);
555
        }
556
        public void RemoveTbl(int tablePos)
557
        {
558
            RemoveObject(DocumentBodyItemChoiceType.tbl, tablePos);
559
        }
560

561
        public CT_SdtBlock AddNewSdt()
562
        {
563
            return AddNewObject<CT_SdtBlock>(DocumentBodyItemChoiceType.sdt);
564
        }
565
        #region Generic methods for object operation
566

567
        private List<T> GetObjectList<T>(DocumentBodyItemChoiceType type) where T : class
568
        {
569
            lock(this)
570
            {
571
                List<T> list = new List<T>();
572
                for(int i = 0; i < itemsElementNameField.Count; i++)
573
                {
574
                    if(itemsElementNameField[i] == type)
575
                        list.Add(itemsField[i] as T);
576
                }
577
                return list;
578
            }
579
        }
580
        private int SizeOfArray(DocumentBodyItemChoiceType type)
581
        {
582
            lock(this)
583
            {
584
                int size = 0;
585
                for(int i = 0; i < itemsElementNameField.Count; i++)
586
                {
587
                    if(itemsElementNameField[i] == type)
588
                        size++;
589
                }
590
                return size;
591
            }
592
        }
593
        private T GetObjectArray<T>(int p, DocumentBodyItemChoiceType type) where T : class
594
        {
595
            lock(this)
596
            {
597
                int pos = GetObjectIndex(type, p);
598
                if(pos < 0 || pos >= this.itemsField.Count)
599
                    return null;
600
                return itemsField[pos] as T;
601
            }
602
        }
603
        private T AddNewObject<T>(DocumentBodyItemChoiceType type) where T : class, new()
604
        {
605
            T t = new T();
606
            lock(this)
607
            {
608
                this.itemsElementNameField.Add(type);
609
                this.itemsField.Add(t);
610
            }
611
            return t;
612
        }
613
        private void SetObject<T>(DocumentBodyItemChoiceType type, int p, T obj) where T : class
614
        {
615
            lock(this)
616
            {
617
                int pos = GetObjectIndex(type, p);
618
                if(pos < 0 || pos >= this.itemsField.Count)
619
                    return;
620
                if(this.itemsField[pos] is T)
621
                    this.itemsField[pos] = obj;
622
                else
623
                    throw new Exception(string.Format(@"object types are difference, itemsField[{0}] is {1}, and parameter obj is {2}",
624
                        pos, this.itemsField[pos].GetType().Name, typeof(T).Name));
625
            }
626
        }
627
        private int GetObjectIndex(DocumentBodyItemChoiceType type, int p)
628
        {
629
            int index = -1;
630
            int pos = 0;
631
            for(int i = 0; i < itemsElementNameField.Count; i++)
632
            {
633
                if(itemsElementNameField[i] == type)
634
                {
635
                    if(pos == p)
636
                    {
637
                        index = i;
638
                        break;
639
                    }
640
                    else
641
                        pos++;
642
                }
643
            }
644
            return index;
645
        }
646
        private void RemoveObject(DocumentBodyItemChoiceType type, int p)
647
        {
648
            lock(this)
649
            {
650
                int pos = GetObjectIndex(type, p);
651
                if(pos < 0 || pos >= this.itemsField.Count)
652
                    return;
653
                itemsElementNameField.RemoveAt(pos);
654
                itemsField.RemoveAt(pos);
655
            }
656
        }
657
        #endregion
658

659

660

661

662
        public void SetPArray(int pos, CT_P cT_P)
663
        {
664
            SetObject<CT_P>(DocumentBodyItemChoiceType.p, pos, cT_P);
665
        }
666
    }
667

668

669
    [Serializable]
670
    [XmlType(Namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", IncludeInSchema = false)]
671
    public enum DocumentBodyItemChoiceType
672
    {
673

674

675
        [XmlEnum("http://schemas.openxmlformats.org/officeDocument/2006/math:oMath")]
676
        oMath,
677

678

679
        [XmlEnum("http://schemas.openxmlformats.org/officeDocument/2006/math:oMathPara")]
680
        oMathPara,
681

682

683
        altChunk,
684

685

686
        bookmarkEnd,
687

688

689
        bookmarkStart,
690

691

692
        commentRangeEnd,
693

694

695
        commentRangeStart,
696

697

698
        customXml,
699

700

701
        customXmlDelRangeEnd,
702

703

704
        customXmlDelRangeStart,
705

706

707
        customXmlInsRangeEnd,
708

709

710
        customXmlInsRangeStart,
711

712

713
        customXmlMoveFromRangeEnd,
714

715

716
        customXmlMoveFromRangeStart,
717

718

719
        customXmlMoveToRangeEnd,
720

721

722
        customXmlMoveToRangeStart,
723

724

725
        del,
726

727

728
        ins,
729

730

731
        moveFrom,
732

733

734
        moveFromRangeEnd,
735

736

737
        moveFromRangeStart,
738

739

740
        moveTo,
741

742

743
        moveToRangeEnd,
744

745

746
        moveToRangeStart,
747

748
        /// <summary>
749
        /// Paragraph
750
        /// </summary>
751
        p,
752

753

754
        permEnd,
755

756

757
        permStart,
758

759

760
        proofErr,
761

762

763
        sdt,
764

765

766
        tbl,
767
    }
768

769

770
    [Serializable]
771

772
    [XmlType(Namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main")]
773
    [XmlRoot(Namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", IsNullable = true)]
774
    public class CT_DocParts
775
    {
776

777
        private List<CT_DocPart> itemsField;
778

779
        public CT_DocParts()
780
        {
781
            this.itemsField = new List<CT_DocPart>();
782
        }
783

784
        [XmlElement("docPart", Order = 0)]
785
        public List<CT_DocPart> Items
786
        {
787
            get
788
            {
789
                return this.itemsField;
790
            }
791
            set
792
            {
793
                this.itemsField = value;
794
            }
795
        }
796
    }
797

798

799
    [Serializable]
800

801
    [XmlType(Namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main")]
802
    [XmlRoot(Namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", IsNullable = true)]
803
    public class CT_DocPart
804
    {
805

806
        private CT_DocPartPr docPartPrField;
807

808
        private CT_Body docPartBodyField;
809

810
        public CT_DocPart()
811
        {
812
            //this.docPartBodyField = new CT_Body();
813
            //this.docPartPrField = new CT_DocPartPr();
814
        }
815

816
        [XmlElement(Order = 0)]
817
        public CT_DocPartPr docPartPr
818
        {
819
            get
820
            {
821
                return this.docPartPrField;
822
            }
823
            set
824
            {
825
                this.docPartPrField = value;
826
            }
827
        }
828

829
        [XmlElement(Order = 1)]
830
        public CT_Body docPartBody
831
        {
832
            get
833
            {
834
                return this.docPartBodyField;
835
            }
836
            set
837
            {
838
                this.docPartBodyField = value;
839
            }
840
        }
841
    }
842

843

844
    [Serializable]
845

846
    [XmlType(Namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main")]
847
    [XmlRoot(Namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", IsNullable = true)]
848
    public class CT_DocPartPr
849
    {
850

851
        private object[] itemsField;
852

853
        private ItemsChoiceType11[] itemsElementNameField;
854

855
        public CT_DocPartPr()
856
        {
857
            this.itemsElementNameField = new ItemsChoiceType11[0];
858
            this.itemsField = new object[0];
859
        }
860

861
        [XmlElement("behaviors", typeof(CT_DocPartBehaviors), Order = 0)]
862
        [XmlElement("category", typeof(CT_DocPartCategory), Order = 0)]
863
        [XmlElement("description", typeof(CT_String), Order = 0)]
864
        [XmlElement("guid", typeof(CT_Guid), Order = 0)]
865
        [XmlElement("name", typeof(CT_DocPartName), Order = 0)]
866
        [XmlElement("style", typeof(CT_String), Order = 0)]
867
        [XmlElement("types", typeof(CT_DocPartTypes), Order = 0)]
868
        [XmlChoiceIdentifier("ItemsElementName")]
869
        public object[] Items
870
        {
871
            get
872
            {
873
                return this.itemsField;
874
            }
875
            set
876
            {
877
                this.itemsField = value;
878
            }
879
        }
880

881
        [XmlElement("ItemsElementName", Order = 1)]
882
        [XmlIgnore]
883
        public ItemsChoiceType11[] ItemsElementName
884
        {
885
            get
886
            {
887
                return this.itemsElementNameField;
888
            }
889
            set
890
            {
891
                this.itemsElementNameField = value;
892
            }
893
        }
894
    }
895

896

897
    [Serializable]
898

899
    [XmlType(Namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main")]
900
    [XmlRoot(Namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", IsNullable = true)]
901
    public class CT_DocPartBehaviors
902
    {
903

904
        private List<CT_DocPartBehavior> itemsField;
905

906
        public CT_DocPartBehaviors()
907
        {
908
            this.itemsField = new List<CT_DocPartBehavior>();
909
        }
910

911
        [XmlElement("behavior", Order = 0)]
912
        public List<CT_DocPartBehavior> Items
913
        {
914
            get
915
            {
916
                return this.itemsField;
917
            }
918
            set
919
            {
920
                this.itemsField = value;
921
            }
922
        }
923
    }
924

925

926
    [Serializable]
927

928
    [XmlType(Namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main")]
929
    [XmlRoot(Namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", IsNullable = true)]
930
    public class CT_DocPartBehavior
931
    {
932

933
        private ST_DocPartBehavior valField;
934

935
        [XmlAttribute(Form = System.Xml.Schema.XmlSchemaForm.Qualified)]
936
        public ST_DocPartBehavior val
937
        {
938
            get
939
            {
940
                return this.valField;
941
            }
942
            set
943
            {
944
                this.valField = value;
945
            }
946
        }
947
    }
948

949

950
    [Serializable]
951
    [XmlType(Namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main")]
952
    public enum ST_DocPartBehavior
953
    {
954

955

956
        content,
957

958

959
        p,
960

961

962
        pg,
963
    }
964

965

966
    [Serializable]
967

968
    [XmlType(Namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main")]
969
    [XmlRoot(Namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", IsNullable = true)]
970
    public class CT_DocPartCategory
971
    {
972

973
        private CT_String nameField;
974

975
        private CT_DocPartGallery galleryField;
976

977
        public CT_DocPartCategory()
978
        {
979
            this.galleryField = new CT_DocPartGallery();
980
            this.nameField = new CT_String();
981
        }
982

983
        [XmlElement(Order = 0)]
984
        public CT_String name
985
        {
986
            get
987
            {
988
                return this.nameField;
989
            }
990
            set
991
            {
992
                this.nameField = value;
993
            }
994
        }
995

996
        [XmlElement(Order = 1)]
997
        public CT_DocPartGallery gallery
998
        {
999
            get
1000
            {
1001
                return this.galleryField;
1002
            }
1003
            set
1004
            {
1005
                this.galleryField = value;
1006
            }
1007
        }
1008
    }
1009

1010

1011
    [Serializable]
1012
    [XmlType(Namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main")]
1013
    [XmlRoot(Namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", IsNullable = true)]
1014
    public class CT_DocPartGallery
1015
    {
1016

1017
        private ST_DocPartGallery valField;
1018

1019
        [XmlAttribute(Form = System.Xml.Schema.XmlSchemaForm.Qualified)]
1020
        public ST_DocPartGallery val
1021
        {
1022
            get
1023
            {
1024
                return this.valField;
1025
            }
1026
            set
1027
            {
1028
                this.valField = value;
1029
            }
1030
        }
1031
    }
1032

1033

1034
    [Serializable]
1035
    [XmlType(Namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main")]
1036
    public enum ST_DocPartGallery
1037
    {
1038

1039

1040
        placeholder,
1041

1042

1043
        any,
1044

1045

1046
        @default,
1047

1048

1049
        docParts,
1050

1051

1052
        coverPg,
1053

1054

1055
        eq,
1056

1057

1058
        ftrs,
1059

1060

1061
        hdrs,
1062

1063

1064
        pgNum,
1065

1066

1067
        tbls,
1068

1069

1070
        watermarks,
1071

1072

1073
        autoTxt,
1074

1075

1076
        txtBox,
1077

1078

1079
        pgNumT,
1080

1081

1082
        pgNumB,
1083

1084

1085
        pgNumMargins,
1086

1087

1088
        tblOfContents,
1089

1090

1091
        bib,
1092

1093

1094
        custQuickParts,
1095

1096

1097
        custCoverPg,
1098

1099

1100
        custEq,
1101

1102

1103
        custFtrs,
1104

1105

1106
        custHdrs,
1107

1108

1109
        custPgNum,
1110

1111

1112
        custTbls,
1113

1114

1115
        custWatermarks,
1116

1117

1118
        custAutoTxt,
1119

1120

1121
        custTxtBox,
1122

1123

1124
        custPgNumT,
1125

1126

1127
        custPgNumB,
1128

1129

1130
        custPgNumMargins,
1131

1132

1133
        custTblOfContents,
1134

1135

1136
        custBib,
1137

1138

1139
        custom1,
1140

1141

1142
        custom2,
1143

1144

1145
        custom3,
1146

1147

1148
        custom4,
1149

1150

1151
        custom5,
1152
    }
1153

1154
    [Serializable]
1155
    [XmlType(Namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main")]
1156
    [XmlRoot(Namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", IsNullable = true)]
1157
    public class CT_DocPartName
1158
    {
1159

1160
        private string valField;
1161

1162
        private ST_OnOff decoratedField;
1163

1164
        private bool decoratedFieldSpecified;
1165

1166
        [XmlAttribute(Form = System.Xml.Schema.XmlSchemaForm.Qualified)]
1167
        public string val
1168
        {
1169
            get
1170
            {
1171
                return this.valField;
1172
            }
1173
            set
1174
            {
1175
                this.valField = value;
1176
            }
1177
        }
1178

1179
        [XmlAttribute(Form = System.Xml.Schema.XmlSchemaForm.Qualified)]
1180
        public ST_OnOff decorated
1181
        {
1182
            get
1183
            {
1184
                return this.decoratedField;
1185
            }
1186
            set
1187
            {
1188
                this.decoratedField = value;
1189
            }
1190
        }
1191

1192
        [XmlIgnore]
1193
        public bool decoratedSpecified
1194
        {
1195
            get
1196
            {
1197
                return this.decoratedFieldSpecified;
1198
            }
1199
            set
1200
            {
1201
                this.decoratedFieldSpecified = value;
1202
            }
1203
        }
1204
    }
1205

1206

1207
    [Serializable]
1208
    [XmlType(Namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main")]
1209
    [XmlRoot(Namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", IsNullable = true)]
1210
    public class CT_DocPartTypes
1211
    {
1212

1213
        private List<CT_DocPartType> itemsField;
1214

1215
        private ST_OnOff allField;
1216

1217
        private bool allFieldSpecified;
1218

1219
        public CT_DocPartTypes()
1220
        {
1221
            this.itemsField = new List<CT_DocPartType>();
1222
        }
1223

1224
        [XmlElement("type", Order = 0)]
1225
        public List<CT_DocPartType> Items
1226
        {
1227
            get
1228
            {
1229
                return this.itemsField;
1230
            }
1231
            set
1232
            {
1233
                this.itemsField = value;
1234
            }
1235
        }
1236

1237
        [XmlAttribute(Form = System.Xml.Schema.XmlSchemaForm.Qualified)]
1238
        public ST_OnOff all
1239
        {
1240
            get
1241
            {
1242
                return this.allField;
1243
            }
1244
            set
1245
            {
1246
                this.allField = value;
1247
            }
1248
        }
1249

1250
        [XmlIgnore]
1251
        public bool allSpecified
1252
        {
1253
            get
1254
            {
1255
                return this.allFieldSpecified;
1256
            }
1257
            set
1258
            {
1259
                this.allFieldSpecified = value;
1260
            }
1261
        }
1262
    }
1263

1264

1265
    [Serializable]
1266
    [XmlType(Namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main")]
1267
    [XmlRoot(Namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", IsNullable = true)]
1268
    public class CT_DocPartType
1269
    {
1270

1271
        private ST_DocPartType valField;
1272

1273
        [XmlAttribute(Form = System.Xml.Schema.XmlSchemaForm.Qualified)]
1274
        public ST_DocPartType val
1275
        {
1276
            get
1277
            {
1278
                return this.valField;
1279
            }
1280
            set
1281
            {
1282
                this.valField = value;
1283
            }
1284
        }
1285
    }
1286

1287

1288
    [Serializable]
1289
    [XmlType(Namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main")]
1290
    public enum ST_DocPartType
1291
    {
1292

1293

1294
        none,
1295

1296

1297
        normal,
1298

1299

1300
        autoExp,
1301

1302

1303
        toolbar,
1304

1305

1306
        speller,
1307

1308

1309
        formFld,
1310

1311

1312
        bbPlcHdr,
1313
    }
1314

1315
    [Serializable]
1316
    [XmlType(Namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", IncludeInSchema = false)]
1317
    public enum ItemsChoiceType11
1318
    {
1319

1320

1321
        behaviors,
1322

1323

1324
        category,
1325

1326

1327
        description,
1328

1329

1330
        guid,
1331

1332

1333
        name,
1334

1335

1336
        style,
1337

1338

1339
        types,
1340
    }
1341

1342
    [Serializable]
1343

1344
    [XmlType(Namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main")]
1345
    [XmlRoot(Namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", IsNullable = true)]
1346
    public class CT_DocGrid
1347
    {
1348

1349
        private ST_DocGrid typeField;
1350

1351
        private bool typeFieldSpecified;
1352

1353
        private string linePitchField;
1354

1355
        private string charSpaceField;
1356
        public CT_DocGrid()
1357
        {
1358
            this.type = ST_DocGrid.@default;
1359
        }
1360

1361
        public static CT_DocGrid Parse(XmlNode node, XmlNamespaceManager namespaceManager)
1362
        {
1363
            if(node == null)
1364
                return null;
1365
            CT_DocGrid ctObj = new CT_DocGrid();
1366
            if(node.Attributes["w:type"] != null)
1367
                ctObj.type = (ST_DocGrid) Enum.Parse(typeof(ST_DocGrid), node.Attributes["w:type"].Value);
1368
            ctObj.linePitch = XmlHelper.ReadString(node.Attributes["w:linePitch"]);
1369
            ctObj.charSpace = XmlHelper.ReadString(node.Attributes["w:charSpace"]);
1370
            return ctObj;
1371
        }
1372

1373

1374

1375
        internal void Write(StreamWriter sw, string nodeName)
1376
        {
1377
            sw.Write(string.Format("<w:{0}", nodeName));
1378
            if(this.type!= ST_DocGrid.@default)
1379
                XmlHelper.WriteAttribute(sw, "w:type", this.type.ToString());
1380
            XmlHelper.WriteAttribute(sw, "w:linePitch", this.linePitch);
1381
            XmlHelper.WriteAttribute(sw, "w:charSpace", this.charSpace);
1382
            sw.Write("/>");
1383
        }
1384

1385
        [XmlAttribute(Form = System.Xml.Schema.XmlSchemaForm.Qualified)]
1386
        public ST_DocGrid type
1387
        {
1388
            get
1389
            {
1390
                return this.typeField;
1391
            }
1392
            set
1393
            {
1394
                this.typeField = value;
1395
            }
1396
        }
1397

1398
        [XmlIgnore]
1399
        public bool typeSpecified
1400
        {
1401
            get
1402
            {
1403
                return this.typeFieldSpecified;
1404
            }
1405
            set
1406
            {
1407
                this.typeFieldSpecified = value;
1408
            }
1409
        }
1410

1411
        [XmlAttribute(Form = System.Xml.Schema.XmlSchemaForm.Qualified, DataType = "integer")]
1412
        public string linePitch
1413
        {
1414
            get
1415
            {
1416
                return this.linePitchField;
1417
            }
1418
            set
1419
            {
1420
                this.linePitchField = value;
1421
            }
1422
        }
1423

1424
        [XmlAttribute(Form = System.Xml.Schema.XmlSchemaForm.Qualified, DataType = "integer")]
1425
        public string charSpace
1426
        {
1427
            get
1428
            {
1429
                return this.charSpaceField;
1430
            }
1431
            set
1432
            {
1433
                this.charSpaceField = value;
1434
            }
1435
        }
1436
    }
1437

1438

1439
    [Serializable]
1440
    [XmlType(Namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main")]
1441
    public enum ST_DocGrid
1442
    {
1443

1444

1445
        @default,
1446

1447

1448
        lines,
1449

1450

1451
        linesAndChars,
1452

1453

1454
        snapToChars,
1455
    }
1456

1457
    [Serializable]
1458

1459
    [XmlType(Namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main")]
1460
    [XmlRoot(Namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", IsNullable = true)]
1461
    public class CT_DocVars
1462
    {
1463

1464
        private List<CT_DocVar> docVarField;
1465

1466
        public CT_DocVars()
1467
        {
1468
            this.docVarField = new List<CT_DocVar>();
1469
        }
1470

1471
        [XmlElement("docVar", Order = 0)]
1472
        public List<CT_DocVar> docVar
1473
        {
1474
            get
1475
            {
1476
                return this.docVarField;
1477
            }
1478
            set
1479
            {
1480
                this.docVarField = value;
1481
            }
1482
        }
1483

1484
        public static CT_DocVars Parse(XmlNode node, XmlNamespaceManager namespaceManager)
1485
        {
1486
            if(node == null)
1487
                return null;
1488

1489
            CT_DocVars ctObj = new CT_DocVars();
1490
            ctObj.docVar = new List<CT_DocVar>();
1491
            foreach(XmlNode childNode in node.ChildNodes)
1492
                ctObj.docVar.Add(CT_DocVar.Parse(childNode, namespaceManager));
1493

1494
            return ctObj;
1495
        }
1496

1497
        internal void Write(StreamWriter sw, string nodeName)
1498
        {
1499
            sw.Write(string.Format("<w:{0}", nodeName));
1500
            sw.Write(">");
1501
            if(this.docVar != null)
1502
            {
1503
                foreach(CT_DocVar x in this.docVar)
1504
                {
1505
                    x.Write(sw, "docVar");
1506
                }
1507
            }
1508
            sw.WriteEndW(nodeName);
1509
        }
1510
    }
1511

1512
}
1513

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

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

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

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