LCOV - code coverage report
Current view: top level - oox/source/drawingml - textfont.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 28 28 100.0 %
Date: 2012-08-25 Functions: 9 9 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 12 18 66.7 %

           Branch data     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/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 ::rtl::OUString;
      28                 :            : using ::oox::core::XmlFilterBase;
      29                 :            : 
      30                 :            : namespace oox {
      31                 :            : namespace drawingml {
      32                 :            : 
      33                 :            : // ============================================================================
      34                 :            : 
      35                 :            : namespace {
      36                 :            : 
      37                 :        777 : sal_Int16 lclGetFontPitch( sal_Int32 nOoxValue )
      38                 :            : {
      39                 :            :     using namespace ::com::sun::star::awt::FontPitch;
      40                 :            :     static const sal_Int16 spnFontPitch[] = { DONTKNOW, FIXED, VARIABLE };
      41         [ +  - ]:        777 :     return STATIC_ARRAY_SELECT( spnFontPitch, nOoxValue, DONTKNOW );
      42                 :            : }
      43                 :            : 
      44                 :        777 : sal_Int16 lclGetFontFamily( sal_Int32 nOoxValue )
      45                 :            : {
      46                 :            :     using namespace ::com::sun::star::awt::FontFamily;
      47                 :            :     static const sal_Int16 spnFontFamily[] = { DONTKNOW, ROMAN, SWISS, MODERN, SCRIPT, DECORATIVE };
      48         [ +  - ]:        777 :     return STATIC_ARRAY_SELECT( spnFontFamily, nOoxValue, DONTKNOW );
      49                 :            : }
      50                 :            : 
      51                 :            : } // namespace
      52                 :            : 
      53                 :            : // ============================================================================
      54                 :            : 
      55                 :      80379 : TextFont::TextFont() :
      56                 :            :     mnPitch( 0 ),
      57                 :      80379 :     mnCharset( WINDOWS_CHARSET_ANSI )
      58                 :            : {
      59                 :      80379 : }
      60                 :            : 
      61                 :        693 : void TextFont::setAttributes( const AttributeList& rAttribs )
      62                 :            : {
      63         [ +  - ]:        693 :     maTypeface = rAttribs.getString( XML_typeface, OUString() );
      64         [ +  - ]:        693 :     maPanose   = rAttribs.getString( XML_panose, OUString() );
      65                 :        693 :     mnPitch    = rAttribs.getInteger( XML_pitchFamily, 0 );
      66                 :        693 :     mnCharset  = rAttribs.getInteger( XML_charset, WINDOWS_CHARSET_DEFAULT );
      67                 :        693 : }
      68                 :            : 
      69                 :      21150 : void TextFont::assignIfUsed( const TextFont& rTextFont )
      70                 :            : {
      71         [ +  + ]:      21150 :     if( !rTextFont.maTypeface.isEmpty() )
      72                 :       1494 :         *this = rTextFont;
      73                 :      21150 : }
      74                 :            : 
      75                 :        777 : bool TextFont::getFontData( OUString& rFontName, sal_Int16& rnFontPitch, sal_Int16& rnFontFamily, const XmlFilterBase& rFilter ) const
      76                 :            : {
      77         [ +  + ]:        777 :     if( const Theme* pTheme = rFilter.getCurrentTheme() )
      78         [ +  + ]:        759 :         if( const TextFont* pFont = pTheme->resolveFont( maTypeface ) )
      79                 :        405 :             return pFont->implGetFontData( rFontName, rnFontPitch, rnFontFamily );
      80                 :        777 :     return implGetFontData( rFontName, rnFontPitch, rnFontFamily );
      81                 :            : }
      82                 :            : 
      83                 :        777 : bool TextFont::implGetFontData( OUString& rFontName, sal_Int16& rnFontPitch, sal_Int16& rnFontFamily ) const
      84                 :            : {
      85                 :        777 :     rFontName = maTypeface;
      86                 :        777 :     rnFontPitch = lclGetFontPitch( extractValue< sal_Int16 >( mnPitch, 0, 4 ) );
      87                 :        777 :     rnFontFamily = lclGetFontFamily( extractValue< sal_Int16 >( mnPitch, 4, 4 ) );
      88                 :        777 :     return !rFontName.isEmpty();
      89                 :            : }
      90                 :            : 
      91                 :            : // ============================================================================
      92                 :            : 
      93                 :            : } // namespace drawingml
      94 [ +  - ][ +  - ]:        285 : } // namespace oox
      95                 :            : 
      96                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10