Summary for EventListeners
Inheritance: IContent, IContentContainer, ICloneable
Example #1
0
		public void FrameWriteTest()
		{
			TextDocument textdocument = new TextDocument();
			textdocument.New();

			// Create a frame incl. graphic file
			Frame frame					= FrameBuilder.BuildStandardGraphicFrame(
				textdocument, "frame1", "graphic1", _imagefile);
			
			// Create some event listeners (using OpenOffice friendly syntax).
			EventListener script1 = new EventListener(textdocument,
			                                          "dom:mouseover", "javascript",
			                                          "vnd.sun.star.script:HelloWorld.helloworld.js?language=JavaScript&location=share");
			EventListener script2 = new EventListener(textdocument,
			                                          "dom:mouseout", "javascript",
			                                          "vnd.sun.star.script:HelloWorld.helloworld.js?language=JavaScript&location=share");
			EventListeners listeners = new EventListeners(textdocument, new EventListener[] { script1, script2 });
			
			// Create and add some area rectangles
			DrawAreaRectangle[] rects = new DrawAreaRectangle[2];
			rects[0] = new DrawAreaRectangle(textdocument, "4cm", "4cm", "2cm", "2cm");
			rects[0].Href = @"http://www.eduworks.com";
			rects[1] = new DrawAreaRectangle(textdocument, "1cm", "1cm", "2cm", "2cm", listeners);

			// Create and add an image map, referencing the area rectangles
			ImageMap map = new ImageMap(textdocument, rects);
			frame.Content.Add(map);

			// Add the frame to the text document
			textdocument.Content.Add(frame);

			// Save the document
			textdocument.SaveTo(_framefile3);
			textdocument.Dispose();
		}
Example #2
0
        /// <summary>
        /// Create a deep clone of this EventListeners object.
        /// </summary>
        /// <remarks>A possible Attached Style wouldn't be cloned!</remarks>
        /// <returns>
        /// A clone of this object.
        /// </returns>
        public object Clone()
        {
            EventListeners eventListenersClone = null;

            if (this.Document != null && this.Node != null)
            {
                MainContentProcessor mcp = new MainContentProcessor(this.Document);
                eventListenersClone = mcp.CreateEventListeners(this.Node.CloneNode(true));
            }

            return(eventListenersClone);
        }
Example #3
0
        /// <summary>
        /// Create a deep clone of this EventListeners object.
        /// </summary>
        /// <remarks>A possible Attached Style wouldn't be cloned!</remarks>
        /// <returns>
        /// A clone of this object.
        /// </returns>
        public object Clone()
        {
            EventListeners eventListenersClone = null;

            if (Document != null && Node != null)
            {
                MainContentProcessor mcp = new MainContentProcessor(Document);
                eventListenersClone = mcp.CreateEventListeners(new XElement(Node));
            }

            return(eventListenersClone);
        }
		/// <summary>
		/// Initializes a new instance of the <see cref="DrawAreaRectangle"/> class.
		/// </summary>
		/// <param name="document">The document.</param>
		/// <param name="x">The x.</param>
		/// <param name="y">The y.</param>
		/// <param name="width">The width.</param>
		/// <param name="height">The height.</param>
		/// <param name="listeners">The listeners.</param>
		public DrawAreaRectangle(IDocument document,
			string x, string y, string width, string height,
			EventListeners listeners)
			: base(document)
		{
			this.X = x;
			this.Y = y;
			this.Width = width;
			this.Height = height;

			if (listeners != null)
			{
				this.Content.Add(listeners);
			}
		}
		/// <summary>
		/// Initializes a new instance of the <see cref="DrawAreaCircle"/> class.
		/// </summary>
		/// <param name="document">The document.</param>
		/// <param name="cx">The cx.</param>
		/// <param name="cy">The cy.</param>
		/// <param name="radius">The radius.</param>
		/// <param name="listeners">The listeners.</param>
		public DrawAreaCircle(IDocument document,
			string cx, string cy, string radius, EventListeners listeners)
			: base(document)
		{
			this.CX = cx;
			this.CY = cy;
			this.Radius = radius;

			if (listeners != null)
			{
				this.Content.Add(listeners);
			}
		}
		/// <summary>
		/// Creates the event listeners.
		/// </summary>
		/// <param name="eventListenersNode">The event listeners node.</param>
		/// <returns></returns>
		public EventListeners CreateEventListeners(XmlNode eventListenersNode)
		{
			try
			{
				EventListeners eventList	= new EventListeners(this._document, eventListenersNode);
				ContentCollection iCol		= new ContentCollection();

				if (eventList.Node != null)
					foreach(XmlNode nodeChild in eventList.Node.ChildNodes)
				{
					IContent iContent	= this.CreateContent(nodeChild);
					if (iContent != null)
						AddToCollection(iContent,iCol);
					//iCol.Add(iContent);
				}

				eventList.Node.InnerXml		= "";

				foreach(IContent iContent in iCol)
					AddToCollection(iContent, eventList.Content);
				//eventList.Content.Add(iContent);

				return eventList;
			}
			catch(Exception ex)
			{
				throw new AODLException("Exception while trying to create a ImageMap.", ex);
			}
		}
        /// <summary>
        /// Creates the event listeners.
        /// </summary>
        /// <param name="eventListenersNode">The event listeners node.</param>
        /// <returns></returns>
        public EventListeners CreateEventListeners(XmlNode eventListenersNode)
        {
            try
            {
                EventListeners eventList	= new EventListeners(this._document, eventListenersNode);
                IContentCollection iCol		= new IContentCollection();

                if(eventList.Node != null)
                    foreach(XmlNode nodeChild in eventList.Node.ChildNodes)
                    {
                        IContent iContent	= this.CreateContent(nodeChild);
                        if(iContent != null)
                            iCol.Add(iContent);
                    }

                eventList.Node.InnerXml		= "";

                foreach(IContent iContent in iCol)
                    eventList.Content.Add(iContent);

                return eventList;
            }
            catch(Exception ex)
            {
                AODLException exception		= new AODLException("Exception while trying to create a ImageMap.");
                exception.InMethod			= AODLException.GetExceptionSourceInfo(new StackFrame(1, true));
                exception.Node				= eventListenersNode;
                exception.OriginalException	= ex;

                throw exception;
            }
        }
Example #8
0
        public void EventListenerTest()
        {
            try
            {
                TextDocument textdocument = new TextDocument();
                textdocument.New();

                // Create a frame (GraphicName == name property of frame)
                Frame frame						= new Frame(textdocument, "frame1", "img1", _imagefile);

                // Create some event listeners (using OpenOffice friendly syntax).
                EventListener script1 = new EventListener(textdocument,
                    "dom:mouseover", "javascript",
                    "vnd.sun.star.script:HelloWorld.helloworld.js?language=JavaScript&location=share");
                EventListener script2 = new EventListener(textdocument,
                    "dom:mouseout", "javascript",
                    "vnd.sun.star.script:HelloWorld.helloworld.js?language=JavaScript&location=share");
                EventListeners listeners = new EventListeners(textdocument, new EventListener[] { script1, script2 });

                // Create and add some area rectangles; reuse event listeners
                DrawAreaRectangle[] rects = new DrawAreaRectangle[2];
                rects[0] = new DrawAreaRectangle(textdocument, "4cm", "4cm", "2cm", "2cm", listeners);
                //Reuse a clone of the EventListener
                rects[1] = new DrawAreaRectangle(textdocument, "1cm", "1cm", "2cm", "2cm", (EventListeners)listeners.Clone());

                // Create and add an image map, referencing the area rectangles
                ImageMap map = new ImageMap(textdocument, rects);
                frame.Content.Add(map);

                // Add the frame to the text document
                textdocument.Content.Add(frame);

                // Save the document
                textdocument.SaveTo(_framefile);
                textdocument.Dispose();
            }
            catch (Exception ex)
            {
                //Console.Write(ex.Message);
            }
        }