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

Generated by: LCOV version 1.10