1*cdf0e10cSrcweir#*************************************************************************
2*cdf0e10cSrcweir#
3*cdf0e10cSrcweir# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir#
5*cdf0e10cSrcweir# Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir#
7*cdf0e10cSrcweir# OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir#
9*cdf0e10cSrcweir# This file is part of OpenOffice.org.
10*cdf0e10cSrcweir#
11*cdf0e10cSrcweir# OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir# it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir# only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir#
15*cdf0e10cSrcweir# OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir# but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir# GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir# (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir#
21*cdf0e10cSrcweir# You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir# version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir# <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir# for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir#
26*cdf0e10cSrcweir#*************************************************************************
27*cdf0e10cSrcweirimport uno
28*cdf0e10cSrcweirimport unohelper
29*cdf0e10cSrcweir
30*cdf0e10cSrcweirfrom com.sun.star.lang import IllegalArgumentException,XServiceInfo
31*cdf0e10cSrcweirfrom com.sun.star.uno import RuntimeException
32*cdf0e10cSrcweirfrom com.sun.star.beans import UnknownPropertyException
33*cdf0e10cSrcweirfrom test.testtools.bridgetest import TestData,XRecursiveCall,XBridgeTestBase
34*cdf0e10cSrcweir
35*cdf0e10cSrcweirg_ImplementationHelper = unohelper.ImplementationHelper()
36*cdf0e10cSrcweirg_implName = "org.openoffice.comp.pyuno.PythonTestObject"
37*cdf0e10cSrcweir
38*cdf0e10cSrcweirg_attribs = "RuntimeException", "Bool", "Char", "Byte", "Short", "UShort", \
39*cdf0e10cSrcweir            "Long", "ULong", "Hyper", "UHyper", "Float", "Double", "Enum", \
40*cdf0e10cSrcweir	    "String", "Interface", "Any" , "Sequence" , "Struct"
41*cdf0e10cSrcweir
42*cdf0e10cSrcweirdef assign( rData, bBool, cChar, nByte, nShort, nUShort, nLong, nULong, nHyper,\
43*cdf0e10cSrcweir	      nUHyper, fFloat, fDouble, eEnum, rStr, xTest, rAny  ):
44*cdf0e10cSrcweir    rData.Bool = bBool;
45*cdf0e10cSrcweir    rData.Char = cChar;
46*cdf0e10cSrcweir    rData.Byte = nByte;
47*cdf0e10cSrcweir    rData.Short = nShort;
48*cdf0e10cSrcweir    rData.UShort = nUShort;
49*cdf0e10cSrcweir    rData.Long = nLong;
50*cdf0e10cSrcweir    rData.ULong = nULong;
51*cdf0e10cSrcweir    rData.Hyper = nHyper;
52*cdf0e10cSrcweir    rData.UHyper = nUHyper;
53*cdf0e10cSrcweir    rData.Float = fFloat;
54*cdf0e10cSrcweir    rData.Double = fDouble;
55*cdf0e10cSrcweir    rData.Enum = eEnum;
56*cdf0e10cSrcweir    rData.String = rStr;
57*cdf0e10cSrcweir    rData.Interface = xTest;
58*cdf0e10cSrcweir    rData.Any = rAny;
59*cdf0e10cSrcweir
60*cdf0e10cSrcweirclass MyRecursiveCall( XRecursiveCall, unohelper.Base ):
61*cdf0e10cSrcweir      def callRecursivly( xCall, nToCall ):
62*cdf0e10cSrcweir	  if nToCall:
63*cdf0e10cSrcweir	     xCall.callRecursivly( self, nToCall -1 )
64*cdf0e10cSrcweir
65*cdf0e10cSrcweirclass SampleUnoComponent( XBridgeTestBase,XServiceInfo ):
66*cdf0e10cSrcweir      def __init__(self,ctx):
67*cdf0e10cSrcweir	  self.__dict__["callid"] = 0
68*cdf0e10cSrcweir	  self.__dict__["sequenceBroken"] = 0
69*cdf0e10cSrcweir
70*cdf0e10cSrcweir      def transportAny( self, value ):
71*cdf0e10cSrcweir	  return value
72*cdf0e10cSrcweir
73*cdf0e10cSrcweir      def raiseException( self, ArgumentPosition, Message, Context ):
74*cdf0e10cSrcweir	  raise IllegalArgumentException( Message, Context, ArgumentPosition )
75*cdf0e10cSrcweir
76*cdf0e10cSrcweir      def raiseRuntimeExceptionOneway(self, Message, Context ):
77*cdf0e10cSrcweir	  raise RuntimeException( Message, Context )
78*cdf0e10cSrcweir
79*cdf0e10cSrcweir      def setValues( self, bBool, cChar, nByte, nShort, nUShort, nLong,\
80*cdf0e10cSrcweir		     nULong, nHyper, nUHyper, fFloat, fDouble, eEnum, \
81*cdf0e10cSrcweir		     aString, xInterface, aAny, aSequence, aStruct ):
82*cdf0e10cSrcweir         self.__dict__["data"] = TestDataElements( bBool, cChar, nByte, nShort, nUShort, nLong,
83*cdf0e10cSrcweir	                  nULong, nHyper, nUHyper, fFloat, fDouble, eEnum, aStruct, xInterface,
84*cdf0e10cSrcweir			  aAny, aSequence )
85*cdf0e10cSrcweir         self.__dict__["Struct"] = aStruct
86*cdf0e10cSrcweir
87*cdf0e10cSrcweir      def setValues2( self, bBool, cChar, nByte, nShort, nUShort, nLong, nULong,\
88*cdf0e10cSrcweir		      nHyper, nUHyper, fFloat, fDouble, eEnum,		\
89*cdf0e10cSrcweir		      aString, xInterface, aAny, aSequence, aStruct ):
90*cdf0e10cSrcweir          self.__dict__["Struct"] = TestData( cChar, nByte, nShort, nUShort, nLong, nULong, nHyper,\
91*cdf0e10cSrcweir	                                      nUHyper, fFloat, fDouble, eEnum, aStruct, xInterface,\
92*cdf0e10cSrcweir					      aAny, aSequence )
93*cdf0e10cSrcweir          self.__dict__["Struct"] = aStruct
94*cdf0e10cSrcweir	  return bBool, cChar, nByte, nShort, nUShort, nLong, nULong, nHyper, nUHyper, nULong, \
95*cdf0e10cSrcweir	         nHyper, nUHyper, fFloat, fDouble, eEnum, aStruct, xInterface, aAny,	       \
96*cdf0e10cSrcweir		 (aSequence[1],aSequence[0]), aStruct
97*cdf0e10cSrcweir
98*cdf0e10cSrcweir      def getValues(self, a,b,c,d,e,f,g,h, i,j,k,l,m,n):
99*cdf0e10cSrcweir	  v = self.__dict__["data"]
100*cdf0e10cSrcweir	  return self.__dict__["Struct"],v.Bool, v.Char, v.Byte, v.Short, v.UShort, v.Long,	\
101*cdf0e10cSrcweir	         v.ULong, v.Hyper, v.UHyper, v.Float, v.Double, v.Enum, v.String, v.Interface,	\
102*cdf0e10cSrcweir		 v.Any, v.Sequence, self.__dict__["Struct"]
103*cdf0e10cSrcweir
104*cdf0e10cSrcweir      def call( self, callid, nWaitMUSEC ):
105*cdf0e10cSrcweir	  if self.__dict__["callid"] >= callid:
106*cdf0e10cSrcweir	     self.__dict__["sequenceBroken"] = 1
107*cdf0e10cSrcweir	  else:
108*cdf0e10cSrcweir	     self.__dict__["callid"] = callid
109*cdf0e10cSrcweir
110*cdf0e10cSrcweir      def callOneway( self, nCallId, nWaitMUSEC ):
111*cdf0e10cSrcweir	  call( nCallId, nWaitMUSEC )
112*cdf0e10cSrcweir
113*cdf0e10cSrcweir      def sequenceOfCallTestPassed():
114*cdf0e10cSrcweir	  return self.__dict__["sequenceBroken"]
115*cdf0e10cSrcweir
116*cdf0e10cSrcweir      def startRecursiveCall( xCall , nToCall ):
117*cdf0e10cSrcweir	  if nToCall:
118*cdf0e10cSrcweir	     xCall.callRecursivly( MyRecursiveCall(), nToCall -1 )
119*cdf0e10cSrcweir
120*cdf0e10cSrcweir      def checkExistence( self, name ):
121*cdf0e10cSrcweir	  found = 0
122*cdf0e10cSrcweir	  for x in g_attribs:
123*cdf0e10cSrcweir	      if x == name:
124*cdf0e10cSrcweir		 found = 1
125*cdf0e10cSrcweir		 break
126*cdf0e10cSrcweir	  if not found:
127*cdf0e10cSrcweir	     raise UnknownPropertyException( "Property "+name+" is unknown", self )
128*cdf0e10cSrcweir
129*cdf0e10cSrcweir      def __setattr__( self, name, value ):
130*cdf0e10cSrcweir	  checkExistence( name )
131*cdf0e10cSrcweir	  self.__dict__[name] = value
132*cdf0e10cSrcweir
133*cdf0e10cSrcweir      def __getattr__( self, name ):
134*cdf0e10cSrcweir	  checkExistence( name )
135*cdf0e10cSrcweir	  return self.__dict__[name]
136*cdf0e10cSrcweir
137*cdf0e10cSrcweir      def getSupportedServices( self ):
138*cdf0e10cSrcweir	  return g_ImplementationHelper.getSupportedServices(g_implName)
139*cdf0e10cSrcweir      def supportsService( self, ServiceName ):
140*cdf0e10cSrcweir	  return g_ImplementationHelper.supportsService( g_implName, ServiceName )
141*cdf0e10cSrcweir      def getImplementationName(self):
142*cdf0e10cSrcweir	  return g_implName
143*cdf0e10cSrcweir
144*cdf0e10cSrcweir
145*cdf0e10cSrcweirg_ImplementationHelper.addImplementation( \
146*cdf0e10cSrcweir	SampleUnoComponent,g_implName,("com.sun.star.test.bridge.PythonTestObject",),)
147*cdf0e10cSrcweir
148*cdf0e10cSrcweir#g_ImplementationEntries = \
149*cdf0e10cSrcweir#    unohelper.ImplementationEntry(				\
150*cdf0e10cSrcweir#	      "org.openoffice.comp.SamplePythonComponent",	\
151*cdf0e10cSrcweir#	      ("com.sun.star.test.bridge.PythonTestObject",),	\
152*cdf0e10cSrcweir#	      SampleUnoComponent)				\
153*cdf0e10cSrcweir#	   ,
154*cdf0e10cSrcweir
155