Hi,

Kim Kulak wrote
While translating FirstLoadComponent.java to Python I've encountered
problems with this one line of code:

            System.out.println(elemType.getTypeName());

1. The method getTypeName() is not listed in the index of the "IDL
Reference" documentation.
have a look at

http://udk.openoffice.org/python/python-bridge.html#mapping

to see how a uno type is mapped. Basically, it is a uno.Type, which has the members typeName and typeClass, so the java getTypeName() must be transfered to a typeName.

2. The output from the unohelper.inspect() function on the elemType
object indicates that there is a "getName()" method and a "Name"
attribute but neither of these work either.
unohelper.inspect() seems to report nonsense when a uno.Type is passed. It either must report an error or give something sensible, you may create an issue therefor and assign it to me (jbu).

Bye,

Joerg



Kim

Here's a short program to illustrate the problems:
#
# Translated to python from "FirstLoadComponent.java" by Kim Kulak
#
import sys
import traceback
import uno
from com.sun.star.uno import Exception as UnoException

class FirstLoadComponent:
    def main(args):
        try:
            localContext = uno.getComponentContext()
            resolver =
localContext.ServiceManager.createInstanceWithContext("com.sun.star.bridge.UnoUrlResolver",localContext)
            xRemoteContext =
resolver.resolve("uno:socket,host=localhost,port=2002;urp;StarOffice.ComponentContext")
            print "Connected to a running office ..."
            xRemoteServiceManager = xRemoteContext.getServiceManager()

            xComponentLoader =
xRemoteServiceManager.createInstanceWithContext("com.sun.star.frame.Desktop",xRemoteContext)
            loadProps = ()
            xSpreadsheetDocument =
xComponentLoader.loadComponentFromURL("private:factory/scalc", "_blank",
0, loadProps);
            xSpreadsheets = xSpreadsheetDocument.getSheets()
            elemType = xSpreadsheets.getElementType()
            inspect(elemType,"elemType")
            try:
                print
"\nelemType.getElementType()",elemType.getElementType()
            except Exception,e:
                print "Caught exception"
                traceback.print_exc()

            try:
                print "\nelemType.getName()",elemType.getName()
            except Exception,e:
                print "Caught exception"
                traceback.print_exc()

            try:
                print "\nelemType.Name",elemType.Name
            except Exception,e:
                print "Caught exception"
                traceback.print_exc()

        except UnoException,e:
            traceback.print_exc()
            sys.exit(1)
        sys.exit(0)

    main = staticmethod(main)


def inspect(obj,name):
    import unohelper

    of = file(name+".inspect","w")
    of.write("Inspect variable '%s'\n"%(name,))
    of.write("Type of %s is %s\n"%(name,type(obj)))
    unohelper.inspect(obj,of)
    of.close()
    return

if __name__ == '__main__':
    FirstLoadComponent.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]

Reply via email to