1*50e6b072SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*50e6b072SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*50e6b072SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*50e6b072SAndrew Rist * distributed with this work for additional information 6*50e6b072SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*50e6b072SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*50e6b072SAndrew Rist * "License"); you may not use this file except in compliance 9*50e6b072SAndrew Rist * with the License. You may obtain a copy of the License at 10*50e6b072SAndrew Rist * 11*50e6b072SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*50e6b072SAndrew Rist * 13*50e6b072SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*50e6b072SAndrew Rist * software distributed under the License is distributed on an 15*50e6b072SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*50e6b072SAndrew Rist * KIND, either express or implied. See the License for the 17*50e6b072SAndrew Rist * specific language governing permissions and limitations 18*50e6b072SAndrew Rist * under the License. 19*50e6b072SAndrew Rist * 20*50e6b072SAndrew Rist *************************************************************/ 21*50e6b072SAndrew Rist 22*50e6b072SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef _LAYOUT_UNO_HXX 25cdf0e10cSrcweir #define _LAYOUT_UNO_HXX 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <cstdio> 28cdf0e10cSrcweir #include <com/sun/star/lang/XComponent.hpp> 29cdf0e10cSrcweir #include <com/sun/star/lang/XInitialization.hpp> 30cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp> 31cdf0e10cSrcweir 32cdf0e10cSrcweir #include <layout/core/root.hxx> 33cdf0e10cSrcweir #include <layout/core/factory.hxx> 34cdf0e10cSrcweir 35cdf0e10cSrcweir #if LAYOUT_WEAK 36cdf0e10cSrcweir #include <cppuhelper/implbase1.hxx> 37cdf0e10cSrcweir class UnoBootstrapLayout : public ::cppu::WeakImplHelper1< com::sun::star::lang::XMultiServiceFactory > 38cdf0e10cSrcweir #else /* !LAYOUT_WEAK */ 39cdf0e10cSrcweir class UnoBootstrapLayout : public com::sun::star::lang::XMultiServiceFactory 40cdf0e10cSrcweir #endif /* LAYOUT_WEAK */ 41cdf0e10cSrcweir { 42cdf0e10cSrcweir public: 43cdf0e10cSrcweir com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > mxMSF; UnoBootstrapLayout(com::sun::star::uno::Reference<com::sun::star::lang::XMultiServiceFactory> xMSF)44cdf0e10cSrcweir UnoBootstrapLayout( com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > xMSF ) 45cdf0e10cSrcweir : mxMSF( xMSF ) 46cdf0e10cSrcweir { 47cdf0e10cSrcweir fprintf( stderr, "UnoBootstrap Layout\n" ); 48cdf0e10cSrcweir } 49cdf0e10cSrcweir virtual com::sun::star::uno::Reference< com::sun::star::uno::XInterface > SAL_CALL createInstance(const rtl::OUString & aServiceSpecifier)50cdf0e10cSrcweir createInstance( const rtl::OUString& aServiceSpecifier ) throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException) 51cdf0e10cSrcweir { 52cdf0e10cSrcweir if ( aServiceSpecifier.equalsAscii( "com.sun.star.awt.Layout" ) ) 53cdf0e10cSrcweir { 54cdf0e10cSrcweir fprintf( stderr, "UnoBootstrapLayout: create service '%s'\n", 55cdf0e10cSrcweir rtl::OUStringToOString (aServiceSpecifier, RTL_TEXTENCODING_UTF8 ).getStr() ); 56cdf0e10cSrcweir return com::sun::star::uno::Reference< com::sun::star::lang::XSingleServiceFactory >( new ::LayoutFactory( this ) ); 57cdf0e10cSrcweir } 58cdf0e10cSrcweir else 59cdf0e10cSrcweir { 60cdf0e10cSrcweir fprintf( stderr, "UnoBootstrapLayout: create service '%s'\n", 61cdf0e10cSrcweir rtl::OUStringToOString (aServiceSpecifier, RTL_TEXTENCODING_UTF8 ).getStr() ); 62cdf0e10cSrcweir try 63cdf0e10cSrcweir { 64cdf0e10cSrcweir return mxMSF->createInstance( aServiceSpecifier ); 65cdf0e10cSrcweir } 66cdf0e10cSrcweir catch ( const com::sun::star::uno::Exception &rExc ) 67cdf0e10cSrcweir { 68cdf0e10cSrcweir rtl::OString aStr( rtl::OUStringToOString( rExc.Message, RTL_TEXTENCODING_ASCII_US ) ); 69cdf0e10cSrcweir fprintf( stderr, "service construction exception '%s'\n", aStr.getStr()); 70cdf0e10cSrcweir throw rExc; 71cdf0e10cSrcweir } 72cdf0e10cSrcweir } 73cdf0e10cSrcweir } 74cdf0e10cSrcweir 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)75cdf0e10cSrcweir 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) 76cdf0e10cSrcweir { 77cdf0e10cSrcweir return mxMSF->createInstanceWithArguments( ServiceSpecifier, Arguments ); 78cdf0e10cSrcweir } 79cdf0e10cSrcweir virtual com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getAvailableServiceNames()80cdf0e10cSrcweir getAvailableServiceNames() throw (com::sun::star::uno::RuntimeException) 81cdf0e10cSrcweir { 82cdf0e10cSrcweir return mxMSF->getAvailableServiceNames(); 83cdf0e10cSrcweir } 84cdf0e10cSrcweir 85cdf0e10cSrcweir #if !LAYOUT_WEAK 86cdf0e10cSrcweir // XInterface queryInterface(const::com::sun::star::uno::Type & rType)87cdf0e10cSrcweir virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) 88cdf0e10cSrcweir { 89cdf0e10cSrcweir return mxMSF->queryInterface( rType ); 90cdf0e10cSrcweir } acquire()91cdf0e10cSrcweir virtual void SAL_CALL acquire() throw() 92cdf0e10cSrcweir { 93cdf0e10cSrcweir mxMSF->acquire(); 94cdf0e10cSrcweir } release()95cdf0e10cSrcweir virtual void SAL_CALL release() throw() 96cdf0e10cSrcweir { 97cdf0e10cSrcweir mxMSF->release(); 98cdf0e10cSrcweir } 99cdf0e10cSrcweir #endif /* !LAYOUT_WEAK */ 100cdf0e10cSrcweir }; 101cdf0e10cSrcweir 102cdf0e10cSrcweir #endif /* _LAYOUT_UNO_HXX */ 103