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 24 #ifndef _LAYOUT_UNO_HXX 25 #define _LAYOUT_UNO_HXX 26 27 #include <cstdio> 28 #include <com/sun/star/lang/XComponent.hpp> 29 #include <com/sun/star/lang/XInitialization.hpp> 30 #include <com/sun/star/lang/XMultiServiceFactory.hpp> 31 32 #include <layout/core/root.hxx> 33 #include <layout/core/factory.hxx> 34 35 #if LAYOUT_WEAK 36 #include <cppuhelper/implbase1.hxx> 37 class UnoBootstrapLayout : public ::cppu::WeakImplHelper1< com::sun::star::lang::XMultiServiceFactory > 38 #else /* !LAYOUT_WEAK */ 39 class UnoBootstrapLayout : public com::sun::star::lang::XMultiServiceFactory 40 #endif /* LAYOUT_WEAK */ 41 { 42 public: 43 com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > mxMSF; UnoBootstrapLayout(com::sun::star::uno::Reference<com::sun::star::lang::XMultiServiceFactory> xMSF)44 UnoBootstrapLayout( com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > xMSF ) 45 : mxMSF( xMSF ) 46 { 47 fprintf( stderr, "UnoBootstrap Layout\n" ); 48 } 49 virtual com::sun::star::uno::Reference< com::sun::star::uno::XInterface > SAL_CALL createInstance(const rtl::OUString & aServiceSpecifier)50 createInstance( const rtl::OUString& aServiceSpecifier ) throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException) 51 { 52 if ( aServiceSpecifier.equalsAscii( "com.sun.star.awt.Layout" ) ) 53 { 54 fprintf( stderr, "UnoBootstrapLayout: create service '%s'\n", 55 rtl::OUStringToOString (aServiceSpecifier, RTL_TEXTENCODING_UTF8 ).getStr() ); 56 return com::sun::star::uno::Reference< com::sun::star::lang::XSingleServiceFactory >( new ::LayoutFactory( this ) ); 57 } 58 else 59 { 60 fprintf( stderr, "UnoBootstrapLayout: create service '%s'\n", 61 rtl::OUStringToOString (aServiceSpecifier, RTL_TEXTENCODING_UTF8 ).getStr() ); 62 try 63 { 64 return mxMSF->createInstance( aServiceSpecifier ); 65 } 66 catch ( const com::sun::star::uno::Exception &rExc ) 67 { 68 rtl::OString aStr( rtl::OUStringToOString( rExc.Message, RTL_TEXTENCODING_ASCII_US ) ); 69 fprintf( stderr, "service construction exception '%s'\n", aStr.getStr()); 70 throw rExc; 71 } 72 } 73 } 74 virtual com::sun::star::uno::Reference< com::sun::star::uno::XInterface > SAL_CALL createInstanceWithArguments(const rtl::OUString & ServiceSpecifier,const com::sun::star::uno::Sequence<com::sun::star::uno::Any> & Arguments)75 createInstanceWithArguments( const rtl::OUString& ServiceSpecifier, const com::sun::star::uno::Sequence< com::sun::star::uno::Any >& Arguments ) throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException) 76 { 77 return mxMSF->createInstanceWithArguments( ServiceSpecifier, Arguments ); 78 } 79 virtual com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getAvailableServiceNames()80 getAvailableServiceNames() throw (com::sun::star::uno::RuntimeException) 81 { 82 return mxMSF->getAvailableServiceNames(); 83 } 84 85 #if !LAYOUT_WEAK 86 // XInterface queryInterface(const::com::sun::star::uno::Type & rType)87 virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) 88 { 89 return mxMSF->queryInterface( rType ); 90 } acquire()91 virtual void SAL_CALL acquire() throw() 92 { 93 mxMSF->acquire(); 94 } release()95 virtual void SAL_CALL release() throw() 96 { 97 mxMSF->release(); 98 } 99 #endif /* !LAYOUT_WEAK */ 100 }; 101 102 #endif /* _LAYOUT_UNO_HXX */ 103