DrawAreaRectangle represent draw area rectangle which could be used within a ImageMap.
Inheritance: DrawArea
 void Example3()
 {
     string imagePath = @"Assets\ODFSample\Examples\example3.png";
     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", imagePath);
     //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(@"example3_simpleImageMap.odt");
 }
Example #2
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 draw area rectangle.
		/// </summary>
		/// <param name="drawAreaRectangleNode">The draw area rectangle node.</param>
		/// <returns></returns>
		private DrawAreaRectangle CreateDrawAreaRectangle(XmlNode drawAreaRectangleNode)
		{
			try
			{
				DrawAreaRectangle dAreaRec	= new DrawAreaRectangle(this._document, drawAreaRectangleNode);
				ContentCollection iCol		= new ContentCollection();

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

				dAreaRec.Node.InnerXml		= "";

				foreach(IContent iContent in iCol)
					AddToCollection(iContent, dAreaRec.Content);

				//dAreaRec.Content.Add(iContent);

				return dAreaRec;
			}
			catch(Exception ex)
			{
				throw new AODLException("Exception while trying to create a DrawAreaRectangle.", ex);
			}
		}
Example #4
0
		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 draw area rectangle.
        /// </summary>
        /// <param name="drawAreaRectangleNode">The draw area rectangle node.</param>
        /// <returns></returns>
        private DrawAreaRectangle CreateDrawAreaRectangle(XmlNode drawAreaRectangleNode)
        {
            try
            {
                DrawAreaRectangle dAreaRec	= new DrawAreaRectangle(this._document, drawAreaRectangleNode);
                IContentCollection iCol		= new IContentCollection();

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

                dAreaRec.Node.InnerXml		= "";

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

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

                throw exception;
            }
        }
Example #6
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);
            }
        }