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

Generated by: LCOV version 1.10