merge the formfield patch from ooo-build
[ooovba.git] / vbahelper / source / msforms / vbacheckbox.cxx
blob3a6c5d98520e25d7bc0dc0288745b1f705c4d55a
1 /*************************************************************************
3 * OpenOffice.org - a multi-platform office productivity suite
5 * $RCSfile$
7 * $Revision$
9 * last change: $Author$ $Date$
11 * The Contents of this file are made available subject to
12 * the terms of GNU Lesser General Public License Version 2.1.
15 * GNU Lesser General Public License Version 2.1
16 * =============================================
17 * Copyright 2005 by Sun Microsystems, Inc.
18 * 901 San Antonio Road, Palo Alto, CA 94303, USA
20 * This library is free software; you can redistribute it and/or
21 * modify it under the terms of the GNU Lesser General Public
22 * License version 2.1, as published by the Free Software Foundation.
24 * This library is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
27 * Lesser General Public License for more details.
29 * You should have received a copy of the GNU Lesser General Public
30 * License along with this library; if not, write to the Free Software
31 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
32 * MA 02111-1307 USA
34 ************************************************************************/
35 #include "vbacheckbox.hxx"
36 #include <vbahelper/helperdecl.hxx>
37 #include <vector>
39 using namespace com::sun::star;
40 using namespace ooo::vba;
43 const static rtl::OUString LABEL( RTL_CONSTASCII_USTRINGPARAM("Label") );
44 const static rtl::OUString STATE( RTL_CONSTASCII_USTRINGPARAM("State") );
45 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 )
49 // Attributes
50 rtl::OUString SAL_CALL
51 ScVbaCheckbox::getCaption() throw (css::uno::RuntimeException)
53 rtl::OUString Label;
54 m_xProps->getPropertyValue( LABEL ) >>= Label;
55 return Label;
58 void SAL_CALL
59 ScVbaCheckbox::setCaption( const rtl::OUString& _caption ) throw (::com::sun::star::uno::RuntimeException)
61 m_xProps->setPropertyValue( LABEL, uno::makeAny( _caption ) );
64 uno::Any SAL_CALL
65 ScVbaCheckbox::getValue() throw (css::uno::RuntimeException)
67 sal_Int16 nValue = -1;
68 m_xProps->getPropertyValue( STATE ) >>= nValue;
69 if( nValue != 0 )
70 nValue = -1;
71 // return uno::makeAny( nValue );
72 // I must be missing something MSO says value should be -1 if selected, 0 if not
73 // selected
74 return uno::makeAny( ( nValue == -1 ) ? sal_True : sal_False );
77 void SAL_CALL
78 ScVbaCheckbox::setValue( const uno::Any& _value ) throw (css::uno::RuntimeException)
80 sal_Int16 nValue = 0;
81 sal_Bool bValue = false;
82 if( _value >>= nValue )
84 if( nValue == -1)
85 nValue = 1;
87 else if ( _value >>= bValue )
89 if ( bValue )
90 nValue = 1;
92 m_xProps->setPropertyValue( STATE, uno::makeAny( nValue ) );
94 rtl::OUString&
95 ScVbaCheckbox::getServiceImplName()
97 static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaCheckbox") );
98 return sImplName;
101 uno::Sequence< rtl::OUString >
102 ScVbaCheckbox::getServiceNames()
104 static uno::Sequence< rtl::OUString > aServiceNames;
105 if ( aServiceNames.getLength() == 0 )
107 aServiceNames.realloc( 1 );
108 aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.msforms.CheckBox" ) );
110 return aServiceNames;