update dev300-m58
[ooovba.git] / embeddedobj / test / mtexecutor / bitmapcreator.cxx
blobae5b2d45012a520def44e0773bfa9b0df1bf5481
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: bitmapcreator.cxx,v $
10 * $Revision: 1.5 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_embeddedobj.hxx"
34 #include "bitmapcreator.hxx"
36 #include <vcl/bitmapex.hxx>
37 #include <toolkit/helper/vclunohelper.hxx>
38 #include <tools/stream.hxx>
40 using namespace ::com::sun::star;
42 //-------------------------------------------------------------------------
43 uno::Sequence< ::rtl::OUString > SAL_CALL VCLBitmapCreator::impl_staticGetSupportedServiceNames()
45 uno::Sequence< ::rtl::OUString > aRet(2);
46 aRet[0] = ::rtl::OUString::createFromAscii("com.sun.star.embed.BitmapCreator");
47 aRet[1] = ::rtl::OUString::createFromAscii("com.sun.star.comp.embed.BitmapCreator");
48 return aRet;
51 //-------------------------------------------------------------------------
52 ::rtl::OUString SAL_CALL VCLBitmapCreator::impl_staticGetImplementationName()
54 return ::rtl::OUString::createFromAscii("com.sun.star.comp.embed.BitmapCreator");
57 //-------------------------------------------------------------------------
58 uno::Reference< uno::XInterface > SAL_CALL VCLBitmapCreator::impl_staticCreateSelfInstance(
59 const uno::Reference< lang::XMultiServiceFactory >& xServiceManager )
61 return uno::Reference< uno::XInterface >( *new VCLBitmapCreator( xServiceManager ) );
64 //-------------------------------------------------------------------------
66 uno::Reference< uno::XInterface > SAL_CALL VCLBitmapCreator::createInstance()
67 throw ( uno::Exception,
68 uno::RuntimeException)
70 BitmapEx aBitmap;
71 uno::Reference< uno::XInterface> aResult( VCLUnoHelper::CreateBitmap( aBitmap ), uno::UNO_QUERY );
73 return aResult;
76 //-------------------------------------------------------------------------
77 uno::Reference< uno::XInterface > SAL_CALL VCLBitmapCreator::createInstanceWithArguments(
78 const uno::Sequence< uno::Any >& aArguments )
79 throw ( uno::Exception,
80 uno::RuntimeException)
82 if ( aArguments.getLength() != 1 )
83 throw uno::Exception(); // TODO
85 uno::Sequence< sal_Int8 > aOrigBitmap;
86 if ( !( aArguments[0] >>= aOrigBitmap ) )
87 throw uno::Exception(); // TODO
89 BitmapEx aBitmap;
90 SvMemoryStream aStream( aOrigBitmap.getArray(), aOrigBitmap.getLength(), STREAM_READ );
91 aStream >> aBitmap;
92 if ( aStream.GetError() )
93 throw uno::Exception(); // TODO
95 uno::Reference< uno::XInterface > aResult( VCLUnoHelper::CreateBitmap( aBitmap ), uno::UNO_QUERY );
97 return aResult;
100 //-------------------------------------------------------------------------
101 ::rtl::OUString SAL_CALL VCLBitmapCreator::getImplementationName()
102 throw ( uno::RuntimeException )
104 return impl_staticGetImplementationName();
107 //-------------------------------------------------------------------------
108 sal_Bool SAL_CALL VCLBitmapCreator::supportsService( const ::rtl::OUString& ServiceName )
109 throw ( uno::RuntimeException )
111 uno::Sequence< ::rtl::OUString > aSeq = impl_staticGetSupportedServiceNames();
113 for ( sal_Int32 nInd = 0; nInd < aSeq.getLength(); nInd++ )
114 if ( ServiceName.compareTo( aSeq[nInd] ) == 0 )
115 return sal_True;
117 return sal_False;
120 //-------------------------------------------------------------------------
121 uno::Sequence< ::rtl::OUString > SAL_CALL VCLBitmapCreator::getSupportedServiceNames()
122 throw ( uno::RuntimeException )
124 return impl_staticGetSupportedServiceNames();