Ejemplo n.º 1
0
        public void EventListenerTest()
        {
            TextDocument textdocument = new TextDocument();

            textdocument.New();

            // Create a frame (GraphicName == name property of frame)
            Frame frame = new Frame(textdocument, "frame1", "img1", new DiskFile(_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
            using (IPackageWriter writer = new OnDiskPackageWriter())
            {
                textdocument.Save(_framefile, new OpenDocumentTextExporter(writer));
            }
            textdocument.Dispose();
        }