LCOV - code coverage report
Current view: top level - xmloff/source/style - lspachdl.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 53 72 73.6 %
Date: 2015-06-13 12:38:46 Functions: 11 12 91.7 %
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 <lspachdl.hxx>
      21             : #include <xmloff/xmltoken.hxx>
      22             : #include <xmloff/xmluconv.hxx>
      23             : #include <sax/tools/converter.hxx>
      24             : #include <rtl/ustrbuf.hxx>
      25             : #include <com/sun/star/uno/Any.hxx>
      26             : #include <com/sun/star/style/LineSpacing.hpp>
      27             : #include <com/sun/star/style/LineSpacingMode.hpp>
      28             : 
      29             : using namespace ::com::sun::star;
      30             : using ::xmloff::token::IsXMLToken;
      31             : using ::xmloff::token::XML_CASEMAP_NORMAL;
      32             : 
      33             : 
      34             : // class XMLEscapementPropHdl
      35             : 
      36             : 
      37       15130 : XMLLineHeightHdl::~XMLLineHeightHdl()
      38             : {
      39             :     // nothing to do
      40       15130 : }
      41             : 
      42         807 : bool XMLLineHeightHdl::importXML( const OUString& rStrImpValue, uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const
      43             : {
      44         807 :     style::LineSpacing aLSp;
      45         807 :     sal_Int32 nTemp = 0;
      46             : 
      47         807 :     if( -1 != rStrImpValue.indexOf( '%' ) )
      48             :     {
      49         693 :         aLSp.Mode = style::LineSpacingMode::PROP;
      50         693 :         if (!::sax::Converter::convertPercent( nTemp, rStrImpValue ))
      51           0 :             return false;
      52         693 :         aLSp.Height = sal::static_int_cast< sal_Int16 >(nTemp);
      53             :     }
      54         114 :     else if( IsXMLToken( rStrImpValue, XML_CASEMAP_NORMAL) )
      55             :     {
      56           0 :         aLSp.Mode = style::LineSpacingMode::PROP;
      57           0 :         aLSp.Height = 100;
      58             :     }
      59             :     else
      60             :     {
      61         114 :         aLSp.Mode = style::LineSpacingMode::FIX;
      62         114 :         if (!rUnitConverter.convertMeasureToCore(
      63         114 :                     nTemp, rStrImpValue, 0x0000, 0xffff))
      64           0 :             return false;
      65         114 :         aLSp.Height = sal::static_int_cast< sal_Int16 >(nTemp);
      66             :     }
      67             : 
      68         807 :     rValue <<= aLSp;
      69         807 :     return true;
      70             : }
      71             : 
      72         171 : bool XMLLineHeightHdl::exportXML( OUString& rStrExpValue, const uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const
      73             : {
      74         171 :     OUStringBuffer aOut;
      75             : 
      76         171 :     style::LineSpacing aLSp;
      77         171 :     if(!(rValue >>= aLSp))
      78           0 :         return false;
      79             : 
      80         171 :     if( style::LineSpacingMode::PROP != aLSp.Mode && style::LineSpacingMode::FIX  != aLSp.Mode )
      81          14 :         return false;
      82             : 
      83         157 :     if( style::LineSpacingMode::PROP == aLSp.Mode )
      84             :     {
      85         122 :         ::sax::Converter::convertPercent( aOut, aLSp.Height );
      86             :     }
      87             :     else
      88             :     {
      89          35 :         rUnitConverter.convertMeasureToXML( aOut, aLSp.Height );
      90             :     }
      91             : 
      92         157 :     rStrExpValue = aOut.makeStringAndClear();
      93         157 :     return !rStrExpValue.isEmpty();
      94             : }
      95             : 
      96             : 
      97             : // class XMLLineHeightAtLeastHdl
      98             : 
      99             : 
     100       15130 : XMLLineHeightAtLeastHdl::~XMLLineHeightAtLeastHdl()
     101             : {
     102             :     // nothing to do
     103       15130 : }
     104             : 
     105          92 : bool XMLLineHeightAtLeastHdl::importXML( const OUString& rStrImpValue, uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const
     106             : {
     107          92 :     style::LineSpacing aLSp;
     108             : 
     109             :     sal_Int32 nTemp;
     110          92 :     aLSp.Mode = style::LineSpacingMode::MINIMUM;
     111          92 :     if (!rUnitConverter.convertMeasureToCore( nTemp, rStrImpValue, 0, 0xffff))
     112           0 :         return false;
     113          92 :     aLSp.Height = sal::static_int_cast< sal_Int16 >(nTemp);
     114             : 
     115          92 :     rValue <<= aLSp;
     116          92 :     return true;
     117             : }
     118             : 
     119         171 : bool XMLLineHeightAtLeastHdl::exportXML( OUString& rStrExpValue, const uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const
     120             : {
     121         171 :     OUStringBuffer aOut;
     122             : 
     123         171 :     style::LineSpacing aLSp;
     124         171 :     if(!(rValue >>= aLSp))
     125           0 :         return false;
     126             : 
     127         171 :     if( style::LineSpacingMode::MINIMUM != aLSp.Mode )
     128         157 :         return false;
     129             : 
     130          14 :     rUnitConverter.convertMeasureToXML( aOut, aLSp.Height );
     131             : 
     132          14 :     rStrExpValue = aOut.makeStringAndClear();
     133          14 :     return !rStrExpValue.isEmpty();
     134             : }
     135             : 
     136             : 
     137             : // class XMLLineSpacingHdl
     138             : 
     139             : 
     140       15130 : XMLLineSpacingHdl::~XMLLineSpacingHdl()
     141             : {
     142             :     // nothing to do
     143       15130 : }
     144             : 
     145           0 : bool XMLLineSpacingHdl::importXML( const OUString& rStrImpValue, uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const
     146             : {
     147           0 :     style::LineSpacing aLSp;
     148             :     sal_Int32 nTemp;
     149             : 
     150           0 :     aLSp.Mode = style::LineSpacingMode::LEADING;
     151           0 :     if (!rUnitConverter.convertMeasureToCore( nTemp, rStrImpValue, 0, 0xffff))
     152           0 :         return false;
     153           0 :     aLSp.Height = sal::static_int_cast< sal_Int16 >(nTemp);
     154             : 
     155           0 :     rValue <<= aLSp;
     156           0 :     return true;
     157             : }
     158             : 
     159         171 : bool XMLLineSpacingHdl::exportXML( OUString& rStrExpValue, const uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const
     160             : {
     161         171 :     OUStringBuffer aOut;
     162             : 
     163         171 :     style::LineSpacing aLSp;
     164         171 :     if(!(rValue >>= aLSp))
     165           0 :         return false;
     166             : 
     167         171 :     if( style::LineSpacingMode::LEADING != aLSp.Mode )
     168         171 :         return false;
     169             : 
     170           0 :     rUnitConverter.convertMeasureToXML( aOut, aLSp.Height );
     171             : 
     172           0 :     rStrExpValue = aOut.makeStringAndClear();
     173           0 :     return !rStrExpValue.isEmpty();
     174             : }
     175             : 
     176             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11