1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
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.
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).
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.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_framework.hxx"
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>
39 using namespace com::sun::star::lang
;
40 using namespace com::sun::star::uno
;
45 static Sequence
< sal_Int8
> impl_getStaticIdentifier()
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) ;
53 ImageWrapper::ImageWrapper( const Image
& aImage
) : ThreadHelpBase( &Application::GetSolarMutex() )
59 ImageWrapper::~ImageWrapper()
64 Sequence
< sal_Int8
> ImageWrapper::GetUnoTunnelId()
66 return impl_getStaticIdentifier();
70 com::sun::star::awt::Size SAL_CALL
ImageWrapper::getSize() throw ( RuntimeException
)
72 vos::OGuard
aGuard( Application::GetSolarMutex() );
74 BitmapEx
aBitmapEx( m_aImage
.GetBitmapEx() );
75 Size
aBitmapSize( aBitmapEx
.GetSizePixel() );
77 return com::sun::star::awt::Size( aBitmapSize
.Width(), aBitmapSize
.Height() );
80 Sequence
< sal_Int8
> SAL_CALL
ImageWrapper::getDIB() throw ( RuntimeException
)
82 vos::OGuard
aGuard( Application::GetSolarMutex() );
85 aMem
<< m_aImage
.GetBitmapEx().GetBitmap();
86 return Sequence
< sal_Int8
>( (sal_Int8
*) aMem
.GetData(), aMem
.Tell() );
89 Sequence
< sal_Int8
> SAL_CALL
ImageWrapper::getMaskDIB() throw ( RuntimeException
)
91 vos::OGuard
aGuard( Application::GetSolarMutex() );
92 BitmapEx
aBmpEx( m_aImage
.GetBitmapEx() );
94 if ( aBmpEx
.IsAlpha() )
97 aMem
<< aBmpEx
.GetAlpha().GetBitmap();
98 return Sequence
< sal_Int8
>( (sal_Int8
*) aMem
.GetData(), aMem
.Tell() );
100 else if ( aBmpEx
.IsTransparent() )
103 aMem
<< aBmpEx
.GetMask();
104 return Sequence
< sal_Int8
>( (sal_Int8
*) aMem
.GetData(), aMem
.Tell() );
107 return Sequence
< sal_Int8
>();
111 sal_Int64 SAL_CALL
ImageWrapper::getSomething( const Sequence
< sal_Int8
>& aIdentifier
) throw ( RuntimeException
)
113 if ( aIdentifier
== impl_getStaticIdentifier() )
114 return reinterpret_cast< sal_Int64
>( this );