00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #include "precompiled_goodies.hxx"
00030
00031 #include <main.hxx>
00032 #include <chart.hxx>
00033 #include <outact.hxx>
00034 #include <math.h>
00035
00036 using namespace ::com::sun::star;
00037
00038 double CGM::ImplGetOrientation( FloatPoint& rCenter, FloatPoint& rPoint )
00039 {
00040 double fOrientation;
00041
00042 double nX = rPoint.X - rCenter.X;
00043 double nY = rPoint.Y - rCenter.Y;
00044
00045 fOrientation = acos( nX / sqrt( nX * nX + nY * nY ) ) * 57.29577951308;
00046 if ( nY > 0 )
00047 fOrientation = 360 - fOrientation;
00048
00049 return fOrientation;
00050 }
00051
00052
00053
00054 void CGM::ImplSwitchStartEndAngle( double& rStartAngle, double& rEndAngle )
00055 {
00056 double nTemp;
00057 nTemp = rStartAngle;
00058 rStartAngle = rEndAngle;
00059 rEndAngle = nTemp;
00060 }
00061
00062
00063
00064 void CGM::ImplGetVector( double* pVector )
00065 {
00066 if ( pElement->eVDCType == VDC_REAL )
00067 {
00068 for ( sal_uInt32 i = 0; i < 4; i++ )
00069 {
00070 pVector[ i ] = (double)ImplGetFloat( pElement->eVDCRealPrecision, pElement->nVDCRealSize );
00071 }
00072 }
00073 else
00074 {
00075 for ( sal_uInt32 i = 0; i < 4; i++ )
00076 {
00077 pVector[ i ] = (double)ImplGetI( pElement->nVDCIntegerPrecision );
00078 }
00079 }
00080 pVector[ 0 ] *= mnVDCXmul;
00081 pVector[ 2 ] *= mnVDCXmul;
00082 pVector[ 1 ] *= mnVDCYmul;
00083 pVector[ 3 ] *= mnVDCYmul;
00084 }
00085
00086
00087 sal_Bool CGM::ImplGetEllipse( FloatPoint& rCenter, FloatPoint& rRadius, double& rAngle )
00088 {
00089 FloatPoint aPoint1, aPoint2;
00090 double fRot1, fRot2;
00091 ImplGetPoint( rCenter, sal_True );
00092 ImplGetPoint( aPoint1, sal_True );
00093 ImplGetPoint( aPoint2, sal_True );
00094 fRot1 = ImplGetOrientation( rCenter, aPoint1 );
00095 fRot2 = ImplGetOrientation( rCenter, aPoint2 );
00096 rAngle = ImplGetOrientation( rCenter, aPoint1 );
00097 aPoint1.X -= rCenter.X;
00098 aPoint1.Y -= rCenter.Y;
00099 rRadius.X = sqrt( aPoint1.X * aPoint1.X + aPoint1.Y * aPoint1.Y );
00100 aPoint2.X -= rCenter.X;
00101 aPoint2.Y -= rCenter.Y;
00102 rRadius.Y = sqrt( aPoint2.X * aPoint2.X + aPoint2.Y * aPoint2.Y );
00103
00104 if ( fRot1 > fRot2 )
00105 {
00106 if ( ( fRot1 - fRot2 ) < 180 )
00107 return sal_False;
00108 }
00109 else
00110 {
00111 if ( ( fRot2 - fRot1 ) > 180 )
00112 return sal_False;
00113 }
00114 return sal_True;
00115 }
00116
00117 void CGM::ImplDoClass4()
00118 {
00119 if ( mbFirstOutPut )
00120 mpOutAct->FirstOutPut();
00121
00122 if ( mpBitmapInUse && ( mnElementID != 9 ) )
00123 {
00124 CGMBitmapDescriptor* pBmpDesc = mpBitmapInUse->GetBitmap();
00125
00126 mpOutAct->DrawBitmap( pBmpDesc );
00127 delete mpBitmapInUse;
00128 mpBitmapInUse = NULL;
00129 }
00130
00131 if ( ( mpChart == NULL ) || mpChart->IsAnnotation() )
00132 {
00133 switch ( mnElementID )
00134 {
00135 case 0x01 : ComOut( CGM_LEVEL1, "PolyLine" )
00136 {
00137 sal_uInt32 nPoints = mnElementSize / ImplGetPointSize();
00138 Polygon aPolygon( (sal_uInt16)nPoints );
00139 for ( sal_uInt16 i = 0; i < nPoints; i++)
00140 {
00141 FloatPoint aFloatPoint;
00142 ImplGetPoint( aFloatPoint, sal_True );
00143 aPolygon.SetPoint( Point( (long)aFloatPoint.X, (long)aFloatPoint.Y ), i );
00144 }
00145 if ( mbFigure )
00146 mpOutAct->RegPolyLine( aPolygon );
00147 else
00148 mpOutAct->DrawPolyLine( aPolygon );
00149 }
00150 break;
00151
00152 case 0x02 : ComOut( CGM_LEVEL1 | CGM_EXTENDED_PRIMITIVES_SET, "Disjoint PolyLine" )
00153 {
00154 USHORT nPoints = sal::static_int_cast< USHORT >(
00155 mnElementSize / ImplGetPointSize());
00156 if ( ! ( nPoints & 1 ) )
00157 {
00158 nPoints >>= 1;
00159 FloatPoint aFloatPoint;
00160 if ( mbFigure )
00161 {
00162 Polygon aPolygon( nPoints );
00163 for ( sal_uInt16 i = 0; i < nPoints; i++ )
00164 {
00165 ImplGetPoint( aFloatPoint, sal_True );
00166 aPolygon.SetPoint( Point( (long)aFloatPoint.X, (long)aFloatPoint.Y ), 0 );
00167 }
00168 mpOutAct->RegPolyLine( aPolygon );
00169 }
00170 else
00171 {
00172 mpOutAct->BeginGroup();
00173 Polygon aPolygon( (sal_uInt16)2 );
00174 for ( sal_uInt16 i = 0; i < nPoints; i++ )
00175 {
00176 ImplGetPoint( aFloatPoint, sal_True );
00177 aPolygon.SetPoint( Point( (long)aFloatPoint.X, (long)aFloatPoint.Y ), 0 );
00178 ImplGetPoint( aFloatPoint, sal_True );
00179 aPolygon.SetPoint( Point( (long)aFloatPoint.X, (long)aFloatPoint.Y ), 1);
00180 mpOutAct->DrawPolyLine( aPolygon );
00181 }
00182 mpOutAct->EndGroup();
00183 }
00184 }
00185 }
00186 break;
00187
00188 case 0x03 : ComOut( CGM_LEVEL1, "PolyMarker" ) break;
00189 case 0x04 : ComOut( CGM_LEVEL1, "Text" )
00190 {
00191 FloatPoint aFloatPoint;
00192 sal_uInt32 nType, nSize;
00193
00194 if ( mbFigure )
00195 mpOutAct->CloseRegion();
00196
00197 ImplGetPoint ( aFloatPoint, sal_True );
00198 nType = ImplGetUI16( 4 );
00199 nSize = ImplGetUI( 1 );
00200 mpSource[ mnParaSize + nSize ] = 0;
00201
00202 ComOut( CGM_DESCRIPTION, (char*)mpSource + mnParaSize );
00203
00204 awt::Size aSize;
00205 awt::Point aPoint( (long)aFloatPoint.X, (long)aFloatPoint.Y );
00206 mpOutAct->DrawText( aPoint, aSize,
00207 (char*)mpSource + mnParaSize, nSize, (FinalFlag)nType );
00208
00209 mnParaSize = mnElementSize;
00210 }
00211 break;
00212
00213 case 0x05 : ComOut( CGM_LEVEL1 | CGM_EXTENDED_PRIMITIVES_SET, "Restricted Text" )
00214 {
00215 double dx, dy;
00216 FloatPoint aFloatPoint;
00217 sal_uInt32 nType, nSize;
00218
00219 if ( mbFigure )
00220 mpOutAct->CloseRegion();
00221
00222 if ( pElement->eVDCType == VDC_REAL )
00223 {
00224 dx = ImplGetFloat( pElement->eVDCRealPrecision, pElement->nVDCRealSize );
00225 dy = ImplGetFloat( pElement->eVDCRealPrecision, pElement->nVDCRealSize );
00226 }
00227 else
00228 {
00229 dx = (double)ImplGetI( pElement->nVDCIntegerPrecision );
00230 dy = (double)ImplGetI( pElement->nVDCIntegerPrecision );
00231 }
00232 ImplMapDouble( dx );
00233 ImplMapDouble( dy );
00234
00235 ImplGetPoint ( aFloatPoint, sal_True );
00236 nType = ImplGetUI16( 4 );
00237 nSize = ImplGetUI( 1 );
00238
00239 mpSource[ mnParaSize + nSize ] = 0;
00240
00241 ComOut( CGM_DESCRIPTION, (char*)mpSource + mnParaSize );
00242
00243 awt::Point aPoint( (long)aFloatPoint.X, (long)aFloatPoint.Y );
00244 awt::Size aSize((long)dx, (long)dy);
00245 mpOutAct->DrawText( aPoint, aSize ,
00246 (char*)mpSource + mnParaSize, nSize, (FinalFlag)nType );
00247
00248 mnParaSize = mnElementSize;
00249 }
00250 break;
00251
00252 case 0x06 : ComOut( CGM_LEVEL1 | CGM_EXTENDED_PRIMITIVES_SET, "Append Text" )
00253 {
00254 sal_uInt32 nSize;
00255 sal_uInt32 nType = ImplGetUI16( 4 );
00256
00257 nSize = ImplGetUI( 1 );
00258 mpSource[ mnParaSize + nSize ] = 0;
00259
00260 ComOut( CGM_DESCRIPTION, (char*)mpSource + mnParaSize );
00261
00262 mpOutAct->AppendText( (char*)mpSource + mnParaSize, nSize, (FinalFlag)nType );
00263
00264 mnParaSize = mnElementSize;
00265 }
00266 break;
00267
00268 case 0x07 : ComOut( CGM_LEVEL1, "Polygon" )
00269 {
00270 if ( mbFigure )
00271 mpOutAct->CloseRegion();
00272
00273 USHORT nPoints = sal::static_int_cast< USHORT >(
00274 mnElementSize / ImplGetPointSize());
00275 Polygon aPolygon( nPoints );
00276 for ( USHORT i = 0; i < nPoints; i++)
00277 {
00278 FloatPoint aFloatPoint;
00279 ImplGetPoint( aFloatPoint, sal_True );
00280 aPolygon.SetPoint( Point ( (long)( aFloatPoint.X ), (long)( aFloatPoint.Y ) ), i );
00281 }
00282 mpOutAct->DrawPolygon( aPolygon );
00283 }
00284 break;
00285
00286 case 0x08 : ComOut( CGM_LEVEL1 | CGM_EXTENDED_PRIMITIVES_SET, "Polygon Set" )
00287 {
00288 if ( mbFigure )
00289 mpOutAct->CloseRegion();
00290
00291 USHORT nPoints = 0;
00292 Point* pPoints = new Point[ 0x4000 ];
00293
00294 PolyPolygon aPolyPolygon;
00295 FloatPoint aFloatPoint;
00296 sal_uInt32 nEdgeFlag;
00297 while ( mnParaSize < mnElementSize )
00298 {
00299 ImplGetPoint( aFloatPoint, sal_True );
00300 nEdgeFlag = ImplGetUI16();
00301 pPoints[ nPoints++ ] = Point( (long)aFloatPoint.X, (long)aFloatPoint.Y );
00302 if ( ( nEdgeFlag & 2 ) || ( mnParaSize == mnElementSize ) )
00303 {
00304 Polygon aPolygon( nPoints );
00305 for ( USHORT i = 0; i < nPoints; i++ )
00306 {
00307 aPolygon.SetPoint( pPoints[ i ], i );
00308 }
00309 aPolyPolygon.Insert( aPolygon, POLYPOLY_APPEND );
00310 nPoints = 0;
00311 }
00312 }
00313 delete[] pPoints;
00314 mpOutAct->DrawPolyPolygon( aPolyPolygon );
00315 }
00316 break;
00317
00318 case 0x09 : ComOut( CGM_LEVEL1, "Cell Array" )
00319 {
00320 if ( mbFigure )
00321 mpOutAct->CloseRegion();
00322
00323 if ( mpBitmapInUse )
00324 {
00325 CGMBitmap* pBmpDesc = mpBitmapInUse->GetNext();
00326 if ( pBmpDesc )
00327 {
00328 mpOutAct->DrawBitmap( pBmpDesc->GetBitmap() );
00329 delete pBmpDesc;
00330 }
00331 }
00332 else
00333 {
00334 mpBitmapInUse = new CGMBitmap( *this );
00335 }
00336 }
00337 break;
00338
00339 case 0x0a : ComOut( CGM_LEVEL1, "Generalized Drawing Primitive" )
00340 {
00341 ImplGetI( pElement->nIntegerPrecision );
00342 ImplGetUI( pElement->nIntegerPrecision );
00343 mnParaSize = mnElementSize;
00344 }
00345 break;
00346
00347 case 0x0b : ComOut( CGM_LEVEL1 | CGM_EXTENDED_PRIMITIVES_SET, "Rectangle" )
00348 {
00349 if ( mbFigure )
00350 mpOutAct->CloseRegion();
00351
00352 FloatRect aFloatRect;
00353 ImplGetRectangle( aFloatRect, sal_True );
00354 mpOutAct->DrawRectangle( aFloatRect );
00355 }
00356 break;
00357
00358 case 0x0c : ComOut( CGM_LEVEL1 | CGM_EXTENDED_PRIMITIVES_SET, "Circle" )
00359 {
00360 if ( mbFigure )
00361 mpOutAct->CloseRegion();
00362
00363 double fRotation = 0;
00364 FloatPoint aCenter, aRadius;
00365 ImplGetPoint( aCenter, sal_True );
00366 if ( pElement->eVDCType == VDC_REAL )
00367 aRadius.X = ImplGetFloat( pElement->eVDCRealPrecision, pElement->nVDCRealSize );
00368 else
00369 aRadius.X = (double)ImplGetI( pElement->nVDCIntegerPrecision );
00370 ImplMapDouble( aRadius.X );
00371 aRadius.Y = aRadius.X;
00372 mpOutAct->DrawEllipse( aCenter, aRadius, fRotation );
00373 }
00374 break;
00375
00376 case 0x0d : ComOut( CGM_LEVEL1 | CGM_EXTENDED_PRIMITIVES_SET, "Circular Arc 3 Point" )
00377 {
00378 int nSwitch = 0;
00379
00380 FloatPoint aStartingPoint, aIntermediatePoint, aEndingPoint, aCenterPoint;
00381 ImplGetPoint( aStartingPoint, sal_True );
00382 ImplGetPoint( aIntermediatePoint, sal_True );
00383 ImplGetPoint( aEndingPoint, sal_True );
00384
00385 double fA = aIntermediatePoint.X - aStartingPoint.X;
00386 double fB = aIntermediatePoint.Y - aStartingPoint.Y;
00387 double fC = aEndingPoint.X - aStartingPoint.X;
00388 double fD = aEndingPoint.Y - aStartingPoint.Y;
00389
00390 double fE = fA * ( aStartingPoint.X + aIntermediatePoint.X ) + fB * ( aStartingPoint.Y + aIntermediatePoint.Y );
00391 double fF = fC * ( aStartingPoint.X + aEndingPoint.X ) + fD * ( aStartingPoint.Y + aEndingPoint.Y );
00392
00393 double fG = 2.0 * ( fA * ( aEndingPoint.Y - aIntermediatePoint.Y ) - fB * ( aEndingPoint.X - aIntermediatePoint.X ) );
00394
00395 aCenterPoint.X = ( fD * fE - fB * fF ) / fG;
00396 aCenterPoint.Y = ( fA * fF - fC * fE ) / fG;
00397
00398 if ( fG != 0 )
00399 {
00400 double fStartAngle = ImplGetOrientation( aCenterPoint, aStartingPoint );
00401 double fInterAngle = ImplGetOrientation( aCenterPoint, aIntermediatePoint );
00402 double fEndAngle = ImplGetOrientation( aCenterPoint, aEndingPoint );
00403
00404 if ( fStartAngle > fEndAngle )
00405 {
00406 nSwitch ^=1;
00407 aIntermediatePoint = aEndingPoint;
00408 aEndingPoint = aStartingPoint;
00409 aStartingPoint = aIntermediatePoint;
00410 fG = fStartAngle;
00411 fStartAngle = fEndAngle;
00412 fEndAngle = fG;
00413 }
00414 if ( ! ( fInterAngle > fStartAngle ) && ( fInterAngle < fEndAngle ) )
00415 {
00416 nSwitch ^=1;
00417 aIntermediatePoint = aEndingPoint;
00418 aEndingPoint = aStartingPoint;
00419 aStartingPoint = aIntermediatePoint;
00420 fG = fStartAngle;
00421 fStartAngle = fEndAngle;
00422 fEndAngle = fG;
00423 }
00424 double fRadius = sqrt( pow( ( aStartingPoint.X - aCenterPoint.X ), 2 ) + pow( ( aStartingPoint.Y - aCenterPoint.Y ), 2 ) ) ;
00425
00426 if ( mbFigure )
00427 {
00428 Rectangle aBoundingBox( Point( (long)( aCenterPoint.X - fRadius ), long( aCenterPoint.Y - fRadius ) ),
00429 Size( ( static_cast< long >( 2 * fRadius ) ), (long)( 2 * fRadius) ) );
00430 Polygon aPolygon( aBoundingBox, Point( (long)aStartingPoint.X, (long)aStartingPoint.Y ) ,Point( (long)aEndingPoint.X, (long)aEndingPoint.Y ), POLY_ARC );
00431 if ( nSwitch )
00432 mpOutAct->RegPolyLine( aPolygon, sal_True );
00433 else
00434 mpOutAct->RegPolyLine( aPolygon );
00435 }
00436 else
00437 {
00438 fG = 0;
00439 FloatPoint aRadius;
00440 aRadius.X = aRadius.Y = fRadius;
00441 mpOutAct->DrawEllipticalArc( aCenterPoint, aRadius, fG, 2, fStartAngle, fEndAngle );
00442 }
00443 }
00444 }
00445 break;
00446
00447 case 0x0e : ComOut( CGM_LEVEL1 | CGM_EXTENDED_PRIMITIVES_SET, "Circular Arc 3 Point Close" )
00448 {
00449 int nSwitch = 0;
00450
00451 if ( mbFigure )
00452 mpOutAct->CloseRegion();
00453
00454 FloatPoint aStartingPoint, aIntermediatePoint, aEndingPoint, aCenterPoint;
00455 ImplGetPoint( aStartingPoint );
00456 ImplGetPoint( aIntermediatePoint );
00457 ImplGetPoint( aEndingPoint );
00458
00459 double fA = aIntermediatePoint.X - aStartingPoint.X;
00460 double fB = aIntermediatePoint.Y - aStartingPoint.Y;
00461 double fC = aEndingPoint.X - aStartingPoint.X;
00462 double fD = aEndingPoint.Y - aStartingPoint.Y;
00463
00464 double fE = fA * ( aStartingPoint.X + aIntermediatePoint.X ) + fB * ( aStartingPoint.Y + aIntermediatePoint.Y );
00465 double fF = fC * ( aStartingPoint.X + aEndingPoint.X ) + fD * ( aStartingPoint.Y + aEndingPoint.Y );
00466
00467 double fG = 2.0 * ( fA * ( aEndingPoint.Y - aIntermediatePoint.Y ) - fB * ( aEndingPoint.X - aIntermediatePoint.X ) );
00468
00469 aCenterPoint.X = ( fD * fE - fB * fF ) / fG;
00470 aCenterPoint.Y = ( fA * fF - fC * fE ) / fG;
00471
00472 if ( fG != 0 )
00473 {
00474 double fStartAngle = ImplGetOrientation( aCenterPoint, aStartingPoint );
00475 double fInterAngle = ImplGetOrientation( aCenterPoint, aIntermediatePoint );
00476 double fEndAngle = ImplGetOrientation( aCenterPoint, aEndingPoint );
00477
00478 if ( fStartAngle > fEndAngle )
00479 {
00480 nSwitch ^=1;
00481 aIntermediatePoint = aEndingPoint;
00482 aEndingPoint = aStartingPoint;
00483 aStartingPoint = aIntermediatePoint;
00484 fG = fStartAngle;
00485 fStartAngle = fEndAngle;
00486 fEndAngle = fG;
00487 }
00488 if ( ! ( fInterAngle > fStartAngle ) && ( fInterAngle < fEndAngle ) )
00489 {
00490 nSwitch ^=1;
00491 aIntermediatePoint = aEndingPoint;
00492 aEndingPoint = aStartingPoint;
00493 aStartingPoint = aIntermediatePoint;
00494 fG = fStartAngle;
00495 fStartAngle = fEndAngle;
00496 fEndAngle = fG;
00497 }
00498 FloatPoint fRadius;
00499 fRadius.Y = fRadius.X = sqrt( pow( ( aStartingPoint.X - aCenterPoint.X ), 2 ) + pow( ( aStartingPoint.Y - aCenterPoint.Y ), 2 ) ) ;
00500
00501 sal_uInt32 nType = ImplGetUI16();
00502 if ( nType == 0 )
00503 nType = 0;
00504 else
00505 nType = 1;
00506
00507 double fOrientation = 0;
00508 mpOutAct->DrawEllipticalArc( aCenterPoint, fRadius, fOrientation, nType, fStartAngle, fEndAngle );
00509 }
00510 }
00511 break;
00512
00513 case 0x0f : ComOut( CGM_LEVEL1 | CGM_EXTENDED_PRIMITIVES_SET, "Circular Arc Centre" )
00514 {
00515 double fOrientation, fStartAngle, fEndAngle, vector[ 4 ];
00516 FloatPoint aCenter, aRadius;
00517
00518 if ( mbFigure )
00519 mpOutAct->CloseRegion();
00520
00521 ImplGetPoint( aCenter, sal_True );
00522 ImplGetVector( &vector[ 0 ] );
00523
00524 if ( pElement->eVDCType == VDC_REAL )
00525 {
00526 aRadius.X = (double)ImplGetFloat( pElement->eVDCRealPrecision, pElement->nVDCRealSize );
00527 }
00528 else
00529 {
00530 aRadius.X = (double)ImplGetI( pElement->nVDCIntegerPrecision );
00531 }
00532
00533 ImplMapDouble( aRadius.X );
00534 aRadius.Y = aRadius.X;
00535
00536 fStartAngle = acos( vector[ 0 ] / sqrt( vector[ 0 ] * vector[ 0 ] + vector[ 1 ] * vector[ 1 ] ) ) * 57.29577951308;
00537 fEndAngle = acos( vector[ 2 ] / sqrt( vector[ 2 ] * vector[ 2 ] + vector[ 3 ] * vector[ 3 ] ) ) * 57.29577951308;
00538
00539 if ( vector[ 1 ] > 0 )
00540 fStartAngle = 360 - fStartAngle;
00541 if ( vector[ 3 ] > 0 )
00542 fEndAngle = 360 - fEndAngle;
00543
00544 if ( mbAngReverse )
00545 ImplSwitchStartEndAngle( fStartAngle, fEndAngle );
00546
00547 if ( mbFigure )
00548 {
00549 Rectangle aBoundingBox(
00550 Point( (long)( aCenter.X - aRadius.X ), long( aCenter.Y - aRadius.X ) ),
00551 Size( static_cast< long >( 2 * aRadius.X ), (long)( 2 * aRadius.X ) ) );
00552 Polygon aPolygon( aBoundingBox,
00553 Point( (long)vector[ 0 ], (long)vector[ 1 ] ),
00554 Point( (long)vector[ 2 ], (long)vector[ 3 ] ), POLY_ARC );
00555 mpOutAct->RegPolyLine( aPolygon );
00556 }
00557 else
00558 {
00559 fOrientation = 0;
00560 mpOutAct->DrawEllipticalArc( aCenter, aRadius, fOrientation, 2, fStartAngle, fEndAngle );
00561 }
00562 mnParaSize = mnElementSize;
00563
00564 }
00565 break;
00566
00567 case 0x10 : ComOut( CGM_LEVEL1 | CGM_EXTENDED_PRIMITIVES_SET, "Circular Arc Centre Close" )
00568 {
00569 double fOrientation, fStartAngle, fEndAngle, vector[ 4 ];
00570 FloatPoint aCenter, aRadius;
00571
00572 if ( mbFigure )
00573 mpOutAct->CloseRegion();
00574
00575 ImplGetPoint( aCenter, sal_True );
00576 ImplGetVector( &vector[ 0 ] );
00577 if ( pElement->eVDCType == VDC_REAL )
00578 {
00579 aRadius.X = (double)ImplGetFloat( pElement->eVDCRealPrecision, pElement->nVDCRealSize );
00580 }
00581 else
00582 {
00583 aRadius.X = (double)ImplGetI( pElement->nVDCIntegerPrecision );
00584 }
00585 ImplMapDouble( aRadius.X );
00586 aRadius.Y = aRadius.X;
00587 fStartAngle = acos( vector[ 0 ] / sqrt( vector[ 0 ] * vector[ 0 ] + vector[ 1 ] * vector[ 1 ] ) ) * 57.29577951308;
00588 fEndAngle = acos( vector[ 2 ] / sqrt( vector[ 2 ] * vector[ 2 ] + vector[ 3 ] * vector[ 3 ] ) ) * 57.29577951308;
00589
00590 if ( vector[ 1 ] > 0 )
00591 fStartAngle = 360 - fStartAngle;
00592 if ( vector[ 3 ] > 0 )
00593 fEndAngle = 360 - fEndAngle;
00594
00595 if ( mbAngReverse )
00596 ImplSwitchStartEndAngle( fStartAngle, fEndAngle );
00597
00598
00599 sal_uInt32 nType = ImplGetUI16();
00600 if ( nType == 0 )
00601 nType = 0;
00602 else
00603 nType = 1;
00604 fOrientation = 0;
00605
00606 mpOutAct->DrawEllipticalArc( aCenter, aRadius, fOrientation,
00607 nType, fStartAngle, fEndAngle );
00608 mnParaSize = mnElementSize;
00609 }
00610 break;
00611
00612 case 0x11 : ComOut( CGM_LEVEL1 | CGM_EXTENDED_PRIMITIVES_SET, "Ellipse" )
00613 {
00614 double fOrientation;
00615 FloatPoint aCenter, aRadius;
00616
00617 if ( mbFigure )
00618 mpOutAct->CloseRegion();
00619
00620 ImplGetEllipse( aCenter, aRadius, fOrientation ) ;
00621 mpOutAct->DrawEllipse( aCenter, aRadius, fOrientation ) ;
00622 }
00623 break;
00624
00625 case 0x12 : ComOut( CGM_LEVEL1 | CGM_EXTENDED_PRIMITIVES_SET, "Elliptical Arc" )
00626 {
00627 if ( mbFigure )
00628 mpOutAct->CloseRegion();
00629
00630 double fOrientation, fStartAngle, fEndAngle, vector[ 4 ];
00631 FloatPoint aCenter, aRadius;
00632
00633 if ( mbFigure )
00634 mpOutAct->CloseRegion();
00635
00636 sal_Bool bDirection = ImplGetEllipse( aCenter, aRadius, fOrientation );
00637 ImplGetVector( &vector[ 0 ] );
00638
00639 fStartAngle = acos( vector[ 0 ] / sqrt( vector[ 0 ] * vector[ 0 ] + vector[ 1 ] * vector[ 1 ] ) ) * 57.29577951308;
00640 fEndAngle = acos( vector[ 2 ] / sqrt( vector[ 2 ] * vector[ 2 ] + vector[ 3 ] * vector[ 3 ] ) ) * 57.29577951308;
00641
00642 if ( vector[ 1 ] > 0 )
00643 fStartAngle = 360 - fStartAngle;
00644 if ( vector[ 3 ] > 0 )
00645 fEndAngle = 360 - fEndAngle;
00646
00647 if ( bDirection )
00648 mpOutAct->DrawEllipticalArc( aCenter, aRadius, fOrientation,
00649 2, fStartAngle, fEndAngle );
00650 else
00651 mpOutAct->DrawEllipticalArc( aCenter, aRadius, fOrientation,
00652 2, fEndAngle, fStartAngle);
00653 }
00654 break;
00655
00656 case 0x13 : ComOut( CGM_LEVEL1 | CGM_EXTENDED_PRIMITIVES_SET, "Elliptical Arc Close" )
00657 {
00658 double fOrientation, fStartAngle, fEndAngle, vector[ 4 ];
00659 FloatPoint aCenter, aRadius;
00660
00661 if ( mbFigure )
00662 mpOutAct->CloseRegion();
00663
00664 sal_Bool bDirection = ImplGetEllipse( aCenter, aRadius, fOrientation );
00665 ImplGetVector( &vector[ 0 ] );
00666
00667 fStartAngle = acos( vector[ 0 ] / sqrt( vector[ 0 ] * vector[ 0 ] + vector[ 1 ] * vector[ 1 ] ) ) * 57.29577951308;
00668 fEndAngle = acos( vector[ 2 ] / sqrt( vector[ 2 ] * vector[ 2 ] + vector[ 3 ] * vector[ 3 ] ) ) * 57.29577951308;
00669
00670 if ( vector[ 1 ] > 0 )
00671 fStartAngle = 360 - fStartAngle;
00672 if ( vector[ 3 ] > 0 )
00673 fEndAngle = 360 - fEndAngle;
00674
00675 sal_uInt32 nType = ImplGetUI16();
00676 if ( nType == 0 )
00677 nType = 0;
00678 else
00679 nType = 1;
00680
00681 if ( bDirection )
00682 mpOutAct->DrawEllipticalArc( aCenter, aRadius, fOrientation,
00683 nType, fStartAngle, fEndAngle );
00684 else
00685 mpOutAct->DrawEllipticalArc( aCenter, aRadius, fOrientation,
00686 nType, fEndAngle, fStartAngle);
00687 }
00688 break;
00689 case 0x14 : ComOut( CGM_LEVEL2, "Circular Arc Centre Reversed" )
00690 {
00691 if ( mbFigure )
00692 mpOutAct->CloseRegion();
00693 }
00694 break;
00695 case 0x15 : ComOut( CGM_LEVEL2, "Connection Edge" )
00696 {
00697
00698
00699 }
00700 break;
00701 case 0x16 : ComOut( CGM_LEVEL3, "Hyperbolic Arc" )
00702 {
00703 if ( mbFigure )
00704 mpOutAct->CloseRegion();
00705 }
00706 break;
00707 case 0x17 : ComOut( CGM_LEVEL3, "Parabolic Arc" )
00708 {
00709 if ( mbFigure )
00710 mpOutAct->CloseRegion();
00711 }
00712 break;
00713 case 0x18 : ComOut( CGM_LEVEL3, "Non Uniform B-Spline" )
00714 {
00715 if ( mbFigure )
00716 mpOutAct->CloseRegion();
00717 }
00718 break;
00719 case 0x19 : ComOut( CGM_LEVEL3, "Non Uniform Rational B-Spline" )
00720 {
00721 if ( mbFigure )
00722 mpOutAct->CloseRegion();
00723 }
00724 break;
00725 case 0x1a : ComOut( CGM_LEVEL3, "Polybezier" )
00726 {
00727 sal_uInt32 nOrder = ImplGetI( pElement->nIntegerPrecision );
00728
00729 USHORT nNumberOfPoints = sal::static_int_cast< USHORT >(( mnElementSize - pElement->nIntegerPrecision ) / ImplGetPointSize());
00730
00731 Polygon aPolygon( nNumberOfPoints );
00732
00733 for ( USHORT i = 0; i < nNumberOfPoints; i++)
00734 {
00735 FloatPoint aFloatPoint;
00736 ImplGetPoint( aFloatPoint, sal_True );
00737 aPolygon.SetPoint( Point ( (long)( aFloatPoint.X ), (long)( aFloatPoint.Y ) ), i );
00738 }
00739 if ( nOrder & 4 )
00740 {
00741 for ( USHORT i = 0; i < nNumberOfPoints; i++ )
00742 {
00743 if ( ( i % 3 ) == 0 )
00744 aPolygon.SetFlags( i, POLY_NORMAL );
00745 else
00746 aPolygon.SetFlags( i, POLY_CONTROL );
00747 }
00748 }
00749 else
00750 {
00751 for ( USHORT i = 0; i < nNumberOfPoints; i++ )
00752 {
00753 switch ( i & 3 )
00754 {
00755 case 0 :
00756 case 3 : aPolygon.SetFlags( i, POLY_NORMAL ); break;
00757 default : aPolygon.SetFlags( i, POLY_CONTROL ); break;
00758 }
00759 }
00760 }
00761 if ( mbFigure )
00762 mpOutAct->RegPolyLine( aPolygon );
00763 else
00764 mpOutAct->DrawPolybezier( aPolygon );
00765 mnParaSize = mnElementSize;
00766 }
00767 break;
00768
00769 case 0x1b : ComOut( CGM_LEVEL3, "Polysymbol" )
00770 {
00771 if ( mbFigure )
00772 mpOutAct->CloseRegion();
00773 }
00774 break;
00775 case 0x1c : ComOut( CGM_LEVEL3, "Bitonal Tile" )
00776 {
00777 if ( mbFigure )
00778 mpOutAct->CloseRegion();
00779 }
00780 break;
00781 case 0x1d : ComOut( CGM_LEVEL3, "Tile" )
00782 {
00783 if ( mbFigure )
00784 mpOutAct->CloseRegion();
00785 }
00786 break;
00787 case 0x1e : ComOut( CGM_UNKNOWN_LEVEL, "Insert Object" )
00788 {
00789 if ( mbFigure )
00790 mpOutAct->CloseRegion();
00791 }
00792 break;
00793 case 0xff : ComOut( CGM_GDSF_ONLY, "Polybezier" )
00794 {
00795 if ( mbFigure )
00796 mpOutAct->CloseRegion();
00797 }
00798 break;
00799 case 0xfe : ComOut( CGM_GDSF_ONLY, "Sharp Polybezier" )
00800 {
00801 if ( mbFigure )
00802 mpOutAct->CloseRegion();
00803 }
00804 break;
00805 case 0xfd : ComOut( CGM_GDSF_ONLY, "Polyspline" )
00806 {
00807 if ( mbFigure )
00808 mpOutAct->CloseRegion();
00809 }
00810 break;
00811 case 0xfc : ComOut( CGM_GDSF_ONLY, "Reounded Rectangle" )
00812 {
00813 if ( mbFigure )
00814 mpOutAct->CloseRegion();
00815 }
00816 break;
00817 case 0xfb : ComOut( CGM_GDSF_ONLY, "Begin Cell Array" )
00818 {
00819 if ( mbFigure )
00820 mpOutAct->CloseRegion();
00821 }
00822 break;
00823 case 0xfa : ComOut( CGM_GDSF_ONLY, "End Cell Array" )
00824 {
00825 if ( mbFigure )
00826 mpOutAct->CloseRegion();
00827 }
00828 break;
00829 case 0xf9 : ComOut( CGM_GDSF_ONLY, "Insert File" )
00830 {
00831 if ( mbFigure )
00832 mpOutAct->CloseRegion();
00833 }
00834 break;
00835 case 0xf8 : ComOut( CGM_GDSF_ONLY, "Block Text" )
00836 {
00837 if ( mbFigure )
00838 mpOutAct->CloseRegion();
00839 }
00840 break;
00841 case 0xf7 : ComOut( CGM_GDSF_ONLY, "Variable Width Polyline" )
00842 {
00843 if ( mbFigure )
00844 mpOutAct->CloseRegion();
00845 }
00846 break;
00847 case 0xf6 : ComOut( CGM_GDSF_ONLY, "Elliptical Arc 3 Point" )
00848 {
00849 if ( mbFigure )
00850 mpOutAct->CloseRegion();
00851 }
00852 break;
00853 case 0xf1 : ComOut( CGM_GDSF_ONLY, "Hyperlink Definition" ) break;
00854 default: ComOut( CGM_UNKNOWN_COMMAND, "" ) break;
00855 }
00856 }
00857 else
00858 mnParaSize = mnElementSize;
00859 };
00860
00861