1a0428e9eSAndrew Rist#************************************************************** 2cdf0e10cSrcweir# 3a0428e9eSAndrew Rist# Licensed to the Apache Software Foundation (ASF) under one 4a0428e9eSAndrew Rist# or more contributor license agreements. See the NOTICE file 5a0428e9eSAndrew Rist# distributed with this work for additional information 6a0428e9eSAndrew Rist# regarding copyright ownership. The ASF licenses this file 7a0428e9eSAndrew Rist# to you under the Apache License, Version 2.0 (the 8a0428e9eSAndrew Rist# "License"); you may not use this file except in compliance 9a0428e9eSAndrew Rist# with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir# 11a0428e9eSAndrew Rist# http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir# 13a0428e9eSAndrew Rist# Unless required by applicable law or agreed to in writing, 14a0428e9eSAndrew Rist# software distributed under the License is distributed on an 15a0428e9eSAndrew Rist# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16a0428e9eSAndrew Rist# KIND, either express or implied. See the License for the 17a0428e9eSAndrew Rist# specific language governing permissions and limitations 18a0428e9eSAndrew Rist# under the License. 19cdf0e10cSrcweir# 20a0428e9eSAndrew Rist#************************************************************** 21cdf0e10cSrcweir 22cdf0e10cSrcweirimport uno 23cdf0e10cSrcweirimport unohelper 24cdf0e10cSrcweir 25cdf0e10cSrcweirfrom com.sun.star.awt import Rectangle 26cdf0e10cSrcweirfrom com.sun.star.awt.MessageBoxButtons import BUTTONS_OK 27*61161268SAriel Constenla-Hailefrom com.sun.star.awt.MessageBoxType import INFOBOX 28cdf0e10cSrcweirfrom com.sun.star.frame import XDispatch, XDispatchProvider 29cdf0e10cSrcweirfrom com.sun.star.lang import XServiceInfo 30cdf0e10cSrcweirfrom com.sun.star.registry import InvalidRegistryException 31cdf0e10cSrcweir 32cdf0e10cSrcweirclass Provider(unohelper.Base, XServiceInfo, XDispatchProvider): 33cdf0e10cSrcweir implementationName = "com.sun.star.comp.test.deployment.active_python" 34cdf0e10cSrcweir 35cdf0e10cSrcweir serviceNames = ("com.sun.star.test.deployment.active_python",) 36cdf0e10cSrcweir 37cdf0e10cSrcweir def __init__(self, context): 38cdf0e10cSrcweir self.context = context 39cdf0e10cSrcweir 40cdf0e10cSrcweir def getImplementationName(self): 41cdf0e10cSrcweir return self.implementationName 42cdf0e10cSrcweir 43cdf0e10cSrcweir def supportsService(self, ServiceName): 44cdf0e10cSrcweir return ServiceName in self.serviceNames 45cdf0e10cSrcweir 46cdf0e10cSrcweir def getSupportedServiceNames(self): 47cdf0e10cSrcweir return self.serviceNames 48cdf0e10cSrcweir 49cdf0e10cSrcweir def queryDispatch(self, URL, TargetFrame, SearchFlags): 50cdf0e10cSrcweir return self.context.getValueByName( \ 51cdf0e10cSrcweir "/singletons/com.sun.star.test.deployment.active_python_singleton") 52cdf0e10cSrcweir 53cdf0e10cSrcweir def queryDispatches(self, Requests): 54cdf0e10cSrcweir tuple( \ 55cdf0e10cSrcweir self.queryDispatch(i.FeatureURL, i.FrameName, i.SearchFlags) \ 56cdf0e10cSrcweir for i in Requests) 57cdf0e10cSrcweir 58cdf0e10cSrcweirclass Dispatch(unohelper.Base, XServiceInfo, XDispatch): 59cdf0e10cSrcweir implementationName = \ 60cdf0e10cSrcweir "com.sun.star.comp.test.deployment.active_python_singleton" 61cdf0e10cSrcweir 62cdf0e10cSrcweir serviceNames = () 63cdf0e10cSrcweir 64cdf0e10cSrcweir def __init__(self, context): 65cdf0e10cSrcweir self.context = context 66cdf0e10cSrcweir 67cdf0e10cSrcweir def getImplementationName(self): 68cdf0e10cSrcweir return self.implementationName 69cdf0e10cSrcweir 70cdf0e10cSrcweir def supportsService(self, ServiceName): 71cdf0e10cSrcweir return ServiceName in self.serviceNames 72cdf0e10cSrcweir 73cdf0e10cSrcweir def getSupportedServiceNames(self): 74cdf0e10cSrcweir return self.serviceNames 75cdf0e10cSrcweir 76cdf0e10cSrcweir def dispatch(self, URL, Arguments): 77cdf0e10cSrcweir smgr = self.context.getServiceManager() 78cdf0e10cSrcweir box = smgr.createInstanceWithContext( \ 79cdf0e10cSrcweir "com.sun.star.awt.Toolkit", self.context).createMessageBox( \ 80cdf0e10cSrcweir smgr.createInstanceWithContext( \ 81cdf0e10cSrcweir "com.sun.star.frame.Desktop", self.context). \ 82cdf0e10cSrcweir getCurrentFrame().getComponentWindow(), \ 83*61161268SAriel Constenla-Haile INFOBOX, BUTTONS_OK, "active", "python") 84cdf0e10cSrcweir box.execute(); 85cdf0e10cSrcweir box.dispose(); 86cdf0e10cSrcweir 87cdf0e10cSrcweir def addStatusListener(self, Control, URL): 88cdf0e10cSrcweir pass 89cdf0e10cSrcweir 90cdf0e10cSrcweir def removeStatusListener(self, Control, URL): 91cdf0e10cSrcweir pass 92cdf0e10cSrcweir 93cdf0e10cSrcweirdef getComponentFactory(implementationName, smgr, regKey): 94cdf0e10cSrcweir if implementationName == Provider.implementationName: 95cdf0e10cSrcweir return unohelper.createSingleServiceFactory( \ 96cdf0e10cSrcweir Provider, Provider.implementationName, Provider.serviceNames) 97cdf0e10cSrcweir elif implementationName == Dispatch.implementationName: 98cdf0e10cSrcweir return unohelper.createSingleServiceFactory( \ 99cdf0e10cSrcweir Dispatch, Dispatch.implementationName, Dispatch.serviceNames) 100cdf0e10cSrcweir else: 101cdf0e10cSrcweir return None 102cdf0e10cSrcweir 103cdf0e10cSrcweirdef writeRegistryInfo(smgr, regKey): 104cdf0e10cSrcweir try: 105cdf0e10cSrcweir for i in (Provider, Dispatch): 106cdf0e10cSrcweir key = regKey.createKey("/" + i.implementationName + "/UNO") 107cdf0e10cSrcweir for j in i.serviceNames: 108cdf0e10cSrcweir key.createKey("/SERVICES/" + j); 109cdf0e10cSrcweir regKey.createKey( \ 110cdf0e10cSrcweir "/" + Dispatch.implementationName + "/UNO/SINGLETONS/" \ 111cdf0e10cSrcweir "com.sun.star.test.deployment.active_python_singleton"). \ 112cdf0e10cSrcweir setStringValue(Dispatch.implementationName) 113cdf0e10cSrcweir except InvalidRegistryException: 114cdf0e10cSrcweir return False 115cdf0e10cSrcweir return True 116