xref: /trunk/main/bridges/test/testcomp.h (revision 5d328669834268fa077da8fd0d9b44cc5ce2793b)
1*9eab2a37SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*9eab2a37SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*9eab2a37SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*9eab2a37SAndrew Rist  * distributed with this work for additional information
6*9eab2a37SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*9eab2a37SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*9eab2a37SAndrew Rist  * "License"); you may not use this file except in compliance
9*9eab2a37SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*9eab2a37SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*9eab2a37SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*9eab2a37SAndrew Rist  * software distributed under the License is distributed on an
15*9eab2a37SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*9eab2a37SAndrew Rist  * KIND, either express or implied.  See the License for the
17*9eab2a37SAndrew Rist  * specific language governing permissions and limitations
18*9eab2a37SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*9eab2a37SAndrew Rist  *************************************************************/
21*9eab2a37SAndrew Rist 
22*9eab2a37SAndrew Rist 
23cdf0e10cSrcweir //#include <com/sun/star/bridge/XServer.hpp>
24cdf0e10cSrcweir //#include <com/sun/star/bridge/XClient.hpp>
25cdf0e10cSrcweir #include <stdio.h>
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <com/sun/star/bridge/XInstanceProvider.hpp>
28cdf0e10cSrcweir //#include <com/sun/star/bridge/XConnectionAdministration.hpp>
29cdf0e10cSrcweir #include <osl/thread.hxx>
30cdf0e10cSrcweir 
31cdf0e10cSrcweir 
32cdf0e10cSrcweir void parseCommandLine( char *argv[] ,
33cdf0e10cSrcweir                        ::rtl::OUString *pProtocol , ::rtl::OUString *pConnection ,
34cdf0e10cSrcweir                        sal_Bool *pbLatency , sal_Bool *pbReverse);
35cdf0e10cSrcweir 
36cdf0e10cSrcweir 
37cdf0e10cSrcweir Reference< XInterface > createComponent(
38cdf0e10cSrcweir     const ::rtl::OUString &sServiceName,
39cdf0e10cSrcweir     const ::rtl::OUString &sDllName,
40cdf0e10cSrcweir     const Reference < XMultiServiceFactory > & rSMgr );
41cdf0e10cSrcweir 
42cdf0e10cSrcweir class OInterfaceTest :
43cdf0e10cSrcweir     public ::cppu::OWeakObject,
44cdf0e10cSrcweir     public XInterfaceTest
45cdf0e10cSrcweir {
46cdf0e10cSrcweir public:
OInterfaceTest()47cdf0e10cSrcweir     OInterfaceTest() {}
~OInterfaceTest()48cdf0e10cSrcweir     ~OInterfaceTest() {}
49cdf0e10cSrcweir 
50cdf0e10cSrcweir public:
51cdf0e10cSrcweir     // XInterface
52cdf0e10cSrcweir     Any SAL_CALL queryInterface( const com::sun::star::uno::Type & aType) throw ( ::com::sun::star::uno::RuntimeException );
acquire()53cdf0e10cSrcweir     void        SAL_CALL acquire() throw()                       { OWeakObject::acquire(); }
release()54cdf0e10cSrcweir     void        SAL_CALL release() throw()                       { OWeakObject::release(); }
55cdf0e10cSrcweir 
56cdf0e10cSrcweir public:
57cdf0e10cSrcweir     virtual void SAL_CALL setIn( const ::com::sun::star::uno::Reference< ::test::XCallMe >& callback ) throw(::com::sun::star::uno::RuntimeException);
58cdf0e10cSrcweir     virtual void SAL_CALL setInOut( ::com::sun::star::uno::Reference< ::test::XCallMe >& callback ) throw(::com::sun::star::uno::RuntimeException);
59cdf0e10cSrcweir     virtual void SAL_CALL getOut( ::com::sun::star::uno::Reference< ::test::XCallMe >& callback ) throw(::com::sun::star::uno::RuntimeException);
60cdf0e10cSrcweir     virtual ::com::sun::star::uno::Reference< ::test::XCallMe > SAL_CALL get(  ) throw(::com::sun::star::uno::RuntimeException);
61cdf0e10cSrcweir private:
62cdf0e10cSrcweir     void call();
63cdf0e10cSrcweir 
64cdf0e10cSrcweir private:
65cdf0e10cSrcweir     Reference < XCallMe > m_rCallMe;
66cdf0e10cSrcweir };
67cdf0e10cSrcweir 
68cdf0e10cSrcweir 
69cdf0e10cSrcweir class OCallMe :
70cdf0e10cSrcweir     public ::cppu::OWeakObject,
71cdf0e10cSrcweir     public XCallMe
72cdf0e10cSrcweir {
73cdf0e10cSrcweir public:
OCallMe()74cdf0e10cSrcweir     OCallMe() : m_nLastToDos(-1) {}
~OCallMe()75cdf0e10cSrcweir     ~OCallMe() {}
76cdf0e10cSrcweir 
77cdf0e10cSrcweir public:
78cdf0e10cSrcweir     // XInterface
79cdf0e10cSrcweir     Any SAL_CALL queryInterface( const com::sun::star::uno::Type & aType) throw ( ::com::sun::star::uno::RuntimeException );
acquire()80cdf0e10cSrcweir     void        SAL_CALL acquire()throw()                        { OWeakObject::acquire(); }
release()81cdf0e10cSrcweir     void        SAL_CALL release()throw()                        { OWeakObject::release(); }
82cdf0e10cSrcweir public:
83cdf0e10cSrcweir     // XCallMe
84cdf0e10cSrcweir     virtual void SAL_CALL call( const ::rtl::OUString& s, sal_Int32 nToDo )
85cdf0e10cSrcweir         throw(::com::sun::star::uno::RuntimeException,
86cdf0e10cSrcweir               ::test::TestBridgeException);
87cdf0e10cSrcweir     virtual void SAL_CALL callOneway( const ::rtl::OUString& s, sal_Int32 nToDo )
88cdf0e10cSrcweir         throw(::com::sun::star::uno::RuntimeException);
89cdf0e10cSrcweir     virtual void SAL_CALL drawLine( sal_Int32 x1, sal_Int32 y1 , sal_Int32 x2 , sal_Int32 y2 )
90cdf0e10cSrcweir         throw(::com::sun::star::uno::RuntimeException);
91cdf0e10cSrcweir 
92cdf0e10cSrcweir     virtual ::rtl::OUString SAL_CALL getsAttribute() throw(::com::sun::star::uno::RuntimeException);
93cdf0e10cSrcweir     virtual void SAL_CALL setsAttribute( const ::rtl::OUString& _sattribute ) throw(::com::sun::star::uno::RuntimeException);
94cdf0e10cSrcweir     virtual void SAL_CALL callAgain( const ::com::sun::star::uno::Reference< ::test::XCallMe >& callAgain,
95cdf0e10cSrcweir                                      sal_Int32 nToCall ) throw(::com::sun::star::uno::RuntimeException);
96cdf0e10cSrcweir 
97cdf0e10cSrcweir     virtual ::test::TestTypes SAL_CALL transport( const ::test::TestTypes& types )
98cdf0e10cSrcweir         throw(::com::sun::star::uno::RuntimeException);
99cdf0e10cSrcweir 
100cdf0e10cSrcweir     ::osl::Mutex m_mutex;
101cdf0e10cSrcweir     ::rtl::OUString m_sAttribute;
102cdf0e10cSrcweir     sal_Int32 m_nLastToDos;
103cdf0e10cSrcweir };
104cdf0e10cSrcweir 
105cdf0e10cSrcweir class OTestFactory :
106cdf0e10cSrcweir     public ::cppu::OWeakObject,
107cdf0e10cSrcweir     public XTestFactory
108cdf0e10cSrcweir {
109cdf0e10cSrcweir public:
OTestFactory()110cdf0e10cSrcweir     OTestFactory() {}
~OTestFactory()111cdf0e10cSrcweir     ~OTestFactory() {}
112cdf0e10cSrcweir 
113cdf0e10cSrcweir public:
114cdf0e10cSrcweir     // XInterface
115cdf0e10cSrcweir     Any         SAL_CALL queryInterface( const  com::sun::star::uno::Type & aType ) throw ( ::com::sun::star::uno::RuntimeException );
acquire()116cdf0e10cSrcweir     void        SAL_CALL acquire() throw()                       { OWeakObject::acquire(); }
release()117cdf0e10cSrcweir     void        SAL_CALL release() throw()                       { OWeakObject::release(); }
118cdf0e10cSrcweir public:
119cdf0e10cSrcweir     virtual ::com::sun::star::uno::Reference< ::test::XCallMe > SAL_CALL createCallMe(  )
120cdf0e10cSrcweir         throw(::com::sun::star::uno::RuntimeException);
121cdf0e10cSrcweir     virtual ::com::sun::star::uno::Reference< ::test::XInterfaceTest > SAL_CALL createInterfaceTest(  )
122cdf0e10cSrcweir         throw(::com::sun::star::uno::RuntimeException);
123cdf0e10cSrcweir 
124cdf0e10cSrcweir };
125cdf0e10cSrcweir 
126cdf0e10cSrcweir 
127cdf0e10cSrcweir class OInstanceProvider :
128cdf0e10cSrcweir     public ::cppu::OWeakObject,
129cdf0e10cSrcweir     public XInstanceProvider
130cdf0e10cSrcweir {
131cdf0e10cSrcweir public:
OInstanceProvider()132cdf0e10cSrcweir     OInstanceProvider( ){}
OInstanceProvider(const::com::sun::star::uno::Reference<::com::sun::star::lang::XMultiServiceFactory> & r)133cdf0e10cSrcweir     OInstanceProvider( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & r ) :
134cdf0e10cSrcweir         m_rSMgr( r )
135cdf0e10cSrcweir         {}
~OInstanceProvider()136cdf0e10cSrcweir     ~OInstanceProvider(){ printf( "instance provider dies\n" );}
137cdf0e10cSrcweir public:
138cdf0e10cSrcweir     // XInterface
139cdf0e10cSrcweir     Any         SAL_CALL queryInterface( const Type & aType)throw ( ::com::sun::star::uno::RuntimeException );
acquire()140cdf0e10cSrcweir     void        SAL_CALL acquire()throw()                        { OWeakObject::acquire(); }
release()141cdf0e10cSrcweir     void        SAL_CALL release() throw()                       { OWeakObject::release(); }
142cdf0e10cSrcweir 
143cdf0e10cSrcweir public:
144cdf0e10cSrcweir     virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL
145cdf0e10cSrcweir            getInstance( const ::rtl::OUString& sObjectName )
146cdf0e10cSrcweir                  throw( ::com::sun::star::container::NoSuchElementException,
147cdf0e10cSrcweir                         ::com::sun::star::uno::RuntimeException);
148cdf0e10cSrcweir 
149cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_rSMgr;
150cdf0e10cSrcweir };
151cdf0e10cSrcweir 
152cdf0e10cSrcweir void testRemote( const Reference< XInterface > &rRemote );
153