Exemple #1
0
        public void FrameWriteTest()
        {
            try
            {
                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();
            }
            catch (Exception ex)
            {
                //Console.Write(ex.Message);
            }
        }
Exemple #2
0
        public void CreateFreePositionGraphic()
        {
            TextDocument textdocument = new TextDocument();

            textdocument.New();
            Paragraph p     = ParagraphBuilder.CreateStandardTextParagraph(textdocument);
            Frame     frame = FrameBuilder.BuildStandardGraphicFrame(textdocument, "frame1",
                                                                     "graphic1", _imagefile);

            //Setps to set a graphic free with x and y
            frame.SvgX = "1.75cm";
            frame.SvgY = "1.75cm";
            ((FrameStyle)frame.Style).GraphicProperties.HorizontalPosition = "from-left";
            ((FrameStyle)frame.Style).GraphicProperties.VerticalPosition   = "from-top";
            ((FrameStyle)frame.Style).GraphicProperties.HorizontalRelative = "paragraph";
            ((FrameStyle)frame.Style).GraphicProperties.VerticalRelative   = "paragraph";
            p.Content.Add(frame);
            textdocument.Content.Add(p);
            textdocument.SaveTo(AARunMeFirstAndOnce.outPutFolder + "grapic_free_xy.odt");
        }