LCOV - code coverage report
Current view: top level - libreoffice/filter/source/graphicfilter/icgm - elements.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 252 0.0 %
Date: 2012-12-27 Functions: 0 10 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 "elements.hxx"
      22             : 
      23             : // ---------------------------------------------------------------
      24             : 
      25             : 
      26           0 : CGMElements::CGMElements( CGM& rCGM ) :
      27           0 :     mpCGM ( &rCGM )
      28             : {
      29           0 :     Init();
      30           0 : };
      31             : 
      32             : // ---------------------------------------------------------------
      33             : 
      34           0 : CGMElements::~CGMElements()
      35             : {
      36           0 :     DeleteAllBundles( aLineList );
      37           0 :     DeleteAllBundles( aMarkerList );
      38           0 :     DeleteAllBundles( aEdgeList );
      39           0 :     DeleteAllBundles( aTextList );
      40           0 :     DeleteAllBundles( aFillList );
      41           0 : }
      42             : 
      43             : // ---------------------------------------------------------------
      44             : 
      45           0 : CGMElements& CGMElements::operator=( CGMElements& rSource )
      46             : {
      47             :     sal_uInt32 nIndex;
      48             : 
      49           0 :     nVDCIntegerPrecision = rSource.nVDCIntegerPrecision;
      50           0 :     nIntegerPrecision = rSource.nIntegerPrecision;
      51           0 :     eRealPrecision = rSource.eRealPrecision;
      52           0 :     nRealSize = rSource.nRealSize;
      53           0 :     nIndexPrecision = rSource.nIndexPrecision;
      54           0 :     nColorPrecision = rSource.nColorPrecision;
      55           0 :     nColorIndexPrecision = rSource.nColorIndexPrecision;
      56             : 
      57           0 :     nMetaFileVersion = rSource.nMetaFileVersion;
      58           0 :     eScalingMode = rSource.eScalingMode;
      59           0 :     nScalingFactor = rSource.nScalingFactor;
      60           0 :     eVDCType = rSource.eVDCType;
      61           0 :     eVDCRealPrecision = rSource.eVDCRealPrecision;
      62           0 :     nVDCRealSize = rSource.nVDCRealSize;
      63           0 :     aVDCExtent = rSource.aVDCExtent;
      64           0 :     aVDCExtentMaximum = rSource.aVDCExtentMaximum;
      65           0 :     eDeviceViewPortMode = rSource.eDeviceViewPortMode;
      66           0 :     nDeviceViewPortScale = rSource.nDeviceViewPortScale;
      67           0 :     eDeviceViewPortMap = rSource.eDeviceViewPortMap;
      68           0 :     eDeviceViewPortMapH = rSource.eDeviceViewPortMapH;
      69           0 :     eDeviceViewPortMapV = rSource.eDeviceViewPortMapV;
      70           0 :     aDeviceViewPort = rSource.aDeviceViewPort;
      71           0 :     nMitreLimit = rSource.nMitreLimit;
      72           0 :     eClipIndicator = rSource.eClipIndicator;
      73           0 :     aClipRect = rSource.aClipRect;
      74           0 :     eColorSelectionMode = rSource.eColorSelectionMode;
      75           0 :     eColorModel = rSource.eColorModel;
      76           0 :     nColorMaximumIndex = rSource.nColorMaximumIndex;
      77           0 :     nLatestColorMaximumIndex = rSource.nLatestColorMaximumIndex;
      78             : 
      79           0 :     for ( nIndex = 1; nIndex < 256; nIndex++ )      // do not overwrite the background color
      80             :     {
      81           0 :         aColorTableEntryIs[ nIndex ] = rSource.aColorTableEntryIs[ nIndex ];
      82           0 :         aColorTable[ nIndex ] = rSource.aColorTable[ nIndex ];
      83           0 :         aLatestColorTable[ nIndex ] = rSource.aColorTable[ nIndex ];
      84             :     }
      85             : 
      86           0 :     for ( nIndex = 0; nIndex < 8; nIndex++ )
      87             :     {
      88           0 :         nColorValueExtent[ nIndex ] = rSource.nColorValueExtent[ nIndex ];
      89             :     }
      90           0 :     nAspectSourceFlags = rSource.nAspectSourceFlags;
      91             : 
      92           0 :     CopyAllBundles( rSource.aLineList, aLineList );
      93           0 :     aLineBundle = rSource.aLineBundle;
      94           0 :     pLineBundle = (LineBundle*)GetBundle( aLineList, rSource.pLineBundle->GetIndex() );
      95           0 :     eLineWidthSpecMode = rSource.eLineWidthSpecMode;
      96           0 :     eLineCapType = rSource.eLineCapType;
      97           0 :     eLineJoinType = rSource.eLineJoinType;
      98             : 
      99           0 :     CopyAllBundles( rSource.aMarkerList, aMarkerList );
     100           0 :     aMarkerBundle = rSource.aMarkerBundle;
     101           0 :     pMarkerBundle = (MarkerBundle*)GetBundle( aMarkerList, rSource.pMarkerBundle->GetIndex() );
     102           0 :     eMarkerSizeSpecMode = rSource.eMarkerSizeSpecMode;
     103             : 
     104           0 :     CopyAllBundles( rSource.aEdgeList, aEdgeList );
     105           0 :     aEdgeBundle = rSource.aEdgeBundle;
     106           0 :     pEdgeBundle = (EdgeBundle*)GetBundle( aEdgeList, rSource.pEdgeBundle->GetIndex() );
     107           0 :     eEdgeVisibility = rSource.eEdgeVisibility;
     108           0 :     eEdgeWidthSpecMode = rSource.eEdgeWidthSpecMode;
     109             : 
     110           0 :     CopyAllBundles( rSource.aTextList, aTextList );
     111           0 :     aTextBundle = rSource.aTextBundle;
     112           0 :     pTextBundle = (TextBundle*)GetBundle( aTextList, rSource.pTextBundle->GetIndex() );
     113           0 :     nCharacterHeight = rSource.nCharacterHeight;
     114           0 :     nCharacterOrientation[ 0 ] = rSource.nCharacterOrientation[ 0 ];
     115           0 :     nCharacterOrientation[ 1 ] = rSource.nCharacterOrientation[ 1 ];
     116           0 :     nCharacterOrientation[ 2 ] = rSource.nCharacterOrientation[ 2 ];
     117           0 :     nCharacterOrientation[ 3 ] = rSource.nCharacterOrientation[ 3 ];
     118           0 :     eUnderlineMode = rSource.eUnderlineMode;
     119           0 :     nUnderlineColor = rSource.nUnderlineColor;
     120           0 :     eTextPath = rSource.eTextPath;
     121           0 :     eTextAlignmentH = rSource.eTextAlignmentH;
     122           0 :     eTextAlignmentV = rSource.eTextAlignmentV;
     123           0 :     nTextAlignmentHCont = rSource.nTextAlignmentHCont;
     124           0 :     nTextAlignmentVCont = rSource.nTextAlignmentVCont;
     125           0 :     nCharacterSetIndex = rSource.nCharacterSetIndex;
     126           0 :     nAlternateCharacterSetIndex = rSource.nAlternateCharacterSetIndex;
     127           0 :     aFontList = rSource.aFontList;
     128           0 :     eCharacterCodingA = rSource.eCharacterCodingA;
     129             : 
     130           0 :     CopyAllBundles( rSource.aFillList, aFillList );
     131           0 :     aFillBundle = rSource.aFillBundle;
     132           0 :     pFillBundle = (FillBundle*)GetBundle( aFillList, rSource.pFillBundle->GetIndex() );
     133           0 :     aFillRefPoint = rSource.aFillRefPoint;
     134           0 :     eTransparency = rSource.eTransparency;
     135           0 :     nAuxiliaryColor = rSource.nAuxiliaryColor;
     136             : 
     137           0 :     maHatchMap = rSource.maHatchMap;
     138           0 :     bSegmentCount = rSource.bSegmentCount;
     139           0 :     return (*this);
     140             : }
     141             : 
     142             : // ---------------------------------------------------------------
     143             : 
     144           0 : void CGMElements::Init()
     145             : {
     146             : 
     147           0 :     nIntegerPrecision = nIndexPrecision = 2;
     148           0 :     nRealSize = nVDCRealSize = 4;
     149           0 :     nColorIndexPrecision = 1;
     150           0 :     nColorPrecision = 1;
     151           0 :     nVDCIntegerPrecision = 2;
     152           0 :     eRealPrecision = eVDCRealPrecision = RP_FIXED;      //RP_FLOAT;
     153             : 
     154           0 :     nMetaFileVersion = 1;
     155           0 :     eScalingMode = SM_ABSTRACT;
     156           0 :     eVDCType = VDC_INTEGER;
     157           0 :     aVDCExtent.Left = aVDCExtent.Bottom = 0;
     158             : //  aVDCExtent.Right = aVDCExtent.Top = 32767;
     159           0 :     aVDCExtent.Right = aVDCExtent.Top = 1.0;
     160           0 :     aVDCExtentMaximum.Left = aVDCExtentMaximum.Bottom = 0;
     161             : //  aVDCExtentMaximum.Right = aVDCExtentMaximum.Top = 32767;
     162           0 :     aVDCExtentMaximum.Right = aVDCExtentMaximum.Top = 1.0;
     163             : 
     164           0 :     eDeviceViewPortMode = DVPM_FRACTION;
     165           0 :     nDeviceViewPortScale = 1;
     166           0 :     eDeviceViewPortMap = DVPM_FORCED;
     167           0 :     eDeviceViewPortMapH = DVPMH_LEFT;
     168           0 :     eDeviceViewPortMapV = DVPMV_BOTTOM;
     169           0 :     aDeviceViewPort.Left = 0;
     170           0 :     aDeviceViewPort.Top = 1;
     171           0 :     aDeviceViewPort.Right = 0;
     172           0 :     aDeviceViewPort.Bottom = 1;
     173             : 
     174           0 :     nMitreLimit = 32767;
     175           0 :     eClipIndicator = CI_ON;
     176           0 :     aClipRect = aVDCExtent;
     177             : 
     178           0 :     eColorSelectionMode = CSM_INDEXED;
     179           0 :     eColorModel = CM_RGB;
     180           0 :     nColorMaximumIndex = 63;
     181             :     int i;
     182           0 :     for ( i = 0; i < 256; aColorTableEntryIs[ i++ ] = 0 ) ;
     183           0 :     aColorTable[ 0 ] = 0;
     184           0 :     for ( i = 1; i < 256; aColorTable[ i++ ] = 0xffffff ) ;
     185           0 :     nLatestColorMaximumIndex = 63;
     186           0 :     aLatestColorTable[ 0 ] = 0;
     187           0 :     for ( i = 1; i < 256; aLatestColorTable[ i++ ] = 0xffffff ) ;
     188           0 :     nColorValueExtent[ 0 ] = nColorValueExtent[ 1 ] = nColorValueExtent[ 2 ] = 0;
     189           0 :     nColorValueExtent[ 3 ] = nColorValueExtent[ 4 ] = nColorValueExtent[ 5 ] = 255;
     190             : 
     191           0 :     nAspectSourceFlags = 0;     // all flags are individual
     192             : 
     193           0 :     eLineWidthSpecMode = SM_SCALED;         // line parameter
     194           0 :     eLineCapType = LCT_NONE;
     195           0 :     eLineJoinType = LJT_NONE;
     196           0 :     pLineBundle = &aLineBundle;                 // line bundle parameter
     197           0 :     aLineBundle.SetIndex( 1 );
     198           0 :     aLineBundle.eLineType = LT_SOLID;
     199           0 :     aLineBundle.nLineWidth = 1;
     200           0 :     aLineBundle.SetColor( 0xffffff );
     201           0 :     InsertBundle( aLineList, aLineBundle );
     202             : 
     203           0 :     eMarkerSizeSpecMode = SM_SCALED;            // marker parameter
     204           0 :     pMarkerBundle = &aMarkerBundle;             // marker bundle parameter
     205           0 :     aMarkerBundle.SetIndex( 1 );
     206           0 :     aMarkerBundle.eMarkerType = MT_STAR;
     207           0 :     aMarkerBundle.nMarkerSize = 1;
     208           0 :     aMarkerBundle.SetColor( 0xffffff );
     209           0 :     InsertBundle( aMarkerList, aMarkerBundle );
     210             : 
     211           0 :     eEdgeVisibility = EV_OFF;                   // edge parameter
     212           0 :     eEdgeWidthSpecMode = SM_SCALED;
     213           0 :     pEdgeBundle = &aEdgeBundle;                 // edge bundle parameter
     214           0 :     aEdgeBundle.SetIndex( 1 );
     215           0 :     aEdgeBundle.eEdgeType = ET_SOLID;
     216           0 :     aEdgeBundle.nEdgeWidth = 1;
     217           0 :     aEdgeBundle.SetColor( 0xffffff );
     218           0 :     InsertBundle( aEdgeList, aEdgeBundle );
     219             : 
     220           0 :     nCharacterHeight = 327;                     // text parameter
     221           0 :     nCharacterOrientation[0] = 0;
     222           0 :     nCharacterOrientation[1] = 1;
     223           0 :     nCharacterOrientation[2] = 1;
     224           0 :     nCharacterOrientation[3] = 0;
     225           0 :     eUnderlineMode = UM_OFF;
     226           0 :     nUnderlineColor = 0xffffff;
     227           0 :     eTextPath = TPR_RIGHT;
     228           0 :     eTextAlignmentH = TAH_NORMAL;
     229           0 :     eTextAlignmentV = TAV_NORMAL;
     230           0 :     nCharacterSetIndex = nAlternateCharacterSetIndex = 1;
     231           0 :     eCharacterCodingA = CCA_BASIC_7;
     232           0 :     pTextBundle = &aTextBundle;                 // text bundle parameter
     233           0 :     aTextBundle.SetIndex( 1 );
     234           0 :     aTextBundle.nTextFontIndex = 1;
     235           0 :     aTextBundle.eTextPrecision = TPR_STRING;
     236           0 :     aTextBundle.nCharacterExpansion = 1;
     237           0 :     aTextBundle.nCharacterSpacing = 0;
     238           0 :     aTextBundle.SetColor( 0xffffff );
     239           0 :     InsertBundle( aTextList, aTextBundle );
     240             : 
     241           0 :     pFillBundle = &aFillBundle;                 // fill bundle parameter
     242           0 :     aFillBundle.SetIndex( 1 );
     243           0 :     aFillBundle.eFillInteriorStyle = FIS_HOLLOW;
     244           0 :     aFillBundle.nFillHatchIndex = 1;
     245           0 :     aFillBundle.nFillPatternIndex = 1;
     246           0 :     aFillBundle.SetColor( 0xffffff );
     247           0 :     InsertBundle( aFillList, aFillBundle );
     248             : 
     249           0 :     ImplInsertHatch( 0, 0, 0, 0 );
     250           0 :     ImplInsertHatch( 1, 0, 125, 0 );
     251           0 :     ImplInsertHatch( 2, 0, 125, 900 );
     252           0 :     ImplInsertHatch( 3, 0, 125, 450 );
     253           0 :     ImplInsertHatch( 4, 0, 125, 1350 );
     254           0 :     ImplInsertHatch( 5, 1, 125, 0 );
     255           0 :     ImplInsertHatch( 6, 1, 125, 450 );
     256           0 :     ImplInsertHatch( -1, 0, 75, 0 );
     257           0 :     ImplInsertHatch( -2, 0, 75, 900 );
     258           0 :     ImplInsertHatch( -3, 0, 75, 450 );
     259           0 :     ImplInsertHatch( -4, 0, 75, 1350 );
     260           0 :     ImplInsertHatch( -5, 1, 75, 0 );
     261           0 :     ImplInsertHatch( -6, 1, 75, 450 );
     262           0 :     ImplInsertHatch( -7, 2, 125, 0 );
     263           0 :     ImplInsertHatch( -8, 2, 125, 900 );
     264           0 :     ImplInsertHatch( -9, 2, 125, 450 );
     265           0 :     ImplInsertHatch( -10, 2, 125, 1350 );
     266           0 :     ImplInsertHatch( -11, 0, 40, 0 );
     267           0 :     ImplInsertHatch( -12, 0, 40, 900 );
     268           0 :     ImplInsertHatch( -13, 0, 40, 450 );
     269           0 :     ImplInsertHatch( -14, 0, 40, 1350 );
     270           0 :     ImplInsertHatch( -15, 1, 40, 0 );
     271           0 :     ImplInsertHatch( -16, 1, 40, 900 );
     272           0 :     ImplInsertHatch( -21, 0, 250, 0 );
     273           0 :     ImplInsertHatch( -22, 0, 250, 900 );
     274           0 :     ImplInsertHatch( -23, 0, 250, 450 );
     275           0 :     ImplInsertHatch( -24, 0, 250, 1350 );
     276           0 :     ImplInsertHatch( -25, 1, 250, 0 );
     277           0 :     ImplInsertHatch( -26, 1, 250, 450 );
     278             : 
     279           0 :     eTransparency = T_ON;
     280             : 
     281           0 :     nBackGroundColor = nAuxiliaryColor = 0;
     282             : 
     283           0 :     bSegmentCount = sal_False;
     284           0 : }
     285             : 
     286             : // ---------------------------------------------------------------
     287             : 
     288           0 : void CGMElements::ImplInsertHatch( sal_Int32 nKey, int nStyle, long nDistance, long nAngle )
     289             : {
     290           0 :     HatchEntry& rEntry = maHatchMap[nKey];
     291           0 :     rEntry.HatchStyle = nStyle;
     292           0 :     rEntry.HatchDistance = nDistance;
     293           0 :     rEntry.HatchAngle = nAngle;
     294           0 : }
     295             : 
     296             : // ---------------------------------------------------------------
     297             : 
     298           0 : void CGMElements::DeleteAllBundles( BundleList& rList )
     299             : {
     300           0 :     for ( size_t i = 0, n = rList.size(); i < n; ++i ) {
     301           0 :         delete rList[ i ];
     302             :     }
     303           0 :     rList.clear();
     304           0 : };
     305             : 
     306             : 
     307             : // ---------------------------------------------------------------
     308             : 
     309           0 : void CGMElements::CopyAllBundles( BundleList& rSource, BundleList& rDest )
     310             : {
     311           0 :     DeleteAllBundles( rDest );
     312             : 
     313           0 :     for ( size_t i = 0, n = rSource.size(); i < n; ++i )
     314             :     {
     315           0 :         Bundle* pPtr = rSource[ i ];
     316           0 :         Bundle* pTempBundle = pPtr->Clone();
     317           0 :         rDest.push_back( pTempBundle );
     318             :     }
     319           0 : };
     320             : 
     321             : // ---------------------------------------------------------------
     322             : 
     323           0 : Bundle* CGMElements::GetBundleIndex( long nIndex, BundleList& rList, Bundle& rBundle )
     324             : {
     325           0 :     rBundle.SetIndex( nIndex );
     326           0 :     Bundle* pBundle = GetBundle( rList, nIndex );
     327           0 :     if ( !pBundle )
     328           0 :         pBundle = InsertBundle( rList, rBundle );
     329           0 :     return pBundle;
     330             : }
     331             : 
     332             : // ---------------------------------------------------------------
     333             : 
     334           0 : Bundle* CGMElements::GetBundle( BundleList& rList, long nIndex )
     335             : {
     336           0 :     for ( size_t i = 0, n = rList.size(); i < n; ++i ) {
     337           0 :         if ( rList[ i ]->GetIndex() == nIndex ) {
     338           0 :             return rList[ i ];
     339             :         }
     340             :     }
     341           0 :     return NULL;
     342             : }
     343             : 
     344             : // ---------------------------------------------------------------
     345             : 
     346           0 : Bundle* CGMElements::InsertBundle( BundleList& rList, Bundle& rBundle )
     347             : {
     348           0 :     Bundle* pBundle = GetBundle( rList, rBundle.GetIndex() );
     349           0 :     if ( pBundle )
     350             :     {
     351           0 :         for ( BundleList::iterator it = rList.begin(); it != rList.end(); ++it ) {
     352           0 :             if ( *it == pBundle ) {
     353           0 :                 rList.erase( it );
     354           0 :                 delete pBundle;
     355           0 :                 break;
     356             :             }
     357             :         }
     358             :     }
     359           0 :     pBundle = rBundle.Clone();
     360           0 :     rList.push_back( pBundle );
     361           0 :     return pBundle;
     362             : };
     363             : 
     364             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10