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 29cdf0e10cSrcweir 30cdf0e10cSrcweirclass Provider(unohelper.Base, XServiceInfo, XDispatchProvider): 31cdf0e10cSrcweir implementationName = "com.sun.star.comp.test.deployment.passive_python" 32cdf0e10cSrcweir 33cdf0e10cSrcweir serviceNames = ("com.sun.star.test.deployment.passive_python",) 34cdf0e10cSrcweir 35cdf0e10cSrcweir def __init__(self, context): 36cdf0e10cSrcweir self.context = context 37cdf0e10cSrcweir 38cdf0e10cSrcweir def getImplementationName(self): 39cdf0e10cSrcweir return self.implementationName 40cdf0e10cSrcweir 41cdf0e10cSrcweir def supportsService(self, ServiceName): 42cdf0e10cSrcweir return ServiceName in self.serviceNames 43cdf0e10cSrcweir 44cdf0e10cSrcweir def getSupportedServiceNames(self): 45cdf0e10cSrcweir return self.serviceNames 46cdf0e10cSrcweir 47cdf0e10cSrcweir def queryDispatch(self, URL, TargetFrame, SearchFlags): 48cdf0e10cSrcweir return self.context.getValueByName( \ 49cdf0e10cSrcweir "/singletons/com.sun.star.test.deployment.passive_python_singleton") 50cdf0e10cSrcweir 51cdf0e10cSrcweir def queryDispatches(self, Requests): 52cdf0e10cSrcweir tuple( \ 53cdf0e10cSrcweir self.queryDispatch(i.FeatureURL, i.FrameName, i.SearchFlags) \ 54cdf0e10cSrcweir for i in Requests) 55cdf0e10cSrcweir 56cdf0e10cSrcweirclass Dispatch(unohelper.Base, XServiceInfo, XDispatch): 57cdf0e10cSrcweir implementationName = \ 58cdf0e10cSrcweir "com.sun.star.comp.test.deployment.passive_python_singleton" 59cdf0e10cSrcweir 60cdf0e10cSrcweir serviceNames = () 61cdf0e10cSrcweir 62cdf0e10cSrcweir def __init__(self, context): 63cdf0e10cSrcweir self.context = context 64cdf0e10cSrcweir 65cdf0e10cSrcweir def getImplementationName(self): 66cdf0e10cSrcweir return self.implementationName 67cdf0e10cSrcweir 68cdf0e10cSrcweir def supportsService(self, ServiceName): 69cdf0e10cSrcweir return ServiceName in self.serviceNames 70cdf0e10cSrcweir 71cdf0e10cSrcweir def getSupportedServiceNames(self): 72cdf0e10cSrcweir return self.serviceNames 73cdf0e10cSrcweir 74cdf0e10cSrcweir def dispatch(self, URL, Arguments): 75cdf0e10cSrcweir smgr = self.context.getServiceManager() 76cdf0e10cSrcweir box = smgr.createInstanceWithContext( \ 77cdf0e10cSrcweir "com.sun.star.awt.Toolkit", self.context).createMessageBox( \ 78cdf0e10cSrcweir smgr.createInstanceWithContext( \ 79cdf0e10cSrcweir "com.sun.star.frame.Desktop", self.context). \ 80cdf0e10cSrcweir getCurrentFrame().getComponentWindow(), \ 81cdf0e10cSrcweir Rectangle(), "infobox", BUTTONS_OK, "passive", "python") 82cdf0e10cSrcweir box.execute(); 83cdf0e10cSrcweir box.dispose(); 84cdf0e10cSrcweir 85cdf0e10cSrcweir def addStatusListener(self, Control, URL): 86cdf0e10cSrcweir pass 87cdf0e10cSrcweir 88cdf0e10cSrcweir def removeStatusListener(self, Control, URL): 89cdf0e10cSrcweir pass 90cdf0e10cSrcweir 91cdf0e10cSrcweirg_ImplementationHelper = unohelper.ImplementationHelper() 92cdf0e10cSrcweirg_ImplementationHelper.addImplementation( \ 93cdf0e10cSrcweir Provider, Provider.implementationName, Provider.serviceNames) 94cdf0e10cSrcweirg_ImplementationHelper.addImplementation( \ 95cdf0e10cSrcweir Dispatch, Dispatch.implementationName, Dispatch.serviceNames) 96