LCOV - code coverage report
Current view: top level - xmloff/source/style - chrhghdl.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 52 0.0 %
Date: 2014-04-14 Functions: 0 12 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 <chrhghdl.hxx>
      21             : 
      22             : #include <rtl/ustrbuf.hxx>
      23             : 
      24             : #include <com/sun/star/uno/Any.hxx>
      25             : 
      26             : #include <sax/tools/converter.hxx>
      27             : 
      28             : #include <xmloff/xmluconv.hxx>
      29             : 
      30             : using namespace ::com::sun::star;
      31             : 
      32             : 
      33             : // class XMLEscapementPropHdl
      34             : 
      35             : 
      36           0 : XMLCharHeightHdl::~XMLCharHeightHdl()
      37             : {
      38             :     // nothing to do
      39           0 : }
      40             : 
      41           0 : bool XMLCharHeightHdl::importXML( const OUString& rStrImpValue, uno::Any& rValue, const SvXMLUnitConverter& ) const
      42             : {
      43           0 :     if( rStrImpValue.indexOf( '%' ) == -1 )
      44             :     {
      45             :         double fSize;
      46             :         sal_Int16 const eSrcUnit = ::sax::Converter::GetUnitFromString(
      47           0 :                 rStrImpValue, util::MeasureUnit::POINT );
      48           0 :         if (::sax::Converter::convertDouble(fSize, rStrImpValue,
      49           0 :                     eSrcUnit, util::MeasureUnit::POINT))
      50             :         {
      51           0 :             fSize = ::std::max<double>(fSize, 1.0); // fdo#49876: 0pt is invalid
      52           0 :             rValue <<= (float)fSize;
      53           0 :             return true;
      54             :         }
      55             :     }
      56             : 
      57           0 :     return false;
      58             : }
      59             : 
      60           0 : bool XMLCharHeightHdl::exportXML( OUString& rStrExpValue, const uno::Any& rValue, const SvXMLUnitConverter& ) const
      61             : {
      62           0 :     OUStringBuffer aOut;
      63             : 
      64           0 :     float fSize = 0;
      65           0 :     if( rValue >>= fSize )
      66             :     {
      67           0 :         fSize = ::std::max<float>(fSize, 1.0f); // fdo#49876: 0pt is invalid
      68             :         ::sax::Converter::convertDouble(aOut, (double)fSize, true,
      69           0 :                 util::MeasureUnit::POINT, util::MeasureUnit::POINT);
      70           0 :         aOut.append( 'p');
      71           0 :         aOut.append( 't');
      72             :     }
      73             : 
      74           0 :     rStrExpValue = aOut.makeStringAndClear();
      75           0 :     return !rStrExpValue.isEmpty();
      76             : }
      77             : 
      78             : 
      79             : // class XMLEscapementHeightPropHdl
      80             : 
      81             : 
      82           0 : XMLCharHeightPropHdl::~XMLCharHeightPropHdl()
      83             : {
      84             :     // nothing to do
      85           0 : }
      86             : 
      87           0 : bool XMLCharHeightPropHdl::importXML( const OUString& rStrImpValue, uno::Any& rValue, const SvXMLUnitConverter& ) const
      88             : {
      89           0 :     if( rStrImpValue.indexOf( '%' ) != -1 )
      90             :     {
      91           0 :         sal_Int32 nPrc = 100;
      92           0 :         if (::sax::Converter::convertPercent( nPrc, rStrImpValue ))
      93             :         {
      94           0 :             rValue <<= (sal_Int16)nPrc;
      95           0 :             return true;
      96             :         }
      97             :     }
      98             : 
      99           0 :     return false;
     100             : }
     101             : 
     102           0 : bool XMLCharHeightPropHdl::exportXML( OUString& rStrExpValue, const uno::Any& rValue, const SvXMLUnitConverter& ) const
     103             : {
     104           0 :     OUStringBuffer aOut( rStrExpValue );
     105             : 
     106           0 :     sal_Int16 nValue = sal_Int16();
     107           0 :     if( rValue >>= nValue )
     108             :     {
     109           0 :         ::sax::Converter::convertPercent( aOut, nValue );
     110             :     }
     111             : 
     112           0 :     rStrExpValue = aOut.makeStringAndClear();
     113           0 :     return !rStrExpValue.isEmpty();
     114             : }
     115             : 
     116             : 
     117             : // class XMLEscapementPropHdl
     118             : 
     119             : 
     120           0 : XMLCharHeightDiffHdl::~XMLCharHeightDiffHdl()
     121             : {
     122             :     // nothing to do
     123           0 : }
     124             : 
     125           0 : bool XMLCharHeightDiffHdl::importXML( const OUString& rStrImpValue, uno::Any& rValue, const SvXMLUnitConverter& ) const
     126             : {
     127           0 :     sal_Int32 nRel = 0;
     128             : 
     129           0 :     if (::sax::Converter::convertMeasure( nRel, rStrImpValue,
     130             :                 util::MeasureUnit::POINT ))
     131             :     {
     132           0 :         rValue <<= (float)nRel;
     133           0 :         return true;
     134             :     }
     135             : 
     136           0 :     return false;
     137             : }
     138             : 
     139           0 : bool XMLCharHeightDiffHdl::exportXML( OUString& rStrExpValue, const uno::Any& rValue, const SvXMLUnitConverter& ) const
     140             : {
     141           0 :     OUStringBuffer aOut;
     142             : 
     143           0 :     float nRel = 0;
     144           0 :     if( (rValue >>= nRel) && (nRel != 0) )
     145             :     {
     146             :         ::sax::Converter::convertMeasure( aOut, static_cast<sal_Int32>(nRel),
     147           0 :                 util::MeasureUnit::POINT, util::MeasureUnit::POINT );
     148           0 :         rStrExpValue = aOut.makeStringAndClear();
     149             :     }
     150             : 
     151           0 :     return !rStrExpValue.isEmpty();
     152             : }
     153             : 
     154             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10