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

Generated by: LCOV version 1.10