Coverage Report

Created: 2026-11-06 11:29

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/cppcanvas/source/tools/canvasgraphichelper.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 <canvasgraphichelper.hxx>
22
23
#include <com/sun/star/rendering/XCanvas.hpp>
24
25
#include <canvas/canvastools.hxx>
26
#include <basegfx/utils/canvastools.hxx>
27
#include <osl/diagnose.h>
28
#include <utility>
29
30
31
using namespace ::com::sun::star;
32
33
/* Implementation of CanvasGraphicHelper class */
34
35
namespace cppcanvas::internal
36
{
37
        CanvasGraphicHelper::CanvasGraphicHelper( CanvasSharedPtr xParentCanvas ) :
38
0
            mpCanvas(std::move( xParentCanvas ))
39
0
        {
40
0
            OSL_ENSURE( mpCanvas && mpCanvas->getUNOCanvas().is(),
41
0
                        "CanvasGraphicHelper::CanvasGraphicHelper: no valid canvas" );
42
43
0
            ::canvastools::initRenderState( maRenderState );
44
0
        }
45
46
        void CanvasGraphicHelper::setTransformation( const ::basegfx::B2DHomMatrix& rMatrix )
47
0
        {
48
0
            ::canvastools::setRenderStateTransform( maRenderState, rMatrix );
49
0
        }
50
51
        void CanvasGraphicHelper::setClip( const ::basegfx::B2DPolyPolygon& rClipPoly )
52
0
        {
53
            // TODO(T3): not thread-safe. B2DPolyPolygon employs copy-on-write
54
0
            maClipPolyPolygon = rClipPoly;
55
0
            maRenderState.Clip.clear();
56
0
        }
57
58
        void CanvasGraphicHelper::setClip()
59
0
        {
60
0
            maClipPolyPolygon.reset();
61
0
            maRenderState.Clip.clear();
62
0
        }
63
64
        const rendering::RenderState& CanvasGraphicHelper::getRenderState() const
65
0
        {
66
0
            if( maClipPolyPolygon && !maRenderState.Clip.is() )
67
0
            {
68
0
                uno::Reference< rendering::XCanvas > xCanvas( mpCanvas->getUNOCanvas() );
69
0
                if( !xCanvas.is() )
70
0
                    return maRenderState;
71
72
0
                maRenderState.Clip = ::basegfx::unotools::xPolyPolygonFromB2DPolyPolygon(
73
0
                    xCanvas->getDevice(),
74
0
                    *maClipPolyPolygon );
75
0
            }
76
77
0
            return maRenderState;
78
0
        }
79
80
        void CanvasGraphicHelper::setCompositeOp( sal_Int8 aOp )
81
0
        {
82
0
            maRenderState.CompositeOperation = aOp;
83
0
        }
84
85
}
86
87
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */