LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/xmloff/source/style - breakhdl.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 27 66 40.9 %
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 <breakhdl.hxx>
      21             : #include <xmloff/xmltoken.hxx>
      22             : #include <xmloff/xmluconv.hxx>
      23             : #include <rtl/ustrbuf.hxx>
      24             : #include <com/sun/star/style/BreakType.hpp>
      25             : #include <com/sun/star/uno/Any.hxx>
      26             : 
      27             : 
      28             : using namespace ::com::sun::star;
      29             : using namespace ::xmloff::token;
      30             : 
      31             : SvXMLEnumMapEntry pXML_BreakTypes[] =
      32             : {
      33             :     { XML_AUTO,         0 },
      34             :     { XML_COLUMN,       1 },
      35             :     { XML_PAGE,         2 },
      36             :     { XML_EVEN_PAGE,    2 },
      37             :     { XML_ODD_PAGE,     2 },
      38             :     { XML_TOKEN_INVALID, 0}
      39             : };
      40             : 
      41             : ///////////////////////////////////////////////////////////////////////////////
      42             : //
      43             : // class XMLFmtBreakBeforePropHdl
      44             : //
      45             : 
      46        2866 : XMLFmtBreakBeforePropHdl::~XMLFmtBreakBeforePropHdl()
      47             : {
      48             :     // Nothing to do
      49        2866 : }
      50             : 
      51           4 : sal_Bool XMLFmtBreakBeforePropHdl::importXML( const OUString& rStrImpValue, uno::Any& rValue, const SvXMLUnitConverter& ) const
      52             : {
      53             :     sal_uInt16 nEnum;
      54           4 :     sal_Bool bRet = SvXMLUnitConverter::convertEnum( nEnum, rStrImpValue, pXML_BreakTypes );
      55           4 :     if( bRet )
      56             :     {
      57             :         style::BreakType eBreak;
      58           4 :         switch ( nEnum )
      59             :         {
      60             :         case 0:
      61           0 :             eBreak = style::BreakType_NONE;
      62           0 :             break;
      63             :         case 1:
      64           0 :             eBreak = style::BreakType_COLUMN_BEFORE;
      65           0 :             break;
      66             :         default:
      67           4 :             eBreak = style::BreakType_PAGE_BEFORE;
      68           4 :             break;
      69             :         }
      70           4 :         rValue <<= eBreak;
      71             :     }
      72             : 
      73           4 :     return bRet;
      74             : }
      75             : 
      76           1 : sal_Bool XMLFmtBreakBeforePropHdl::exportXML( OUString& rStrExpValue, const uno::Any& rValue, const SvXMLUnitConverter& ) const
      77             : {
      78             :     style::BreakType eBreak;
      79             : 
      80           1 :     if( !( rValue >>= eBreak ) )
      81             :     {
      82           0 :         sal_Int32 nValue = 0;
      83           0 :         if( !( rValue >>= nValue ) )
      84           0 :             return sal_False;
      85             : 
      86           0 :         eBreak = (style::BreakType) nValue;
      87             :     }
      88             : 
      89           1 :     sal_uInt16 nEnum = 0;
      90           1 :     switch( eBreak )
      91             :     {
      92             :         case style::BreakType_COLUMN_BEFORE:
      93           0 :             nEnum = 1;
      94           0 :             break;
      95             :         case style::BreakType_PAGE_BEFORE:
      96           1 :             nEnum = 2;
      97           1 :             break;
      98             :         case style::BreakType_NONE:
      99           0 :             nEnum = 0;
     100           0 :             break;
     101             :         default:
     102           0 :             return sal_False;
     103             :     }
     104             : 
     105           1 :     OUStringBuffer aOut;
     106           1 :     /* sal_Bool bOk = */ SvXMLUnitConverter::convertEnum( aOut, nEnum, pXML_BreakTypes );
     107           1 :     rStrExpValue = aOut.makeStringAndClear();
     108             : 
     109           1 :     return sal_True;
     110             : }
     111             : 
     112             : ///////////////////////////////////////////////////////////////////////////////
     113             : //
     114             : // class XMLFmtBreakBeforePropHdl
     115             : //
     116             : 
     117        2866 : XMLFmtBreakAfterPropHdl::~XMLFmtBreakAfterPropHdl()
     118             : {
     119             :     // Nothing to do
     120        2866 : }
     121             : 
     122           0 : sal_Bool XMLFmtBreakAfterPropHdl::importXML( const OUString& rStrImpValue, uno::Any& rValue, const SvXMLUnitConverter& ) const
     123             : {
     124             :     sal_uInt16 nEnum;
     125           0 :     sal_Bool bRet = SvXMLUnitConverter::convertEnum( nEnum, rStrImpValue, pXML_BreakTypes );
     126           0 :     if( bRet )
     127             :     {
     128             :         style::BreakType eBreak;
     129           0 :         switch ( nEnum )
     130             :         {
     131             :         case 0:
     132           0 :             eBreak = style::BreakType_NONE;
     133           0 :             break;
     134             :         case 1:
     135           0 :             eBreak = style::BreakType_COLUMN_AFTER;
     136           0 :             break;
     137             :         default:
     138           0 :             eBreak = style::BreakType_PAGE_AFTER;
     139           0 :             break;
     140             :         }
     141           0 :         rValue <<= eBreak;
     142             :     }
     143             : 
     144           0 :     return bRet;
     145             : }
     146             : 
     147           1 : sal_Bool XMLFmtBreakAfterPropHdl::exportXML( OUString& rStrExpValue, const uno::Any& rValue, const SvXMLUnitConverter& ) const
     148             : {
     149             :     style::BreakType eBreak;
     150             : 
     151           1 :     if( !( rValue >>= eBreak ) )
     152             :     {
     153           0 :         sal_Int32 nValue = 0;
     154           0 :         if( !( rValue >>= nValue ) )
     155           0 :             return sal_False;
     156             : 
     157           0 :         eBreak = (style::BreakType) nValue;
     158             :     }
     159             : 
     160           1 :     sal_uInt16 nEnum = 0;
     161           1 :     switch( eBreak )
     162             :     {
     163             :         case style::BreakType_COLUMN_AFTER:
     164           0 :             nEnum = 1;
     165           0 :             break;
     166             :         case style::BreakType_PAGE_AFTER:
     167           0 :             nEnum = 2;
     168           0 :             break;
     169             :         case style::BreakType_NONE:
     170           0 :             nEnum = 0;
     171           0 :             break;
     172             :         default:
     173           1 :             return sal_False;
     174             :     }
     175             : 
     176           0 :     OUStringBuffer aOut;
     177           0 :     /* sal_Bool bOk = */ SvXMLUnitConverter::convertEnum( aOut, nEnum, pXML_BreakTypes );
     178           0 :     rStrExpValue = aOut.makeStringAndClear();
     179             : 
     180           0 :     return sal_True;
     181             : }
     182             : 
     183             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10