Version 3.6.0.2, tag libreoffice-3.6.0.2
[LibreOffice.git] / vbahelper / source / msforms / vbatogglebutton.cxx
blob4406dbc188623758691922bb3da270dd331c60a0
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #include "vbatogglebutton.hxx"
30 #include "vbanewfont.hxx"
32 using namespace com::sun::star;
33 using namespace ooo::vba;
36 const static rtl::OUString LABEL( RTL_CONSTASCII_USTRINGPARAM("Label") );
37 const static rtl::OUString TOGGLE( RTL_CONSTASCII_USTRINGPARAM("Toggle") );
38 const static rtl::OUString STATE( RTL_CONSTASCII_USTRINGPARAM("State") );
39 ScVbaToggleButton::ScVbaToggleButton( const css::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 ) : ToggleButtonImpl_BASE( xParent, xContext, xControl, xModel, pGeomHelper )
41 OSL_TRACE("ScVbaToggleButton(ctor)");
42 m_xProps->setPropertyValue( TOGGLE, uno::makeAny( sal_True ) );
45 ScVbaToggleButton::~ScVbaToggleButton()
47 OSL_TRACE("~ScVbaToggleButton(dtor)");
50 // Attributes
51 rtl::OUString SAL_CALL
52 ScVbaToggleButton::getCaption() throw (css::uno::RuntimeException)
54 rtl::OUString Label;
55 m_xProps->getPropertyValue( LABEL ) >>= Label;
56 return Label;
59 void SAL_CALL
60 ScVbaToggleButton::setCaption( const rtl::OUString& _caption ) throw (::com::sun::star::uno::RuntimeException)
62 m_xProps->setPropertyValue( LABEL, uno::makeAny( _caption ) );
65 uno::Any SAL_CALL
66 ScVbaToggleButton::getValue() throw (uno::RuntimeException)
68 sal_Int16 nState = 0;
69 m_xProps->getPropertyValue( STATE ) >>= nState;
70 return uno::makeAny( nState ? sal_Int16( -1 ) : sal_Int16( 0 ) );
74 void SAL_CALL
75 ScVbaToggleButton::setValue( const uno::Any& _value ) throw (uno::RuntimeException)
77 sal_Int16 nState = 0;
78 if (_value.getValueTypeClass() == uno::TypeClass_BOOLEAN)
80 sal_Bool bValue;
81 _value >>= bValue;
82 nState = static_cast< sal_Int16 >(bValue);
84 else if (_value.getValueTypeClass() == uno::TypeClass_BYTE)
86 sal_Int8 nValue;
87 _value >>= nValue;
88 nState = ( nValue == 1) ? 1 : 0;
90 else
92 _value >>= nState;
93 OSL_TRACE( "nState - %d", nState );
94 nState = ( nState == -1 ) ? 1 : 0;
95 OSL_TRACE( "nState - %d", nState );
97 m_xProps->setPropertyValue( STATE, uno::makeAny( nState ) );
100 sal_Bool SAL_CALL ScVbaToggleButton::getAutoSize() throw (uno::RuntimeException)
102 return ScVbaControl::getAutoSize();
105 void SAL_CALL ScVbaToggleButton::setAutoSize( sal_Bool bAutoSize ) throw (uno::RuntimeException)
107 ScVbaControl::setAutoSize( bAutoSize );
110 sal_Bool SAL_CALL ScVbaToggleButton::getCancel() throw (uno::RuntimeException)
112 return sal_False;
115 void SAL_CALL ScVbaToggleButton::setCancel( sal_Bool /*bCancel*/ ) throw (uno::RuntimeException)
119 sal_Bool SAL_CALL ScVbaToggleButton::getDefault() throw (uno::RuntimeException)
121 return sal_False;
124 void SAL_CALL ScVbaToggleButton::setDefault( sal_Bool /*bDefault*/ ) throw (uno::RuntimeException)
128 sal_Int32 SAL_CALL ScVbaToggleButton::getBackColor() throw (uno::RuntimeException)
130 return ScVbaControl::getBackColor();
133 void SAL_CALL ScVbaToggleButton::setBackColor( sal_Int32 nBackColor ) throw (uno::RuntimeException)
135 ScVbaControl::setBackColor( nBackColor );
138 sal_Int32 SAL_CALL ScVbaToggleButton::getForeColor() throw (uno::RuntimeException)
140 return 0;
143 void SAL_CALL ScVbaToggleButton::setForeColor( sal_Int32 /*nForeColor*/ ) throw (uno::RuntimeException)
147 uno::Reference< msforms::XNewFont > SAL_CALL ScVbaToggleButton::getFont() throw (uno::RuntimeException)
149 return new VbaNewFont( this, mxContext, m_xProps );
152 sal_Bool SAL_CALL ScVbaToggleButton::getLocked() throw (uno::RuntimeException)
154 return ScVbaControl::getLocked();
157 void SAL_CALL ScVbaToggleButton::setLocked( sal_Bool bLocked ) throw (uno::RuntimeException)
159 ScVbaControl::setLocked( bLocked );
162 rtl::OUString
163 ScVbaToggleButton::getServiceImplName()
165 return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ScVbaToggleButton"));
168 uno::Sequence< rtl::OUString >
169 ScVbaToggleButton::getServiceNames()
171 static uno::Sequence< rtl::OUString > aServiceNames;
172 if ( aServiceNames.getLength() == 0 )
174 aServiceNames.realloc( 1 );
175 aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.msforms.ToggleButton" ) );
177 return aServiceNames;
180 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */