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 <main.hxx>
31 : : #include <chart.hxx>
32 : : #include <outact.hxx>
33 : : #include <math.h>
34 : :
35 : : using namespace ::com::sun::star;
36 : :
37 : 0 : double CGM::ImplGetOrientation( FloatPoint& rCenter, FloatPoint& rPoint )
38 : : {
39 : : double fOrientation;
40 : :
41 : 0 : double nX = rPoint.X - rCenter.X;
42 : 0 : double nY = rPoint.Y - rCenter.Y;
43 : :
44 : 0 : fOrientation = acos( nX / sqrt( nX * nX + nY * nY ) ) * 57.29577951308;
45 : 0 : if ( nY > 0 )
46 : 0 : fOrientation = 360 - fOrientation;
47 : :
48 : 0 : return fOrientation;
49 : : }
50 : :
51 : : // ---------------------------------------------------------------
52 : :
53 : 0 : void CGM::ImplSwitchStartEndAngle( double& rStartAngle, double& rEndAngle )
54 : : {
55 : : double nTemp;
56 : 0 : nTemp = rStartAngle;
57 : 0 : rStartAngle = rEndAngle;
58 : 0 : rEndAngle = nTemp;
59 : 0 : }
60 : :
61 : : // ---------------------------------------------------------------
62 : :
63 : 0 : void CGM::ImplGetVector( double* pVector )
64 : : {
65 : 0 : if ( pElement->eVDCType == VDC_REAL )
66 : : {
67 : 0 : for ( sal_uInt32 i = 0; i < 4; i++ )
68 : : {
69 : 0 : pVector[ i ] = (double)ImplGetFloat( pElement->eVDCRealPrecision, pElement->nVDCRealSize );
70 : : }
71 : : }
72 : : else
73 : : {
74 : 0 : for ( sal_uInt32 i = 0; i < 4; i++ )
75 : : {
76 : 0 : pVector[ i ] = (double)ImplGetI( pElement->nVDCIntegerPrecision );
77 : : }
78 : : }
79 : 0 : pVector[ 0 ] *= mnVDCXmul;
80 : 0 : pVector[ 2 ] *= mnVDCXmul;
81 : 0 : pVector[ 1 ] *= mnVDCYmul;
82 : 0 : pVector[ 3 ] *= mnVDCYmul;
83 : 0 : }
84 : :
85 : : // ---------------------------------------------------------------
86 : 0 : sal_Bool CGM::ImplGetEllipse( FloatPoint& rCenter, FloatPoint& rRadius, double& rAngle )
87 : : {
88 : 0 : FloatPoint aPoint1, aPoint2;
89 : : double fRot1, fRot2;
90 : 0 : ImplGetPoint( rCenter, sal_True );
91 : 0 : ImplGetPoint( aPoint1, sal_True );
92 : 0 : ImplGetPoint( aPoint2, sal_True );
93 : 0 : fRot1 = ImplGetOrientation( rCenter, aPoint1 );
94 : 0 : fRot2 = ImplGetOrientation( rCenter, aPoint2 );
95 : 0 : rAngle = ImplGetOrientation( rCenter, aPoint1 );
96 : 0 : aPoint1.X -= rCenter.X;
97 : 0 : aPoint1.Y -= rCenter.Y;
98 : 0 : rRadius.X = sqrt( aPoint1.X * aPoint1.X + aPoint1.Y * aPoint1.Y );
99 : 0 : aPoint2.X -= rCenter.X;
100 : 0 : aPoint2.Y -= rCenter.Y;
101 : 0 : rRadius.Y = sqrt( aPoint2.X * aPoint2.X + aPoint2.Y * aPoint2.Y );
102 : :
103 : 0 : if ( fRot1 > fRot2 )
104 : : {
105 : 0 : if ( ( fRot1 - fRot2 ) < 180 )
106 : 0 : return sal_False;
107 : : }
108 : : else
109 : : {
110 : 0 : if ( ( fRot2 - fRot1 ) > 180 )
111 : 0 : return sal_False;
112 : : }
113 : 0 : return sal_True;
114 : : }
115 : :
116 : 0 : void CGM::ImplDoClass4()
117 : : {
118 : 0 : if ( mbFirstOutPut )
119 : 0 : mpOutAct->FirstOutPut();
120 : :
121 : 0 : if ( mpBitmapInUse && ( mnElementID != 9 ) ) // vorhandene grafik verarbeiten,
122 : : { // da jetzt nicht bitmap actions anstehen
123 : 0 : CGMBitmapDescriptor* pBmpDesc = mpBitmapInUse->GetBitmap();
124 : : // irgendetwas mit der Bitmap anfangen
125 : 0 : mpOutAct->DrawBitmap( pBmpDesc );
126 : 0 : delete mpBitmapInUse;
127 : 0 : mpBitmapInUse = NULL;
128 : : }
129 : :
130 : 0 : if ( ( mpChart == NULL ) || mpChart->IsAnnotation() )
131 : : {
132 : 0 : switch ( mnElementID )
133 : : {
134 : : case 0x01 : /*PolyLine*/
135 : : {
136 : 0 : sal_uInt32 nPoints = mnElementSize / ImplGetPointSize();
137 : 0 : Polygon aPolygon( (sal_uInt16)nPoints );
138 : 0 : for ( sal_uInt16 i = 0; i < nPoints; i++)
139 : : {
140 : 0 : FloatPoint aFloatPoint;
141 : 0 : ImplGetPoint( aFloatPoint, sal_True );
142 : 0 : aPolygon.SetPoint( Point( (long)aFloatPoint.X, (long)aFloatPoint.Y ), i );
143 : : }
144 : 0 : if ( mbFigure )
145 : 0 : mpOutAct->RegPolyLine( aPolygon );
146 : : else
147 : 0 : mpOutAct->DrawPolyLine( aPolygon );
148 : : }
149 : 0 : break;
150 : :
151 : : case 0x02 : /*Disjoint PolyLine*/
152 : : {
153 : : sal_uInt16 nPoints = sal::static_int_cast< sal_uInt16 >(
154 : 0 : mnElementSize / ImplGetPointSize());
155 : 0 : if ( ! ( nPoints & 1 ) )
156 : : {
157 : 0 : nPoints >>= 1;
158 : 0 : FloatPoint aFloatPoint;
159 : 0 : if ( mbFigure )
160 : : {
161 : 0 : Polygon aPolygon( nPoints );
162 : 0 : for ( sal_uInt16 i = 0; i < nPoints; i++ )
163 : : {
164 : 0 : ImplGetPoint( aFloatPoint, sal_True );
165 : 0 : aPolygon.SetPoint( Point( (long)aFloatPoint.X, (long)aFloatPoint.Y ), 0 );
166 : : }
167 : 0 : mpOutAct->RegPolyLine( aPolygon );
168 : : }
169 : : else
170 : : {
171 : 0 : mpOutAct->BeginGroup();
172 : 0 : Polygon aPolygon( (sal_uInt16)2 );
173 : 0 : for ( sal_uInt16 i = 0; i < nPoints; i++ )
174 : : {
175 : 0 : ImplGetPoint( aFloatPoint, sal_True );
176 : 0 : aPolygon.SetPoint( Point( (long)aFloatPoint.X, (long)aFloatPoint.Y ), 0 );
177 : 0 : ImplGetPoint( aFloatPoint, sal_True );
178 : 0 : aPolygon.SetPoint( Point( (long)aFloatPoint.X, (long)aFloatPoint.Y ), 1);
179 : 0 : mpOutAct->DrawPolyLine( aPolygon );
180 : : }
181 : 0 : mpOutAct->EndGroup();
182 : : }
183 : : }
184 : : }
185 : 0 : break;
186 : :
187 : 0 : case 0x03 : /*PolyMarker*/ break;
188 : : case 0x04 : /*Text*/
189 : : {
190 : 0 : FloatPoint aFloatPoint;
191 : : sal_uInt32 nType, nSize;
192 : :
193 : 0 : if ( mbFigure )
194 : 0 : mpOutAct->CloseRegion();
195 : :
196 : 0 : ImplGetPoint ( aFloatPoint, sal_True );
197 : 0 : nType = ImplGetUI16( 4 );
198 : 0 : nSize = ImplGetUI( 1 );
199 : 0 : mpSource[ mnParaSize + nSize ] = 0;
200 : :
201 : 0 : awt::Size aSize;
202 : 0 : awt::Point aPoint( (long)aFloatPoint.X, (long)aFloatPoint.Y );
203 : : mpOutAct->DrawText( aPoint, aSize,
204 : 0 : (char*)mpSource + mnParaSize, nSize, (FinalFlag)nType );
205 : 0 : mnParaSize = mnElementSize;
206 : : }
207 : 0 : break;
208 : :
209 : : case 0x05 : /*Restricted Text*/
210 : : {
211 : : double dx, dy;
212 : 0 : FloatPoint aFloatPoint;
213 : : sal_uInt32 nType, nSize;
214 : :
215 : 0 : if ( mbFigure )
216 : 0 : mpOutAct->CloseRegion();
217 : :
218 : 0 : if ( pElement->eVDCType == VDC_REAL )
219 : : {
220 : 0 : dx = ImplGetFloat( pElement->eVDCRealPrecision, pElement->nVDCRealSize );
221 : 0 : dy = ImplGetFloat( pElement->eVDCRealPrecision, pElement->nVDCRealSize );
222 : : }
223 : : else
224 : : {
225 : 0 : dx = (double)ImplGetI( pElement->nVDCIntegerPrecision );
226 : 0 : dy = (double)ImplGetI( pElement->nVDCIntegerPrecision );
227 : : }
228 : 0 : ImplMapDouble( dx );
229 : 0 : ImplMapDouble( dy );
230 : :
231 : 0 : ImplGetPoint ( aFloatPoint, sal_True );
232 : 0 : nType = ImplGetUI16( 4 );
233 : 0 : nSize = ImplGetUI( 1 );
234 : :
235 : 0 : mpSource[ mnParaSize + nSize ] = 0;
236 : :
237 : 0 : awt::Point aPoint( (long)aFloatPoint.X, (long)aFloatPoint.Y );
238 : 0 : awt::Size aSize((long)dx, (long)dy);
239 : : mpOutAct->DrawText( aPoint, aSize ,
240 : 0 : (char*)mpSource + mnParaSize, nSize, (FinalFlag)nType );
241 : 0 : mnParaSize = mnElementSize;
242 : : }
243 : 0 : break;
244 : :
245 : : case 0x06 : /*Append Text*/
246 : : {
247 : : sal_uInt32 nSize;
248 : 0 : sal_uInt32 nType = ImplGetUI16( 4 );
249 : :
250 : 0 : nSize = ImplGetUI( 1 );
251 : 0 : mpSource[ mnParaSize + nSize ] = 0;
252 : :
253 : 0 : mpOutAct->AppendText( (char*)mpSource + mnParaSize, nSize, (FinalFlag)nType );
254 : 0 : mnParaSize = mnElementSize;
255 : : }
256 : 0 : break;
257 : :
258 : : case 0x07 : /*Polygon*/
259 : : {
260 : 0 : if ( mbFigure )
261 : 0 : mpOutAct->CloseRegion();
262 : :
263 : : sal_uInt16 nPoints = sal::static_int_cast< sal_uInt16 >(
264 : 0 : mnElementSize / ImplGetPointSize());
265 : 0 : Polygon aPolygon( nPoints );
266 : 0 : for ( sal_uInt16 i = 0; i < nPoints; i++)
267 : : {
268 : 0 : FloatPoint aFloatPoint;
269 : 0 : ImplGetPoint( aFloatPoint, sal_True );
270 : 0 : aPolygon.SetPoint( Point ( (long)( aFloatPoint.X ), (long)( aFloatPoint.Y ) ), i );
271 : : }
272 : 0 : mpOutAct->DrawPolygon( aPolygon );
273 : : }
274 : 0 : break;
275 : :
276 : : case 0x08 : /*Polygon Set*/
277 : : {
278 : 0 : if ( mbFigure )
279 : 0 : mpOutAct->CloseRegion();
280 : :
281 : 0 : sal_uInt16 nPoints = 0;
282 : 0 : Point* pPoints = new Point[ 0x4000 ];
283 : :
284 : 0 : PolyPolygon aPolyPolygon;
285 : 0 : FloatPoint aFloatPoint;
286 : : sal_uInt32 nEdgeFlag;
287 : 0 : while ( mnParaSize < mnElementSize )
288 : : {
289 : 0 : ImplGetPoint( aFloatPoint, sal_True );
290 : 0 : nEdgeFlag = ImplGetUI16();
291 : 0 : pPoints[ nPoints++ ] = Point( (long)aFloatPoint.X, (long)aFloatPoint.Y );
292 : 0 : if ( ( nEdgeFlag & 2 ) || ( mnParaSize == mnElementSize ) )
293 : : {
294 : 0 : Polygon aPolygon( nPoints );
295 : 0 : for ( sal_uInt16 i = 0; i < nPoints; i++ )
296 : : {
297 : 0 : aPolygon.SetPoint( pPoints[ i ], i );
298 : : }
299 : 0 : aPolyPolygon.Insert( aPolygon, POLYPOLY_APPEND );
300 : 0 : nPoints = 0;
301 : : }
302 : : }
303 : 0 : delete[] pPoints;
304 : 0 : mpOutAct->DrawPolyPolygon( aPolyPolygon );
305 : : }
306 : 0 : break;
307 : :
308 : : case 0x09 : /*Cell Array*/
309 : : {
310 : 0 : if ( mbFigure )
311 : 0 : mpOutAct->CloseRegion();
312 : :
313 : 0 : if ( mpBitmapInUse )
314 : : {
315 : 0 : CGMBitmap* pBmpDesc = mpBitmapInUse->GetNext();
316 : 0 : if ( pBmpDesc ) // eventuell bekommen wir eine bitmap zurück, die nicht
317 : : { // zur vorherigen paßt -> diese müssen wir dann auch löschen
318 : 0 : mpOutAct->DrawBitmap( pBmpDesc->GetBitmap() );
319 : 0 : delete pBmpDesc;
320 : : }
321 : : }
322 : : else
323 : : {
324 : 0 : mpBitmapInUse = new CGMBitmap( *this );
325 : : }
326 : : }
327 : 0 : break;
328 : :
329 : : case 0x0a : /*Generalized Drawing Primitive*/
330 : : {
331 : 0 : ImplGetI( pElement->nIntegerPrecision ); //-Wall is this needed
332 : 0 : ImplGetUI( pElement->nIntegerPrecision ); //-Wall is this needed
333 : 0 : mnParaSize = mnElementSize;
334 : : }
335 : 0 : break;
336 : :
337 : : case 0x0b : /*Rectangle*/
338 : : {
339 : 0 : if ( mbFigure )
340 : 0 : mpOutAct->CloseRegion();
341 : :
342 : 0 : FloatRect aFloatRect;
343 : 0 : ImplGetRectangle( aFloatRect, sal_True );
344 : 0 : mpOutAct->DrawRectangle( aFloatRect );
345 : : }
346 : 0 : break;
347 : :
348 : : case 0x0c : /*Circle*/
349 : : {
350 : 0 : if ( mbFigure )
351 : 0 : mpOutAct->CloseRegion();
352 : :
353 : 0 : double fRotation = 0;
354 : 0 : FloatPoint aCenter, aRadius;
355 : 0 : ImplGetPoint( aCenter, sal_True );
356 : 0 : if ( pElement->eVDCType == VDC_REAL )
357 : 0 : aRadius.X = ImplGetFloat( pElement->eVDCRealPrecision, pElement->nVDCRealSize );
358 : : else
359 : 0 : aRadius.X = (double)ImplGetI( pElement->nVDCIntegerPrecision );
360 : 0 : ImplMapDouble( aRadius.X );
361 : 0 : aRadius.Y = aRadius.X;
362 : 0 : mpOutAct->DrawEllipse( aCenter, aRadius, fRotation );
363 : : }
364 : 0 : break;
365 : :
366 : : case 0x0d : /*Circular Arc 3 Point*/
367 : : {
368 : 0 : FloatPoint aStartingPoint, aIntermediatePoint, aEndingPoint, aCenterPoint;
369 : 0 : ImplGetPoint( aStartingPoint, sal_True );
370 : 0 : ImplGetPoint( aIntermediatePoint, sal_True );
371 : 0 : ImplGetPoint( aEndingPoint, sal_True );
372 : :
373 : 0 : double fA = aIntermediatePoint.X - aStartingPoint.X;
374 : 0 : double fB = aIntermediatePoint.Y - aStartingPoint.Y;
375 : 0 : double fC = aEndingPoint.X - aStartingPoint.X;
376 : 0 : double fD = aEndingPoint.Y - aStartingPoint.Y;
377 : :
378 : 0 : double fE = fA * ( aStartingPoint.X + aIntermediatePoint.X ) + fB * ( aStartingPoint.Y + aIntermediatePoint.Y );
379 : 0 : double fF = fC * ( aStartingPoint.X + aEndingPoint.X ) + fD * ( aStartingPoint.Y + aEndingPoint.Y );
380 : :
381 : 0 : double fG = 2.0 * ( fA * ( aEndingPoint.Y - aIntermediatePoint.Y ) - fB * ( aEndingPoint.X - aIntermediatePoint.X ) );
382 : :
383 : 0 : aCenterPoint.X = ( fD * fE - fB * fF ) / fG;
384 : 0 : aCenterPoint.Y = ( fA * fF - fC * fE ) / fG;
385 : :
386 : 0 : if ( fG != 0 )
387 : : {
388 : 0 : double fStartAngle = ImplGetOrientation( aCenterPoint, aStartingPoint );
389 : 0 : double fInterAngle = ImplGetOrientation( aCenterPoint, aIntermediatePoint );
390 : 0 : double fEndAngle = ImplGetOrientation( aCenterPoint, aEndingPoint );
391 : :
392 : 0 : int nSwitch = 0;
393 : :
394 : 0 : if ( fStartAngle > fEndAngle )
395 : : {
396 : 0 : nSwitch ^=1;
397 : 0 : aIntermediatePoint = aEndingPoint;
398 : 0 : aEndingPoint = aStartingPoint;
399 : 0 : aStartingPoint = aIntermediatePoint;
400 : 0 : fG = fStartAngle;
401 : 0 : fStartAngle = fEndAngle;
402 : 0 : fEndAngle = fG;
403 : : }
404 : 0 : if ( ! ( fInterAngle > fStartAngle ) && ( fInterAngle < fEndAngle ) )
405 : : {
406 : 0 : nSwitch ^=1;
407 : 0 : aIntermediatePoint = aEndingPoint;
408 : 0 : aEndingPoint = aStartingPoint;
409 : 0 : aStartingPoint = aIntermediatePoint;
410 : 0 : fG = fStartAngle;
411 : 0 : fStartAngle = fEndAngle;
412 : 0 : fEndAngle = fG;
413 : : }
414 : 0 : double fRadius = sqrt( pow( ( aStartingPoint.X - aCenterPoint.X ), 2 ) + pow( ( aStartingPoint.Y - aCenterPoint.Y ), 2 ) ) ;
415 : :
416 : 0 : if ( mbFigure )
417 : : {
418 : : Rectangle aBoundingBox( Point( (long)( aCenterPoint.X - fRadius ), long( aCenterPoint.Y - fRadius ) ),
419 : 0 : Size( ( static_cast< long >( 2 * fRadius ) ), (long)( 2 * fRadius) ) );
420 : 0 : Polygon aPolygon( aBoundingBox, Point( (long)aStartingPoint.X, (long)aStartingPoint.Y ) ,Point( (long)aEndingPoint.X, (long)aEndingPoint.Y ), POLY_ARC );
421 : 0 : if ( nSwitch )
422 : 0 : mpOutAct->RegPolyLine( aPolygon, sal_True );
423 : : else
424 : 0 : mpOutAct->RegPolyLine( aPolygon );
425 : : }
426 : : else
427 : : {
428 : 0 : fG = 0;
429 : 0 : FloatPoint aRadius;
430 : 0 : aRadius.X = aRadius.Y = fRadius;
431 : 0 : mpOutAct->DrawEllipticalArc( aCenterPoint, aRadius, fG, 2, fStartAngle, fEndAngle );
432 : : }
433 : : }
434 : : }
435 : 0 : break;
436 : :
437 : : case 0x0e : /*Circular Arc 3 Point Close*/
438 : : {
439 : 0 : if ( mbFigure )
440 : 0 : mpOutAct->CloseRegion();
441 : :
442 : 0 : FloatPoint aStartingPoint, aIntermediatePoint, aEndingPoint, aCenterPoint;
443 : 0 : ImplGetPoint( aStartingPoint );
444 : 0 : ImplGetPoint( aIntermediatePoint );
445 : 0 : ImplGetPoint( aEndingPoint );
446 : :
447 : 0 : double fA = aIntermediatePoint.X - aStartingPoint.X;
448 : 0 : double fB = aIntermediatePoint.Y - aStartingPoint.Y;
449 : 0 : double fC = aEndingPoint.X - aStartingPoint.X;
450 : 0 : double fD = aEndingPoint.Y - aStartingPoint.Y;
451 : :
452 : 0 : double fE = fA * ( aStartingPoint.X + aIntermediatePoint.X ) + fB * ( aStartingPoint.Y + aIntermediatePoint.Y );
453 : 0 : double fF = fC * ( aStartingPoint.X + aEndingPoint.X ) + fD * ( aStartingPoint.Y + aEndingPoint.Y );
454 : :
455 : 0 : double fG = 2.0 * ( fA * ( aEndingPoint.Y - aIntermediatePoint.Y ) - fB * ( aEndingPoint.X - aIntermediatePoint.X ) );
456 : :
457 : 0 : aCenterPoint.X = ( fD * fE - fB * fF ) / fG;
458 : 0 : aCenterPoint.Y = ( fA * fF - fC * fE ) / fG;
459 : :
460 : 0 : if ( fG != 0 )
461 : : {
462 : 0 : double fStartAngle = ImplGetOrientation( aCenterPoint, aStartingPoint );
463 : 0 : double fInterAngle = ImplGetOrientation( aCenterPoint, aIntermediatePoint );
464 : 0 : double fEndAngle = ImplGetOrientation( aCenterPoint, aEndingPoint );
465 : :
466 : 0 : if ( fStartAngle > fEndAngle )
467 : : {
468 : 0 : aIntermediatePoint = aEndingPoint;
469 : 0 : aEndingPoint = aStartingPoint;
470 : 0 : aStartingPoint = aIntermediatePoint;
471 : 0 : fG = fStartAngle;
472 : 0 : fStartAngle = fEndAngle;
473 : 0 : fEndAngle = fG;
474 : : }
475 : 0 : if ( ! ( fInterAngle > fStartAngle ) && ( fInterAngle < fEndAngle ) )
476 : : {
477 : 0 : aIntermediatePoint = aEndingPoint;
478 : 0 : aEndingPoint = aStartingPoint;
479 : 0 : aStartingPoint = aIntermediatePoint;
480 : 0 : fG = fStartAngle;
481 : 0 : fStartAngle = fEndAngle;
482 : 0 : fEndAngle = fG;
483 : : }
484 : 0 : FloatPoint fRadius;
485 : 0 : fRadius.Y = fRadius.X = sqrt( pow( ( aStartingPoint.X - aCenterPoint.X ), 2 ) + pow( ( aStartingPoint.Y - aCenterPoint.Y ), 2 ) ) ;
486 : :
487 : 0 : sal_uInt32 nType = ImplGetUI16();
488 : 0 : if ( nType == 0 )
489 : 0 : nType = 0; // is PIE
490 : : else
491 : 0 : nType = 1; // is CHORD
492 : :
493 : 0 : double fOrientation = 0;
494 : 0 : mpOutAct->DrawEllipticalArc( aCenterPoint, fRadius, fOrientation, nType, fStartAngle, fEndAngle );
495 : : }
496 : : }
497 : 0 : break;
498 : :
499 : : case 0x0f : /*Circular Arc Centre*/
500 : : {
501 : : double fStartAngle, fEndAngle, vector[ 4 ];
502 : 0 : FloatPoint aCenter, aRadius;
503 : :
504 : 0 : if ( mbFigure )
505 : 0 : mpOutAct->CloseRegion();
506 : :
507 : 0 : ImplGetPoint( aCenter, sal_True );
508 : 0 : ImplGetVector( &vector[ 0 ] );
509 : :
510 : 0 : if ( pElement->eVDCType == VDC_REAL )
511 : : {
512 : 0 : aRadius.X = (double)ImplGetFloat( pElement->eVDCRealPrecision, pElement->nVDCRealSize );
513 : : }
514 : : else
515 : : {
516 : 0 : aRadius.X = (double)ImplGetI( pElement->nVDCIntegerPrecision );
517 : : }
518 : :
519 : 0 : ImplMapDouble( aRadius.X );
520 : 0 : aRadius.Y = aRadius.X;
521 : :
522 : 0 : fStartAngle = acos( vector[ 0 ] / sqrt( vector[ 0 ] * vector[ 0 ] + vector[ 1 ] * vector[ 1 ] ) ) * 57.29577951308;
523 : 0 : fEndAngle = acos( vector[ 2 ] / sqrt( vector[ 2 ] * vector[ 2 ] + vector[ 3 ] * vector[ 3 ] ) ) * 57.29577951308;
524 : :
525 : 0 : if ( vector[ 1 ] > 0 )
526 : 0 : fStartAngle = 360 - fStartAngle;
527 : 0 : if ( vector[ 3 ] > 0 )
528 : 0 : fEndAngle = 360 - fEndAngle;
529 : :
530 : 0 : if ( mbAngReverse )
531 : 0 : ImplSwitchStartEndAngle( fStartAngle, fEndAngle );
532 : :
533 : 0 : if ( mbFigure )
534 : : {
535 : : Rectangle aBoundingBox(
536 : : Point( (long)( aCenter.X - aRadius.X ), long( aCenter.Y - aRadius.X ) ),
537 : 0 : Size( static_cast< long >( 2 * aRadius.X ), (long)( 2 * aRadius.X ) ) );
538 : : Polygon aPolygon( aBoundingBox,
539 : 0 : Point( (long)vector[ 0 ], (long)vector[ 1 ] ),
540 : 0 : Point( (long)vector[ 2 ], (long)vector[ 3 ] ), POLY_ARC );
541 : 0 : mpOutAct->RegPolyLine( aPolygon );
542 : : }
543 : : else
544 : : {
545 : 0 : double fOrientation = 0;
546 : 0 : mpOutAct->DrawEllipticalArc( aCenter, aRadius, fOrientation, 2, fStartAngle, fEndAngle );
547 : : }
548 : 0 : mnParaSize = mnElementSize;
549 : :
550 : : }
551 : 0 : break;
552 : :
553 : : case 0x10 : /*Circular Arc Centre Close*/
554 : : {
555 : : double fOrientation, fStartAngle, fEndAngle, vector[ 4 ];
556 : 0 : FloatPoint aCenter, aRadius;
557 : :
558 : 0 : if ( mbFigure )
559 : 0 : mpOutAct->CloseRegion();
560 : :
561 : 0 : ImplGetPoint( aCenter, sal_True );
562 : 0 : ImplGetVector( &vector[ 0 ] );
563 : 0 : if ( pElement->eVDCType == VDC_REAL )
564 : : {
565 : 0 : aRadius.X = (double)ImplGetFloat( pElement->eVDCRealPrecision, pElement->nVDCRealSize );
566 : : }
567 : : else
568 : : {
569 : 0 : aRadius.X = (double)ImplGetI( pElement->nVDCIntegerPrecision );
570 : : }
571 : 0 : ImplMapDouble( aRadius.X );
572 : 0 : aRadius.Y = aRadius.X;
573 : 0 : fStartAngle = acos( vector[ 0 ] / sqrt( vector[ 0 ] * vector[ 0 ] + vector[ 1 ] * vector[ 1 ] ) ) * 57.29577951308;
574 : 0 : fEndAngle = acos( vector[ 2 ] / sqrt( vector[ 2 ] * vector[ 2 ] + vector[ 3 ] * vector[ 3 ] ) ) * 57.29577951308;
575 : :
576 : 0 : if ( vector[ 1 ] > 0 )
577 : 0 : fStartAngle = 360 - fStartAngle;
578 : 0 : if ( vector[ 3 ] > 0 )
579 : 0 : fEndAngle = 360 - fEndAngle;
580 : :
581 : 0 : if ( mbAngReverse )
582 : 0 : ImplSwitchStartEndAngle( fStartAngle, fEndAngle );
583 : :
584 : :
585 : 0 : sal_uInt32 nType = ImplGetUI16();
586 : 0 : if ( nType == 0 )
587 : 0 : nType = 0; // is PIE
588 : : else
589 : 0 : nType = 1; // is CHORD
590 : 0 : fOrientation = 0;
591 : :
592 : : mpOutAct->DrawEllipticalArc( aCenter, aRadius, fOrientation,
593 : 0 : nType, fStartAngle, fEndAngle );
594 : 0 : mnParaSize = mnElementSize;
595 : : }
596 : 0 : break;
597 : :
598 : : case 0x11 : /*Ellipse*/
599 : : {
600 : : double fOrientation;
601 : 0 : FloatPoint aCenter, aRadius;
602 : :
603 : 0 : if ( mbFigure )
604 : 0 : mpOutAct->CloseRegion();
605 : :
606 : 0 : ImplGetEllipse( aCenter, aRadius, fOrientation ) ;
607 : 0 : mpOutAct->DrawEllipse( aCenter, aRadius, fOrientation ) ;
608 : : }
609 : 0 : break;
610 : :
611 : : case 0x12 : /*Elliptical Arc*/
612 : : {
613 : 0 : if ( mbFigure )
614 : 0 : mpOutAct->CloseRegion();
615 : :
616 : : double fOrientation, fStartAngle, fEndAngle, vector[ 4 ];
617 : 0 : FloatPoint aCenter, aRadius;
618 : :
619 : 0 : if ( mbFigure )
620 : 0 : mpOutAct->CloseRegion();
621 : :
622 : 0 : sal_Bool bDirection = ImplGetEllipse( aCenter, aRadius, fOrientation );
623 : 0 : ImplGetVector( &vector[ 0 ] );
624 : :
625 : 0 : fStartAngle = acos( vector[ 0 ] / sqrt( vector[ 0 ] * vector[ 0 ] + vector[ 1 ] * vector[ 1 ] ) ) * 57.29577951308;
626 : 0 : fEndAngle = acos( vector[ 2 ] / sqrt( vector[ 2 ] * vector[ 2 ] + vector[ 3 ] * vector[ 3 ] ) ) * 57.29577951308;
627 : :
628 : 0 : if ( vector[ 1 ] > 0 )
629 : 0 : fStartAngle = 360 - fStartAngle;
630 : 0 : if ( vector[ 3 ] > 0 )
631 : 0 : fEndAngle = 360 - fEndAngle;
632 : :
633 : 0 : if ( bDirection )
634 : : mpOutAct->DrawEllipticalArc( aCenter, aRadius, fOrientation,
635 : 0 : 2, fStartAngle, fEndAngle );
636 : : else
637 : : mpOutAct->DrawEllipticalArc( aCenter, aRadius, fOrientation,
638 : 0 : 2, fEndAngle, fStartAngle);
639 : : }
640 : 0 : break;
641 : :
642 : : case 0x13 : /*Elliptical Arc Close*/
643 : : {
644 : : double fOrientation, fStartAngle, fEndAngle, vector[ 4 ];
645 : 0 : FloatPoint aCenter, aRadius;
646 : :
647 : 0 : if ( mbFigure )
648 : 0 : mpOutAct->CloseRegion();
649 : :
650 : 0 : sal_Bool bDirection = ImplGetEllipse( aCenter, aRadius, fOrientation );
651 : 0 : ImplGetVector( &vector[ 0 ] );
652 : :
653 : 0 : fStartAngle = acos( vector[ 0 ] / sqrt( vector[ 0 ] * vector[ 0 ] + vector[ 1 ] * vector[ 1 ] ) ) * 57.29577951308;
654 : 0 : fEndAngle = acos( vector[ 2 ] / sqrt( vector[ 2 ] * vector[ 2 ] + vector[ 3 ] * vector[ 3 ] ) ) * 57.29577951308;
655 : :
656 : 0 : if ( vector[ 1 ] > 0 )
657 : 0 : fStartAngle = 360 - fStartAngle;
658 : 0 : if ( vector[ 3 ] > 0 )
659 : 0 : fEndAngle = 360 - fEndAngle;
660 : :
661 : 0 : sal_uInt32 nType = ImplGetUI16();
662 : 0 : if ( nType == 0 )
663 : 0 : nType = 0; // is PIE
664 : : else
665 : 0 : nType = 1; // is CHORD
666 : :
667 : 0 : if ( bDirection )
668 : : mpOutAct->DrawEllipticalArc( aCenter, aRadius, fOrientation,
669 : 0 : nType, fStartAngle, fEndAngle );
670 : : else
671 : : mpOutAct->DrawEllipticalArc( aCenter, aRadius, fOrientation,
672 : 0 : nType, fEndAngle, fStartAngle);
673 : : }
674 : 0 : break;
675 : : case 0x14 : /*Circular Arc Centre Reversed*/
676 : : {
677 : 0 : if ( mbFigure )
678 : 0 : mpOutAct->CloseRegion();
679 : : }
680 : 0 : break;
681 : : case 0x15 : /*Connection Edge */ // NS
682 : : {
683 : : // if ( mbFigure )
684 : : // mpOutAct->CloseRegion();
685 : : }
686 : 0 : break;
687 : : case 0x16 : /*Hyperbolic Arc */ // NS
688 : : {
689 : 0 : if ( mbFigure )
690 : 0 : mpOutAct->CloseRegion();
691 : : }
692 : 0 : break;
693 : : case 0x17 : /*Parabolic Arc */ // NS
694 : : {
695 : 0 : if ( mbFigure )
696 : 0 : mpOutAct->CloseRegion();
697 : : }
698 : 0 : break;
699 : : case 0x18 : /*Non Uniform B-Spline */ // NS
700 : : {
701 : 0 : if ( mbFigure )
702 : 0 : mpOutAct->CloseRegion();
703 : : }
704 : 0 : break;
705 : : case 0x19 : /*Non Uniform Rational B-Spline */ // NS
706 : : {
707 : 0 : if ( mbFigure )
708 : 0 : mpOutAct->CloseRegion();
709 : : }
710 : 0 : break;
711 : : case 0x1a : /*Polybezier*/
712 : : {
713 : 0 : sal_uInt32 nOrder = ImplGetI( pElement->nIntegerPrecision );
714 : :
715 : 0 : sal_uInt16 nNumberOfPoints = sal::static_int_cast< sal_uInt16 >(( mnElementSize - pElement->nIntegerPrecision ) / ImplGetPointSize());
716 : :
717 : 0 : Polygon aPolygon( nNumberOfPoints );
718 : :
719 : 0 : for ( sal_uInt16 i = 0; i < nNumberOfPoints; i++)
720 : : {
721 : 0 : FloatPoint aFloatPoint;
722 : 0 : ImplGetPoint( aFloatPoint, sal_True );
723 : 0 : aPolygon.SetPoint( Point ( (long)( aFloatPoint.X ), (long)( aFloatPoint.Y ) ), i );
724 : : }
725 : 0 : if ( nOrder & 4 )
726 : : {
727 : 0 : for ( sal_uInt16 i = 0; i < nNumberOfPoints; i++ )
728 : : {
729 : 0 : if ( ( i % 3 ) == 0 )
730 : 0 : aPolygon.SetFlags( i, POLY_NORMAL );
731 : : else
732 : 0 : aPolygon.SetFlags( i, POLY_CONTROL );
733 : : }
734 : : }
735 : : else
736 : : {
737 : 0 : for ( sal_uInt16 i = 0; i < nNumberOfPoints; i++ )
738 : : {
739 : 0 : switch ( i & 3 )
740 : : {
741 : : case 0 :
742 : 0 : case 3 : aPolygon.SetFlags( i, POLY_NORMAL ); break;
743 : 0 : default : aPolygon.SetFlags( i, POLY_CONTROL ); break;
744 : : }
745 : : }
746 : : }
747 : 0 : if ( mbFigure )
748 : 0 : mpOutAct->RegPolyLine( aPolygon );
749 : : else
750 : 0 : mpOutAct->DrawPolybezier( aPolygon );
751 : 0 : mnParaSize = mnElementSize;
752 : : }
753 : 0 : break;
754 : :
755 : : case 0x1b : /*Polysymbol */ // NS
756 : : {
757 : 0 : if ( mbFigure )
758 : 0 : mpOutAct->CloseRegion();
759 : : }
760 : 0 : break;
761 : : case 0x1c : /*Bitonal Tile */ // NS
762 : : {
763 : 0 : if ( mbFigure )
764 : 0 : mpOutAct->CloseRegion();
765 : : }
766 : 0 : break;
767 : : case 0x1d : /*Tile */ // NS
768 : : {
769 : 0 : if ( mbFigure )
770 : 0 : mpOutAct->CloseRegion();
771 : : }
772 : 0 : break;
773 : : case 0x1e : /*Insert Object*/
774 : : {
775 : 0 : if ( mbFigure )
776 : 0 : mpOutAct->CloseRegion();
777 : : }
778 : 0 : break;
779 : : case 0xff : /*Polybezier*/
780 : : {
781 : 0 : if ( mbFigure )
782 : 0 : mpOutAct->CloseRegion();
783 : : }
784 : 0 : break;
785 : : case 0xfe : /*Sharp Polybezier*/
786 : : {
787 : 0 : if ( mbFigure )
788 : 0 : mpOutAct->CloseRegion();
789 : : }
790 : 0 : break;
791 : : case 0xfd : /*Polyspline*/
792 : : {
793 : 0 : if ( mbFigure )
794 : 0 : mpOutAct->CloseRegion();
795 : : }
796 : 0 : break;
797 : : case 0xfc : /*Reounded Rectangle*/
798 : : {
799 : 0 : if ( mbFigure )
800 : 0 : mpOutAct->CloseRegion();
801 : : }
802 : 0 : break;
803 : : case 0xfb : /*Begin Cell Array*/
804 : : {
805 : 0 : if ( mbFigure )
806 : 0 : mpOutAct->CloseRegion();
807 : : }
808 : 0 : break;
809 : : case 0xfa : /*End Cell Array*/
810 : : {
811 : 0 : if ( mbFigure )
812 : 0 : mpOutAct->CloseRegion();
813 : : }
814 : 0 : break;
815 : : case 0xf9 : /*Insert File*/
816 : : {
817 : 0 : if ( mbFigure )
818 : 0 : mpOutAct->CloseRegion();
819 : : }
820 : 0 : break;
821 : : case 0xf8 : /*Block Text*/
822 : : {
823 : 0 : if ( mbFigure )
824 : 0 : mpOutAct->CloseRegion();
825 : : }
826 : 0 : break;
827 : : case 0xf7 : /*Variable Width Polyline*/
828 : : {
829 : 0 : if ( mbFigure )
830 : 0 : mpOutAct->CloseRegion();
831 : : }
832 : 0 : break;
833 : : case 0xf6 : /*Elliptical Arc 3 Point*/
834 : : {
835 : 0 : if ( mbFigure )
836 : 0 : mpOutAct->CloseRegion();
837 : : }
838 : 0 : break;
839 : 0 : case 0xf1 : /*Hyperlink Definition */break;
840 : 0 : default: break;
841 : : }
842 : : }
843 : : else
844 : 0 : mnParaSize = mnElementSize;
845 : 0 : };
846 : :
847 : :
848 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|