tdf#130857 qt weld: Implement QtInstanceWidget::get_text_height
[LibreOffice.git] / vbahelper / source / msforms / vbacheckbox.cxx
blob9069fdfe880287d5d50737e81d4aae7fe6b237f2
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"
23 using namespace com::sun::star;
24 using namespace ooo::vba;
26 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 )
27 : CheckBoxImpl_BASE( xParent, xContext, xControl, xModel, std::move(pGeomHelper) )
31 // Attributes
32 OUString SAL_CALL
33 ScVbaCheckbox::getCaption()
35 OUString Label;
36 m_xProps->getPropertyValue( u"Label"_ustr ) >>= Label;
37 return Label;
40 void SAL_CALL
41 ScVbaCheckbox::setCaption( const OUString& _caption )
43 m_xProps->setPropertyValue( u"Label"_ustr, uno::Any( _caption ) );
46 uno::Any SAL_CALL
47 ScVbaCheckbox::getValue()
49 sal_Int16 nValue = -1;
50 m_xProps->getPropertyValue( u"State"_ustr ) >>= 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 );
59 void SAL_CALL
60 ScVbaCheckbox::setValue( const uno::Any& _value )
62 sal_Int16 nValue = 0;
63 sal_Int16 nOldValue = 0;
64 m_xProps->getPropertyValue( u"State"_ustr ) >>= nOldValue;
65 if( !( _value >>= nValue ) )
67 bool bValue = false;
68 _value >>= bValue;
69 if ( bValue )
70 nValue = -1;
73 if( nValue == -1)
74 nValue = 1;
75 m_xProps->setPropertyValue( u"State"_ustr, uno::Any( nValue ) );
76 if ( nValue != nOldValue )
77 fireClickEvent();
80 uno::Reference< msforms::XNewFont > SAL_CALL ScVbaCheckbox::getFont()
82 return new VbaNewFont( m_xProps );
85 OUString
86 ScVbaCheckbox::getServiceImplName()
88 return u"ScVbaCheckbox"_ustr;
91 uno::Sequence< OUString >
92 ScVbaCheckbox::getServiceNames()
94 static uno::Sequence< OUString > const aServiceNames
96 u"ooo.vba.msforms.CheckBox"_ustr
98 return aServiceNames;
101 sal_Int32 SAL_CALL ScVbaCheckbox::getBackColor()
103 return ScVbaControl::getBackColor();
106 void SAL_CALL ScVbaCheckbox::setBackColor( sal_Int32 nBackColor )
108 ScVbaControl::setBackColor( nBackColor );
111 sal_Bool SAL_CALL ScVbaCheckbox::getAutoSize()
113 return ScVbaControl::getAutoSize();
116 void SAL_CALL ScVbaCheckbox::setAutoSize( sal_Bool bAutoSize )
118 ScVbaControl::setAutoSize( bAutoSize );
121 sal_Bool SAL_CALL ScVbaCheckbox::getLocked()
123 return ScVbaControl::getLocked();
126 void SAL_CALL ScVbaCheckbox::setLocked( sal_Bool bLocked )
128 ScVbaControl::setLocked( bLocked );
130 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */