LCOV - code coverage report
Current view: top level - filter/source/graphicfilter/icgm - bundles.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 49 139 35.3 %
Date: 2015-06-13 12:38:46 Functions: 10 17 58.8 %
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 "bundles.hxx"
      22             : 
      23             : #include <tools/stream.hxx>
      24             : #include <boost/scoped_array.hpp>
      25             : 
      26           0 : Bundle& Bundle::operator=( Bundle& rSource )
      27             : {
      28           0 :     mnColor = rSource.mnColor;
      29           0 :     mnBundleIndex = rSource.mnBundleIndex;
      30           0 :     return *this;
      31             : };
      32             : 
      33             : 
      34             : 
      35          20 : void Bundle::SetColor( sal_uInt32 nColor )
      36             : {
      37          20 :     mnColor = nColor;
      38          20 : }
      39             : 
      40             : 
      41             : 
      42             : 
      43          28 : LineBundle& LineBundle::operator=( LineBundle& rSource )
      44             : {
      45          28 :     SetIndex( rSource.GetIndex() );
      46          28 :     eLineType = rSource.eLineType;
      47          28 :     nLineWidth = rSource.nLineWidth;
      48          28 :     return *this;
      49             : };
      50             : 
      51          28 : MarkerBundle& MarkerBundle::operator=( MarkerBundle& rSource )
      52             : {
      53          28 :     SetIndex( rSource.GetIndex() );
      54          28 :     eMarkerType = rSource.eMarkerType;
      55          28 :     nMarkerSize = rSource.nMarkerSize;
      56          28 :     return *this;
      57             : };
      58             : 
      59          28 : EdgeBundle& EdgeBundle::operator=( EdgeBundle& rSource )
      60             : {
      61          28 :     SetIndex( rSource.GetIndex() );
      62          28 :     eEdgeType = rSource.eEdgeType;
      63          28 :     nEdgeWidth = rSource.nEdgeWidth;
      64          28 :     return *this;
      65             : };
      66             : 
      67          28 : TextBundle& TextBundle::operator=( TextBundle& rSource )
      68             : {
      69          28 :     SetIndex( rSource.GetIndex() );
      70          28 :     nTextFontIndex = rSource.nTextFontIndex;
      71          28 :     eTextPrecision = rSource.eTextPrecision;
      72          28 :     nCharacterExpansion = rSource.nCharacterExpansion;
      73          28 :     nCharacterSpacing = rSource.nCharacterSpacing;
      74          28 :     return *this;
      75             : };
      76             : 
      77          28 : FillBundle& FillBundle::operator=( FillBundle& rSource )
      78             : {
      79          28 :     SetIndex( rSource.GetIndex() );
      80          28 :     eFillInteriorStyle = rSource.eFillInteriorStyle;
      81          28 :     nFillPatternIndex = rSource.nFillPatternIndex;
      82          28 :     nFillHatchIndex = rSource.nFillHatchIndex;
      83          28 :     return *this;
      84             : };
      85             : 
      86           0 : FontEntry::FontEntry() :
      87             :     pFontName       ( NULL ),
      88             :     eCharSetType    ( CST_CCOMPLETE ),
      89             :     pCharSetValue   ( NULL ),
      90           0 :     nFontType       ( 0 )
      91             : {
      92           0 : }
      93             : 
      94           0 : FontEntry::~FontEntry()
      95             : {
      96           0 :     delete [] pFontName;
      97           0 :     delete[] pCharSetValue;
      98           0 : }
      99             : 
     100           4 : CGMFList::CGMFList() :
     101             :     nFontNameCount      ( 0 ),
     102             :     nCharSetCount       ( 0 ),
     103           4 :     nFontsAvailable     ( 0 )
     104             : {
     105           4 :     aFontEntryList.clear();
     106           4 : }
     107             : 
     108           8 : CGMFList::~CGMFList()
     109             : {
     110           4 :     ImplDeleteList();
     111           4 : }
     112             : 
     113             : 
     114             : 
     115          28 : CGMFList& CGMFList::operator=( CGMFList& rSource )
     116             : {
     117          28 :     ImplDeleteList();
     118          28 :     nFontsAvailable = rSource.nFontsAvailable;
     119          28 :     nFontNameCount  = rSource.nFontNameCount;
     120          28 :     nCharSetCount   = rSource.nCharSetCount;
     121          28 :     for ( size_t i = 0, n = rSource.aFontEntryList.size(); i < n; ++i )
     122             :     {
     123           0 :         FontEntry* pPtr = rSource.aFontEntryList[ i ];
     124           0 :         FontEntry* pCFontEntry = new FontEntry;
     125           0 :         if ( pPtr->pFontName )
     126             :         {
     127           0 :             sal_uInt32 nSize = strlen( reinterpret_cast<char*>(pPtr->pFontName) ) + 1;
     128           0 :             pCFontEntry->pFontName = new sal_Int8[ nSize ];
     129           0 :             memcpy( pCFontEntry->pFontName, pPtr->pFontName, nSize );
     130             :         }
     131           0 :         if ( pPtr->pCharSetValue )
     132             :         {
     133           0 :             sal_uInt32 nSize = strlen( reinterpret_cast<char*>(pPtr->pCharSetValue) ) + 1;
     134           0 :             pCFontEntry->pCharSetValue = new sal_Int8[ nSize ];
     135           0 :             memcpy( pCFontEntry->pCharSetValue, pPtr->pCharSetValue, nSize );
     136             :         }
     137           0 :         pCFontEntry->eCharSetType = pPtr->eCharSetType;
     138           0 :         pCFontEntry->nFontType = pPtr->nFontType;
     139           0 :         aFontEntryList.push_back( pCFontEntry );
     140             :     }
     141          28 :     return *this;
     142             : }
     143             : 
     144             : 
     145             : 
     146           0 : FontEntry* CGMFList::GetFontEntry( sal_uInt32 nIndex )
     147             : {
     148           0 :     sal_uInt32 nInd = nIndex;
     149           0 :     if ( nInd )
     150           0 :         nInd--;
     151           0 :     return ( nInd < aFontEntryList.size() ) ? aFontEntryList[ nInd ] : NULL;
     152             : }
     153             : 
     154             : 
     155             : 
     156           0 : static sal_Int8* ImplSearchEntry( sal_Int8* pSource, sal_Int8 const * pDest, sal_uInt32 nComp, sal_uInt32 nSize )
     157             : {
     158           0 :     while ( nComp-- >= nSize )
     159             :     {
     160             :         sal_uInt32 i;
     161           0 :         for ( i = 0; i < nSize; i++ )
     162             :         {
     163           0 :             if ( ( pSource[i]&~0x20 ) != ( pDest[i]&~0x20 ) )
     164           0 :                 break;
     165             :         }
     166           0 :         if ( i == nSize )
     167           0 :             return pSource;
     168           0 :         pSource++;
     169             :     }
     170           0 :     return NULL;
     171             : }
     172             : 
     173           0 : void CGMFList::InsertName( sal_uInt8* pSource, sal_uInt32 nSize )
     174             : {
     175             :     FontEntry* pFontEntry;
     176           0 :     if ( nFontsAvailable == nFontNameCount )
     177             :     {
     178           0 :         nFontsAvailable++;
     179           0 :         pFontEntry = new FontEntry;
     180           0 :         aFontEntryList.push_back( pFontEntry );
     181             :     }
     182             :     else
     183             :     {
     184           0 :         pFontEntry = aFontEntryList[ nFontNameCount ];
     185             :     }
     186           0 :     nFontNameCount++;
     187           0 :     boost::scoped_array<sal_Int8> pBuf(new sal_Int8[ nSize ]);
     188           0 :     memcpy( pBuf.get(), pSource, nSize );
     189           0 :     sal_Int8* pFound = ImplSearchEntry( pBuf.get(), reinterpret_cast<sal_Int8 const *>("ITALIC"), nSize, 6 );
     190           0 :     if ( pFound )
     191             :     {
     192           0 :         pFontEntry->nFontType |= 1;
     193           0 :         sal_uInt32 nPrev = ( pFound - pBuf.get() );
     194           0 :         sal_uInt32 nToCopyOfs = 6;
     195           0 :         if ( nPrev && ( pFound[ -1 ] == '-' || pFound[ -1 ] == ' ' ) )
     196             :         {
     197           0 :             nPrev--;
     198           0 :             pFound--;
     199           0 :             nToCopyOfs++;
     200             :         }
     201           0 :         sal_uInt32 nToCopy = nSize - nToCopyOfs - nPrev;
     202           0 :         if ( nToCopy )
     203             :         {
     204           0 :             memmove( pFound, pFound + nToCopyOfs, nToCopy );
     205             :         }
     206           0 :         nSize -= nToCopyOfs;
     207             :     }
     208           0 :     pFound = ImplSearchEntry( pBuf.get(), reinterpret_cast<sal_Int8 const *>("BOLD"), nSize, 4 );
     209           0 :     if ( pFound )
     210             :     {
     211           0 :         pFontEntry->nFontType |= 2;
     212             : 
     213           0 :         sal_uInt32 nPrev = ( pFound - pBuf.get() );
     214           0 :         sal_uInt32 nToCopyOfs = 4;
     215           0 :         if ( nPrev && ( pFound[ -1 ] == '-' || pFound[ -1 ] == ' ' ) )
     216             :         {
     217           0 :             nPrev--;
     218           0 :             pFound--;
     219           0 :             nToCopyOfs++;
     220             :         }
     221           0 :         sal_uInt32 nToCopy = nSize - nToCopyOfs - nPrev;
     222           0 :         if ( nToCopy )
     223             :         {
     224           0 :             memmove( pFound, pFound + nToCopyOfs, nToCopy );
     225             :         }
     226           0 :         nSize -= nToCopyOfs;
     227             :     }
     228           0 :     pFontEntry->pFontName = new sal_Int8[ nSize + 1 ];
     229           0 :     pFontEntry->pFontName[ nSize ] = 0;
     230           0 :     memcpy( pFontEntry->pFontName, pBuf.get(), nSize );
     231           0 : }
     232             : 
     233             : 
     234             : 
     235           0 : void CGMFList::InsertCharSet( CharSetType eCharSetType, sal_uInt8* pSource, sal_uInt32 nSize )
     236             : {
     237             :     FontEntry* pFontEntry;
     238           0 :     if ( nFontsAvailable == nCharSetCount )
     239             :     {
     240           0 :         nFontsAvailable++;
     241           0 :         pFontEntry = new FontEntry;
     242           0 :         aFontEntryList.push_back( pFontEntry );
     243             :     }
     244             :     else
     245             :     {
     246           0 :         pFontEntry = aFontEntryList[ nCharSetCount ];
     247             :     }
     248           0 :     nCharSetCount++;
     249           0 :     pFontEntry->eCharSetType = eCharSetType;
     250           0 :     pFontEntry->pCharSetValue = new sal_Int8[ nSize + 1 ];
     251           0 :     pFontEntry->pCharSetValue[ nSize ] = 0;
     252           0 :     memcpy( pFontEntry->pCharSetValue, pSource , nSize );
     253           0 : }
     254             : 
     255             : 
     256             : 
     257          32 : void CGMFList::ImplDeleteList()
     258             : {
     259          32 :     for ( size_t i = 0, n = aFontEntryList.size(); i < n; ++i )
     260           0 :         delete aFontEntryList[ i ];
     261          32 :     aFontEntryList.clear();
     262          32 : }
     263             : 
     264             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11