1*bfd08df8SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*bfd08df8SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*bfd08df8SAndrew Rist * or more contributor license agreements. See the NOTICE file
5*bfd08df8SAndrew Rist * distributed with this work for additional information
6*bfd08df8SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*bfd08df8SAndrew Rist * to you under the Apache License, Version 2.0 (the
8*bfd08df8SAndrew Rist * "License"); you may not use this file except in compliance
9*bfd08df8SAndrew Rist * with the License. You may obtain a copy of the License at
10*bfd08df8SAndrew Rist *
11*bfd08df8SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*bfd08df8SAndrew Rist *
13*bfd08df8SAndrew Rist * Unless required by applicable law or agreed to in writing,
14*bfd08df8SAndrew Rist * software distributed under the License is distributed on an
15*bfd08df8SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*bfd08df8SAndrew Rist * KIND, either express or implied. See the License for the
17*bfd08df8SAndrew Rist * specific language governing permissions and limitations
18*bfd08df8SAndrew Rist * under the License.
19*bfd08df8SAndrew Rist *
20*bfd08df8SAndrew Rist *************************************************************/
21*bfd08df8SAndrew Rist
22*bfd08df8SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_embeddedobj.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include "bitmapcreator.hxx"
28cdf0e10cSrcweir
29cdf0e10cSrcweir #include <vcl/bitmapex.hxx>
30cdf0e10cSrcweir #include <toolkit/helper/vclunohelper.hxx>
31cdf0e10cSrcweir #include <tools/stream.hxx>
32cdf0e10cSrcweir
33cdf0e10cSrcweir using namespace ::com::sun::star;
34cdf0e10cSrcweir
35cdf0e10cSrcweir //-------------------------------------------------------------------------
impl_staticGetSupportedServiceNames()36cdf0e10cSrcweir uno::Sequence< ::rtl::OUString > SAL_CALL VCLBitmapCreator::impl_staticGetSupportedServiceNames()
37cdf0e10cSrcweir {
38cdf0e10cSrcweir uno::Sequence< ::rtl::OUString > aRet(2);
39cdf0e10cSrcweir aRet[0] = ::rtl::OUString::createFromAscii("com.sun.star.embed.BitmapCreator");
40cdf0e10cSrcweir aRet[1] = ::rtl::OUString::createFromAscii("com.sun.star.comp.embed.BitmapCreator");
41cdf0e10cSrcweir return aRet;
42cdf0e10cSrcweir }
43cdf0e10cSrcweir
44cdf0e10cSrcweir //-------------------------------------------------------------------------
impl_staticGetImplementationName()45cdf0e10cSrcweir ::rtl::OUString SAL_CALL VCLBitmapCreator::impl_staticGetImplementationName()
46cdf0e10cSrcweir {
47cdf0e10cSrcweir return ::rtl::OUString::createFromAscii("com.sun.star.comp.embed.BitmapCreator");
48cdf0e10cSrcweir }
49cdf0e10cSrcweir
50cdf0e10cSrcweir //-------------------------------------------------------------------------
impl_staticCreateSelfInstance(const uno::Reference<lang::XMultiServiceFactory> & xServiceManager)51cdf0e10cSrcweir uno::Reference< uno::XInterface > SAL_CALL VCLBitmapCreator::impl_staticCreateSelfInstance(
52cdf0e10cSrcweir const uno::Reference< lang::XMultiServiceFactory >& xServiceManager )
53cdf0e10cSrcweir {
54cdf0e10cSrcweir return uno::Reference< uno::XInterface >( *new VCLBitmapCreator( xServiceManager ) );
55cdf0e10cSrcweir }
56cdf0e10cSrcweir
57cdf0e10cSrcweir //-------------------------------------------------------------------------
58cdf0e10cSrcweir
createInstance()59cdf0e10cSrcweir uno::Reference< uno::XInterface > SAL_CALL VCLBitmapCreator::createInstance()
60cdf0e10cSrcweir throw ( uno::Exception,
61cdf0e10cSrcweir uno::RuntimeException)
62cdf0e10cSrcweir {
63cdf0e10cSrcweir BitmapEx aBitmap;
64cdf0e10cSrcweir uno::Reference< uno::XInterface> aResult( VCLUnoHelper::CreateBitmap( aBitmap ), uno::UNO_QUERY );
65cdf0e10cSrcweir
66cdf0e10cSrcweir return aResult;
67cdf0e10cSrcweir }
68cdf0e10cSrcweir
69cdf0e10cSrcweir //-------------------------------------------------------------------------
createInstanceWithArguments(const uno::Sequence<uno::Any> & aArguments)70cdf0e10cSrcweir uno::Reference< uno::XInterface > SAL_CALL VCLBitmapCreator::createInstanceWithArguments(
71cdf0e10cSrcweir const uno::Sequence< uno::Any >& aArguments )
72cdf0e10cSrcweir throw ( uno::Exception,
73cdf0e10cSrcweir uno::RuntimeException)
74cdf0e10cSrcweir {
75cdf0e10cSrcweir if ( aArguments.getLength() != 1 )
76cdf0e10cSrcweir throw uno::Exception(); // TODO
77cdf0e10cSrcweir
78cdf0e10cSrcweir uno::Sequence< sal_Int8 > aOrigBitmap;
79cdf0e10cSrcweir if ( !( aArguments[0] >>= aOrigBitmap ) )
80cdf0e10cSrcweir throw uno::Exception(); // TODO
81cdf0e10cSrcweir
82cdf0e10cSrcweir BitmapEx aBitmap;
83cdf0e10cSrcweir SvMemoryStream aStream( aOrigBitmap.getArray(), aOrigBitmap.getLength(), STREAM_READ );
84cdf0e10cSrcweir aStream >> aBitmap;
85cdf0e10cSrcweir if ( aStream.GetError() )
86cdf0e10cSrcweir throw uno::Exception(); // TODO
87cdf0e10cSrcweir
88cdf0e10cSrcweir uno::Reference< uno::XInterface > aResult( VCLUnoHelper::CreateBitmap( aBitmap ), uno::UNO_QUERY );
89cdf0e10cSrcweir
90cdf0e10cSrcweir return aResult;
91cdf0e10cSrcweir }
92cdf0e10cSrcweir
93cdf0e10cSrcweir //-------------------------------------------------------------------------
getImplementationName()94cdf0e10cSrcweir ::rtl::OUString SAL_CALL VCLBitmapCreator::getImplementationName()
95cdf0e10cSrcweir throw ( uno::RuntimeException )
96cdf0e10cSrcweir {
97cdf0e10cSrcweir return impl_staticGetImplementationName();
98cdf0e10cSrcweir }
99cdf0e10cSrcweir
100cdf0e10cSrcweir //-------------------------------------------------------------------------
supportsService(const::rtl::OUString & ServiceName)101cdf0e10cSrcweir sal_Bool SAL_CALL VCLBitmapCreator::supportsService( const ::rtl::OUString& ServiceName )
102cdf0e10cSrcweir throw ( uno::RuntimeException )
103cdf0e10cSrcweir {
104cdf0e10cSrcweir uno::Sequence< ::rtl::OUString > aSeq = impl_staticGetSupportedServiceNames();
105cdf0e10cSrcweir
106cdf0e10cSrcweir for ( sal_Int32 nInd = 0; nInd < aSeq.getLength(); nInd++ )
107cdf0e10cSrcweir if ( ServiceName.compareTo( aSeq[nInd] ) == 0 )
108cdf0e10cSrcweir return sal_True;
109cdf0e10cSrcweir
110cdf0e10cSrcweir return sal_False;
111cdf0e10cSrcweir }
112cdf0e10cSrcweir
113cdf0e10cSrcweir //-------------------------------------------------------------------------
getSupportedServiceNames()114cdf0e10cSrcweir uno::Sequence< ::rtl::OUString > SAL_CALL VCLBitmapCreator::getSupportedServiceNames()
115cdf0e10cSrcweir throw ( uno::RuntimeException )
116cdf0e10cSrcweir {
117cdf0e10cSrcweir return impl_staticGetSupportedServiceNames();
118cdf0e10cSrcweir }
119cdf0e10cSrcweir
120