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 .
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
27 from com
.sun
.star
.registry
import InvalidRegistryException
29 class Provider(unohelper
.Base
, XServiceInfo
, XDispatchProvider
):
30 implementationName
= "com.sun.star.comp.test.deployment.active_python"
32 serviceNames
= ("com.sun.star.test.deployment.active_python",)
34 def __init__(self
, context
):
35 self
.context
= context
37 def getImplementationName(self
):
38 return self
.implementationName
40 def supportsService(self
, ServiceName
):
41 return ServiceName
in self
.serviceNames
43 def getSupportedServiceNames(self
):
44 return self
.serviceNames
46 def queryDispatch(self
, URL
, TargetFrame
, SearchFlags
):
47 return self
.context
.getValueByName( \
48 "/singletons/com.sun.star.test.deployment.active_python_singleton")
50 def queryDispatches(self
, Requests
):
52 self
.queryDispatch(i
.FeatureURL
, i
.FrameName
, i
.SearchFlags
) \
55 class Dispatch(unohelper
.Base
, XServiceInfo
, XDispatch
):
56 implementationName
= \
57 "com.sun.star.comp.test.deployment.active_python_singleton"
61 def __init__(self
, context
):
62 self
.context
= context
64 def getImplementationName(self
):
65 return self
.implementationName
67 def supportsService(self
, ServiceName
):
68 return ServiceName
in self
.serviceNames
70 def getSupportedServiceNames(self
):
71 return self
.serviceNames
73 def dispatch(self
, URL
, Arguments
):
74 smgr
= self
.context
.getServiceManager()
75 box
= smgr
.createInstanceWithContext( \
76 "com.sun.star.awt.Toolkit", self
.context
).createMessageBox( \
77 smgr
.createInstanceWithContext( \
78 "com.sun.star.frame.Desktop", self
.context
). \
79 getCurrentFrame().getComponentWindow(), \
80 INFOBOX
, BUTTONS_OK
, "active", "python")
84 def addStatusListener(self
, Control
, URL
):
87 def removeStatusListener(self
, Control
, URL
):
90 def getComponentFactory(implementationName
, smgr
, regKey
):
91 if implementationName
== Provider
.implementationName
:
92 return unohelper
.createSingleServiceFactory( \
93 Provider
, Provider
.implementationName
, Provider
.serviceNames
)
94 elif implementationName
== Dispatch
.implementationName
:
95 return unohelper
.createSingleServiceFactory( \
96 Dispatch
, Dispatch
.implementationName
, Dispatch
.serviceNames
)
100 def writeRegistryInfo(smgr
, regKey
):
102 for i
in (Provider
, Dispatch
):
103 key
= regKey
.createKey("/" + i
.implementationName
+ "/UNO")
104 for j
in i
.serviceNames
:
105 key
.createKey("/SERVICES/" + j
);
107 "/" + Dispatch
.implementationName
+ "/UNO/SINGLETONS/" \
108 "com.sun.star.test.deployment.active_python_singleton"). \
109 setStringValue(Dispatch
.implementationName
)
110 except InvalidRegistryException
: