-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOooBaseWProps.py
More file actions
executable file
·30 lines (25 loc) · 1007 Bytes
/
OooBaseWProps.py
File metadata and controls
executable file
·30 lines (25 loc) · 1007 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#
# OooBase - The base class for general python programs to interact with OpenOffice.
#
# Copyright 2013 Fahlstrom Research LLC
#
# Author : Carl A. Fahlstrom
#
import uno
class OooBaseWProps(object):
'''
Base object for Python OpenOffice extensions
'''
def __init__(self):
'''
This init method creates a UNO conection to OpenOffice on port 2002.
The method gets a handle to the current app (Writer, Calc, Impress)
'''
self.localContext = uno.getComponentContext()
self.resolver = self.localContext.ServiceManager.createInstanceWithContext(
"com.sun.star.bridge.UnoUrlResolver", self.localContext)
self.ctx = self.resolver.resolve("uno:socket,host=localhost,port=2002;urp;StarOffice.ComponentContext")
self.smgr = self.ctx.ServiceManager
self.desktop = self.smgr.createInstanceWithContext("com.sun.star.frame.Desktop", self.ctx)
self.props = self.smgr.createInstanceWithContext("com.sun.star.beans.PropertySet", self.ctx)
self.model = self.desktop.getCurrentComponent()