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); 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 ); 58 virtual void SAL_CALL setInOut( ::com::sun::star::uno::Reference< ::test::XCallMe >& callback ); 59 virtual void SAL_CALL getOut( ::com::sun::star::uno::Reference< ::test::XCallMe >& callback ); 60 virtual ::com::sun::star::uno::Reference< ::test::XCallMe > SAL_CALL get( ); 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); 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 virtual void SAL_CALL callOneway( const ::rtl::OUString& s, sal_Int32 nToDo ); 86 virtual void SAL_CALL drawLine( sal_Int32 x1, sal_Int32 y1 , sal_Int32 x2 , sal_Int32 y2 ); 87 88 virtual ::rtl::OUString SAL_CALL getsAttribute(); 89 virtual void SAL_CALL setsAttribute( const ::rtl::OUString& _sattribute ); 90 virtual void SAL_CALL callAgain( const ::com::sun::star::uno::Reference< ::test::XCallMe >& callAgain, 91 sal_Int32 nToCall ); 92 93 virtual ::test::TestTypes SAL_CALL transport( const ::test::TestTypes& types ); 94 95 ::osl::Mutex m_mutex; 96 ::rtl::OUString m_sAttribute; 97 sal_Int32 m_nLastToDos; 98 }; 99 100 class OTestFactory : 101 public ::cppu::OWeakObject, 102 public XTestFactory 103 { 104 public: OTestFactory()105 OTestFactory() {} ~OTestFactory()106 ~OTestFactory() {} 107 108 public: 109 // XInterface 110 Any SAL_CALL queryInterface( const com::sun::star::uno::Type & aType ); acquire()111 void SAL_CALL acquire() throw() { OWeakObject::acquire(); } release()112 void SAL_CALL release() throw() { OWeakObject::release(); } 113 public: 114 virtual ::com::sun::star::uno::Reference< ::test::XCallMe > SAL_CALL createCallMe( ); 115 virtual ::com::sun::star::uno::Reference< ::test::XInterfaceTest > SAL_CALL createInterfaceTest( ); 116 117 }; 118 119 120 class OInstanceProvider : 121 public ::cppu::OWeakObject, 122 public XInstanceProvider 123 { 124 public: OInstanceProvider()125 OInstanceProvider( ){} OInstanceProvider(const::com::sun::star::uno::Reference<::com::sun::star::lang::XMultiServiceFactory> & r)126 OInstanceProvider( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & r ) : 127 m_rSMgr( r ) 128 {} ~OInstanceProvider()129 ~OInstanceProvider(){ printf( "instance provider dies\n" );} 130 public: 131 // XInterface 132 Any SAL_CALL queryInterface( const Type & aType); acquire()133 void SAL_CALL acquire()throw() { OWeakObject::acquire(); } release()134 void SAL_CALL release() throw() { OWeakObject::release(); } 135 136 public: 137 virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL 138 getInstance( const ::rtl::OUString& sObjectName ); 139 140 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_rSMgr; 141 }; 142 143 void testRemote( const Reference< XInterface > &rRemote ); 144