Update ooo320-m1
[ooovba.git] / goodies / source / filter.vcl / icgm / class4.cxx
blob4fc900872912560525dae1ad55a755de4d520132
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: class4.cxx,v $
10 * $Revision: 1.9 $
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_goodies.hxx"
34 #include <main.hxx>
35 #include <chart.hxx>
36 #include <outact.hxx>
37 #include <math.h>
39 using namespace ::com::sun::star;
41 double CGM::ImplGetOrientation( FloatPoint& rCenter, FloatPoint& rPoint )
43 double fOrientation;
45 double nX = rPoint.X - rCenter.X;
46 double nY = rPoint.Y - rCenter.Y;
48 fOrientation = acos( nX / sqrt( nX * nX + nY * nY ) ) * 57.29577951308;
49 if ( nY > 0 )
50 fOrientation = 360 - fOrientation;
52 return fOrientation;
55 // ---------------------------------------------------------------
57 void CGM::ImplSwitchStartEndAngle( double& rStartAngle, double& rEndAngle )
59 double nTemp;
60 nTemp = rStartAngle;
61 rStartAngle = rEndAngle;
62 rEndAngle = nTemp;
65 // ---------------------------------------------------------------
67 void CGM::ImplGetVector( double* pVector )
69 if ( pElement->eVDCType == VDC_REAL )
71 for ( sal_uInt32 i = 0; i < 4; i++ )
73 pVector[ i ] = (double)ImplGetFloat( pElement->eVDCRealPrecision, pElement->nVDCRealSize );
76 else
78 for ( sal_uInt32 i = 0; i < 4; i++ )
80 pVector[ i ] = (double)ImplGetI( pElement->nVDCIntegerPrecision );
83 pVector[ 0 ] *= mnVDCXmul;
84 pVector[ 2 ] *= mnVDCXmul;
85 pVector[ 1 ] *= mnVDCYmul;
86 pVector[ 3 ] *= mnVDCYmul;
89 // ---------------------------------------------------------------
90 sal_Bool CGM::ImplGetEllipse( FloatPoint& rCenter, FloatPoint& rRadius, double& rAngle )
92 FloatPoint aPoint1, aPoint2;
93 double fRot1, fRot2;
94 ImplGetPoint( rCenter, sal_True );
95 ImplGetPoint( aPoint1, sal_True );
96 ImplGetPoint( aPoint2, sal_True );
97 fRot1 = ImplGetOrientation( rCenter, aPoint1 );
98 fRot2 = ImplGetOrientation( rCenter, aPoint2 );
99 rAngle = ImplGetOrientation( rCenter, aPoint1 );
100 aPoint1.X -= rCenter.X;
101 aPoint1.Y -= rCenter.Y;
102 rRadius.X = sqrt( aPoint1.X * aPoint1.X + aPoint1.Y * aPoint1.Y );
103 aPoint2.X -= rCenter.X;
104 aPoint2.Y -= rCenter.Y;
105 rRadius.Y = sqrt( aPoint2.X * aPoint2.X + aPoint2.Y * aPoint2.Y );
107 if ( fRot1 > fRot2 )
109 if ( ( fRot1 - fRot2 ) < 180 )
110 return sal_False;
112 else
114 if ( ( fRot2 - fRot1 ) > 180 )
115 return sal_False;
117 return sal_True;
120 void CGM::ImplDoClass4()
122 if ( mbFirstOutPut )
123 mpOutAct->FirstOutPut();
125 if ( mpBitmapInUse && ( mnElementID != 9 ) ) // vorhandene grafik verarbeiten,
126 { // da jetzt nicht bitmap actions anstehen
127 CGMBitmapDescriptor* pBmpDesc = mpBitmapInUse->GetBitmap();
128 // irgendetwas mit der Bitmap anfangen
129 mpOutAct->DrawBitmap( pBmpDesc );
130 delete mpBitmapInUse;
131 mpBitmapInUse = NULL;
134 if ( ( mpChart == NULL ) || mpChart->IsAnnotation() )
136 switch ( mnElementID )
138 case 0x01 : ComOut( CGM_LEVEL1, "PolyLine" )
140 sal_uInt32 nPoints = mnElementSize / ImplGetPointSize();
141 Polygon aPolygon( (sal_uInt16)nPoints );
142 for ( sal_uInt16 i = 0; i < nPoints; i++)
144 FloatPoint aFloatPoint;
145 ImplGetPoint( aFloatPoint, sal_True );
146 aPolygon.SetPoint( Point( (long)aFloatPoint.X, (long)aFloatPoint.Y ), i );
148 if ( mbFigure )
149 mpOutAct->RegPolyLine( aPolygon );
150 else
151 mpOutAct->DrawPolyLine( aPolygon );
153 break;
155 case 0x02 : ComOut( CGM_LEVEL1 | CGM_EXTENDED_PRIMITIVES_SET, "Disjoint PolyLine" )
157 USHORT nPoints = sal::static_int_cast< USHORT >(
158 mnElementSize / ImplGetPointSize());
159 if ( ! ( nPoints & 1 ) )
161 nPoints >>= 1;
162 FloatPoint aFloatPoint;
163 if ( mbFigure )
165 Polygon aPolygon( nPoints );
166 for ( sal_uInt16 i = 0; i < nPoints; i++ )
168 ImplGetPoint( aFloatPoint, sal_True );
169 aPolygon.SetPoint( Point( (long)aFloatPoint.X, (long)aFloatPoint.Y ), 0 );
171 mpOutAct->RegPolyLine( aPolygon );
173 else
175 mpOutAct->BeginGroup();
176 Polygon aPolygon( (sal_uInt16)2 );
177 for ( sal_uInt16 i = 0; i < nPoints; i++ )
179 ImplGetPoint( aFloatPoint, sal_True );
180 aPolygon.SetPoint( Point( (long)aFloatPoint.X, (long)aFloatPoint.Y ), 0 );
181 ImplGetPoint( aFloatPoint, sal_True );
182 aPolygon.SetPoint( Point( (long)aFloatPoint.X, (long)aFloatPoint.Y ), 1);
183 mpOutAct->DrawPolyLine( aPolygon );
185 mpOutAct->EndGroup();
189 break;
191 case 0x03 : ComOut( CGM_LEVEL1, "PolyMarker" ) break;
192 case 0x04 : ComOut( CGM_LEVEL1, "Text" )
194 FloatPoint aFloatPoint;
195 sal_uInt32 nType, nSize;
197 if ( mbFigure )
198 mpOutAct->CloseRegion();
200 ImplGetPoint ( aFloatPoint, sal_True );
201 nType = ImplGetUI16( 4 );
202 nSize = ImplGetUI( 1 );
203 mpSource[ mnParaSize + nSize ] = 0;
205 ComOut( CGM_DESCRIPTION, (char*)mpSource + mnParaSize );
207 awt::Size aSize;
208 awt::Point aPoint( (long)aFloatPoint.X, (long)aFloatPoint.Y );
209 mpOutAct->DrawText( aPoint, aSize,
210 (char*)mpSource + mnParaSize, nSize, (FinalFlag)nType );
211 // mnParaSize += nSize;
212 mnParaSize = mnElementSize;
214 break;
216 case 0x05 : ComOut( CGM_LEVEL1 | CGM_EXTENDED_PRIMITIVES_SET, "Restricted Text" )
218 double dx, dy;
219 FloatPoint aFloatPoint;
220 sal_uInt32 nType, nSize;
222 if ( mbFigure )
223 mpOutAct->CloseRegion();
225 if ( pElement->eVDCType == VDC_REAL )
227 dx = ImplGetFloat( pElement->eVDCRealPrecision, pElement->nVDCRealSize );
228 dy = ImplGetFloat( pElement->eVDCRealPrecision, pElement->nVDCRealSize );
230 else
232 dx = (double)ImplGetI( pElement->nVDCIntegerPrecision );
233 dy = (double)ImplGetI( pElement->nVDCIntegerPrecision );
235 ImplMapDouble( dx );
236 ImplMapDouble( dy );
238 ImplGetPoint ( aFloatPoint, sal_True );
239 nType = ImplGetUI16( 4 );
240 nSize = ImplGetUI( 1 );
242 mpSource[ mnParaSize + nSize ] = 0;
244 ComOut( CGM_DESCRIPTION, (char*)mpSource + mnParaSize );
246 awt::Point aPoint( (long)aFloatPoint.X, (long)aFloatPoint.Y );
247 awt::Size aSize((long)dx, (long)dy);
248 mpOutAct->DrawText( aPoint, aSize ,
249 (char*)mpSource + mnParaSize, nSize, (FinalFlag)nType );
250 // mnParaSize += nSize;
251 mnParaSize = mnElementSize;
253 break;
255 case 0x06 : ComOut( CGM_LEVEL1 | CGM_EXTENDED_PRIMITIVES_SET, "Append Text" )
257 sal_uInt32 nSize;
258 sal_uInt32 nType = ImplGetUI16( 4 );
260 nSize = ImplGetUI( 1 );
261 mpSource[ mnParaSize + nSize ] = 0;
263 ComOut( CGM_DESCRIPTION, (char*)mpSource + mnParaSize );
265 mpOutAct->AppendText( (char*)mpSource + mnParaSize, nSize, (FinalFlag)nType );
266 // mnParaSize += nSize;
267 mnParaSize = mnElementSize;
269 break;
271 case 0x07 : ComOut( CGM_LEVEL1, "Polygon" )
273 if ( mbFigure )
274 mpOutAct->CloseRegion();
276 USHORT nPoints = sal::static_int_cast< USHORT >(
277 mnElementSize / ImplGetPointSize());
278 Polygon aPolygon( nPoints );
279 for ( USHORT i = 0; i < nPoints; i++)
281 FloatPoint aFloatPoint;
282 ImplGetPoint( aFloatPoint, sal_True );
283 aPolygon.SetPoint( Point ( (long)( aFloatPoint.X ), (long)( aFloatPoint.Y ) ), i );
285 mpOutAct->DrawPolygon( aPolygon );
287 break;
289 case 0x08 : ComOut( CGM_LEVEL1 | CGM_EXTENDED_PRIMITIVES_SET, "Polygon Set" )
291 if ( mbFigure )
292 mpOutAct->CloseRegion();
294 USHORT nPoints = 0;
295 Point* pPoints = new Point[ 0x4000 ];
297 PolyPolygon aPolyPolygon;
298 FloatPoint aFloatPoint;
299 sal_uInt32 nEdgeFlag;
300 while ( mnParaSize < mnElementSize )
302 ImplGetPoint( aFloatPoint, sal_True );
303 nEdgeFlag = ImplGetUI16();
304 pPoints[ nPoints++ ] = Point( (long)aFloatPoint.X, (long)aFloatPoint.Y );
305 if ( ( nEdgeFlag & 2 ) || ( mnParaSize == mnElementSize ) )
307 Polygon aPolygon( nPoints );
308 for ( USHORT i = 0; i < nPoints; i++ )
310 aPolygon.SetPoint( pPoints[ i ], i );
312 aPolyPolygon.Insert( aPolygon, POLYPOLY_APPEND );
313 nPoints = 0;
316 delete[] pPoints;
317 mpOutAct->DrawPolyPolygon( aPolyPolygon );
319 break;
321 case 0x09 : ComOut( CGM_LEVEL1, "Cell Array" )
323 if ( mbFigure )
324 mpOutAct->CloseRegion();
326 if ( mpBitmapInUse )
328 CGMBitmap* pBmpDesc = mpBitmapInUse->GetNext();
329 if ( pBmpDesc ) // eventuell bekommen wir eine bitmap zurück, die nicht
330 { // zur vorherigen paßt -> diese müssen wir dann auch löschen
331 mpOutAct->DrawBitmap( pBmpDesc->GetBitmap() );
332 delete pBmpDesc;
335 else
337 mpBitmapInUse = new CGMBitmap( *this );
340 break;
342 case 0x0a : ComOut( CGM_LEVEL1, "Generalized Drawing Primitive" )
344 ImplGetI( pElement->nIntegerPrecision ); //-Wall is this needed
345 ImplGetUI( pElement->nIntegerPrecision ); //-Wall is this needed
346 mnParaSize = mnElementSize;
348 break;
350 case 0x0b : ComOut( CGM_LEVEL1 | CGM_EXTENDED_PRIMITIVES_SET, "Rectangle" )
352 if ( mbFigure )
353 mpOutAct->CloseRegion();
355 FloatRect aFloatRect;
356 ImplGetRectangle( aFloatRect, sal_True );
357 mpOutAct->DrawRectangle( aFloatRect );
359 break;
361 case 0x0c : ComOut( CGM_LEVEL1 | CGM_EXTENDED_PRIMITIVES_SET, "Circle" )
363 if ( mbFigure )
364 mpOutAct->CloseRegion();
366 double fRotation = 0;
367 FloatPoint aCenter, aRadius;
368 ImplGetPoint( aCenter, sal_True );
369 if ( pElement->eVDCType == VDC_REAL )
370 aRadius.X = ImplGetFloat( pElement->eVDCRealPrecision, pElement->nVDCRealSize );
371 else
372 aRadius.X = (double)ImplGetI( pElement->nVDCIntegerPrecision );
373 ImplMapDouble( aRadius.X );
374 aRadius.Y = aRadius.X;
375 mpOutAct->DrawEllipse( aCenter, aRadius, fRotation );
377 break;
379 case 0x0d : ComOut( CGM_LEVEL1 | CGM_EXTENDED_PRIMITIVES_SET, "Circular Arc 3 Point" )
381 int nSwitch = 0;
383 FloatPoint aStartingPoint, aIntermediatePoint, aEndingPoint, aCenterPoint;
384 ImplGetPoint( aStartingPoint, sal_True );
385 ImplGetPoint( aIntermediatePoint, sal_True );
386 ImplGetPoint( aEndingPoint, sal_True );
388 double fA = aIntermediatePoint.X - aStartingPoint.X;
389 double fB = aIntermediatePoint.Y - aStartingPoint.Y;
390 double fC = aEndingPoint.X - aStartingPoint.X;
391 double fD = aEndingPoint.Y - aStartingPoint.Y;
393 double fE = fA * ( aStartingPoint.X + aIntermediatePoint.X ) + fB * ( aStartingPoint.Y + aIntermediatePoint.Y );
394 double fF = fC * ( aStartingPoint.X + aEndingPoint.X ) + fD * ( aStartingPoint.Y + aEndingPoint.Y );
396 double fG = 2.0 * ( fA * ( aEndingPoint.Y - aIntermediatePoint.Y ) - fB * ( aEndingPoint.X - aIntermediatePoint.X ) );
398 aCenterPoint.X = ( fD * fE - fB * fF ) / fG;
399 aCenterPoint.Y = ( fA * fF - fC * fE ) / fG;
401 if ( fG != 0 )
403 double fStartAngle = ImplGetOrientation( aCenterPoint, aStartingPoint );
404 double fInterAngle = ImplGetOrientation( aCenterPoint, aIntermediatePoint );
405 double fEndAngle = ImplGetOrientation( aCenterPoint, aEndingPoint );
407 if ( fStartAngle > fEndAngle )
409 nSwitch ^=1;
410 aIntermediatePoint = aEndingPoint;
411 aEndingPoint = aStartingPoint;
412 aStartingPoint = aIntermediatePoint;
413 fG = fStartAngle;
414 fStartAngle = fEndAngle;
415 fEndAngle = fG;
417 if ( ! ( fInterAngle > fStartAngle ) && ( fInterAngle < fEndAngle ) )
419 nSwitch ^=1;
420 aIntermediatePoint = aEndingPoint;
421 aEndingPoint = aStartingPoint;
422 aStartingPoint = aIntermediatePoint;
423 fG = fStartAngle;
424 fStartAngle = fEndAngle;
425 fEndAngle = fG;
427 double fRadius = sqrt( pow( ( aStartingPoint.X - aCenterPoint.X ), 2 ) + pow( ( aStartingPoint.Y - aCenterPoint.Y ), 2 ) ) ;
429 if ( mbFigure )
431 Rectangle aBoundingBox( Point( (long)( aCenterPoint.X - fRadius ), long( aCenterPoint.Y - fRadius ) ),
432 Size( ( static_cast< long >( 2 * fRadius ) ), (long)( 2 * fRadius) ) );
433 Polygon aPolygon( aBoundingBox, Point( (long)aStartingPoint.X, (long)aStartingPoint.Y ) ,Point( (long)aEndingPoint.X, (long)aEndingPoint.Y ), POLY_ARC );
434 if ( nSwitch )
435 mpOutAct->RegPolyLine( aPolygon, sal_True );
436 else
437 mpOutAct->RegPolyLine( aPolygon );
439 else
441 fG = 0;
442 FloatPoint aRadius;
443 aRadius.X = aRadius.Y = fRadius;
444 mpOutAct->DrawEllipticalArc( aCenterPoint, aRadius, fG, 2, fStartAngle, fEndAngle );
448 break;
450 case 0x0e : ComOut( CGM_LEVEL1 | CGM_EXTENDED_PRIMITIVES_SET, "Circular Arc 3 Point Close" )
452 int nSwitch = 0;
454 if ( mbFigure )
455 mpOutAct->CloseRegion();
457 FloatPoint aStartingPoint, aIntermediatePoint, aEndingPoint, aCenterPoint;
458 ImplGetPoint( aStartingPoint );
459 ImplGetPoint( aIntermediatePoint );
460 ImplGetPoint( aEndingPoint );
462 double fA = aIntermediatePoint.X - aStartingPoint.X;
463 double fB = aIntermediatePoint.Y - aStartingPoint.Y;
464 double fC = aEndingPoint.X - aStartingPoint.X;
465 double fD = aEndingPoint.Y - aStartingPoint.Y;
467 double fE = fA * ( aStartingPoint.X + aIntermediatePoint.X ) + fB * ( aStartingPoint.Y + aIntermediatePoint.Y );
468 double fF = fC * ( aStartingPoint.X + aEndingPoint.X ) + fD * ( aStartingPoint.Y + aEndingPoint.Y );
470 double fG = 2.0 * ( fA * ( aEndingPoint.Y - aIntermediatePoint.Y ) - fB * ( aEndingPoint.X - aIntermediatePoint.X ) );
472 aCenterPoint.X = ( fD * fE - fB * fF ) / fG;
473 aCenterPoint.Y = ( fA * fF - fC * fE ) / fG;
475 if ( fG != 0 )
477 double fStartAngle = ImplGetOrientation( aCenterPoint, aStartingPoint );
478 double fInterAngle = ImplGetOrientation( aCenterPoint, aIntermediatePoint );
479 double fEndAngle = ImplGetOrientation( aCenterPoint, aEndingPoint );
481 if ( fStartAngle > fEndAngle )
483 nSwitch ^=1;
484 aIntermediatePoint = aEndingPoint;
485 aEndingPoint = aStartingPoint;
486 aStartingPoint = aIntermediatePoint;
487 fG = fStartAngle;
488 fStartAngle = fEndAngle;
489 fEndAngle = fG;
491 if ( ! ( fInterAngle > fStartAngle ) && ( fInterAngle < fEndAngle ) )
493 nSwitch ^=1;
494 aIntermediatePoint = aEndingPoint;
495 aEndingPoint = aStartingPoint;
496 aStartingPoint = aIntermediatePoint;
497 fG = fStartAngle;
498 fStartAngle = fEndAngle;
499 fEndAngle = fG;
501 FloatPoint fRadius;
502 fRadius.Y = fRadius.X = sqrt( pow( ( aStartingPoint.X - aCenterPoint.X ), 2 ) + pow( ( aStartingPoint.Y - aCenterPoint.Y ), 2 ) ) ;
504 sal_uInt32 nType = ImplGetUI16();
505 if ( nType == 0 )
506 nType = 0; // is PIE
507 else
508 nType = 1; // is CHORD
510 double fOrientation = 0;
511 mpOutAct->DrawEllipticalArc( aCenterPoint, fRadius, fOrientation, nType, fStartAngle, fEndAngle );
514 break;
516 case 0x0f : ComOut( CGM_LEVEL1 | CGM_EXTENDED_PRIMITIVES_SET, "Circular Arc Centre" )
518 double fOrientation, fStartAngle, fEndAngle, vector[ 4 ];
519 FloatPoint aCenter, aRadius;
521 if ( mbFigure )
522 mpOutAct->CloseRegion();
524 ImplGetPoint( aCenter, sal_True );
525 ImplGetVector( &vector[ 0 ] );
527 if ( pElement->eVDCType == VDC_REAL )
529 aRadius.X = (double)ImplGetFloat( pElement->eVDCRealPrecision, pElement->nVDCRealSize );
531 else
533 aRadius.X = (double)ImplGetI( pElement->nVDCIntegerPrecision );
536 ImplMapDouble( aRadius.X );
537 aRadius.Y = aRadius.X;
539 fStartAngle = acos( vector[ 0 ] / sqrt( vector[ 0 ] * vector[ 0 ] + vector[ 1 ] * vector[ 1 ] ) ) * 57.29577951308;
540 fEndAngle = acos( vector[ 2 ] / sqrt( vector[ 2 ] * vector[ 2 ] + vector[ 3 ] * vector[ 3 ] ) ) * 57.29577951308;
542 if ( vector[ 1 ] > 0 )
543 fStartAngle = 360 - fStartAngle;
544 if ( vector[ 3 ] > 0 )
545 fEndAngle = 360 - fEndAngle;
547 if ( mbAngReverse )
548 ImplSwitchStartEndAngle( fStartAngle, fEndAngle );
550 if ( mbFigure )
552 Rectangle aBoundingBox(
553 Point( (long)( aCenter.X - aRadius.X ), long( aCenter.Y - aRadius.X ) ),
554 Size( static_cast< long >( 2 * aRadius.X ), (long)( 2 * aRadius.X ) ) );
555 Polygon aPolygon( aBoundingBox,
556 Point( (long)vector[ 0 ], (long)vector[ 1 ] ),
557 Point( (long)vector[ 2 ], (long)vector[ 3 ] ), POLY_ARC );
558 mpOutAct->RegPolyLine( aPolygon );
560 else
562 fOrientation = 0;
563 mpOutAct->DrawEllipticalArc( aCenter, aRadius, fOrientation, 2, fStartAngle, fEndAngle );
565 mnParaSize = mnElementSize;
568 break;
570 case 0x10 : ComOut( CGM_LEVEL1 | CGM_EXTENDED_PRIMITIVES_SET, "Circular Arc Centre Close" )
572 double fOrientation, fStartAngle, fEndAngle, vector[ 4 ];
573 FloatPoint aCenter, aRadius;
575 if ( mbFigure )
576 mpOutAct->CloseRegion();
578 ImplGetPoint( aCenter, sal_True );
579 ImplGetVector( &vector[ 0 ] );
580 if ( pElement->eVDCType == VDC_REAL )
582 aRadius.X = (double)ImplGetFloat( pElement->eVDCRealPrecision, pElement->nVDCRealSize );
584 else
586 aRadius.X = (double)ImplGetI( pElement->nVDCIntegerPrecision );
588 ImplMapDouble( aRadius.X );
589 aRadius.Y = aRadius.X;
590 fStartAngle = acos( vector[ 0 ] / sqrt( vector[ 0 ] * vector[ 0 ] + vector[ 1 ] * vector[ 1 ] ) ) * 57.29577951308;
591 fEndAngle = acos( vector[ 2 ] / sqrt( vector[ 2 ] * vector[ 2 ] + vector[ 3 ] * vector[ 3 ] ) ) * 57.29577951308;
593 if ( vector[ 1 ] > 0 )
594 fStartAngle = 360 - fStartAngle;
595 if ( vector[ 3 ] > 0 )
596 fEndAngle = 360 - fEndAngle;
598 if ( mbAngReverse )
599 ImplSwitchStartEndAngle( fStartAngle, fEndAngle );
602 sal_uInt32 nType = ImplGetUI16();
603 if ( nType == 0 )
604 nType = 0; // is PIE
605 else
606 nType = 1; // is CHORD
607 fOrientation = 0;
609 mpOutAct->DrawEllipticalArc( aCenter, aRadius, fOrientation,
610 nType, fStartAngle, fEndAngle );
611 mnParaSize = mnElementSize;
613 break;
615 case 0x11 : ComOut( CGM_LEVEL1 | CGM_EXTENDED_PRIMITIVES_SET, "Ellipse" )
617 double fOrientation;
618 FloatPoint aCenter, aRadius;
620 if ( mbFigure )
621 mpOutAct->CloseRegion();
623 ImplGetEllipse( aCenter, aRadius, fOrientation ) ;
624 mpOutAct->DrawEllipse( aCenter, aRadius, fOrientation ) ;
626 break;
628 case 0x12 : ComOut( CGM_LEVEL1 | CGM_EXTENDED_PRIMITIVES_SET, "Elliptical Arc" )
630 if ( mbFigure )
631 mpOutAct->CloseRegion();
633 double fOrientation, fStartAngle, fEndAngle, vector[ 4 ];
634 FloatPoint aCenter, aRadius;
636 if ( mbFigure )
637 mpOutAct->CloseRegion();
639 sal_Bool bDirection = ImplGetEllipse( aCenter, aRadius, fOrientation );
640 ImplGetVector( &vector[ 0 ] );
642 fStartAngle = acos( vector[ 0 ] / sqrt( vector[ 0 ] * vector[ 0 ] + vector[ 1 ] * vector[ 1 ] ) ) * 57.29577951308;
643 fEndAngle = acos( vector[ 2 ] / sqrt( vector[ 2 ] * vector[ 2 ] + vector[ 3 ] * vector[ 3 ] ) ) * 57.29577951308;
645 if ( vector[ 1 ] > 0 )
646 fStartAngle = 360 - fStartAngle;
647 if ( vector[ 3 ] > 0 )
648 fEndAngle = 360 - fEndAngle;
650 if ( bDirection )
651 mpOutAct->DrawEllipticalArc( aCenter, aRadius, fOrientation,
652 2, fStartAngle, fEndAngle );
653 else
654 mpOutAct->DrawEllipticalArc( aCenter, aRadius, fOrientation,
655 2, fEndAngle, fStartAngle);
657 break;
659 case 0x13 : ComOut( CGM_LEVEL1 | CGM_EXTENDED_PRIMITIVES_SET, "Elliptical Arc Close" )
661 double fOrientation, fStartAngle, fEndAngle, vector[ 4 ];
662 FloatPoint aCenter, aRadius;
664 if ( mbFigure )
665 mpOutAct->CloseRegion();
667 sal_Bool bDirection = ImplGetEllipse( aCenter, aRadius, fOrientation );
668 ImplGetVector( &vector[ 0 ] );
670 fStartAngle = acos( vector[ 0 ] / sqrt( vector[ 0 ] * vector[ 0 ] + vector[ 1 ] * vector[ 1 ] ) ) * 57.29577951308;
671 fEndAngle = acos( vector[ 2 ] / sqrt( vector[ 2 ] * vector[ 2 ] + vector[ 3 ] * vector[ 3 ] ) ) * 57.29577951308;
673 if ( vector[ 1 ] > 0 )
674 fStartAngle = 360 - fStartAngle;
675 if ( vector[ 3 ] > 0 )
676 fEndAngle = 360 - fEndAngle;
678 sal_uInt32 nType = ImplGetUI16();
679 if ( nType == 0 )
680 nType = 0; // is PIE
681 else
682 nType = 1; // is CHORD
684 if ( bDirection )
685 mpOutAct->DrawEllipticalArc( aCenter, aRadius, fOrientation,
686 nType, fStartAngle, fEndAngle );
687 else
688 mpOutAct->DrawEllipticalArc( aCenter, aRadius, fOrientation,
689 nType, fEndAngle, fStartAngle);
691 break;
692 case 0x14 : ComOut( CGM_LEVEL2, "Circular Arc Centre Reversed" )
694 if ( mbFigure )
695 mpOutAct->CloseRegion();
697 break;
698 case 0x15 : ComOut( CGM_LEVEL2, "Connection Edge" ) // NS
700 // if ( mbFigure )
701 // mpOutAct->CloseRegion();
703 break;
704 case 0x16 : ComOut( CGM_LEVEL3, "Hyperbolic Arc" ) // NS
706 if ( mbFigure )
707 mpOutAct->CloseRegion();
709 break;
710 case 0x17 : ComOut( CGM_LEVEL3, "Parabolic Arc" ) // NS
712 if ( mbFigure )
713 mpOutAct->CloseRegion();
715 break;
716 case 0x18 : ComOut( CGM_LEVEL3, "Non Uniform B-Spline" ) // NS
718 if ( mbFigure )
719 mpOutAct->CloseRegion();
721 break;
722 case 0x19 : ComOut( CGM_LEVEL3, "Non Uniform Rational B-Spline" ) // NS
724 if ( mbFigure )
725 mpOutAct->CloseRegion();
727 break;
728 case 0x1a : ComOut( CGM_LEVEL3, "Polybezier" )
730 sal_uInt32 nOrder = ImplGetI( pElement->nIntegerPrecision );
732 USHORT nNumberOfPoints = sal::static_int_cast< USHORT >(( mnElementSize - pElement->nIntegerPrecision ) / ImplGetPointSize());
734 Polygon aPolygon( nNumberOfPoints );
736 for ( USHORT i = 0; i < nNumberOfPoints; i++)
738 FloatPoint aFloatPoint;
739 ImplGetPoint( aFloatPoint, sal_True );
740 aPolygon.SetPoint( Point ( (long)( aFloatPoint.X ), (long)( aFloatPoint.Y ) ), i );
742 if ( nOrder & 4 )
744 for ( USHORT i = 0; i < nNumberOfPoints; i++ )
746 if ( ( i % 3 ) == 0 )
747 aPolygon.SetFlags( i, POLY_NORMAL );
748 else
749 aPolygon.SetFlags( i, POLY_CONTROL );
752 else
754 for ( USHORT i = 0; i < nNumberOfPoints; i++ )
756 switch ( i & 3 )
758 case 0 :
759 case 3 : aPolygon.SetFlags( i, POLY_NORMAL ); break;
760 default : aPolygon.SetFlags( i, POLY_CONTROL ); break;
764 if ( mbFigure )
765 mpOutAct->RegPolyLine( aPolygon );
766 else
767 mpOutAct->DrawPolybezier( aPolygon );
768 mnParaSize = mnElementSize;
770 break;
772 case 0x1b : ComOut( CGM_LEVEL3, "Polysymbol" ) // NS
774 if ( mbFigure )
775 mpOutAct->CloseRegion();
777 break;
778 case 0x1c : ComOut( CGM_LEVEL3, "Bitonal Tile" ) // NS
780 if ( mbFigure )
781 mpOutAct->CloseRegion();
783 break;
784 case 0x1d : ComOut( CGM_LEVEL3, "Tile" ) // NS
786 if ( mbFigure )
787 mpOutAct->CloseRegion();
789 break;
790 case 0x1e : ComOut( CGM_UNKNOWN_LEVEL, "Insert Object" )
792 if ( mbFigure )
793 mpOutAct->CloseRegion();
795 break;
796 case 0xff : ComOut( CGM_GDSF_ONLY, "Polybezier" )
798 if ( mbFigure )
799 mpOutAct->CloseRegion();
801 break;
802 case 0xfe : ComOut( CGM_GDSF_ONLY, "Sharp Polybezier" )
804 if ( mbFigure )
805 mpOutAct->CloseRegion();
807 break;
808 case 0xfd : ComOut( CGM_GDSF_ONLY, "Polyspline" )
810 if ( mbFigure )
811 mpOutAct->CloseRegion();
813 break;
814 case 0xfc : ComOut( CGM_GDSF_ONLY, "Reounded Rectangle" )
816 if ( mbFigure )
817 mpOutAct->CloseRegion();
819 break;
820 case 0xfb : ComOut( CGM_GDSF_ONLY, "Begin Cell Array" )
822 if ( mbFigure )
823 mpOutAct->CloseRegion();
825 break;
826 case 0xfa : ComOut( CGM_GDSF_ONLY, "End Cell Array" )
828 if ( mbFigure )
829 mpOutAct->CloseRegion();
831 break;
832 case 0xf9 : ComOut( CGM_GDSF_ONLY, "Insert File" )
834 if ( mbFigure )
835 mpOutAct->CloseRegion();
837 break;
838 case 0xf8 : ComOut( CGM_GDSF_ONLY, "Block Text" )
840 if ( mbFigure )
841 mpOutAct->CloseRegion();
843 break;
844 case 0xf7 : ComOut( CGM_GDSF_ONLY, "Variable Width Polyline" )
846 if ( mbFigure )
847 mpOutAct->CloseRegion();
849 break;
850 case 0xf6 : ComOut( CGM_GDSF_ONLY, "Elliptical Arc 3 Point" )
852 if ( mbFigure )
853 mpOutAct->CloseRegion();
855 break;
856 case 0xf1 : ComOut( CGM_GDSF_ONLY, "Hyperlink Definition" ) break;
857 default: ComOut( CGM_UNKNOWN_COMMAND, "" ) break;
860 else
861 mnParaSize = mnElementSize;