Package com.sun.star.frame

Examples of com.sun.star.frame.XComponentLoader


     
      /* A desktop environment contains tasks with one or more
         frames in which components can be loaded. Desktop is the
         environment for components which can instanciate within
         frames. */
      XComponentLoader xcomponentloader = ( XComponentLoader )
      UnoRuntime.queryInterface( XComponentLoader.class,
      xmulticomponentfactory.createInstanceWithContext(
      "com.sun.star.frame.Desktop", xcomponentcontext ) );

      java.io.File sourceFile = new java.io.File(args[0]);
      StringBuffer sLoadUrl = new StringBuffer("file:///");
      sLoadUrl.append(sourceFile.getCanonicalPath().replace('\\', '/'));

      sourceFile = new java.io.File(args[1]);
      StringBuffer sSaveUrl = new StringBuffer("file:///");
      sSaveUrl.append(sourceFile.getCanonicalPath().replace('\\', '/'));

      PropertyValue[] propertyvalue = new PropertyValue[ 1 ];
      propertyvalue[ 0 ] = new PropertyValue();
      propertyvalue[ 0 ].Name = "Hidden";
      propertyvalue[ 0 ].Value = new Boolean(true);
     
      Object objectDocumentToStore = xcomponentloader.loadComponentFromURL(
      sLoadUrl.toString(), "_blank", 0, propertyvalue );
      XStorable xstorable =
      ( XStorable ) UnoRuntime.queryInterface( XStorable.class,
      objectDocumentToStore );

View Full Code Here


        }

        // create a new spreadsheet document
        try
        {
            XComponentLoader aLoader = (XComponentLoader) UnoRuntime.queryInterface(
                XComponentLoader.class,
                maMSFactory.createInstance( "com.sun.star.frame.Desktop" ) );

            maSpreadsheetDoc = (XSpreadsheetDocument) UnoRuntime.queryInterface(
                XSpreadsheetDocument.class,
                aLoader.loadComponentFromURL( "private:factory/scalc",
                                              "_blank",
                                              0,
                                              new PropertyValue[ 0 ] ) );

            bOk = initSpreadsheet();
View Full Code Here

     
      /* A desktop environment contains tasks with one or more
         frames in which components can be loaded. Desktop is the
         environment for components which can instanciate within
         frames. */
      XComponentLoader xcomponentloader = ( XComponentLoader )
      UnoRuntime.queryInterface( XComponentLoader.class,
      xmulticomponentfactory.createInstanceWithContext(
      "com.sun.star.frame.Desktop", xcomponentcontext ) );
     
      // Load a Writer document, which will be automaticly displayed
      XComponent xcomponent = xcomponentloader.loadComponentFromURL(
      "private:factory/scalc", "_blank", 0,
      new PropertyValue[0] );
     
      // Querying for the interface XSpreadsheetDocument
      XSpreadsheetDocument xspreadsheetdocument =
View Full Code Here

     
      /* A desktop environment contains tasks with one or more
         frames in which components can be loaded. Desktop is the
         environment for components which can instanciate within
         frames. */
      XComponentLoader xcomponentloader = ( XComponentLoader )
      UnoRuntime.queryInterface( XComponentLoader.class,
      xmulticomponentfactory.createInstanceWithContext(
      "com.sun.star.frame.Desktop", xcomponentcontext ) );

      String sUrl = args[0];
      if ( sUrl.indexOf("private:") != 0) {
          java.io.File sourceFile = new java.io.File(args[0]);
          StringBuffer sTmp = new StringBuffer("file:///");
          sTmp.append(sourceFile.getCanonicalPath().replace('\\', '/'));
          sUrl = sTmp.toString();
      }   
     
      // Load a Writer document, which will be automaticly displayed
      XComponent xcomponent = xcomponentloader.loadComponentFromURL(
      sUrl, "_blank", 0,
      new PropertyValue[0] );
     
      System.exit(0);
    }
View Full Code Here

     
      /* A desktop environment contains tasks with one or more
         frames in which components can be loaded. Desktop is the
         environment for components which can instanciate within
         frames. */
      XComponentLoader xcomponentloader = ( XComponentLoader )
      UnoRuntime.queryInterface( XComponentLoader.class,
      xmulticomponentfactory.createInstanceWithContext(
      "com.sun.star.frame.Desktop", xcomponentcontext ) );

      java.io.File sourceFile = new java.io.File(args[1]);
      StringBuffer sUrl = new StringBuffer("file:///");
      sUrl.append(sourceFile.getCanonicalPath().replace('\\', '/'));
     
      // Load a Writer document, which will be automaticly displayed
      XComponent xcomponent = xcomponentloader.loadComponentFromURL(
      sUrl.toString(), "_blank", 0,
      new PropertyValue[0] );
     
      // Querying for the interface XPrintable on the loaded document
      XPrintable xprintable =
View Full Code Here

        // get the remote service manager
        mxRemoteServiceManager = this.getRemoteServiceManager(unoUrl);
        // retrieve the Desktop object, we need its XComponentLoader
        Object desktop = mxRemoteServiceManager.createInstanceWithContext(
            "com.sun.star.frame.Desktop", mxRemoteContext);
        XComponentLoader xComponentLoader = (XComponentLoader)UnoRuntime.queryInterface(
            XComponentLoader.class, desktop);
        PropertyValue[] loadProps = new PropertyValue[0];

        java.io.File sourceFile = new java.io.File("PrintDemo.sxw");
        StringBuffer sLoadFileUrl = new StringBuffer("file:///");
        sLoadFileUrl.append(sourceFile.getCanonicalPath().replace('\\', '/'));
       
        XComponent xDoc = xComponentLoader.loadComponentFromURL(sLoadFileUrl.toString(), "_blank",
                                                                0, loadProps);

        if ( xDoc != null ) {
            sourceFile = new java.io.File("somepopularfileformat.doc");
            StringBuffer sStoreFileUrl = new StringBuffer("file:///");
View Full Code Here

    protected XComponent newDocComponent(String docType) throws java.lang.Exception {
        String loadUrl = "private:factory/" + docType;
        mxRemoteServiceManager = this.getRemoteServiceManager(unoUrl);
        Object desktop = mxRemoteServiceManager.createInstanceWithContext(
            "com.sun.star.frame.Desktop", mxRemoteContext);
        XComponentLoader xComponentLoader = (XComponentLoader)UnoRuntime.queryInterface(
            XComponentLoader.class, desktop);
        PropertyValue[] loadProps = new PropertyValue[0];
        return xComponentLoader.loadComponentFromURL(loadUrl, "_blank", 0, loadProps);   
    }
View Full Code Here

        // get the remote service manager
        mxRemoteServiceManager = this.getRemoteServiceManager(unoUrl);
        // retrieve the Desktop object, we need its XComponentLoader
        Object desktop = mxRemoteServiceManager.createInstanceWithContext(
            "com.sun.star.frame.Desktop", mxRemoteContext);
        XComponentLoader xComponentLoader = (XComponentLoader)UnoRuntime.queryInterface(
            XComponentLoader.class, desktop);
       
        // define load properties according to com.sun.star.document.MediaDescriptor
        // the boolean property AsTemplate tells the office to create a new document
        // from the given file
        PropertyValue[] loadProps = new PropertyValue[1];
        loadProps[0] = new PropertyValue();
        loadProps[0].Name = "AsTemplate";
        loadProps[0].Value = new Boolean(true);      
        // load
        return xComponentLoader.loadComponentFromURL(loadUrl, "_blank", 0, loadProps);          
    }
View Full Code Here

    public XModel createDocument( String sDocType )
    {
        XModel aResult = null;
        try
        {
            XComponentLoader aLoader = (XComponentLoader) UnoRuntime.queryInterface(
                XComponentLoader.class,
                maMSFactory.createInstance( "com.sun.star.frame.Desktop" ) );

            aResult = (XModel) UnoRuntime.queryInterface(
                XModel.class,
                aLoader.loadComponentFromURL( "private:factory/" + sDocType,
                                              "_blank",
                                              0,
                                              new PropertyValue[ 0 ] ) );
        }
        catch( Exception ex )
View Full Code Here

                            if ( event.getKeyCode() == KeyEvent.VK_F1 ) {
                                //  function key F1 pressed
                               
                                XInterface oInterface;
                                XDesktop oDesktop;
                                XComponentLoader oCLoader;
                                XComponent aDoc = null;
                                String stringParentNode = "";
                                String stringURLDocument = "";
                               
                                //  Path to the selected node
                                TreePath treePath = tree.getSelectionPath();
                               
                                //  get the parent node
                                if ( treePath.getParentPath() != null ) {
                                    stringParentNode = treePath.getParentPath().getLastPathComponent().toString();
                                }
                               
                                //  get the stored object
                                Object object = hashtableObjects.get( treePath.toString() );
                               
                                //  set the context dependend part of the URL path for the documentation
                                if ( treePath.getPathCount() % 2 <= 0 ) {
                                    //  Category is selected
                                    stringParentNode = treePath.getParentPath().getLastPathComponent().toString();
                                    int intBegin = stringParentNode.indexOf( " = (" ) + 4;
                                    int intEnd = stringParentNode.indexOf( ")" );
                                    stringURLDocument = stringParentNode.substring( intBegin, intEnd ).replace( '.', '/' ) + ".html";
                                }
                                else if ( object != null ) {
                                    //  Complex property selected
                                    String stringNode = treePath.getLastPathComponent().toString();
                                    int intBegin = stringNode.indexOf( " = (" ) + 4;
                                    int intEnd = stringNode.indexOf( ")" );
                                    stringURLDocument = stringNode.substring( intBegin, intEnd ).replace( '.', '/' ) + ".html";
                                }
                                else if ( stringParentNode.equals( "Methods" ) ) {
                                    //  Method selected
                                    String stringNode = treePath.getLastPathComponent().toString();
                                    int intBegin = stringNode.indexOf( " " ) + 1;
                                    int intEnd = stringNode.indexOf( " (" );
                                    String stringMethod = stringNode.substring( intBegin, intEnd );
                                   
                                    Object objectGrandParent = hashtableObjects.get( treePath.getParentPath().getParentPath().toString() );
                                    XIntrospectionAccess xIntrospectionAccess = xIntrospection.inspect( objectGrandParent );
                                    XIdlMethod xIdlMethod = xIntrospectionAccess.getMethod( stringMethod, com.sun.star.beans.MethodConcept.ALL );
                                    String stringDeclaringClass = xIdlMethod.getDeclaringClass().getName().replace( '.', '/' );
                                   
                                    stringURLDocument = stringDeclaringClass + ".html#" + stringMethod;
                                }
                                else if ( ( stringParentNode.equals( "Services" )
                                || ( stringParentNode.equals( "Interfaces" ) ) ) ) {
                                    //  Service or interface selected
                                    stringURLDocument = treePath.getLastPathComponent().toString().replace( '.', '/' ) + ".html";
                                }
                                else if ( ( (DefaultMutableTreeNode) treePath.getLastPathComponent() ).getChildCount() == 0 ) {
                                    //  Simple property selected
                                    String stringGrandParentNode = treePath.getParentPath().getParentPath().getLastPathComponent().toString();
                                    int intBegin = stringGrandParentNode.indexOf( " = (" ) + 4;
                                    int intEnd = stringGrandParentNode.indexOf( ")" );
                                    stringURLDocument = stringGrandParentNode.substring( intBegin, intEnd ).replace( '.', '/' ) + ".html";
                                }
                               
                                //  get the component loader
                                oInterface = (XInterface) xmulticomponentfactory.createInstanceWithContext( "com.sun.star.frame.Desktop", xcomponentcontext );
                                oDesktop = ( XDesktop ) UnoRuntime.queryInterface( XDesktop.class,
                                oInterface );
                                oCLoader = ( XComponentLoader ) UnoRuntime.queryInterface( XComponentLoader.class, oDesktop );
                                PropertyValue [] szEmptyArgs = new PropertyValue [0];
                               
                                //  open a HTML document from OpenOffice.org
                                aDoc = oCLoader.loadComponentFromURL("http://api.openoffice.org/common/ref/" + stringURLDocument,
                                "_blank", 0, szEmptyArgs );
                            }
                        }
                        catch ( Exception exception ) {
                            System.err.println( exception );
View Full Code Here

TOP

Related Classes of com.sun.star.frame.XComponentLoader

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.