LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/vbahelper/source/msforms - vbacheckbox.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 26 57 45.6 %
Date: 2013-07-09 Functions: 5 16 31.2 %
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 "vbacheckbox.hxx"
      21             : #include "vbanewfont.hxx"
      22             : #include <vbahelper/helperdecl.hxx>
      23             : 
      24             : using namespace com::sun::star;
      25             : using namespace ooo::vba;
      26             : 
      27             : 
      28           1 : const static OUString LABEL( "Label" );
      29           1 : const static OUString STATE( "State" );
      30          16 : ScVbaCheckbox::ScVbaCheckbox( const uno::Reference< ov::XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< uno::XInterface >& xControl, const uno::Reference< frame::XModel >& xModel, ov::AbstractGeometryAttributes* pGeomHelper ) : CheckBoxImpl_BASE( xParent, xContext, xControl, xModel, pGeomHelper )
      31             : {
      32          16 : }
      33             : 
      34             : // Attributes
      35             : OUString SAL_CALL
      36           0 : ScVbaCheckbox::getCaption() throw (css::uno::RuntimeException)
      37             : {
      38           0 :     OUString Label;
      39           0 :     m_xProps->getPropertyValue( LABEL ) >>= Label;
      40           0 :     return Label;
      41             : }
      42             : 
      43             : void SAL_CALL
      44           0 : ScVbaCheckbox::setCaption( const OUString& _caption ) throw (::com::sun::star::uno::RuntimeException)
      45             : {
      46           0 :     m_xProps->setPropertyValue( LABEL, uno::makeAny( _caption ) );
      47           0 : }
      48             : 
      49             : uno::Any SAL_CALL
      50          16 : ScVbaCheckbox::getValue() throw (css::uno::RuntimeException)
      51             : {
      52          16 :     sal_Int16 nValue = -1;
      53          16 :     m_xProps->getPropertyValue( STATE ) >>= nValue;
      54          16 :     if( nValue != 0 )
      55           6 :         nValue = -1;
      56             : //    return uno::makeAny( nValue );
      57             : // I must be missing something MSO says value should be -1 if selected, 0 if not
      58             : // selected
      59          16 :     return uno::makeAny( ( nValue == -1 ) ? sal_True : sal_False );
      60             : }
      61             : 
      62             : void SAL_CALL
      63           8 : ScVbaCheckbox::setValue( const uno::Any& _value ) throw (css::uno::RuntimeException)
      64             : {
      65           8 :     sal_Int16 nValue = 0;
      66           8 :     sal_Int16 nOldValue = 0;
      67           8 :     m_xProps->getPropertyValue( STATE ) >>= nOldValue;
      68           8 :     if( !( _value >>= nValue ) )
      69             :     {
      70           4 :         sal_Bool bValue = false;
      71           4 :         _value >>= bValue;
      72           4 :         if ( bValue )
      73           2 :             nValue = -1;
      74             :     }
      75             : 
      76           8 :     if( nValue == -1)
      77           4 :         nValue = 1;
      78           8 :     m_xProps->setPropertyValue( STATE, uno::makeAny( nValue ) );
      79           8 :     if ( nValue != nOldValue )
      80           6 :         fireClickEvent();
      81           8 : }
      82             : 
      83           0 : uno::Reference< msforms::XNewFont > SAL_CALL ScVbaCheckbox::getFont() throw (uno::RuntimeException)
      84             : {
      85           0 :     return new VbaNewFont( this, mxContext, m_xProps );
      86             : }
      87             : 
      88             : OUString
      89           0 : ScVbaCheckbox::getServiceImplName()
      90             : {
      91           0 :     return OUString("ScVbaCheckbox");
      92             : }
      93             : 
      94             : uno::Sequence< OUString >
      95           0 : ScVbaCheckbox::getServiceNames()
      96             : {
      97           0 :     static uno::Sequence< OUString > aServiceNames;
      98           0 :     if ( aServiceNames.getLength() == 0 )
      99             :     {
     100           0 :         aServiceNames.realloc( 1 );
     101           0 :         aServiceNames[ 0 ] = "ooo.vba.msforms.CheckBox";
     102             :     }
     103           0 :     return aServiceNames;
     104             : }
     105             : 
     106           0 : sal_Int32 SAL_CALL ScVbaCheckbox::getBackColor() throw (uno::RuntimeException)
     107             : {
     108           0 :     return ScVbaControl::getBackColor();
     109             : }
     110             : 
     111           0 : void SAL_CALL ScVbaCheckbox::setBackColor( sal_Int32 nBackColor ) throw (uno::RuntimeException)
     112             : {
     113           0 :     ScVbaControl::setBackColor( nBackColor );
     114           0 : }
     115             : 
     116           0 : sal_Bool SAL_CALL ScVbaCheckbox::getAutoSize() throw (uno::RuntimeException)
     117             : {
     118           0 :     return ScVbaControl::getAutoSize();
     119             : }
     120             : 
     121           0 : void SAL_CALL ScVbaCheckbox::setAutoSize( sal_Bool bAutoSize ) throw (uno::RuntimeException)
     122             : {
     123           0 :     ScVbaControl::setAutoSize( bAutoSize );
     124           0 : }
     125             : 
     126           0 : sal_Bool SAL_CALL ScVbaCheckbox::getLocked() throw (uno::RuntimeException)
     127             : {
     128           0 :     return ScVbaControl::getLocked();
     129             : }
     130             : 
     131           0 : void SAL_CALL ScVbaCheckbox::setLocked( sal_Bool bLocked ) throw (uno::RuntimeException)
     132             : {
     133           0 :     ScVbaControl::setLocked( bLocked );
     134           3 : }
     135             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10