1*e6ed5fbcSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*e6ed5fbcSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*e6ed5fbcSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*e6ed5fbcSAndrew Rist  * distributed with this work for additional information
6*e6ed5fbcSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*e6ed5fbcSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*e6ed5fbcSAndrew Rist  * "License"); you may not use this file except in compliance
9*e6ed5fbcSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*e6ed5fbcSAndrew Rist  *
11*e6ed5fbcSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*e6ed5fbcSAndrew Rist  *
13*e6ed5fbcSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*e6ed5fbcSAndrew Rist  * software distributed under the License is distributed on an
15*e6ed5fbcSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*e6ed5fbcSAndrew Rist  * KIND, either express or implied.  See the License for the
17*e6ed5fbcSAndrew Rist  * specific language governing permissions and limitations
18*e6ed5fbcSAndrew Rist  * under the License.
19*e6ed5fbcSAndrew Rist  *
20*e6ed5fbcSAndrew Rist  *************************************************************/
21*e6ed5fbcSAndrew Rist 
22*e6ed5fbcSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #include "vbacheckbox.hxx"
25cdf0e10cSrcweir #include "vbanewfont.hxx"
26cdf0e10cSrcweir #include <vbahelper/helperdecl.hxx>
27cdf0e10cSrcweir 
28cdf0e10cSrcweir using namespace com::sun::star;
29cdf0e10cSrcweir using namespace ooo::vba;
30cdf0e10cSrcweir 
31cdf0e10cSrcweir 
32cdf0e10cSrcweir const static rtl::OUString LABEL( RTL_CONSTASCII_USTRINGPARAM("Label") );
33cdf0e10cSrcweir const static rtl::OUString STATE( RTL_CONSTASCII_USTRINGPARAM("State") );
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)34cdf0e10cSrcweir 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 )
35cdf0e10cSrcweir {
36cdf0e10cSrcweir }
37cdf0e10cSrcweir 
38cdf0e10cSrcweir // Attributes
39cdf0e10cSrcweir rtl::OUString SAL_CALL
getCaption()40cdf0e10cSrcweir ScVbaCheckbox::getCaption() throw (css::uno::RuntimeException)
41cdf0e10cSrcweir {
42cdf0e10cSrcweir     rtl::OUString Label;
43cdf0e10cSrcweir     m_xProps->getPropertyValue( LABEL ) >>= Label;
44cdf0e10cSrcweir     return Label;
45cdf0e10cSrcweir }
46cdf0e10cSrcweir 
47cdf0e10cSrcweir void SAL_CALL
setCaption(const rtl::OUString & _caption)48cdf0e10cSrcweir ScVbaCheckbox::setCaption( const rtl::OUString& _caption ) throw (::com::sun::star::uno::RuntimeException)
49cdf0e10cSrcweir {
50cdf0e10cSrcweir     m_xProps->setPropertyValue( LABEL, uno::makeAny( _caption ) );
51cdf0e10cSrcweir }
52cdf0e10cSrcweir 
53cdf0e10cSrcweir uno::Any SAL_CALL
getValue()54cdf0e10cSrcweir ScVbaCheckbox::getValue() throw (css::uno::RuntimeException)
55cdf0e10cSrcweir {
56cdf0e10cSrcweir     sal_Int16 nValue = -1;
57cdf0e10cSrcweir     m_xProps->getPropertyValue( STATE ) >>= nValue;
58cdf0e10cSrcweir     if( nValue != 0 )
59cdf0e10cSrcweir         nValue = -1;
60cdf0e10cSrcweir //    return uno::makeAny( nValue );
61cdf0e10cSrcweir // I must be missing something MSO says value should be -1 if selected, 0 if not
62cdf0e10cSrcweir // selected
63cdf0e10cSrcweir     return uno::makeAny( ( nValue == -1 ) ? sal_True : sal_False );
64cdf0e10cSrcweir }
65cdf0e10cSrcweir 
66cdf0e10cSrcweir void SAL_CALL
setValue(const uno::Any & _value)67cdf0e10cSrcweir ScVbaCheckbox::setValue( const uno::Any& _value ) throw (css::uno::RuntimeException)
68cdf0e10cSrcweir {
69cdf0e10cSrcweir     sal_Int16 nValue = 0;
70cdf0e10cSrcweir     sal_Bool bValue = false;
71cdf0e10cSrcweir     if( _value >>= nValue )
72cdf0e10cSrcweir     {
73cdf0e10cSrcweir         if( nValue == -1)
74cdf0e10cSrcweir             nValue = 1;
75cdf0e10cSrcweir     }
76cdf0e10cSrcweir     else if ( _value >>= bValue )
77cdf0e10cSrcweir     {
78cdf0e10cSrcweir         if ( bValue )
79cdf0e10cSrcweir             nValue = 1;
80cdf0e10cSrcweir     }
81cdf0e10cSrcweir     m_xProps->setPropertyValue( STATE, uno::makeAny( nValue ) );
82cdf0e10cSrcweir }
83cdf0e10cSrcweir 
getFont()84cdf0e10cSrcweir uno::Reference< msforms::XNewFont > SAL_CALL ScVbaCheckbox::getFont() throw (uno::RuntimeException)
85cdf0e10cSrcweir {
86cdf0e10cSrcweir     return new VbaNewFont( this, mxContext, m_xProps );
87cdf0e10cSrcweir }
88cdf0e10cSrcweir 
89cdf0e10cSrcweir rtl::OUString&
getServiceImplName()90cdf0e10cSrcweir ScVbaCheckbox::getServiceImplName()
91cdf0e10cSrcweir {
92cdf0e10cSrcweir 	static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaCheckbox") );
93cdf0e10cSrcweir 	return sImplName;
94cdf0e10cSrcweir }
95cdf0e10cSrcweir 
96cdf0e10cSrcweir uno::Sequence< rtl::OUString >
getServiceNames()97cdf0e10cSrcweir ScVbaCheckbox::getServiceNames()
98cdf0e10cSrcweir {
99cdf0e10cSrcweir 	static uno::Sequence< rtl::OUString > aServiceNames;
100cdf0e10cSrcweir 	if ( aServiceNames.getLength() == 0 )
101cdf0e10cSrcweir 	{
102cdf0e10cSrcweir 		aServiceNames.realloc( 1 );
103cdf0e10cSrcweir 		aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.msforms.CheckBox" ) );
104cdf0e10cSrcweir 	}
105cdf0e10cSrcweir 	return aServiceNames;
106cdf0e10cSrcweir }
107cdf0e10cSrcweir 
108