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 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_embeddedobj.hxx" 26 27 #include "bitmapcreator.hxx" 28 29 #include <vcl/bitmapex.hxx> 30 #include <toolkit/helper/vclunohelper.hxx> 31 #include <tools/stream.hxx> 32 33 using namespace ::com::sun::star; 34 35 //------------------------------------------------------------------------- impl_staticGetSupportedServiceNames()36uno::Sequence< ::rtl::OUString > SAL_CALL VCLBitmapCreator::impl_staticGetSupportedServiceNames() 37 { 38 uno::Sequence< ::rtl::OUString > aRet(2); 39 aRet[0] = ::rtl::OUString::createFromAscii("com.sun.star.embed.BitmapCreator"); 40 aRet[1] = ::rtl::OUString::createFromAscii("com.sun.star.comp.embed.BitmapCreator"); 41 return aRet; 42 } 43 44 //------------------------------------------------------------------------- impl_staticGetImplementationName()45::rtl::OUString SAL_CALL VCLBitmapCreator::impl_staticGetImplementationName() 46 { 47 return ::rtl::OUString::createFromAscii("com.sun.star.comp.embed.BitmapCreator"); 48 } 49 50 //------------------------------------------------------------------------- impl_staticCreateSelfInstance(const uno::Reference<lang::XMultiServiceFactory> & xServiceManager)51uno::Reference< uno::XInterface > SAL_CALL VCLBitmapCreator::impl_staticCreateSelfInstance( 52 const uno::Reference< lang::XMultiServiceFactory >& xServiceManager ) 53 { 54 return uno::Reference< uno::XInterface >( *new VCLBitmapCreator( xServiceManager ) ); 55 } 56 57 //------------------------------------------------------------------------- 58 createInstance()59uno::Reference< uno::XInterface > SAL_CALL VCLBitmapCreator::createInstance() 60 { 61 BitmapEx aBitmap; 62 uno::Reference< uno::XInterface> aResult( VCLUnoHelper::CreateBitmap( aBitmap ), uno::UNO_QUERY ); 63 64 return aResult; 65 } 66 67 //------------------------------------------------------------------------- createInstanceWithArguments(const uno::Sequence<uno::Any> & aArguments)68uno::Reference< uno::XInterface > SAL_CALL VCLBitmapCreator::createInstanceWithArguments( 69 const uno::Sequence< uno::Any >& aArguments ) 70 { 71 if ( aArguments.getLength() != 1 ) 72 throw uno::Exception(); // TODO 73 74 uno::Sequence< sal_Int8 > aOrigBitmap; 75 if ( !( aArguments[0] >>= aOrigBitmap ) ) 76 throw uno::Exception(); // TODO 77 78 BitmapEx aBitmap; 79 SvMemoryStream aStream( aOrigBitmap.getArray(), aOrigBitmap.getLength(), STREAM_READ ); 80 aStream >> aBitmap; 81 if ( aStream.GetError() ) 82 throw uno::Exception(); // TODO 83 84 uno::Reference< uno::XInterface > aResult( VCLUnoHelper::CreateBitmap( aBitmap ), uno::UNO_QUERY ); 85 86 return aResult; 87 } 88 89 //------------------------------------------------------------------------- getImplementationName()90::rtl::OUString SAL_CALL VCLBitmapCreator::getImplementationName() 91 { 92 return impl_staticGetImplementationName(); 93 } 94 95 //------------------------------------------------------------------------- supportsService(const::rtl::OUString & ServiceName)96sal_Bool SAL_CALL VCLBitmapCreator::supportsService( const ::rtl::OUString& ServiceName ) 97 { 98 uno::Sequence< ::rtl::OUString > aSeq = impl_staticGetSupportedServiceNames(); 99 100 for ( sal_Int32 nInd = 0; nInd < aSeq.getLength(); nInd++ ) 101 if ( ServiceName.compareTo( aSeq[nInd] ) == 0 ) 102 return sal_True; 103 104 return sal_False; 105 } 106 107 //------------------------------------------------------------------------- getSupportedServiceNames()108uno::Sequence< ::rtl::OUString > SAL_CALL VCLBitmapCreator::getSupportedServiceNames() 109 { 110 return impl_staticGetSupportedServiceNames(); 111 } 112