Coverage Report

Created: 2026-02-14 09:37

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/vcl/source/outdev/curvedshapes.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
#include <vcl/metaact.hxx>
21
#include <vcl/virdev.hxx>
22
23
#include <salgdi.hxx>
24
25
#include <cassert>
26
27
void OutputDevice::DrawEllipse( const tools::Rectangle& rRect )
28
36.0k
{
29
36.0k
    assert(!is_double_buffered_window());
30
31
36.0k
    if ( mpMetaFile )
32
32.6k
        mpMetaFile->AddAction( new MetaEllipseAction( rRect ) );
33
34
36.0k
    if  ( !IsDeviceOutputNecessary() || (!mbLineColor && !mbFillColor) || ImplIsRecordLayout() )
35
33.7k
        return;
36
37
2.29k
    tools::Rectangle aRect( ImplLogicToDevicePixel( rRect ) );
38
2.29k
    if ( aRect.IsEmpty() )
39
0
        return;
40
41
    // we need a graphics
42
2.29k
    if ( !mpGraphics && !AcquireGraphics() )
43
0
        return;
44
2.29k
    assert(mpGraphics);
45
46
2.29k
    if ( mbInitClipRegion )
47
255
        InitClipRegion();
48
2.29k
    if ( mbOutputClipped )
49
248
        return;
50
51
2.04k
    if ( mbInitLineColor )
52
78
        InitLineColor();
53
54
2.04k
    tools::Polygon aRectPoly( aRect.Center(), aRect.GetWidth() >> 1, aRect.GetHeight() >> 1 );
55
2.04k
    if ( aRectPoly.GetSize() >= 2 )
56
868
    {
57
868
        Point* pPtAry = aRectPoly.GetPointAry();
58
868
        if ( !mbFillColor )
59
110
            mpGraphics->DrawPolyLine( aRectPoly.GetSize(), pPtAry, *this );
60
758
        else
61
758
        {
62
758
            if ( mbInitFillColor )
63
35
                InitFillColor();
64
758
            mpGraphics->DrawPolygon( aRectPoly.GetSize(), pPtAry, *this );
65
758
        }
66
868
    }
67
2.04k
}
68
69
void OutputDevice::DrawArc( const tools::Rectangle& rRect,
70
                            const Point& rStartPt, const Point& rEndPt )
71
50.5k
{
72
50.5k
    assert(!is_double_buffered_window());
73
74
50.5k
    if ( mpMetaFile )
75
36.2k
        mpMetaFile->AddAction( new MetaArcAction( rRect, rStartPt, rEndPt ) );
76
77
50.5k
    if ( !IsDeviceOutputNecessary() || !mbLineColor || ImplIsRecordLayout() )
78
48.6k
        return;
79
80
1.89k
    tools::Rectangle aRect( ImplLogicToDevicePixel( rRect ) );
81
1.89k
    if ( aRect.IsEmpty() )
82
2
        return;
83
84
    // we need a graphics
85
1.88k
    if ( !mpGraphics && !AcquireGraphics() )
86
0
        return;
87
1.88k
    assert(mpGraphics);
88
89
1.88k
    if ( mbInitClipRegion )
90
267
        InitClipRegion();
91
1.88k
    if ( mbOutputClipped )
92
189
        return;
93
94
1.69k
    if ( mbInitLineColor )
95
261
        InitLineColor();
96
97
1.69k
    const Point     aStart( ImplLogicToDevicePixel( rStartPt ) );
98
1.69k
    const Point     aEnd( ImplLogicToDevicePixel( rEndPt ) );
99
1.69k
    tools::Polygon aArcPoly( aRect, aStart, aEnd, PolyStyle::Arc );
100
101
1.69k
    if ( aArcPoly.GetSize() >= 2 )
102
1.69k
    {
103
1.69k
        Point* pPtAry = aArcPoly.GetPointAry();
104
1.69k
        mpGraphics->DrawPolyLine( aArcPoly.GetSize(), pPtAry, *this );
105
1.69k
    }
106
1.69k
}
107
108
void OutputDevice::DrawPie( const tools::Rectangle& rRect,
109
                            const Point& rStartPt, const Point& rEndPt )
110
7.16k
{
111
7.16k
    assert(!is_double_buffered_window());
112
113
7.16k
    if ( mpMetaFile )
114
0
        mpMetaFile->AddAction( new MetaPieAction( rRect, rStartPt, rEndPt ) );
115
116
7.16k
    if ( !IsDeviceOutputNecessary() || (!mbLineColor && !mbFillColor) || ImplIsRecordLayout() )
117
368
        return;
118
119
6.79k
    tools::Rectangle aRect( ImplLogicToDevicePixel( rRect ) );
120
6.79k
    if ( aRect.IsEmpty() )
121
110
        return;
122
123
    // we need a graphics
124
6.68k
    if ( !mpGraphics && !AcquireGraphics() )
125
0
        return;
126
6.68k
    assert(mpGraphics);
127
128
6.68k
    if ( mbInitClipRegion )
129
1.65k
        InitClipRegion();
130
6.68k
    if ( mbOutputClipped )
131
878
        return;
132
133
5.81k
    if ( mbInitLineColor )
134
1.01k
        InitLineColor();
135
136
5.81k
    const Point     aStart( ImplLogicToDevicePixel( rStartPt ) );
137
5.81k
    const Point     aEnd( ImplLogicToDevicePixel( rEndPt ) );
138
5.81k
    tools::Polygon aPiePoly( aRect, aStart, aEnd, PolyStyle::Pie );
139
140
5.81k
    if ( aPiePoly.GetSize() >= 2 )
141
5.81k
    {
142
5.81k
        Point* pPtAry = aPiePoly.GetPointAry();
143
5.81k
        if ( !mbFillColor )
144
1.71k
            mpGraphics->DrawPolyLine( aPiePoly.GetSize(), pPtAry, *this );
145
4.09k
        else
146
4.09k
        {
147
4.09k
            if ( mbInitFillColor )
148
1.70k
                InitFillColor();
149
4.09k
            mpGraphics->DrawPolygon( aPiePoly.GetSize(), pPtAry, *this );
150
4.09k
        }
151
5.81k
    }
152
5.81k
}
153
154
void OutputDevice::DrawChord( const tools::Rectangle& rRect,
155
                              const Point& rStartPt, const Point& rEndPt )
156
2.23k
{
157
2.23k
    assert(!is_double_buffered_window());
158
159
2.23k
    if ( mpMetaFile )
160
0
        mpMetaFile->AddAction( new MetaChordAction( rRect, rStartPt, rEndPt ) );
161
162
2.23k
    if ( !IsDeviceOutputNecessary() || (!mbLineColor && !mbFillColor) || ImplIsRecordLayout() )
163
133
        return;
164
165
2.10k
    tools::Rectangle aRect( ImplLogicToDevicePixel( rRect ) );
166
2.10k
    if ( aRect.IsEmpty() )
167
3
        return;
168
169
    // we need a graphics
170
2.10k
    if ( !mpGraphics && !AcquireGraphics() )
171
0
        return;
172
2.10k
    assert(mpGraphics);
173
174
2.10k
    if ( mbInitClipRegion )
175
635
        InitClipRegion();
176
2.10k
    if ( mbOutputClipped )
177
341
        return;
178
179
1.76k
    if ( mbInitLineColor )
180
127
        InitLineColor();
181
182
1.76k
    const Point     aStart( ImplLogicToDevicePixel( rStartPt ) );
183
1.76k
    const Point     aEnd( ImplLogicToDevicePixel( rEndPt ) );
184
1.76k
    tools::Polygon aChordPoly( aRect, aStart, aEnd, PolyStyle::Chord );
185
186
1.76k
    if ( aChordPoly.GetSize() >= 2 )
187
1.76k
    {
188
1.76k
        Point* pPtAry = aChordPoly.GetPointAry();
189
1.76k
        if ( !mbFillColor )
190
980
            mpGraphics->DrawPolyLine( aChordPoly.GetSize(), pPtAry, *this );
191
781
        else
192
781
        {
193
781
            if ( mbInitFillColor )
194
85
                InitFillColor();
195
781
            mpGraphics->DrawPolygon( aChordPoly.GetSize(), pPtAry, *this );
196
781
        }
197
1.76k
    }
198
1.76k
}
199
200
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */