LCOV - code coverage report
Current view: top level - filter/source/graphicfilter/icgm - cgm.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 366 0.0 %
Date: 2014-04-14 Functions: 0 30 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             : #include <com/sun/star/task/XStatusIndicator.hpp>
      21             : #include <unotools/ucbstreamhelper.hxx>
      22             : 
      23             : #include <osl/endian.h>
      24             : #include <vcl/virdev.hxx>
      25             : #include <vcl/graph.hxx>
      26             : #include <tools/stream.hxx>
      27             : #include <chart.hxx>
      28             : #include <main.hxx>
      29             : #include <elements.hxx>
      30             : #include <outact.hxx>
      31             : #include <boost/scoped_ptr.hpp>
      32             : 
      33             : using namespace ::com::sun::star;
      34             : 
      35           0 : void CGM::ImplCGMInit()
      36             : {
      37           0 :     mbIsFinished = mbPicture = mbMetaFile = mbPictureBody = sal_False;
      38             : 
      39           0 :     mnActCount = 0;
      40           0 :     mnOutdx = 28000;
      41           0 :     mnOutdy = 21000;
      42             : 
      43           0 :     mpBuf = NULL;
      44           0 :     mpChart = NULL;
      45           0 :     mpBitmapInUse = NULL;
      46             : 
      47           0 :     pCopyOfE = new CGMElements( *this );
      48           0 :     pElement = new CGMElements( *this );
      49           0 : }
      50             : 
      51             : #ifdef CGM_EXPORT_IMPRESS
      52             : 
      53           0 : CGM::CGM( sal_uInt32 nMode, uno::Reference< frame::XModel > & rModel )  :
      54             :     mpGraphic               ( NULL ),
      55             :     mbStatus                ( sal_True ),
      56           0 :     mpOutAct                ( new CGMImpressOutAct( *this, rModel ) ),
      57           0 :     mnMode                  ( nMode )
      58             : {
      59           0 :     mnMode |= CGM_EXPORT_IMPRESS;
      60           0 :     ImplCGMInit();
      61           0 : }
      62             : #endif
      63             : 
      64           0 : CGM::~CGM()
      65             : {
      66             : 
      67             : #ifdef CGM_EXPORT_META
      68           0 :     if ( mpGraphic )
      69             :     {
      70           0 :         mpGDIMetaFile->Stop();
      71           0 :         mpGDIMetaFile->SetPrefMapMode( MapMode() );
      72           0 :         mpGDIMetaFile->SetPrefSize( Size( static_cast< long >( mnOutdx ), static_cast< long >( mnOutdy ) ) );
      73           0 :         delete mpVirDev;
      74           0 :         *mpGraphic = Graphic( *mpGDIMetaFile );
      75             :     }
      76             : #endif
      77           0 :     for( size_t i = 0, n = maDefRepList.size(); i < n; ++i )
      78           0 :         delete maDefRepList[ i ];
      79           0 :     maDefRepList.clear();
      80           0 :     maDefRepSizeList.clear();
      81           0 :     delete mpBitmapInUse;
      82           0 :     delete mpChart;
      83           0 :     delete mpOutAct;
      84           0 :     delete pCopyOfE;
      85           0 :     delete pElement;
      86           0 :     delete [] mpBuf;
      87           0 : };
      88             : 
      89           0 : sal_uInt32 CGM::GetBackGroundColor()
      90             : {
      91           0 :     return ( pElement ) ? pElement->aColorTable[ 0 ] : 0;
      92             : }
      93             : 
      94           0 : sal_uInt32 CGM::ImplGetUI16( sal_uInt32 /*nAlign*/ )
      95             : {
      96           0 :     sal_uInt8* pSource = mpSource + mnParaSize;
      97           0 :     mnParaSize += 2;
      98           0 :     return ( pSource[ 0 ] << 8 ) +  pSource[ 1 ];
      99             : };
     100             : 
     101           0 : sal_uInt8 CGM::ImplGetByte( sal_uInt32 nSource, sal_uInt32 nPrecision )
     102             : {
     103           0 :     return (sal_uInt8)( nSource >> ( ( nPrecision - 1 ) << 3 ) );
     104             : };
     105             : 
     106           0 : long CGM::ImplGetI( sal_uInt32 nPrecision )
     107             : {
     108           0 :     sal_uInt8* pSource = mpSource + mnParaSize;
     109           0 :     mnParaSize += nPrecision;
     110           0 :     switch( nPrecision )
     111             :     {
     112             :         case 1 :
     113             :         {
     114           0 :             return  (char)*pSource;
     115             :         }
     116             : 
     117             :         case 2 :
     118             :         {
     119           0 :             return (sal_Int16)( ( pSource[ 0 ] << 8 ) | pSource[ 1 ] );
     120             :         }
     121             : 
     122             :         case 3 :
     123             :         {
     124           0 :             return ( ( pSource[ 0 ] << 24 ) | ( pSource[ 1 ] << 16 ) | pSource[ 2 ] << 8 ) >> 8;
     125             :         }
     126             :         case 4:
     127             :         {
     128           0 :             return (sal_Int32)( ( pSource[ 0 ] << 24 ) | ( pSource[ 1 ] << 16 ) | ( pSource[ 2 ] << 8 ) | ( pSource[ 3 ] ) );
     129             :         }
     130             :         default:
     131           0 :             mbStatus = sal_False;
     132           0 :             return 0;
     133             :     }
     134             : }
     135             : 
     136           0 : sal_uInt32 CGM::ImplGetUI( sal_uInt32 nPrecision )
     137             : {
     138           0 :     sal_uInt8* pSource = mpSource + mnParaSize;
     139           0 :     mnParaSize += nPrecision;
     140           0 :     switch( nPrecision )
     141             :     {
     142             :         case 1 :
     143           0 :             return  (sal_Int8)*pSource;
     144             :         case 2 :
     145             :         {
     146           0 :             return (sal_uInt16)( ( pSource[ 0 ] << 8 ) | pSource[ 1 ] );
     147             :         }
     148             :         case 3 :
     149             :         {
     150           0 :             return ( pSource[ 0 ] << 16 ) | ( pSource[ 1 ] << 8 ) | pSource[ 2 ];
     151             :         }
     152             :         case 4:
     153             :         {
     154           0 :             return (sal_uInt32)( ( pSource[ 0 ] << 24 ) | ( pSource[ 1 ] << 16 ) | ( pSource[ 2 ] << 8 ) | ( pSource[ 3 ] ) );
     155             :         }
     156             :         default:
     157           0 :             mbStatus = sal_False;
     158           0 :             return 0;
     159             :     }
     160             : }
     161             : 
     162           0 : void CGM::ImplGetSwitch4( sal_uInt8* pSource, sal_uInt8* pDest )
     163             : {
     164           0 :     for ( int i = 0; i < 4; i++ )
     165             :     {
     166           0 :         pDest[ i ] = pSource[ i ^ 3 ];          // Little Endian <-> Big Endian switch
     167             :     }
     168           0 : }
     169             : 
     170           0 : void CGM::ImplGetSwitch8( sal_uInt8* pSource, sal_uInt8* pDest )
     171             : {
     172           0 :     for ( int i = 0; i < 8; i++ )
     173             :     {
     174           0 :         pDest[ i ] = pSource[ i ^ 7 ];          // Little Endian <-> Big Endian switch
     175             :     }
     176           0 : }
     177             : 
     178           0 : double CGM::ImplGetFloat( RealPrecision eRealPrecision, sal_uInt32 nRealSize )
     179             : {
     180             :     void*   pPtr;
     181             :     sal_uInt8   aBuf[8];
     182             :     sal_Bool    bCompatible;
     183             :     double  nRetValue;
     184             :     double  fDoubleBuf;
     185             :     float   fFloatBuf;
     186             : 
     187             : #ifdef OSL_BIGENDIAN
     188             :         bCompatible = sal_True;
     189             : #else
     190           0 :         bCompatible = sal_False;
     191             : #endif
     192           0 :     if ( bCompatible )
     193           0 :         pPtr = mpSource + mnParaSize;
     194             :     else
     195             :     {
     196           0 :         if ( nRealSize == 4 )
     197           0 :             ImplGetSwitch4( mpSource + mnParaSize, &aBuf[0] );
     198             :         else
     199           0 :             ImplGetSwitch8( mpSource + mnParaSize, &aBuf[0] );
     200           0 :         pPtr = &aBuf;
     201             :     }
     202           0 :     if ( eRealPrecision == RP_FLOAT )
     203             :     {
     204           0 :         if ( nRealSize == 4 )
     205             :         {
     206           0 :             memcpy( (void*)&fFloatBuf, pPtr, 4 );
     207           0 :             nRetValue = (double)fFloatBuf;
     208             :         }
     209             :         else
     210             :         {
     211           0 :             memcpy( (void*)&fDoubleBuf, pPtr, 8 );
     212           0 :             nRetValue = fDoubleBuf;
     213             :         }
     214             :     }
     215             :     else // ->RP_FIXED
     216             :     {
     217             :         long    nVal;
     218           0 :         int     nSwitch = ( bCompatible ) ? 0 : 1 ;
     219           0 :         if ( nRealSize == 4 )
     220             :         {
     221           0 :             sal_uInt16* pShort = (sal_uInt16*)pPtr;
     222           0 :             nVal = pShort[ nSwitch ];
     223           0 :             nVal <<= 16;
     224           0 :             nVal |= pShort[ nSwitch ^ 1 ];
     225           0 :             nRetValue = (double)nVal;
     226           0 :             nRetValue /= 65536;
     227             :         }
     228             :         else
     229             :         {
     230           0 :             sal_Int32* pLong = (sal_Int32*)pPtr;
     231           0 :             nRetValue = (double)abs( pLong[ nSwitch ] );
     232           0 :             nRetValue *= 65536;
     233           0 :             nVal = (sal_uInt32)( pLong[ nSwitch ^ 1 ] );
     234           0 :             nVal >>= 16;
     235           0 :             nRetValue += (double)nVal;
     236           0 :             if ( pLong[ nSwitch ] < 0 )
     237             :             {
     238           0 :                 nRetValue = -nRetValue;
     239             :             }
     240           0 :             nRetValue /= 65536;
     241             :         }
     242             :     }
     243           0 :     mnParaSize += nRealSize;
     244           0 :     return nRetValue;
     245             : }
     246             : 
     247           0 : sal_uInt32 CGM::ImplGetPointSize()
     248             : {
     249           0 :     if ( pElement->eVDCType == VDC_INTEGER )
     250           0 :         return pElement->nVDCIntegerPrecision << 1;
     251             :     else
     252           0 :         return pElement->nVDCRealSize << 1;
     253             : }
     254             : 
     255           0 : inline double CGM::ImplGetIX()
     256             : {
     257           0 :     return ( ( ImplGetI( pElement->nVDCIntegerPrecision ) + mnVDCXadd ) * mnVDCXmul );
     258             : }
     259             : 
     260           0 : inline double CGM::ImplGetFX()
     261             : {
     262           0 :     return ( ( ImplGetFloat( pElement->eVDCRealPrecision, pElement->nVDCRealSize ) + mnVDCXadd ) * mnVDCXmul );
     263             : }
     264             : 
     265           0 : inline double CGM::ImplGetIY()
     266             : {
     267           0 :     return ( ( ImplGetI( pElement->nVDCIntegerPrecision ) + mnVDCYadd ) * mnVDCYmul );
     268             : }
     269             : 
     270           0 : inline double CGM::ImplGetFY()
     271             : {
     272           0 :     return ( ( ImplGetFloat( pElement->eVDCRealPrecision, pElement->nVDCRealSize ) + mnVDCYadd ) * mnVDCYmul );
     273             : }
     274             : 
     275           0 : void CGM::ImplGetPoint( FloatPoint& rFloatPoint, sal_Bool bMap )
     276             : {
     277           0 :     if ( pElement->eVDCType == VDC_INTEGER )
     278             :     {
     279           0 :         rFloatPoint.X = ImplGetIX();
     280           0 :         rFloatPoint.Y = ImplGetIY();
     281             :     }
     282             :     else // ->floating points
     283             :     {
     284           0 :         rFloatPoint.X = ImplGetFX();
     285           0 :         rFloatPoint.Y = ImplGetFY();
     286             :     }
     287           0 :     if ( bMap )
     288           0 :         ImplMapPoint( rFloatPoint );
     289           0 : }
     290             : 
     291           0 : void CGM::ImplGetRectangle( FloatRect& rFloatRect, sal_Bool bMap )
     292             : {
     293           0 :     if ( pElement->eVDCType == VDC_INTEGER )
     294             :     {
     295           0 :         rFloatRect.Left = ImplGetIX();
     296           0 :         rFloatRect.Bottom = ImplGetIY();
     297           0 :         rFloatRect.Right = ImplGetIX();
     298           0 :         rFloatRect.Top = ImplGetIY();
     299             :     }
     300             :     else // ->floating points
     301             :     {
     302           0 :         rFloatRect.Left = ImplGetFX();
     303           0 :         rFloatRect.Bottom = ImplGetFY();
     304           0 :         rFloatRect.Right = ImplGetFX();
     305           0 :         rFloatRect.Top = ImplGetFY();
     306             :     }
     307           0 :     if ( bMap )
     308             :     {
     309           0 :         ImplMapX( rFloatRect.Left );
     310           0 :         ImplMapX( rFloatRect.Right );
     311           0 :         ImplMapY( rFloatRect.Top );
     312           0 :         ImplMapY( rFloatRect.Bottom );
     313           0 :         rFloatRect.Justify();
     314             :     }
     315           0 : }
     316             : 
     317           0 : void CGM::ImplGetRectangleNS( FloatRect& rFloatRect )
     318             : {
     319           0 :     if ( pElement->eVDCType == VDC_INTEGER )
     320             :     {
     321           0 :         rFloatRect.Left = ImplGetI( pElement->nVDCIntegerPrecision );
     322           0 :         rFloatRect.Bottom = ImplGetI( pElement->nVDCIntegerPrecision );
     323           0 :         rFloatRect.Right = ImplGetI( pElement->nVDCIntegerPrecision );
     324           0 :         rFloatRect.Top = ImplGetI( pElement->nVDCIntegerPrecision );
     325             :     }
     326             :     else // ->floating points
     327             :     {
     328           0 :         rFloatRect.Left = ImplGetFloat( pElement->eVDCRealPrecision, pElement->nVDCRealSize );
     329           0 :         rFloatRect.Bottom = ImplGetFloat( pElement->eVDCRealPrecision, pElement->nVDCRealSize );
     330           0 :         rFloatRect.Right = ImplGetFloat( pElement->eVDCRealPrecision, pElement->nVDCRealSize );
     331           0 :         rFloatRect.Top = ImplGetFloat( pElement->eVDCRealPrecision, pElement->nVDCRealSize );
     332             :     }
     333           0 : }
     334             : 
     335           0 : sal_uInt32 CGM::ImplGetBitmapColor( sal_Bool bDirect )
     336             : {
     337             :     // the background color is always a direct color
     338             : 
     339             :     sal_uInt32  nTmp;
     340           0 :     if ( ( pElement->eColorSelectionMode == CSM_DIRECT ) || bDirect )
     341             :     {
     342           0 :         sal_uInt32      nColor = ImplGetByte( ImplGetUI( pElement->nColorPrecision ), 1 );
     343           0 :         sal_uInt32      nDiff = pElement->nColorValueExtent[ 3 ] - pElement->nColorValueExtent[ 0 ] + 1;
     344             : 
     345           0 :         if ( !nDiff )
     346           0 :             nDiff++;
     347           0 :         nColor = ( ( nColor - pElement->nColorValueExtent[ 0 ] ) << 8 ) / nDiff;
     348           0 :         nTmp = nColor << 16 & 0xff0000;
     349             : 
     350           0 :         nColor = ImplGetByte( ImplGetUI( pElement->nColorPrecision ), 1 );
     351           0 :         nDiff = pElement->nColorValueExtent[ 4 ] - pElement->nColorValueExtent[ 1 ] + 1;
     352           0 :         if ( !nDiff )
     353           0 :             nDiff++;
     354           0 :         nColor = ( ( nColor - pElement->nColorValueExtent[ 1 ] ) << 8 ) / nDiff;
     355           0 :         nTmp |= nColor << 8 & 0xff00;
     356             : 
     357           0 :         nColor = ImplGetByte( ImplGetUI( pElement->nColorPrecision ), 1 );
     358           0 :         nDiff = pElement->nColorValueExtent[ 5 ] - pElement->nColorValueExtent[ 2 ] + 1;
     359           0 :         if ( !nDiff )
     360           0 :             nDiff++;
     361           0 :         nColor = ( ( nColor - pElement->nColorValueExtent[ 2 ] ) << 8 ) / nDiff;
     362           0 :         nTmp |= (sal_uInt8)nColor;
     363             :     }
     364             :     else
     365             :     {
     366           0 :         sal_uInt32 nIndex = ImplGetUI( pElement->nColorIndexPrecision );
     367           0 :         nTmp = pElement->aColorTable[ (sal_uInt8)( nIndex ) ] ;
     368             :     }
     369           0 :     return nTmp;
     370             : }
     371             : 
     372             : // call this function each time after the mapmode settings has been changed
     373           0 : void CGM::ImplSetMapMode()
     374             : {
     375           0 :     int nAngReverse = 1;
     376           0 :     mnVDCdx = pElement->aVDCExtent.Right - pElement->aVDCExtent.Left;
     377             : 
     378           0 :     mnVDCXadd = -pElement->aVDCExtent.Left;
     379           0 :     mnVDCXmul = 1;
     380           0 :     if ( mnVDCdx < 0 )
     381             :     {
     382           0 :         nAngReverse ^= 1;
     383           0 :         mnVDCdx = -mnVDCdx;
     384           0 :         mnVDCXmul = -1;
     385             :     }
     386             : 
     387           0 :     mnVDCdy = pElement->aVDCExtent.Bottom - pElement->aVDCExtent.Top;
     388           0 :     mnVDCYadd = -pElement->aVDCExtent.Top;
     389           0 :     mnVDCYmul = 1;
     390           0 :     if ( mnVDCdy < 0 )
     391             :     {
     392           0 :         nAngReverse ^= 1;
     393           0 :         mnVDCdy = -mnVDCdy;
     394           0 :         mnVDCYmul = -1;
     395             :     }
     396           0 :     if ( nAngReverse )
     397           0 :         mbAngReverse = sal_True;
     398             :     else
     399           0 :         mbAngReverse = sal_False;
     400             : 
     401           0 :     double fQuo1 = mnVDCdx / mnVDCdy;
     402           0 :     double fQuo2 = mnOutdx / mnOutdy;
     403           0 :     if ( fQuo2 < fQuo1 )
     404             :     {
     405           0 :         mnXFraction = mnOutdx / mnVDCdx;
     406           0 :         mnYFraction = mnOutdy * ( fQuo2 / fQuo1 ) / mnVDCdy;
     407             :     }
     408             :     else
     409             :     {
     410           0 :         mnXFraction = mnOutdx * ( fQuo1 / fQuo2 ) / mnVDCdx;
     411           0 :         mnYFraction = mnOutdy / mnVDCdy;
     412             :     }
     413           0 : }
     414             : 
     415           0 : void CGM::ImplMapDouble( double& nNumb )
     416             : {
     417           0 :     if ( pElement->eDeviceViewPortMap == DVPM_FORCED )
     418             :     {
     419             :         // point is 1mm * ScalingFactor
     420           0 :         switch ( pElement->eDeviceViewPortMode )
     421             :         {
     422             :             case DVPM_FRACTION :
     423             :             {
     424           0 :                 nNumb *= ( mnXFraction + mnYFraction ) / 2;
     425             :             }
     426           0 :             break;
     427             : 
     428             :             case DVPM_METRIC :
     429             :             {
     430             :                 // nNumb *= ( 100 * pElement->nDeviceViewPortScale );
     431           0 :                 nNumb *= ( mnXFraction + mnYFraction ) / 2;
     432           0 :                 if ( pElement->nDeviceViewPortScale < 0 )
     433           0 :                     nNumb = -nNumb;
     434             :             }
     435           0 :             break;
     436             : 
     437             :             case DVPM_DEVICE :
     438             :             {
     439             : 
     440             :             }
     441           0 :             break;
     442             : 
     443             :             default:
     444             : 
     445           0 :                 break;
     446             :         }
     447             :     }
     448             :     else
     449             :     {
     450             : 
     451             : 
     452             :     }
     453           0 : }
     454             : 
     455           0 : void CGM::ImplMapX( double& nNumb )
     456             : {
     457           0 :     if ( pElement->eDeviceViewPortMap == DVPM_FORCED )
     458             :     {
     459             :         // point is 1mm * ScalingFactor
     460           0 :         switch ( pElement->eDeviceViewPortMode )
     461             :         {
     462             :             case DVPM_FRACTION :
     463             :             {
     464           0 :                 nNumb *= mnXFraction;
     465             :             }
     466           0 :             break;
     467             : 
     468             :             case DVPM_METRIC :
     469             :             {
     470             :                 // nNumb *= ( 100 * pElement->nDeviceViewPortScale );
     471           0 :                 nNumb *= mnXFraction;
     472           0 :                 if ( pElement->nDeviceViewPortScale < 0 )
     473           0 :                     nNumb = -nNumb;
     474             :             }
     475           0 :             break;
     476             : 
     477             :             case DVPM_DEVICE :
     478             :             {
     479             : 
     480             :             }
     481           0 :             break;
     482             : 
     483             :             default:
     484             : 
     485           0 :                 break;
     486             :         }
     487             :     }
     488             :     else
     489             :     {
     490             : 
     491             : 
     492             :     }
     493           0 : }
     494             : 
     495           0 : void CGM::ImplMapY( double& nNumb )
     496             : {
     497           0 :     if ( pElement->eDeviceViewPortMap == DVPM_FORCED )
     498             :     {
     499             :         // point is 1mm * ScalingFactor
     500           0 :         switch ( pElement->eDeviceViewPortMode )
     501             :         {
     502             :             case DVPM_FRACTION :
     503             :             {
     504           0 :                 nNumb *= mnYFraction;
     505             :             }
     506           0 :             break;
     507             : 
     508             :             case DVPM_METRIC :
     509             :             {
     510             :                 // nNumb *= ( 100 * pElement->nDeviceViewPortScale );
     511           0 :                 nNumb *= mnYFraction;
     512           0 :                 if ( pElement->nDeviceViewPortScale < 0 )
     513           0 :                     nNumb = -nNumb;
     514             :             }
     515           0 :             break;
     516             : 
     517             :             case DVPM_DEVICE :
     518             :             {
     519             : 
     520             :             }
     521           0 :             break;
     522             : 
     523             :             default:
     524             : 
     525           0 :                 break;
     526             :         }
     527             :     }
     528             :     else
     529             :     {
     530             : 
     531             : 
     532             :     }
     533           0 : }
     534             : 
     535             : // convert a point to the current VC mapmode (1/100TH mm)
     536           0 : void CGM::ImplMapPoint( FloatPoint& rFloatPoint )
     537             : {
     538           0 :     if ( pElement->eDeviceViewPortMap == DVPM_FORCED )
     539             :     {
     540             :         // point is 1mm * ScalingFactor
     541           0 :         switch ( pElement->eDeviceViewPortMode )
     542             :         {
     543             :             case DVPM_FRACTION :
     544             :             {
     545           0 :                 rFloatPoint.X *= mnXFraction;
     546           0 :                 rFloatPoint.Y *= mnYFraction;
     547             :             }
     548           0 :             break;
     549             : 
     550             :             case DVPM_METRIC :
     551             :             {
     552           0 :                 rFloatPoint.X *= mnXFraction;
     553           0 :                 rFloatPoint.Y *= mnYFraction;
     554           0 :                 if ( pElement->nDeviceViewPortScale < 0 )
     555             :                 {
     556           0 :                     rFloatPoint.X = -rFloatPoint.X;
     557           0 :                     rFloatPoint.Y = -rFloatPoint.Y;
     558             :                 }
     559             :             }
     560           0 :             break;
     561             : 
     562             :             case DVPM_DEVICE :
     563             :             {
     564             : 
     565             :             }
     566           0 :             break;
     567             : 
     568             :             default:
     569             : 
     570           0 :                 break;
     571             :         }
     572             :     }
     573             :     else
     574             :     {
     575             : 
     576             : 
     577             :     }
     578           0 : }
     579             : 
     580           0 : void CGM::ImplDoClass()
     581             : {
     582             : #ifdef CGM_USER_BREAKPOINT
     583             : #ifdef WNT
     584             : #define CGM_BREAK_ACTION    0xffffffff
     585             :     if ( mnActCount == CGM_BREAK_ACTION )
     586             :         _asm int 0x3;
     587             : #endif
     588             : #endif
     589           0 :     switch ( mnElementClass )
     590             :     {
     591           0 :         case 0 : ImplDoClass0(); break;
     592           0 :         case 1 : ImplDoClass1(); break;
     593           0 :         case 2 : ImplDoClass2(); break;
     594           0 :         case 3 : ImplDoClass3(); break;
     595             :         case 4 :
     596             :         {
     597           0 :             ImplDoClass4();
     598           0 :             mnAct4PostReset = 0;
     599             :         }
     600           0 :         break;
     601           0 :         case 5 : ImplDoClass5(); break;
     602           0 :         case 6 : ImplDoClass6(); break;
     603           0 :         case 7 : ImplDoClass7(); break;
     604           0 :         case 8 : ImplDoClass8(); break;
     605           0 :         case 9 : ImplDoClass9(); break;
     606           0 :         case 15 :ImplDoClass15(); break;
     607           0 :         default: break;
     608             :     }
     609           0 :     mnActCount++;
     610           0 : };
     611             : 
     612           0 : void CGM::ImplDefaultReplacement()
     613             : {
     614           0 :     if ( !maDefRepList.empty() )
     615             :     {
     616           0 :         sal_uInt32  nOldEscape = mnEscape;
     617           0 :         sal_uInt32  nOldElementClass = mnElementClass;
     618           0 :         sal_uInt32  nOldElementID = mnElementID;
     619           0 :         sal_uInt32  nOldElementSize = mnElementSize;
     620           0 :         sal_uInt8*  pOldBuf = mpSource;
     621             : 
     622           0 :         for ( size_t i = 0, n = maDefRepList.size(); i < n; ++i )
     623             :         {
     624           0 :             sal_uInt8*  pBuf = maDefRepList[ i ];
     625           0 :             sal_uInt32  nElementSize = maDefRepSizeList[ i ];
     626           0 :             sal_uInt32  nCount = 0;
     627           0 :             while ( mbStatus && ( nCount < nElementSize ) )
     628             :             {
     629           0 :                 mpSource = pBuf + nCount;
     630           0 :                 mnParaSize = 0;
     631           0 :                 mnEscape = ImplGetUI16();
     632           0 :                 mnElementClass = mnEscape >> 12;
     633           0 :                 mnElementID = ( mnEscape & 0x0fe0 ) >> 5;
     634           0 :                 mnElementSize = mnEscape & 0x1f;
     635           0 :                 if ( mnElementSize == 31 )
     636             :                 {
     637           0 :                     mnElementSize = ImplGetUI16();
     638             :                 }
     639           0 :                 nCount += mnParaSize;
     640           0 :                 mnParaSize = 0;
     641           0 :                 mpSource = pBuf + nCount;
     642           0 :                 if ( mnElementSize & 1 )
     643           0 :                     nCount++;
     644           0 :                 nCount += mnElementSize;
     645           0 :                 if ( ( mnElementClass != 1 ) || ( mnElementID != 0xc ) )    // recursion is not possible here!!
     646           0 :                     ImplDoClass();
     647             :             }
     648             :         }
     649           0 :         mnEscape = nOldEscape;
     650           0 :         mnElementClass = nOldElementClass;
     651           0 :         mnElementID = nOldElementID;
     652           0 :         mnParaSize = mnElementSize = nOldElementSize;
     653           0 :         mpSource = pOldBuf;
     654             :     }
     655           0 : }
     656             : 
     657           0 : sal_Bool CGM::Write( SvStream& rIStm )
     658             : {
     659           0 :     if ( !mpBuf )
     660           0 :         mpBuf = new sal_uInt8[ 0xffff ];
     661             : 
     662           0 :     mnParaSize = 0;
     663           0 :     mpSource = mpBuf;
     664           0 :     rIStm.Read( mpSource, 2 );
     665           0 :     mnEscape = ImplGetUI16();
     666           0 :     mnElementClass = mnEscape >> 12;
     667           0 :     mnElementID = ( mnEscape & 0x0fe0 ) >> 5;
     668           0 :     mnElementSize = mnEscape & 0x1f;
     669             : 
     670           0 :     if ( mnElementSize == 31 )
     671             :     {
     672           0 :         rIStm.Read( mpSource + mnParaSize, 2 );
     673           0 :         mnElementSize = ImplGetUI16();
     674             :     }
     675           0 :     mnParaSize = 0;
     676           0 :     if ( mnElementSize )
     677           0 :         rIStm.Read( mpSource + mnParaSize, mnElementSize );
     678             : 
     679           0 :     if ( mnElementSize & 1 )
     680           0 :         rIStm.SeekRel( 1 );
     681           0 :     ImplDoClass();
     682             : 
     683             : 
     684             : #ifdef CGM_USER_BREAKPOINT
     685             : #ifdef WNT
     686             :     if ( !mbStatus || mnParaSize && ( mnElementSize != mnParaSize ) )
     687             :         _asm int 0x3;
     688             : #endif
     689             : #endif
     690             : 
     691           0 :     return mbStatus;
     692             : };
     693             : 
     694           0 : SvStream& operator>>( SvStream& rOStm, CGM& /*rCGM*/ )
     695             : {
     696             : 
     697           0 :     return rOStm;
     698             : };
     699             : 
     700             : // GraphicImport - the exported function
     701             : extern "C" SAL_DLLPUBLIC_EXPORT sal_uInt32 SAL_CALL
     702           0 : ImportCGM( OUString& rFileName, uno::Reference< frame::XModel > & rXModel, sal_uInt32 nMode, void* pProgressBar )
     703             : {
     704             : 
     705           0 :     sal_uInt32  nStatus = 0;            // retvalue == 0 -> ERROR
     706             :                                         //          == 0xffrrggbb -> background color in the lower 24 bits
     707           0 :     sal_Bool    bProgressBar = sal_False;
     708             : 
     709           0 :     if( rXModel.is() )
     710             :     {
     711             :         try
     712             :         {
     713           0 :             boost::scoped_ptr<CGM> pCGM(new CGM( nMode, rXModel ));
     714           0 :             if ( pCGM && pCGM->IsValid() )
     715             :             {
     716           0 :                 if ( nMode & CGM_IMPORT_CGM )
     717             :                 {
     718           0 :                     boost::scoped_ptr<SvStream> pIn(::utl::UcbStreamHelper::CreateStream( rFileName, STREAM_READ ));
     719           0 :                     if ( pIn )
     720             :                     {
     721           0 :                         pIn->SetNumberFormatInt( NUMBERFORMAT_INT_BIGENDIAN );
     722           0 :                         pIn->Seek( STREAM_SEEK_TO_END );
     723           0 :                         sal_uInt32  nInSize = pIn->Tell();
     724           0 :                         pIn->Seek( 0 );
     725             : 
     726             : #ifdef CGM_EXPORT_IMPRESS
     727           0 :                         uno::Reference< task::XStatusIndicator >  aXStatInd;
     728           0 :                         sal_uInt32  nNext = 0;
     729           0 :                         sal_uInt32  nAdd = nInSize / 20;
     730           0 :                         if ( pProgressBar )
     731           0 :                             aXStatInd = *(uno::Reference< task::XStatusIndicator > *)pProgressBar;
     732           0 :                         bProgressBar = aXStatInd.is();
     733           0 :                         if ( bProgressBar )
     734           0 :                             aXStatInd->start( "CGM Import" , nInSize );
     735             : #endif
     736             : 
     737           0 :                         while ( pCGM->IsValid() && ( pIn->Tell() < nInSize ) && !pCGM->IsFinished() )
     738             :                         {
     739             : 
     740             : #ifdef CGM_EXPORT_IMPRESS
     741             : 
     742             : 
     743           0 :                             if ( bProgressBar )
     744             :                             {
     745           0 :                                 sal_uInt32 nCurrentPos = pIn->Tell();
     746           0 :                                 if ( nCurrentPos >= nNext )
     747             :                                 {
     748           0 :                                     aXStatInd->setValue( nCurrentPos );
     749           0 :                                     nNext = nCurrentPos + nAdd;
     750             :                                 }
     751             :                             }
     752             : #endif
     753             : 
     754           0 :                             if ( pCGM->Write( *pIn ) == sal_False )
     755           0 :                                 break;
     756             :                         }
     757           0 :                         if ( pCGM->IsValid() )
     758             :                         {
     759           0 :                             nStatus = pCGM->GetBackGroundColor() | 0xff000000;
     760             :                         }
     761             : #ifdef CGM_EXPORT_IMPRESS
     762           0 :                         if ( bProgressBar )
     763           0 :                             aXStatInd->end();
     764             : #endif
     765           0 :                     }
     766             :                 }
     767           0 :             }
     768             :         }
     769           0 :         catch( const ::com::sun::star::uno::Exception& )
     770             :         {
     771           0 :             nStatus = 0;
     772             :         }
     773             :     }
     774           0 :     return nStatus;
     775             : }
     776             : 
     777             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10