LCOV - code coverage report
Current view: top level - oox/source/drawingml - colorchoicecontext.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 30 35 85.7 %
Date: 2014-04-11 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 "oox/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             : 
      36             : 
      37       30806 : ColorValueContext::ColorValueContext( ContextHandler2Helper& rParent, Color& rColor ) :
      38             :     ContextHandler2( rParent ),
      39       30806 :     mrColor( rColor )
      40             : {
      41       30806 : }
      42             : 
      43       30806 : void ColorValueContext::onStartElement( const AttributeList& rAttribs )
      44             : {
      45       30806 :     switch( getCurrentElement() )
      46             :     {
      47             :         case A_TOKEN( scrgbClr ):
      48             :             mrColor.setScrgbClr(
      49             :                 rAttribs.getInteger( XML_r, 0 ),
      50             :                 rAttribs.getInteger( XML_g, 0 ),
      51         819 :                 rAttribs.getInteger( XML_b, 0 ) );
      52         819 :         break;
      53             : 
      54             :         case A_TOKEN( srgbClr ):
      55       12511 :             mrColor.setSrgbClr( rAttribs.getIntegerHex( XML_val, 0 ) );
      56       12511 :         break;
      57             : 
      58             :         case A_TOKEN( hslClr ):
      59             :             mrColor.setHslClr(
      60             :                 rAttribs.getInteger( XML_hue, 0 ),
      61             :                 rAttribs.getInteger( XML_sat, 0 ),
      62           0 :                 rAttribs.getInteger( XML_lum, 0 ) );
      63           0 :         break;
      64             : 
      65             :         case A_TOKEN( sysClr ):
      66             :             mrColor.setSysClr(
      67             :                 rAttribs.getToken( XML_val, XML_TOKEN_INVALID ),
      68        1860 :                 rAttribs.getIntegerHex( XML_lastClr, -1 ) );
      69        1860 :         break;
      70             : 
      71             :         case A_TOKEN( schemeClr ):
      72             :         {
      73       15605 :             mrColor.setSchemeClr( rAttribs.getToken( XML_val, XML_TOKEN_INVALID ) );
      74       15605 :             oox::OptValue<rtl::OUString> sSchemeName = rAttribs.getString( XML_val );
      75       15605 :             if( sSchemeName.has() )
      76       15605 :                 mrColor.setSchemeName( sSchemeName.use() );
      77             :         }
      78       15605 :         break;
      79             : 
      80             :         case A_TOKEN( prstClr ):
      81          11 :             mrColor.setPrstClr( rAttribs.getToken( XML_val, XML_TOKEN_INVALID ) );
      82          11 :         break;
      83             :     }
      84       30806 : }
      85             : 
      86       26541 : ::oox::core::ContextHandlerRef ColorValueContext::onCreateContext(
      87             :         sal_Int32 nElement, const AttributeList& rAttribs )
      88             : {
      89       26541 :     switch( nElement )
      90             :     {
      91             :         case A_TOKEN( alpha ):
      92             :         case A_TOKEN( alphaMod ):
      93             :         case A_TOKEN( alphaOff ):
      94             :         case A_TOKEN( blue ):
      95             :         case A_TOKEN( blueMod ):
      96             :         case A_TOKEN( blueOff ):
      97             :         case A_TOKEN( hue ):
      98             :         case A_TOKEN( hueMod ):
      99             :         case A_TOKEN( hueOff ):
     100             :         case A_TOKEN( lum ):
     101             :         case A_TOKEN( lumMod ):
     102             :         case A_TOKEN( lumOff ):
     103             :         case A_TOKEN( green ):
     104             :         case A_TOKEN( greenMod ):
     105             :         case A_TOKEN( greenOff ):
     106             :         case A_TOKEN( red ):
     107             :         case A_TOKEN( redMod ):
     108             :         case A_TOKEN( redOff ):
     109             :         case A_TOKEN( sat ):
     110             :         case A_TOKEN( satMod ):
     111             :         case A_TOKEN( satOff ):
     112             :         case A_TOKEN( shade ):
     113             :         case A_TOKEN( tint ):
     114       26541 :             mrColor.addTransformation( nElement, rAttribs.getInteger( XML_val, 0 ) );
     115       26541 :         break;
     116             :         case A_TOKEN( comp ):
     117             :         case A_TOKEN( gamma ):
     118             :         case A_TOKEN( gray ):
     119             :         case A_TOKEN( inv ):
     120             :         case A_TOKEN( invGamma ):
     121           0 :             mrColor.addTransformation( nElement );
     122           0 :         break;
     123             :     }
     124       26541 :     return 0;
     125             : }
     126             : 
     127             : 
     128             : 
     129       31621 : ColorContext::ColorContext( ContextHandler2Helper& rParent, Color& rColor ) :
     130             :     ContextHandler2( rParent ),
     131       31621 :     mrColor( rColor )
     132             : {
     133       31621 : }
     134             : 
     135       30788 : ::oox::core::ContextHandlerRef ColorContext::onCreateContext(
     136             :         sal_Int32 nElement, const AttributeList& )
     137             : {
     138       30788 :     switch( nElement )
     139             :     {
     140             :         case A_TOKEN( scrgbClr ):
     141             :         case A_TOKEN( srgbClr ):
     142             :         case A_TOKEN( hslClr ):
     143             :         case A_TOKEN( sysClr ):
     144             :         case A_TOKEN( schemeClr ):
     145             :         case A_TOKEN( prstClr ):
     146       30788 :             return new ColorValueContext( *this, mrColor );
     147             :     }
     148           0 :     return 0;
     149             : }
     150             : 
     151             : 
     152             : 
     153             : } // namespace drawingml
     154             : } // namespace oox
     155             : 
     156             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10