LCOV - code coverage report
Current view: top level - oox/source/ole - axfontdata.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 55 0.0 %
Date: 2014-04-14 Functions: 0 9 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 "oox/ole/axfontdata.hxx"
      21             : #include "oox/ole/olehelper.hxx"
      22             : #include "oox/ole/axbinaryreader.hxx"
      23             : #include "oox/ole/axbinarywriter.hxx"
      24             : 
      25             : namespace oox {
      26             : namespace ole {
      27             : 
      28             : 
      29             : 
      30           0 : AxFontData::AxFontData() :
      31             :     mnFontEffects( 0 ),
      32             :     mnFontHeight( 160 ),
      33             :     mnFontCharSet( WINDOWS_CHARSET_DEFAULT ),
      34             :     mnHorAlign( AX_FONTDATA_LEFT ),
      35           0 :     mbDblUnderline( false )
      36             : {
      37           0 : }
      38             : 
      39           0 : sal_Int16 AxFontData::getHeightPoints() const
      40             : {
      41             :     /*  MSO uses weird font sizes:
      42             :         1pt->30, 2pt->45, 3pt->60, 4pt->75, 5pt->105, 6pt->120, 7pt->135,
      43             :         8pt->165, 9pt->180, 10pt->195, 11pt->225, ... */
      44           0 :     return getLimitedValue< sal_Int16, sal_Int32 >( (mnFontHeight + 10) / 20, 1, SAL_MAX_INT16 );
      45             : }
      46             : 
      47           0 : void AxFontData::setHeightPoints( sal_Int16 nPoints )
      48             : {
      49           0 :     mnFontHeight = getLimitedValue< sal_Int32, sal_Int32 >( ((nPoints * 4 + 1) / 3) * 15, 30, 4294967 );
      50           0 : }
      51             : 
      52           0 : bool AxFontData::importBinaryModel( BinaryInputStream& rInStrm )
      53             : {
      54           0 :     AxBinaryPropertyReader aReader( rInStrm );
      55           0 :     aReader.readStringProperty( maFontName );
      56           0 :     aReader.readIntProperty< sal_uInt32 >( mnFontEffects );
      57           0 :     aReader.readIntProperty< sal_Int32 >( mnFontHeight );
      58           0 :     aReader.skipIntProperty< sal_Int32 >(); // font offset
      59           0 :     aReader.readIntProperty< sal_uInt8 >( mnFontCharSet );
      60           0 :     aReader.skipIntProperty< sal_uInt8 >(); // font pitch/family
      61           0 :     aReader.readIntProperty< sal_uInt8 >( mnHorAlign );
      62           0 :     aReader.skipIntProperty< sal_uInt16 >(); // font weight
      63           0 :     mbDblUnderline = false;
      64           0 :     return aReader.finalizeImport();
      65             : }
      66             : 
      67           0 : void AxFontData::exportBinaryModel( BinaryOutputStream& rOutStrm )
      68             : {
      69           0 :     AxBinaryPropertyWriter aWriter( rOutStrm );
      70           0 :     aWriter.writeStringProperty( maFontName );
      71           0 :     aWriter.writeIntProperty< sal_uInt32 >( mnFontEffects );
      72           0 :     aWriter.writeIntProperty< sal_Int32 >( mnFontHeight );
      73           0 :     aWriter.skipProperty(); // font offset
      74             :     // TODO make AxFontDataModel::convertFromProperties convert the textencoding
      75           0 :     aWriter.writeIntProperty< sal_uInt8 >( mnFontCharSet );
      76           0 :     aWriter.skipProperty(); // font pitch/family
      77             : 
      78           0 :     aWriter.writeIntProperty< sal_uInt8 >( mnHorAlign );
      79           0 :     aWriter.skipProperty(); // font weight
      80           0 :     aWriter.finalizeExport();
      81           0 : }
      82             : 
      83           0 : bool AxFontData::importStdFont( BinaryInputStream& rInStrm )
      84             : {
      85           0 :     StdFontInfo aFontInfo;
      86           0 :     if( OleHelper::importStdFont( aFontInfo, rInStrm, false ) )
      87             :     {
      88           0 :         maFontName = aFontInfo.maName;
      89           0 :         mnFontEffects = 0;
      90           0 :         setFlag( mnFontEffects, AX_FONTDATA_BOLD,      aFontInfo.mnWeight >= OLE_STDFONT_BOLD );
      91           0 :         setFlag( mnFontEffects, AX_FONTDATA_ITALIC,    getFlag( aFontInfo.mnFlags, OLE_STDFONT_ITALIC ) );
      92           0 :         setFlag( mnFontEffects, AX_FONTDATA_UNDERLINE, getFlag( aFontInfo.mnFlags, OLE_STDFONT_UNDERLINE ) );
      93           0 :         setFlag( mnFontEffects, AX_FONTDATA_STRIKEOUT, getFlag( aFontInfo.mnFlags,OLE_STDFONT_STRIKE ) );
      94           0 :         mbDblUnderline = false;
      95             :         // StdFont stores font height in 1/10,000 of points
      96           0 :         setHeightPoints( getLimitedValue< sal_Int16, sal_Int32 >( aFontInfo.mnHeight / 10000, 0, SAL_MAX_INT16 ) );
      97           0 :         mnFontCharSet = aFontInfo.mnCharSet;
      98           0 :         mnHorAlign = AX_FONTDATA_LEFT;
      99           0 :         return true;
     100             :     }
     101           0 :     return false;
     102             : }
     103             : 
     104           0 : bool AxFontData::importGuidAndFont( BinaryInputStream& rInStrm )
     105             : {
     106           0 :     OUString aGuid = OleHelper::importGuid( rInStrm );
     107           0 :     if( aGuid.equalsAscii( AX_GUID_CFONT ) )
     108           0 :         return importBinaryModel( rInStrm );
     109           0 :     if ( aGuid == OLE_GUID_STDFONT )
     110           0 :         return importStdFont( rInStrm );
     111           0 :     return false;
     112             : }
     113             : 
     114             : 
     115             : 
     116             : } // namespace ole
     117           0 : } // namespace oox
     118             : 
     119             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10