Free cookie consent management tool by TermsFeed Policy Generator

source: branches/PersistenceReintegration/HeuristicLab.ExtLibs/HeuristicLab.EPPlus/4.0.3/EPPlus-4.0.3/Style/XmlAccess/ExcelBorderXml.cs @ 15802

Last change on this file since 15802 was 12074, checked in by sraggl, 10 years ago

#2341: Added EPPlus-4.0.3 to ExtLibs

File size: 7.2 KB
Line 
1/*******************************************************************************
2 * You may amend and distribute as you like, but don't remove this header!
3 *
4 * EPPlus provides server-side generation of Excel 2007/2010 spreadsheets.
5 * See http://www.codeplex.com/EPPlus for details.
6 *
7 * Copyright (C) 2011  Jan Källman
8 *
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
13
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
17 * See the GNU Lesser General Public License for more details.
18 *
19 * The GNU Lesser General Public License can be viewed at http://www.opensource.org/licenses/lgpl-license.php
20 * If you unfamiliar with this license or have questions about it, here is an http://www.gnu.org/licenses/gpl-faq.html
21 *
22 * All code and executables are provided "as is" with no warranty either express or implied.
23 * The author accepts no liability for any damage or loss of business that this product may cause.
24 *
25 * Code change notes:
26 *
27 * Author             Change            Date
28 * ******************************************************************************
29 * Jan Källman                    Initial Release           2009-10-01
30 * Jan Källman    License changed GPL-->LGPL 2011-12-16
31 *******************************************************************************/
32using System;
33using System.Collections.Generic;
34using System.Text;
35using System.Xml;
36namespace OfficeOpenXml.Style.XmlAccess
37{
38    /// <summary>
39    /// Xml access class for border top level
40    /// </summary>
41    public sealed class ExcelBorderXml : StyleXmlHelper
42    {
43        internal ExcelBorderXml(XmlNamespaceManager nameSpaceManager)
44            : base(nameSpaceManager)
45        {
46
47        }
48        internal ExcelBorderXml(XmlNamespaceManager nsm, XmlNode topNode) :
49            base(nsm, topNode)
50        {
51            _left = new ExcelBorderItemXml(nsm, topNode.SelectSingleNode(leftPath, nsm));
52            _right = new ExcelBorderItemXml(nsm, topNode.SelectSingleNode(rightPath, nsm));
53            _top = new ExcelBorderItemXml(nsm, topNode.SelectSingleNode(topPath, nsm));
54            _bottom = new ExcelBorderItemXml(nsm, topNode.SelectSingleNode(bottomPath, nsm));
55            _diagonal = new ExcelBorderItemXml(nsm, topNode.SelectSingleNode(diagonalPath, nsm));
56        }
57        internal override string Id
58        {
59            get
60            {
61                return Left.Id + Right.Id + Top.Id + Bottom.Id + Diagonal.Id + DiagonalUp.ToString() + DiagonalDown.ToString();
62            }
63        }
64        const string leftPath = "d:left";
65        ExcelBorderItemXml _left = null;
66        /// <summary>
67        /// Left border style properties
68        /// </summary>
69        public ExcelBorderItemXml Left
70        {
71            get
72            {
73                return _left;
74            }
75            internal set
76            {
77                _left = value;
78            }
79        }
80        const string rightPath = "d:right";
81        ExcelBorderItemXml _right = null;
82        /// <summary>
83        /// Right border style properties
84        /// </summary>
85        public ExcelBorderItemXml Right
86        {
87            get
88            {
89                return _right;
90            }
91            internal set
92            {
93                _right = value;
94            }
95        }
96        const string topPath = "d:top";
97        ExcelBorderItemXml _top = null;
98        /// <summary>
99        /// Top border style properties
100        /// </summary>
101        public ExcelBorderItemXml Top
102        {
103            get
104            {
105                return _top;
106            }
107            internal set
108            {
109                _top = value;
110            }
111        }
112        const string bottomPath = "d:bottom";
113        ExcelBorderItemXml _bottom = null;
114        /// <summary>
115        /// Bottom border style properties
116        /// </summary>
117        public ExcelBorderItemXml Bottom
118        {
119            get
120            {
121                return _bottom;
122            }
123            internal set
124            {
125                _bottom = value;
126            }
127        }
128        const string diagonalPath = "d:diagonal";
129        ExcelBorderItemXml _diagonal = null;
130        /// <summary>
131        /// Diagonal border style properties
132        /// </summary>
133        public ExcelBorderItemXml Diagonal
134        {
135            get
136            {
137                return _diagonal;
138            }
139            internal set
140            {
141                _diagonal = value;
142            }
143        }
144        const string diagonalUpPath = "@diagonalUp";
145        bool _diagonalUp = false;
146        /// <summary>
147        /// Diagonal up border
148        /// </summary>
149        public bool DiagonalUp
150        {
151            get
152            {
153                return _diagonalUp;
154            }
155            internal set
156            {
157                _diagonalUp = value;
158            }
159        }
160        const string diagonalDownPath = "@diagonalDown";
161        bool _diagonalDown = false;
162        /// <summary>
163        /// Diagonal down border
164        /// </summary>
165        public bool DiagonalDown
166        {
167            get
168            {
169                return _diagonalDown;
170            }
171            internal set
172            {
173                _diagonalDown = value;
174            }
175        }
176
177        internal ExcelBorderXml Copy()
178        {
179            ExcelBorderXml newBorder = new ExcelBorderXml(NameSpaceManager);
180            newBorder.Bottom = _bottom.Copy();
181            newBorder.Diagonal = _diagonal.Copy();
182            newBorder.Left = _left.Copy();
183            newBorder.Right = _right.Copy();
184            newBorder.Top = _top.Copy();
185            newBorder.DiagonalUp = _diagonalUp;
186            newBorder.DiagonalDown = _diagonalDown;
187
188            return newBorder;
189
190        }
191
192        internal override XmlNode CreateXmlNode(XmlNode topNode)
193        {
194            TopNode = topNode;
195            CreateNode(leftPath);
196            topNode.AppendChild(_left.CreateXmlNode(TopNode.SelectSingleNode(leftPath, NameSpaceManager)));
197            CreateNode(rightPath);
198            topNode.AppendChild(_right.CreateXmlNode(TopNode.SelectSingleNode(rightPath, NameSpaceManager)));
199            CreateNode(topPath);
200            topNode.AppendChild(_top.CreateXmlNode(TopNode.SelectSingleNode(topPath, NameSpaceManager)));
201            CreateNode(bottomPath);
202            topNode.AppendChild(_bottom.CreateXmlNode(TopNode.SelectSingleNode(bottomPath, NameSpaceManager)));
203            CreateNode(diagonalPath);
204            topNode.AppendChild(_diagonal.CreateXmlNode(TopNode.SelectSingleNode(diagonalPath, NameSpaceManager)));
205            if (_diagonalUp)
206            {
207                SetXmlNodeString(diagonalUpPath, "1");
208            }
209            if (_diagonalDown)
210            {
211                SetXmlNodeString(diagonalDownPath, "1");
212            }
213            return topNode;
214        }
215    }
216}
Note: See TracBrowser for help on using the repository browser.