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