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