LCOV - code coverage report
Current view: top level - xmloff/source/style - csmaphdl.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 36 38 94.7 %
Date: 2014-04-11 Functions: 8 8 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 <csmaphdl.hxx>
      21             : #include <xmloff/xmltoken.hxx>
      22             : #include <xmloff/xmluconv.hxx>
      23             : #include <rtl/ustrbuf.hxx>
      24             : #include <com/sun/star/style/CaseMap.hpp>
      25             : #include <com/sun/star/uno/Any.hxx>
      26             : 
      27             : using namespace ::com::sun::star;
      28             : using namespace ::xmloff::token;
      29             : 
      30             : static SvXMLEnumMapEntry pXML_Casemap_Enum[] =
      31             : {
      32             :     { XML_NONE,                 style::CaseMap::NONE },
      33             :     { XML_CASEMAP_LOWERCASE,    style::CaseMap::LOWERCASE },
      34             :     { XML_CASEMAP_UPPERCASE,    style::CaseMap::UPPERCASE },
      35             :     { XML_CASEMAP_CAPITALIZE,   style::CaseMap::TITLE },
      36             :     { XML_TOKEN_INVALID,        0 }
      37             : };
      38             : 
      39             : // class XMLPosturePropHdl
      40             : 
      41       11262 : XMLCaseMapPropHdl::~XMLCaseMapPropHdl()
      42             : {
      43             :     // nothing to do
      44       11262 : }
      45             : 
      46          51 : bool XMLCaseMapPropHdl::importXML( const OUString& rStrImpValue, uno::Any& rValue, const SvXMLUnitConverter& ) const
      47             : {
      48             :     sal_uInt16 nVal;
      49             :     bool bRet = SvXMLUnitConverter::convertEnum(
      50          51 :         nVal, rStrImpValue, pXML_Casemap_Enum );
      51          51 :     if( ( bRet ) )
      52          51 :         rValue <<= nVal;
      53             : 
      54          51 :     return bRet;
      55             : }
      56             : 
      57          39 : bool XMLCaseMapPropHdl::exportXML( OUString& rStrExpValue, const uno::Any& rValue, const SvXMLUnitConverter& ) const
      58             : {
      59          39 :     bool bRet = false;
      60          39 :     sal_uInt16 nValue = sal_uInt16();
      61          39 :     OUStringBuffer aOut;
      62             : 
      63          39 :     if( rValue >>= nValue )
      64             :     {
      65             :         bRet = SvXMLUnitConverter::convertEnum(
      66          39 :             aOut, nValue, pXML_Casemap_Enum );
      67          39 :         if( bRet )
      68          39 :             rStrExpValue = aOut.makeStringAndClear();
      69             :     }
      70             : 
      71          39 :     return bRet;
      72             : }
      73             : 
      74             : // class XMLCaseMapVariantHdl
      75             : 
      76       11262 : XMLCaseMapVariantHdl::~XMLCaseMapVariantHdl()
      77             : {
      78             :     // nothing to do
      79       11262 : }
      80             : 
      81          46 : bool XMLCaseMapVariantHdl::importXML( const OUString& rStrImpValue, uno::Any& rValue, const SvXMLUnitConverter& ) const
      82             : {
      83          46 :     bool bRet = false;
      84             : 
      85          46 :     if( IsXMLToken( rStrImpValue, XML_CASEMAP_SMALL_CAPS ) )
      86             :     {
      87           7 :         rValue <<= (sal_Int16)style::CaseMap::SMALLCAPS;
      88           7 :         bRet = true;
      89             :     }
      90          39 :     else if( IsXMLToken( rStrImpValue, XML_CASEMAP_NORMAL ) )
      91             :     {
      92          39 :         rValue <<= (sal_Int16)style::CaseMap::NONE;
      93          39 :         bRet = true;
      94             :     }
      95             : 
      96          46 :     return bRet;
      97             : }
      98             : 
      99          39 : bool XMLCaseMapVariantHdl::exportXML( OUString& rStrExpValue, const uno::Any& rValue, const SvXMLUnitConverter& ) const
     100             : {
     101          39 :     sal_uInt16 nValue = sal_uInt16();
     102          39 :     OUStringBuffer aOut;
     103             : 
     104          39 :     if( rValue >>= nValue )
     105             :     {
     106          39 :         switch( nValue )
     107             :         {
     108             :         case style::CaseMap::NONE:
     109          39 :             aOut.append( GetXMLToken(XML_CASEMAP_NORMAL) );
     110          39 :             break;
     111             :         case style::CaseMap::SMALLCAPS:
     112           0 :             aOut.append( GetXMLToken(XML_CASEMAP_SMALL_CAPS) );
     113           0 :             break;
     114             :         }
     115             :     }
     116             : 
     117          39 :     rStrExpValue = aOut.makeStringAndClear();
     118          39 :     return !rStrExpValue.isEmpty();
     119             : }
     120             : 
     121             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10