The root object in the document object hierarchy of an Svg document.

When an 'svg' element is embedded inline as a component of a document from another namespace, such as when an 'svg' element is embedded inline within an XHTML document [XHTML], then an ISvgDocument object will not exist; instead, the root object in the document object hierarchy will be a Document object of a different type, such as an HTMLDocument object.

However, an ISvgDocument object will indeed exist when the root element of the XML document hierarchy is an 'svg' element, such as when viewing a stand-alone SVG file (i.e., a file with MIME type "image/svg+xml"). In this case, the ISvgDocument object will be the root object of the document object model hierarchy.

In the case where an SVG document is embedded by reference, such as when an XHTML document has an 'object' element whose href attribute references an SVG document (i.e., a document whose MIME type is "image/svg+xml" and whose root element is thus an 'svg' element), there will exist two distinct DOM hierarchies. The first DOM hierarchy will be for the referencing document (e.g., an XHTML document). The second DOM hierarchy will be for the referenced SVG document. In this second DOM hierarchy, the root object of the document object model hierarchy is an ISvgDocument object.

The ISvgDocument interface contains a similar list of attributes and methods to the HTMLDocument interface described in the Document Object Model (HTML) Level 1 chapter of the [DOM1] specification.

Inheritance: SharpVectors.Dom.Css.CssXmlDocument, ISvgDocument
 public void TestKnownDomain()
 {
     SvgWindow wnd = new SvgWindow(75, 75, null);
     SvgDocument doc = new SvgDocument(wnd);
     doc.Load("http://www.shiny-donkey.com/shinyDonkey.svg");
     Assert.AreEqual("www.shiny-donkey.com", doc.Domain);
 }
        public override void TestTypeFromCreateElement()
        {
            SvgWindow wnd = new SvgWindow(100, 100, null);
            SvgDocument doc = new SvgDocument(wnd);
            XmlElement elm = doc.CreateElement("", localName, "http://www.w3.org/2000/svg");

            Assert.AreEqual(elmType, elm.GetType());
        }
 public SvgUseElement(string prefix, string localname, string ns, SvgDocument doc)
     : base(prefix, localname, ns, doc)
 {
     svgURIReference = new SvgUriReference(this);
     svgURIReference.NodeChanged += new NodeChangeHandler(ReferencedNodeChange);
     svgExternalResourcesRequired = new SvgExternalResourcesRequired(this);
     svgTests = new SvgTests(this);
 }
 public SvgPatternElement(string prefix, string localname, string ns, SvgDocument doc)
     : base(prefix, localname, ns, doc)
 {
     svgURIReference              = new SvgUriReference(this);
     svgExternalResourcesRequired = new SvgExternalResourcesRequired(this);
     svgFitToViewBox              = new SvgFitToViewBox(this);
     svgTests                     = new SvgTests(this);
 }
Beispiel #5
0
 internal SvgSvgElement(string prefix, string localname, string ns, SvgDocument doc)
     : base(prefix, localname, ns, doc)
 {
     svgExternalResourcesRequired = new SvgExternalResourcesRequired(this);
     svgFitToViewBox = new SvgFitToViewBox(this);
     svgTests = new SvgTests(this);
     currentTranslate = new SvgPoint(0, 0);
 }
        public void Render(SvgDocument docElement)
        {
            SvgSvgElement root = docElement.RootElement as SvgSvgElement;

            if (root != null)
            {
                this.Render(root);
            }
        }
Beispiel #7
0
 public void InitTest()
 {
     if(!initDone)
     {
         doc = LoadXml("<rect height='1' width='1' />");
         elm = (SvgElement)doc.SelectSingleNode("//*[local-name()='rect']");
         initDone = true;
     }
 }
        public void SetUp()
        {
            if(doc == null)
            {
                SvgWindow wnd = new SvgWindow(75, 75, null);
                doc = new SvgDocument(wnd);

                doc.Load(@"Renderer.Gdi\cssSelectors.svg");
            }
        }
Beispiel #9
0
 public void SetUp()
 {
     if(doc == null)
     {
         SvgWindow wnd = new SvgWindow(100, 100, null);
         doc = new SvgDocument(wnd);
         doc.Load("events_01.svg");
         rect = (SvgRectElement)doc.SelectSingleNode("//*[local-name()='rect']");
         g = (SvgGElement)doc.SelectSingleNode("//*[local-name()='g']");
     }
     eventStatus = 0;
 }
Beispiel #10
0
        public static SvgDocument GetXmlDoc(string content, string style)
        {
            SvgWindow wnd = new SvgWindow(100, 100, null);
            SvgDocument doc = new SvgDocument(wnd);

            string xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n";
            xml += "<svg xmlns='" + SvgDocument.SvgNamespace + "' xmlns:xlink='" + SvgDocument.XLinkNamespace + "'>";
            xml += "<style type='text/css'>" + style + "</style>";
            xml += content;
            xml += "</svg>";

            doc.LoadXml(xml);
            return doc;
        }
    public void TestDataImage()
    {
        string testData = "<?xml version='1.0'?>\n<svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'><image id='theImage' width='50' height='50' xlink:href='data:image/gif;base64,R0lGODdhMAAwAPAAAAAAAP///ywAAAAAMAAwAAAC8IyPqcvt3wCcDkiLc7C0qwyGHhSWpjQu5yqmCYsapyuvUUlvONmOZtfzgFzByTB10QgxOR0TqBQejhRNzOfkVJ+5YiUqrXF5Y5lKh/DeuNcP5yLWGsEbtLiOSpa/TPg7JpJHxyendzWTBfX0cxOnKPjgBzi4diinWGdkF8kjdfnycQZXZeYGejmJlZeGl9i2icVqaNVailT6F5iJ90m6mvuTS4OK05M0vDk0Q4XUtwvKOzrcd3iq9uisF81M1OIcR7lEewwcLp7tuNNkM3uNna3F2JQFo97Vriy/Xl4/f1cf5VWzXyym7PHhhx4dbgYKAAA7'/></svg>";
                SvgWindow wnd = new SvgWindow(50, 50, null);
                SvgDocument doc = new SvgDocument(wnd);
                doc.LoadXml(testData);

                SvgImageElement imgElm = doc.GetElementById("theImage") as SvgImageElement;
                Assert.IsNotNull(imgElm);
                Assert.IsTrue(!imgElm.IsSvgImage, "IsSvgImage");

                Bitmap bmp = imgElm.Bitmap;

                Assert.AreEqual(48, bmp.Width);
                Assert.AreEqual(48, bmp.Height);
    }
Beispiel #12
0
        public static PaintServer CreatePaintServer(SvgDocument document, string absoluteUri)
        {
            XmlNode node = document.GetNodeByUri(absoluteUri);

            if(node is SvgGradientElement)
            {
                return new GradientPaintServer((SvgGradientElement)node);
            }
            else if(node is SvgPatternElement)
            {
                return new PatternPaintServer((SvgPatternElement)node);
            }
            else
            {
                return null;
            }
        }
Beispiel #13
0
        public static WpfFill CreateFill(SvgDocument document, string absoluteUri)
        {
            XmlNode node = document.GetNodeByUri(absoluteUri);

            SvgGradientElement gradientNode = node as SvgGradientElement;
            if (gradientNode != null)
            {
                return new WpfGradientFill(gradientNode);
            }

            SvgPatternElement patternNode = node as SvgPatternElement;
            if (patternNode != null)
            {
                return new WpfPatternFill(patternNode);
            }

            return null;
        }
Beispiel #14
0
 internal SvgScriptElement(string prefix, string localname, string ns, SvgDocument doc) :
     base(prefix, localname, ns, doc)
 {
     svgURIReference = new SvgURIReference(this);
     svgExternalResourcesRequired = new SvgExternalResourcesRequired(this);
 }
 public SvgLinearGradientElement(string prefix, string localname, string ns, SvgDocument doc)
     : base(prefix, localname, ns, doc)
 {
 }
Beispiel #16
0
        private SvgDocument LoadXml(string content)
        {
            SvgWindow wnd = new SvgWindow(200, 300, null);
            SvgDocument doc = new SvgDocument(wnd);
            string xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.0//EN\" \"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd\">\n<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"100%\" height=\"100%\">";
            xml += content;
            xml += "</svg>";

            doc.LoadXml(xml);
            return doc;
        }
Beispiel #17
0
 internal SvgSymbolElement(string prefix, string localname, string ns, SvgDocument doc) : base(prefix, localname, ns, doc)
 {
     svgExternalResourcesRequired = new SvgExternalResourcesRequired(this);
     svgFitToViewBox = new SvgFitToViewBox(this);
 }
 protected SvgFilterPrimitiveStandardAttributes(string prefix, string localname, string ns, SvgDocument doc)
     : base(prefix, localname, ns, doc)
 {
 }
Beispiel #19
0
 internal SvgLinearGradientElement(string prefix, string localname, string ns, SvgDocument doc)
     : base(prefix, localname, ns, doc)
 {
 }
 public SvgPolygonElement(string prefix, string localname, string ns, SvgDocument doc)
     : base(prefix, localname, ns, doc)
 {
 }
 internal SvgTransformableElement(string prefix, string localname, string ns, SvgDocument doc)
     : base(prefix, localname, ns, doc)
 {
 }
 public SvgTRefElement(string prefix, string localname, string ns, SvgDocument doc)
     : base(prefix, localname, ns, doc)
 {
     svgURIReference = new SvgUriReference(this);
 }
Beispiel #23
0
 public SvgMetadataElement(string prefix, string localname, string ns, SvgDocument doc)
     : base(prefix, localname, ns, doc)
 {
 }
Beispiel #24
0
 public SvgTextPositioningElement(string prefix, string localname, string ns, SvgDocument doc)
     : base(prefix, localname, ns, doc)
 {
 }
 protected SvgTextContentElement(string prefix, string localname, string ns, SvgDocument doc)
     : base(prefix, localname, ns, doc)
 {
     _svgTests = new SvgTests(this);
     _externalResourcesRequired = new SvgExternalResourcesRequired(this);
 }
Beispiel #26
0
        public static XmlElement Create(string prefix, string localName, string ns, SvgDocument doc)
        {
            // This factory assumes the requested element is defined in the
            // http://www.w3.org/2000/svg namespace.
            if (string.IsNullOrWhiteSpace(ns) || !string.Equals(ns,
                                                                SvgDocument.SvgNamespace, StringComparison.OrdinalIgnoreCase))
            {
                return(null);
            }

            switch (localName)
            {
            case "a":
                return(new SvgAElement(prefix, localName, ns, doc));

            case "circle":
                return(new SvgCircleElement(prefix, localName, ns, doc));

            case "clipPath":
                return(new SvgClipPathElement(prefix, localName, ns, doc));

            case "defs":
                return(new SvgDefsElement(prefix, localName, ns, doc));

            case "desc":
                return(new SvgDescElement(prefix, localName, ns, doc));

            case "ellipse":
                return(new SvgEllipseElement(prefix, localName, ns, doc));

            case "g":
                return(new SvgGElement(prefix, localName, ns, doc));

            case "image":
                return(new SvgImageElement(prefix, localName, ns, doc));

            case "line":
                return(new SvgLineElement(prefix, localName, ns, doc));

            case "linearGradient":
                return(new SvgLinearGradientElement(prefix, localName, ns, doc));

            case "marker":
                return(new SvgMarkerElement(prefix, localName, ns, doc));

            case "mask":
                return(new SvgMaskElement(prefix, localName, ns, doc));

            case "metadata":
                return(new SvgMetadataElement(prefix, localName, ns, doc));

            case "rect":
                return(new SvgRectElement(prefix, localName, ns, doc));

            case "path":
                return(new SvgPathElement(prefix, localName, ns, doc));

            case "pattern":
                return(new SvgPatternElement(prefix, localName, ns, doc));

            case "polyline":
                return(new SvgPolylineElement(prefix, localName, ns, doc));

            case "polygon":
                return(new SvgPolygonElement(prefix, localName, ns, doc));

            case "radialGradient":
                return(new SvgRadialGradientElement(prefix, localName, ns, doc));

            case "script":
                return(new SvgScriptElement(prefix, localName, ns, doc));

            case "stop":
                return(new SvgStopElement(prefix, localName, ns, doc));

            case "svg":
                return(new SvgSvgElement(prefix, localName, ns, doc));

            case "switch":
                return(new SvgSwitchElement(prefix, localName, ns, doc));

            case "symbol":
                return(new SvgSymbolElement(prefix, localName, ns, doc));

            case "text":
                return(new SvgTextElement(prefix, localName, ns, doc));

            case "textArea":
                return(new SvgTextAreaElement(prefix, localName, ns, doc));

            case "textPath":
                return(new SvgTextPathElement(prefix, localName, ns, doc));

            case "title":
                return(new SvgTitleElement(prefix, localName, ns, doc));

            case "tref":
                return(new SvgTRefElement(prefix, localName, ns, doc));

            case "tspan":
                return(new SvgTSpanElement(prefix, localName, ns, doc));

            case "use":
                return(new SvgUseElement(prefix, localName, ns, doc));

            case "color-profile":
                return(new SvgColorProfileElement(prefix, localName, ns, doc));

            // SVG font support
            case "font":
                return(new SvgFontElement(prefix, localName, ns, doc));

            case "font-face":
                return(new SvgFontFaceElement(prefix, localName, ns, doc));

            case "font-face-format":
                return(new SvgFontFaceFormatElement(prefix, localName, ns, doc));

            case "font-face-name":
                return(new SvgFontFaceNameElement(prefix, localName, ns, doc));

            case "font-face-src":
                return(new SvgFontFaceSrcElement(prefix, localName, ns, doc));

            case "font-face-uri":
                return(new SvgFontFaceUriElement(prefix, localName, ns, doc));

            case "glyph":
                return(new SvgGlyphElement(prefix, localName, ns, doc));

            case "glyphRef":
                return(new SvgGlyphRefElement(prefix, localName, ns, doc));

            case "hkern":
                return(new SvgHKernElement(prefix, localName, ns, doc));

            case "missing-glyph":
                return(new SvgMissingGlyphElement(prefix, localName, ns, doc));

            case "vkern":
                return(new SvgVKernElement(prefix, localName, ns, doc));

            case "altGlyph":
                return(new SvgAltGlyphElement(prefix, localName, ns, doc));

            case "altGlyphDef":
                return(new SvgAltGlyphDefElement(prefix, localName, ns, doc));

            case "altGlyphItem":
                return(new SvgAltGlyphItemElement(prefix, localName, ns, doc));

            // Animation Support
            case "animate":
                return(new SvgAnimateElement(prefix, localName, ns, doc));

            case "set":
                return(new SvgAnimateSetElement(prefix, localName, ns, doc));

            case "animateMotion":
                return(new SvgAnimateMotionElement(prefix, localName, ns, doc));

            case "animateColor":
                return(new SvgAnimateColorElement(prefix, localName, ns, doc));

            case "animateTransform":
                return(new SvgAnimateTransformElement(prefix, localName, ns, doc));

            case "mpath":
                return(new SvgAnimateMPathElement(prefix, localName, ns, doc));
            }

            return(null);
        }
Beispiel #27
0
 public SvgPathElement(string prefix, string localname, string ns, SvgDocument doc)
     : base(prefix, localname, ns, doc)
 {
     _svgTests = new SvgTests(this);
 }
        private bool CompareImages(string svgFile)
        {
            svgFile = Path.Combine(baseDir, svgFile);
            CompareUtil util = new CompareUtil();

            SvgDocument doc = new SvgDocument(window);
            doc.Load(svgFile);

            return util.CompareImages(renderer.Render(doc), svgFile + ".png");
        }
 public SvgColorProfileElement(string prefix, string localname, string ns, SvgDocument doc)
     : base(prefix, localname, ns, doc)
 {
     _svgURIReference = new SvgUriReference(this);
 }
Beispiel #30
0
 public SvgAltGlyphElement(string prefix, string localname, string ns, SvgDocument doc)
     : base(prefix, localname, ns, doc)
 {
     _uriReference = new SvgUriReference(this);
 }
        /// <summary>
        /// Generates a new <see cref="RenderingNode">RenderingNode</see> that
        /// corresponds to the given Uri.
        /// </summary>
        /// <param name="baseUri">
        /// The base Uri.
        /// </param>
        /// <param name="url">
        /// The url.
        /// </param>
        /// <returns>
        /// The generated <see cref="RenderingNode">RenderingNode</see> that
        /// corresponds to the given Uri.
        /// </returns>
        public static GdiRendering CreateByUri(SvgDocument document, string baseUri, string url)
        {
            if (url.StartsWith("#"))
            {
                // do nothing
            }
            else if (baseUri != "")
            {
                Uri absoluteUri = new Uri(new Uri(baseUri), url);
                url = absoluteUri.AbsoluteUri;
            }
            else
            {
                // TODO: Handle xml:base here?
                // Right now just skip this... it can't be resolved, must assume it is absolute
            }
            ISvgElement elm = document.GetNodeByUri(url) as ISvgElement;

            if (elm != null)
            {
                return GdiRendering.Create(elm);
            }
            else
            {
                return null;
            }
        }
 public SvgAnimateMotionElement(string prefix, string localname, string ns, SvgDocument doc)
     : base(prefix, localname, ns, doc)
 {
 }
 public SvgFontFaceFormatElement(string prefix, string localname, string ns, SvgDocument doc)
     : base(prefix, localname, ns, doc)
 {
 }
Beispiel #34
0
 protected SvgKernElement(string prefix, string localname, string ns, SvgDocument doc)
     : base(prefix, localname, ns, doc)
 {
 }
 public SvgRadialGradientElement(string prefix, string localname, string ns, SvgDocument doc)
     : base(prefix, localname, ns, doc)
 {
 }
Beispiel #36
0
 public SvgFEDistantLightElement(string prefix, string localname, string ns, SvgDocument doc)
     : base(prefix, localname, ns, doc)
 {
 }
 internal SvgRadialGradientElement(string prefix, string localname, string ns, SvgDocument doc)
     : base(prefix, localname, ns, doc)
 {
 }
 public SvgScriptElement(string prefix, string localname, string ns, SvgDocument doc)
     : base(prefix, localname, ns, doc)
 {
     _uriReference = new SvgUriReference(this);
     _externalResourcesRequired = new SvgExternalResourcesRequired(this);
 }
 public SvgPolygonElement(string prefix, string localname, string ns, SvgDocument doc)
     : base(prefix, localname, ns, doc)
 {
 }
 public void TestLength()
 {
     SvgWindow wnd = new SvgWindow(100, 100, null);
     SvgDocument doc = new SvgDocument(wnd);
     Assert.AreEqual(61, doc.CssPropertyProfile.Length);
 }
 internal SvgPolylineElement(string prefix, string localname, string ns, SvgDocument doc)
     : base(prefix, localname, ns, doc)
 {
 }
Beispiel #42
0
        public void LoadDocument(Stream documentStream)
        {
            if (documentStream == null)
            {
                return;
            }

            SvgDocument document = new SvgDocument(this);
            if (_settings != null)
            {
                document.CustomSettings = _settings;
            }
            document.Load(documentStream);

            this.Document = document;
        }
 internal SvgStyleableElement(string prefix, string localname, string ns, SvgDocument doc)
     : base(prefix, localname, ns, doc)
 {
 }
Beispiel #44
0
 public SvgScriptElement(string prefix, string localname, string ns, SvgDocument doc)
     : base(prefix, localname, ns, doc)
 {
     svgURIReference = new SvgUriReference(this);
     svgExternalResourcesRequired = new SvgExternalResourcesRequired(this);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="SvgAltGlyphDefElement"/> class with the specified parameters.
 /// </summary>
 /// <param name="prefix"></param>
 /// <param name="localname"></param>
 /// <param name="ns"></param>
 /// <param name="doc"></param>
 public SvgAltGlyphDefElement(string prefix, string localname, string ns, SvgDocument doc)
     : base(prefix, localname, ns, doc)
 {
 }
Beispiel #46
0
 internal SvgTextElement(string prefix, string localname, string ns, SvgDocument doc) : base(prefix, localname, ns, doc)
 {
 }
Beispiel #47
0
 public SvgElement(string prefix, string localname, string ns, SvgDocument doc)
     : base(prefix, localname, ns, doc)
 {
     _uniqueId = Guid.NewGuid();
 }
 public SvgFEDiffuseLightingElement(string prefix, string localname, string ns, SvgDocument doc)
     : base(prefix, localname, ns, doc)
 {
 }
 internal SvgMarkerElement(string prefix, string localname, string ns, SvgDocument doc)
     : base(prefix, localname, ns, doc)
 {
     svgExternalResourcesRequired = new SvgExternalResourcesRequired(this);
     svgFitToViewBox = new SvgFitToViewBox(this);
 }
 protected SvgComponentTransferFunctionElement(string prefix, string localname, string ns, SvgDocument doc)
     : base(prefix, localname, ns, doc)
 {
 }
Beispiel #51
0
 internal SvgDefsElement(string prefix, string localname, string ns, SvgDocument doc) : base(prefix, localname, ns, doc)
 {
     svgExternalResourcesRequired = new SvgExternalResourcesRequired(this);
     svgTests = new SvgTests(this);
 }
Beispiel #52
0
 /// <summary>
 /// Create and assign an empty SvgDocument to this window.  This is needed only in situations where
 /// the library user needs to create an SVG DOM tree outside of the usual LoadSvgDocument mechanism.
 /// </summary>
 public SvgDocument CreateEmptySvgDocument()
 {
     return(_document = new SvgDocument(this));
 }
Beispiel #53
0
        public void LoadDocument(Uri documentUri)
        {
            if (documentUri == null || !documentUri.IsAbsoluteUri)
            {
                return;
            }

            SvgDocument document = new SvgDocument(this);
            if (_settings != null)
            {
                document.CustomSettings = _settings;
            }
            document.Load(documentUri.AbsoluteUri);

            this.Document = document;
        }
Beispiel #54
0
 public SvgMarkerElement(string prefix, string localname, string ns, SvgDocument doc)
     : base(prefix, localname, ns, doc)
 {
     _externalResourcesRequired = new SvgExternalResourcesRequired(this);
     _fitToViewBox = new SvgFitToViewBox(this);
 }
Beispiel #55
0
        public void LoadDocument(XmlReader xmlReader)
        {
            if (xmlReader == null)
            {
                return;
            }

            SvgDocument document = new SvgDocument(this);
            if (_settings != null)
            {
                document.CustomSettings = _settings;
            }
            document.Load(xmlReader);

            this.Document = document;
        }
Beispiel #56
0
 protected SvgStyleableElement(string prefix, string localname, string ns, SvgDocument doc)
     : base(prefix, localname, ns, doc)
 {
     _presentationAttributes = new Dictionary <string, ICssValue>(StringComparer.Ordinal);
 }
 public SvgDefsElement(string prefix, string localname, string ns, SvgDocument doc)
     : base(prefix, localname, ns, doc)
 {
     svgExternalResourcesRequired = new SvgExternalResourcesRequired(this);
     svgTests = new SvgTests(this);
 }
 public SvgFEFuncRElement(string prefix, string localname, string ns, SvgDocument doc)
     : base(prefix, localname, ns, doc)
 {
 }
Beispiel #59
0
 /// <summary>
 /// Create and assign an empty SvgDocument to this window.  This is needed only in situations where the library user needs to create an SVG DOM tree outside of the usual LoadSvgDocument mechanism.
 /// </summary>
 public SvgDocument CreateEmptySvgDocument()
 {
     return document = new SvgDocument(this);
 }
Beispiel #60
0
 public SvgEllipseElement(string prefix, string localname, string ns, SvgDocument doc)
     : base(prefix, localname, ns, doc)
 {
     _externalResourcesRequired = new SvgExternalResourcesRequired(this);
     _svgTests = new SvgTests(this);
 }