1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "vbaradiobutton.hxx"
21 #include "vbanewfont.hxx"
23 using namespace com::sun::star
;
24 using namespace ooo::vba
;
26 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
)
32 ScVbaRadioButton::getCaption() throw (css::uno::RuntimeException
, std::exception
)
35 m_xProps
->getPropertyValue( "Label" ) >>= Label
;
40 ScVbaRadioButton::setCaption( const OUString
& _caption
) throw (::com::sun::star::uno::RuntimeException
, std::exception
)
42 m_xProps
->setPropertyValue( "Label", uno::makeAny( _caption
) );
46 ScVbaRadioButton::getValue() throw (css::uno::RuntimeException
, std::exception
)
48 sal_Int16 nValue
= -1;
49 m_xProps
->getPropertyValue( "State" ) >>= nValue
;
52 // return uno::makeAny( nValue );
53 // I must be missing something MSO says value should be -1 if selected, 0 if not
55 return uno::makeAny( ( nValue
== -1 ) ? sal_True
: sal_False
);
60 ScVbaRadioButton::setValue( const uno::Any
& _value
) throw (uno::RuntimeException
, std::exception
)
63 sal_Int16 nOldValue
= 0;
64 m_xProps
->getPropertyValue( "State" ) >>= nOldValue
;
66 if( !( _value
>>= nValue
) )
76 m_xProps
->setPropertyValue( "State", uno::makeAny( nValue
) );
77 if ( nValue
!= nOldValue
)
80 // In Excel, only when the radio button is checked, the click event is fired.
88 uno::Reference
< msforms::XNewFont
> SAL_CALL
ScVbaRadioButton::getFont() throw (uno::RuntimeException
, std::exception
)
90 return new VbaNewFont( m_xProps
);
94 ScVbaRadioButton::getServiceImplName()
96 return OUString( "ScVbaRadioButton" );
99 uno::Sequence
< OUString
>
100 ScVbaRadioButton::getServiceNames()
102 static uno::Sequence
< OUString
> aServiceNames
;
103 if ( aServiceNames
.getLength() == 0 )
105 aServiceNames
.realloc( 1 );
106 aServiceNames
[ 0 ] = "ooo.vba.msforms.RadioButton";
108 return aServiceNames
;
111 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */