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