1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: outdev5.cxx,v $
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>
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
);
62 mpMetaFile
->AddAction( new MetaRoundRectAction( rRect
, nHorzRound
, nVertRound
) );
64 if ( !IsDeviceOutputNecessary() || (!mbLineColor
&& !mbFillColor
) || ImplIsRecordLayout() )
67 const Rectangle
aRect( ImplLogicToDevicePixel( rRect
) );
69 if ( aRect
.IsEmpty() )
72 nHorzRound
= ImplLogicWidthToDevicePixel( nHorzRound
);
73 nVertRound
= ImplLogicHeightToDevicePixel( nVertRound
);
78 if ( !ImplGetGraphics() )
82 if ( mbInitClipRegion
)
84 if ( mbOutputClipped
)
87 if ( mbInitLineColor
)
89 if ( mbInitFillColor
)
92 if ( !nHorzRound
&& !nVertRound
)
93 mpGraphics
->DrawRect( aRect
.Left(), aRect
.Top(), aRect
.GetWidth(), aRect
.GetHeight(), this );
96 const Polygon
aRoundRectPoly( aRect
, nHorzRound
, nVertRound
);
98 if ( aRoundRectPoly
.GetSize() >= 2 )
100 const SalPoint
* pPtAry
= (const SalPoint
*) aRoundRectPoly
.GetConstPointAry();
103 mpGraphics
->DrawPolyLine( aRoundRectPoly
.GetSize(), pPtAry
, this );
105 mpGraphics
->DrawPolygon( aRoundRectPoly
.GetSize(), pPtAry
, this );
110 mpAlphaVDev
->DrawRect( rRect
, nHorzRound
, nVertRound
);
113 // -----------------------------------------------------------------------
115 void OutputDevice::DrawEllipse( const Rectangle
& rRect
)
117 DBG_TRACE( "OutputDevice::DrawEllipse()" );
118 DBG_CHKTHIS( OutputDevice
, ImplDbgCheckOutputDevice
);
121 mpMetaFile
->AddAction( new MetaEllipseAction( rRect
) );
123 if ( !IsDeviceOutputNecessary() || (!mbLineColor
&& !mbFillColor
) || ImplIsRecordLayout() )
126 Rectangle
aRect( ImplLogicToDevicePixel( rRect
) );
127 if ( aRect
.IsEmpty() )
130 // we need a graphics
133 if ( !ImplGetGraphics() )
137 if ( mbInitClipRegion
)
138 ImplInitClipRegion();
139 if ( mbOutputClipped
)
142 if ( mbInitLineColor
)
145 Polygon
aRectPoly( aRect
.Center(), aRect
.GetWidth() >> 1, aRect
.GetHeight() >> 1 );
146 if ( aRectPoly
.GetSize() >= 2 )
148 const SalPoint
* pPtAry
= (const SalPoint
*)aRectPoly
.GetConstPointAry();
150 mpGraphics
->DrawPolyLine( aRectPoly
.GetSize(), pPtAry
, this );
153 if ( mbInitFillColor
)
155 mpGraphics
->DrawPolygon( aRectPoly
.GetSize(), pPtAry
, this );
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
);
172 mpMetaFile
->AddAction( new MetaArcAction( rRect
, rStartPt
, rEndPt
) );
174 if ( !IsDeviceOutputNecessary() || !mbLineColor
|| ImplIsRecordLayout() )
177 Rectangle
aRect( ImplLogicToDevicePixel( rRect
) );
178 if ( aRect
.IsEmpty() )
181 // we need a graphics
184 if ( !ImplGetGraphics() )
188 if ( mbInitClipRegion
)
189 ImplInitClipRegion();
190 if ( mbOutputClipped
)
193 if ( mbInitLineColor
)
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 );
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
);
219 mpMetaFile
->AddAction( new MetaPieAction( rRect
, rStartPt
, rEndPt
) );
221 if ( !IsDeviceOutputNecessary() || (!mbLineColor
&& !mbFillColor
) || ImplIsRecordLayout() )
224 Rectangle
aRect( ImplLogicToDevicePixel( rRect
) );
225 if ( aRect
.IsEmpty() )
228 // we need a graphics
231 if ( !ImplGetGraphics() )
235 if ( mbInitClipRegion
)
236 ImplInitClipRegion();
237 if ( mbOutputClipped
)
240 if ( mbInitLineColor
)
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();
251 mpGraphics
->DrawPolyLine( aPiePoly
.GetSize(), pPtAry
, this );
254 if ( mbInitFillColor
)
256 mpGraphics
->DrawPolygon( aPiePoly
.GetSize(), pPtAry
, this );
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
);
273 mpMetaFile
->AddAction( new MetaChordAction( rRect
, rStartPt
, rEndPt
) );
275 if ( !IsDeviceOutputNecessary() || (!mbLineColor
&& !mbFillColor
) || ImplIsRecordLayout() )
278 Rectangle
aRect( ImplLogicToDevicePixel( rRect
) );
279 if ( aRect
.IsEmpty() )
282 // we need a graphics
285 if ( !ImplGetGraphics() )
289 if ( mbInitClipRegion
)
290 ImplInitClipRegion();
291 if ( mbOutputClipped
)
294 if ( mbInitLineColor
)
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();
305 mpGraphics
->DrawPolyLine( aChordPoly
.GetSize(), pPtAry
, this );
308 if ( mbInitFillColor
)
310 mpGraphics
->DrawPolygon( aChordPoly
.GetSize(), pPtAry
, this );
315 mpAlphaVDev
->DrawChord( rRect
, rStartPt
, rEndPt
);