bump product version to 4.1.6.2
[LibreOffice.git] / filter / source / graphicfilter / icgm / class4.cxx
blob8899d73a8951fb10890d14cf32158b7e9416e70a
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 .
21 #include <main.hxx>
22 #include <chart.hxx>
23 #include <outact.hxx>
24 #include <math.h>
26 using namespace ::com::sun::star;
28 double CGM::ImplGetOrientation( FloatPoint& rCenter, FloatPoint& rPoint )
30 double fOrientation;
32 double nX = rPoint.X - rCenter.X;
33 double nY = rPoint.Y - rCenter.Y;
35 fOrientation = acos( nX / sqrt( nX * nX + nY * nY ) ) * 57.29577951308;
36 if ( nY > 0 )
37 fOrientation = 360 - fOrientation;
39 return fOrientation;
42 // ---------------------------------------------------------------
44 void CGM::ImplSwitchStartEndAngle( double& rStartAngle, double& rEndAngle )
46 double nTemp;
47 nTemp = rStartAngle;
48 rStartAngle = rEndAngle;
49 rEndAngle = nTemp;
52 // ---------------------------------------------------------------
54 void CGM::ImplGetVector( double* pVector )
56 if ( pElement->eVDCType == VDC_REAL )
58 for ( sal_uInt32 i = 0; i < 4; i++ )
60 pVector[ i ] = (double)ImplGetFloat( pElement->eVDCRealPrecision, pElement->nVDCRealSize );
63 else
65 for ( sal_uInt32 i = 0; i < 4; i++ )
67 pVector[ i ] = (double)ImplGetI( pElement->nVDCIntegerPrecision );
70 pVector[ 0 ] *= mnVDCXmul;
71 pVector[ 2 ] *= mnVDCXmul;
72 pVector[ 1 ] *= mnVDCYmul;
73 pVector[ 3 ] *= mnVDCYmul;
76 // ---------------------------------------------------------------
77 sal_Bool CGM::ImplGetEllipse( FloatPoint& rCenter, FloatPoint& rRadius, double& rAngle )
79 FloatPoint aPoint1, aPoint2;
80 double fRot1, fRot2;
81 ImplGetPoint( rCenter, sal_True );
82 ImplGetPoint( aPoint1, sal_True );
83 ImplGetPoint( aPoint2, sal_True );
84 fRot1 = ImplGetOrientation( rCenter, aPoint1 );
85 fRot2 = ImplGetOrientation( rCenter, aPoint2 );
86 rAngle = ImplGetOrientation( rCenter, aPoint1 );
87 aPoint1.X -= rCenter.X;
88 aPoint1.Y -= rCenter.Y;
89 rRadius.X = sqrt( aPoint1.X * aPoint1.X + aPoint1.Y * aPoint1.Y );
90 aPoint2.X -= rCenter.X;
91 aPoint2.Y -= rCenter.Y;
92 rRadius.Y = sqrt( aPoint2.X * aPoint2.X + aPoint2.Y * aPoint2.Y );
94 if ( fRot1 > fRot2 )
96 if ( ( fRot1 - fRot2 ) < 180 )
97 return sal_False;
99 else
101 if ( ( fRot2 - fRot1 ) > 180 )
102 return sal_False;
104 return sal_True;
107 void CGM::ImplDoClass4()
109 if ( mbFirstOutPut )
110 mpOutAct->FirstOutPut();
112 if ( mpBitmapInUse && ( mnElementID != 9 ) ) // process existend graphic
113 { // because there are now no pending bitmap actions
114 CGMBitmapDescriptor* pBmpDesc = mpBitmapInUse->GetBitmap();
115 // do anything with the bitmap
116 mpOutAct->DrawBitmap( pBmpDesc );
117 delete mpBitmapInUse;
118 mpBitmapInUse = NULL;
121 if ( ( mpChart == NULL ) || mpChart->IsAnnotation() )
123 switch ( mnElementID )
125 case 0x01 : /*PolyLine*/
127 sal_uInt32 nPoints = mnElementSize / ImplGetPointSize();
128 Polygon aPolygon( (sal_uInt16)nPoints );
129 for ( sal_uInt16 i = 0; i < nPoints; i++)
131 FloatPoint aFloatPoint;
132 ImplGetPoint( aFloatPoint, sal_True );
133 aPolygon.SetPoint( Point( (long)aFloatPoint.X, (long)aFloatPoint.Y ), i );
135 if ( mbFigure )
136 mpOutAct->RegPolyLine( aPolygon );
137 else
138 mpOutAct->DrawPolyLine( aPolygon );
140 break;
142 case 0x02 : /*Disjoint PolyLine*/
144 sal_uInt16 nPoints = sal::static_int_cast< sal_uInt16 >(
145 mnElementSize / ImplGetPointSize());
146 if ( ! ( nPoints & 1 ) )
148 nPoints >>= 1;
149 FloatPoint aFloatPoint;
150 if ( mbFigure )
152 Polygon aPolygon( nPoints );
153 for ( sal_uInt16 i = 0; i < nPoints; i++ )
155 ImplGetPoint( aFloatPoint, sal_True );
156 aPolygon.SetPoint( Point( (long)aFloatPoint.X, (long)aFloatPoint.Y ), 0 );
158 mpOutAct->RegPolyLine( aPolygon );
160 else
162 mpOutAct->BeginGroup();
163 Polygon aPolygon( (sal_uInt16)2 );
164 for ( sal_uInt16 i = 0; i < nPoints; i++ )
166 ImplGetPoint( aFloatPoint, sal_True );
167 aPolygon.SetPoint( Point( (long)aFloatPoint.X, (long)aFloatPoint.Y ), 0 );
168 ImplGetPoint( aFloatPoint, sal_True );
169 aPolygon.SetPoint( Point( (long)aFloatPoint.X, (long)aFloatPoint.Y ), 1);
170 mpOutAct->DrawPolyLine( aPolygon );
172 mpOutAct->EndGroup();
176 break;
178 case 0x03 : /*PolyMarker*/ break;
179 case 0x04 : /*Text*/
181 FloatPoint aFloatPoint;
182 sal_uInt32 nType, nSize;
184 if ( mbFigure )
185 mpOutAct->CloseRegion();
187 ImplGetPoint ( aFloatPoint, sal_True );
188 nType = ImplGetUI16( 4 );
189 nSize = ImplGetUI( 1 );
190 mpSource[ mnParaSize + nSize ] = 0;
192 awt::Size aSize;
193 awt::Point aPoint( (long)aFloatPoint.X, (long)aFloatPoint.Y );
194 mpOutAct->DrawText( aPoint, aSize,
195 (char*)mpSource + mnParaSize, nSize, (FinalFlag)nType );
196 mnParaSize = mnElementSize;
198 break;
200 case 0x05 : /*Restricted Text*/
202 double dx, dy;
203 FloatPoint aFloatPoint;
204 sal_uInt32 nType, nSize;
206 if ( mbFigure )
207 mpOutAct->CloseRegion();
209 if ( pElement->eVDCType == VDC_REAL )
211 dx = ImplGetFloat( pElement->eVDCRealPrecision, pElement->nVDCRealSize );
212 dy = ImplGetFloat( pElement->eVDCRealPrecision, pElement->nVDCRealSize );
214 else
216 dx = (double)ImplGetI( pElement->nVDCIntegerPrecision );
217 dy = (double)ImplGetI( pElement->nVDCIntegerPrecision );
219 ImplMapDouble( dx );
220 ImplMapDouble( dy );
222 ImplGetPoint ( aFloatPoint, sal_True );
223 nType = ImplGetUI16( 4 );
224 nSize = ImplGetUI( 1 );
226 mpSource[ mnParaSize + nSize ] = 0;
228 awt::Point aPoint( (long)aFloatPoint.X, (long)aFloatPoint.Y );
229 awt::Size aSize((long)dx, (long)dy);
230 mpOutAct->DrawText( aPoint, aSize ,
231 (char*)mpSource + mnParaSize, nSize, (FinalFlag)nType );
232 mnParaSize = mnElementSize;
234 break;
236 case 0x06 : /*Append Text*/
238 sal_uInt32 nSize;
239 sal_uInt32 nType = ImplGetUI16( 4 );
241 nSize = ImplGetUI( 1 );
242 mpSource[ mnParaSize + nSize ] = 0;
244 mpOutAct->AppendText( (char*)mpSource + mnParaSize, nSize, (FinalFlag)nType );
245 mnParaSize = mnElementSize;
247 break;
249 case 0x07 : /*Polygon*/
251 if ( mbFigure )
252 mpOutAct->CloseRegion();
254 sal_uInt16 nPoints = sal::static_int_cast< sal_uInt16 >(
255 mnElementSize / ImplGetPointSize());
256 Polygon aPolygon( nPoints );
257 for ( sal_uInt16 i = 0; i < nPoints; i++)
259 FloatPoint aFloatPoint;
260 ImplGetPoint( aFloatPoint, sal_True );
261 aPolygon.SetPoint( Point ( (long)( aFloatPoint.X ), (long)( aFloatPoint.Y ) ), i );
263 mpOutAct->DrawPolygon( aPolygon );
265 break;
267 case 0x08 : /*Polygon Set*/
269 if ( mbFigure )
270 mpOutAct->CloseRegion();
272 sal_uInt16 nPoints = 0;
273 Point* pPoints = new Point[ 0x4000 ];
275 PolyPolygon aPolyPolygon;
276 FloatPoint aFloatPoint;
277 sal_uInt32 nEdgeFlag;
278 while ( mnParaSize < mnElementSize )
280 ImplGetPoint( aFloatPoint, sal_True );
281 nEdgeFlag = ImplGetUI16();
282 pPoints[ nPoints++ ] = Point( (long)aFloatPoint.X, (long)aFloatPoint.Y );
283 if ( ( nEdgeFlag & 2 ) || ( mnParaSize == mnElementSize ) )
285 Polygon aPolygon( nPoints );
286 for ( sal_uInt16 i = 0; i < nPoints; i++ )
288 aPolygon.SetPoint( pPoints[ i ], i );
290 aPolyPolygon.Insert( aPolygon, POLYPOLY_APPEND );
291 nPoints = 0;
294 delete[] pPoints;
295 mpOutAct->DrawPolyPolygon( aPolyPolygon );
297 break;
299 case 0x09 : /*Cell Array*/
301 if ( mbFigure )
302 mpOutAct->CloseRegion();
304 if ( mpBitmapInUse )
306 CGMBitmap* pBmpDesc = mpBitmapInUse->GetNext();
307 if ( pBmpDesc ) // we possibly get a bitmap back which does not fit to
308 { // to the previous -> we need to delete this one too
309 mpOutAct->DrawBitmap( pBmpDesc->GetBitmap() );
310 delete pBmpDesc;
313 else
315 mpBitmapInUse = new CGMBitmap( *this );
318 break;
320 case 0x0a : /*Generalized Drawing Primitive*/
322 ImplGetI( pElement->nIntegerPrecision ); //-Wall is this needed
323 ImplGetUI( pElement->nIntegerPrecision ); //-Wall is this needed
324 mnParaSize = mnElementSize;
326 break;
328 case 0x0b : /*Rectangle*/
330 if ( mbFigure )
331 mpOutAct->CloseRegion();
333 FloatRect aFloatRect;
334 ImplGetRectangle( aFloatRect, sal_True );
335 mpOutAct->DrawRectangle( aFloatRect );
337 break;
339 case 0x0c : /*Circle*/
341 if ( mbFigure )
342 mpOutAct->CloseRegion();
344 double fRotation = 0;
345 FloatPoint aCenter, aRadius;
346 ImplGetPoint( aCenter, sal_True );
347 if ( pElement->eVDCType == VDC_REAL )
348 aRadius.X = ImplGetFloat( pElement->eVDCRealPrecision, pElement->nVDCRealSize );
349 else
350 aRadius.X = (double)ImplGetI( pElement->nVDCIntegerPrecision );
351 ImplMapDouble( aRadius.X );
352 aRadius.Y = aRadius.X;
353 mpOutAct->DrawEllipse( aCenter, aRadius, fRotation );
355 break;
357 case 0x0d : /*Circular Arc 3 Point*/
359 FloatPoint aStartingPoint, aIntermediatePoint, aEndingPoint, aCenterPoint;
360 ImplGetPoint( aStartingPoint, sal_True );
361 ImplGetPoint( aIntermediatePoint, sal_True );
362 ImplGetPoint( aEndingPoint, sal_True );
364 double fA = aIntermediatePoint.X - aStartingPoint.X;
365 double fB = aIntermediatePoint.Y - aStartingPoint.Y;
366 double fC = aEndingPoint.X - aStartingPoint.X;
367 double fD = aEndingPoint.Y - aStartingPoint.Y;
369 double fE = fA * ( aStartingPoint.X + aIntermediatePoint.X ) + fB * ( aStartingPoint.Y + aIntermediatePoint.Y );
370 double fF = fC * ( aStartingPoint.X + aEndingPoint.X ) + fD * ( aStartingPoint.Y + aEndingPoint.Y );
372 double fG = 2.0 * ( fA * ( aEndingPoint.Y - aIntermediatePoint.Y ) - fB * ( aEndingPoint.X - aIntermediatePoint.X ) );
374 aCenterPoint.X = ( fD * fE - fB * fF ) / fG;
375 aCenterPoint.Y = ( fA * fF - fC * fE ) / fG;
377 if ( fG != 0 )
379 double fStartAngle = ImplGetOrientation( aCenterPoint, aStartingPoint );
380 double fInterAngle = ImplGetOrientation( aCenterPoint, aIntermediatePoint );
381 double fEndAngle = ImplGetOrientation( aCenterPoint, aEndingPoint );
383 int nSwitch = 0;
385 if ( fStartAngle > fEndAngle )
387 nSwitch ^=1;
388 aIntermediatePoint = aEndingPoint;
389 aEndingPoint = aStartingPoint;
390 aStartingPoint = aIntermediatePoint;
391 fG = fStartAngle;
392 fStartAngle = fEndAngle;
393 fEndAngle = fG;
395 if ( ! ( fInterAngle > fStartAngle ) && ( fInterAngle < fEndAngle ) )
397 nSwitch ^=1;
398 aIntermediatePoint = aEndingPoint;
399 aEndingPoint = aStartingPoint;
400 aStartingPoint = aIntermediatePoint;
401 fG = fStartAngle;
402 fStartAngle = fEndAngle;
403 fEndAngle = fG;
405 double fRadius = sqrt( pow( ( aStartingPoint.X - aCenterPoint.X ), 2 ) + pow( ( aStartingPoint.Y - aCenterPoint.Y ), 2 ) ) ;
407 if ( mbFigure )
409 Rectangle aBoundingBox( Point( (long)( aCenterPoint.X - fRadius ), long( aCenterPoint.Y - fRadius ) ),
410 Size( ( static_cast< long >( 2 * fRadius ) ), (long)( 2 * fRadius) ) );
411 Polygon aPolygon( aBoundingBox, Point( (long)aStartingPoint.X, (long)aStartingPoint.Y ) ,Point( (long)aEndingPoint.X, (long)aEndingPoint.Y ), POLY_ARC );
412 if ( nSwitch )
413 mpOutAct->RegPolyLine( aPolygon, sal_True );
414 else
415 mpOutAct->RegPolyLine( aPolygon );
417 else
419 fG = 0;
420 FloatPoint aRadius;
421 aRadius.X = aRadius.Y = fRadius;
422 mpOutAct->DrawEllipticalArc( aCenterPoint, aRadius, fG, 2, fStartAngle, fEndAngle );
426 break;
428 case 0x0e : /*Circular Arc 3 Point Close*/
430 if ( mbFigure )
431 mpOutAct->CloseRegion();
433 FloatPoint aStartingPoint, aIntermediatePoint, aEndingPoint, aCenterPoint;
434 ImplGetPoint( aStartingPoint );
435 ImplGetPoint( aIntermediatePoint );
436 ImplGetPoint( aEndingPoint );
438 double fA = aIntermediatePoint.X - aStartingPoint.X;
439 double fB = aIntermediatePoint.Y - aStartingPoint.Y;
440 double fC = aEndingPoint.X - aStartingPoint.X;
441 double fD = aEndingPoint.Y - aStartingPoint.Y;
443 double fE = fA * ( aStartingPoint.X + aIntermediatePoint.X ) + fB * ( aStartingPoint.Y + aIntermediatePoint.Y );
444 double fF = fC * ( aStartingPoint.X + aEndingPoint.X ) + fD * ( aStartingPoint.Y + aEndingPoint.Y );
446 double fG = 2.0 * ( fA * ( aEndingPoint.Y - aIntermediatePoint.Y ) - fB * ( aEndingPoint.X - aIntermediatePoint.X ) );
448 aCenterPoint.X = ( fD * fE - fB * fF ) / fG;
449 aCenterPoint.Y = ( fA * fF - fC * fE ) / fG;
451 if ( fG != 0 )
453 double fStartAngle = ImplGetOrientation( aCenterPoint, aStartingPoint );
454 double fInterAngle = ImplGetOrientation( aCenterPoint, aIntermediatePoint );
455 double fEndAngle = ImplGetOrientation( aCenterPoint, aEndingPoint );
457 if ( fStartAngle > fEndAngle )
459 aIntermediatePoint = aEndingPoint;
460 aEndingPoint = aStartingPoint;
461 aStartingPoint = aIntermediatePoint;
462 fG = fStartAngle;
463 fStartAngle = fEndAngle;
464 fEndAngle = fG;
466 if ( ! ( fInterAngle > fStartAngle ) && ( fInterAngle < fEndAngle ) )
468 aIntermediatePoint = aEndingPoint;
469 aEndingPoint = aStartingPoint;
470 aStartingPoint = aIntermediatePoint;
471 fG = fStartAngle;
472 fStartAngle = fEndAngle;
473 fEndAngle = fG;
475 FloatPoint fRadius;
476 fRadius.Y = fRadius.X = sqrt( pow( ( aStartingPoint.X - aCenterPoint.X ), 2 ) + pow( ( aStartingPoint.Y - aCenterPoint.Y ), 2 ) ) ;
478 sal_uInt32 nType = ImplGetUI16();
479 if ( nType == 0 )
480 nType = 0; // is PIE
481 else
482 nType = 1; // is CHORD
484 double fOrientation = 0;
485 mpOutAct->DrawEllipticalArc( aCenterPoint, fRadius, fOrientation, nType, fStartAngle, fEndAngle );
488 break;
490 case 0x0f : /*Circular Arc Centre*/
492 double fStartAngle, fEndAngle, vector[ 4 ];
493 FloatPoint aCenter, aRadius;
495 if ( mbFigure )
496 mpOutAct->CloseRegion();
498 ImplGetPoint( aCenter, sal_True );
499 ImplGetVector( &vector[ 0 ] );
501 if ( pElement->eVDCType == VDC_REAL )
503 aRadius.X = (double)ImplGetFloat( pElement->eVDCRealPrecision, pElement->nVDCRealSize );
505 else
507 aRadius.X = (double)ImplGetI( pElement->nVDCIntegerPrecision );
510 ImplMapDouble( aRadius.X );
511 aRadius.Y = aRadius.X;
513 fStartAngle = acos( vector[ 0 ] / sqrt( vector[ 0 ] * vector[ 0 ] + vector[ 1 ] * vector[ 1 ] ) ) * 57.29577951308;
514 fEndAngle = acos( vector[ 2 ] / sqrt( vector[ 2 ] * vector[ 2 ] + vector[ 3 ] * vector[ 3 ] ) ) * 57.29577951308;
516 if ( vector[ 1 ] > 0 )
517 fStartAngle = 360 - fStartAngle;
518 if ( vector[ 3 ] > 0 )
519 fEndAngle = 360 - fEndAngle;
521 if ( mbAngReverse )
522 ImplSwitchStartEndAngle( fStartAngle, fEndAngle );
524 if ( mbFigure )
526 Rectangle aBoundingBox(
527 Point( (long)( aCenter.X - aRadius.X ), long( aCenter.Y - aRadius.X ) ),
528 Size( static_cast< long >( 2 * aRadius.X ), (long)( 2 * aRadius.X ) ) );
529 Polygon aPolygon( aBoundingBox,
530 Point( (long)vector[ 0 ], (long)vector[ 1 ] ),
531 Point( (long)vector[ 2 ], (long)vector[ 3 ] ), POLY_ARC );
532 mpOutAct->RegPolyLine( aPolygon );
534 else
536 double fOrientation = 0;
537 mpOutAct->DrawEllipticalArc( aCenter, aRadius, fOrientation, 2, fStartAngle, fEndAngle );
539 mnParaSize = mnElementSize;
542 break;
544 case 0x10 : /*Circular Arc Centre Close*/
546 double fOrientation, fStartAngle, fEndAngle, vector[ 4 ];
547 FloatPoint aCenter, aRadius;
549 if ( mbFigure )
550 mpOutAct->CloseRegion();
552 ImplGetPoint( aCenter, sal_True );
553 ImplGetVector( &vector[ 0 ] );
554 if ( pElement->eVDCType == VDC_REAL )
556 aRadius.X = (double)ImplGetFloat( pElement->eVDCRealPrecision, pElement->nVDCRealSize );
558 else
560 aRadius.X = (double)ImplGetI( pElement->nVDCIntegerPrecision );
562 ImplMapDouble( aRadius.X );
563 aRadius.Y = aRadius.X;
564 fStartAngle = acos( vector[ 0 ] / sqrt( vector[ 0 ] * vector[ 0 ] + vector[ 1 ] * vector[ 1 ] ) ) * 57.29577951308;
565 fEndAngle = acos( vector[ 2 ] / sqrt( vector[ 2 ] * vector[ 2 ] + vector[ 3 ] * vector[ 3 ] ) ) * 57.29577951308;
567 if ( vector[ 1 ] > 0 )
568 fStartAngle = 360 - fStartAngle;
569 if ( vector[ 3 ] > 0 )
570 fEndAngle = 360 - fEndAngle;
572 if ( mbAngReverse )
573 ImplSwitchStartEndAngle( fStartAngle, fEndAngle );
576 sal_uInt32 nType = ImplGetUI16();
577 if ( nType == 0 )
578 nType = 0; // is PIE
579 else
580 nType = 1; // is CHORD
581 fOrientation = 0;
583 mpOutAct->DrawEllipticalArc( aCenter, aRadius, fOrientation,
584 nType, fStartAngle, fEndAngle );
585 mnParaSize = mnElementSize;
587 break;
589 case 0x11 : /*Ellipse*/
591 double fOrientation;
592 FloatPoint aCenter, aRadius;
594 if ( mbFigure )
595 mpOutAct->CloseRegion();
597 ImplGetEllipse( aCenter, aRadius, fOrientation ) ;
598 mpOutAct->DrawEllipse( aCenter, aRadius, fOrientation ) ;
600 break;
602 case 0x12 : /*Elliptical Arc*/
604 if ( mbFigure )
605 mpOutAct->CloseRegion();
607 double fOrientation, fStartAngle, fEndAngle, vector[ 4 ];
608 FloatPoint aCenter, aRadius;
610 if ( mbFigure )
611 mpOutAct->CloseRegion();
613 sal_Bool bDirection = ImplGetEllipse( aCenter, aRadius, fOrientation );
614 ImplGetVector( &vector[ 0 ] );
616 fStartAngle = acos( vector[ 0 ] / sqrt( vector[ 0 ] * vector[ 0 ] + vector[ 1 ] * vector[ 1 ] ) ) * 57.29577951308;
617 fEndAngle = acos( vector[ 2 ] / sqrt( vector[ 2 ] * vector[ 2 ] + vector[ 3 ] * vector[ 3 ] ) ) * 57.29577951308;
619 if ( vector[ 1 ] > 0 )
620 fStartAngle = 360 - fStartAngle;
621 if ( vector[ 3 ] > 0 )
622 fEndAngle = 360 - fEndAngle;
624 if ( bDirection )
625 mpOutAct->DrawEllipticalArc( aCenter, aRadius, fOrientation,
626 2, fStartAngle, fEndAngle );
627 else
628 mpOutAct->DrawEllipticalArc( aCenter, aRadius, fOrientation,
629 2, fEndAngle, fStartAngle);
631 break;
633 case 0x13 : /*Elliptical Arc Close*/
635 double fOrientation, fStartAngle, fEndAngle, vector[ 4 ];
636 FloatPoint aCenter, aRadius;
638 if ( mbFigure )
639 mpOutAct->CloseRegion();
641 sal_Bool bDirection = ImplGetEllipse( aCenter, aRadius, fOrientation );
642 ImplGetVector( &vector[ 0 ] );
644 fStartAngle = acos( vector[ 0 ] / sqrt( vector[ 0 ] * vector[ 0 ] + vector[ 1 ] * vector[ 1 ] ) ) * 57.29577951308;
645 fEndAngle = acos( vector[ 2 ] / sqrt( vector[ 2 ] * vector[ 2 ] + vector[ 3 ] * vector[ 3 ] ) ) * 57.29577951308;
647 if ( vector[ 1 ] > 0 )
648 fStartAngle = 360 - fStartAngle;
649 if ( vector[ 3 ] > 0 )
650 fEndAngle = 360 - fEndAngle;
652 sal_uInt32 nType = ImplGetUI16();
653 if ( nType == 0 )
654 nType = 0; // is PIE
655 else
656 nType = 1; // is CHORD
658 if ( bDirection )
659 mpOutAct->DrawEllipticalArc( aCenter, aRadius, fOrientation,
660 nType, fStartAngle, fEndAngle );
661 else
662 mpOutAct->DrawEllipticalArc( aCenter, aRadius, fOrientation,
663 nType, fEndAngle, fStartAngle);
665 break;
666 case 0x14 : /*Circular Arc Centre Reversed*/
668 if ( mbFigure )
669 mpOutAct->CloseRegion();
671 break;
672 case 0x15 : /*Connection Edge */ // NS
674 // if ( mbFigure )
675 // mpOutAct->CloseRegion();
677 break;
678 case 0x16 : /*Hyperbolic Arc */ // NS
680 if ( mbFigure )
681 mpOutAct->CloseRegion();
683 break;
684 case 0x17 : /*Parabolic Arc */ // NS
686 if ( mbFigure )
687 mpOutAct->CloseRegion();
689 break;
690 case 0x18 : /*Non Uniform B-Spline */ // NS
692 if ( mbFigure )
693 mpOutAct->CloseRegion();
695 break;
696 case 0x19 : /*Non Uniform Rational B-Spline */ // NS
698 if ( mbFigure )
699 mpOutAct->CloseRegion();
701 break;
702 case 0x1a : /*Polybezier*/
704 sal_uInt32 nOrder = ImplGetI( pElement->nIntegerPrecision );
706 sal_uInt16 nNumberOfPoints = sal::static_int_cast< sal_uInt16 >(( mnElementSize - pElement->nIntegerPrecision ) / ImplGetPointSize());
708 Polygon aPolygon( nNumberOfPoints );
710 for ( sal_uInt16 i = 0; i < nNumberOfPoints; i++)
712 FloatPoint aFloatPoint;
713 ImplGetPoint( aFloatPoint, sal_True );
714 aPolygon.SetPoint( Point ( (long)( aFloatPoint.X ), (long)( aFloatPoint.Y ) ), i );
716 if ( nOrder & 4 )
718 for ( sal_uInt16 i = 0; i < nNumberOfPoints; i++ )
720 if ( ( i % 3 ) == 0 )
721 aPolygon.SetFlags( i, POLY_NORMAL );
722 else
723 aPolygon.SetFlags( i, POLY_CONTROL );
726 else
728 for ( sal_uInt16 i = 0; i < nNumberOfPoints; i++ )
730 switch ( i & 3 )
732 case 0 :
733 case 3 : aPolygon.SetFlags( i, POLY_NORMAL ); break;
734 default : aPolygon.SetFlags( i, POLY_CONTROL ); break;
738 if ( mbFigure )
739 mpOutAct->RegPolyLine( aPolygon );
740 else
741 mpOutAct->DrawPolybezier( aPolygon );
742 mnParaSize = mnElementSize;
744 break;
746 case 0x1b : /*Polysymbol */ // NS
748 if ( mbFigure )
749 mpOutAct->CloseRegion();
751 break;
752 case 0x1c : /*Bitonal Tile */ // NS
754 if ( mbFigure )
755 mpOutAct->CloseRegion();
757 break;
758 case 0x1d : /*Tile */ // NS
760 if ( mbFigure )
761 mpOutAct->CloseRegion();
763 break;
764 case 0x1e : /*Insert Object*/
766 if ( mbFigure )
767 mpOutAct->CloseRegion();
769 break;
770 case 0xff : /*Polybezier*/
772 if ( mbFigure )
773 mpOutAct->CloseRegion();
775 break;
776 case 0xfe : /*Sharp Polybezier*/
778 if ( mbFigure )
779 mpOutAct->CloseRegion();
781 break;
782 case 0xfd : /*Polyspline*/
784 if ( mbFigure )
785 mpOutAct->CloseRegion();
787 break;
788 case 0xfc : /*Reounded Rectangle*/
790 if ( mbFigure )
791 mpOutAct->CloseRegion();
793 break;
794 case 0xfb : /*Begin Cell Array*/
796 if ( mbFigure )
797 mpOutAct->CloseRegion();
799 break;
800 case 0xfa : /*End Cell Array*/
802 if ( mbFigure )
803 mpOutAct->CloseRegion();
805 break;
806 case 0xf9 : /*Insert File*/
808 if ( mbFigure )
809 mpOutAct->CloseRegion();
811 break;
812 case 0xf8 : /*Block Text*/
814 if ( mbFigure )
815 mpOutAct->CloseRegion();
817 break;
818 case 0xf7 : /*Variable Width Polyline*/
820 if ( mbFigure )
821 mpOutAct->CloseRegion();
823 break;
824 case 0xf6 : /*Elliptical Arc 3 Point*/
826 if ( mbFigure )
827 mpOutAct->CloseRegion();
829 break;
830 case 0xf1 : /*Hyperlink Definition */break;
831 default: break;
834 else
835 mnParaSize = mnElementSize;
839 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */