Ramon F Herrera wrote:

> The OpenOffice process can be run in either (a) named-pipe mode, or
> (b) listening to some particular socket mode. According to all the
> code I have seen, the programmer has to know those details in advance.

No, that is not necessary. Only if you are not satisfied with the
standard connection that you get with the Simple Bootstrap process or if
you want to connect to an OOo instance that is not running on the same
machine as your application.

> IOW, if my program is going to connect the OO server via socket 8100
> (some sort of convention), it has to be started like this:
> 
> "C:\Program Files\OpenOffice.org 2.3\program\soffice" 
> -accept=socket,host=0,port=8100;urp;

If *your* program wants to use a specific communication channel then of
course you will need to know which one you want to use. But OOo does not
enforce that. If you are fine with whatever connection OOo uses, you can
ignore which it is exactly.

> These are the first 5 lines of a typical OO client program (not drawn
> to scale!):
> 
> (1) xContext = Bootstrap.bootstrap();  // starts OO process (plus 
> Windows icon) if not already running

It not only starts OOo, it already connects to it and gives you an
object that can be used to create and access others. See the attached
source code that loads a document via UNO (I tried to link to the source
code on api.openoffice.org but for whatever reasons it's not there).

> (2) XMultiComponentFactory xMCF = xContext.getServiceManager();
> (3) createInstanceWithContext("com.sun.star.bridge.BridgeFactory");
> (4) xConnector = UnoRuntime.queryInterface(XConnector.class, x);
> (5) connection = xConnector.connect(con);  <-- finally!, there is TCP/IP 
> communication here
> 
> where 'con' can be something like: "socket,host=localhost,port=8100"
> or "pipe,name=whatever".
> 
> Can I insert some statement between steps (4) and (5) in which I ask
> the OO server: what kind of IPC mode are you using: named pipe or
> socket? If pipe: what is the name of the pipe? If socket, what socket
> number are you using?

I don't understand why you want to know that. The Component Context you
have bootstrapped is your entry to the UNO world and gives you
everything you need. What else do you want to achieve by establishing
another connection?

I don't know what answers you will get here - in case they don't satisfy
you you could perhaps try to get more information on [EMAIL PROTECTED]

Ciao,
Mathias

-- 
Mathias Bauer (mba) - Project Lead OpenOffice.org Writer
OpenOffice.org Engineering at Sun: http://blogs.sun.com/GullFOSS
Please don't reply to "[EMAIL PROTECTED]".
I use it for the OOo lists and only rarely read other mails sent to it.
/*************************************************************************
 *
 *  $RCSfile: DocumentLoader.java,v $
 *
 *  $Revision: 1.5 $
 *
 *  last change: $Author: rt $ $Date: 2005/01/31 17:08:37 $
 *
 *  The Contents of this file are made available subject to the terms of
 *  the BSD license.
 *  
 *  Copyright (c) 2003 by Sun Microsystems, Inc.
 *  All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions
 *  are met:
 *  1. Redistributions of source code must retain the above copyright
 *     notice, this list of conditions and the following disclaimer.
 *  2. Redistributions in binary form must reproduce the above copyright
 *     notice, this list of conditions and the following disclaimer in the
 *     documentation and/or other materials provided with the distribution.
 *  3. Neither the name of Sun Microsystems, Inc. nor the names of its
 *     contributors may be used to endorse or promote products derived
 *     from this software without specific prior written permission.
 *
 *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
 *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
 *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
 *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
 *  OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 *  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
 *  TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
 *  USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *     
 *************************************************************************/

import com.sun.star.uno.UnoRuntime;


/** This class opens a new or an existing office document.
 */
public class DocumentLoader {
    public static void main(String args[]) {
        if ( args.length < 1 ) {
            System.out.println(
                "usage: java -jar DocumentLoader.jar \"<URL|path>\"" );
            System.out.println( "\ne.g.:" );
            System.out.println(
                "java -jar DocumentLoader.jar \"private:factory/swriter\"" );
            System.exit(1);
        }
        
        com.sun.star.uno.XComponentContext xContext = null;

        try {
            // get the remote office component context
            xContext = com.sun.star.comp.helper.Bootstrap.bootstrap();
            System.out.println("Connected to a running office ...");
            
            // get the remote office service manager
            com.sun.star.lang.XMultiComponentFactory xMCF =
                xContext.getServiceManager();
            
            Object oDesktop = xMCF.createInstanceWithContext(
                "com.sun.star.frame.Desktop", xContext);
        
            com.sun.star.frame.XComponentLoader xCompLoader =
                (com.sun.star.frame.XComponentLoader)
                     UnoRuntime.queryInterface(
                         com.sun.star.frame.XComponentLoader.class, oDesktop);

            String sUrl = args[0];
            if ( sUrl.indexOf("private:") != 0) {
                java.io.File sourceFile = new java.io.File(args[0]);
                StringBuffer sbTmp = new StringBuffer("file:///");
                sbTmp.append(sourceFile.getCanonicalPath().replace('\\', '/'));
                sUrl = sbTmp.toString();
            }    
      
            // Load a Writer document, which will be automaticly displayed
            com.sun.star.lang.XComponent xComp = xCompLoader.loadComponentFromURL(
                sUrl, "_blank", 0, new com.sun.star.beans.PropertyValue[0]);

            if ( xComp != null )
                System.exit(0);
            else
                System.exit(1);
        }
        catch( Exception e ) {
            e.printStackTrace(System.err);
            System.exit(1);
        }
    }
}

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to