1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_framework.hxx" 26 27 #include <classes/imagewrapper.hxx> 28 #include <osl/mutex.hxx> 29 #include <vcl/svapp.hxx> 30 #include <vcl/bitmap.hxx> 31 #include <vcl/bitmapex.hxx> 32 #include <tools/stream.hxx> 33 #include <cppuhelper/typeprovider.hxx> 34 35 using namespace com::sun::star::lang; 36 using namespace com::sun::star::uno; 37 38 namespace framework 39 { 40 41 static Sequence< sal_Int8 > impl_getStaticIdentifier() 42 { 43 static sal_uInt8 pGUID[16] = { 0x46, 0xAD, 0x69, 0xFB, 0xA7, 0xBE, 0x44, 0x83, 0xB2, 0xA7, 0xB3, 0xEC, 0x59, 0x4A, 0xB7, 0x00 }; 44 static ::com::sun::star::uno::Sequence< sal_Int8 > seqID((sal_Int8*)pGUID,16) ; 45 return seqID ; 46 } 47 48 49 ImageWrapper::ImageWrapper( const Image& aImage ) : ThreadHelpBase( &Application::GetSolarMutex() ) 50 , m_aImage( aImage ) 51 { 52 } 53 54 55 ImageWrapper::~ImageWrapper() 56 { 57 } 58 59 60 Sequence< sal_Int8 > ImageWrapper::GetUnoTunnelId() 61 { 62 return impl_getStaticIdentifier(); 63 } 64 65 // XBitmap 66 com::sun::star::awt::Size SAL_CALL ImageWrapper::getSize() throw ( RuntimeException ) 67 { 68 vos::OGuard aGuard( Application::GetSolarMutex() ); 69 70 BitmapEx aBitmapEx( m_aImage.GetBitmapEx() ); 71 Size aBitmapSize( aBitmapEx.GetSizePixel() ); 72 73 return com::sun::star::awt::Size( aBitmapSize.Width(), aBitmapSize.Height() ); 74 } 75 76 Sequence< sal_Int8 > SAL_CALL ImageWrapper::getDIB() throw ( RuntimeException ) 77 { 78 vos::OGuard aGuard( Application::GetSolarMutex() ); 79 80 SvMemoryStream aMem; 81 aMem << m_aImage.GetBitmapEx().GetBitmap(); 82 return Sequence< sal_Int8 >( (sal_Int8*) aMem.GetData(), aMem.Tell() ); 83 } 84 85 Sequence< sal_Int8 > SAL_CALL ImageWrapper::getMaskDIB() throw ( RuntimeException ) 86 { 87 vos::OGuard aGuard( Application::GetSolarMutex() ); 88 BitmapEx aBmpEx( m_aImage.GetBitmapEx() ); 89 90 if ( aBmpEx.IsAlpha() ) 91 { 92 SvMemoryStream aMem; 93 aMem << aBmpEx.GetAlpha().GetBitmap(); 94 return Sequence< sal_Int8 >( (sal_Int8*) aMem.GetData(), aMem.Tell() ); 95 } 96 else if ( aBmpEx.IsTransparent() ) 97 { 98 SvMemoryStream aMem; 99 aMem << aBmpEx.GetMask(); 100 return Sequence< sal_Int8 >( (sal_Int8*) aMem.GetData(), aMem.Tell() ); 101 } 102 103 return Sequence< sal_Int8 >(); 104 } 105 106 // XUnoTunnel 107 sal_Int64 SAL_CALL ImageWrapper::getSomething( const Sequence< sal_Int8 >& aIdentifier ) throw ( RuntimeException ) 108 { 109 if ( aIdentifier == impl_getStaticIdentifier() ) 110 return reinterpret_cast< sal_Int64 >( this ); 111 else 112 return 0; 113 } 114 115 } 116 117