LCOV - code coverage report
Current view: top level - xmloff/source/chart - XMLAxisPositionPropertyHdl.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 18 47 38.3 %
Date: 2012-08-25 Functions: 4 5 80.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 6 44 13.6 %

           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                 :            : 
      30                 :            : #include "XMLAxisPositionPropertyHdl.hxx"
      31                 :            : 
      32                 :            : #include <rtl/ustrbuf.hxx>
      33                 :            : 
      34                 :            : #include <com/sun/star/uno/Any.hxx>
      35                 :            : #include <com/sun/star/chart/ChartAxisPosition.hpp>
      36                 :            : 
      37                 :            : #include <sax/tools/converter.hxx>
      38                 :            : 
      39                 :            : #include <xmloff/xmltoken.hxx>
      40                 :            : 
      41                 :            : 
      42                 :            : using namespace ::xmloff::token;
      43                 :            : using ::rtl::OUString;
      44                 :            : using ::rtl::OUStringBuffer;
      45                 :            : 
      46                 :            : using namespace com::sun::star;
      47                 :            : 
      48                 :         66 : XMLAxisPositionPropertyHdl::XMLAxisPositionPropertyHdl( bool bCrossingValue )
      49                 :         66 :         : m_bCrossingValue( bCrossingValue )
      50                 :         66 : {}
      51                 :            : 
      52                 :         66 : XMLAxisPositionPropertyHdl::~XMLAxisPositionPropertyHdl()
      53         [ -  + ]:        132 : {}
      54                 :            : 
      55                 :          0 : sal_Bool XMLAxisPositionPropertyHdl::importXML( const OUString& rStrImpValue,
      56                 :            :                                                   uno::Any& rValue, const SvXMLUnitConverter& /*rUnitConverter*/ ) const
      57                 :            : {
      58                 :          0 :     sal_Bool bResult = false;
      59                 :            : 
      60         [ #  # ]:          0 :     if( rStrImpValue.equals( GetXMLToken(XML_START) ) )
      61                 :            :     {
      62         [ #  # ]:          0 :         if( !m_bCrossingValue )
      63                 :            :         {
      64         [ #  # ]:          0 :             rValue <<= ::com::sun::star::chart::ChartAxisPosition_START;
      65                 :          0 :             bResult = true;
      66                 :            :         }
      67                 :            :     }
      68         [ #  # ]:          0 :     else if( rStrImpValue.equals( GetXMLToken(XML_END) ) )
      69                 :            :     {
      70         [ #  # ]:          0 :         if( !m_bCrossingValue )
      71                 :            :         {
      72         [ #  # ]:          0 :             rValue <<= ::com::sun::star::chart::ChartAxisPosition_END;
      73                 :          0 :             bResult = true;
      74                 :            :         }
      75                 :            :     }
      76                 :            :     else
      77                 :            :     {
      78         [ #  # ]:          0 :         if( !m_bCrossingValue )
      79                 :            :         {
      80         [ #  # ]:          0 :             rValue <<= ::com::sun::star::chart::ChartAxisPosition_VALUE;
      81                 :          0 :             bResult = true;
      82                 :            :         }
      83                 :            :         else
      84                 :            :         {
      85                 :          0 :             double fDblValue=0.0;
      86         [ #  # ]:          0 :             bResult = ::sax::Converter::convertDouble(fDblValue, rStrImpValue);
      87         [ #  # ]:          0 :             rValue <<= fDblValue;
      88                 :            :         }
      89                 :            :     }
      90                 :            : 
      91                 :          0 :     return bResult;
      92                 :            : }
      93                 :            : 
      94                 :         18 : sal_Bool XMLAxisPositionPropertyHdl::exportXML( OUString& rStrExpValue,
      95                 :            :                                               const uno::Any& rValue, const SvXMLUnitConverter& /*rUnitConverter*/ ) const
      96                 :            : {
      97                 :         18 :     sal_Bool bResult = sal_False;
      98                 :            : 
      99                 :         18 :     rtl::OUStringBuffer sValueBuffer;
     100         [ -  + ]:         18 :     if( m_bCrossingValue )
     101                 :            :     {
     102         [ #  # ]:          0 :         if(rStrExpValue.isEmpty())
     103                 :            :         {
     104                 :          0 :             double fValue = 0.0;
     105                 :          0 :             rValue >>= fValue;
     106         [ #  # ]:          0 :             ::sax::Converter::convertDouble( sValueBuffer, fValue );
     107         [ #  # ]:          0 :             rStrExpValue = sValueBuffer.makeStringAndClear();
     108                 :          0 :             bResult = true;
     109                 :            :         }
     110                 :            :     }
     111                 :            :     else
     112                 :            :     {
     113                 :         18 :         ::com::sun::star::chart::ChartAxisPosition ePosition( ::com::sun::star::chart::ChartAxisPosition_ZERO );
     114         [ +  - ]:         18 :         rValue >>= ePosition;
     115   [ -  -  +  - ]:         18 :         switch(ePosition)
     116                 :            :         {
     117                 :            :             case ::com::sun::star::chart::ChartAxisPosition_START:
     118         [ #  # ]:          0 :                 rStrExpValue = GetXMLToken( XML_START );
     119                 :          0 :                 bResult = true;
     120                 :          0 :                 break;
     121                 :            :             case ::com::sun::star::chart::ChartAxisPosition_END:
     122         [ #  # ]:          0 :                 rStrExpValue = GetXMLToken( XML_END );
     123                 :          0 :                 bResult = true;
     124                 :          0 :                 break;
     125                 :            :             case ::com::sun::star::chart::ChartAxisPosition_ZERO:
     126         [ +  - ]:         18 :                 ::sax::Converter::convertDouble( sValueBuffer, 0.0 );
     127         [ +  - ]:         18 :                 rStrExpValue = sValueBuffer.makeStringAndClear();
     128                 :         18 :                 bResult = true;
     129                 :         18 :                 break;
     130                 :            :             default:
     131                 :         18 :                 break;
     132                 :            :         }
     133                 :            :     }
     134                 :         18 :     return bResult;
     135                 :            : }
     136                 :            : 
     137                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10