LCOV - code coverage report
Current view: top level - xmloff/source/style - csmaphdl.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 10 38 26.3 %
Date: 2012-08-25 Functions: 5 8 62.5 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 4 41 9.8 %

           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 <csmaphdl.hxx>
      30                 :            : #include <xmloff/xmltoken.hxx>
      31                 :            : #include <xmloff/xmluconv.hxx>
      32                 :            : #include <rtl/ustrbuf.hxx>
      33                 :            : #include <com/sun/star/style/CaseMap.hpp>
      34                 :            : #include <com/sun/star/uno/Any.hxx>
      35                 :            : 
      36                 :            : using ::rtl::OUString;
      37                 :            : using ::rtl::OUStringBuffer;
      38                 :            : 
      39                 :            : using namespace ::com::sun::star;
      40                 :            : using namespace ::xmloff::token;
      41                 :            : 
      42                 :            : static SvXMLEnumMapEntry pXML_Casemap_Enum[] =
      43                 :            : {
      44                 :            :     { XML_NONE,                 style::CaseMap::NONE },
      45                 :            :     { XML_CASEMAP_LOWERCASE,    style::CaseMap::LOWERCASE },
      46                 :            :     { XML_CASEMAP_UPPERCASE,    style::CaseMap::UPPERCASE },
      47                 :            :     { XML_CASEMAP_CAPITALIZE,   style::CaseMap::TITLE },
      48                 :            :     { XML_TOKEN_INVALID,        0 }
      49                 :            : };
      50                 :            : 
      51                 :            : ///////////////////////////////////////////////////////////////////////////////
      52                 :            : //
      53                 :            : // class XMLPosturePropHdl
      54                 :            : //
      55                 :            : 
      56                 :       2285 : XMLCaseMapPropHdl::~XMLCaseMapPropHdl()
      57                 :            : {
      58                 :            :     // nothing to do
      59         [ -  + ]:       4570 : }
      60                 :            : 
      61                 :          0 : sal_Bool XMLCaseMapPropHdl::importXML( const OUString& rStrImpValue, uno::Any& rValue, const SvXMLUnitConverter& ) const
      62                 :            : {
      63                 :            :     sal_uInt16 nVal;
      64                 :            :     sal_Bool bRet = SvXMLUnitConverter::convertEnum(
      65         [ #  # ]:          0 :         nVal, rStrImpValue, pXML_Casemap_Enum );
      66         [ #  # ]:          0 :     if( ( bRet ) )
      67         [ #  # ]:          0 :         rValue <<= nVal;
      68                 :            : 
      69                 :          0 :     return bRet;
      70                 :            : }
      71                 :            : 
      72                 :          0 : sal_Bool XMLCaseMapPropHdl::exportXML( OUString& rStrExpValue, const uno::Any& rValue, const SvXMLUnitConverter& ) const
      73                 :            : {
      74                 :          0 :     sal_Bool bRet = sal_False;
      75                 :          0 :     sal_uInt16 nValue = sal_uInt16();
      76                 :          0 :     OUStringBuffer aOut;
      77                 :            : 
      78         [ #  # ]:          0 :     if( rValue >>= nValue )
      79                 :            :     {
      80                 :            :         bRet = SvXMLUnitConverter::convertEnum(
      81         [ #  # ]:          0 :             aOut, nValue, pXML_Casemap_Enum );
      82         [ #  # ]:          0 :         if( bRet )
      83         [ #  # ]:          0 :             rStrExpValue = aOut.makeStringAndClear();
      84                 :            :     }
      85                 :            : 
      86                 :          0 :     return bRet;
      87                 :            : }
      88                 :            : 
      89                 :            : ///////////////////////////////////////////////////////////////////////////////
      90                 :            : //
      91                 :            : // class XMLCaseMapVariantHdl
      92                 :            : //
      93                 :            : 
      94                 :       2285 : XMLCaseMapVariantHdl::~XMLCaseMapVariantHdl()
      95                 :            : {
      96                 :            :     // nothing to do
      97         [ -  + ]:       4570 : }
      98                 :            : 
      99                 :          2 : sal_Bool XMLCaseMapVariantHdl::importXML( const OUString& rStrImpValue, uno::Any& rValue, const SvXMLUnitConverter& ) const
     100                 :            : {
     101                 :          2 :     sal_Bool bRet = sal_False;
     102                 :            : 
     103         [ +  - ]:          2 :     if( IsXMLToken( rStrImpValue, XML_CASEMAP_SMALL_CAPS ) )
     104                 :            :     {
     105         [ +  - ]:          2 :         rValue <<= (sal_Int16)style::CaseMap::SMALLCAPS;
     106                 :          2 :         bRet = sal_True;
     107                 :            :     }
     108         [ #  # ]:          0 :     else if( IsXMLToken( rStrImpValue, XML_CASEMAP_NORMAL ) )
     109                 :            :     {
     110         [ #  # ]:          0 :         rValue <<= (sal_Int16)style::CaseMap::NONE;
     111                 :          0 :         bRet = sal_True;
     112                 :            :     }
     113                 :            : 
     114                 :          2 :     return bRet;
     115                 :            : }
     116                 :            : 
     117                 :          0 : sal_Bool XMLCaseMapVariantHdl::exportXML( OUString& rStrExpValue, const uno::Any& rValue, const SvXMLUnitConverter& ) const
     118                 :            : {
     119                 :          0 :     sal_uInt16 nValue = sal_uInt16();
     120                 :          0 :     OUStringBuffer aOut;
     121                 :            : 
     122         [ #  # ]:          0 :     if( rValue >>= nValue )
     123                 :            :     {
     124      [ #  #  # ]:          0 :         switch( nValue )
     125                 :            :         {
     126                 :            :         case style::CaseMap::NONE:
     127 [ #  # ][ #  # ]:          0 :             aOut.append( GetXMLToken(XML_CASEMAP_NORMAL) );
     128                 :          0 :             break;
     129                 :            :         case style::CaseMap::SMALLCAPS:
     130 [ #  # ][ #  # ]:          0 :             aOut.append( GetXMLToken(XML_CASEMAP_SMALL_CAPS) );
     131                 :          0 :             break;
     132                 :            :         }
     133                 :            :     }
     134                 :            : 
     135         [ #  # ]:          0 :     rStrExpValue = aOut.makeStringAndClear();
     136                 :          0 :     return !rStrExpValue.isEmpty();
     137                 :            : }
     138                 :            : 
     139                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10