LCOV - code coverage report
Current view: top level - oox/source/drawingml - textfont.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 34 0.0 %
Date: 2014-04-14 Functions: 0 10 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/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             : 
      33             : 
      34             : namespace {
      35             : 
      36           0 : sal_Int16 lclGetFontPitch( sal_Int32 nOoxValue )
      37             : {
      38             :     using namespace ::com::sun::star::awt::FontPitch;
      39             :     static const sal_Int16 spnFontPitch[] = { DONTKNOW, FIXED, VARIABLE };
      40           0 :     return STATIC_ARRAY_SELECT( spnFontPitch, nOoxValue, DONTKNOW );
      41             : }
      42             : 
      43           0 : sal_Int16 lclGetFontFamily( sal_Int32 nOoxValue )
      44             : {
      45             :     using namespace ::com::sun::star::awt::FontFamily;
      46             :     static const sal_Int16 spnFontFamily[] = { DONTKNOW, ROMAN, SWISS, MODERN, SCRIPT, DECORATIVE };
      47           0 :     return STATIC_ARRAY_SELECT( spnFontFamily, nOoxValue, DONTKNOW );
      48             : }
      49             : 
      50             : } // namespace
      51             : 
      52             : 
      53             : 
      54           0 : TextFont::TextFont() :
      55             :     mnPitch( 0 ),
      56           0 :     mnCharset( WINDOWS_CHARSET_ANSI )
      57             : {
      58           0 : }
      59             : 
      60           0 : void TextFont::setAttributes( const AttributeList& rAttribs )
      61             : {
      62           0 :     maTypeface = rAttribs.getString( XML_typeface, OUString() );
      63           0 :     maPanose   = rAttribs.getString( XML_panose, OUString() );
      64           0 :     mnPitch    = rAttribs.getInteger( XML_pitchFamily, 0 );
      65           0 :     mnCharset  = rAttribs.getInteger( XML_charset, WINDOWS_CHARSET_DEFAULT );
      66           0 : }
      67             : 
      68           0 : void TextFont::setAttributes( const OUString& sFontName )
      69             : {
      70           0 :     maTypeface = sFontName;
      71           0 :     maPanose = OUString();
      72           0 :     mnPitch = 0;
      73           0 :     mnCharset = WINDOWS_CHARSET_DEFAULT;
      74           0 : }
      75             : 
      76           0 : void TextFont::assignIfUsed( const TextFont& rTextFont )
      77             : {
      78           0 :     if( !rTextFont.maTypeface.isEmpty() )
      79           0 :         *this = rTextFont;
      80           0 : }
      81             : 
      82           0 : bool TextFont::getFontData( OUString& rFontName, sal_Int16& rnFontPitch, sal_Int16& rnFontFamily, const XmlFilterBase& rFilter ) const
      83             : {
      84           0 :     if( const Theme* pTheme = rFilter.getCurrentTheme() )
      85           0 :         if( const TextFont* pFont = pTheme->resolveFont( maTypeface ) )
      86           0 :             return pFont->implGetFontData( rFontName, rnFontPitch, rnFontFamily );
      87           0 :     return implGetFontData( rFontName, rnFontPitch, rnFontFamily );
      88             : }
      89             : 
      90           0 : bool TextFont::implGetFontData( OUString& rFontName, sal_Int16& rnFontPitch, sal_Int16& rnFontFamily ) const
      91             : {
      92           0 :     rFontName = maTypeface;
      93           0 :     rnFontPitch = lclGetFontPitch( extractValue< sal_Int16 >( mnPitch, 0, 4 ) );
      94           0 :     rnFontFamily = lclGetFontFamily( extractValue< sal_Int16 >( mnPitch, 4, 4 ) );
      95           0 :     return !rFontName.isEmpty();
      96             : }
      97             : 
      98             : 
      99             : 
     100             : } // namespace drawingml
     101           0 : } // namespace oox
     102             : 
     103             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10