LCOV - code coverage report
Current view: top level - xmloff/source/style - XMLConstantsPropertyHandler.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 24 24 100.0 %
Date: 2015-06-13 12:38:46 Functions: 5 5 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 <xmloff/xmluconv.hxx>
      21             : #include <rtl/ustrbuf.hxx>
      22             : #include <osl/diagnose.h>
      23             : #include <com/sun/star/uno/Any.hxx>
      24             : #include <xmloff/XMLConstantsPropertyHandler.hxx>
      25             : 
      26             : using namespace ::com::sun::star::uno;
      27             : 
      28             : using ::xmloff::token::XMLTokenEnum;
      29             : 
      30      104134 : XMLConstantsPropertyHandler::XMLConstantsPropertyHandler(
      31             :     const SvXMLEnumMapEntry *pM,
      32             :     enum XMLTokenEnum eDflt ) :
      33             :         pMap( pM ),
      34      104134 :         eDefault( eDflt )
      35             : {
      36      104134 : }
      37             : 
      38      204687 : XMLConstantsPropertyHandler::~XMLConstantsPropertyHandler()
      39             : {
      40      204687 : }
      41             : 
      42        4898 : bool XMLConstantsPropertyHandler::importXML(
      43             :     const OUString& rStrImpValue,
      44             :     Any& rValue,
      45             :     const SvXMLUnitConverter& ) const
      46             : {
      47             :     sal_uInt16 nEnum;
      48             :     bool bRet = SvXMLUnitConverter::convertEnum(
      49        4898 :         nEnum, rStrImpValue, pMap );
      50             : 
      51        4898 :     if( bRet )
      52        4464 :         rValue <<= (sal_Int16)nEnum;
      53             : 
      54        4898 :     return bRet;
      55             : }
      56             : 
      57         904 : bool XMLConstantsPropertyHandler::exportXML(
      58             :     OUString& rStrExpValue,
      59             :     const Any& rValue,
      60             :     const SvXMLUnitConverter& ) const
      61             : {
      62         904 :     OUStringBuffer aOut;
      63             : 
      64         904 :     bool bRet = false;
      65             : 
      66         904 :     sal_Int32 nEnum = 0;
      67             : 
      68         904 :     if( rValue.hasValue() && (rValue.getValueTypeClass() == TypeClass_ENUM))
      69             :     {
      70           3 :         nEnum = *static_cast<sal_Int32 const *>(rValue.getValue());
      71           3 :         bRet = true;
      72             :     }
      73             :     else
      74             :     {
      75         901 :         bRet = (rValue >>= nEnum );
      76             :     }
      77             : 
      78         904 :     if( bRet )
      79             :     {
      80         904 :         if( (nEnum >= 0) && (nEnum <= 0xffff) )
      81             :         {
      82         904 :             sal_uInt16 nConst = static_cast<sal_uInt16>( nEnum );
      83             : 
      84             :             bRet = SvXMLUnitConverter::convertEnum(
      85         904 :                 aOut, nConst, pMap, eDefault );
      86             : 
      87         904 :             rStrExpValue = aOut.makeStringAndClear();
      88             :         }
      89             :         else
      90             :         {
      91             :             OSL_FAIL("XMLConstantsPropertyHandler::exportXML() constant is out of range for implementation using sal_uInt16");
      92             :         }
      93             :     }
      94             :     else
      95             :     {
      96             :         OSL_FAIL("XMLConstantsPropertyHandler::exportXML() could not convert any to sal_Int32");
      97             :     }
      98             : 
      99         904 :     return bRet;
     100             : }
     101             : 
     102             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11