1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
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.
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).
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.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_embeddedobj.hxx"
31 #include "bitmapcreator.hxx"
33 #include <vcl/bitmapex.hxx>
34 #include <toolkit/helper/vclunohelper.hxx>
35 #include <tools/stream.hxx>
37 using namespace ::com::sun::star
;
39 //-------------------------------------------------------------------------
40 uno::Sequence
< ::rtl::OUString
> SAL_CALL
VCLBitmapCreator::impl_staticGetSupportedServiceNames()
42 uno::Sequence
< ::rtl::OUString
> aRet(2);
43 aRet
[0] = ::rtl::OUString::createFromAscii("com.sun.star.embed.BitmapCreator");
44 aRet
[1] = ::rtl::OUString::createFromAscii("com.sun.star.comp.embed.BitmapCreator");
48 //-------------------------------------------------------------------------
49 ::rtl::OUString SAL_CALL
VCLBitmapCreator::impl_staticGetImplementationName()
51 return ::rtl::OUString::createFromAscii("com.sun.star.comp.embed.BitmapCreator");
54 //-------------------------------------------------------------------------
55 uno::Reference
< uno::XInterface
> SAL_CALL
VCLBitmapCreator::impl_staticCreateSelfInstance(
56 const uno::Reference
< lang::XMultiServiceFactory
>& xServiceManager
)
58 return uno::Reference
< uno::XInterface
>( *new VCLBitmapCreator( xServiceManager
) );
61 //-------------------------------------------------------------------------
63 uno::Reference
< uno::XInterface
> SAL_CALL
VCLBitmapCreator::createInstance()
64 throw ( uno::Exception
,
65 uno::RuntimeException
)
68 uno::Reference
< uno::XInterface
> aResult( VCLUnoHelper::CreateBitmap( aBitmap
), uno::UNO_QUERY
);
73 //-------------------------------------------------------------------------
74 uno::Reference
< uno::XInterface
> SAL_CALL
VCLBitmapCreator::createInstanceWithArguments(
75 const uno::Sequence
< uno::Any
>& aArguments
)
76 throw ( uno::Exception
,
77 uno::RuntimeException
)
79 if ( aArguments
.getLength() != 1 )
80 throw uno::Exception(); // TODO
82 uno::Sequence
< sal_Int8
> aOrigBitmap
;
83 if ( !( aArguments
[0] >>= aOrigBitmap
) )
84 throw uno::Exception(); // TODO
87 SvMemoryStream
aStream( aOrigBitmap
.getArray(), aOrigBitmap
.getLength(), STREAM_READ
);
89 if ( aStream
.GetError() )
90 throw uno::Exception(); // TODO
92 uno::Reference
< uno::XInterface
> aResult( VCLUnoHelper::CreateBitmap( aBitmap
), uno::UNO_QUERY
);
97 //-------------------------------------------------------------------------
98 ::rtl::OUString SAL_CALL
VCLBitmapCreator::getImplementationName()
99 throw ( uno::RuntimeException
)
101 return impl_staticGetImplementationName();
104 //-------------------------------------------------------------------------
105 sal_Bool SAL_CALL
VCLBitmapCreator::supportsService( const ::rtl::OUString
& ServiceName
)
106 throw ( uno::RuntimeException
)
108 uno::Sequence
< ::rtl::OUString
> aSeq
= impl_staticGetSupportedServiceNames();
110 for ( sal_Int32 nInd
= 0; nInd
< aSeq
.getLength(); nInd
++ )
111 if ( ServiceName
.compareTo( aSeq
[nInd
] ) == 0 )
117 //-------------------------------------------------------------------------
118 uno::Sequence
< ::rtl::OUString
> SAL_CALL
VCLBitmapCreator::getSupportedServiceNames()
119 throw ( uno::RuntimeException
)
121 return impl_staticGetSupportedServiceNames();