tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / testtools / source / bridgetest / pyuno / samplecomponent.py
blob1af48bb678760e02ba9249b975b27d42abc243db
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 .
18 import uno
19 import unohelper
21 from com.sun.star.lang import IllegalArgumentException,XServiceInfo
22 from com.sun.star.uno import RuntimeException
23 from com.sun.star.beans import UnknownPropertyException
24 from test.testtools.bridgetest import TestData,XRecursiveCall,XBridgeTestBase
26 g_ImplementationHelper = unohelper.ImplementationHelper()
27 g_implName = "org.openoffice.comp.pyuno.PythonTestObject"
29 g_attribs = "RuntimeException", "Bool", "Char", "Byte", "Short", "UShort", \
30 "Long", "ULong", "Hyper", "UHyper", "Float", "Double", "Enum", \
31 "String", "Interface", "Any" , "Sequence" , "Struct"
33 def assign( rData, bBool, cChar, nByte, nShort, nUShort, nLong, nULong, nHyper,\
34 nUHyper, fFloat, fDouble, eEnum, rStr, xTest, rAny ):
35 rData.Bool = bBool
36 rData.Char = cChar
37 rData.Byte = nByte
38 rData.Short = nShort
39 rData.UShort = nUShort
40 rData.Long = nLong
41 rData.ULong = nULong
42 rData.Hyper = nHyper
43 rData.UHyper = nUHyper
44 rData.Float = fFloat
45 rData.Double = fDouble
46 rData.Enum = eEnum
47 rData.String = rStr
48 rData.Interface = xTest
49 rData.Any = rAny
51 class MyRecursiveCall( XRecursiveCall, unohelper.Base ):
52 def callRecursivly( xCall, nToCall ):
53 if nToCall:
54 xCall.callRecursivly( self, nToCall -1 )
56 class SampleUnoComponent( XBridgeTestBase,XServiceInfo ):
57 def __init__(self,ctx):
58 self.__dict__["callid"] = 0
59 self.__dict__["sequenceBroken"] = 0
61 def transportAny( self, value ):
62 return value
64 def raiseException( self, ArgumentPosition, Message, Context ):
65 raise IllegalArgumentException( Message, Context, ArgumentPosition )
67 def raiseRuntimeExceptionOneway(self, Message, Context ):
68 raise RuntimeException( Message, Context )
70 def setValues( self, \
71 bBool, \
72 cChar, \
73 nByte, \
74 nShort, \
75 nUShort, \
76 nLong, \
77 nULong, \
78 nHyper, \
79 nUHyper, \
80 fFloat, \
81 fDouble, \
82 eEnum, \
83 aString, \
84 xInterface, \
85 aAny, \
86 aSequence, \
87 aStruct ):
88 self.__dict__["data"] = TestDataElements( bBool, cChar, nByte, nShort, nUShort, nLong,
89 nULong, nHyper, nUHyper, fFloat, fDouble, eEnum, aStruct, xInterface,
90 aAny, aSequence )
91 self.__dict__["Struct"] = aStruct
93 def setValues2( self, \
94 bBool, \
95 cChar, \
96 nByte, \
97 nShort, \
98 nUShort, \
99 nLong, \
100 nULong,\
101 nHyper, \
102 nUHyper, \
103 fFloat, \
104 fDouble, \
105 eEnum, \
106 aString, \
107 xInterface, \
108 aAny, \
109 aSequence, \
110 aStruct ):
111 self.__dict__["Struct"] = TestData( cChar, nByte, nShort, nUShort, nLong, nULong, nHyper,\
112 nUHyper, fFloat, fDouble, eEnum, aStruct, xInterface,\
113 aAny, aSequence )
114 self.__dict__["Struct"] = aStruct
115 return bBool, cChar, nByte, nShort, nUShort, nLong, nULong, nHyper, nUHyper, nULong, \
116 nHyper, nUHyper, fFloat, fDouble, eEnum, aStruct, xInterface, aAny, \
117 (aSequence[1],aSequence[0]), aStruct
119 def getValues(self, \
120 a, \
121 b, \
122 c, \
123 d, \
124 e, \
125 f, \
126 g, \
127 h, \
128 i, \
129 j, \
130 k, \
131 l, \
132 m, \
134 v = self.__dict__["data"]
135 return self.__dict__["Struct"],v.Bool, v.Char, v.Byte, v.Short, v.UShort, v.Long, \
136 v.ULong, v.Hyper, v.UHyper, v.Float, v.Double, v.Enum, v.String, v.Interface, \
137 v.Any, v.Sequence, self.__dict__["Struct"]
139 def call( self, callid, nWaitMUSEC ):
140 if self.__dict__["callid"] >= callid:
141 self.__dict__["sequenceBroken"] = 1
142 else:
143 self.__dict__["callid"] = callid
145 def callOneway( self, nCallId, nWaitMUSEC ):
146 call( nCallId, nWaitMUSEC )
148 def sequenceOfCallTestPassed():
149 return self.__dict__["sequenceBroken"]
151 def startRecursiveCall( xCall , nToCall ):
152 if nToCall:
153 xCall.callRecursivly( MyRecursiveCall(), nToCall -1 )
155 def checkExistence( self, name ):
156 found = 0
157 for x in g_attribs:
158 if x == name:
159 found = 1
160 break
161 if not found:
162 raise UnknownPropertyException( "Property "+name+" is unknown", self )
164 def __setattr__( self, name, value ):
165 checkExistence( name )
166 self.__dict__[name] = value
168 def __getattr__( self, name ):
169 checkExistence( name )
170 return self.__dict__[name]
172 def getSupportedServices( self ):
173 return g_ImplementationHelper.getSupportedServices(g_implName)
174 def supportsService( self, ServiceName ):
175 return g_ImplementationHelper.supportsService( g_implName, ServiceName )
176 def getImplementationName(self):
177 return g_implName
180 g_ImplementationHelper.addImplementation( \
181 SampleUnoComponent,g_implName,("com.sun.star.test.bridge.PythonTestObject",),)
183 #g_ImplementationEntries = \
184 # unohelper.ImplementationEntry( \
185 # "org.openoffice.comp.SamplePythonComponent", \
186 # ("com.sun.star.test.bridge.PythonTestObject",), \
187 # SampleUnoComponent) \