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