LCOV - code coverage report
Current view: top level - libreoffice/filter/source/graphicfilter/icgm - class4.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 447 0.0 %
Date: 2012-12-27 Functions: 0 5 0.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10