Package com.sun.star.frame

Examples of com.sun.star.frame.XComponentLoader


      rText.insertString(rRange , string, false);
    }
  }

  static void testDocument(XMultiServiceFactory rSmgr) throws com.sun.star.uno.Exception, IOException {
    XComponentLoader rLoader = UnoRuntime.queryInterface(XComponentLoader.class, rSmgr.createInstance("com.sun.star.frame.Desktop"));

    String urls[] = new String[] {
      "private:factory/swriter",
      "private:factory/scalc",
      "private:factory/sdraw",
      "http://www.heise.de",
    };

    String docu[] = new String[] {
      "a new writer document ...\n",
      "a new calc document ...\n",
      "a new draw document ...\n",
      "www.heise.de\n",
    };

    for(int i = 0; i < urls.length; ++ i)  {
      System.err.println("press any key to open "  + docu[i]);

      System.in.read();
      while(System.in.available() > 0)
        System.in.read();

      XComponent rComponent = rLoader.loadComponentFromURL(urls[i], "_blank"0, new PropertyValue[0]);

//          testWriter(rComponent);
      System.err.println("press any key to close the document");
      System.in.read();
      while(System.in.available() > 0)
View Full Code Here


    {
        final CRMDatabase database = new CRMDatabase( getORB() );

        // load the document
        String docURL = database.getDatabase().getDocumentURL();
        final XComponentLoader loader = (XComponentLoader)UnoRuntime.queryInterface( XComponentLoader.class,
            getORB().createInstance( "com.sun.star.frame.Desktop" ) );
        XModel doc = (XModel)UnoRuntime.queryInterface( XModel.class,
            loader.loadComponentFromURL( docURL, "_blank", 0, new PropertyValue[] {} ) );

        // establish the connection
        XDatabaseDocumentUI docUI = (XDatabaseDocumentUI)UnoRuntime.queryInterface( XDatabaseDocumentUI.class,
            doc.getCurrentController() );
        docUI.connect();

        // display the table
        XComponent tableViewComp = docUI.loadComponent( com.sun.star.sdb.application.DatabaseObject.TABLE, "customers", false );
        XFormController tableViewController = (XFormController)UnoRuntime.queryInterface( XFormController.class,
            tableViewComp );
        XPropertySet tableControlModel = (XPropertySet)UnoRuntime.queryInterface( XPropertySet.class,
            tableViewController.getCurrentControl().getModel() );

        // change the table's formatting
        tableControlModel.setPropertyValue( "FontName", "Andale Sans UI" );
        tableControlModel.setPropertyValue( "FontHeight", Float.valueOf( 20 ) );
        tableControlModel.setPropertyValue( "FontSlant", FontSlant.ITALIC );

        // close the table
        docUI.closeSubComponents();

        // save and close the database document
        database.getDatabase().store();
        database.close();

        // load a copy of the document
        // normally, it should be sufficient to load the same doc. However, there might be objects in the Java VM
        // which are not yet freed, and which effectively hold the document alive. More precise: The document (|doc|)
        // is certainly disposed, but other objects might hold a reference to one of the many other components
        // around the database document, the data source, the connection, etc. As long as those objects are
        // not cleaned up, the "database model impl" - the structure holding all document data - will
        // stay alive, and subsequent requests to load the doc will just reuse it, without really loading it.
        docURL = copyToTempFile( docURL );
        doc = (XModel)UnoRuntime.queryInterface( XModel.class,
            loader.loadComponentFromURL( docURL, "_blank", 0, new PropertyValue[] {} ) );

        docUI = (XDatabaseDocumentUI)UnoRuntime.queryInterface( XDatabaseDocumentUI.class,
            doc.getCurrentController() );
        docUI.connect();
View Full Code Here

    PropertyValue[] properties = new PropertyValue[props.size()];
    props.toArray(properties);

    // query the desktop object for the XComponentLoader
    XComponentLoader xCLoader = (XComponentLoader)(UnoRuntime.queryInterface (XComponentLoader.class, oDesktop));
    if (templateUri != null) {
      // Create a new document that is a duplicate of the template.
      myDocument = xCLoader.loadComponentFromURL (templateUri, "_blank", 0, properties);
    }
    else {
      myDocument = xCLoader.loadComponentFromURL ("private:factory/" + docType, "_blank", 0, properties);
    }
    return (myDocument != null);
  }
View Full Code Here

    // create a new instance of the the desktop
    Object oDesktop = xMCF.createInstanceWithContext("com.sun.star.frame.Desktop", getConnection ().getComponentContext ());

    // query the desktop object for the XComponentLoader
    XComponentLoader xCLoader = (XComponentLoader)(UnoRuntime.queryInterface (XComponentLoader.class, oDesktop));

    PropertyValue [] szEmptyArgs = new PropertyValue [0];
    myDocument = xCLoader.loadComponentFromURL (uri, "_blank", 0, szEmptyArgs);
    return (myDocument != null);
  }
View Full Code Here

    */
    public static XComponentLoader getCLoader(XMultiServiceFactory xMSF) {
        XDesktop oDesktop = (XDesktop) UnoRuntime.queryInterface(
                                    XDesktop.class, createDesktop(xMSF));

        XComponentLoader oCLoader = (XComponentLoader) UnoRuntime.queryInterface(
                                            XComponentLoader.class, oDesktop);

        return oCLoader;
    } // finish getCLoader
View Full Code Here

           environment for components which can instanciate within
           frames. */

        Object desktopObj = xmulticomponentfactory.createInstanceWithContext("com.sun.star.frame.Desktop", xcomponentcontext);
        //XDesktop desktop = (XDesktop) UnoRuntime.queryInterface(XDesktop.class, desktopObj);
        XComponentLoader xcomponentloader = (XComponentLoader) UnoRuntime.queryInterface(XComponentLoader.class, desktopObj);


        // Preparing properties for loading the document
        PropertyValue propertyvalue[] = new PropertyValue[ 2 ];
        // Setting the flag for hidding the open document
        propertyvalue[ 0 ] = new PropertyValue();
        propertyvalue[ 0 ].Name = "Hidden";
        propertyvalue[ 0 ].Value = Boolean.valueOf(false);

        propertyvalue[ 1 ] = new PropertyValue();
        propertyvalue[ 1 ].Name = "UpdateDocMode";
        propertyvalue[ 1 ].Value = "1";

        // Loading the wanted document
        String stringUrl = convertToUrl(fileInPath, xcomponentcontext);
        Debug.logInfo("stringUrl:" + stringUrl, module);
        Object objectDocumentToStore = xcomponentloader.loadComponentFromURL(stringUrl, "_blank", 0, propertyvalue);

        // Getting an object that will offer a simple way to store a document to a URL.
        XStorable xstorable = (XStorable) UnoRuntime.queryInterface(XStorable.class, objectDocumentToStore);

        // Preparing properties for converting the document
View Full Code Here

           environment for components which can instanciate within
           frames. */

        Object desktopObj = xmulticomponentfactory.createInstanceWithContext("com.sun.star.frame.Desktop", xcomponentcontext);
        //XDesktop desktop = (XDesktop) UnoRuntime.queryInterface(XDesktop.class, desktopObj);
        XComponentLoader xcomponentloader = (XComponentLoader) UnoRuntime.queryInterface(XComponentLoader.class, desktopObj);

        // Preparing properties for loading the document
        PropertyValue propertyvalue[] = new PropertyValue[2];
        // Setting the flag for hidding the open document
        propertyvalue[0] = new PropertyValue();
        propertyvalue[0].Name = "Hidden";
        propertyvalue[0].Value = Boolean.TRUE;
        //
        propertyvalue[1] = new PropertyValue();
        propertyvalue[1].Name = "InputStream";
        propertyvalue[1].Value = is;

        // Loading the wanted document
        Object objectDocumentToStore = xcomponentloader.loadComponentFromURL("private:stream", "_blank", 0, propertyvalue);
        if (objectDocumentToStore == null) {
            Debug.logError("Could not get objectDocumentToStore object from xcomponentloader.loadComponentFromURL", module);
        }

        // Getting an object that will offer a simple way to store a document to a URL.
View Full Code Here

               environment for components which can instanciate within
               frames. */

            Object desktopObj = xmulticomponentfactory.createInstanceWithContext("com.sun.star.frame.Desktop", xcomponentcontext);
            XDesktop desktop = (XDesktop) UnoRuntime.queryInterface(XDesktop.class, desktopObj);
            XComponentLoader xcomponentloader = (XComponentLoader) UnoRuntime.queryInterface(XComponentLoader.class, desktopObj);


            // Preparing properties for loading the document
            PropertyValue propertyvalue[] = new PropertyValue[ 1 ];
            // Setting the flag for hidding the open document
            propertyvalue[ 0 ] = new PropertyValue();
            propertyvalue[ 0 ].Name = "Hidden";
            propertyvalue[ 0 ].Value = Boolean.valueOf(true);
            //TODO: Hardcoding opening word documents -- this will need to change.
            //propertyvalue[ 1 ] = new PropertyValue();
            //propertyvalue[ 1 ].Name = "FilterName";
            //propertyvalue[ 1 ].Value = "HTML (StarWriter)";

            // Loading the wanted document
            Object objectDocumentToStore = xcomponentloader.loadComponentFromURL(stringUrl, "_blank", 0, propertyvalue);

            // Getting an object that will offer a simple way to store a document to a URL.
            XStorable xstorable = (XStorable) UnoRuntime.queryInterface(XStorable.class, objectDocumentToStore);

            // Preparing properties for comparing the document
View Full Code Here

    /** Creates an empty spreadsheet document.
        @return  The XSpreadsheetDocument interface of the document. */
    private com.sun.star.sheet.XSpreadsheetDocument initDocument()
            throws RuntimeException, Exception
    {
        XComponentLoader aLoader = (XComponentLoader)
            UnoRuntime.queryInterface(
                XComponentLoader.class,
                mxMSFactory.createInstance( "com.sun.star.frame.Desktop" ) );

        XComponent xComponent = aLoader.loadComponentFromURL(
            "private:factory/scalc", "_blank", 0, new com.sun.star.beans.PropertyValue[0] );

        return (com.sun.star.sheet.XSpreadsheetDocument)
            UnoRuntime.queryInterface( com.sun.star.sheet.XSpreadsheetDocument.class, xComponent );
    }
View Full Code Here

       
       
        //define variables
        XInterface oInterface;
        XDesktop oDesktop;
        XComponentLoader oCLoader;
        XComponent aDoc = null;
       
        try {
           
            oInterface = (XInterface) oMSF.createInstance( "com.sun.star.frame.Desktop" );
            oDesktop = ( XDesktop ) UnoRuntime.queryInterface( XDesktop.class, oInterface );
            oCLoader = ( XComponentLoader ) UnoRuntime.queryInterface( XComponentLoader.class, oDesktop );
            PropertyValue [] szEmptyArgs = new PropertyValue [0];
            String doc = "private:factory/sdraw";
            aDoc = oCLoader.loadComponentFromURL(doc, "_blank", 0, szEmptyArgs );
           
        } // end of try
       
        catch(Exception e){
           
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.