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 "vbaradiobutton.hxx"
25 #include "vbanewfont.hxx"
26
27 using namespace com::sun::star;
28 using namespace ooo::vba;
29
30
31 const static rtl::OUString LABEL( RTL_CONSTASCII_USTRINGPARAM("Label") );
32 const static rtl::OUString STATE( RTL_CONSTASCII_USTRINGPARAM("State") );
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)33 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 )
34 {
35 }
36
37 // Attributes
38 rtl::OUString SAL_CALL
getCaption()39 ScVbaRadioButton::getCaption() throw (css::uno::RuntimeException)
40 {
41 rtl::OUString Label;
42 m_xProps->getPropertyValue( LABEL ) >>= Label;
43 return Label;
44 }
45
46 void SAL_CALL
setCaption(const rtl::OUString & _caption)47 ScVbaRadioButton::setCaption( const rtl::OUString& _caption ) throw (::com::sun::star::uno::RuntimeException)
48 {
49 m_xProps->setPropertyValue( LABEL, uno::makeAny( _caption ) );
50 }
51
52 uno::Any SAL_CALL
getValue()53 ScVbaRadioButton::getValue() throw (css::uno::RuntimeException)
54 {
55 sal_Int16 nValue = -1;
56 m_xProps->getPropertyValue( STATE ) >>= nValue;
57 if( nValue != 0 )
58 nValue = -1;
59 // return uno::makeAny( nValue );
60 // I must be missing something MSO says value should be -1 if selected, 0 if not
61 // selected
62 return uno::makeAny( ( nValue == -1 ) ? sal_True : sal_False );
63
64 }
65
66 void SAL_CALL
setValue(const uno::Any & _value)67 ScVbaRadioButton::setValue( const uno::Any& _value ) throw (uno::RuntimeException)
68 {
69 sal_Int16 nValue = 0;
70 sal_Bool bValue = sal_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 ScVbaRadioButton::getFont() throw (uno::RuntimeException)
85 {
86 return new VbaNewFont( this, mxContext, m_xProps );
87 }
88
89 rtl::OUString&
getServiceImplName()90 ScVbaRadioButton::getServiceImplName()
91 {
92 static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaRadioButton") );
93 return sImplName;
94 }
95
96 uno::Sequence< rtl::OUString >
getServiceNames()97 ScVbaRadioButton::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.RadioButton" ) );
104 }
105 return aServiceNames;
106 }
107