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