LCOV - code coverage report
Current view: top level - oox/source/drawingml - theme.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 43 43 100.0 %
Date: 2014-04-11 Functions: 12 12 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 "oox/drawingml/theme.hxx"
      21             : 
      22             : namespace oox {
      23             : namespace drawingml {
      24             : 
      25             : 
      26             : 
      27        1157 : Theme::Theme()
      28             : {
      29        1157 : }
      30             : 
      31        1157 : Theme::~Theme()
      32             : {
      33        1157 : }
      34             : 
      35             : namespace {
      36             : 
      37             : template< typename Type >
      38        3727 : const Type* lclGetStyleElement( const RefVector< Type >& rVector, sal_Int32 nIndex )
      39             : {
      40       13292 :     return (rVector.empty() || (nIndex < 1)) ? 0 :
      41       17019 :         rVector.get( ::std::min( static_cast< sal_Int32 >( nIndex - 1 ), static_cast< sal_Int32 >( rVector.size() - 1 ) ) ).get();
      42             : }
      43             : 
      44             : } // namespace
      45             : 
      46        1231 : const FillProperties* Theme::getFillStyle( sal_Int32 nIndex ) const
      47             : {
      48             :     return (nIndex >= 1000) ?
      49          21 :         lclGetStyleElement( maBgFillStyleList, nIndex - 1000 ) :
      50        1252 :         lclGetStyleElement( maFillStyleList, nIndex );
      51             : }
      52             : 
      53        1837 : const LineProperties* Theme::getLineStyle( sal_Int32 nIndex ) const
      54             : {
      55        1837 :      return lclGetStyleElement( maLineStyleList, nIndex );
      56             : }
      57             : 
      58         659 : const EffectProperties* Theme::getEffectStyle( sal_Int32 nIndex ) const
      59             : {
      60         659 :     return lclGetStyleElement( maEffectStyleList, nIndex );
      61             : }
      62             : 
      63         836 : const TextCharacterProperties* Theme::getFontStyle( sal_Int32 nSchemeType ) const
      64             : {
      65         836 :     return maFontScheme.get( nSchemeType ).get();
      66             : }
      67             : 
      68        8111 : const TextFont* Theme::resolveFont( const OUString& rName ) const
      69             : {
      70        8111 :     const TextCharacterProperties* pCharProps = 0;
      71             :     /*  Resolves the following names:
      72             :         +mj-lt, +mj-ea, +mj-cs  --  major Latin, Asian, Complex font
      73             :         +mn-lt, +mn-ea, +mn-cs  --  minor Latin, Asian, Complex font
      74             :      */
      75        8111 :     if( (rName.getLength() == 6) && (rName[ 0 ] == '+') && (rName[ 3 ] == '-') )
      76             :     {
      77        1455 :         if( (rName[ 1 ] == 'm') && (rName[ 2 ] == 'j') )
      78         123 :             pCharProps = maFontScheme.get( XML_major ).get();
      79        1332 :         else if( (rName[ 1 ] == 'm') && (rName[ 2 ] == 'n') )
      80        1332 :             pCharProps = maFontScheme.get( XML_minor ).get();
      81        1455 :         if( pCharProps )
      82             :         {
      83        1455 :             if( (rName[ 4 ] == 'l') && (rName[ 5 ] == 't') )
      84         363 :                 return &pCharProps->maLatinFont;
      85        1092 :             if( (rName[ 4 ] == 'e') && (rName[ 5 ] == 'a') )
      86         589 :                 return &pCharProps->maAsianFont;
      87         503 :             if( (rName[ 4 ] == 'c') && (rName[ 5 ] == 's') )
      88         503 :                 return &pCharProps->maComplexFont;
      89             :         }
      90             :     }
      91             : 
      92             :     // See writerfilter::dmapper::ThemeTable::getFontNameForTheme().
      93        6656 :     if (rName == "majorHAnsi" || rName == "majorAscii" || rName == "majorBidi" || rName == "majorEastAsia")
      94          16 :         pCharProps = maFontScheme.get(XML_major).get();
      95        6640 :     else if (rName == "minorHAnsi" || rName == "minorAscii" || rName == "minorBidi" || rName == "minorEastAsia")
      96           2 :         pCharProps = maFontScheme.get(XML_minor).get();
      97        6656 :     if (pCharProps)
      98             :     {
      99          18 :         if (rName == "majorAscii" || rName == "majorHAnsi" || rName == "minorAscii" || rName == "minorHAnsi")
     100           7 :             return &pCharProps->maLatinFont;
     101          11 :         else if (rName == "minorBidi" || rName == "majorBidi")
     102           6 :             return &pCharProps->maComplexFont;
     103           5 :         else if (rName == "minorEastAsia" || rName == "majorEastAsia")
     104           5 :             return &pCharProps->maAsianFont;
     105             :     }
     106        6638 :     return 0;
     107             : }
     108             : 
     109             : 
     110             : 
     111             : } // namespace drawingml
     112         177 : } // namespace oox
     113             : 
     114             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10