Version 4.0.0.1, tag libreoffice-4.0.0.1
[LibreOffice.git] / vbahelper / source / msforms / vbacheckbox.cxx
blobde32e34abe5d4fb88f9ea7a928ec7d9c8ee041e6
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;
28 const static OUString LABEL( "Label" );
29 const static OUString STATE( "State" );
30 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 )
34 // Attributes
35 OUString SAL_CALL
36 ScVbaCheckbox::getCaption() throw (css::uno::RuntimeException)
38 OUString Label;
39 m_xProps->getPropertyValue( LABEL ) >>= Label;
40 return Label;
43 void SAL_CALL
44 ScVbaCheckbox::setCaption( const OUString& _caption ) throw (::com::sun::star::uno::RuntimeException)
46 m_xProps->setPropertyValue( LABEL, uno::makeAny( _caption ) );
49 uno::Any SAL_CALL
50 ScVbaCheckbox::getValue() throw (css::uno::RuntimeException)
52 sal_Int16 nValue = -1;
53 m_xProps->getPropertyValue( STATE ) >>= nValue;
54 if( nValue != 0 )
55 nValue = -1;
56 // return uno::makeAny( nValue );
57 // I must be missing something MSO says value should be -1 if selected, 0 if not
58 // selected
59 return uno::makeAny( ( nValue == -1 ) ? sal_True : sal_False );
62 void SAL_CALL
63 ScVbaCheckbox::setValue( const uno::Any& _value ) throw (css::uno::RuntimeException)
65 sal_Int16 nValue = 0;
66 sal_Int16 nOldValue = 0;
67 m_xProps->getPropertyValue( STATE ) >>= nOldValue;
68 sal_Bool bValue = false;
69 if( _value >>= nValue )
71 if( nValue == -1)
72 nValue = 1;
74 else if ( _value >>= bValue )
76 if ( bValue )
77 nValue = 1;
79 m_xProps->setPropertyValue( STATE, uno::makeAny( nValue ) );
80 if ( nValue != nOldValue )
81 fireClickEvent();
84 uno::Reference< msforms::XNewFont > SAL_CALL ScVbaCheckbox::getFont() throw (uno::RuntimeException)
86 return new VbaNewFont( this, mxContext, m_xProps );
89 OUString
90 ScVbaCheckbox::getServiceImplName()
92 return OUString("ScVbaCheckbox");
95 uno::Sequence< OUString >
96 ScVbaCheckbox::getServiceNames()
98 static uno::Sequence< OUString > aServiceNames;
99 if ( aServiceNames.getLength() == 0 )
101 aServiceNames.realloc( 1 );
102 aServiceNames[ 0 ] = "ooo.vba.msforms.CheckBox";
104 return aServiceNames;
107 sal_Int32 SAL_CALL ScVbaCheckbox::getBackColor() throw (uno::RuntimeException)
109 return ScVbaControl::getBackColor();
112 void SAL_CALL ScVbaCheckbox::setBackColor( sal_Int32 nBackColor ) throw (uno::RuntimeException)
114 ScVbaControl::setBackColor( nBackColor );
117 sal_Bool SAL_CALL ScVbaCheckbox::getAutoSize() throw (uno::RuntimeException)
119 return ScVbaControl::getAutoSize();
122 void SAL_CALL ScVbaCheckbox::setAutoSize( sal_Bool bAutoSize ) throw (uno::RuntimeException)
124 ScVbaControl::setAutoSize( bAutoSize );
127 sal_Bool SAL_CALL ScVbaCheckbox::getLocked() throw (uno::RuntimeException)
129 return ScVbaControl::getLocked();
132 void SAL_CALL ScVbaCheckbox::setLocked( sal_Bool bLocked ) throw (uno::RuntimeException)
134 ScVbaControl::setLocked( bLocked );
136 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */