Summary for ImageMap. Example ImageMap
Inheritance: IContent, IContentContainer
Exemple #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();
		}
		/// <summary>
		/// Creates the image map.
		/// </summary>
		/// <param name="imageMapNode">The image map node.</param>
		/// <returns></returns>
		private ImageMap CreateImageMap(XmlNode imageMapNode)
		{
			try
			{
				ImageMap imageMap			= new ImageMap(this._document, imageMapNode);
				ContentCollection iCol		= new ContentCollection();

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

				imageMap.Node.InnerXml		= "";

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

				return imageMap;
			}
			catch(Exception ex)
			{
				throw new AODLException("Exception while trying to create a ImageMap.", ex);
			}
		}
		/// <summary>
		/// Gets the image map as HTML.
		/// </summary>
		/// <param name="imageMap">The image map.</param>
		/// <returns></returns>
		public string GetImageMapAsHtml(ImageMap imageMap)
		{
			string html					= "<div>\n<map name=\""+this._nextImageMapName+"\">\n";

			try
			{
				if (imageMap != null)
				{
					if (imageMap.Content != null)
					{
						html			+= this.GetIContentCollectionAsHtml(imageMap.Content);
					}
				}

				html					+= "</map>\n</div>\n";
			}
			catch(Exception ex)
			{
				throw new AODLException("Exception while trying to build a HTML string from a ImageMap object.", ex);
			}

			return html;
		}
		public void ImageMapTest()
		{
			TextDocument document			= new TextDocument();
			document.New();
			//Create standard paragraph
			Paragraph paragraphOuter		= ParagraphBuilder.CreateStandardTextParagraph(document);
			//Create the frame with graphic
			Frame frame						= new Frame(document, "frame1", "graphic1", _imagefile);
			//Create a Draw Area Rectangle
			DrawAreaRectangle drawAreaRec	= new DrawAreaRectangle(
				document, "0cm", "0cm", "1.5cm", "2.5cm", null);
			drawAreaRec.Href				= "http://OpenDocument4all.com";
			//Create a Draw Area Circle
			DrawAreaCircle drawAreaCircle	= new DrawAreaCircle(
				document, "4cm", "4cm", "1.5cm", null);
			drawAreaCircle.Href				= "http://AODL.OpenDocument4all.com";
			DrawArea[] drawArea				= new DrawArea[2] { drawAreaRec, drawAreaCircle };
			//Create a Image Map
			ImageMap imageMap				= new ImageMap(document, drawArea);
			//Add Image Map to the frame
			frame.Content.Add(imageMap);
			//Add frame to paragraph
			paragraphOuter.Content.Add(frame);
			//Add paragraph to document
			document.Content.Add(paragraphOuter);
			//Save the document
			document.SaveTo(AARunMeFirstAndOnce.outPutFolder+"simpleImageMap.odt");
		}
        /// <summary>
        /// Creates the image map.
        /// </summary>
        /// <param name="imageMapNode">The image map node.</param>
        /// <returns></returns>
        private ImageMap CreateImageMap(XmlNode imageMapNode)
        {
            try
            {
                ImageMap imageMap			= new ImageMap(this._document, imageMapNode);
                IContentCollection iCol		= new IContentCollection();

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

                imageMap.Node.InnerXml		= "";

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

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

                throw exception;
            }
        }
        /// <summary>
        /// Gets the image map as HTML.
        /// </summary>
        /// <param name="imageMap">The image map.</param>
        /// <returns></returns>
        public string GetImageMapAsHtml(ImageMap imageMap)
        {
            string html					= "<div>\n<map name=\""+this._nextImageMapName+"\">\n";

            try
            {
                if(imageMap != null)
                {
                    if(imageMap.Content != null)
                    {
                        html			+= this.GetIContentCollectionAsHtml(imageMap.Content);
                    }
                }

                html					+= "</map>\n</div>\n";
            }
            catch(Exception ex)
            {
                AODLException exception		= new AODLException("Exception while trying to build a HTML string from a ImageMap object.");
                exception.InMethod			= AODLException.GetExceptionSourceInfo(new StackFrame(1, true));
                exception.OriginalException	= ex;

                throw exception;
            }

            return html;
        }
Exemple #7
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);
            }
        }