npoi

Форк
0
/
SpreadsheetPicture.cs 
231 строка · 7.5 Кб
1
using NPOI.OpenXml4Net.Util;
2
using System;
3
using System.ComponentModel;
4
using System.IO;
5
using System.Xml;
6
using System.Xml.Serialization;
7

8
namespace NPOI.OpenXmlFormats.Dml.Spreadsheet
9
{
10

11
    [Serializable]
12
    [XmlType(Namespace = "http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing")]
13
    public class CT_Picture // empty interface: EG_ObjectChoices
14
    {
15
        private CT_PictureNonVisual nvPicPrField = new CT_PictureNonVisual();        //  draw-ssdraw: 1..1 
16
        private CT_BlipFillProperties blipFillField = new CT_BlipFillProperties();   //  draw-ssdraw: 1..1 
17
        private CT_ShapeProperties spPrField = new CT_ShapeProperties();             //  draw-ssdraw: 1..1 
18
        private CT_ShapeStyle styleField = null; // 0..1
19

20
        private string macroField = null;
21
        private bool fPublishedField = false;
22
        public static CT_Picture Parse(XmlNode node, XmlNamespaceManager namespaceManager)
23
        {
24
            if (node == null)
25
                return null;
26
            CT_Picture ctObj = new CT_Picture();
27
            ctObj.macro = XmlHelper.ReadString(node.Attributes["macro"]);
28
            ctObj.fPublished = XmlHelper.ReadBool(node.Attributes["fPublished"]);
29
            foreach (XmlNode childNode in node.ChildNodes)
30
            {
31
                if (childNode.LocalName == "nvPicPr")
32
                    ctObj.nvPicPr = CT_PictureNonVisual.Parse(childNode, namespaceManager);
33
                else if (childNode.LocalName == "blipFill")
34
                    ctObj.blipFill = CT_BlipFillProperties.Parse(childNode, namespaceManager);
35
                else if (childNode.LocalName == "spPr")
36
                    ctObj.spPr = CT_ShapeProperties.Parse(childNode, namespaceManager);
37
                else if (childNode.LocalName == "style")
38
                    ctObj.style = CT_ShapeStyle.Parse(childNode, namespaceManager);
39
            }
40
            return ctObj;
41
        }
42

43

44

45
        internal void Write(StreamWriter sw, string nodeName)
46
        {
47
            sw.Write(string.Format("<xdr:{0}", nodeName));
48
            XmlHelper.WriteAttribute(sw, "macro", this.macro);
49
            if (this.fPublished)
50
                XmlHelper.WriteAttribute(sw, "fPublished", this.fPublished);
51
            sw.Write(">");
52
            if (this.nvPicPr != null)
53
                this.nvPicPr.Write(sw, "nvPicPr");
54
            if (this.blipFill != null)
55
                this.blipFill.Write(sw, "blipFill");
56
            if (this.spPr != null)
57
                this.spPr.Write(sw, "spPr");
58
            if (this.style != null)
59
                this.style.Write(sw, "style");
60
            sw.Write(string.Format("</xdr:{0}>", nodeName));
61
        }
62

63
        [XmlElement]
64
        public CT_PictureNonVisual nvPicPr
65
        {
66
            get { return this.nvPicPrField; }
67
            set { this.nvPicPrField = value; }
68
        }
69

70
        [XmlElement]
71
        public CT_BlipFillProperties blipFill
72
        {
73
            get { return this.blipFillField; }
74
            set { this.blipFillField = value; }
75
        }
76

77
        [XmlElement]
78
        public CT_ShapeProperties spPr
79
        {
80
            get { return this.spPrField; }
81
            set { this.spPrField = value; }
82
        }
83

84
        [XmlElement]
85
        public CT_ShapeStyle style
86
        {
87
            get
88
            {
89
                return this.styleField;
90
            }
91
            set
92
            {
93
                this.styleField = value;
94
            }
95
        }
96
        private bool styleSpecifiedField = false;
97
        [XmlIgnore]
98
        public bool styleSpecified
99
        {
100
            get { return styleSpecifiedField; }
101
            set { styleSpecifiedField = value; }
102
        }
103

104
        [XmlAttribute]
105
        public string macro
106
        {
107
            get { return macroField; }
108
            set { macroField = value; }
109
        }
110
        private bool macroSpecifiedField = false;
111
        [XmlIgnore]
112
        public bool macroSpecified
113
        {
114
            get { return macroSpecifiedField; }
115
            set { macroSpecifiedField = value; }
116
        }
117

118
        [XmlAttribute]
119
        public bool fPublished
120
        {
121
            get { return fPublishedField; }
122
            set { fPublishedField = value; }
123
        }
124
        private bool fPublishedSpecifiedField = false;
125
        [XmlIgnore]
126
        public bool fPublishedSpecified
127
        {
128
            get { return fPublishedSpecifiedField; }
129
            set { fPublishedSpecifiedField = value; }
130
        }
131

132
        public CT_PictureNonVisual AddNewNvPicPr()
133
        {
134
            nvPicPrField = new CT_PictureNonVisual();
135
            return this.nvPicPrField;
136
        }
137

138
        public CT_BlipFillProperties AddNewBlipFill()
139
        {
140
            blipFillField = new CT_BlipFillProperties();
141
            return this.blipFillField;
142
        }
143

144
        public CT_ShapeProperties AddNewSpPr()
145
        {
146
            spPrField = new CT_ShapeProperties();
147
            return this.spPrField;
148
        }
149

150
        public void Set(CT_Picture pict)
151
        {
152
            this.nvPicPr = pict.nvPicPr;
153
            this.spPr = pict.spPr;
154
            this.macro = pict.macro;
155
            this.macroSpecified = this.macroSpecified;
156
            this.style = pict.style;
157
            this.styleSpecified = pict.styleSpecified;
158
            this.fPublished = pict.fPublished;
159
            this.fPublishedSpecified = pict.fPublishedSpecified;
160
            this.blipFill = pict.blipFill;
161

162

163
        }
164

165
    }
166

167
    // see same class in different name space in Picture.cs
168
    [Serializable]
169
    [XmlType(Namespace = "http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing")]
170
    public class CT_PictureNonVisual
171
    {
172

173
        private CT_NonVisualDrawingProps cNvPrField = new CT_NonVisualDrawingProps(); // 1..1
174
        private CT_NonVisualPictureProperties cNvPicPrField = new CT_NonVisualPictureProperties(); // 1..1
175

176
        public static CT_PictureNonVisual Parse(XmlNode node, XmlNamespaceManager namespaceManager)
177
        {
178
            if (node == null)
179
                return null;
180
            CT_PictureNonVisual ctObj = new CT_PictureNonVisual();
181
            foreach (XmlNode childNode in node.ChildNodes)
182
            {
183
                if (childNode.LocalName == "cNvPr")
184
                    ctObj.cNvPr = CT_NonVisualDrawingProps.Parse(childNode, namespaceManager);
185
                else if (childNode.LocalName == "cNvPicPr")
186
                    ctObj.cNvPicPr = CT_NonVisualPictureProperties.Parse(childNode, namespaceManager);
187
            }
188
            return ctObj;
189
        }
190

191

192

193
        internal void Write(StreamWriter sw, string nodeName)
194
        {
195
            sw.Write(string.Format("<xdr:{0}", nodeName));
196
            sw.Write(">");
197
            if (this.cNvPr != null)
198
                this.cNvPr.Write(sw, "cNvPr");
199
            if (this.cNvPicPr != null)
200
                this.cNvPicPr.Write(sw, "cNvPicPr");
201
            sw.Write(string.Format("</xdr:{0}>", nodeName));
202
        }
203
        public CT_NonVisualDrawingProps AddNewCNvPr()
204
        {
205
            this.cNvPrField = new CT_NonVisualDrawingProps();
206
            return this.cNvPrField;
207
        }
208
        public CT_NonVisualPictureProperties AddNewCNvPicPr()
209
        {
210
            this.cNvPicPrField = new CT_NonVisualPictureProperties();
211
            return this.cNvPicPrField;
212
        }
213

214
        [XmlElement]
215
        public CT_NonVisualDrawingProps cNvPr
216
        {
217
            get { return this.cNvPrField; }
218
            set { this.cNvPrField = value; }
219
        }
220

221

222
        [XmlElement]
223
        public CT_NonVisualPictureProperties cNvPicPr
224
        {
225
            get { return this.cNvPicPrField; }
226
            set { this.cNvPicPrField = value; }
227
        }
228

229
    }
230

231
}
232

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

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

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

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