Commit 1585c700 authored by Ritch Melton's avatar Ritch Melton
Browse files

merged

parents cc4f2940 1818255b
This diff is collapsed.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
namespace Svg
{
public interface IGraphicsProvider
{
Graphics GetGraphics();
}
}
using System;
using System.Drawing.Drawing2D;
using System.Drawing;
using System.Collections.Generic;
namespace Svg
{
public interface ISvgRenderer : IDisposable
{
float DpiY { get; }
void DrawImage(Image image, RectangleF destRect, RectangleF srcRect, GraphicsUnit graphicsUnit);
void DrawImageUnscaled(Image image, Point location);
void DrawPath(Pen pen, GraphicsPath path);
void FillPath(Brush brush, GraphicsPath path);
ISvgBoundable GetBoundable();
Region GetClip();
ISvgBoundable PopBoundable();
void RotateTransform(float fAngle, MatrixOrder order = MatrixOrder.Append);
void ScaleTransform(float sx, float sy, MatrixOrder order = MatrixOrder.Append);
void SetBoundable(ISvgBoundable boundable);
void SetClip(Region region, CombineMode combineMode = CombineMode.Replace);
SmoothingMode SmoothingMode { get; set; }
Matrix Transform { get; set; }
void TranslateTransform(float dx, float dy, MatrixOrder order = MatrixOrder.Append);
}
}
...@@ -100,8 +100,20 @@ ...@@ -100,8 +100,20 @@
<Compile Include="Clipping and Masking\SvgClipPath.cs" /> <Compile Include="Clipping and Masking\SvgClipPath.cs" />
<Compile Include="Clipping and Masking\SvgMask.cs" /> <Compile Include="Clipping and Masking\SvgMask.cs" />
<Compile Include="DataTypes\ISvgSupportsCoordinateUnits.cs" /> <Compile Include="DataTypes\ISvgSupportsCoordinateUnits.cs" />
<Compile Include="DataTypes\SvgPointCollection.cs" />
<Compile Include="DataTypes\SvgTextDecoration.cs" /> <Compile Include="DataTypes\SvgTextDecoration.cs" />
<Compile Include="DataTypes\SvgTextLengthAdjust.cs" />
<Compile Include="DataTypes\SvgTextPathMethod.cs" />
<Compile Include="DataTypes\SvgTextPathSpacing.cs" />
<Compile Include="DataTypes\XmlSpaceHandling.cs" />
<Compile Include="Document Structure\SvgSymbol.cs" />
<Compile Include="Filter Effects\ImageBuffer.cs" />
<Compile Include="Painting\GenericBoundable.cs" /> <Compile Include="Painting\GenericBoundable.cs" />
<Compile Include="Painting\SvgFallbackPaintServer .cs" />
<Compile Include="Paths\CoordinateParser.cs" />
<Compile Include="Rendering\IGraphicsProvider.cs" />
<Compile Include="Rendering\ISvgRenderer.cs" />
<Compile Include="SvgElementStyle.cs" />
<Compile Include="SvgNodeReader.cs" /> <Compile Include="SvgNodeReader.cs" />
<Compile Include="Css\CssQuery.cs" /> <Compile Include="Css\CssQuery.cs" />
<Compile Include="Css\SvgElementOps.cs" /> <Compile Include="Css\SvgElementOps.cs" />
...@@ -234,7 +246,7 @@ ...@@ -234,7 +246,7 @@
<Compile Include="SvgUnknownElement.cs" /> <Compile Include="SvgUnknownElement.cs" />
<Compile Include="SvgElementAttribute.cs" /> <Compile Include="SvgElementAttribute.cs" />
<Compile Include="SvgExtentions.cs" /> <Compile Include="SvgExtentions.cs" />
<Compile Include="SvgRenderer.cs" /> <Compile Include="Rendering\SvgRenderer.cs" />
<Compile Include="Painting\SvgColourConverter.cs" /> <Compile Include="Painting\SvgColourConverter.cs" />
<Compile Include="Painting\SvgGradientSpreadMethod.cs" /> <Compile Include="Painting\SvgGradientSpreadMethod.cs" />
<Compile Include="SvgDtdResolver.cs" /> <Compile Include="SvgDtdResolver.cs" />
...@@ -275,10 +287,24 @@ ...@@ -275,10 +287,24 @@
<Compile Include="DataTypes\SvgUnit.cs" /> <Compile Include="DataTypes\SvgUnit.cs" />
<Compile Include="DataTypes\SvgUnitConverter.cs" /> <Compile Include="DataTypes\SvgUnitConverter.cs" />
<Compile Include="SvgTextReader.cs" /> <Compile Include="SvgTextReader.cs" />
<Compile Include="Text\SvgFontFaceUri.cs" />
<Compile Include="Text\FontFamily.cs" />
<Compile Include="Text\GdiFontDefn.cs" />
<Compile Include="Text\IFontDefn.cs" />
<Compile Include="Text\SvgFont.cs" />
<Compile Include="Text\SvgFontDefn.cs" />
<Compile Include="Text\SvgFontFace.cs" />
<Compile Include="Text\SvgFontFaceSrc.cs" />
<Compile Include="Text\SvgGlyph.cs" />
<Compile Include="Text\SvgKern.cs" />
<Compile Include="Text\SvgMissingGlyph.cs" />
<Compile Include="Text\SvgText.cs" /> <Compile Include="Text\SvgText.cs" />
<Compile Include="Text\SvgTextBase.cs" /> <Compile Include="Text\SvgTextBase.cs" />
<Compile Include="Text\SvgTextAnchor.cs" /> <Compile Include="Text\SvgTextAnchor.cs" />
<Compile Include="Text\SvgTextPath.cs" />
<Compile Include="Text\SvgTextSpan.cs" /> <Compile Include="Text\SvgTextSpan.cs" />
<Compile Include="Text\SvgTextRef.cs" />
<Compile Include="Text\PathStatistics.cs" />
<Compile Include="Transforms\ISvgTransformable.cs" /> <Compile Include="Transforms\ISvgTransformable.cs" />
<Compile Include="Transforms\SvgMatrix.cs" /> <Compile Include="Transforms\SvgMatrix.cs" />
<Compile Include="Transforms\SvgRotate.cs" /> <Compile Include="Transforms\SvgRotate.cs" />
......
...@@ -15,13 +15,14 @@ namespace Svg ...@@ -15,13 +15,14 @@ namespace Svg
/// <summary> /// <summary>
/// Gets a <see cref="string"/> containing the XLink namespace (http://www.w3.org/1999/xlink). /// Gets a <see cref="string"/> containing the XLink namespace (http://www.w3.org/1999/xlink).
/// </summary> /// </summary>
public const string SVG_NAMESPACE = "http://www.w3.org/2000/svg"; public const string SvgNamespace = "http://www.w3.org/2000/svg";
public const string XLinkPrefix = "xlink"; public const string XLinkPrefix = "xlink";
public const string XLinkNamespace = "http://www.w3.org/1999/xlink"; public const string XLinkNamespace = "http://www.w3.org/1999/xlink";
public const string XmlNamespace = "http://www.w3.org/XML/1998/namespace";
public static readonly List<KeyValuePair<string, string>> Namespaces = new List<KeyValuePair<string, string>>() public static readonly List<KeyValuePair<string, string>> Namespaces = new List<KeyValuePair<string, string>>()
{ {
new KeyValuePair<string, string>("", SVG_NAMESPACE), new KeyValuePair<string, string>("", SvgNamespace),
new KeyValuePair<string, string>(XLinkPrefix, XLinkNamespace) new KeyValuePair<string, string>(XLinkPrefix, XLinkNamespace)
}; };
private string _name; private string _name;
...@@ -55,7 +56,7 @@ namespace Svg ...@@ -55,7 +56,7 @@ namespace Svg
{ {
get get
{ {
if (_namespace == SVG_NAMESPACE) if (_namespace == SvgNamespace)
return _name; return _name;
return Namespaces.First(x => x.Value == _namespace).Key + ":" + _name; return Namespaces.First(x => x.Value == _namespace).Key + ":" + _name;
} }
...@@ -93,7 +94,7 @@ namespace Svg ...@@ -93,7 +94,7 @@ namespace Svg
internal SvgAttributeAttribute(string name) internal SvgAttributeAttribute(string name)
{ {
this._name = name; this._name = name;
this._namespace = SVG_NAMESPACE; this._namespace = SvgNamespace;
} }
/// <summary> /// <summary>
......
...@@ -89,8 +89,11 @@ namespace Svg ...@@ -89,8 +89,11 @@ namespace Svg
(value is SvgFontWeight && (SvgFontWeight)value == SvgFontWeight.inherit) || (value is SvgFontWeight && (SvgFontWeight)value == SvgFontWeight.inherit) ||
(value is SvgTextAnchor && (SvgTextAnchor)value == SvgTextAnchor.inherit) || (value is SvgTextAnchor && (SvgTextAnchor)value == SvgTextAnchor.inherit) ||
(value is SvgFontVariant && (SvgFontVariant)value == SvgFontVariant.inherit) || (value is SvgFontVariant && (SvgFontVariant)value == SvgFontVariant.inherit) ||
(value is SvgTextDecoration && (SvgTextDecoration)value == SvgTextDecoration.inherit) || (value is SvgTextDecoration && (SvgTextDecoration)value == SvgTextDecoration.inherit) ||
(value == "inherit") (value is XmlSpaceHandling && (XmlSpaceHandling)value == XmlSpaceHandling.inherit) ||
(value is SvgOverflow && (SvgOverflow)value == SvgOverflow.inherit) ||
(value == SvgColourServer.Inherit) ||
(value is string && (string)value == "inherit")
); );
} }
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -3,6 +3,8 @@ using System.Collections.Generic; ...@@ -3,6 +3,8 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Net;
using System.IO;
namespace Svg namespace Svg
{ {
...@@ -39,6 +41,30 @@ namespace Svg ...@@ -39,6 +41,30 @@ namespace Svg
public virtual SvgElement GetElementById(Uri uri) public virtual SvgElement GetElementById(Uri uri)
{ {
if (uri.ToString().StartsWith("url(")) uri = new Uri(uri.ToString().Substring(4).TrimEnd(')'), UriKind.Relative);
if (!uri.IsAbsoluteUri && this._document.BaseUri != null && !uri.ToString().StartsWith("#"))
{
var fullUri = new Uri(this._document.BaseUri, uri);
var hash = fullUri.OriginalString.Substring(fullUri.OriginalString.LastIndexOf('#'));
SvgDocument doc;
switch (fullUri.Scheme.ToLowerInvariant())
{
case "file":
doc = SvgDocument.Open<SvgDocument>(fullUri.LocalPath.Substring(0, fullUri.LocalPath.Length - hash.Length));
return doc.IdManager.GetElementById(hash);
case "http":
case "https":
var httpRequest = WebRequest.Create(uri);
using (WebResponse webResponse = httpRequest.GetResponse())
{
doc = SvgDocument.Open<SvgDocument>(webResponse.GetResponseStream());
return doc.IdManager.GetElementById(hash);
}
default:
throw new NotSupportedException();
}
}
return this.GetElementById(uri.ToString()); return this.GetElementById(uri.ToString());
} }
......
This diff is collapsed.
...@@ -123,7 +123,6 @@ namespace Svg ...@@ -123,7 +123,6 @@ namespace Svg
{ {
const string entityText = "<!ENTITY"; const string entityText = "<!ENTITY";
string[] entities = this.Value.Split(new string[]{entityText}, StringSplitOptions.None); string[] entities = this.Value.Split(new string[]{entityText}, StringSplitOptions.None);
string[] parts = null;
string name = null; string name = null;
string value = null; string value = null;
int quoteIndex; int quoteIndex;
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment