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

Generated by: LCOV version 1.10