Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*
3 : : * This file is part of the LibreOffice project.
4 : : *
5 : : * This Source Code Form is subject to the terms of the Mozilla Public
6 : : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : : *
9 : : * This file incorporates work covered by the following license notice:
10 : : *
11 : : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : : * contributor license agreements. See the NOTICE file distributed
13 : : * with this work for additional information regarding copyright
14 : : * ownership. The ASF licenses this file to you under the Apache
15 : : * License, Version 2.0 (the "License"); you may not use this file
16 : : * except in compliance with the License. You may obtain a copy of
17 : : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : : */
19 : :
20 : :
21 : : #include <classes/imagewrapper.hxx>
22 : : #include <osl/mutex.hxx>
23 : : #include <vcl/svapp.hxx>
24 : : #include <vcl/bitmap.hxx>
25 : : #include <vcl/bitmapex.hxx>
26 : : #include <tools/stream.hxx>
27 : : #include <cppuhelper/typeprovider.hxx>
28 : :
29 : : using namespace com::sun::star::lang;
30 : : using namespace com::sun::star::uno;
31 : :
32 : : namespace framework
33 : : {
34 : :
35 : 0 : static Sequence< sal_Int8 > impl_getStaticIdentifier()
36 : : {
37 : : static sal_uInt8 pGUID[16] = { 0x46, 0xAD, 0x69, 0xFB, 0xA7, 0xBE, 0x44, 0x83, 0xB2, 0xA7, 0xB3, 0xEC, 0x59, 0x4A, 0xB7, 0x00 };
38 [ # # ][ # # ]: 0 : static ::com::sun::star::uno::Sequence< sal_Int8 > seqID((sal_Int8*)pGUID,16) ;
[ # # ][ # # ]
39 : 0 : return seqID ;
40 : : }
41 : :
42 : :
43 : 0 : ImageWrapper::ImageWrapper( const Image& aImage ) : ThreadHelpBase( &Application::GetSolarMutex() )
44 [ # # ][ # # ]: 0 : , m_aImage( aImage )
45 : : {
46 : 0 : }
47 : :
48 : :
49 [ # # ][ # # ]: 0 : ImageWrapper::~ImageWrapper()
50 : : {
51 [ # # ]: 0 : }
52 : :
53 : :
54 : 0 : Sequence< sal_Int8 > ImageWrapper::GetUnoTunnelId()
55 : : {
56 : 0 : return impl_getStaticIdentifier();
57 : : }
58 : :
59 : : // XBitmap
60 : 0 : com::sun::star::awt::Size SAL_CALL ImageWrapper::getSize() throw ( RuntimeException )
61 : : {
62 [ # # ]: 0 : SolarMutexGuard aGuard;
63 : :
64 [ # # ]: 0 : BitmapEx aBitmapEx( m_aImage.GetBitmapEx() );
65 : 0 : Size aBitmapSize( aBitmapEx.GetSizePixel() );
66 : :
67 [ # # ][ # # ]: 0 : return com::sun::star::awt::Size( aBitmapSize.Width(), aBitmapSize.Height() );
68 : : }
69 : :
70 : 0 : Sequence< sal_Int8 > SAL_CALL ImageWrapper::getDIB() throw ( RuntimeException )
71 : : {
72 [ # # ]: 0 : SolarMutexGuard aGuard;
73 : :
74 [ # # ]: 0 : SvMemoryStream aMem;
75 [ # # ][ # # ]: 0 : aMem << m_aImage.GetBitmapEx().GetBitmap();
[ # # ][ # # ]
[ # # ]
76 [ # # ][ # # ]: 0 : return Sequence< sal_Int8 >( (sal_Int8*) aMem.GetData(), aMem.Tell() );
[ # # ][ # # ]
77 : : }
78 : :
79 : 0 : Sequence< sal_Int8 > SAL_CALL ImageWrapper::getMaskDIB() throw ( RuntimeException )
80 : : {
81 [ # # ]: 0 : SolarMutexGuard aGuard;
82 [ # # ]: 0 : BitmapEx aBmpEx( m_aImage.GetBitmapEx() );
83 : :
84 [ # # ][ # # ]: 0 : if ( aBmpEx.IsAlpha() )
85 : : {
86 [ # # ]: 0 : SvMemoryStream aMem;
87 [ # # ][ # # ]: 0 : aMem << aBmpEx.GetAlpha().GetBitmap();
[ # # ][ # # ]
[ # # ]
88 [ # # ][ # # ]: 0 : return Sequence< sal_Int8 >( (sal_Int8*) aMem.GetData(), aMem.Tell() );
[ # # ]
89 : : }
90 [ # # ][ # # ]: 0 : else if ( aBmpEx.IsTransparent() )
91 : : {
92 [ # # ]: 0 : SvMemoryStream aMem;
93 [ # # ][ # # ]: 0 : aMem << aBmpEx.GetMask();
[ # # ]
94 [ # # ][ # # ]: 0 : return Sequence< sal_Int8 >( (sal_Int8*) aMem.GetData(), aMem.Tell() );
[ # # ]
95 : : }
96 : :
97 [ # # ][ # # ]: 0 : return Sequence< sal_Int8 >();
[ # # ]
98 : : }
99 : :
100 : : // XUnoTunnel
101 : 0 : sal_Int64 SAL_CALL ImageWrapper::getSomething( const Sequence< sal_Int8 >& aIdentifier ) throw ( RuntimeException )
102 : : {
103 [ # # ][ # # ]: 0 : if ( aIdentifier == impl_getStaticIdentifier() )
104 : 0 : return reinterpret_cast< sal_Int64 >( this );
105 : : else
106 : 0 : return 0;
107 : : }
108 : :
109 : : }
110 : :
111 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|