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 <vcl/bitmapex.hxx>
23 #include <toolkit/helper/vclunohelper.hxx>
24 #include <tools/stream.hxx>
26 using namespace ::com::sun::star
;
28 //-------------------------------------------------------------------------
29 uno::Sequence
< OUString
> SAL_CALL
VCLBitmapCreator::impl_staticGetSupportedServiceNames()
31 uno::Sequence
< OUString
> aRet(2);
32 aRet
[0] = "com.sun.star.embed.BitmapCreator";
33 aRet
[1] = "com.sun.star.comp.embed.BitmapCreator";
37 //-------------------------------------------------------------------------
38 OUString SAL_CALL
VCLBitmapCreator::impl_staticGetImplementationName()
40 return OUString("com.sun.star.comp.embed.BitmapCreator");
43 //-------------------------------------------------------------------------
44 uno::Reference
< uno::XInterface
> SAL_CALL
VCLBitmapCreator::impl_staticCreateSelfInstance(
45 const uno::Reference
< lang::XMultiServiceFactory
>& xServiceManager
)
47 return uno::Reference
< uno::XInterface
>( *new VCLBitmapCreator( xServiceManager
) );
50 //-------------------------------------------------------------------------
52 uno::Reference
< uno::XInterface
> SAL_CALL
VCLBitmapCreator::createInstance()
53 throw ( uno::Exception
,
54 uno::RuntimeException
)
57 uno::Reference
< uno::XInterface
> aResult( VCLUnoHelper::CreateBitmap( aBitmap
), uno::UNO_QUERY
);
62 //-------------------------------------------------------------------------
63 uno::Reference
< uno::XInterface
> SAL_CALL
VCLBitmapCreator::createInstanceWithArguments(
64 const uno::Sequence
< uno::Any
>& aArguments
)
65 throw ( uno::Exception
,
66 uno::RuntimeException
)
68 if ( aArguments
.getLength() != 1 )
69 throw uno::Exception(); // TODO
71 uno::Sequence
< sal_Int8
> aOrigBitmap
;
72 if ( !( aArguments
[0] >>= aOrigBitmap
) )
73 throw uno::Exception(); // TODO
76 SvMemoryStream
aStream( aOrigBitmap
.getArray(), aOrigBitmap
.getLength(), STREAM_READ
);
78 if ( aStream
.GetError() )
79 throw uno::Exception(); // TODO
81 uno::Reference
< uno::XInterface
> aResult( VCLUnoHelper::CreateBitmap( aBitmap
), uno::UNO_QUERY
);
86 //-------------------------------------------------------------------------
87 OUString SAL_CALL
VCLBitmapCreator::getImplementationName()
88 throw ( uno::RuntimeException
)
90 return impl_staticGetImplementationName();
93 //-------------------------------------------------------------------------
94 sal_Bool SAL_CALL
VCLBitmapCreator::supportsService( const OUString
& ServiceName
)
95 throw ( uno::RuntimeException
)
97 uno::Sequence
< OUString
> aSeq
= impl_staticGetSupportedServiceNames();
99 for ( sal_Int32 nInd
= 0; nInd
< aSeq
.getLength(); nInd
++ )
100 if ( ServiceName
== aSeq
[nInd
] )
106 //-------------------------------------------------------------------------
107 uno::Sequence
< OUString
> SAL_CALL
VCLBitmapCreator::getSupportedServiceNames()
108 throw ( uno::RuntimeException
)
110 return impl_staticGetSupportedServiceNames();
113 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */