1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef _LAYOUT_UNO_HXX 29 #define _LAYOUT_UNO_HXX 30 31 #include <cstdio> 32 #include <com/sun/star/lang/XComponent.hpp> 33 #include <com/sun/star/lang/XInitialization.hpp> 34 #include <com/sun/star/lang/XMultiServiceFactory.hpp> 35 36 #include <layout/core/root.hxx> 37 #include <layout/core/factory.hxx> 38 39 #if LAYOUT_WEAK 40 #include <cppuhelper/implbase1.hxx> 41 class UnoBootstrapLayout : public ::cppu::WeakImplHelper1< com::sun::star::lang::XMultiServiceFactory > 42 #else /* !LAYOUT_WEAK */ 43 class UnoBootstrapLayout : public com::sun::star::lang::XMultiServiceFactory 44 #endif /* LAYOUT_WEAK */ 45 { 46 public: 47 com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > mxMSF; 48 UnoBootstrapLayout( com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > xMSF ) 49 : mxMSF( xMSF ) 50 { 51 fprintf( stderr, "UnoBootstrap Layout\n" ); 52 } 53 virtual com::sun::star::uno::Reference< com::sun::star::uno::XInterface > SAL_CALL 54 createInstance( const rtl::OUString& aServiceSpecifier ) throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException) 55 { 56 if ( aServiceSpecifier.equalsAscii( "com.sun.star.awt.Layout" ) ) 57 { 58 fprintf( stderr, "UnoBootstrapLayout: create service '%s'\n", 59 rtl::OUStringToOString (aServiceSpecifier, RTL_TEXTENCODING_UTF8 ).getStr() ); 60 return com::sun::star::uno::Reference< com::sun::star::lang::XSingleServiceFactory >( new ::LayoutFactory( this ) ); 61 } 62 else 63 { 64 fprintf( stderr, "UnoBootstrapLayout: create service '%s'\n", 65 rtl::OUStringToOString (aServiceSpecifier, RTL_TEXTENCODING_UTF8 ).getStr() ); 66 try 67 { 68 return mxMSF->createInstance( aServiceSpecifier ); 69 } 70 catch ( const com::sun::star::uno::Exception &rExc ) 71 { 72 rtl::OString aStr( rtl::OUStringToOString( rExc.Message, RTL_TEXTENCODING_ASCII_US ) ); 73 fprintf( stderr, "service construction exception '%s'\n", aStr.getStr()); 74 throw rExc; 75 } 76 } 77 } 78 virtual com::sun::star::uno::Reference< com::sun::star::uno::XInterface > SAL_CALL 79 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) 80 { 81 return mxMSF->createInstanceWithArguments( ServiceSpecifier, Arguments ); 82 } 83 virtual com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL 84 getAvailableServiceNames() throw (com::sun::star::uno::RuntimeException) 85 { 86 return mxMSF->getAvailableServiceNames(); 87 } 88 89 #if !LAYOUT_WEAK 90 // XInterface 91 virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) 92 { 93 return mxMSF->queryInterface( rType ); 94 } 95 virtual void SAL_CALL acquire() throw() 96 { 97 mxMSF->acquire(); 98 } 99 virtual void SAL_CALL release() throw() 100 { 101 mxMSF->release(); 102 } 103 #endif /* !LAYOUT_WEAK */ 104 }; 105 106 #endif /* _LAYOUT_UNO_HXX */ 107