LCOV - code coverage report
Current view: top level - xmloff/source/style - adjushdl.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 30 32 93.8 %
Date: 2015-06-13 12:38:46 Functions: 8 8 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 <adjushdl.hxx>
      21             : #include <xmloff/xmltoken.hxx>
      22             : #include <xmloff/xmluconv.hxx>
      23             : #include <rtl/ustrbuf.hxx>
      24             : #include <com/sun/star/style/ParagraphAdjust.hpp>
      25             : #include <com/sun/star/uno/Any.hxx>
      26             : 
      27             : using namespace ::com::sun::star;
      28             : 
      29             : using namespace ::xmloff::token;
      30             : 
      31             : SvXMLEnumMapEntry const pXML_Para_Adjust_Enum[] =
      32             : {
      33             :     { XML_START,        style::ParagraphAdjust_LEFT },
      34             :     { XML_END,          style::ParagraphAdjust_RIGHT },
      35             :     { XML_CENTER,       style::ParagraphAdjust_CENTER },
      36             :     { XML_JUSTIFY,      style::ParagraphAdjust_BLOCK },
      37             :     { XML_JUSTIFIED,    style::ParagraphAdjust_BLOCK }, // obsolete
      38             :     { XML_LEFT,         style::ParagraphAdjust_LEFT },
      39             :     { XML_RIGHT,        style::ParagraphAdjust_RIGHT },
      40             :     { XML_TOKEN_INVALID, 0 }
      41             : };
      42             : 
      43             : SvXMLEnumMapEntry const pXML_Para_Align_Last_Enum[] =
      44             : {
      45             :     { XML_START,        style::ParagraphAdjust_LEFT },
      46             :     { XML_CENTER,       style::ParagraphAdjust_CENTER },
      47             :     { XML_JUSTIFY,      style::ParagraphAdjust_BLOCK },
      48             :     { XML_JUSTIFIED,    style::ParagraphAdjust_BLOCK }, // obsolete
      49             :     { XML_TOKEN_INVALID, 0 }
      50             : };
      51             : 
      52             : 
      53             : // class XMLParaAdjustPropHdl
      54             : 
      55             : 
      56       15130 : XMLParaAdjustPropHdl::~XMLParaAdjustPropHdl()
      57             : {
      58             :     // nothing to do
      59       15130 : }
      60             : 
      61        1453 : bool XMLParaAdjustPropHdl::importXML( const OUString& rStrImpValue, uno::Any& rValue, const SvXMLUnitConverter& ) const
      62             : {
      63             :     sal_uInt16 eAdjust;
      64        1453 :     bool bRet = SvXMLUnitConverter::convertEnum( eAdjust, rStrImpValue, pXML_Para_Adjust_Enum );
      65        1453 :     if( bRet )
      66        1453 :         rValue <<= (sal_Int16)eAdjust;
      67             : 
      68        1453 :     return bRet;
      69             : }
      70             : 
      71         206 : bool XMLParaAdjustPropHdl::exportXML( OUString& rStrExpValue, const uno::Any& rValue, const SvXMLUnitConverter& ) const
      72             : {
      73         206 :     if(!rValue.hasValue())
      74           0 :         return false;
      75         206 :     OUStringBuffer aOut;
      76         206 :     sal_Int16 nVal = 0;
      77             : 
      78         206 :     rValue >>= nVal;
      79             : 
      80         206 :     bool bRet = SvXMLUnitConverter::convertEnum( aOut, nVal, pXML_Para_Adjust_Enum, XML_START );
      81             : 
      82         206 :     rStrExpValue = aOut.makeStringAndClear();
      83             : 
      84         206 :     return bRet;
      85             : }
      86             : 
      87             : 
      88             : // class XMLLastLineAdjustPropHdl
      89             : 
      90             : 
      91       15130 : XMLLastLineAdjustPropHdl::~XMLLastLineAdjustPropHdl()
      92             : {
      93             :     // nothing to do
      94       15130 : }
      95             : 
      96           2 : bool XMLLastLineAdjustPropHdl::importXML( const OUString& rStrImpValue, uno::Any& rValue, const SvXMLUnitConverter& ) const
      97             : {
      98             :     sal_uInt16 eAdjust;
      99           2 :     bool bRet = SvXMLUnitConverter::convertEnum( eAdjust, rStrImpValue, pXML_Para_Align_Last_Enum );
     100           2 :     if( bRet )
     101           2 :         rValue <<= (sal_Int16)eAdjust;
     102             : 
     103           2 :     return bRet;
     104             : }
     105             : 
     106         204 : bool XMLLastLineAdjustPropHdl::exportXML( OUString& rStrExpValue, const uno::Any& rValue, const SvXMLUnitConverter& ) const
     107             : {
     108         204 :     OUStringBuffer aOut;
     109         204 :     sal_Int16 nVal = 0;
     110         204 :     bool bRet = false;
     111             : 
     112         204 :     rValue >>= nVal;
     113             : 
     114         204 :     if( nVal != style::ParagraphAdjust_LEFT )
     115           0 :         bRet = SvXMLUnitConverter::convertEnum( aOut, nVal, pXML_Para_Align_Last_Enum, XML_START );
     116             : 
     117         204 :     rStrExpValue = aOut.makeStringAndClear();
     118             : 
     119         204 :     return bRet;
     120             : }
     121             : 
     122             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11