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

Generated by: LCOV version 1.10