xref: /aoo41x/main/toolkit/source/awt/vclxbitmap.cxx (revision b0724fc6)
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_toolkit.hxx"
26 
27 
28 #include <toolkit/awt/vclxbitmap.hxx>
29 #include <toolkit/helper/macros.hxx>
30 #include <cppuhelper/typeprovider.hxx>
31 #include <tools/stream.hxx>
32 #include <rtl/memory.h>
33 #include <rtl/uuid.h>
34 
35 //	----------------------------------------------------
36 //	class VCLXBitmap
37 //	----------------------------------------------------
38 
39 // ::com::sun::star::uno::XInterface
40 ::com::sun::star::uno::Any VCLXBitmap::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException)
41 {
42 	::com::sun::star::uno::Any aRet = ::cppu::queryInterface( rType,
43 										SAL_STATIC_CAST( ::com::sun::star::awt::XBitmap*, this ),
44 										SAL_STATIC_CAST( ::com::sun::star::awt::XDisplayBitmap*, this ),
45 										SAL_STATIC_CAST( ::com::sun::star::lang::XUnoTunnel*, this ),
46 										SAL_STATIC_CAST( ::com::sun::star::lang::XTypeProvider*, this ) );
47 	return (aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType ));
48 }
49 
50 // ::com::sun::star::lang::XUnoTunnel
51 IMPL_XUNOTUNNEL( VCLXBitmap )
52 
53 // ::com::sun::star::lang::XTypeProvider
54 IMPL_XTYPEPROVIDER_START( VCLXBitmap )
55 	getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XBitmap>* ) NULL ),
56 	getCppuType( ( ::com::sun::star::uno::Reference< ::com::sun::star::awt::XDisplayBitmap>* ) NULL )
57 IMPL_XTYPEPROVIDER_END
58 
59 
60 // ::com::sun::star::awt::XBitmap
61 ::com::sun::star::awt::Size VCLXBitmap::getSize() throw(::com::sun::star::uno::RuntimeException)
62 {
63 	::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
64 
65 	::com::sun::star::awt::Size aSize( maBitmap.GetSizePixel().Width(), maBitmap.GetSizePixel().Height() );
66 	return aSize;
67 }
68 
69 ::com::sun::star::uno::Sequence< sal_Int8 > VCLXBitmap::getDIB() throw(::com::sun::star::uno::RuntimeException)
70 {
71 	::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
72 
73 	SvMemoryStream aMem;
74 	aMem << maBitmap.GetBitmap();
75 	return ::com::sun::star::uno::Sequence<sal_Int8>( (sal_Int8*) aMem.GetData(), aMem.Tell() );
76 }
77 
78 ::com::sun::star::uno::Sequence< sal_Int8 > VCLXBitmap::getMaskDIB() throw(::com::sun::star::uno::RuntimeException)
79 {
80 	::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
81 
82 	SvMemoryStream aMem;
83 	aMem << maBitmap.GetMask();
84 	return ::com::sun::star::uno::Sequence<sal_Int8>( (sal_Int8*) aMem.GetData(), aMem.Tell() );
85 }
86 
87 
88 
89 
90