Package com.sun.star.lang

Examples of com.sun.star.lang.XMultiComponentFactory


            XTextDocument xTextDoc = (XTextDocument)UnoRuntime.queryInterface(XTextDocument.class,
                    xFrame.getController().getModel());

            myLogger.log(
                    Level.FINE, "xTextDoc "+xTextDoc);
            XMultiComponentFactory xServiceManager =
                    m_xContext.getServiceManager();

            /* create expression, select expression and move focus to the
             formula edit field */
            if ( aURL.Path.compareTo("CreateExpression") == 0 ){
                /* This is just a button for "insert - object - formula "*/
                XDispatchProvider xDP =
                        (XDispatchProvider)UnoRuntime.queryInterface(
                        XDispatchProvider.class, xFrame);
                XURLTransformer xParser =
                        (XURLTransformer) UnoRuntime.queryInterface(
                        XURLTransformer.class,
                        xServiceManager.createInstanceWithContext(
                        "com.sun.star.util.URLTransformer",m_xContext));
                com.sun.star.util.URL[] aParseURL = new com.sun.star.util.URL[1];
                aParseURL[0] = new com.sun.star.util.URL();
                aParseURL[0].Complete = ".uno:InsertObjectStarMath";
                xParser.parseStrict (aParseURL);
View Full Code Here


                nv[0].Value = text;
                ControlCommand cc = new ControlCommand();
                cc.Command = "SetText";
                cc.Arguments = nv;
                /* send dispatch to frame */
                XMultiComponentFactory xServiceManager = m_xContext.getServiceManager();
                XURLTransformer xParser = (XURLTransformer) UnoRuntime.queryInterface(
                            XURLTransformer.class,
                            xServiceManager.createInstanceWithContext(
                            "com.sun.star.util.URLTransformer",m_xContext));
                URL[] aParseURL = new URL[1];
                aParseURL[0] = new URL();
                aParseURL[0].Complete = "com.CompPad.addon:editExprField";
                xParser.parseStrict(aParseURL);
View Full Code Here

        ((XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xc)).setPropertyValue("Formula",formulaText);
    }
    /* Get current frame from context */
    private static XFrame getFrameFromContext(XComponentContext xContext) throws java.lang.Exception{
            XTextDocument xTextDoc=null;
            XMultiComponentFactory xServiceManager =
                    xContext.getServiceManager();
            Object odesktop = xServiceManager.createInstanceWithContext(
                    "com.sun.star.frame.Desktop", xContext);
            XDesktop xDesktop = (XDesktop) UnoRuntime.queryInterface(
                    XDesktop.class, odesktop);
            // get the XDesktop interface
            return xDesktop.getCurrentFrame();
View Full Code Here

    try {

      // get the remote office component context
      XComponentContext xContext = Bootstrap.bootstrap();
      logger.trace("Bootstrap OK");
      XMultiComponentFactory xMCF = xContext.getServiceManager();
      logger.trace("ServiceManager OK");
      Object desktop = xMCF.createInstanceWithContext(
          "com.sun.star.frame.Desktop", xContext);
      XComponentLoader loader = unoCast(XComponentLoader.class, desktop);

      String internalLocation = getSupportedLocation(location, xContext);
      // internalLocation = correctLocation;
View Full Code Here

     */
    public static Map<String, Object> convertDocumentByteBuffer(DispatchContext dctx, Map<String, ? extends Object> context) {

        Map results = ServiceUtil.returnSuccess();
        GenericDelegator delegator = dctx.getDelegator();
        XMultiComponentFactory xmulticomponentfactory = null;
        //String uniqueSeqNum = delegator.getNextSeqId("OOTempDir");
        Timestamp ts = UtilDateTime.nowTimestamp();
        Random random = new Random(ts.getTime());
        String uniqueSeqNum = Integer.toString(Math.abs(random.nextInt()));
        String fileInName = "OOIN_" + uniqueSeqNum;
View Full Code Here

    /**
     * Use OpenOffice to convert documents between types
     */
    public static Map<String, Object> convertDocument(DispatchContext dctx, Map<String, ? extends Object> context) {
        XMultiComponentFactory xmulticomponentfactory = null;

        String stringUrl = "file:///" + context.get("filenameFrom");
        String stringConvertedFile = "file:///" + context.get("filenameTo");
        String filterName = "file:///" + context.get("filterName");

View Full Code Here

    /**
     * Use OpenOffice to convert documents between types
     */
    public static Map<String, Object> convertDocumentFileToFile(DispatchContext dctx, Map<String, ? extends Object> context) {
        XMultiComponentFactory xmulticomponentfactory = null;

        String stringUrl = (String) context.get("filenameFrom");
        String stringConvertedFile = (String) context.get("filenameTo");
        String inputMimeType = (String) context.get("inputMimeType");
        String outputMimeType = (String) context.get("outputMimeType");
View Full Code Here

    /**
     * Use OpenOffice to convert documents between types
     */
    public static Map<String, Object> convertDocumentStreamToStream(DispatchContext dctx, Map<String, ? extends Object> context) {
        XMultiComponentFactory xmulticomponentfactory = null;

        String stringUrl = "file:///" + context.get("filenameFrom");
        String stringConvertedFile = "file:///" + context.get("filenameTo");
        String inputMimeType = (String) context.get("inputMimeType");
        String outputMimeType = (String) context.get("outputMimeType");
View Full Code Here

    /**
     * Use OpenOffice to compare documents
     */
    public static Map<String, Object> compareDocuments(DispatchContext dctx, Map<String, ? extends Object> context) {
        XMultiComponentFactory xmulticomponentfactory = null;

        String stringUrl = "file:///" + context.get("filenameFrom");
        String stringOriginalFile = "file:///" + context.get("filenameOriginal");
        String stringOutFile = "file:///" + context.get("filenameOut");

        // if these are empty don't worry, the OpenOfficeWorker down below will take care of it
        String oooHost = (String)context.get("oooHost");
        String oooPort = (String)context.get("oooPort");

        try {
            xmulticomponentfactory = OpenOfficeWorker.getRemoteServer(oooHost, oooPort);
        } catch (IOException e) {
            Debug.logError(e, "Error in OpenOffice operation: ", module);
            return ServiceUtil.returnError(e.toString());
        } catch (Exception e) {
            Debug.logError(e, "Error in OpenOffice operation: ", module);
            return ServiceUtil.returnError(e.toString());
        }
        //System.out.println("xmulticomponentfactory: " + xmulticomponentfactory);

        // Converting the document to the favoured type
        try {
            // Composing the URL


            // Query for the XPropertySet interface.
            XPropertySet xpropertysetMultiComponentFactory = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xmulticomponentfactory);

            // Get the default context from the office server.
            Object objectDefaultContext = xpropertysetMultiComponentFactory.getPropertyValue("DefaultContext");

            // Query for the interface XComponentContext.
            XComponentContext xcomponentcontext = (XComponentContext) UnoRuntime.queryInterface(XComponentContext.class, objectDefaultContext);

            /* 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. */

            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
            propertyvalue = new PropertyValue[ 1 ];
            // Setting the flag for overwriting
            propertyvalue[ 0 ] = new PropertyValue();
            propertyvalue[ 0 ].Name = "URL";
            propertyvalue[ 0 ].Value = stringOriginalFile;
            // Setting the filter name
            //propertyvalue[ 1 ] = new PropertyValue();
            //propertyvalue[ 1 ].Name = "FilterName";
            //propertyvalue[ 1 ].Value = context.get("convertFilterName");
            XFrame frame = desktop.getCurrentFrame();
            //XFrame frame = (XFrame) UnoRuntime.queryInterface(XFrame.class, desktop);
            Object dispatchHelperObj = xmulticomponentfactory.createInstanceWithContext("com.sun.star.frame.DispatchHelper", xcomponentcontext);
            XDispatchHelper dispatchHelper = (XDispatchHelper) UnoRuntime.queryInterface(XDispatchHelper.class, dispatchHelperObj);
            XDispatchProvider dispatchProvider = (XDispatchProvider) UnoRuntime.queryInterface(XDispatchProvider.class, frame);
            dispatchHelper.executeDispatch(dispatchProvider, ".uno:CompareDocuments", "", 0, propertyvalue);

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

    public static XMultiComponentFactory getRemoteServer(String host, String port) throws IOException, Exception {

        if (UtilValidate.isEmpty(host)) host = UtilProperties.getPropertyValue("openoffice-uno", "oo.host", "localhost");
        if (UtilValidate.isEmpty(port)) port = UtilProperties.getPropertyValue("openoffice-uno", "oo.port", "8100");

        XMultiComponentFactory xmulticomponentfactory = null;
        XComponentContext xcomponentcontext = null;
        Object objectUrlResolver = null;
        XUnoUrlResolver xurlresolver = null;
        Object objectInitial = null;
        // Converting the document to the favoured type
        try {
            /* Bootstraps a component context with the jurt base components
            registered. Component context to be granted to a component for running.
            Arbitrary values can be retrieved from the context. */
            xcomponentcontext = com.sun.star.comp.helper.Bootstrap.createInitialComponentContext(null);

            /* Gets the service manager instance to be used (or null). This method has
            been added for convenience, because the service manager is a often used
            object. */
            xmulticomponentfactory = xcomponentcontext.getServiceManager();

            /* Creates an instance of the component UnoUrlResolver which
            supports the services specified by the factory. */
            objectUrlResolver = xmulticomponentfactory.createInstanceWithContext("com.sun.star.bridge.UnoUrlResolver", xcomponentcontext);

            // Create a new url resolver
            xurlresolver = (XUnoUrlResolver) UnoRuntime.queryInterface(XUnoUrlResolver.class, objectUrlResolver);

            // Resolves an object that is specified as follow:
View Full Code Here

TOP

Related Classes of com.sun.star.lang.XMultiComponentFactory

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.