Coverage Report

Created: 2025-11-16 09:57

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/cppcanvas/source/wrapper/implbitmap.cxx
Line
Count
Source
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 "implbitmap.hxx"
22
#include "implbitmapcanvas.hxx"
23
24
#include <osl/diagnose.h>
25
26
27
using namespace ::com::sun::star;
28
29
namespace cppcanvas::internal
30
{
31
32
        ImplBitmap::ImplBitmap( const CanvasSharedPtr&                      rParentCanvas,
33
                                const uno::Reference< rendering::XBitmap >& rBitmap ) :
34
0
            CanvasGraphicHelper( rParentCanvas ),
35
0
            mxBitmap( rBitmap )
36
0
        {
37
0
            OSL_ENSURE( mxBitmap.is(), "ImplBitmap::ImplBitmap: no valid bitmap" );
38
39
0
            uno::Reference< rendering::XBitmapCanvas > xBitmapCanvas( rBitmap,
40
0
                                                                      uno::UNO_QUERY );
41
0
            if( xBitmapCanvas.is() )
42
0
                mpBitmapCanvas = std::make_shared<ImplBitmapCanvas>(
43
0
                                          uno::Reference< rendering::XBitmapCanvas >(rBitmap,
44
0
                                                                                     uno::UNO_QUERY) );
45
0
        }
Unexecuted instantiation: cppcanvas::internal::ImplBitmap::ImplBitmap(std::__1::shared_ptr<cppcanvas::Canvas> const&, com::sun::star::uno::Reference<com::sun::star::rendering::XBitmap> const&)
Unexecuted instantiation: cppcanvas::internal::ImplBitmap::ImplBitmap(std::__1::shared_ptr<cppcanvas::Canvas> const&, com::sun::star::uno::Reference<com::sun::star::rendering::XBitmap> const&)
46
47
        ImplBitmap::~ImplBitmap()
48
0
        {
49
0
        }
50
51
        bool ImplBitmap::draw() const
52
0
        {
53
0
            CanvasSharedPtr pCanvas( getCanvas() );
54
55
0
            OSL_ENSURE( pCanvas && pCanvas->getUNOCanvas().is(),
56
0
                        "ImplBitmap::draw: invalid canvas" );
57
58
0
            if( !pCanvas ||
59
0
                !pCanvas->getUNOCanvas().is() )
60
0
            {
61
0
                return false;
62
0
            }
63
64
            // TODO(P1): implement caching
65
0
            pCanvas->getUNOCanvas()->drawBitmap( mxBitmap,
66
0
                                                 pCanvas->getViewState(),
67
0
                                                 getRenderState() );
68
69
0
            return true;
70
0
        }
71
72
        void ImplBitmap::drawAlphaModulated( double nAlphaModulation ) const
73
0
        {
74
0
            CanvasSharedPtr pCanvas( getCanvas() );
75
76
0
            OSL_ENSURE( pCanvas && pCanvas->getUNOCanvas().is(),
77
0
                        "ImplBitmap::drawAlphaModulated(): invalid canvas" );
78
79
0
            if( !pCanvas ||
80
0
                !pCanvas->getUNOCanvas().is() )
81
0
            {
82
0
                return;
83
0
            }
84
85
0
            rendering::RenderState aLocalState( getRenderState() );
86
0
            uno::Sequence<rendering::ARGBColor> aCol { { nAlphaModulation, 1.0, 1.0, 1.0 } };
87
0
            aLocalState.DeviceColor =
88
0
                pCanvas->getUNOCanvas()->getDevice()->getDeviceColorSpace()->convertFromARGB(aCol);
89
90
            // TODO(P1): implement caching
91
0
            pCanvas->getUNOCanvas()->drawBitmapModulated( mxBitmap,
92
0
                                                          pCanvas->getViewState(),
93
0
                                                          aLocalState );
94
0
        }
95
96
        BitmapCanvasSharedPtr ImplBitmap::getBitmapCanvas() const
97
0
        {
98
0
            return mpBitmapCanvas;
99
0
        }
100
101
        uno::Reference< rendering::XBitmap > ImplBitmap::getUNOBitmap() const
102
0
        {
103
0
            return mxBitmap;
104
0
        }
105
}
106
107
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */