这么写一个helloworld就贼慢,以后在做pdf,doc等转矢量图那就更慢了,请问有啥办法么?
日志:
2015-08-03 18:30:56,804 [CALL,tid 1]: Instantiating pyuno bridge
2015-08-03 18:30:56,808 [CALL,tid 1]: try py->uno[0x7fd8e9b51c30].createInstanceWithContext((string)"com.sun.star.bridge.UnoUrlResolver", (com.sun.star.uno.XComponentContext)0x7fd8e9bdcd18)
2015-08-03 18:30:56,809 [CALL,tid 1]: success py->uno[0x7fd8e9b51c30].createInstanceWithContext()=(com.sun.star.uno.XInterface)0x7fd8e9baf288
2015-08-03 18:30:56,809 [CALL,tid 1]: try py->uno[0x7fd8e9b51e30].resolve((string)"uno:socket,host=localhost,port=2002;urp;StarOffice.ComponentContext")
#此处等待30s以上
2015-08-03 18:31:56,892 [CALL,tid 1]: success py->uno[0x7fd8e9b51e30].resolve()=(com.sun.star.uno.XInterface)0x167e7d8
2015-08-03 18:31:56,907 [CALL,tid 1]: try py->uno[0x7fd8e9b51d30].createInstanceWithContext((string)"com.sun.star.frame.Desktop", (com.sun.star.uno.XInterface)0x167e7d8)
2015-08-03 18:31:56,908 [CALL,tid 1]: success py->uno[0x7fd8e9b51d30].createInstanceWithContext()=(com.sun.star.uno.XInterface)0x1687a88
2015-08-03 18:31:56,928 [CALL,tid 1]: try py->uno[0x7fd8e9b9a038].getCurrentComponent()
2015-08-03 18:31:56,929 [CALL,tid 1]: success py->uno[0x7fd8e9b9a038].getCurrentComponent()=(com.sun.star.lang.XComponent)0x1696828
2015-08-03 18:31:56,983 [CALL,tid 1]: try py->uno[0x7fd8e16f6060].createTextCursor()
2015-08-03 18:31:56,984 [CALL,tid 1]: success py->uno[0x7fd8e16f6060].createTextCursor()=(com.sun.star.text.XTextCursor)0x16d79d8
2015-08-03 18:31:57,000 [CALL,tid 1]: try py->uno[0x7fd8e16f6060].insertString((com.sun.star.text.XTextCursor)0x16d79d8, (string)"Hello World", (byte)0x0)
2015-08-03 18:31:57,002 [CALL,tid 1]: success py->uno[0x7fd8e16f6060].insertString()=void
python程序:
import socket
import uno
#get the uno component from the PyUNO runtime
localContext = uno.getComponentContext()
#create the UnoUrlResolver
resolver = localContext.ServiceManager.createInstanceWithContext("com.sun.star.bridge.UnoUrlResolver",localContext)
#connect to the running office
ctx = resolver.resolve("uno:socket,host=localhost,port=2002;urp;StarOffice.ComponentContext")
smgr = ctx.ServiceManager
# get the contral desktop object
desktop = smgr.createInstanceWithContext("com.sun.star.frame.Desktop",ctx)
# access the current writer document
model = desktop.getCurrentComponent()
# access the document's text property
text = model.Text
# create a cursor
cursor = text.createTextCursor()
# Insert the text into the document
text.insertString(cursor,"Hello World",0)
# Do a nasty thing before exiting the python process. In case the
# last call is a oneway call (e.g. see idl-spec of insertString),
# it must be forced out of the remote-bridge caches before python
# exits the process. Otherwise, the oneway call may or may not reach
# the target object.
# I do this here by calling a cheap synchronous call (getPropertyValue).
ctx.ServiceManager