xref: /aoo41x/main/toolkit/source/awt/vclxbitmap.cxx (revision b0724fc6)
1*b0724fc6SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*b0724fc6SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*b0724fc6SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*b0724fc6SAndrew Rist  * distributed with this work for additional information
6*b0724fc6SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*b0724fc6SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*b0724fc6SAndrew Rist  * "License"); you may not use this file except in compliance
9*b0724fc6SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*b0724fc6SAndrew Rist  *
11*b0724fc6SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*b0724fc6SAndrew Rist  *
13*b0724fc6SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*b0724fc6SAndrew Rist  * software distributed under the License is distributed on an
15*b0724fc6SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*b0724fc6SAndrew Rist  * KIND, either express or implied.  See the License for the
17*b0724fc6SAndrew Rist  * specific language governing permissions and limitations
18*b0724fc6SAndrew Rist  * under the License.
19*b0724fc6SAndrew Rist  *
20*b0724fc6SAndrew Rist  *************************************************************/
21*b0724fc6SAndrew Rist 
22*b0724fc6SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_toolkit.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir 
28cdf0e10cSrcweir #include <toolkit/awt/vclxbitmap.hxx>
29cdf0e10cSrcweir #include <toolkit/helper/macros.hxx>
30cdf0e10cSrcweir #include <cppuhelper/typeprovider.hxx>
31cdf0e10cSrcweir #include <tools/stream.hxx>
32cdf0e10cSrcweir #include <rtl/memory.h>
33cdf0e10cSrcweir #include <rtl/uuid.h>
34cdf0e10cSrcweir 
35cdf0e10cSrcweir //	----------------------------------------------------
36cdf0e10cSrcweir //	class VCLXBitmap
37cdf0e10cSrcweir //	----------------------------------------------------
38cdf0e10cSrcweir 
39cdf0e10cSrcweir // ::com::sun::star::uno::XInterface
40cdf0e10cSrcweir ::com::sun::star::uno::Any VCLXBitmap::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException)
41cdf0e10cSrcweir {
42cdf0e10cSrcweir 	::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
43cdf0e10cSrcweir 										SAL_STATIC_CAST( ::com::sun::star::awt::XBitmap*, this ),
44cdf0e10cSrcweir 										SAL_STATIC_CAST( ::com::sun::star::awt::XDisplayBitmap*, this ),
45cdf0e10cSrcweir 										SAL_STATIC_CAST( ::com::sun::star::lang::XUnoTunnel*, this ),
46cdf0e10cSrcweir 										SAL_STATIC_CAST( ::com::sun::star::lang::XTypeProvider*, this ) );
47cdf0e10cSrcweir 	return (aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType ));
48cdf0e10cSrcweir }
49cdf0e10cSrcweir 
50cdf0e10cSrcweir // ::com::sun::star::lang::XUnoTunnel
51cdf0e10cSrcweir IMPL_XUNOTUNNEL( VCLXBitmap )
52cdf0e10cSrcweir 
53cdf0e10cSrcweir // ::com::sun::star::lang::XTypeProvider
54cdf0e10cSrcweir IMPL_XTYPEPROVIDER_START( VCLXBitmap )
55cdf0e10cSrcweir 	getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XBitmap>* ) NULL ),
56cdf0e10cSrcweir 	getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XDisplayBitmap>* ) NULL )
57cdf0e10cSrcweir IMPL_XTYPEPROVIDER_END
58cdf0e10cSrcweir 
59cdf0e10cSrcweir 
60cdf0e10cSrcweir // ::com::sun::star::awt::XBitmap
61cdf0e10cSrcweir ::com::sun::star::awt::Size VCLXBitmap::getSize() throw(::com::sun::star::uno::RuntimeException)
62cdf0e10cSrcweir {
63cdf0e10cSrcweir 	::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
64cdf0e10cSrcweir 
65cdf0e10cSrcweir 	::com::sun::star::awt::Size aSize( maBitmap.GetSizePixel().Width(), maBitmap.GetSizePixel().Height() );
66cdf0e10cSrcweir 	return aSize;
67cdf0e10cSrcweir }
68cdf0e10cSrcweir 
69cdf0e10cSrcweir ::com::sun::star::uno::Sequence< sal_Int8 > VCLXBitmap::getDIB() throw(::com::sun::star::uno::RuntimeException)
70cdf0e10cSrcweir {
71cdf0e10cSrcweir 	::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
72cdf0e10cSrcweir 
73cdf0e10cSrcweir 	SvMemoryStream aMem;
74cdf0e10cSrcweir 	aMem << maBitmap.GetBitmap();
75cdf0e10cSrcweir 	return ::com::sun::star::uno::Sequence<sal_Int8>( (sal_Int8*) aMem.GetData(), aMem.Tell() );
76cdf0e10cSrcweir }
77cdf0e10cSrcweir 
78cdf0e10cSrcweir ::com::sun::star::uno::Sequence< sal_Int8 > VCLXBitmap::getMaskDIB() throw(::com::sun::star::uno::RuntimeException)
79cdf0e10cSrcweir {
80cdf0e10cSrcweir 	::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
81cdf0e10cSrcweir 
82cdf0e10cSrcweir 	SvMemoryStream aMem;
83cdf0e10cSrcweir 	aMem << maBitmap.GetMask();
84cdf0e10cSrcweir 	return ::com::sun::star::uno::Sequence<sal_Int8>( (sal_Int8*) aMem.GetData(), aMem.Tell() );
85cdf0e10cSrcweir }
86cdf0e10cSrcweir 
87cdf0e10cSrcweir 
88cdf0e10cSrcweir 
89cdf0e10cSrcweir 
90