Line data Source code
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 : #include <vbahelper/helperdecl.hxx>
23 :
24 : using namespace com::sun::star;
25 : using namespace ooo::vba;
26 :
27 32 : 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, ov::AbstractGeometryAttributes* pGeomHelper ) : CheckBoxImpl_BASE( xParent, xContext, xControl, xModel, pGeomHelper )
28 : {
29 32 : }
30 :
31 : // Attributes
32 : OUString SAL_CALL
33 0 : ScVbaCheckbox::getCaption() throw (css::uno::RuntimeException, std::exception)
34 : {
35 0 : OUString Label;
36 0 : m_xProps->getPropertyValue( "Label" ) >>= Label;
37 0 : return Label;
38 : }
39 :
40 : void SAL_CALL
41 0 : ScVbaCheckbox::setCaption( const OUString& _caption ) throw (::com::sun::star::uno::RuntimeException, std::exception)
42 : {
43 0 : m_xProps->setPropertyValue( "Label", uno::makeAny( _caption ) );
44 0 : }
45 :
46 : uno::Any SAL_CALL
47 32 : ScVbaCheckbox::getValue() throw (css::uno::RuntimeException, std::exception)
48 : {
49 32 : sal_Int16 nValue = -1;
50 32 : m_xProps->getPropertyValue( "State" ) >>= nValue;
51 32 : if( nValue != 0 )
52 12 : 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 32 : return uno::makeAny( ( nValue == -1 ) ? sal_True : sal_False );
57 : }
58 :
59 : void SAL_CALL
60 16 : ScVbaCheckbox::setValue( const uno::Any& _value ) throw (css::uno::RuntimeException, std::exception)
61 : {
62 16 : sal_Int16 nValue = 0;
63 16 : sal_Int16 nOldValue = 0;
64 16 : m_xProps->getPropertyValue( "State" ) >>= nOldValue;
65 16 : if( !( _value >>= nValue ) )
66 : {
67 8 : bool bValue = false;
68 8 : _value >>= bValue;
69 8 : if ( bValue )
70 4 : nValue = -1;
71 : }
72 :
73 16 : if( nValue == -1)
74 8 : nValue = 1;
75 16 : m_xProps->setPropertyValue( "State", uno::makeAny( nValue ) );
76 16 : if ( nValue != nOldValue )
77 12 : fireClickEvent();
78 16 : }
79 :
80 0 : uno::Reference< msforms::XNewFont > SAL_CALL ScVbaCheckbox::getFont() throw (uno::RuntimeException, std::exception)
81 : {
82 0 : return new VbaNewFont( m_xProps );
83 : }
84 :
85 : OUString
86 0 : ScVbaCheckbox::getServiceImplName()
87 : {
88 0 : return OUString("ScVbaCheckbox");
89 : }
90 :
91 : uno::Sequence< OUString >
92 0 : ScVbaCheckbox::getServiceNames()
93 : {
94 0 : static uno::Sequence< OUString > aServiceNames;
95 0 : if ( aServiceNames.getLength() == 0 )
96 : {
97 0 : aServiceNames.realloc( 1 );
98 0 : aServiceNames[ 0 ] = "ooo.vba.msforms.CheckBox";
99 : }
100 0 : return aServiceNames;
101 : }
102 :
103 0 : sal_Int32 SAL_CALL ScVbaCheckbox::getBackColor() throw (uno::RuntimeException, std::exception)
104 : {
105 0 : return ScVbaControl::getBackColor();
106 : }
107 :
108 0 : void SAL_CALL ScVbaCheckbox::setBackColor( sal_Int32 nBackColor ) throw (uno::RuntimeException, std::exception)
109 : {
110 0 : ScVbaControl::setBackColor( nBackColor );
111 0 : }
112 :
113 0 : sal_Bool SAL_CALL ScVbaCheckbox::getAutoSize() throw (uno::RuntimeException, std::exception)
114 : {
115 0 : return ScVbaControl::getAutoSize();
116 : }
117 :
118 0 : void SAL_CALL ScVbaCheckbox::setAutoSize( sal_Bool bAutoSize ) throw (uno::RuntimeException, std::exception)
119 : {
120 0 : ScVbaControl::setAutoSize( bAutoSize );
121 0 : }
122 :
123 0 : sal_Bool SAL_CALL ScVbaCheckbox::getLocked() throw (uno::RuntimeException, std::exception)
124 : {
125 0 : return ScVbaControl::getLocked();
126 : }
127 :
128 0 : void SAL_CALL ScVbaCheckbox::setLocked( sal_Bool bLocked ) throw (uno::RuntimeException, std::exception)
129 : {
130 0 : ScVbaControl::setLocked( bLocked );
131 6 : }
132 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|