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

Generated by: LCOV version 1.11