LCOV - code coverage report
Current view: top level - vbahelper/source/msforms - vbaradiobutton.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 26 43 60.5 %
Date: 2014-11-03 Functions: 5 10 50.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             : #include "vbaradiobutton.hxx"
      21             : #include "vbanewfont.hxx"
      22             : 
      23             : using namespace com::sun::star;
      24             : using namespace ooo::vba;
      25             : 
      26          32 : ScVbaRadioButton::ScVbaRadioButton( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< uno::XInterface >& xControl, const uno::Reference< frame::XModel >& xModel, AbstractGeometryAttributes* pGeomHelper ) : RadioButtonImpl_BASE( xParent, xContext, xControl, xModel, pGeomHelper )
      27             : {
      28          32 : }
      29             : 
      30             : // Attributes
      31             : OUString SAL_CALL
      32           0 : ScVbaRadioButton::getCaption() throw (css::uno::RuntimeException, std::exception)
      33             : {
      34           0 :     OUString Label;
      35           0 :     m_xProps->getPropertyValue( "Label" ) >>= Label;
      36           0 :     return Label;
      37             : }
      38             : 
      39             : void SAL_CALL
      40           0 : ScVbaRadioButton::setCaption( const OUString& _caption ) throw (::com::sun::star::uno::RuntimeException, std::exception)
      41             : {
      42           0 :     m_xProps->setPropertyValue( "Label", uno::makeAny( _caption ) );
      43           0 : }
      44             : 
      45             : uno::Any SAL_CALL
      46          32 : ScVbaRadioButton::getValue() throw (css::uno::RuntimeException, std::exception)
      47             : {
      48          32 :     sal_Int16 nValue = -1;
      49          32 :     m_xProps->getPropertyValue( "State" ) >>= nValue;
      50          32 :     if( nValue != 0 )
      51          12 :         nValue = -1;
      52             : //    return uno::makeAny( nValue );
      53             : // I must be missing something MSO says value should be -1 if selected, 0 if not
      54             : // selected
      55          32 :     return uno::makeAny( ( nValue == -1 ) ? sal_True : sal_False );
      56             : 
      57             : }
      58             : 
      59             : void SAL_CALL
      60          16 : ScVbaRadioButton::setValue( const uno::Any& _value ) throw (uno::RuntimeException, std::exception)
      61             : {
      62          16 :     sal_Int16 nValue = 0;
      63          16 :     sal_Int16 nOldValue = 0;
      64          16 :     m_xProps->getPropertyValue( "State" ) >>= nOldValue;
      65             : 
      66          16 :     if( !( _value >>= nValue ) )
      67             :     {
      68           8 :         bool bValue = false;
      69           8 :         _value >>= bValue;
      70           8 :         if ( bValue )
      71           4 :             nValue = -1;
      72             :     }
      73             : 
      74          16 :     if( nValue == -1)
      75           8 :         nValue = 1;
      76          16 :     m_xProps->setPropertyValue( "State", uno::makeAny( nValue ) );
      77          16 :     if ( nValue != nOldValue )
      78             :     {
      79          12 :         fireChangeEvent();
      80             :         // In Excel, only when the radio button is checked, the click event is fired.
      81          12 :         if ( nValue != 0 )
      82             :         {
      83           8 :             fireClickEvent();
      84             :         }
      85             :     }
      86          16 : }
      87             : 
      88           0 : uno::Reference< msforms::XNewFont > SAL_CALL ScVbaRadioButton::getFont() throw (uno::RuntimeException, std::exception)
      89             : {
      90           0 :     return new VbaNewFont( m_xProps );
      91             : }
      92             : 
      93             : OUString
      94           0 : ScVbaRadioButton::getServiceImplName()
      95             : {
      96           0 :     return OUString( "ScVbaRadioButton" );
      97             : }
      98             : 
      99             : uno::Sequence< OUString >
     100           0 : ScVbaRadioButton::getServiceNames()
     101             : {
     102           0 :     static uno::Sequence< OUString > aServiceNames;
     103           0 :     if ( aServiceNames.getLength() == 0 )
     104             :     {
     105           0 :         aServiceNames.realloc( 1 );
     106           0 :         aServiceNames[ 0 ] = "ooo.vba.msforms.RadioButton";
     107             :     }
     108           0 :     return aServiceNames;
     109           6 : }
     110             : 
     111             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10