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

Generated by: LCOV version 1.10