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