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