LCOV - code coverage report
Current view: top level - xmloff/source/style - lspachdl.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 72 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 <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           0 : XMLLineHeightHdl::~XMLLineHeightHdl()
      38             : {
      39             :     // nothing to do
      40           0 : }
      41             : 
      42           0 : bool XMLLineHeightHdl::importXML( const OUString& rStrImpValue, uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const
      43             : {
      44           0 :     style::LineSpacing aLSp;
      45           0 :     sal_Int32 nTemp = 0;
      46             : 
      47           0 :     if( -1 != rStrImpValue.indexOf( '%' ) )
      48             :     {
      49           0 :         aLSp.Mode = style::LineSpacingMode::PROP;
      50           0 :         if (!::sax::Converter::convertPercent( nTemp, rStrImpValue ))
      51           0 :             return false;
      52           0 :         aLSp.Height = sal::static_int_cast< sal_Int16 >(nTemp);
      53             :     }
      54           0 :     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           0 :         aLSp.Mode = style::LineSpacingMode::FIX;
      62           0 :         if (!rUnitConverter.convertMeasureToCore(
      63           0 :                     nTemp, rStrImpValue, 0x0000, 0xffff))
      64           0 :             return false;
      65           0 :         aLSp.Height = sal::static_int_cast< sal_Int16 >(nTemp);
      66             :     }
      67             : 
      68           0 :     rValue <<= aLSp;
      69           0 :     return true;
      70             : }
      71             : 
      72           0 : bool XMLLineHeightHdl::exportXML( OUString& rStrExpValue, const uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const
      73             : {
      74           0 :     OUStringBuffer aOut;
      75             : 
      76           0 :     style::LineSpacing aLSp;
      77           0 :     if(!(rValue >>= aLSp))
      78           0 :         return false;
      79             : 
      80           0 :     if( style::LineSpacingMode::PROP != aLSp.Mode && style::LineSpacingMode::FIX  != aLSp.Mode )
      81           0 :         return false;
      82             : 
      83           0 :     if( style::LineSpacingMode::PROP == aLSp.Mode )
      84             :     {
      85           0 :         ::sax::Converter::convertPercent( aOut, aLSp.Height );
      86             :     }
      87             :     else
      88             :     {
      89           0 :         rUnitConverter.convertMeasureToXML( aOut, aLSp.Height );
      90             :     }
      91             : 
      92           0 :     rStrExpValue = aOut.makeStringAndClear();
      93           0 :     return !rStrExpValue.isEmpty();
      94             : }
      95             : 
      96             : 
      97             : // class XMLLineHeightAtLeastHdl
      98             : 
      99             : 
     100           0 : XMLLineHeightAtLeastHdl::~XMLLineHeightAtLeastHdl()
     101             : {
     102             :     // nothing to do
     103           0 : }
     104             : 
     105           0 : bool XMLLineHeightAtLeastHdl::importXML( const OUString& rStrImpValue, uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const
     106             : {
     107           0 :     style::LineSpacing aLSp;
     108             : 
     109             :     sal_Int32 nTemp;
     110           0 :     aLSp.Mode = style::LineSpacingMode::MINIMUM;
     111           0 :     if (!rUnitConverter.convertMeasureToCore( nTemp, rStrImpValue, 0, 0xffff))
     112           0 :         return false;
     113           0 :     aLSp.Height = sal::static_int_cast< sal_Int16 >(nTemp);
     114             : 
     115           0 :     rValue <<= aLSp;
     116           0 :     return true;
     117             : }
     118             : 
     119           0 : bool XMLLineHeightAtLeastHdl::exportXML( OUString& rStrExpValue, const uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const
     120             : {
     121           0 :     OUStringBuffer aOut;
     122             : 
     123           0 :     style::LineSpacing aLSp;
     124           0 :     if(!(rValue >>= aLSp))
     125           0 :         return false;
     126             : 
     127           0 :     if( style::LineSpacingMode::MINIMUM != aLSp.Mode )
     128           0 :         return false;
     129             : 
     130           0 :     rUnitConverter.convertMeasureToXML( aOut, aLSp.Height );
     131             : 
     132           0 :     rStrExpValue = aOut.makeStringAndClear();
     133           0 :     return !rStrExpValue.isEmpty();
     134             : }
     135             : 
     136             : 
     137             : // class XMLLineSpacingHdl
     138             : 
     139             : 
     140           0 : XMLLineSpacingHdl::~XMLLineSpacingHdl()
     141             : {
     142             :     // nothing to do
     143           0 : }
     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           0 : bool XMLLineSpacingHdl::exportXML( OUString& rStrExpValue, const uno::Any& rValue, const SvXMLUnitConverter& rUnitConverter ) const
     160             : {
     161           0 :     OUStringBuffer aOut;
     162             : 
     163           0 :     style::LineSpacing aLSp;
     164           0 :     if(!(rValue >>= aLSp))
     165           0 :         return false;
     166             : 
     167           0 :     if( style::LineSpacingMode::LEADING != aLSp.Mode )
     168           0 :         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.10