LCOV - code coverage report
Current view: top level - libreoffice/xmloff/source/style - EnumPropertyHdl.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 12 27 44.4 %
Date: 2012-12-27 Functions: 3 4 75.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 <com/sun/star/uno/Any.hxx>
      26             : 
      27             : using ::rtl::OUString;
      28             : using ::rtl::OUStringBuffer;
      29             : 
      30             : using namespace ::com::sun::star::uno;
      31             : 
      32             : ///////////////////////////////////////////////////////////////////////////////
      33             : //
      34             : // class XMLEnumPropertyHdl
      35             : //
      36             : 
      37        7388 : XMLEnumPropertyHdl::~XMLEnumPropertyHdl()
      38             : {
      39             :     // Nothing to do
      40        7388 : }
      41             : 
      42         185 : sal_Bool XMLEnumPropertyHdl::importXML( const OUString& rStrImpValue, Any& rValue, const SvXMLUnitConverter& ) const
      43             : {
      44         185 :     sal_uInt16 nValue = 0;
      45             : 
      46         185 :     if( SvXMLUnitConverter::convertEnum( nValue, rStrImpValue, mpEnumMap ) )
      47             :     {
      48         184 :         switch( mrType.getTypeClass() )
      49             :         {
      50             :         case TypeClass_ENUM:
      51         183 :             rValue = ::cppu::int2enum( nValue, mrType );
      52         183 :             break;
      53             :         case TypeClass_LONG:
      54           1 :             rValue <<= (sal_Int32) nValue;
      55           1 :             break;
      56             :         case TypeClass_SHORT:
      57           0 :             rValue <<= (sal_Int16) nValue;
      58           0 :             break;
      59             :         case TypeClass_BYTE:
      60           0 :             rValue <<= (sal_Int8) nValue;
      61           0 :             break;
      62             :         default:
      63             :             OSL_FAIL( "Wrong type for enum property handler!" );
      64           0 :             return sal_False;
      65             :         }
      66         184 :         return sal_True;
      67             :     }
      68             : 
      69           1 :     return sal_False;
      70             : }
      71             : 
      72           0 : sal_Bool XMLEnumPropertyHdl::exportXML( OUString& rStrExpValue, const Any& rValue, const SvXMLUnitConverter& ) const
      73             : {
      74           0 :     sal_Int32 nValue = 0;
      75           0 :     if(!(rValue >>= nValue ))
      76           0 :         if(!::cppu::enum2int(nValue, rValue) )
      77           0 :             return sal_False;
      78             : 
      79           0 :     OUStringBuffer aOut;
      80             : 
      81           0 :     if(!SvXMLUnitConverter::convertEnum( aOut, nValue, mpEnumMap ))
      82           0 :         return sal_False;
      83             : 
      84           0 :     rStrExpValue = aOut.makeStringAndClear();
      85           0 :     return sal_True;
      86             : }
      87             : 
      88             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10