I originally sent this to [EMAIL PROTECTED] I think that this is
the more appropriate list.
Kim
-------- Original Message --------
I've been writing an application in Python using OOo and it's great!
Time to give back and I'd like to do this by translating the examples
from Java into Python. The examples have been irreplaceable, even
written in Java, in helping me to get my programs running.
I've started, of course, with FirstUnoContact.py. It's ready to go and
I'll append it to this email but first I have a few questions and comments:
1. Is there some place I can upload these files rather than sending them
in an email? How would you prefer to receive them? Especially as they
get larger!
2. I've left the Java code commingled with the Python code. I think it's
useful to illustrate the translation process. The Java can be removed by
deleting each line that begins with "###".
3. Some questions and problems have come up during the translation
process. I'll address these in separate emails.
4. Your comments and suggestions?
TTYL,
Kim
Here's FirstUnoContact.py:
###/*************************************************************************
### *
### * $RCSfile: FirstUnoContact.java,v $
### *
### * $Revision: 1.2 $
### *
### * last change: $Author: rt $ $Date: 2005/01/31 16:26:35 $
### *
### * 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.
### *
###
*************************************************************************/
###
#
# Translated to python from "FirstUnoContact.java" by Kim Kulak
#
import sys
import traceback
import uno
from com.sun.star.uno import Exception as UnoException
###public class FirstUnoContact {
class FirstUnoContact:
###
### public static void main(String[] args) {
def main(args):
### try {
try:
### // get the remote office component context
### com.sun.star.uno.XComponentContext xContext =
### com.sun.star.comp.helper.Bootstrap.bootstrap();
localContext = uno.getComponentContext()
resolver =
localContext.ServiceManager.createInstanceWithContext("com.sun.star.bridge.UnoUrlResolver",localContext)
xContext =
resolver.resolve("uno:socket,host=localhost,port=2002;urp;StarOffice.ComponentContext")
###
### System.out.println("Connected to a running office ...");
print "Connected to a running office ..."
###
### com.sun.star.lang.XMultiComponentFactory xMCF =
### xContext.getServiceManager();
xMFC = xContext.getServiceManager()
###
### String available = (xMCF != null ? "available" : "not
available");
if xMFC is not None:
available = "available"
else:
available = "not available"
### System.out.println( "remote ServiceManager is " + available );
print "remote ServiceManager is",available
### }
### catch (java.lang.Exception e){
except UnoException,e:
### e.printStackTrace();
traceback.print_exc()
### }
### finally {
### System.exit(0);
### }
sys.exit(0)
### }
###}
main = staticmethod(main)
###
if __name__ == '__main__':
FirstUnoContact.main(sys.argv)
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]