1 /*************************************************************************
3 * OpenOffice.org - a multi-platform office productivity suite
9 * last change: $Author$ $Date$
11 * The Contents of this file are made available subject to
12 * the terms of GNU Lesser General Public License Version 2.1.
15 * GNU Lesser General Public License Version 2.1
16 * =============================================
17 * Copyright 2005 by Sun Microsystems, Inc.
18 * 901 San Antonio Road, Palo Alto, CA 94303, USA
20 * This library is free software; you can redistribute it and/or
21 * modify it under the terms of the GNU Lesser General Public
22 * License version 2.1, as published by the Free Software Foundation.
24 * This library is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
27 * Lesser General Public License for more details.
29 * You should have received a copy of the GNU Lesser General Public
30 * License along with this library; if not, write to the Free Software
31 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
34 ************************************************************************/
35 #include "vbatogglebutton.hxx"
38 using namespace com::sun::star
;
39 using namespace ooo::vba
;
42 const static rtl::OUString
LABEL( RTL_CONSTASCII_USTRINGPARAM("Label") );
43 const static rtl::OUString
TOGGLE( RTL_CONSTASCII_USTRINGPARAM("Toggle") );
44 const static rtl::OUString
STATE( RTL_CONSTASCII_USTRINGPARAM("State") );
45 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
)
47 OSL_TRACE("ScVbaToggleButton(ctor)");
48 m_xProps
->setPropertyValue( TOGGLE
, uno::makeAny( sal_True
) );
51 ScVbaToggleButton::~ScVbaToggleButton()
53 OSL_TRACE("~ScVbaToggleButton(dtor)");
57 rtl::OUString SAL_CALL
58 ScVbaToggleButton::getCaption() throw (css::uno::RuntimeException
)
61 m_xProps
->getPropertyValue( LABEL
) >>= Label
;
66 ScVbaToggleButton::setCaption( const rtl::OUString
& _caption
) throw (::com::sun::star::uno::RuntimeException
)
68 m_xProps
->setPropertyValue( LABEL
, uno::makeAny( _caption
) );
72 ScVbaToggleButton::getValue() throw (uno::RuntimeException
)
75 m_xProps
->getPropertyValue( STATE
) >>= nState
;
76 return uno::makeAny( nState
? sal_Int16( -1 ) : sal_Int16( 0 ) );
79 //liuchen 2009-7-23, resolve the defect that ToggleButton.Value cannot be set correctly
81 ScVbaToggleButton::setValue( const uno::Any
& _value
) throw (uno::RuntimeException
)
84 if (_value
.getValueTypeClass() == typelib_TypeClass_BOOLEAN
)
88 nState
= static_cast< sal_Int16
>(bValue
);
90 else if (_value
.getValueTypeClass() == typelib_TypeClass_BYTE
)
94 nState
= ( nValue
== 1) ? 1 : 0;
99 OSL_TRACE( "nState - %d", nState
);
100 nState
= ( nState
== -1 ) ? 1 : 0;
101 OSL_TRACE( "nState - %d", nState
);
103 m_xProps
->setPropertyValue( STATE
, uno::makeAny( nState
) );
108 ScVbaToggleButton::getServiceImplName()
110 static rtl::OUString
sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaToggleButton") );
114 uno::Sequence
< rtl::OUString
>
115 ScVbaToggleButton::getServiceNames()
117 static uno::Sequence
< rtl::OUString
> aServiceNames
;
118 if ( aServiceNames
.getLength() == 0 )
120 aServiceNames
.realloc( 1 );
121 aServiceNames
[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.msforms.ToggleButton" ) );
123 return aServiceNames
;