bump product version to 6.4.0.3
[LibreOffice.git] / vcl / source / outdev / curvedshapes.cxx
blobd25d69ad19181bc47c1735bd7f503cd802fccbd5
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <cassert>
22 #include <vcl/gdimtf.hxx>
23 #include <vcl/metaact.hxx>
24 #include <vcl/outdev.hxx>
25 #include <vcl/virdev.hxx>
27 #include <salgdi.hxx>
29 void OutputDevice::DrawEllipse( const tools::Rectangle& rRect )
31 assert(!is_double_buffered_window());
33 if ( mpMetaFile )
34 mpMetaFile->AddAction( new MetaEllipseAction( rRect ) );
36 if ( !IsDeviceOutputNecessary() || (!mbLineColor && !mbFillColor) || ImplIsRecordLayout() )
37 return;
39 tools::Rectangle aRect( ImplLogicToDevicePixel( rRect ) );
40 if ( aRect.IsEmpty() )
41 return;
43 // we need a graphics
44 if ( !mpGraphics && !AcquireGraphics() )
45 return;
47 if ( mbInitClipRegion )
48 InitClipRegion();
49 if ( mbOutputClipped )
50 return;
52 if ( mbInitLineColor )
53 InitLineColor();
55 tools::Polygon aRectPoly( aRect.Center(), aRect.GetWidth() >> 1, aRect.GetHeight() >> 1 );
56 if ( aRectPoly.GetSize() >= 2 )
58 SalPoint* pPtAry = reinterpret_cast<SalPoint*>(aRectPoly.GetPointAry());
59 if ( !mbFillColor )
60 mpGraphics->DrawPolyLine( aRectPoly.GetSize(), pPtAry, this );
61 else
63 if ( mbInitFillColor )
64 InitFillColor();
65 mpGraphics->DrawPolygon( aRectPoly.GetSize(), pPtAry, this );
69 if( mpAlphaVDev )
70 mpAlphaVDev->DrawEllipse( rRect );
73 void OutputDevice::DrawArc( const tools::Rectangle& rRect,
74 const Point& rStartPt, const Point& rEndPt )
76 assert(!is_double_buffered_window());
78 if ( mpMetaFile )
79 mpMetaFile->AddAction( new MetaArcAction( rRect, rStartPt, rEndPt ) );
81 if ( !IsDeviceOutputNecessary() || !mbLineColor || ImplIsRecordLayout() )
82 return;
84 tools::Rectangle aRect( ImplLogicToDevicePixel( rRect ) );
85 if ( aRect.IsEmpty() )
86 return;
88 // we need a graphics
89 if ( !mpGraphics && !AcquireGraphics() )
90 return;
92 if ( mbInitClipRegion )
93 InitClipRegion();
94 if ( mbOutputClipped )
95 return;
97 if ( mbInitLineColor )
98 InitLineColor();
100 const Point aStart( ImplLogicToDevicePixel( rStartPt ) );
101 const Point aEnd( ImplLogicToDevicePixel( rEndPt ) );
102 tools::Polygon aArcPoly( aRect, aStart, aEnd, PolyStyle::Arc );
104 if ( aArcPoly.GetSize() >= 2 )
106 SalPoint* pPtAry = reinterpret_cast<SalPoint*>(aArcPoly.GetPointAry());
107 mpGraphics->DrawPolyLine( aArcPoly.GetSize(), pPtAry, this );
110 if( mpAlphaVDev )
111 mpAlphaVDev->DrawArc( rRect, rStartPt, rEndPt );
114 void OutputDevice::DrawPie( const tools::Rectangle& rRect,
115 const Point& rStartPt, const Point& rEndPt )
117 assert(!is_double_buffered_window());
119 if ( mpMetaFile )
120 mpMetaFile->AddAction( new MetaPieAction( rRect, rStartPt, rEndPt ) );
122 if ( !IsDeviceOutputNecessary() || (!mbLineColor && !mbFillColor) || ImplIsRecordLayout() )
123 return;
125 tools::Rectangle aRect( ImplLogicToDevicePixel( rRect ) );
126 if ( aRect.IsEmpty() )
127 return;
129 // we need a graphics
130 if ( !mpGraphics && !AcquireGraphics() )
131 return;
133 if ( mbInitClipRegion )
134 InitClipRegion();
135 if ( mbOutputClipped )
136 return;
138 if ( mbInitLineColor )
139 InitLineColor();
141 const Point aStart( ImplLogicToDevicePixel( rStartPt ) );
142 const Point aEnd( ImplLogicToDevicePixel( rEndPt ) );
143 tools::Polygon aPiePoly( aRect, aStart, aEnd, PolyStyle::Pie );
145 if ( aPiePoly.GetSize() >= 2 )
147 SalPoint* pPtAry = reinterpret_cast<SalPoint*>(aPiePoly.GetPointAry());
148 if ( !mbFillColor )
149 mpGraphics->DrawPolyLine( aPiePoly.GetSize(), pPtAry, this );
150 else
152 if ( mbInitFillColor )
153 InitFillColor();
154 mpGraphics->DrawPolygon( aPiePoly.GetSize(), pPtAry, this );
158 if( mpAlphaVDev )
159 mpAlphaVDev->DrawPie( rRect, rStartPt, rEndPt );
162 void OutputDevice::DrawChord( const tools::Rectangle& rRect,
163 const Point& rStartPt, const Point& rEndPt )
165 assert(!is_double_buffered_window());
167 if ( mpMetaFile )
168 mpMetaFile->AddAction( new MetaChordAction( rRect, rStartPt, rEndPt ) );
170 if ( !IsDeviceOutputNecessary() || (!mbLineColor && !mbFillColor) || ImplIsRecordLayout() )
171 return;
173 tools::Rectangle aRect( ImplLogicToDevicePixel( rRect ) );
174 if ( aRect.IsEmpty() )
175 return;
177 // we need a graphics
178 if ( !mpGraphics && !AcquireGraphics() )
179 return;
181 if ( mbInitClipRegion )
182 InitClipRegion();
183 if ( mbOutputClipped )
184 return;
186 if ( mbInitLineColor )
187 InitLineColor();
189 const Point aStart( ImplLogicToDevicePixel( rStartPt ) );
190 const Point aEnd( ImplLogicToDevicePixel( rEndPt ) );
191 tools::Polygon aChordPoly( aRect, aStart, aEnd, PolyStyle::Chord );
193 if ( aChordPoly.GetSize() >= 2 )
195 SalPoint* pPtAry = reinterpret_cast<SalPoint*>(aChordPoly.GetPointAry());
196 if ( !mbFillColor )
197 mpGraphics->DrawPolyLine( aChordPoly.GetSize(), pPtAry, this );
198 else
200 if ( mbInitFillColor )
201 InitFillColor();
202 mpGraphics->DrawPolygon( aChordPoly.GetSize(), pPtAry, this );
206 if( mpAlphaVDev )
207 mpAlphaVDev->DrawChord( rRect, rStartPt, rEndPt );
210 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */