Загрузка документа в OpenOffice с использованием внешней программы Python
Я пытаюсь создать программу на Python (используя pyUNO), чтобы внести некоторые изменения в калькуляторе OpenOffice.
Ранее я запускал OpenOffice в режиме «принять», чтобы иметь возможность подключаться из внешней программы. Видимо, должно быть так же просто, как:
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']
Я читал, что есть ошибки, которые делают то же самое, но в OpenOffice 3.0 (я использую OpenOffice 3.1 поверх Red Hat5.3). Я пытался использовать указанный способ обходаВот, но они, кажется, не работают.
Есть идеи?