nss: upgrade to release 3.73
[LibreOffice.git] / embeddedobj / test / mtexecutor / bitmapcreator.cxx
blob458c085ae111cc5e272705085457837a07071bf1
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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;
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";
35 return aRet;
39 OUString SAL_CALL VCLBitmapCreator::impl_staticGetImplementationName()
41 return OUString("com.sun.star.comp.embed.BitmapCreator");
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 ) );
52 uno::Reference< uno::XInterface > SAL_CALL VCLBitmapCreator::createInstance()
53 throw ( uno::Exception,
54 uno::RuntimeException)
56 BitmapEx aBitmap;
57 uno::Reference< uno::XInterface> aResult( VCLUnoHelper::CreateBitmap( aBitmap ), uno::UNO_QUERY );
59 return aResult;
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
75 BitmapEx aBitmap;
76 SvMemoryStream aStream( aOrigBitmap.getArray(), aOrigBitmap.getLength(), StreamMode::READ );
77 aStream >> aBitmap;
78 if ( aStream.GetError() )
79 throw uno::Exception(); // TODO
81 uno::Reference< uno::XInterface > aResult( VCLUnoHelper::CreateBitmap( aBitmap ), uno::UNO_QUERY );
83 return aResult;
87 OUString SAL_CALL VCLBitmapCreator::getImplementationName()
88 throw ( uno::RuntimeException )
90 return impl_staticGetImplementationName();
93 sal_Bool SAL_CALL VCLBitmapCreator::supportsService( const OUString& ServiceName )
94 throw ( uno::RuntimeException )
96 return cppu::supportsService(this, ServiceName);
100 uno::Sequence< OUString > SAL_CALL VCLBitmapCreator::getSupportedServiceNames()
101 throw ( uno::RuntimeException )
103 return impl_staticGetSupportedServiceNames();
106 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */