LCOV - code coverage report
Current view: top level - xmloff/source/style - EnumPropertyHdl.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 21 27 77.8 %
Date: 2015-06-13 12:38:46 Functions: 4 4 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 <xmloff/EnumPropertyHdl.hxx>
      21             : #include <xmloff/xmluconv.hxx>
      22             : #include <comphelper/extract.hxx>
      23             : #include <rtl/ustring.hxx>
      24             : #include <rtl/ustrbuf.hxx>
      25             : #include <osl/diagnose.h>
      26             : #include <com/sun/star/uno/Any.hxx>
      27             : 
      28             : using namespace ::com::sun::star::uno;
      29             : 
      30             : 
      31             : // class XMLEnumPropertyHdl
      32             : 
      33             : 
      34      287766 : XMLEnumPropertyHdl::~XMLEnumPropertyHdl()
      35             : {
      36             :     // Nothing to do
      37      287766 : }
      38             : 
      39        5644 : bool XMLEnumPropertyHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
      40             : {
      41        5644 :     sal_uInt16 nValue = 0;
      42             : 
      43        5644 :     if( SvXMLUnitConverter::convertEnum( nValue, rStrImpValue, mpEnumMap ) )
      44             :     {
      45        5535 :         switch( mrType.getTypeClass() )
      46             :         {
      47             :         case TypeClass_ENUM:
      48        5246 :             rValue = ::cppu::int2enum( nValue, mrType );
      49        5246 :             break;
      50             :         case TypeClass_LONG:
      51         289 :             rValue <<= (sal_Int32) nValue;
      52         289 :             break;
      53             :         case TypeClass_SHORT:
      54           0 :             rValue <<= (sal_Int16) nValue;
      55           0 :             break;
      56             :         case TypeClass_BYTE:
      57           0 :             rValue <<= (sal_Int8) nValue;
      58           0 :             break;
      59             :         default:
      60             :             OSL_FAIL( "Wrong type for enum property handler!" );
      61           0 :             return false;
      62             :         }
      63        5535 :         return true;
      64             :     }
      65             : 
      66         109 :     return false;
      67             : }
      68             : 
      69        4956 : bool XMLEnumPropertyHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
      70             : {
      71        4956 :     sal_Int32 nValue = 0;
      72        4956 :     if(!(rValue >>= nValue ))
      73        3618 :         if(!::cppu::enum2int(nValue, rValue) )
      74          11 :             return false;
      75             : 
      76        4945 :     OUStringBuffer aOut;
      77             : 
      78        4945 :     if(!SvXMLUnitConverter::convertEnum( aOut, nValue, mpEnumMap ))
      79           0 :         return false;
      80             : 
      81        4945 :     rStrExpValue = aOut.makeStringAndClear();
      82        4945 :     return true;
      83             : }
      84             : 
      85             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11