Free cookie consent management tool by TermsFeed Policy Generator

source: branches/2989_MovingPeaksBenchmark/HeuristicLab.ExtLibs/HeuristicLab.EPPlus/4.0.3/EPPlus-4.0.3/Drawing/Vml/ExcelVmlDrawingBase.cs @ 17530

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

#2341: Added EPPlus-4.0.3 to ExtLibs

File size: 4.8 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           2010-06-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;
36using System.Globalization;
37using System.Drawing;
38
39namespace OfficeOpenXml.Drawing.Vml
40{
41    /// <summary>
42    /// Horizontal Alingment
43    /// </summary>
44    public enum eTextAlignHorizontalVml
45    {
46        Left,
47        Center,
48        Right
49    }
50    /// <summary>
51    /// Vertical Alingment
52    /// </summary>
53    public enum eTextAlignVerticalVml
54    {
55        Top,
56        Center,
57        Bottom
58    }
59    /// <summary>
60    /// Linestyle
61    /// </summary>
62    public enum eLineStyleVml
63    {
64        Solid,
65        Round,
66        Square,
67        Dash,
68        DashDot,
69        LongDash,
70        LongDashDot,
71        LongDashDotDot
72    }
73    /// <summary>
74    /// Drawing object used for comments
75    /// </summary>
76    public class ExcelVmlDrawingBase : XmlHelper
77    {
78        internal ExcelVmlDrawingBase(XmlNode topNode, XmlNamespaceManager ns) :
79            base(ns, topNode)
80        {
81            SchemaNodeOrder = new string[] { "fill", "stroke", "shadow", "path", "textbox", "ClientData", "MoveWithCells", "SizeWithCells", "Anchor", "Locked", "AutoFill", "LockText", "TextHAlign", "TextVAlign", "Row", "Column", "Visible" };
82        }   
83        public string Id
84        {
85            get
86            {
87                return GetXmlNodeString("@id");
88            }
89            set
90            {
91                SetXmlNodeString("@id",value);
92            }
93        }
94        #region "Style Handling methods"
95        protected bool GetStyle(string style, string key, out string value)
96        {
97            string[]styles = style.Split(';');
98            foreach(string s in styles)
99            {
100                if (s.IndexOf(':') > 0)
101                {
102                    string[] split = s.Split(':');
103                    if (split[0] == key)
104                    {
105                        value=split[1];
106                        return true;
107                    }
108                }
109                else if (s == key)
110                {
111                    value="";
112                    return true;
113                }
114            }
115            value="";
116            return false;
117        }
118        protected string SetStyle(string style, string key, string value)
119        {
120            string[] styles = style.Split(';');
121            string newStyle="";
122            bool changed = false;
123            foreach (string s in styles)
124            {
125                string[] split = s.Split(':');
126                if (split[0].Trim() == key)
127                {
128                    if (value.Trim() != "") //If blank remove the item
129                    {
130                        newStyle += key + ':' + value;
131                    }
132                    changed = true;
133                }
134                else
135                {
136                    newStyle += s;
137                }
138                newStyle += ';';
139            }
140            if (!changed)
141            {
142                newStyle += key + ':' + value;
143            }
144            else
145            {
146                newStyle = style.Substring(0, style.Length - 1);
147            }
148            return newStyle;
149        }
150        #endregion
151    }
152}
Note: See TracBrowser for help on using the repository browser.