LCOV - code coverage report
Current view: top level - xmloff/source/chart - XMLAxisPositionPropertyHdl.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 33 51 64.7 %
Date: 2014-11-03 Functions: 5 5 100.0 %
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             : 
      21             : #include "XMLAxisPositionPropertyHdl.hxx"
      22             : 
      23             : #include <rtl/ustrbuf.hxx>
      24             : 
      25             : #include <com/sun/star/uno/Any.hxx>
      26             : #include <com/sun/star/chart/ChartAxisPosition.hpp>
      27             : 
      28             : #include <sax/tools/converter.hxx>
      29             : 
      30             : #include <xmloff/xmltoken.hxx>
      31             : 
      32             : 
      33             : using namespace ::xmloff::token;
      34             : 
      35             : using namespace com::sun::star;
      36             : 
      37        3776 : XMLAxisPositionPropertyHdl::XMLAxisPositionPropertyHdl( bool bCrossingValue )
      38        3776 :         : m_bCrossingValue( bCrossingValue )
      39        3776 : {}
      40             : 
      41        7552 : XMLAxisPositionPropertyHdl::~XMLAxisPositionPropertyHdl()
      42        7552 : {}
      43             : 
      44         984 : bool XMLAxisPositionPropertyHdl::importXML( const OUString& rStrImpValue,
      45             :                                                   uno::Any& rValue, const SvXMLUnitConverter& /*rUnitConverter*/ ) const
      46             : {
      47         984 :     bool bResult = false;
      48             : 
      49         984 :     if( rStrImpValue.equals( GetXMLToken(XML_START) ) )
      50             :     {
      51           0 :         if( !m_bCrossingValue )
      52             :         {
      53           0 :             rValue <<= ::com::sun::star::chart::ChartAxisPosition_START;
      54           0 :             bResult = true;
      55             :         }
      56             :     }
      57         984 :     else if( rStrImpValue.equals( GetXMLToken(XML_END) ) )
      58             :     {
      59          24 :         if( !m_bCrossingValue )
      60             :         {
      61          12 :             rValue <<= ::com::sun::star::chart::ChartAxisPosition_END;
      62          12 :             bResult = true;
      63             :         }
      64             :     }
      65         960 :     else if( rStrImpValue.equals( GetXMLToken(XML_0) ) )
      66             :     {
      67         960 :         if( !m_bCrossingValue )
      68             :         {
      69         480 :             rValue <<= ::com::sun::star::chart::ChartAxisPosition_ZERO;
      70         480 :             bResult = true;
      71             :         }
      72             :     }
      73             :     else
      74             :     {
      75           0 :         if( !m_bCrossingValue )
      76             :         {
      77           0 :             rValue <<= ::com::sun::star::chart::ChartAxisPosition_VALUE;
      78           0 :             bResult = true;
      79             :         }
      80             :         else
      81             :         {
      82           0 :             double fDblValue=0.0;
      83           0 :             bResult = ::sax::Converter::convertDouble(fDblValue, rStrImpValue);
      84           0 :             rValue <<= fDblValue;
      85             :         }
      86             :     }
      87             : 
      88         984 :     return bResult;
      89             : }
      90             : 
      91        2372 : bool XMLAxisPositionPropertyHdl::exportXML( OUString& rStrExpValue,
      92             :                                               const uno::Any& rValue, const SvXMLUnitConverter& /*rUnitConverter*/ ) const
      93             : {
      94        2372 :     bool bResult = false;
      95             : 
      96        2372 :     OUStringBuffer sValueBuffer;
      97        2372 :     if( m_bCrossingValue )
      98             :     {
      99        1068 :         if(rStrExpValue.isEmpty())
     100             :         {
     101           0 :             double fValue = 0.0;
     102           0 :             rValue >>= fValue;
     103           0 :             ::sax::Converter::convertDouble( sValueBuffer, fValue );
     104           0 :             rStrExpValue = sValueBuffer.makeStringAndClear();
     105           0 :             bResult = true;
     106             :         }
     107             :     }
     108             :     else
     109             :     {
     110        1304 :         ::com::sun::star::chart::ChartAxisPosition ePosition( ::com::sun::star::chart::ChartAxisPosition_ZERO );
     111        1304 :         rValue >>= ePosition;
     112        1304 :         switch(ePosition)
     113             :         {
     114             :             case ::com::sun::star::chart::ChartAxisPosition_START:
     115           0 :                 rStrExpValue = GetXMLToken( XML_START );
     116           0 :                 bResult = true;
     117           0 :                 break;
     118             :             case ::com::sun::star::chart::ChartAxisPosition_END:
     119          36 :                 rStrExpValue = GetXMLToken( XML_END );
     120          36 :                 bResult = true;
     121          36 :                 break;
     122             :             case ::com::sun::star::chart::ChartAxisPosition_ZERO:
     123        1268 :                 ::sax::Converter::convertDouble( sValueBuffer, 0.0 );
     124        1268 :                 rStrExpValue = sValueBuffer.makeStringAndClear();
     125        1268 :                 bResult = true;
     126        1268 :                 break;
     127             :             default:
     128           0 :                 break;
     129             :         }
     130             :     }
     131        2372 :     return bResult;
     132             : }
     133             : 
     134             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10