xref: /aoo42x/main/bridges/test/testcomp.h (revision cdf0e10c)
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 //#include <com/sun/star/bridge/XServer.hpp>
28 //#include <com/sun/star/bridge/XClient.hpp>
29 #include <stdio.h>
30 
31 #include <com/sun/star/bridge/XInstanceProvider.hpp>
32 //#include <com/sun/star/bridge/XConnectionAdministration.hpp>
33 #include <osl/thread.hxx>
34 
35 
36 void parseCommandLine( char *argv[] ,
37 					   ::rtl::OUString *pProtocol , ::rtl::OUString *pConnection ,
38 					   sal_Bool *pbLatency , sal_Bool *pbReverse);
39 
40 
41 Reference< XInterface > createComponent(
42 	const ::rtl::OUString &sServiceName,
43 	const ::rtl::OUString &sDllName,
44 	const Reference < XMultiServiceFactory > & rSMgr );
45 
46 class OInterfaceTest :
47 	public ::cppu::OWeakObject,
48 	public XInterfaceTest
49 {
50 public:
51 	OInterfaceTest() {}
52 	~OInterfaceTest() {}
53 
54 public:
55 	// XInterface
56 	Any	SAL_CALL queryInterface( const com::sun::star::uno::Type & aType) throw ( ::com::sun::star::uno::RuntimeException );
57 	void 		SAL_CALL acquire() throw() 						 { OWeakObject::acquire(); }
58 	void 		SAL_CALL release() throw()						 { OWeakObject::release(); }
59 
60 public:
61     virtual void SAL_CALL setIn( const ::com::sun::star::uno::Reference< ::test::XCallMe >& callback ) throw(::com::sun::star::uno::RuntimeException);
62     virtual void SAL_CALL setInOut( ::com::sun::star::uno::Reference< ::test::XCallMe >& callback ) throw(::com::sun::star::uno::RuntimeException);
63     virtual void SAL_CALL getOut( ::com::sun::star::uno::Reference< ::test::XCallMe >& callback ) throw(::com::sun::star::uno::RuntimeException);
64     virtual ::com::sun::star::uno::Reference< ::test::XCallMe > SAL_CALL get(  ) throw(::com::sun::star::uno::RuntimeException);
65 private:
66 	void call();
67 
68 private:
69 	Reference < XCallMe > m_rCallMe;
70 };
71 
72 
73 class OCallMe :
74 	public ::cppu::OWeakObject,
75 	public XCallMe
76 {
77 public:
78 	OCallMe() : m_nLastToDos(-1) {}
79 	~OCallMe() {}
80 
81 public:
82 	// XInterface
83 	Any	SAL_CALL queryInterface( const com::sun::star::uno::Type & aType) throw ( ::com::sun::star::uno::RuntimeException );
84 	void 		SAL_CALL acquire()throw() 						 { OWeakObject::acquire(); }
85 	void 		SAL_CALL release()throw() 						 { OWeakObject::release(); }
86 public:
87 	// XCallMe
88     virtual void SAL_CALL call( const ::rtl::OUString& s, sal_Int32 nToDo )
89 		throw(::com::sun::star::uno::RuntimeException,
90 			  ::test::TestBridgeException);
91     virtual void SAL_CALL callOneway( const ::rtl::OUString& s, sal_Int32 nToDo )
92 		throw(::com::sun::star::uno::RuntimeException);
93     virtual void SAL_CALL drawLine( sal_Int32 x1, sal_Int32 y1 , sal_Int32 x2 , sal_Int32 y2 )
94 		throw(::com::sun::star::uno::RuntimeException);
95 
96 	virtual ::rtl::OUString SAL_CALL getsAttribute() throw(::com::sun::star::uno::RuntimeException);
97     virtual void SAL_CALL setsAttribute( const ::rtl::OUString& _sattribute ) throw(::com::sun::star::uno::RuntimeException);
98     virtual void SAL_CALL callAgain( const ::com::sun::star::uno::Reference< ::test::XCallMe >& callAgain,
99 									 sal_Int32 nToCall ) throw(::com::sun::star::uno::RuntimeException);
100 
101     virtual ::test::TestTypes SAL_CALL transport( const ::test::TestTypes& types )
102 		throw(::com::sun::star::uno::RuntimeException);
103 
104 	::osl::Mutex m_mutex;
105 	::rtl::OUString m_sAttribute;
106 	sal_Int32 m_nLastToDos;
107 };
108 
109 class OTestFactory :
110 	public ::cppu::OWeakObject,
111 	public XTestFactory
112 {
113 public:
114 	OTestFactory() {}
115 	~OTestFactory() {}
116 
117 public:
118 	// XInterface
119 	Any	        SAL_CALL queryInterface( const  com::sun::star::uno::Type & aType ) throw ( ::com::sun::star::uno::RuntimeException );
120 	void 		SAL_CALL acquire() throw() 						 { OWeakObject::acquire(); }
121 	void 		SAL_CALL release() throw()						 { OWeakObject::release(); }
122 public:
123 	virtual ::com::sun::star::uno::Reference< ::test::XCallMe > SAL_CALL createCallMe(  )
124 		throw(::com::sun::star::uno::RuntimeException);
125     virtual ::com::sun::star::uno::Reference< ::test::XInterfaceTest > SAL_CALL createInterfaceTest(  )
126 		throw(::com::sun::star::uno::RuntimeException);
127 
128 };
129 
130 
131 class OInstanceProvider :
132 	public ::cppu::OWeakObject,
133 	public XInstanceProvider
134 {
135 public:
136 	OInstanceProvider( ){}
137 	OInstanceProvider( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & r ) :
138 		m_rSMgr( r )
139 		{}
140 	~OInstanceProvider(){ printf( "instance provider dies\n" );}
141 public:
142 	// XInterface
143 	Any	        SAL_CALL queryInterface( const Type & aType)throw ( ::com::sun::star::uno::RuntimeException );
144 	void 		SAL_CALL acquire()throw() 						 { OWeakObject::acquire(); }
145 	void 		SAL_CALL release() throw()						 { OWeakObject::release(); }
146 
147 public:
148     virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL
149 	       getInstance( const ::rtl::OUString& sObjectName )
150 		         throw( ::com::sun::star::container::NoSuchElementException,
151 			            ::com::sun::star::uno::RuntimeException);
152 
153 	::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_rSMgr;
154 };
155 
156 void testRemote( const Reference< XInterface > &rRemote );
157