Re: [udk-dev] pyuno_module.cxx

2005-09-12 Thread Stephan Bergmann

Joerg Budischewski wrote:

Hi Stephan,

you can remove the runtime instances, they just cash some hashmap 
lookups and have no side effects. The PyThreadAttach/Detach classes on 
the other hand have side effects and cannot be removed.


Would be nice if you can execute the pyuno tests in 
testtools/source/bridgetest/pyuno (at best before and ) after your 
modifications. You currently need to set UNO_TYPES and UNO_SERVICES 
environment variable to the values passed formerly by using the -env: 
command line switches, just have a look in the makefile.


I will do that.

Umn, I know, pyuno currently raises a lot of warnings, hope, you get 
through though.


Not thaaat many, actually (at least on Solaris and Linux)...

Thanks,
-Stephan


Good luck and bye,

Joerg

Stephan Bergmann wrote:


Friends and maintainers of pyuno,  :)

Making our code base warning-clean (see thread on dev@openoffice.org), 
I stumbled over a detail in pyuno/source/module/pyuno_module.cxx rev. 
1.9.14.1 I am not sure how to resolve:  The two functions PyEnum2Enum 
and PyType2Type used to take a Runtime argument that they did not use, 
so I removed it.  However, in lines 458 and 483 of pyuno_module.cxx, 
these functions got called with a freshly created Runtime instance:


  {
Runtime runtime;
PyType2Type( obj, runtime );
  }

and I am not sure whether the Runtime constructor should still be 
called for side effects:


  {
Runtime runtime;
PyType2Type( obj );
  }

or whether that is not needed:

  {
PyType2Type( obj );
  }

-Stephan


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



[udk-dev] Problem translating java method, getTypeName(), to python

2005-09-12 Thread Kim Kulak
I originally sent this to [EMAIL PROTECTED] This is the correct
list for pyUno questions. Sorry if you've ween this already. I imagine
that there is a fair overlap between the two lists.

Kim

 Original Message 

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.

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.

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]



[udk-dev] Python equivalent to com.sun.star.comp.helper.Bootstrap.bootstrap()?

2005-09-12 Thread Kim Kulak
I originally sent this to [EMAIL PROTECTED] This should be the
more appropriate list for pyUno questions.

Kim

 Original Message 

I've translated the one call to
com.sun.star.comp.helper.Bootstrap.bootstrap() in FirstUnoContact.java
to three calls in Python:

### 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)

So, is there an equivalent python function to
com.sun.star.comp.helper.Bootstrap.bootstrap()? I've searched the
documentation and the list archives and haven't been able to find an
answer to this question.

Kim



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