LCOV - code coverage report
Current view: top level - xmloff/source/style - breakhdl.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 12 66 18.2 %
Date: 2012-08-25 Functions: 5 8 62.5 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 6 50 12.0 %

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

Generated by: LCOV version 1.10