1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20 #include <classes/imagewrapper.hxx>
21 #include <vcl/svapp.hxx>
22 #include <vcl/bitmapex.hxx>
23 #include <vcl/BitmapTools.hxx>
24 #include <tools/stream.hxx>
25 #include <cppuhelper/typeprovider.hxx>
26 #include <vcl/dibtools.hxx>
27
28 using namespace com::sun::star::lang;
29 using namespace com::sun::star::uno;
30
31 namespace framework
32 {
33
impl_getStaticIdentifier()34 static Sequence< sal_Int8 > const & impl_getStaticIdentifier()
35 {
36 static const sal_uInt8 pGUID[16] = { 0x46, 0xAD, 0x69, 0xFB, 0xA7, 0xBE, 0x44, 0x83, 0xB2, 0xA7, 0xB3, 0xEC, 0x59, 0x4A, 0xB7, 0x00 };
37 static css::uno::Sequence< sal_Int8 > seqID(reinterpret_cast<const sal_Int8*>(pGUID), 16);
38 return seqID;
39 }
40
ImageWrapper(const Image & aImage)41 ImageWrapper::ImageWrapper( const Image& aImage ) : m_aImage( aImage )
42 {
43 }
44
~ImageWrapper()45 ImageWrapper::~ImageWrapper()
46 {
47 }
48
GetUnoTunnelId()49 Sequence< sal_Int8 > const & ImageWrapper::GetUnoTunnelId()
50 {
51 return impl_getStaticIdentifier();
52 }
53
54 // XBitmap
getSize()55 css::awt::Size SAL_CALL ImageWrapper::getSize()
56 {
57 SolarMutexGuard aGuard;
58
59 BitmapEx aBitmapEx( m_aImage.GetBitmapEx() );
60 Size aBitmapSize( aBitmapEx.GetSizePixel() );
61
62 return css::awt::Size( aBitmapSize.Width(), aBitmapSize.Height() );
63 }
64
getDIB()65 Sequence< sal_Int8 > SAL_CALL ImageWrapper::getDIB()
66 {
67 SolarMutexGuard aGuard;
68
69 SvMemoryStream aMem;
70 WriteDIB(m_aImage.GetBitmapEx().GetBitmap(), aMem, false, true);
71 return Sequence< sal_Int8 >( static_cast<sal_Int8 const *>(aMem.GetData()), aMem.Tell() );
72 }
73
getMaskDIB()74 Sequence< sal_Int8 > SAL_CALL ImageWrapper::getMaskDIB()
75 {
76 SolarMutexGuard aGuard;
77
78 return vcl::bitmap::GetMaskDIB(m_aImage.GetBitmapEx());
79 }
80
81 // XUnoTunnel
getSomething(const Sequence<sal_Int8> & aIdentifier)82 sal_Int64 SAL_CALL ImageWrapper::getSomething( const Sequence< sal_Int8 >& aIdentifier )
83 {
84 if ( aIdentifier == impl_getStaticIdentifier() )
85 return reinterpret_cast< sal_Int64 >( this );
86 else
87 return 0;
88 }
89
90 }
91
92 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
93