[12762] | 1 | using System;
|
---|
| 2 | using System.Xml;
|
---|
| 3 |
|
---|
| 4 | namespace SharpVectors.Dom.Svg
|
---|
| 5 | {
|
---|
| 6 | public enum SvgLengthAdjust
|
---|
| 7 | {
|
---|
| 8 | Unknown = 0,
|
---|
| 9 | Spacing = 1,
|
---|
| 10 | SpacingAndGlyphs = 2
|
---|
| 11 | }
|
---|
| 12 |
|
---|
| 13 | /// <summary>
|
---|
| 14 | /// Summary description for SvgTextContentElement.
|
---|
| 15 | /// </summary>
|
---|
| 16 | public abstract class SvgTextContentElement : SvgTransformableElement, ISvgTextContentElement
|
---|
| 17 | {
|
---|
| 18 | #region Private Fields
|
---|
| 19 |
|
---|
| 20 | private SvgTests svgTests;
|
---|
| 21 | private SvgExternalResourcesRequired svgExternalResourcesRequired;
|
---|
| 22 |
|
---|
| 23 | #endregion
|
---|
| 24 |
|
---|
| 25 | #region Constructors and Destructor
|
---|
| 26 |
|
---|
| 27 | protected SvgTextContentElement(string prefix, string localname, string ns, SvgDocument doc)
|
---|
| 28 | : base(prefix, localname, ns, doc)
|
---|
| 29 | {
|
---|
| 30 | svgTests = new SvgTests(this);
|
---|
| 31 | svgExternalResourcesRequired = new SvgExternalResourcesRequired(this);
|
---|
| 32 | }
|
---|
| 33 |
|
---|
| 34 | #endregion
|
---|
| 35 |
|
---|
| 36 | #region ISvgElement Members
|
---|
| 37 |
|
---|
| 38 | /// <summary>
|
---|
| 39 | /// Gets a value providing a hint on the rendering defined by this element.
|
---|
| 40 | /// </summary>
|
---|
| 41 | /// <value>
|
---|
| 42 | /// An enumeration of the <see cref="SvgRenderingHint"/> specifying the rendering hint.
|
---|
| 43 | /// This will always return <see cref="SvgRenderingHint.Text"/>
|
---|
| 44 | /// </value>
|
---|
| 45 | public override SvgRenderingHint RenderingHint
|
---|
| 46 | {
|
---|
| 47 | get
|
---|
| 48 | {
|
---|
| 49 | return SvgRenderingHint.Text;
|
---|
| 50 | }
|
---|
| 51 | }
|
---|
| 52 |
|
---|
| 53 | #endregion
|
---|
| 54 |
|
---|
| 55 | #region ISvgExternalResourcesRequired Members
|
---|
| 56 |
|
---|
| 57 | public ISvgAnimatedBoolean ExternalResourcesRequired
|
---|
| 58 | {
|
---|
| 59 | get
|
---|
| 60 | {
|
---|
| 61 | return svgExternalResourcesRequired.ExternalResourcesRequired;
|
---|
| 62 | }
|
---|
| 63 | }
|
---|
| 64 | #endregion
|
---|
| 65 |
|
---|
| 66 | #region ISvgTests Members
|
---|
| 67 |
|
---|
| 68 | public ISvgStringList RequiredFeatures
|
---|
| 69 | {
|
---|
| 70 | get { return svgTests.RequiredFeatures; }
|
---|
| 71 | }
|
---|
| 72 |
|
---|
| 73 | public ISvgStringList RequiredExtensions
|
---|
| 74 | {
|
---|
| 75 | get { return svgTests.RequiredExtensions; }
|
---|
| 76 | }
|
---|
| 77 |
|
---|
| 78 | public ISvgStringList SystemLanguage
|
---|
| 79 | {
|
---|
| 80 | get { return svgTests.SystemLanguage; }
|
---|
| 81 | }
|
---|
| 82 |
|
---|
| 83 | public bool HasExtension(string extension)
|
---|
| 84 | {
|
---|
| 85 | return svgTests.HasExtension(extension);
|
---|
| 86 | }
|
---|
| 87 |
|
---|
| 88 | #endregion
|
---|
| 89 |
|
---|
| 90 | public ISvgAnimatedLength TextLength
|
---|
| 91 | {
|
---|
| 92 | get { throw new NotImplementedException(); }
|
---|
| 93 | }
|
---|
| 94 |
|
---|
| 95 | public ISvgAnimatedEnumeration LengthAdjust
|
---|
| 96 | {
|
---|
| 97 | get { throw new NotImplementedException(); }
|
---|
| 98 | }
|
---|
| 99 |
|
---|
| 100 | protected SvgTextElement OwnerTextElement
|
---|
| 101 | {
|
---|
| 102 | get
|
---|
| 103 | {
|
---|
| 104 | XmlNode node = this;
|
---|
| 105 | while (node != null)
|
---|
| 106 | {
|
---|
| 107 | SvgTextElement text = node as SvgTextElement;
|
---|
| 108 | if (text != null)
|
---|
| 109 | {
|
---|
| 110 | return text;
|
---|
| 111 | }
|
---|
| 112 |
|
---|
| 113 | node = node.ParentNode;
|
---|
| 114 | }
|
---|
| 115 |
|
---|
| 116 | return null;
|
---|
| 117 | }
|
---|
| 118 | }
|
---|
| 119 |
|
---|
| 120 | #region Update handling
|
---|
| 121 |
|
---|
| 122 | public void Invalidate()
|
---|
| 123 | {
|
---|
| 124 | }
|
---|
| 125 |
|
---|
| 126 | public override void HandleAttributeChange(XmlAttribute attribute)
|
---|
| 127 | {
|
---|
| 128 | if (attribute.NamespaceURI.Length == 0)
|
---|
| 129 | {
|
---|
| 130 | // This list may be too long to be useful...
|
---|
| 131 | switch (attribute.LocalName)
|
---|
| 132 | {
|
---|
| 133 | // Additional attributes
|
---|
| 134 | case "x":
|
---|
| 135 | case "y":
|
---|
| 136 | case "dx":
|
---|
| 137 | case "dy":
|
---|
| 138 | case "rotate":
|
---|
| 139 | case "textLength":
|
---|
| 140 | case "lengthAdjust":
|
---|
| 141 | // Text.attrib
|
---|
| 142 | case "writing-mode":
|
---|
| 143 | // TextContent.attrib
|
---|
| 144 | case "alignment-baseline":
|
---|
| 145 | case "baseline-shift":
|
---|
| 146 | case "direction":
|
---|
| 147 | case "dominant-baseline":
|
---|
| 148 | case "glyph-orientation-horizontal":
|
---|
| 149 | case "glyph-orientation-vertical":
|
---|
| 150 | case "kerning":
|
---|
| 151 | case "letter-spacing":
|
---|
| 152 | case "text-anchor":
|
---|
| 153 | case "text-decoration":
|
---|
| 154 | case "unicode-bidi":
|
---|
| 155 | case "word-spacing":
|
---|
| 156 | // Font.attrib
|
---|
| 157 | case "font-family":
|
---|
| 158 | case "font-size":
|
---|
| 159 | case "font-size-adjust":
|
---|
| 160 | case "font-stretch":
|
---|
| 161 | case "font-style":
|
---|
| 162 | case "font-variant":
|
---|
| 163 | case "font-weight":
|
---|
| 164 | // textPath
|
---|
| 165 | case "startOffset":
|
---|
| 166 | case "method":
|
---|
| 167 | case "spacing":
|
---|
| 168 | // Color.attrib, Paint.attrib
|
---|
| 169 | case "color":
|
---|
| 170 | case "fill":
|
---|
| 171 | case "fill-rule":
|
---|
| 172 | case "stroke":
|
---|
| 173 | case "stroke-dasharray":
|
---|
| 174 | case "stroke-dashoffset":
|
---|
| 175 | case "stroke-linecap":
|
---|
| 176 | case "stroke-linejoin":
|
---|
| 177 | case "stroke-miterlimit":
|
---|
| 178 | case "stroke-width":
|
---|
| 179 | // Opacity.attrib
|
---|
| 180 | case "opacity":
|
---|
| 181 | case "stroke-opacity":
|
---|
| 182 | case "fill-opacity":
|
---|
| 183 | // Graphics.attrib
|
---|
| 184 | case "display":
|
---|
| 185 | case "image-rendering":
|
---|
| 186 | case "shape-rendering":
|
---|
| 187 | case "text-rendering":
|
---|
| 188 | case "visibility":
|
---|
| 189 | Invalidate();
|
---|
| 190 | return;
|
---|
| 191 | case "transform":
|
---|
| 192 | Invalidate();
|
---|
| 193 | break;
|
---|
| 194 | }
|
---|
| 195 |
|
---|
| 196 | base.HandleAttributeChange(attribute);
|
---|
| 197 | }
|
---|
| 198 | else if (attribute.Name == "xml:preserve" || attribute.Name == "xlink:href")
|
---|
| 199 | {
|
---|
| 200 | // xml:preserve and xlink:href changes may affect the actual text content
|
---|
| 201 | Invalidate();
|
---|
| 202 | }
|
---|
| 203 | }
|
---|
| 204 |
|
---|
| 205 | public override void ElementChange(Object src, XmlNodeChangedEventArgs args)
|
---|
| 206 | {
|
---|
| 207 | Invalidate();
|
---|
| 208 |
|
---|
| 209 | base.ElementChange(src, args);
|
---|
| 210 | }
|
---|
| 211 |
|
---|
| 212 | #endregion
|
---|
| 213 |
|
---|
| 214 | #region Private Methods
|
---|
| 215 |
|
---|
| 216 | #endregion
|
---|
| 217 |
|
---|
| 218 | #region Public Methods
|
---|
| 219 |
|
---|
| 220 | public long GetNumberOfChars()
|
---|
| 221 | {
|
---|
| 222 | return this.InnerText.Length;
|
---|
| 223 | }
|
---|
| 224 |
|
---|
| 225 | #region UnImplemented Methods
|
---|
| 226 |
|
---|
| 227 | public float GetComputedTextLength()
|
---|
| 228 | {
|
---|
| 229 | throw new NotImplementedException();
|
---|
| 230 | }
|
---|
| 231 |
|
---|
| 232 | public float GetSubStringLength(long charnum, long nchars)
|
---|
| 233 | {
|
---|
| 234 | throw new NotImplementedException();
|
---|
| 235 | }
|
---|
| 236 |
|
---|
| 237 | public ISvgPoint GetStartPositionOfChar(long charnum)
|
---|
| 238 | {
|
---|
| 239 | throw new NotImplementedException();
|
---|
| 240 | }
|
---|
| 241 |
|
---|
| 242 | public ISvgPoint GetEndPositionOfChar(long charnum)
|
---|
| 243 | {
|
---|
| 244 | throw new NotImplementedException();
|
---|
| 245 | }
|
---|
| 246 |
|
---|
| 247 | public ISvgRect GetExtentOfChar(long charnum)
|
---|
| 248 | {
|
---|
| 249 | throw new NotImplementedException();
|
---|
| 250 | }
|
---|
| 251 |
|
---|
| 252 | public float GetRotationOfChar(long charnum)
|
---|
| 253 | {
|
---|
| 254 | throw new NotImplementedException();
|
---|
| 255 | }
|
---|
| 256 |
|
---|
| 257 | public long GetCharNumAtPosition(ISvgPoint point)
|
---|
| 258 | {
|
---|
| 259 | throw new NotImplementedException();
|
---|
| 260 | }
|
---|
| 261 |
|
---|
| 262 | public void SelectSubString(long charnum, long nchars)
|
---|
| 263 | {
|
---|
| 264 | throw new NotImplementedException();
|
---|
| 265 | }
|
---|
| 266 |
|
---|
| 267 | #endregion
|
---|
| 268 |
|
---|
| 269 | #endregion
|
---|
| 270 | }
|
---|
| 271 | }
|
---|