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