Kim Kulak wrote:
> While translating FirstLoadComponent.java to Python I've encountered
> problems with this one line of code:
> 
>             System.out.println(elemType.getTypeName());

elemType = xSpreadsheets.getElementType() returns a
com.star.uno.TypeClass Enum. It only has 1 value depending on the object
being described, in this case an Interface

print elemType returns:

<Type instance com.sun.star.sheet.XSpreadsheet (<uno.Enum
com.sun.star.uno.TypeClass ('INTERFACE')>)>
> 
> 1. The method getTypeName() is not listed in the index of the "IDL
> Reference" documentation.
> 
> 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.

It should not have any functions, has TypeClass is an enum not an interface.

Regards
Darragh

> 
> 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]
> 
> 


-- 
Darragh Sherwin
PWB Implementations Manager
http://www.propylon.com/solutions/parliament/index.html
+353-1-4927456
+353-87-1204654

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

Reply via email to