Update ooo320-m1
[ooovba.git] / framework / source / classes / imagewrapper.cxx
blob7e001a9e4180be304e368f8dac6b5044247c3ded
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: imagewrapper.cxx,v $
10 * $Revision: 1.9 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_framework.hxx"
34 #include <classes/imagewrapper.hxx>
35 #include <osl/mutex.hxx>
36 #include <vcl/svapp.hxx>
37 #include <vcl/bitmap.hxx>
38 #include <vcl/bitmapex.hxx>
39 #include <tools/stream.hxx>
40 #include <cppuhelper/typeprovider.hxx>
42 using namespace com::sun::star::lang;
43 using namespace com::sun::star::uno;
45 namespace framework
48 static Sequence< sal_Int8 > impl_getStaticIdentifier()
50 static sal_uInt8 pGUID[16] = { 0x46, 0xAD, 0x69, 0xFB, 0xA7, 0xBE, 0x44, 0x83, 0xB2, 0xA7, 0xB3, 0xEC, 0x59, 0x4A, 0xB7, 0x00 };
51 static ::com::sun::star::uno::Sequence< sal_Int8 > seqID((sal_Int8*)pGUID,16) ;
52 return seqID ;
56 ImageWrapper::ImageWrapper( const Image& aImage ) : ThreadHelpBase( &Application::GetSolarMutex() )
57 , m_aImage( aImage )
62 ImageWrapper::~ImageWrapper()
67 Sequence< sal_Int8 > ImageWrapper::GetUnoTunnelId()
69 return impl_getStaticIdentifier();
72 // XBitmap
73 com::sun::star::awt::Size SAL_CALL ImageWrapper::getSize() throw ( RuntimeException )
75 vos::OGuard aGuard( Application::GetSolarMutex() );
77 BitmapEx aBitmapEx( m_aImage.GetBitmapEx() );
78 Size aBitmapSize( aBitmapEx.GetSizePixel() );
80 return com::sun::star::awt::Size( aBitmapSize.Width(), aBitmapSize.Height() );
83 Sequence< sal_Int8 > SAL_CALL ImageWrapper::getDIB() throw ( RuntimeException )
85 vos::OGuard aGuard( Application::GetSolarMutex() );
87 SvMemoryStream aMem;
88 aMem << m_aImage.GetBitmapEx().GetBitmap();
89 return Sequence< sal_Int8 >( (sal_Int8*) aMem.GetData(), aMem.Tell() );
92 Sequence< sal_Int8 > SAL_CALL ImageWrapper::getMaskDIB() throw ( RuntimeException )
94 vos::OGuard aGuard( Application::GetSolarMutex() );
95 BitmapEx aBmpEx( m_aImage.GetBitmapEx() );
97 if ( aBmpEx.IsAlpha() )
99 SvMemoryStream aMem;
100 aMem << aBmpEx.GetAlpha().GetBitmap();
101 return Sequence< sal_Int8 >( (sal_Int8*) aMem.GetData(), aMem.Tell() );
103 else if ( aBmpEx.IsTransparent() )
105 SvMemoryStream aMem;
106 aMem << aBmpEx.GetMask();
107 return Sequence< sal_Int8 >( (sal_Int8*) aMem.GetData(), aMem.Tell() );
110 return Sequence< sal_Int8 >();
113 // XUnoTunnel
114 sal_Int64 SAL_CALL ImageWrapper::getSomething( const Sequence< sal_Int8 >& aIdentifier ) throw ( RuntimeException )
116 if ( aIdentifier == impl_getStaticIdentifier() )
117 return reinterpret_cast< sal_Int64 >( this );
118 else
119 return 0;