LibreOffice Module vbahelper (master) 1
vbacheckbox.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 "vbacheckbox.hxx"
21#include "vbanewfont.hxx"
22
23using namespace com::sun::star;
24using namespace ooo::vba;
25
26ScVbaCheckbox::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) )
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
41ScVbaCheckbox::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
59void SAL_CALL
61{
62 sal_Int16 nValue = 0;
63 sal_Int16 nOldValue = 0;
64 m_xProps->getPropertyValue( "State" ) >>= nOldValue;
65 if( !( _value >>= nValue ) )
66 {
67 bool bValue = false;
68 _value >>= bValue;
69 if ( bValue )
70 nValue = -1;
71 }
72
73 if( nValue == -1)
74 nValue = 1;
75 m_xProps->setPropertyValue( "State", uno::Any( nValue ) );
76 if ( nValue != nOldValue )
77 fireClickEvent();
78}
79
80uno::Reference< msforms::XNewFont > SAL_CALL ScVbaCheckbox::getFont()
81{
82 return new VbaNewFont( m_xProps );
83}
84
85OUString
87{
88 return "ScVbaCheckbox";
89}
90
91uno::Sequence< OUString >
93{
94 static uno::Sequence< OUString > const aServiceNames
95 {
96 "ooo.vba.msforms.CheckBox"
97 };
98 return aServiceNames;
99}
100
101sal_Int32 SAL_CALL ScVbaCheckbox::getBackColor()
102{
104}
105
106void SAL_CALL ScVbaCheckbox::setBackColor( sal_Int32 nBackColor )
107{
108 ScVbaControl::setBackColor( nBackColor );
109}
110
112{
114}
115
116void SAL_CALL ScVbaCheckbox::setAutoSize( sal_Bool bAutoSize )
117{
118 ScVbaControl::setAutoSize( bAutoSize );
119}
120
122{
124}
125
126void SAL_CALL ScVbaCheckbox::setLocked( sal_Bool bLocked )
127{
128 ScVbaControl::setLocked( bLocked );
129}
130/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Reference< XPropertySet > m_xProps
virtual sal_Bool SAL_CALL getLocked() override
virtual void SAL_CALL setAutoSize(sal_Bool bAutoSize) override
virtual void SAL_CALL setLocked(sal_Bool bAutoSize) override
virtual OUString SAL_CALL getCaption() override
Definition: vbacheckbox.cxx:33
virtual css::uno::Sequence< OUString > getServiceNames() override
Definition: vbacheckbox.cxx:92
virtual void SAL_CALL setCaption(const OUString &_caption) override
Definition: vbacheckbox.cxx:41
virtual css::uno::Reference< ov::msforms::XNewFont > SAL_CALL getFont() override
Definition: vbacheckbox.cxx:80
virtual sal_Int32 SAL_CALL getBackColor() override
virtual void SAL_CALL setBackColor(sal_Int32 nBackColor) override
virtual OUString getServiceImplName() override
Definition: vbacheckbox.cxx:86
virtual sal_Bool SAL_CALL getAutoSize() override
virtual css::uno::Any SAL_CALL getValue() override
Definition: vbacheckbox.cxx:47
ScVbaCheckbox(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)
Definition: vbacheckbox.cxx:26
virtual void SAL_CALL setValue(const css::uno::Any &_value) override
Definition: vbacheckbox.cxx:60
bool getLocked()
Definition: vbacontrol.cxx:745
sal_Int32 getBackColor()
Definition: vbacontrol.cxx:708
bool getAutoSize() const
Definition: vbacontrol.cxx:726
void setAutoSize(bool bAutoSize)
Definition: vbacontrol.cxx:737
void setBackColor(sal_Int32 nBackColor)
Definition: vbacontrol.cxx:715
void setLocked(bool bAutoSize)
Definition: vbacontrol.cxx:752
Sequence< OUString > aServiceNames
sal_Int16 nValue
Reference< XModel > xModel
unsigned char sal_Bool
cppu::ImplInheritanceHelper< ScVbaControl, ov::msforms::XCheckBox, css::script::XDefaultProperty > CheckBoxImpl_BASE
Definition: vbacheckbox.hxx:28