LCOV - code coverage report
Current view: top level - xmloff/source/style - XMLConstantsPropertyHandler.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 22 24 91.7 %
Date: 2012-08-25 Functions: 5 5 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 13 24 54.2 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include <xmloff/xmluconv.hxx>
      30                 :            : #include <rtl/ustrbuf.hxx>
      31                 :            : #include <com/sun/star/uno/Any.hxx>
      32                 :            : #include <xmloff/XMLConstantsPropertyHandler.hxx>
      33                 :            : 
      34                 :            : using namespace ::com::sun::star::uno;
      35                 :            : using ::rtl::OUString;
      36                 :            : using ::rtl::OUStringBuffer;
      37                 :            : 
      38                 :            : using ::xmloff::token::XMLTokenEnum;
      39                 :            : 
      40                 :      20735 : XMLConstantsPropertyHandler::XMLConstantsPropertyHandler(
      41                 :            :     const SvXMLEnumMapEntry *pM,
      42                 :            :     enum XMLTokenEnum eDflt ) :
      43                 :            :         pMap( pM ),
      44                 :      20735 :         eDefault( eDflt )
      45                 :            : {
      46                 :      20735 : }
      47                 :            : 
      48                 :      20685 : XMLConstantsPropertyHandler::~XMLConstantsPropertyHandler()
      49                 :            : {
      50         [ -  + ]:      40636 : }
      51                 :            : 
      52                 :        829 : sal_Bool XMLConstantsPropertyHandler::importXML(
      53                 :            :     const OUString& rStrImpValue,
      54                 :            :     Any& rValue,
      55                 :            :     const SvXMLUnitConverter& ) const
      56                 :            : {
      57                 :            :     sal_uInt16 nEnum;
      58                 :            :     sal_Bool bRet = SvXMLUnitConverter::convertEnum(
      59         [ +  - ]:        829 :         nEnum, rStrImpValue, pMap );
      60                 :            : 
      61         [ +  + ]:        829 :     if( bRet )
      62         [ +  - ]:        795 :         rValue <<= (sal_Int16)nEnum;
      63                 :            : 
      64                 :        829 :     return bRet;
      65                 :            : }
      66                 :            : 
      67                 :        129 : sal_Bool XMLConstantsPropertyHandler::exportXML(
      68                 :            :     OUString& rStrExpValue,
      69                 :            :     const Any& rValue,
      70                 :            :     const SvXMLUnitConverter& ) const
      71                 :            : {
      72                 :        129 :     OUStringBuffer aOut;
      73                 :            : 
      74                 :        129 :     sal_Bool bRet = false;
      75                 :            : 
      76                 :        129 :     sal_Int32 nEnum = 0;
      77                 :            : 
      78 [ -  + ][ -  + ]:        129 :     if( rValue.hasValue() && (rValue.getValueTypeClass() == TypeClass_ENUM))
                 [ +  - ]
      79                 :            :     {
      80                 :          0 :         nEnum = *((sal_Int32*)rValue.getValue());
      81                 :          0 :         bRet = true;
      82                 :            :     }
      83                 :            :     else
      84                 :            :     {
      85                 :        129 :         bRet = (rValue >>= nEnum );
      86                 :            :     }
      87                 :            : 
      88         [ +  - ]:        129 :     if( bRet )
      89                 :            :     {
      90 [ +  - ][ +  - ]:        129 :         if( (nEnum >= 0) && (nEnum <= 0xffff) )
      91                 :            :         {
      92                 :        129 :             sal_uInt16 nConst = static_cast<sal_uInt16>( nEnum );
      93                 :            : 
      94                 :            :             bRet = SvXMLUnitConverter::convertEnum(
      95         [ +  - ]:        129 :                 aOut, nConst, pMap, eDefault );
      96                 :            : 
      97         [ +  - ]:        129 :             rStrExpValue = aOut.makeStringAndClear();
      98                 :            :         }
      99                 :            :         else
     100                 :            :         {
     101                 :            :             OSL_FAIL("XMLConstantsPropertyHandler::exportXML() constant is out of range for implementation using sal_uInt16");
     102                 :            :         }
     103                 :            :     }
     104                 :            :     else
     105                 :            :     {
     106                 :            :         OSL_FAIL("XMLConstantsPropertyHandler::exportXML() could not convert any to sal_Int32");
     107                 :            :     }
     108                 :            : 
     109                 :        129 :     return bRet;
     110                 :            : }
     111                 :            : 
     112                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10