Hi,
The follwing code adds a text and image in the writer and te image will have
a hyper link

import com.sun.star.beans.*;
import com.sun.star.lang.*;
import com.sun.star.text.*;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.frame.XComponentLoader;

public class link extends java.lang.Object {
      public static void main(String[] args) throws java.lang.Exception {

   // get the Textdocument
   // get the Text document component
   com.sun.star.uno.XComponentContext xRemoteContext =
com.sun.star.comp.helper.Bootstrap.bootstrap();
           System.out.println("Connected to a running office ...");
           com.sun.star.lang.XMultiComponentFactory xRemoteServiceManager =
xRemoteContext.getServiceManager();

       // get the Desktop, we need its XComponentLoader interface to load a
new document
       Object desktop = xRemoteServiceManager.createInstanceWithContext(
           "com.sun.star.frame.Desktop", xRemoteContext);

      // query the XComponentLoader interface from the desktop
       XComponentLoader xComponentLoader =
(XComponentLoader)UnoRuntime.queryInterface(
           XComponentLoader.class, desktop);

       // create empty array of PropertyValue structs, needed for
loadComponentFromURL
       PropertyValue[] loadProps = new PropertyValue[0];

       // load new writer file
       XComponent xComponent = xComponentLoader.loadComponentFromURL(
           "private:factory/swriter", "_blank", 0, loadProps);

   XTextDocument xTextDocument = (XTextDocument)
       UnoRuntime.queryInterface(XTextDocument.class, xComponent);

   // get the document container
   XText xText = xTextDocument.getText();

   // Create a document cursor and remember it.
   XTextCursor curText = xText.createTextCursor();

   // Access the text document's multi service factory.
   XMultiServiceFactory mxDocFactory = (XMultiServiceFactory)
       UnoRuntime.queryInterface(XMultiServiceFactory.class,
xTextDocument);

   xText.insertString(curText, "Graphic Object", false);
       xText.insertControlCharacter(
           curText, ControlCharacter.PARAGRAPH_BREAK, false);

       // ------------------------------
   // create the GraphicObject and get the XTextContent interface

   Object oGraphicObject =
       mxDocFactory.createInstance ("com.sun.star.text.GraphicObject");

   XTextContent xGraphicContent = (XTextContent)
       UnoRuntime.queryInterface(XTextContent.class, oGraphicObject);

       // ------------------------------
   // set the graphic object property

   XPropertySet xGraphicProps = (XPropertySet)
       UnoRuntime.queryInterface(XPropertySet.class, xGraphicContent);

   // TextContent properties

   xGraphicProps.setPropertyValue(
       "AnchorType", TextContentAnchorType. AT_PARAGRAPH);

   // BaseFrame properties

   xGraphicProps.setPropertyValue("BackColor", new Integer(0x0000ff));
   xGraphicProps.setPropertyValue("BackTransparent", new Boolean(false));

       com.sun.star.awt.Size aSize = new com.sun.star.awt.Size();
       aSize.Height = 1800;
       aSize.Width = 1800;
   xGraphicProps.setPropertyValue("Size", aSize);

   xGraphicProps.setPropertyValue(
       "GraphicURL", "file:///opt/star.gif");
   xGraphicProps.setPropertyValue("AdjustLuminance", new Short((short)-5));
   xGraphicProps.setPropertyValue("Transparency", new Short((short) 20));
       xGraphicProps.setPropertyValue("HyperLinkURL", "
http://www.edurite.com";);
    xText.insertTextContent(curText, xGraphicContent, false);

   System.exit(0);
   }
}
I want to make the same thing in impress....how to do it a presentation? can
any one give me idea

Reply via email to