tdf#154546 skip dispatch when presenter controller is not set
[LibreOffice.git] / desktop / test / deployment / passive / passive_python.py
blobf16797e50175a67b255dab757d9fa63a689f91d4
2 # This file is part of the LibreOffice project.
4 # This Source Code Form is subject to the terms of the Mozilla Public
5 # License, v. 2.0. If a copy of the MPL was not distributed with this
6 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 # This file incorporates work covered by the following license notice:
10 # Licensed to the Apache Software Foundation (ASF) under one or more
11 # contributor license agreements. See the NOTICE file distributed
12 # with this work for additional information regarding copyright
13 # ownership. The ASF licenses this file to you under the Apache
14 # License, Version 2.0 (the "License"); you may not use this file
15 # except in compliance with the License. You may obtain a copy of
16 # the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 import uno
20 import unohelper
22 from com.sun.star.awt import Rectangle
23 from com.sun.star.awt.MessageBoxButtons import BUTTONS_OK
24 from com.sun.star.awt.MessageBoxType import INFOBOX
25 from com.sun.star.frame import XDispatch, XDispatchProvider
26 from com.sun.star.lang import XServiceInfo
28 class Provider(unohelper.Base, XServiceInfo, XDispatchProvider):
29 implementationName = "com.sun.star.comp.test.deployment.passive_python"
31 serviceNames = ("com.sun.star.test.deployment.passive_python",)
33 def __init__(self, context):
34 self.context = context
36 def getImplementationName(self):
37 return self.implementationName
39 def supportsService(self, ServiceName):
40 return ServiceName in self.serviceNames
42 def getSupportedServiceNames(self):
43 return self.serviceNames
45 def queryDispatch(self, URL, TargetFrame, SearchFlags):
46 return self.context.getValueByName( \
47 "/singletons/com.sun.star.test.deployment.passive_python_singleton")
49 def queryDispatches(self, Requests):
50 tuple( \
51 self.queryDispatch(i.FeatureURL, i.FrameName, i.SearchFlags) \
52 for i in Requests)
54 class Dispatch(unohelper.Base, XServiceInfo, XDispatch):
55 implementationName = \
56 "com.sun.star.comp.test.deployment.passive_python_singleton"
58 serviceNames = ()
60 def __init__(self, context):
61 self.context = context
63 def getImplementationName(self):
64 return self.implementationName
66 def supportsService(self, ServiceName):
67 return ServiceName in self.serviceNames
69 def getSupportedServiceNames(self):
70 return self.serviceNames
72 def dispatch(self, URL, Arguments):
73 smgr = self.context.getServiceManager()
74 box = smgr.createInstanceWithContext( \
75 "com.sun.star.awt.Toolkit", self.context).createMessageBox( \
76 smgr.createInstanceWithContext( \
77 "com.sun.star.frame.Desktop", self.context). \
78 getCurrentFrame().getComponentWindow(), \
79 INFOBOX, BUTTONS_OK, "passive", "python")
80 box.execute();
81 box.dispose();
83 def addStatusListener(self, Control, URL):
84 pass
86 def removeStatusListener(self, Control, URL):
87 pass
89 g_ImplementationHelper = unohelper.ImplementationHelper()
90 g_ImplementationHelper.addImplementation( \
91 Provider, Provider.implementationName, Provider.serviceNames)
92 g_ImplementationHelper.addImplementation( \
93 Dispatch, Dispatch.implementationName, Dispatch.serviceNames)