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 .
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
):
39 rData
.UShort
= nUShort
43 rData
.UHyper
= nUHyper
45 rData
.Double
= fDouble
48 rData
.Interface
= xTest
51 class MyRecursiveCall( XRecursiveCall
, unohelper
.Base
):
52 def callRecursivly( xCall
, 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
):
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
, \
88 self
.__dict
__["data"] = TestDataElements( bBool
, cChar
, nByte
, nShort
, nUShort
, nLong
,
89 nULong
, nHyper
, nUHyper
, fFloat
, fDouble
, eEnum
, aStruct
, xInterface
,
91 self
.__dict
__["Struct"] = aStruct
93 def setValues2( self
, \
111 self
.__dict
__["Struct"] = TestData( cChar
, nByte
, nShort
, nUShort
, nLong
, nULong
, nHyper
,\
112 nUHyper
, fFloat
, fDouble
, eEnum
, aStruct
, xInterface
,\
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
, \
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
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
):
153 xCall
.callRecursivly( MyRecursiveCall(), nToCall
-1 )
155 def checkExistence( self
, name
):
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
):
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) \