bump product version to 6.3.0.0.beta1
[LibreOffice.git] / vbahelper / source / msforms / vbacheckbox.cxx
blob719fd318369638918ea42212b4301e08fac9903a
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 "vbacheckbox.hxx"
21 #include "vbanewfont.hxx"
22 #include <vbahelper/helperdecl.hxx>
24 using namespace com::sun::star;
25 using namespace ooo::vba;
27 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, std::unique_ptr<ov::AbstractGeometryAttributes> pGeomHelper )
28 : CheckBoxImpl_BASE( xParent, xContext, xControl, xModel, std::move(pGeomHelper) )
32 // Attributes
33 OUString SAL_CALL
34 ScVbaCheckbox::getCaption()
36 OUString Label;
37 m_xProps->getPropertyValue( "Label" ) >>= Label;
38 return Label;
41 void SAL_CALL
42 ScVbaCheckbox::setCaption( const OUString& _caption )
44 m_xProps->setPropertyValue( "Label", uno::makeAny( _caption ) );
47 uno::Any SAL_CALL
48 ScVbaCheckbox::getValue()
50 sal_Int16 nValue = -1;
51 m_xProps->getPropertyValue( "State" ) >>= nValue;
52 if( nValue != 0 )
53 nValue = -1;
54 // return uno::makeAny( nValue );
55 // I must be missing something MSO says value should be -1 if selected, 0 if not
56 // selected
57 return uno::makeAny( nValue == -1 );
60 void SAL_CALL
61 ScVbaCheckbox::setValue( const uno::Any& _value )
63 sal_Int16 nValue = 0;
64 sal_Int16 nOldValue = 0;
65 m_xProps->getPropertyValue( "State" ) >>= nOldValue;
66 if( !( _value >>= nValue ) )
68 bool bValue = false;
69 _value >>= bValue;
70 if ( bValue )
71 nValue = -1;
74 if( nValue == -1)
75 nValue = 1;
76 m_xProps->setPropertyValue( "State", uno::makeAny( nValue ) );
77 if ( nValue != nOldValue )
78 fireClickEvent();
81 uno::Reference< msforms::XNewFont > SAL_CALL ScVbaCheckbox::getFont()
83 return new VbaNewFont( m_xProps );
86 OUString
87 ScVbaCheckbox::getServiceImplName()
89 return OUString("ScVbaCheckbox");
92 uno::Sequence< OUString >
93 ScVbaCheckbox::getServiceNames()
95 static uno::Sequence< OUString > const aServiceNames
97 "ooo.vba.msforms.CheckBox"
99 return aServiceNames;
102 sal_Int32 SAL_CALL ScVbaCheckbox::getBackColor()
104 return ScVbaControl::getBackColor();
107 void SAL_CALL ScVbaCheckbox::setBackColor( sal_Int32 nBackColor )
109 ScVbaControl::setBackColor( nBackColor );
112 sal_Bool SAL_CALL ScVbaCheckbox::getAutoSize()
114 return ScVbaControl::getAutoSize();
117 void SAL_CALL ScVbaCheckbox::setAutoSize( sal_Bool bAutoSize )
119 ScVbaControl::setAutoSize( bAutoSize );
122 sal_Bool SAL_CALL ScVbaCheckbox::getLocked()
124 return ScVbaControl::getLocked();
127 void SAL_CALL ScVbaCheckbox::setLocked( sal_Bool bLocked )
129 ScVbaControl::setLocked( bLocked );
131 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */