Revert "Revert "Revert "stronger typing for SwClient::GetRegisteredIn"" and fix SwIte...
[LibreOffice.git] / vcl / source / outdev / curvedshapes.cxx
blobb5a13fb721d91838bb7b0a25c48d592bd281e182
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 <vcl/metaact.hxx>
21 #include <vcl/virdev.hxx>
23 #include <salgdi.hxx>
25 #include <cassert>
27 void OutputDevice::DrawEllipse( const tools::Rectangle& rRect )
29 assert(!is_double_buffered_window());
31 if ( mpMetaFile )
32 mpMetaFile->AddAction( new MetaEllipseAction( rRect ) );
34 if ( !IsDeviceOutputNecessary() || (!mbLineColor && !mbFillColor) || ImplIsRecordLayout() )
35 return;
37 tools::Rectangle aRect( ImplLogicToDevicePixel( rRect ) );
38 if ( aRect.IsEmpty() )
39 return;
41 // we need a graphics
42 if ( !mpGraphics && !AcquireGraphics() )
43 return;
44 assert(mpGraphics);
46 if ( mbInitClipRegion )
47 InitClipRegion();
48 if ( mbOutputClipped )
49 return;
51 if ( mbInitLineColor )
52 InitLineColor();
54 tools::Polygon aRectPoly( aRect.Center(), aRect.GetWidth() >> 1, aRect.GetHeight() >> 1 );
55 if ( aRectPoly.GetSize() >= 2 )
57 Point* pPtAry = aRectPoly.GetPointAry();
58 if ( !mbFillColor )
59 mpGraphics->DrawPolyLine( aRectPoly.GetSize(), pPtAry, *this );
60 else
62 if ( mbInitFillColor )
63 InitFillColor();
64 mpGraphics->DrawPolygon( aRectPoly.GetSize(), pPtAry, *this );
68 if( mpAlphaVDev )
69 mpAlphaVDev->DrawEllipse( rRect );
72 void OutputDevice::DrawArc( const tools::Rectangle& rRect,
73 const Point& rStartPt, const Point& rEndPt )
75 assert(!is_double_buffered_window());
77 if ( mpMetaFile )
78 mpMetaFile->AddAction( new MetaArcAction( rRect, rStartPt, rEndPt ) );
80 if ( !IsDeviceOutputNecessary() || !mbLineColor || ImplIsRecordLayout() )
81 return;
83 tools::Rectangle aRect( ImplLogicToDevicePixel( rRect ) );
84 if ( aRect.IsEmpty() )
85 return;
87 // we need a graphics
88 if ( !mpGraphics && !AcquireGraphics() )
89 return;
90 assert(mpGraphics);
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 Point* pPtAry = 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;
132 assert(mpGraphics);
134 if ( mbInitClipRegion )
135 InitClipRegion();
136 if ( mbOutputClipped )
137 return;
139 if ( mbInitLineColor )
140 InitLineColor();
142 const Point aStart( ImplLogicToDevicePixel( rStartPt ) );
143 const Point aEnd( ImplLogicToDevicePixel( rEndPt ) );
144 tools::Polygon aPiePoly( aRect, aStart, aEnd, PolyStyle::Pie );
146 if ( aPiePoly.GetSize() >= 2 )
148 Point* pPtAry = aPiePoly.GetPointAry();
149 if ( !mbFillColor )
150 mpGraphics->DrawPolyLine( aPiePoly.GetSize(), pPtAry, *this );
151 else
153 if ( mbInitFillColor )
154 InitFillColor();
155 mpGraphics->DrawPolygon( aPiePoly.GetSize(), pPtAry, *this );
159 if( mpAlphaVDev )
160 mpAlphaVDev->DrawPie( rRect, rStartPt, rEndPt );
163 void OutputDevice::DrawChord( const tools::Rectangle& rRect,
164 const Point& rStartPt, const Point& rEndPt )
166 assert(!is_double_buffered_window());
168 if ( mpMetaFile )
169 mpMetaFile->AddAction( new MetaChordAction( rRect, rStartPt, rEndPt ) );
171 if ( !IsDeviceOutputNecessary() || (!mbLineColor && !mbFillColor) || ImplIsRecordLayout() )
172 return;
174 tools::Rectangle aRect( ImplLogicToDevicePixel( rRect ) );
175 if ( aRect.IsEmpty() )
176 return;
178 // we need a graphics
179 if ( !mpGraphics && !AcquireGraphics() )
180 return;
181 assert(mpGraphics);
183 if ( mbInitClipRegion )
184 InitClipRegion();
185 if ( mbOutputClipped )
186 return;
188 if ( mbInitLineColor )
189 InitLineColor();
191 const Point aStart( ImplLogicToDevicePixel( rStartPt ) );
192 const Point aEnd( ImplLogicToDevicePixel( rEndPt ) );
193 tools::Polygon aChordPoly( aRect, aStart, aEnd, PolyStyle::Chord );
195 if ( aChordPoly.GetSize() >= 2 )
197 Point* pPtAry = aChordPoly.GetPointAry();
198 if ( !mbFillColor )
199 mpGraphics->DrawPolyLine( aChordPoly.GetSize(), pPtAry, *this );
200 else
202 if ( mbInitFillColor )
203 InitFillColor();
204 mpGraphics->DrawPolygon( aChordPoly.GetSize(), pPtAry, *this );
208 if( mpAlphaVDev )
209 mpAlphaVDev->DrawChord( rRect, rStartPt, rEndPt );
212 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */