26from com.sun.star.beans.MethodConcept
import ALL
as METHOD_CONCEPT_ALL
27from com.sun.star.beans.PropertyConcept
import ALL
as PROPERTY_CONCEPT_ALL
29from com.sun.star.reflection.ParamMode
import \
30 IN
as PARAM_MODE_IN, \
31 OUT
as PARAM_MODE_OUT, \
32 INOUT
as PARAM_MODE_INOUT
34from com.sun.star.beans.PropertyAttribute
import \
35 MAYBEVOID
as PROP_ATTR_MAYBEVOID, \
36 BOUND
as PROP_ATTR_BOUND, \
37 CONSTRAINED
as PROP_ATTR_CONSTRAINED, \
38 TRANSIENT
as PROP_ATTR_TRANSIENT, \
39 READONLY
as PROP_ATTR_READONLY, \
40 MAYBEAMBIGUOUS
as PROP_ATTR_MAYBEAMBIGUOUS, \
41 MAYBEDEFAULT
as PROP_ATTR_MAYBEDEFAULT, \
42 REMOVABLE
as PROP_ATTR_REMOVABLE
46 if mode == PARAM_MODE_INOUT:
48 elif mode == PARAM_MODE_OUT:
50 elif mode == PARAM_MODE_IN:
56 if PROP_ATTR_REMOVABLE & mode:
57 ret = ret +
"removable "
58 if PROP_ATTR_MAYBEDEFAULT & mode:
59 ret = ret +
"maybedefault "
60 if PROP_ATTR_MAYBEAMBIGUOUS & mode:
61 ret = ret +
"maybeambiguous "
62 if PROP_ATTR_READONLY & mode:
63 ret = ret +
"readonly "
64 if PROP_ATTR_TRANSIENT & mode:
65 ret = ret +
"transient "
66 if PROP_ATTR_CONSTRAINED & mode:
67 ret = ret +
"constrained "
68 if PROP_ATTR_BOUND & mode:
70 if PROP_ATTR_MAYBEVOID & mode:
71 ret = ret +
"maybevoid "
81 out.write( str(obj) +
"\n")
86 ctx.ServiceManager.createInstanceWithContext(
"com.sun.star.beans.Introspection", ctx )
88 out.write(
"Supported services:\n" )
89 if hasattr( obj,
"getSupportedServiceNames" ):
90 names = obj.getSupportedServiceNames()
92 out.write(
" " + ii +
"\n" )
94 out.write(
" unknown\n" )
96 out.write(
"Interfaces:\n" )
97 if hasattr( obj,
"getTypes" ):
98 interfaces = obj.getTypes()
100 out.write(
" " + ii.typeName +
"\n" )
102 out.write(
" unknown\n" )
104 access = introspection.inspect( obj )
105 methods = access.getMethods( METHOD_CONCEPT_ALL )
106 out.write(
"Methods:\n" )
108 out.write(
" " + ii.ReturnType.Name +
" " + ii.Name )
109 args = ii.ParameterTypes
110 infos = ii.ParameterInfos
112 for i
in range( 0, len( args ) ):
115 out.write(
_mode_to_str( infos[i].aMode ) +
" " + args[i].Name +
" " + infos[i].aName )
118 props = access.getProperties( PROPERTY_CONCEPT_ALL )
119 out.write (
"Properties:\n" )
121 out.write(
" ("+
_propertymode_to_str( ii.Attributes ) +
") "+ii.Type.typeName+
" "+ii.Name+
"\n" )
139 for i
in list(self.
impls.items()):
140 keyName =
"/"+ i[0] +
"/UNO/SERVICES"
141 key = regKey.createKey( keyName )
142 for serviceName
in i[1].serviceNames:
143 key.createKey( serviceName )
147 entry = self.
impls.get( implementationName,
None )
149 raise RuntimeException( implementationName +
" is unknown" ,
None )
153 entry = self.
impls.get( implementationName,
None )
155 raise RuntimeException( implementationName +
" is unknown" ,
None )
156 return entry.serviceNames
159 entry = self.
impls.get( implementationName,
None )
161 raise RuntimeException( implementationName +
" is unknown",
None )
162 return serviceName
in entry.serviceNames
166 def __init__(self, implName, supportedServices, clazz ):
172 for entry
in seqEntries:
173 keyName =
"/"+ entry.implName +
"/UNO/SERVICES"
174 key = regKey.createKey( keyName )
175 for serviceName
in entry.supportedServices:
176 key.createKey( serviceName )
179 "returns a file-url for the given system path"
180 return pyuno.systemPathToFileUrl( systemPath )
183 "returns a system path (determined by the system, the python interpreter is running on)"
184 return pyuno.fileUrlToSystemPath( url )
187 "returns an absolute file url from the given urls"
188 return pyuno.absolutize( path, relativeUrl )
192 if x.implName == implementationName:
196 smgr = contextRuntime.ServiceManager
197 loader = smgr.createInstanceWithContext( loaderName, contextRuntime )
198 implReg = smgr.createInstanceWithContext(
"com.sun.star.registry.ImplementationRegistration",contextRuntime)
200 isWin = os.name ==
'nt' or os.name ==
'dos'
201 isMac = sys.platform ==
'darwin'
203 for componentUrl
in componentUrls:
204 reg = smgr.createInstanceWithContext(
"com.sun.star.registry.SimpleRegistry", contextRuntime )
206 if not isWin
and componentUrl.endswith(
".uno" ):
208 componentUrl = componentUrl +
".dylib"
210 componentUrl = componentUrl +
".so"
212 implReg.registerImplementation( loaderName,componentUrl, reg )
213 rootKey = reg.getRootKey()
214 implementationKey = rootKey.openKey(
"IMPLEMENTATIONS" )
215 implNames = implementationKey.getKeyNames()
216 extSMGR = toBeExtendedContext.ServiceManager
218 fac = loader.activate( max(x.split(
"/")),
"",componentUrl,rootKey)
219 extSMGR.insert( fac )
226 if self.__class__
in _g_typeTable:
227 ret = _g_typeTable[self.__class__]
230 traverse = list(self.__class__.__bases__)
231 while len( traverse ) > 0:
232 item = traverse.pop()
233 bases = item.__bases__
235 names[item.__pyunointerface__] =
None
238 traverse = traverse + list(bases)
240 lst = list(names.keys())
247 _g_typeTable[self.__class__] = ret
257 """a current context implementation, which first does a lookup in the given
258 hashmap and if the key cannot be found, it delegates to the predecessor
277 def __init__( self, clazz, implementationName, serviceNames ):
292 return self.
clazz( context )
295 return self.
clazz( context, *args )
def getImplementationId(self)
def __init__(self, oldContext, hashMap)
def getValueByName(self, name)
def __init__(self, implName, supportedServices, clazz)
def supportsService(self, implementationName, serviceName)
def addImplementation(self, ctor, implementationName, serviceNames)
def getSupportedServiceNames(self, implementationName)
def writeRegistryInfo(self, regKey, smgr)
def getComponentFactory(self, implementationName, regKey, smgr)
def supportsService(self, ServiceName)
def createInstanceWithArgumentsAndContext(self, args, context)
def createInstanceWithContext(self, context)
def getImplementationName(self)
def __init__(self, clazz, implementationName, serviceNames)
def getSupportedServiceNames(self)
def __init__(self, ctor, serviceNames)
def getComponentContext()
def getTypeByName(typeName)
def _propertymode_to_str(mode)
def systemPathToFileUrl(systemPath)
def addComponentsToContext(toBeExtendedContext, contextRuntime, componentUrls, loaderName)
def getComponentFactoryHelper(implementationName, smgr, regKey, seqEntries)
def _unohelper_getHandle(self)
def writeRegistryInfoHelper(smgr, regKey, seqEntries)
def createSingleServiceFactory(clazz, implementationName, serviceNames)
def fileUrlToSystemPath(url)
def absolutize(path, relativeUrl)