Update ooo320-m1
[ooovba.git] / vcl / source / gdi / outdev5.cxx
blob5e09b0384d6c306deaed612dff9aefcee893874b
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: outdev5.cxx,v $
10 * $Revision: 1.12 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_vcl.hxx"
34 #include <tools/ref.hxx>
35 #ifndef _SV_SVSYS_HXX
36 #include <svsys.h>
37 #endif
38 #include <vcl/salgdi.hxx>
39 #include <tools/debug.hxx>
40 #include <vcl/svdata.hxx>
41 #include <tools/poly.hxx>
42 #include <vcl/metaact.hxx>
43 #include <vcl/gdimtf.hxx>
44 #include <vcl/outdata.hxx>
45 #include <vcl/outdev.h>
46 #include <vcl/outdev.hxx>
47 #include <vcl/virdev.hxx>
49 // =======================================================================
51 DBG_NAMEEX( OutputDevice )
53 // =======================================================================
55 void OutputDevice::DrawRect( const Rectangle& rRect,
56 ULONG nHorzRound, ULONG nVertRound )
58 DBG_TRACE( "OutputDevice::DrawRoundRect()" );
59 DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice );
61 if ( mpMetaFile )
62 mpMetaFile->AddAction( new MetaRoundRectAction( rRect, nHorzRound, nVertRound ) );
64 if ( !IsDeviceOutputNecessary() || (!mbLineColor && !mbFillColor) || ImplIsRecordLayout() )
65 return;
67 const Rectangle aRect( ImplLogicToDevicePixel( rRect ) );
69 if ( aRect.IsEmpty() )
70 return;
72 nHorzRound = ImplLogicWidthToDevicePixel( nHorzRound );
73 nVertRound = ImplLogicHeightToDevicePixel( nVertRound );
75 // we need a graphics
76 if ( !mpGraphics )
78 if ( !ImplGetGraphics() )
79 return;
82 if ( mbInitClipRegion )
83 ImplInitClipRegion();
84 if ( mbOutputClipped )
85 return;
87 if ( mbInitLineColor )
88 ImplInitLineColor();
89 if ( mbInitFillColor )
90 ImplInitFillColor();
92 if ( !nHorzRound && !nVertRound )
93 mpGraphics->DrawRect( aRect.Left(), aRect.Top(), aRect.GetWidth(), aRect.GetHeight(), this );
94 else
96 const Polygon aRoundRectPoly( aRect, nHorzRound, nVertRound );
98 if ( aRoundRectPoly.GetSize() >= 2 )
100 const SalPoint* pPtAry = (const SalPoint*) aRoundRectPoly.GetConstPointAry();
102 if ( !mbFillColor )
103 mpGraphics->DrawPolyLine( aRoundRectPoly.GetSize(), pPtAry, this );
104 else
105 mpGraphics->DrawPolygon( aRoundRectPoly.GetSize(), pPtAry, this );
109 if( mpAlphaVDev )
110 mpAlphaVDev->DrawRect( rRect, nHorzRound, nVertRound );
113 // -----------------------------------------------------------------------
115 void OutputDevice::DrawEllipse( const Rectangle& rRect )
117 DBG_TRACE( "OutputDevice::DrawEllipse()" );
118 DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice );
120 if ( mpMetaFile )
121 mpMetaFile->AddAction( new MetaEllipseAction( rRect ) );
123 if ( !IsDeviceOutputNecessary() || (!mbLineColor && !mbFillColor) || ImplIsRecordLayout() )
124 return;
126 Rectangle aRect( ImplLogicToDevicePixel( rRect ) );
127 if ( aRect.IsEmpty() )
128 return;
130 // we need a graphics
131 if ( !mpGraphics )
133 if ( !ImplGetGraphics() )
134 return;
137 if ( mbInitClipRegion )
138 ImplInitClipRegion();
139 if ( mbOutputClipped )
140 return;
142 if ( mbInitLineColor )
143 ImplInitLineColor();
145 Polygon aRectPoly( aRect.Center(), aRect.GetWidth() >> 1, aRect.GetHeight() >> 1 );
146 if ( aRectPoly.GetSize() >= 2 )
148 const SalPoint* pPtAry = (const SalPoint*)aRectPoly.GetConstPointAry();
149 if ( !mbFillColor )
150 mpGraphics->DrawPolyLine( aRectPoly.GetSize(), pPtAry, this );
151 else
153 if ( mbInitFillColor )
154 ImplInitFillColor();
155 mpGraphics->DrawPolygon( aRectPoly.GetSize(), pPtAry, this );
159 if( mpAlphaVDev )
160 mpAlphaVDev->DrawEllipse( rRect );
163 // -----------------------------------------------------------------------
165 void OutputDevice::DrawArc( const Rectangle& rRect,
166 const Point& rStartPt, const Point& rEndPt )
168 DBG_TRACE( "OutputDevice::DrawArc()" );
169 DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice );
171 if ( mpMetaFile )
172 mpMetaFile->AddAction( new MetaArcAction( rRect, rStartPt, rEndPt ) );
174 if ( !IsDeviceOutputNecessary() || !mbLineColor || ImplIsRecordLayout() )
175 return;
177 Rectangle aRect( ImplLogicToDevicePixel( rRect ) );
178 if ( aRect.IsEmpty() )
179 return;
181 // we need a graphics
182 if ( !mpGraphics )
184 if ( !ImplGetGraphics() )
185 return;
188 if ( mbInitClipRegion )
189 ImplInitClipRegion();
190 if ( mbOutputClipped )
191 return;
193 if ( mbInitLineColor )
194 ImplInitLineColor();
196 const Point aStart( ImplLogicToDevicePixel( rStartPt ) );
197 const Point aEnd( ImplLogicToDevicePixel( rEndPt ) );
198 Polygon aArcPoly( aRect, aStart, aEnd, POLY_ARC );
200 if ( aArcPoly.GetSize() >= 2 )
202 const SalPoint* pPtAry = (const SalPoint*)aArcPoly.GetConstPointAry();
203 mpGraphics->DrawPolyLine( aArcPoly.GetSize(), pPtAry, this );
206 if( mpAlphaVDev )
207 mpAlphaVDev->DrawArc( rRect, rStartPt, rEndPt );
210 // -----------------------------------------------------------------------
212 void OutputDevice::DrawPie( const Rectangle& rRect,
213 const Point& rStartPt, const Point& rEndPt )
215 DBG_TRACE( "OutputDevice::DrawPie()" );
216 DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice );
218 if ( mpMetaFile )
219 mpMetaFile->AddAction( new MetaPieAction( rRect, rStartPt, rEndPt ) );
221 if ( !IsDeviceOutputNecessary() || (!mbLineColor && !mbFillColor) || ImplIsRecordLayout() )
222 return;
224 Rectangle aRect( ImplLogicToDevicePixel( rRect ) );
225 if ( aRect.IsEmpty() )
226 return;
228 // we need a graphics
229 if ( !mpGraphics )
231 if ( !ImplGetGraphics() )
232 return;
235 if ( mbInitClipRegion )
236 ImplInitClipRegion();
237 if ( mbOutputClipped )
238 return;
240 if ( mbInitLineColor )
241 ImplInitLineColor();
243 const Point aStart( ImplLogicToDevicePixel( rStartPt ) );
244 const Point aEnd( ImplLogicToDevicePixel( rEndPt ) );
245 Polygon aPiePoly( aRect, aStart, aEnd, POLY_PIE );
247 if ( aPiePoly.GetSize() >= 2 )
249 const SalPoint* pPtAry = (const SalPoint*)aPiePoly.GetConstPointAry();
250 if ( !mbFillColor )
251 mpGraphics->DrawPolyLine( aPiePoly.GetSize(), pPtAry, this );
252 else
254 if ( mbInitFillColor )
255 ImplInitFillColor();
256 mpGraphics->DrawPolygon( aPiePoly.GetSize(), pPtAry, this );
260 if( mpAlphaVDev )
261 mpAlphaVDev->DrawPie( rRect, rStartPt, rEndPt );
264 // -----------------------------------------------------------------------
266 void OutputDevice::DrawChord( const Rectangle& rRect,
267 const Point& rStartPt, const Point& rEndPt )
269 DBG_TRACE( "OutputDevice::DrawChord()" );
270 DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice );
272 if ( mpMetaFile )
273 mpMetaFile->AddAction( new MetaChordAction( rRect, rStartPt, rEndPt ) );
275 if ( !IsDeviceOutputNecessary() || (!mbLineColor && !mbFillColor) || ImplIsRecordLayout() )
276 return;
278 Rectangle aRect( ImplLogicToDevicePixel( rRect ) );
279 if ( aRect.IsEmpty() )
280 return;
282 // we need a graphics
283 if ( !mpGraphics )
285 if ( !ImplGetGraphics() )
286 return;
289 if ( mbInitClipRegion )
290 ImplInitClipRegion();
291 if ( mbOutputClipped )
292 return;
294 if ( mbInitLineColor )
295 ImplInitLineColor();
297 const Point aStart( ImplLogicToDevicePixel( rStartPt ) );
298 const Point aEnd( ImplLogicToDevicePixel( rEndPt ) );
299 Polygon aChordPoly( aRect, aStart, aEnd, POLY_CHORD );
301 if ( aChordPoly.GetSize() >= 2 )
303 const SalPoint* pPtAry = (const SalPoint*)aChordPoly.GetConstPointAry();
304 if ( !mbFillColor )
305 mpGraphics->DrawPolyLine( aChordPoly.GetSize(), pPtAry, this );
306 else
308 if ( mbInitFillColor )
309 ImplInitFillColor();
310 mpGraphics->DrawPolygon( aChordPoly.GetSize(), pPtAry, this );
314 if( mpAlphaVDev )
315 mpAlphaVDev->DrawChord( rRect, rStartPt, rEndPt );