1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "bitmapcreator.hxx"
22 #include <cppuhelper/supportsservice.hxx>
23 #include <vcl/bitmapex.hxx>
24 #include <toolkit/helper/vclunohelper.hxx>
25 #include <tools/stream.hxx>
27 using namespace ::com::sun::star
;
29 //-------------------------------------------------------------------------
30 uno::Sequence
< OUString
> SAL_CALL
VCLBitmapCreator::impl_staticGetSupportedServiceNames()
32 uno::Sequence
< OUString
> aRet(2);
33 aRet
[0] = "com.sun.star.embed.BitmapCreator";
34 aRet
[1] = "com.sun.star.comp.embed.BitmapCreator";
38 //-------------------------------------------------------------------------
39 OUString SAL_CALL
VCLBitmapCreator::impl_staticGetImplementationName()
41 return OUString("com.sun.star.comp.embed.BitmapCreator");
44 //-------------------------------------------------------------------------
45 uno::Reference
< uno::XInterface
> SAL_CALL
VCLBitmapCreator::impl_staticCreateSelfInstance(
46 const uno::Reference
< lang::XMultiServiceFactory
>& xServiceManager
)
48 return uno::Reference
< uno::XInterface
>( *new VCLBitmapCreator( xServiceManager
) );
51 //-------------------------------------------------------------------------
53 uno::Reference
< uno::XInterface
> SAL_CALL
VCLBitmapCreator::createInstance()
54 throw ( uno::Exception
,
55 uno::RuntimeException
)
58 uno::Reference
< uno::XInterface
> aResult( VCLUnoHelper::CreateBitmap( aBitmap
), uno::UNO_QUERY
);
63 //-------------------------------------------------------------------------
64 uno::Reference
< uno::XInterface
> SAL_CALL
VCLBitmapCreator::createInstanceWithArguments(
65 const uno::Sequence
< uno::Any
>& aArguments
)
66 throw ( uno::Exception
,
67 uno::RuntimeException
)
69 if ( aArguments
.getLength() != 1 )
70 throw uno::Exception(); // TODO
72 uno::Sequence
< sal_Int8
> aOrigBitmap
;
73 if ( !( aArguments
[0] >>= aOrigBitmap
) )
74 throw uno::Exception(); // TODO
77 SvMemoryStream
aStream( aOrigBitmap
.getArray(), aOrigBitmap
.getLength(), STREAM_READ
);
79 if ( aStream
.GetError() )
80 throw uno::Exception(); // TODO
82 uno::Reference
< uno::XInterface
> aResult( VCLUnoHelper::CreateBitmap( aBitmap
), uno::UNO_QUERY
);
87 //-------------------------------------------------------------------------
88 OUString SAL_CALL
VCLBitmapCreator::getImplementationName()
89 throw ( uno::RuntimeException
)
91 return impl_staticGetImplementationName();
94 sal_Bool SAL_CALL
VCLBitmapCreator::supportsService( const OUString
& ServiceName
)
95 throw ( uno::RuntimeException
)
97 return cppu::supportsService(this, ServiceName
);
100 //-------------------------------------------------------------------------
101 uno::Sequence
< OUString
> SAL_CALL
VCLBitmapCreator::getSupportedServiceNames()
102 throw ( uno::RuntimeException
)
104 return impl_staticGetSupportedServiceNames();
107 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */