LibreOffice Module vbahelper (master) 1
vbaradiobutton.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#include "vbaradiobutton.hxx"
21#include "vbanewfont.hxx"
22
23using namespace com::sun::star;
24using namespace ooo::vba;
25
26ScVbaRadioButton::ScVbaRadioButton( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< uno::XInterface >& xControl, const uno::Reference< frame::XModel >& xModel, std::unique_ptr<ov::AbstractGeometryAttributes> pGeomHelper )
27 : RadioButtonImpl_BASE( xParent, xContext, xControl, xModel, std::move(pGeomHelper) )
28{
29}
30
31// Attributes
32OUString SAL_CALL
34{
35 OUString Label;
36 m_xProps->getPropertyValue( "Label" ) >>= Label;
37 return Label;
38}
39
40void SAL_CALL
41ScVbaRadioButton::setCaption( const OUString& _caption )
42{
43 m_xProps->setPropertyValue( "Label", uno::Any( _caption ) );
44}
45
46uno::Any SAL_CALL
48{
49 sal_Int16 nValue = -1;
50 m_xProps->getPropertyValue( "State" ) >>= nValue;
51 if( nValue != 0 )
52 nValue = -1;
53// return uno::makeAny( nValue );
54// I must be missing something MSO says value should be -1 if selected, 0 if not
55// selected
56 return uno::Any( nValue == -1 );
57
58}
59
60void SAL_CALL
62{
63 sal_Int16 nValue = 0;
64 sal_Int16 nOldValue = 0;
65 m_xProps->getPropertyValue( "State" ) >>= nOldValue;
66
67 if( !( _value >>= nValue ) )
68 {
69 bool bValue = false;
70 _value >>= bValue;
71 if ( bValue )
72 nValue = -1;
73 }
74
75 if( nValue == -1)
76 nValue = 1;
77 m_xProps->setPropertyValue( "State", uno::Any( nValue ) );
78 if ( nValue != nOldValue )
79 {
80 fireChangeEvent();
81 // In Excel, only when the radio button is checked, the click event is fired.
82 if ( nValue != 0 )
83 {
84 fireClickEvent();
85 }
86 }
87}
88
89uno::Reference< msforms::XNewFont > SAL_CALL ScVbaRadioButton::getFont()
90{
91 return new VbaNewFont( m_xProps );
92}
93
94OUString
96{
97 return "ScVbaRadioButton";
98}
99
100uno::Sequence< OUString >
102{
103 static uno::Sequence< OUString > const aServiceNames
104 {
105 "ooo.vba.msforms.RadioButton"
106 };
107 return aServiceNames;
108}
109
110/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Reference< XPropertySet > m_xProps
virtual css::uno::Sequence< OUString > getServiceNames() override
virtual OUString getServiceImplName() override
virtual css::uno::Reference< ov::msforms::XNewFont > SAL_CALL getFont() override
virtual void SAL_CALL setValue(const css::uno::Any &) override
virtual css::uno::Any SAL_CALL getValue() override
virtual OUString SAL_CALL getCaption() override
ScVbaRadioButton(const css::uno::Reference< ov::XHelperInterface > &xParent, const css::uno::Reference< css::uno::XComponentContext > &xContext, const css::uno::Reference< css::uno::XInterface > &xControl, const css::uno::Reference< css::frame::XModel > &xModel, std::unique_ptr< ov::AbstractGeometryAttributes > pGeomHelper)
virtual void SAL_CALL setCaption(const OUString &_caption) override
Sequence< OUString > aServiceNames
sal_Int16 nValue
Reference< XModel > xModel
cppu::ImplInheritanceHelper< ScVbaControl, ov::msforms::XRadioButton, css::script::XDefaultProperty > RadioButtonImpl_BASE