1#*************************************************************************
2#
3# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4#
5# Copyright 2000, 2010 Oracle and/or its affiliates.
6#
7# OpenOffice.org - a multi-platform office productivity suite
8#
9# This file is part of OpenOffice.org.
10#
11# OpenOffice.org is free software: you can redistribute it and/or modify
12# it under the terms of the GNU Lesser General Public License version 3
13# only, as published by the Free Software Foundation.
14#
15# OpenOffice.org is distributed in the hope that it will be useful,
16# but WITHOUT ANY WARRANTY; without even the implied warranty of
17# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18# GNU Lesser General Public License version 3 for more details
19# (a copy is included in the LICENSE file that accompanied this code).
20#
21# You should have received a copy of the GNU Lesser General Public License
22# version 3 along with OpenOffice.org.  If not, see
23# <http://www.openoffice.org/license.html>
24# for a copy of the LGPLv3 License.
25#
26#***********************************************************************/
27
28import uno
29import unohelper
30
31from com.sun.star.awt import Rectangle
32from com.sun.star.awt.MessageBoxButtons import BUTTONS_OK
33from com.sun.star.frame import XDispatch, XDispatchProvider
34from com.sun.star.lang import XServiceInfo
35
36class Provider(unohelper.Base, XServiceInfo, XDispatchProvider):
37    implementationName = "com.sun.star.comp.test.deployment.passive_python"
38
39    serviceNames = ("com.sun.star.test.deployment.passive_python",)
40
41    def __init__(self, context):
42        self.context = context
43
44    def getImplementationName(self):
45        return self.implementationName
46
47    def supportsService(self, ServiceName):
48        return ServiceName in self.serviceNames
49
50    def getSupportedServiceNames(self):
51        return self.serviceNames
52
53    def queryDispatch(self, URL, TargetFrame, SearchFlags):
54        return self.context.getValueByName( \
55            "/singletons/com.sun.star.test.deployment.passive_python_singleton")
56
57    def queryDispatches(self, Requests):
58        tuple( \
59            self.queryDispatch(i.FeatureURL, i.FrameName, i.SearchFlags) \
60                for i in Requests)
61
62class Dispatch(unohelper.Base, XServiceInfo, XDispatch):
63    implementationName = \
64        "com.sun.star.comp.test.deployment.passive_python_singleton"
65
66    serviceNames = ()
67
68    def __init__(self, context):
69        self.context = context
70
71    def getImplementationName(self):
72        return self.implementationName
73
74    def supportsService(self, ServiceName):
75        return ServiceName in self.serviceNames
76
77    def getSupportedServiceNames(self):
78        return self.serviceNames
79
80    def dispatch(self, URL, Arguments):
81        smgr = self.context.getServiceManager()
82        box = smgr.createInstanceWithContext( \
83            "com.sun.star.awt.Toolkit", self.context).createMessageBox( \
84                smgr.createInstanceWithContext( \
85                    "com.sun.star.frame.Desktop", self.context). \
86                    getCurrentFrame().getComponentWindow(), \
87                Rectangle(), "infobox", BUTTONS_OK, "passive", "python")
88        box.execute();
89        box.dispose();
90
91    def addStatusListener(self, Control, URL):
92        pass
93
94    def removeStatusListener(self, Control, URL):
95        pass
96
97g_ImplementationHelper = unohelper.ImplementationHelper()
98g_ImplementationHelper.addImplementation( \
99    Provider, Provider.implementationName, Provider.serviceNames)
100g_ImplementationHelper.addImplementation( \
101    Dispatch, Dispatch.implementationName, Dispatch.serviceNames)
102