-
Notifications
You must be signed in to change notification settings - Fork 2
/
registration.py
72 lines (57 loc) · 2.26 KB
/
registration.py
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import bookmarks
imples = {
bookmarks.IMPLE_NAME:
(bookmarks.SERVICE_NAMES, "bookmarks.bookmarks_pmc.create"),
bookmarks.SHOWN_COLUMNS_IMPLE_NAME:
(bookmarks.SERVICE_NAMES, "bookmarks.columns_pmc.create"),
bookmarks.OPTION_PAGE_HANDLER_IMPLE_NAME:
((bookmarks.OPTION_PAGE_HANDLER_IMPLE_NAME,), "bookmarks.options.create"),
bookmarks.MANAGER_IMPLE_NAME:
(bookmarks.MANAGER_SERVICE_NAMES, "bookmarks.organizer.create"),
bookmarks.DIRECTORY_POPUP_IMPLE_NAME:
(bookmarks.SERVICE_NAMES, "bookmarks.directory_pmc.create"),
bookmarks.TAG_POPUP_IMPLE_NAME:
(bookmarks.SERVICE_NAMES, "bookmarks.tag_pmc.create"),
}
def writeRegistryInfo(smgr, reg):
for imple_name in imples.keys():
key = reg.createKey("/%s/UNO/SERVICES" % imple_name)
for name in imples[imple_name][0]:
key.createKey(name)
return True
def getComponentFactory(imple_name, smgr, reg):
try:
imple = imples[imple_name]
names = imple[1].split(".")
if names:
mod = __import__(".".join(names[0:-1]))
for name in names[1:]:
mod = getattr(mod, name)
else:
mod = getattr(__module__, imple[1])
return SingleComponentFactory(imple_name, imple[0], mod)
except Exception as e:
print(e)
return None
import unohelper
from com.sun.star.lang import XServiceInfo, XSingleComponentFactory
class SingleComponentFactory(unohelper.Base, XSingleComponentFactory, XServiceInfo):
def __init__(self, imple_name, service_names, ctor):
self.imple_name = imple_name
self.service_names = service_names
self.ctor = ctor
def createInstanceWithContext(self, ctx):
return self.createInstanceWithArgumentsAndContext((), ctx)
def createInstanceWithArgumentsAndContext(self, args, ctx):
try:
return self.ctor(ctx, *args)
except Exception as e:
print(e)
import traceback
traceback.print_exc()
def getImplementationName(self):
return self.imple_name
def supportsService(self, name):
return name in self.service_names
def getSupportedServiceNames(self):
return self.service_names