読み込み書OpenOffice外部からのPythonプログラム
質問
私が作り出してしまおうというものpythonプログラムを使用pyUNO)に変更、OpenOffice calcます。
私は開始前OpenOfficeに"accept"モードでは接続でき、外部プログラム。どうやら、ど:
import uno
# get the uno component context 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 central desktop object
DESKTOP =smgr.createInstanceWithContext("com.sun.star.frame.Desktop", ctx)
#The calling it's not exactly this way, just to simplify the code
DESKTOP.loadComponentFromURL('file.ods')
か AttributeError
またアクセス loadComponentFromURL
.ば dir(DESKTOP)
, 私の次の属性は、メソッド:
['ActiveFrame', 'DispatchRecorderSupplier', 'ImplementationId', 'ImplementationName',
'IsPlugged', 'PropertySetInfo', 'SupportedServiceNames', 'SuspendQuickstartVeto',
'Title', 'Types', 'addEventListener', 'addPropertyChangeListener',
'addVetoableChangeListener', 'dispose', 'disposing', 'getImplementationId',
'getImplementationName', 'getPropertySetInfo', 'getPropertyValue',
'getSupportedServiceNames', 'getTypes', 'handle', 'queryInterface',
'removeEventListener', 'removePropertyChangeListener', 'removeVetoableChangeListener',
'setPropertyValue', 'supportsService']
このままありがバグっているようになOpenOffice3.0(を使用していOpenOffice3.1以上の赤Hat5.3).また、回避策に記載 こちらの, もあるんですが、そのようだ。
そのアイデア?
他のヒント
私がPyUNOを使って何をしたので、長い時間でしたが、私は'06に戻ってそれを実行した最後の時間を働いていたコードを見て、私はこのように私のロード文書をしました。
def urlify(path):
return uno.systemPathToFileUrl(os.path.realpath(path))
desktop.loadComponentFromURL(
urlify(tempfilename), "_blank", 0, ())
あなたの例では、簡略化されたバージョンで、あなたが意図的かどうかにかかわらず、意図的に追加の引数を削除した場合、私はわからない。
loadComponentFromURLのがない場合、APIは、他の何か間違って変更またはそこのいる、私はあなたのコードを読んで、あなたは私が持っているすべて同じ事をやっているように見えます。
私は私がリクエストを通じてプロキシに使用されて__getattr__
方法があると思う、とあなたは、プリントアウトしたすべてのメソッドは、ユーティリティですとデスクトップオブジェクトのメソッドのdirが()、有用であろうことを信じていません。スタンドインオブジェクトcom.sun.star.frame.Desktop
のために使用される方法。
私は、おそらく障害が正確に1引数を持つloadComponentFromURLにという名前のメソッドはありませんということができると思います。おそらく4引数のバージョンを与えること発見し、使用されている方法になります。これは、単にJavaはコール署名方式のオーバーロードを有するPythonとJavaの間のインピーダンス不整合であってもよい。