Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include <tools/debug.hxx>
31 : : #include <tools/poly.hxx>
32 : :
33 : : #include <vcl/metaact.hxx>
34 : : #include <vcl/gdimtf.hxx>
35 : : #include <vcl/outdev.hxx>
36 : : #include <vcl/virdev.hxx>
37 : :
38 : : #include <salgdi.hxx>
39 : : #include <svdata.hxx>
40 : : #include <outdata.hxx>
41 : : #include <outdev.h>
42 : :
43 : : // =======================================================================
44 : :
45 : : DBG_NAMEEX( OutputDevice )
46 : :
47 : : // =======================================================================
48 : :
49 : 0 : void OutputDevice::DrawRect( const Rectangle& rRect,
50 : : sal_uLong nHorzRound, sal_uLong nVertRound )
51 : : {
52 : : OSL_TRACE( "OutputDevice::DrawRoundRect()" );
53 : : DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice );
54 : :
55 [ # # ]: 0 : if ( mpMetaFile )
56 [ # # ][ # # ]: 0 : mpMetaFile->AddAction( new MetaRoundRectAction( rRect, nHorzRound, nVertRound ) );
[ # # ]
57 : :
58 [ # # ][ # # ]: 0 : if ( !IsDeviceOutputNecessary() || (!mbLineColor && !mbFillColor) || ImplIsRecordLayout() )
[ # # ][ # # ]
[ # # ][ # # ]
59 : : return;
60 : :
61 [ # # ]: 0 : const Rectangle aRect( ImplLogicToDevicePixel( rRect ) );
62 : :
63 [ # # ][ # # ]: 0 : if ( aRect.IsEmpty() )
64 : : return;
65 : :
66 [ # # ]: 0 : nHorzRound = ImplLogicWidthToDevicePixel( nHorzRound );
67 [ # # ]: 0 : nVertRound = ImplLogicHeightToDevicePixel( nVertRound );
68 : :
69 : : // we need a graphics
70 [ # # ]: 0 : if ( !mpGraphics )
71 : : {
72 [ # # ][ # # ]: 0 : if ( !ImplGetGraphics() )
73 : : return;
74 : : }
75 : :
76 [ # # ]: 0 : if ( mbInitClipRegion )
77 [ # # ]: 0 : ImplInitClipRegion();
78 [ # # ]: 0 : if ( mbOutputClipped )
79 : : return;
80 : :
81 [ # # ]: 0 : if ( mbInitLineColor )
82 [ # # ]: 0 : ImplInitLineColor();
83 [ # # ]: 0 : if ( mbInitFillColor )
84 [ # # ]: 0 : ImplInitFillColor();
85 : :
86 [ # # ][ # # ]: 0 : if ( !nHorzRound && !nVertRound )
87 [ # # ][ # # ]: 0 : mpGraphics->DrawRect( aRect.Left(), aRect.Top(), aRect.GetWidth(), aRect.GetHeight(), this );
[ # # ]
88 : : else
89 : : {
90 [ # # ]: 0 : const Polygon aRoundRectPoly( aRect, nHorzRound, nVertRound );
91 : :
92 [ # # ][ # # ]: 0 : if ( aRoundRectPoly.GetSize() >= 2 )
93 : : {
94 [ # # ]: 0 : const SalPoint* pPtAry = (const SalPoint*) aRoundRectPoly.GetConstPointAry();
95 : :
96 [ # # ]: 0 : if ( !mbFillColor )
97 [ # # ][ # # ]: 0 : mpGraphics->DrawPolyLine( aRoundRectPoly.GetSize(), pPtAry, this );
98 : : else
99 [ # # ][ # # ]: 0 : mpGraphics->DrawPolygon( aRoundRectPoly.GetSize(), pPtAry, this );
100 [ # # ]: 0 : }
101 : : }
102 : :
103 [ # # ]: 0 : if( mpAlphaVDev )
104 [ # # ]: 0 : mpAlphaVDev->DrawRect( rRect, nHorzRound, nVertRound );
105 : : }
106 : :
107 : : // -----------------------------------------------------------------------
108 : :
109 : 3 : void OutputDevice::DrawEllipse( const Rectangle& rRect )
110 : : {
111 : : OSL_TRACE( "OutputDevice::DrawEllipse()" );
112 : : DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice );
113 : :
114 [ + - ]: 3 : if ( mpMetaFile )
115 [ + - ][ + - ]: 3 : mpMetaFile->AddAction( new MetaEllipseAction( rRect ) );
[ + - ]
116 : :
117 [ + - ][ - + ]: 3 : if ( !IsDeviceOutputNecessary() || (!mbLineColor && !mbFillColor) || ImplIsRecordLayout() )
[ # # ][ + - ]
[ - + ][ + - ]
118 : : return;
119 : :
120 [ + - ]: 3 : Rectangle aRect( ImplLogicToDevicePixel( rRect ) );
121 [ + - ][ + - ]: 3 : if ( aRect.IsEmpty() )
122 : : return;
123 : :
124 : : // we need a graphics
125 [ - + ]: 3 : if ( !mpGraphics )
126 : : {
127 [ # # ][ # # ]: 0 : if ( !ImplGetGraphics() )
128 : : return;
129 : : }
130 : :
131 [ - + ]: 3 : if ( mbInitClipRegion )
132 [ # # ]: 0 : ImplInitClipRegion();
133 [ + - ]: 3 : if ( mbOutputClipped )
134 : : return;
135 : :
136 [ + - ]: 3 : if ( mbInitLineColor )
137 [ + - ]: 3 : ImplInitLineColor();
138 : :
139 [ + - ][ + - ]: 3 : Polygon aRectPoly( aRect.Center(), aRect.GetWidth() >> 1, aRect.GetHeight() >> 1 );
[ + - ][ + - ]
140 [ + - ][ + - ]: 3 : if ( aRectPoly.GetSize() >= 2 )
141 : : {
142 [ + - ]: 3 : const SalPoint* pPtAry = (const SalPoint*)aRectPoly.GetConstPointAry();
143 [ - + ]: 3 : if ( !mbFillColor )
144 [ # # ][ # # ]: 0 : mpGraphics->DrawPolyLine( aRectPoly.GetSize(), pPtAry, this );
145 : : else
146 : : {
147 [ + - ]: 3 : if ( mbInitFillColor )
148 [ + - ]: 3 : ImplInitFillColor();
149 [ + - ][ + - ]: 3 : mpGraphics->DrawPolygon( aRectPoly.GetSize(), pPtAry, this );
150 : : }
151 : : }
152 : :
153 [ - + ]: 3 : if( mpAlphaVDev )
154 [ # # ][ + - ]: 3 : mpAlphaVDev->DrawEllipse( rRect );
155 : : }
156 : :
157 : : // -----------------------------------------------------------------------
158 : :
159 : 0 : void OutputDevice::DrawArc( const Rectangle& rRect,
160 : : const Point& rStartPt, const Point& rEndPt )
161 : : {
162 : : OSL_TRACE( "OutputDevice::DrawArc()" );
163 : : DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice );
164 : :
165 [ # # ]: 0 : if ( mpMetaFile )
166 [ # # ][ # # ]: 0 : mpMetaFile->AddAction( new MetaArcAction( rRect, rStartPt, rEndPt ) );
[ # # ]
167 : :
168 [ # # ][ # # ]: 0 : if ( !IsDeviceOutputNecessary() || !mbLineColor || ImplIsRecordLayout() )
[ # # ][ # # ]
[ # # ]
169 : : return;
170 : :
171 [ # # ]: 0 : Rectangle aRect( ImplLogicToDevicePixel( rRect ) );
172 [ # # ][ # # ]: 0 : if ( aRect.IsEmpty() )
173 : : return;
174 : :
175 : : // we need a graphics
176 [ # # ]: 0 : if ( !mpGraphics )
177 : : {
178 [ # # ][ # # ]: 0 : if ( !ImplGetGraphics() )
179 : : return;
180 : : }
181 : :
182 [ # # ]: 0 : if ( mbInitClipRegion )
183 [ # # ]: 0 : ImplInitClipRegion();
184 [ # # ]: 0 : if ( mbOutputClipped )
185 : : return;
186 : :
187 [ # # ]: 0 : if ( mbInitLineColor )
188 [ # # ]: 0 : ImplInitLineColor();
189 : :
190 [ # # ]: 0 : const Point aStart( ImplLogicToDevicePixel( rStartPt ) );
191 [ # # ]: 0 : const Point aEnd( ImplLogicToDevicePixel( rEndPt ) );
192 [ # # ]: 0 : Polygon aArcPoly( aRect, aStart, aEnd, POLY_ARC );
193 : :
194 [ # # ][ # # ]: 0 : if ( aArcPoly.GetSize() >= 2 )
195 : : {
196 [ # # ]: 0 : const SalPoint* pPtAry = (const SalPoint*)aArcPoly.GetConstPointAry();
197 [ # # ][ # # ]: 0 : mpGraphics->DrawPolyLine( aArcPoly.GetSize(), pPtAry, this );
198 : : }
199 : :
200 [ # # ]: 0 : if( mpAlphaVDev )
201 [ # # ][ # # ]: 0 : mpAlphaVDev->DrawArc( rRect, rStartPt, rEndPt );
202 : : }
203 : :
204 : : // -----------------------------------------------------------------------
205 : :
206 : 0 : void OutputDevice::DrawPie( const Rectangle& rRect,
207 : : const Point& rStartPt, const Point& rEndPt )
208 : : {
209 : : OSL_TRACE( "OutputDevice::DrawPie()" );
210 : : DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice );
211 : :
212 [ # # ]: 0 : if ( mpMetaFile )
213 [ # # ][ # # ]: 0 : mpMetaFile->AddAction( new MetaPieAction( rRect, rStartPt, rEndPt ) );
[ # # ]
214 : :
215 [ # # ][ # # ]: 0 : if ( !IsDeviceOutputNecessary() || (!mbLineColor && !mbFillColor) || ImplIsRecordLayout() )
[ # # ][ # # ]
[ # # ][ # # ]
216 : : return;
217 : :
218 [ # # ]: 0 : Rectangle aRect( ImplLogicToDevicePixel( rRect ) );
219 [ # # ][ # # ]: 0 : if ( aRect.IsEmpty() )
220 : : return;
221 : :
222 : : // we need a graphics
223 [ # # ]: 0 : if ( !mpGraphics )
224 : : {
225 [ # # ][ # # ]: 0 : if ( !ImplGetGraphics() )
226 : : return;
227 : : }
228 : :
229 [ # # ]: 0 : if ( mbInitClipRegion )
230 [ # # ]: 0 : ImplInitClipRegion();
231 [ # # ]: 0 : if ( mbOutputClipped )
232 : : return;
233 : :
234 [ # # ]: 0 : if ( mbInitLineColor )
235 [ # # ]: 0 : ImplInitLineColor();
236 : :
237 [ # # ]: 0 : const Point aStart( ImplLogicToDevicePixel( rStartPt ) );
238 [ # # ]: 0 : const Point aEnd( ImplLogicToDevicePixel( rEndPt ) );
239 [ # # ]: 0 : Polygon aPiePoly( aRect, aStart, aEnd, POLY_PIE );
240 : :
241 [ # # ][ # # ]: 0 : if ( aPiePoly.GetSize() >= 2 )
242 : : {
243 [ # # ]: 0 : const SalPoint* pPtAry = (const SalPoint*)aPiePoly.GetConstPointAry();
244 [ # # ]: 0 : if ( !mbFillColor )
245 [ # # ][ # # ]: 0 : mpGraphics->DrawPolyLine( aPiePoly.GetSize(), pPtAry, this );
246 : : else
247 : : {
248 [ # # ]: 0 : if ( mbInitFillColor )
249 [ # # ]: 0 : ImplInitFillColor();
250 [ # # ][ # # ]: 0 : mpGraphics->DrawPolygon( aPiePoly.GetSize(), pPtAry, this );
251 : : }
252 : : }
253 : :
254 [ # # ]: 0 : if( mpAlphaVDev )
255 [ # # ][ # # ]: 0 : mpAlphaVDev->DrawPie( rRect, rStartPt, rEndPt );
256 : : }
257 : :
258 : : // -----------------------------------------------------------------------
259 : :
260 : 0 : void OutputDevice::DrawChord( const Rectangle& rRect,
261 : : const Point& rStartPt, const Point& rEndPt )
262 : : {
263 : : OSL_TRACE( "OutputDevice::DrawChord()" );
264 : : DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice );
265 : :
266 [ # # ]: 0 : if ( mpMetaFile )
267 [ # # ][ # # ]: 0 : mpMetaFile->AddAction( new MetaChordAction( rRect, rStartPt, rEndPt ) );
[ # # ]
268 : :
269 [ # # ][ # # ]: 0 : if ( !IsDeviceOutputNecessary() || (!mbLineColor && !mbFillColor) || ImplIsRecordLayout() )
[ # # ][ # # ]
[ # # ][ # # ]
270 : : return;
271 : :
272 [ # # ]: 0 : Rectangle aRect( ImplLogicToDevicePixel( rRect ) );
273 [ # # ][ # # ]: 0 : if ( aRect.IsEmpty() )
274 : : return;
275 : :
276 : : // we need a graphics
277 [ # # ]: 0 : if ( !mpGraphics )
278 : : {
279 [ # # ][ # # ]: 0 : if ( !ImplGetGraphics() )
280 : : return;
281 : : }
282 : :
283 [ # # ]: 0 : if ( mbInitClipRegion )
284 [ # # ]: 0 : ImplInitClipRegion();
285 [ # # ]: 0 : if ( mbOutputClipped )
286 : : return;
287 : :
288 [ # # ]: 0 : if ( mbInitLineColor )
289 [ # # ]: 0 : ImplInitLineColor();
290 : :
291 [ # # ]: 0 : const Point aStart( ImplLogicToDevicePixel( rStartPt ) );
292 [ # # ]: 0 : const Point aEnd( ImplLogicToDevicePixel( rEndPt ) );
293 [ # # ]: 0 : Polygon aChordPoly( aRect, aStart, aEnd, POLY_CHORD );
294 : :
295 [ # # ][ # # ]: 0 : if ( aChordPoly.GetSize() >= 2 )
296 : : {
297 [ # # ]: 0 : const SalPoint* pPtAry = (const SalPoint*)aChordPoly.GetConstPointAry();
298 [ # # ]: 0 : if ( !mbFillColor )
299 [ # # ][ # # ]: 0 : mpGraphics->DrawPolyLine( aChordPoly.GetSize(), pPtAry, this );
300 : : else
301 : : {
302 [ # # ]: 0 : if ( mbInitFillColor )
303 [ # # ]: 0 : ImplInitFillColor();
304 [ # # ][ # # ]: 0 : mpGraphics->DrawPolygon( aChordPoly.GetSize(), pPtAry, this );
305 : : }
306 : : }
307 : :
308 [ # # ]: 0 : if( mpAlphaVDev )
309 [ # # ][ # # ]: 0 : mpAlphaVDev->DrawChord( rRect, rStartPt, rEndPt );
310 : : }
311 : :
312 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|