/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 | 25.6k | { |
29 | 25.6k | assert(!is_double_buffered_window()); |
30 | | |
31 | 25.6k | if ( mpMetaFile ) |
32 | 23.3k | mpMetaFile->AddAction( new MetaEllipseAction( rRect ) ); |
33 | | |
34 | 25.6k | if ( !IsDeviceOutputNecessary() || (!mbLineColor && !mbFillColor) || ImplIsRecordLayout() ) |
35 | 25.0k | return; |
36 | | |
37 | 524 | tools::Rectangle aRect(LogicToDevicePixel(rRect)); |
38 | 524 | if ( aRect.IsEmpty() ) |
39 | 0 | return; |
40 | | |
41 | | // we need a graphics |
42 | 524 | if ( !mpGraphics && !AcquireGraphics() ) |
43 | 0 | return; |
44 | 524 | assert(mpGraphics); |
45 | | |
46 | 524 | if ( mbInitClipRegion ) |
47 | 15 | InitClipRegion(); |
48 | 524 | if ( mbOutputClipped ) |
49 | 24 | return; |
50 | | |
51 | 500 | if ( mbInitLineColor ) |
52 | 21 | InitLineColor(); |
53 | | |
54 | 500 | tools::Polygon aRectPoly( aRect.Center(), aRect.GetWidth() >> 1, aRect.GetHeight() >> 1 ); |
55 | 500 | if ( aRectPoly.GetSize() >= 2 ) |
56 | 227 | { |
57 | 227 | Point* pPtAry = aRectPoly.GetPointAry(); |
58 | 227 | if ( !mbFillColor ) |
59 | 182 | mpGraphics->DrawPolyLine( aRectPoly.GetSize(), pPtAry, *this ); |
60 | 45 | else |
61 | 45 | { |
62 | 45 | if ( mbInitFillColor ) |
63 | 17 | InitFillColor(); |
64 | 45 | mpGraphics->DrawPolygon( aRectPoly.GetSize(), pPtAry, *this ); |
65 | 45 | } |
66 | 227 | } |
67 | 500 | } |
68 | | |
69 | | void OutputDevice::DrawArc( const tools::Rectangle& rRect, |
70 | | const Point& rStartPt, const Point& rEndPt ) |
71 | 41.5k | { |
72 | 41.5k | assert(!is_double_buffered_window()); |
73 | | |
74 | 41.5k | if ( mpMetaFile ) |
75 | 27.7k | mpMetaFile->AddAction( new MetaArcAction( rRect, rStartPt, rEndPt ) ); |
76 | | |
77 | 41.5k | if ( !IsDeviceOutputNecessary() || !mbLineColor || ImplIsRecordLayout() ) |
78 | 39.3k | return; |
79 | | |
80 | 2.25k | tools::Rectangle aRect(LogicToDevicePixel(rRect)); |
81 | 2.25k | if ( aRect.IsEmpty() ) |
82 | 545 | return; |
83 | | |
84 | | // we need a graphics |
85 | 1.71k | if ( !mpGraphics && !AcquireGraphics() ) |
86 | 0 | return; |
87 | 1.71k | assert(mpGraphics); |
88 | | |
89 | 1.71k | if ( mbInitClipRegion ) |
90 | 196 | InitClipRegion(); |
91 | 1.71k | if ( mbOutputClipped ) |
92 | 364 | return; |
93 | | |
94 | 1.34k | if ( mbInitLineColor ) |
95 | 96 | InitLineColor(); |
96 | | |
97 | 1.34k | const Point aStart(LogicToDevicePixel(rStartPt)); |
98 | 1.34k | const Point aEnd(LogicToDevicePixel(rEndPt)); |
99 | 1.34k | tools::Polygon aArcPoly( aRect, aStart, aEnd, PolyStyle::Arc ); |
100 | | |
101 | 1.34k | if ( aArcPoly.GetSize() >= 2 ) |
102 | 1.34k | { |
103 | 1.34k | Point* pPtAry = aArcPoly.GetPointAry(); |
104 | 1.34k | mpGraphics->DrawPolyLine( aArcPoly.GetSize(), pPtAry, *this ); |
105 | 1.34k | } |
106 | 1.34k | } |
107 | | |
108 | | void OutputDevice::DrawPie( const tools::Rectangle& rRect, |
109 | | const Point& rStartPt, const Point& rEndPt ) |
110 | 5.81k | { |
111 | 5.81k | assert(!is_double_buffered_window()); |
112 | | |
113 | 5.81k | if ( mpMetaFile ) |
114 | 0 | mpMetaFile->AddAction( new MetaPieAction( rRect, rStartPt, rEndPt ) ); |
115 | | |
116 | 5.81k | if ( !IsDeviceOutputNecessary() || (!mbLineColor && !mbFillColor) || ImplIsRecordLayout() ) |
117 | 423 | return; |
118 | | |
119 | 5.39k | tools::Rectangle aRect(LogicToDevicePixel(rRect)); |
120 | 5.39k | if ( aRect.IsEmpty() ) |
121 | 894 | return; |
122 | | |
123 | | // we need a graphics |
124 | 4.49k | if ( !mpGraphics && !AcquireGraphics() ) |
125 | 0 | return; |
126 | 4.49k | assert(mpGraphics); |
127 | | |
128 | 4.49k | if ( mbInitClipRegion ) |
129 | 1.04k | InitClipRegion(); |
130 | 4.49k | if ( mbOutputClipped ) |
131 | 609 | return; |
132 | | |
133 | 3.88k | if ( mbInitLineColor ) |
134 | 515 | InitLineColor(); |
135 | | |
136 | 3.88k | const Point aStart(LogicToDevicePixel(rStartPt)); |
137 | 3.88k | const Point aEnd(LogicToDevicePixel(rEndPt)); |
138 | 3.88k | tools::Polygon aPiePoly( aRect, aStart, aEnd, PolyStyle::Pie ); |
139 | | |
140 | 3.88k | if ( aPiePoly.GetSize() >= 2 ) |
141 | 3.88k | { |
142 | 3.88k | Point* pPtAry = aPiePoly.GetPointAry(); |
143 | 3.88k | if ( !mbFillColor ) |
144 | 1.94k | mpGraphics->DrawPolyLine( aPiePoly.GetSize(), pPtAry, *this ); |
145 | 1.94k | else |
146 | 1.94k | { |
147 | 1.94k | if ( mbInitFillColor ) |
148 | 900 | InitFillColor(); |
149 | 1.94k | mpGraphics->DrawPolygon( aPiePoly.GetSize(), pPtAry, *this ); |
150 | 1.94k | } |
151 | 3.88k | } |
152 | 3.88k | } |
153 | | |
154 | | void OutputDevice::DrawChord( const tools::Rectangle& rRect, |
155 | | const Point& rStartPt, const Point& rEndPt ) |
156 | 1.87k | { |
157 | 1.87k | assert(!is_double_buffered_window()); |
158 | | |
159 | 1.87k | if ( mpMetaFile ) |
160 | 0 | mpMetaFile->AddAction( new MetaChordAction( rRect, rStartPt, rEndPt ) ); |
161 | | |
162 | 1.87k | if ( !IsDeviceOutputNecessary() || (!mbLineColor && !mbFillColor) || ImplIsRecordLayout() ) |
163 | 69 | return; |
164 | | |
165 | 1.80k | tools::Rectangle aRect(LogicToDevicePixel(rRect)); |
166 | 1.80k | if ( aRect.IsEmpty() ) |
167 | 3 | return; |
168 | | |
169 | | // we need a graphics |
170 | 1.79k | if ( !mpGraphics && !AcquireGraphics() ) |
171 | 0 | return; |
172 | 1.79k | assert(mpGraphics); |
173 | | |
174 | 1.79k | if ( mbInitClipRegion ) |
175 | 399 | InitClipRegion(); |
176 | 1.79k | if ( mbOutputClipped ) |
177 | 451 | return; |
178 | | |
179 | 1.34k | if ( mbInitLineColor ) |
180 | 103 | InitLineColor(); |
181 | | |
182 | 1.34k | const Point aStart(LogicToDevicePixel(rStartPt)); |
183 | 1.34k | const Point aEnd(LogicToDevicePixel(rEndPt)); |
184 | 1.34k | tools::Polygon aChordPoly( aRect, aStart, aEnd, PolyStyle::Chord ); |
185 | | |
186 | 1.34k | if ( aChordPoly.GetSize() >= 2 ) |
187 | 1.34k | { |
188 | 1.34k | Point* pPtAry = aChordPoly.GetPointAry(); |
189 | 1.34k | if ( !mbFillColor ) |
190 | 856 | mpGraphics->DrawPolyLine( aChordPoly.GetSize(), pPtAry, *this ); |
191 | 492 | else |
192 | 492 | { |
193 | 492 | if ( mbInitFillColor ) |
194 | 39 | InitFillColor(); |
195 | 492 | mpGraphics->DrawPolygon( aChordPoly.GetSize(), pPtAry, *this ); |
196 | 492 | } |
197 | 1.34k | } |
198 | 1.34k | } |
199 | | |
200 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |