1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_framework.hxx" 30 31 #include <classes/imagewrapper.hxx> 32 #include <osl/mutex.hxx> 33 #include <vcl/svapp.hxx> 34 #include <vcl/bitmap.hxx> 35 #include <vcl/bitmapex.hxx> 36 #include <tools/stream.hxx> 37 #include <cppuhelper/typeprovider.hxx> 38 39 using namespace com::sun::star::lang; 40 using namespace com::sun::star::uno; 41 42 namespace framework 43 { 44 45 static Sequence< sal_Int8 > impl_getStaticIdentifier() 46 { 47 static sal_uInt8 pGUID[16] = { 0x46, 0xAD, 0x69, 0xFB, 0xA7, 0xBE, 0x44, 0x83, 0xB2, 0xA7, 0xB3, 0xEC, 0x59, 0x4A, 0xB7, 0x00 }; 48 static ::com::sun::star::uno::Sequence< sal_Int8 > seqID((sal_Int8*)pGUID,16) ; 49 return seqID ; 50 } 51 52 53 ImageWrapper::ImageWrapper( const Image& aImage ) : ThreadHelpBase( &Application::GetSolarMutex() ) 54 , m_aImage( aImage ) 55 { 56 } 57 58 59 ImageWrapper::~ImageWrapper() 60 { 61 } 62 63 64 Sequence< sal_Int8 > ImageWrapper::GetUnoTunnelId() 65 { 66 return impl_getStaticIdentifier(); 67 } 68 69 // XBitmap 70 com::sun::star::awt::Size SAL_CALL ImageWrapper::getSize() throw ( RuntimeException ) 71 { 72 vos::OGuard aGuard( Application::GetSolarMutex() ); 73 74 BitmapEx aBitmapEx( m_aImage.GetBitmapEx() ); 75 Size aBitmapSize( aBitmapEx.GetSizePixel() ); 76 77 return com::sun::star::awt::Size( aBitmapSize.Width(), aBitmapSize.Height() ); 78 } 79 80 Sequence< sal_Int8 > SAL_CALL ImageWrapper::getDIB() throw ( RuntimeException ) 81 { 82 vos::OGuard aGuard( Application::GetSolarMutex() ); 83 84 SvMemoryStream aMem; 85 aMem << m_aImage.GetBitmapEx().GetBitmap(); 86 return Sequence< sal_Int8 >( (sal_Int8*) aMem.GetData(), aMem.Tell() ); 87 } 88 89 Sequence< sal_Int8 > SAL_CALL ImageWrapper::getMaskDIB() throw ( RuntimeException ) 90 { 91 vos::OGuard aGuard( Application::GetSolarMutex() ); 92 BitmapEx aBmpEx( m_aImage.GetBitmapEx() ); 93 94 if ( aBmpEx.IsAlpha() ) 95 { 96 SvMemoryStream aMem; 97 aMem << aBmpEx.GetAlpha().GetBitmap(); 98 return Sequence< sal_Int8 >( (sal_Int8*) aMem.GetData(), aMem.Tell() ); 99 } 100 else if ( aBmpEx.IsTransparent() ) 101 { 102 SvMemoryStream aMem; 103 aMem << aBmpEx.GetMask(); 104 return Sequence< sal_Int8 >( (sal_Int8*) aMem.GetData(), aMem.Tell() ); 105 } 106 107 return Sequence< sal_Int8 >(); 108 } 109 110 // XUnoTunnel 111 sal_Int64 SAL_CALL ImageWrapper::getSomething( const Sequence< sal_Int8 >& aIdentifier ) throw ( RuntimeException ) 112 { 113 if ( aIdentifier == impl_getStaticIdentifier() ) 114 return reinterpret_cast< sal_Int64 >( this ); 115 else 116 return 0; 117 } 118 119 } 120 121