LCOV - code coverage report
Current view: top level - oox/source/drawingml - colorchoicecontext.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 35 40 87.5 %
Date: 2015-06-13 12:38:46 Functions: 5 5 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/drawingmltypes.hxx"
      21             : #include "drawingml/colorchoicecontext.hxx"
      22             : #include "oox/helper/attributelist.hxx"
      23             : #include "oox/drawingml/color.hxx"
      24             : 
      25             : using ::com::sun::star::uno::Reference;
      26             : using ::com::sun::star::uno::RuntimeException;
      27             : using ::com::sun::star::xml::sax::SAXException;
      28             : using ::com::sun::star::xml::sax::XFastAttributeList;
      29             : using ::com::sun::star::xml::sax::XFastContextHandler;
      30             : using ::oox::core::ContextHandler;
      31             : 
      32             : namespace oox {
      33             : namespace drawingml {
      34             : 
      35       61292 : ColorValueContext::ColorValueContext( ContextHandler2Helper& rParent, Color& rColor ) :
      36             :     ContextHandler2( rParent ),
      37       61292 :     mrColor( rColor )
      38             : {
      39       61292 : }
      40             : 
      41       61292 : void ColorValueContext::onStartElement( const AttributeList& rAttribs )
      42             : {
      43       61292 :     switch( getCurrentElement() )
      44             :     {
      45             :         case A_TOKEN( scrgbClr ):
      46             :             mrColor.setScrgbClr(
      47             :                 rAttribs.getInteger( XML_r, 0 ),
      48             :                 rAttribs.getInteger( XML_g, 0 ),
      49        1033 :                 rAttribs.getInteger( XML_b, 0 ) );
      50        1033 :         break;
      51             : 
      52             :         case A_TOKEN( srgbClr ):
      53       21496 :             mrColor.setSrgbClr( rAttribs.getIntegerHex( XML_val, 0 ) );
      54       21496 :         break;
      55             : 
      56             :         case A_TOKEN( hslClr ):
      57             :             mrColor.setHslClr(
      58             :                 rAttribs.getInteger( XML_hue, 0 ),
      59             :                 rAttribs.getInteger( XML_sat, 0 ),
      60           0 :                 rAttribs.getInteger( XML_lum, 0 ) );
      61           0 :         break;
      62             : 
      63             :         case A_TOKEN( sysClr ):
      64             :             mrColor.setSysClr(
      65             :                 rAttribs.getToken( XML_val, XML_TOKEN_INVALID ),
      66        3026 :                 rAttribs.getIntegerHex( XML_lastClr, -1 ) );
      67        3026 :         break;
      68             : 
      69             :         case A_TOKEN( schemeClr ):
      70             :         {
      71       35639 :             mrColor.setSchemeClr( rAttribs.getToken( XML_val, XML_TOKEN_INVALID ) );
      72       35639 :             oox::OptValue<rtl::OUString> sSchemeName = rAttribs.getString( XML_val );
      73       35639 :             if( sSchemeName.has() )
      74       35639 :                 mrColor.setSchemeName( sSchemeName.use() );
      75             :         }
      76       35639 :         break;
      77             : 
      78             :         case A_TOKEN( prstClr ):
      79          98 :             mrColor.setPrstClr( rAttribs.getToken( XML_val, XML_TOKEN_INVALID ) );
      80          98 :         break;
      81             :     }
      82       61292 : }
      83             : 
      84       47015 : ::oox::core::ContextHandlerRef ColorValueContext::onCreateContext(
      85             :         sal_Int32 nElement, const AttributeList& rAttribs )
      86             : {
      87       47015 :     switch( nElement )
      88             :     {
      89             :         case A_TOKEN( alpha ):
      90             :         case A_TOKEN( alphaMod ):
      91             :         case A_TOKEN( alphaOff ):
      92             :         case A_TOKEN( blue ):
      93             :         case A_TOKEN( blueMod ):
      94             :         case A_TOKEN( blueOff ):
      95             :         case A_TOKEN( hue ):
      96             :         case A_TOKEN( hueMod ):
      97             :         case A_TOKEN( hueOff ):
      98             :         case A_TOKEN( lum ):
      99             :         case A_TOKEN( lumMod ):
     100             :         case A_TOKEN( lumOff ):
     101             :         case A_TOKEN( green ):
     102             :         case A_TOKEN( greenMod ):
     103             :         case A_TOKEN( greenOff ):
     104             :         case A_TOKEN( red ):
     105             :         case A_TOKEN( redMod ):
     106             :         case A_TOKEN( redOff ):
     107             :         case A_TOKEN( sat ):
     108             :         case A_TOKEN( satMod ):
     109             :         case A_TOKEN( satOff ):
     110             :         case A_TOKEN( shade ):
     111             :         case A_TOKEN( tint ):
     112             :         {
     113       47015 :             OUString aValue = rAttribs.getString( XML_val, OUString() );
     114       47015 :             sal_Int32 nVal = 0;
     115       47015 :             if (aValue.endsWith("%"))
     116             :             {
     117         381 :                 nVal = aValue.toDouble() * PER_PERCENT;
     118             :             }
     119             :             else
     120       46634 :                 nVal = rAttribs.getInteger(XML_val, 0);
     121       47015 :             mrColor.addTransformation( nElement, nVal );
     122             :         }
     123       47015 :         break;
     124             :         case A_TOKEN( comp ):
     125             :         case A_TOKEN( gamma ):
     126             :         case A_TOKEN( gray ):
     127             :         case A_TOKEN( inv ):
     128             :         case A_TOKEN( invGamma ):
     129           0 :             mrColor.addTransformation( nElement );
     130           0 :         break;
     131             :     }
     132       47015 :     return 0;
     133             : }
     134             : 
     135       69896 : ColorContext::ColorContext( ContextHandler2Helper& rParent, Color& rColor ) :
     136             :     ContextHandler2( rParent ),
     137       69896 :     mrColor( rColor )
     138             : {
     139       69896 : }
     140             : 
     141       61191 : ::oox::core::ContextHandlerRef ColorContext::onCreateContext(
     142             :         sal_Int32 nElement, const AttributeList& )
     143             : {
     144       61191 :     switch( nElement )
     145             :     {
     146             :         case A_TOKEN( scrgbClr ):
     147             :         case A_TOKEN( srgbClr ):
     148             :         case A_TOKEN( hslClr ):
     149             :         case A_TOKEN( sysClr ):
     150             :         case A_TOKEN( schemeClr ):
     151             :         case A_TOKEN( prstClr ):
     152       61191 :             return new ColorValueContext( *this, mrColor );
     153             :     }
     154           0 :     return 0;
     155             : }
     156             : 
     157             : } // namespace drawingml
     158             : } // namespace oox
     159             : 
     160             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11