merged tag ooo/OOO330_m14
[LibreOffice.git] / vbahelper / source / msforms / vbatogglebutton.cxx
blob071651ff8a361780059a21d5e6b12aa815fda060
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
27 #include "vbatogglebutton.hxx"
28 #include <vector>
30 using namespace com::sun::star;
31 using namespace ooo::vba;
34 const static rtl::OUString LABEL( RTL_CONSTASCII_USTRINGPARAM("Label") );
35 const static rtl::OUString TOGGLE( RTL_CONSTASCII_USTRINGPARAM("Toggle") );
36 const static rtl::OUString STATE( RTL_CONSTASCII_USTRINGPARAM("State") );
37 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 )
39 OSL_TRACE("ScVbaToggleButton(ctor)");
40 m_xProps->setPropertyValue( TOGGLE, uno::makeAny( sal_True ) );
43 ScVbaToggleButton::~ScVbaToggleButton()
45 OSL_TRACE("~ScVbaToggleButton(dtor)");
48 // Attributes
49 rtl::OUString SAL_CALL
50 ScVbaToggleButton::getCaption() throw (css::uno::RuntimeException)
52 rtl::OUString Label;
53 m_xProps->getPropertyValue( LABEL ) >>= Label;
54 return Label;
57 void SAL_CALL
58 ScVbaToggleButton::setCaption( const rtl::OUString& _caption ) throw (::com::sun::star::uno::RuntimeException)
60 m_xProps->setPropertyValue( LABEL, uno::makeAny( _caption ) );
63 uno::Any SAL_CALL
64 ScVbaToggleButton::getValue() throw (uno::RuntimeException)
66 sal_Int16 nState = 0;
67 m_xProps->getPropertyValue( STATE ) >>= nState;
68 return uno::makeAny( nState ? sal_Int16( -1 ) : sal_Int16( 0 ) );
71 void SAL_CALL
72 ScVbaToggleButton::setValue( const uno::Any& _value ) throw (uno::RuntimeException)
74 sal_Int16 nState = 0;
75 _value >>= nState;
76 OSL_TRACE( "nState - %d", nState );
77 nState = ( nState == -1 ) ? 1 : 0;
78 OSL_TRACE( "nState - %d", nState );
79 m_xProps->setPropertyValue( STATE, uno::makeAny( nState ) );
82 rtl::OUString&
83 ScVbaToggleButton::getServiceImplName()
85 static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaToggleButton") );
86 return sImplName;
89 uno::Sequence< rtl::OUString >
90 ScVbaToggleButton::getServiceNames()
92 static uno::Sequence< rtl::OUString > aServiceNames;
93 if ( aServiceNames.getLength() == 0 )
95 aServiceNames.realloc( 1 );
96 aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.msforms.ToggleButton" ) );
98 return aServiceNames;