LCOV - code coverage report
Current view: top level - xmloff/source/style - adjushdl.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 30 32 93.8 %
Date: 2012-08-25 Functions: 8 8 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 13 28 46.4 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include <adjushdl.hxx>
      30                 :            : #include <tools/solar.h>
      31                 :            : #include <xmloff/xmltoken.hxx>
      32                 :            : #include <xmloff/xmluconv.hxx>
      33                 :            : #include <rtl/ustrbuf.hxx>
      34                 :            : #include <com/sun/star/style/ParagraphAdjust.hpp>
      35                 :            : #include <com/sun/star/uno/Any.hxx>
      36                 :            : 
      37                 :            : using namespace ::com::sun::star;
      38                 :            : using ::rtl::OUString;
      39                 :            : using ::rtl::OUStringBuffer;
      40                 :            : 
      41                 :            : using namespace ::xmloff::token;
      42                 :            : 
      43                 :            : SvXMLEnumMapEntry const pXML_Para_Adjust_Enum[] =
      44                 :            : {
      45                 :            :     { XML_START,        style::ParagraphAdjust_LEFT },
      46                 :            :     { XML_END,          style::ParagraphAdjust_RIGHT },
      47                 :            :     { XML_CENTER,       style::ParagraphAdjust_CENTER },
      48                 :            :     { XML_JUSTIFY,      style::ParagraphAdjust_BLOCK },
      49                 :            :     { XML_JUSTIFIED,    style::ParagraphAdjust_BLOCK }, // obsolete
      50                 :            :     { XML_LEFT,         style::ParagraphAdjust_LEFT },
      51                 :            :     { XML_RIGHT,        style::ParagraphAdjust_RIGHT },
      52                 :            :     { XML_TOKEN_INVALID, 0 }
      53                 :            : };
      54                 :            : 
      55                 :            : SvXMLEnumMapEntry const pXML_Para_Align_Last_Enum[] =
      56                 :            : {
      57                 :            :     { XML_START,        style::ParagraphAdjust_LEFT },
      58                 :            :     { XML_CENTER,       style::ParagraphAdjust_CENTER },
      59                 :            :     { XML_JUSTIFY,      style::ParagraphAdjust_BLOCK },
      60                 :            :     { XML_JUSTIFIED,    style::ParagraphAdjust_BLOCK }, // obsolete
      61                 :            :     { XML_TOKEN_INVALID, 0 }
      62                 :            : };
      63                 :            : 
      64                 :            : ///////////////////////////////////////////////////////////////////////////////
      65                 :            : //
      66                 :            : // class XMLParaAdjustPropHdl
      67                 :            : //
      68                 :            : 
      69                 :       1722 : XMLParaAdjustPropHdl::~XMLParaAdjustPropHdl()
      70                 :            : {
      71                 :            :     // nothing to do
      72         [ -  + ]:       3444 : }
      73                 :            : 
      74                 :        155 : sal_Bool XMLParaAdjustPropHdl::importXML( const OUString& rStrImpValue, uno::Any& rValue, const SvXMLUnitConverter& ) const
      75                 :            : {
      76                 :            :     sal_uInt16 eAdjust;
      77         [ +  - ]:        155 :     sal_Bool bRet = SvXMLUnitConverter::convertEnum( eAdjust, rStrImpValue, pXML_Para_Adjust_Enum );
      78         [ +  - ]:        155 :     if( bRet )
      79         [ +  - ]:        155 :         rValue <<= (sal_Int16)eAdjust;
      80                 :            : 
      81                 :        155 :     return bRet;
      82                 :            : }
      83                 :            : 
      84                 :         52 : sal_Bool XMLParaAdjustPropHdl::exportXML( OUString& rStrExpValue, const uno::Any& rValue, const SvXMLUnitConverter& ) const
      85                 :            : {
      86         [ -  + ]:         52 :     if(!rValue.hasValue())
      87                 :          0 :         return sal_False;
      88                 :         52 :     OUStringBuffer aOut;
      89                 :         52 :     sal_Int16 nVal = 0;
      90                 :            : 
      91                 :         52 :     rValue >>= nVal;
      92                 :            : 
      93         [ +  - ]:         52 :     sal_Bool bRet = SvXMLUnitConverter::convertEnum( aOut, nVal, pXML_Para_Adjust_Enum, XML_START );
      94                 :            : 
      95         [ +  - ]:         52 :     rStrExpValue = aOut.makeStringAndClear();
      96                 :            : 
      97                 :         52 :     return bRet;
      98                 :            : }
      99                 :            : 
     100                 :            : ///////////////////////////////////////////////////////////////////////////////
     101                 :            : //
     102                 :            : // class XMLLastLineAdjustPropHdl
     103                 :            : //
     104                 :            : 
     105                 :       1722 : XMLLastLineAdjustPropHdl::~XMLLastLineAdjustPropHdl()
     106                 :            : {
     107                 :            :     // nothing to do
     108         [ -  + ]:       3444 : }
     109                 :            : 
     110                 :          1 : sal_Bool XMLLastLineAdjustPropHdl::importXML( const OUString& rStrImpValue, uno::Any& rValue, const SvXMLUnitConverter& ) const
     111                 :            : {
     112                 :            :     sal_uInt16 eAdjust;
     113         [ +  - ]:          1 :     sal_Bool bRet = SvXMLUnitConverter::convertEnum( eAdjust, rStrImpValue, pXML_Para_Align_Last_Enum );
     114         [ +  - ]:          1 :     if( bRet )
     115         [ +  - ]:          1 :         rValue <<= (sal_Int16)eAdjust;
     116                 :            : 
     117                 :          1 :     return bRet;
     118                 :            : }
     119                 :            : 
     120                 :         52 : sal_Bool XMLLastLineAdjustPropHdl::exportXML( OUString& rStrExpValue, const uno::Any& rValue, const SvXMLUnitConverter& ) const
     121                 :            : {
     122                 :         52 :     OUStringBuffer aOut;
     123                 :         52 :     sal_Int16 nVal = 0;
     124                 :         52 :     sal_Bool bRet = sal_False;
     125                 :            : 
     126                 :         52 :     rValue >>= nVal;
     127                 :            : 
     128         [ -  + ]:         52 :     if( nVal != style::ParagraphAdjust_LEFT )
     129         [ #  # ]:          0 :         bRet = SvXMLUnitConverter::convertEnum( aOut, nVal, pXML_Para_Align_Last_Enum, XML_START );
     130                 :            : 
     131         [ +  - ]:         52 :     rStrExpValue = aOut.makeStringAndClear();
     132                 :            : 
     133                 :         52 :     return bRet;
     134                 :            : }
     135                 :            : 
     136                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10