Branch libreoffice-5-0-4
[LibreOffice.git] / bridges / test / testcomp.h
blob75bd05e81e4f32a660ceff34e164157d7a3c5394
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <stdio.h>
22 #include <com/sun/star/bridge/XInstanceProvider.hpp>
23 #include <osl/thread.hxx>
26 void parseCommandLine( char *argv[] ,
27 OUString *pProtocol , OUString *pConnection ,
28 sal_Bool *pbLatency , sal_Bool *pbReverse);
31 Reference< XInterface > createComponent(
32 const OUString &sServiceName,
33 const OUString &sDllName,
34 const Reference < XMultiServiceFactory > & rSMgr );
36 class OInterfaceTest :
37 public ::cppu::OWeakObject,
38 public XInterfaceTest
40 public:
41 OInterfaceTest() {}
42 ~OInterfaceTest() {}
44 public:
45 // XInterface
46 Any SAL_CALL queryInterface( const com::sun::star::uno::Type & aType) throw ( ::com::sun::star::uno::RuntimeException );
47 void SAL_CALL acquire() throw() { OWeakObject::acquire(); }
48 void SAL_CALL release() throw() { OWeakObject::release(); }
50 public:
51 virtual void SAL_CALL setIn( const ::com::sun::star::uno::Reference< ::test::XCallMe >& callback ) throw(::com::sun::star::uno::RuntimeException);
52 virtual void SAL_CALL setInOut( ::com::sun::star::uno::Reference< ::test::XCallMe >& callback ) throw(::com::sun::star::uno::RuntimeException);
53 virtual void SAL_CALL getOut( ::com::sun::star::uno::Reference< ::test::XCallMe >& callback ) throw(::com::sun::star::uno::RuntimeException);
54 virtual ::com::sun::star::uno::Reference< ::test::XCallMe > SAL_CALL get( ) throw(::com::sun::star::uno::RuntimeException);
55 private:
56 void call();
58 private:
59 Reference < XCallMe > m_rCallMe;
63 class OCallMe :
64 public ::cppu::OWeakObject,
65 public XCallMe
67 public:
68 OCallMe() : m_nLastToDos(-1) {}
69 ~OCallMe() {}
71 public:
72 // XInterface
73 Any SAL_CALL queryInterface( const com::sun::star::uno::Type & aType) throw ( ::com::sun::star::uno::RuntimeException );
74 void SAL_CALL acquire()throw() { OWeakObject::acquire(); }
75 void SAL_CALL release()throw() { OWeakObject::release(); }
76 public:
77 // XCallMe
78 virtual void SAL_CALL call( const OUString& s, sal_Int32 nToDo )
79 throw(::com::sun::star::uno::RuntimeException,
80 ::test::TestBridgeException);
81 virtual void SAL_CALL callOneway( const OUString& s, sal_Int32 nToDo )
82 throw(::com::sun::star::uno::RuntimeException);
83 virtual void SAL_CALL drawLine( sal_Int32 x1, sal_Int32 y1 , sal_Int32 x2 , sal_Int32 y2 )
84 throw(::com::sun::star::uno::RuntimeException);
86 virtual OUString SAL_CALL getsAttribute() throw(::com::sun::star::uno::RuntimeException);
87 virtual void SAL_CALL setsAttribute( const OUString& _sattribute ) throw(::com::sun::star::uno::RuntimeException);
88 virtual void SAL_CALL callAgain( const ::com::sun::star::uno::Reference< ::test::XCallMe >& callAgain,
89 sal_Int32 nToCall ) throw(::com::sun::star::uno::RuntimeException);
91 virtual ::test::TestTypes SAL_CALL transport( const ::test::TestTypes& types )
92 throw(::com::sun::star::uno::RuntimeException);
94 ::osl::Mutex m_mutex;
95 OUString m_sAttribute;
96 sal_Int32 m_nLastToDos;
99 class OTestFactory :
100 public ::cppu::OWeakObject,
101 public XTestFactory
103 public:
104 OTestFactory() {}
105 ~OTestFactory() {}
107 public:
108 // XInterface
109 Any SAL_CALL queryInterface( const com::sun::star::uno::Type & aType ) throw ( ::com::sun::star::uno::RuntimeException );
110 void SAL_CALL acquire() throw() { OWeakObject::acquire(); }
111 void SAL_CALL release() throw() { OWeakObject::release(); }
112 public:
113 virtual ::com::sun::star::uno::Reference< ::test::XCallMe > SAL_CALL createCallMe( )
114 throw(::com::sun::star::uno::RuntimeException);
115 virtual ::com::sun::star::uno::Reference< ::test::XInterfaceTest > SAL_CALL createInterfaceTest( )
116 throw(::com::sun::star::uno::RuntimeException);
121 class OInstanceProvider :
122 public ::cppu::OWeakObject,
123 public XInstanceProvider
125 public:
126 OInstanceProvider( ){}
127 OInstanceProvider( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & r ) :
128 m_rSMgr( r )
130 ~OInstanceProvider(){ printf( "instance provider dies\n" );}
131 public:
132 // XInterface
133 Any SAL_CALL queryInterface( const Type & aType)throw ( ::com::sun::star::uno::RuntimeException );
134 void SAL_CALL acquire()throw() { OWeakObject::acquire(); }
135 void SAL_CALL release() throw() { OWeakObject::release(); }
137 public:
138 virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL
139 getInstance( const OUString& sObjectName )
140 throw( ::com::sun::star::container::NoSuchElementException,
141 ::com::sun::star::uno::RuntimeException);
143 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_rSMgr;
146 void testRemote( const Reference< XInterface > &rRemote );
148 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */