LCOV - code coverage report
Current view: top level - xmloff/source/style - csmaphdl.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 36 38 94.7 %
Date: 2014-11-03 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       31872 : XMLCaseMapPropHdl::~XMLCaseMapPropHdl()
      42             : {
      43             :     // nothing to do
      44       31872 : }
      45             : 
      46         138 : bool XMLCaseMapPropHdl::importXML( const OUString& rStrImpValue, uno::Any& rValue, const SvXMLUnitConverter& ) const
      47             : {
      48             :     sal_uInt16 nVal;
      49             :     bool bRet = SvXMLUnitConverter::convertEnum(
      50         138 :         nVal, rStrImpValue, pXML_Casemap_Enum );
      51         138 :     if( ( bRet ) )
      52         138 :         rValue <<= nVal;
      53             : 
      54         138 :     return bRet;
      55             : }
      56             : 
      57          58 : bool XMLCaseMapPropHdl::exportXML( OUString& rStrExpValue, const uno::Any& rValue, const SvXMLUnitConverter& ) const
      58             : {
      59          58 :     bool bRet = false;
      60          58 :     sal_uInt16 nValue = sal_uInt16();
      61          58 :     OUStringBuffer aOut;
      62             : 
      63          58 :     if( rValue >>= nValue )
      64             :     {
      65             :         bRet = SvXMLUnitConverter::convertEnum(
      66          58 :             aOut, nValue, pXML_Casemap_Enum );
      67          58 :         if( bRet )
      68          58 :             rStrExpValue = aOut.makeStringAndClear();
      69             :     }
      70             : 
      71          58 :     return bRet;
      72             : }
      73             : 
      74             : // class XMLCaseMapVariantHdl
      75             : 
      76       31872 : XMLCaseMapVariantHdl::~XMLCaseMapVariantHdl()
      77             : {
      78             :     // nothing to do
      79       31872 : }
      80             : 
      81         122 : bool XMLCaseMapVariantHdl::importXML( const OUString& rStrImpValue, uno::Any& rValue, const SvXMLUnitConverter& ) const
      82             : {
      83         122 :     bool bRet = false;
      84             : 
      85         122 :     if( IsXMLToken( rStrImpValue, XML_CASEMAP_SMALL_CAPS ) )
      86             :     {
      87          16 :         rValue <<= (sal_Int16)style::CaseMap::SMALLCAPS;
      88          16 :         bRet = true;
      89             :     }
      90         106 :     else if( IsXMLToken( rStrImpValue, XML_CASEMAP_NORMAL ) )
      91             :     {
      92         106 :         rValue <<= (sal_Int16)style::CaseMap::NONE;
      93         106 :         bRet = true;
      94             :     }
      95             : 
      96         122 :     return bRet;
      97             : }
      98             : 
      99          58 : bool XMLCaseMapVariantHdl::exportXML( OUString& rStrExpValue, const uno::Any& rValue, const SvXMLUnitConverter& ) const
     100             : {
     101          58 :     sal_uInt16 nValue = sal_uInt16();
     102          58 :     OUStringBuffer aOut;
     103             : 
     104          58 :     if( rValue >>= nValue )
     105             :     {
     106          58 :         switch( nValue )
     107             :         {
     108             :         case style::CaseMap::NONE:
     109          58 :             aOut.append( GetXMLToken(XML_CASEMAP_NORMAL) );
     110          58 :             break;
     111             :         case style::CaseMap::SMALLCAPS:
     112           0 :             aOut.append( GetXMLToken(XML_CASEMAP_SMALL_CAPS) );
     113           0 :             break;
     114             :         }
     115             :     }
     116             : 
     117          58 :     rStrExpValue = aOut.makeStringAndClear();
     118          58 :     return !rStrExpValue.isEmpty();
     119             : }
     120             : 
     121             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10