LCOV - code coverage report
Current view: top level - oox/source/drawingml - textfont.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 34 34 100.0 %
Date: 2015-06-13 12:38:46 Functions: 10 10 100.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 "drawingml/textfont.hxx"
      21             : #include <com/sun/star/awt/FontFamily.hpp>
      22             : #include <com/sun/star/awt/FontPitch.hpp>
      23             : #include "oox/drawingml/theme.hxx"
      24             : #include "oox/core/xmlfilterbase.hxx"
      25             : #include "oox/helper/attributelist.hxx"
      26             : 
      27             : using ::oox::core::XmlFilterBase;
      28             : 
      29             : namespace oox {
      30             : namespace drawingml {
      31             : 
      32             : namespace {
      33             : 
      34       24185 : sal_Int16 lclGetFontPitch( sal_Int32 nOoxValue )
      35             : {
      36             :     using namespace ::com::sun::star::awt::FontPitch;
      37             :     static const sal_Int16 spnFontPitch[] = { DONTKNOW, FIXED, VARIABLE };
      38       24185 :     return STATIC_ARRAY_SELECT( spnFontPitch, nOoxValue, DONTKNOW );
      39             : }
      40             : 
      41       24185 : sal_Int16 lclGetFontFamily( sal_Int32 nOoxValue )
      42             : {
      43             :     using namespace ::com::sun::star::awt::FontFamily;
      44             :     static const sal_Int16 spnFontFamily[] = { DONTKNOW, ROMAN, SWISS, MODERN, SCRIPT, DECORATIVE };
      45       24185 :     return STATIC_ARRAY_SELECT( spnFontFamily, nOoxValue, DONTKNOW );
      46             : }
      47             : 
      48             : } // namespace
      49             : 
      50     2860528 : TextFont::TextFont() :
      51             :     mnPitch( 0 ),
      52     2860528 :     mnCharset( WINDOWS_CHARSET_ANSI )
      53             : {
      54     2860528 : }
      55             : 
      56       16618 : void TextFont::setAttributes( const AttributeList& rAttribs )
      57             : {
      58       16618 :     maTypeface = rAttribs.getString( XML_typeface, OUString() );
      59       16618 :     maPanose   = rAttribs.getString( XML_panose, OUString() );
      60       16618 :     mnPitch    = rAttribs.getInteger( XML_pitchFamily, 0 );
      61       16618 :     mnCharset  = rAttribs.getInteger( XML_charset, WINDOWS_CHARSET_DEFAULT );
      62       16618 : }
      63             : 
      64         114 : void TextFont::setAttributes( const OUString& sFontName )
      65             : {
      66         114 :     maTypeface = sFontName;
      67         114 :     maPanose.clear();
      68         114 :     mnPitch = 0;
      69         114 :     mnCharset = WINDOWS_CHARSET_DEFAULT;
      70         114 : }
      71             : 
      72      625456 : void TextFont::assignIfUsed( const TextFont& rTextFont )
      73             : {
      74      625456 :     if( !rTextFont.maTypeface.isEmpty() )
      75       33337 :         *this = rTextFont;
      76      625456 : }
      77             : 
      78       24185 : bool TextFont::getFontData( OUString& rFontName, sal_Int16& rnFontPitch, sal_Int16& rnFontFamily, const XmlFilterBase& rFilter ) const
      79             : {
      80       24185 :     if( const Theme* pTheme = rFilter.getCurrentTheme() )
      81       24048 :         if( const TextFont* pFont = pTheme->resolveFont( maTypeface ) )
      82        5893 :             return pFont->implGetFontData( rFontName, rnFontPitch, rnFontFamily );
      83       18292 :     return implGetFontData( rFontName, rnFontPitch, rnFontFamily );
      84             : }
      85             : 
      86       24185 : bool TextFont::implGetFontData( OUString& rFontName, sal_Int16& rnFontPitch, sal_Int16& rnFontFamily ) const
      87             : {
      88       24185 :     rFontName = maTypeface;
      89       24185 :     rnFontPitch = lclGetFontPitch( extractValue< sal_Int16 >( mnPitch, 0, 4 ) );
      90       24185 :     rnFontFamily = lclGetFontFamily( extractValue< sal_Int16 >( mnPitch, 4, 4 ) );
      91       24185 :     return !rFontName.isEmpty();
      92             : }
      93             : 
      94             : } // namespace drawingml
      95         246 : } // namespace oox
      96             : 
      97             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11