1*e6ed5fbcSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*e6ed5fbcSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*e6ed5fbcSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*e6ed5fbcSAndrew Rist * distributed with this work for additional information 6*e6ed5fbcSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*e6ed5fbcSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*e6ed5fbcSAndrew Rist * "License"); you may not use this file except in compliance 9*e6ed5fbcSAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*e6ed5fbcSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*e6ed5fbcSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*e6ed5fbcSAndrew Rist * software distributed under the License is distributed on an 15*e6ed5fbcSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*e6ed5fbcSAndrew Rist * KIND, either express or implied. See the License for the 17*e6ed5fbcSAndrew Rist * specific language governing permissions and limitations 18*e6ed5fbcSAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*e6ed5fbcSAndrew Rist *************************************************************/ 21*e6ed5fbcSAndrew Rist 22*e6ed5fbcSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #include "vbatogglebutton.hxx" 25cdf0e10cSrcweir #include "vbanewfont.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir using namespace com::sun::star; 28cdf0e10cSrcweir using namespace ooo::vba; 29cdf0e10cSrcweir 30cdf0e10cSrcweir 31cdf0e10cSrcweir const static rtl::OUString LABEL( RTL_CONSTASCII_USTRINGPARAM("Label") ); 32cdf0e10cSrcweir const static rtl::OUString TOGGLE( RTL_CONSTASCII_USTRINGPARAM("Toggle") ); 33cdf0e10cSrcweir const static rtl::OUString STATE( RTL_CONSTASCII_USTRINGPARAM("State") ); 34cdf0e10cSrcweir 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 ) 35cdf0e10cSrcweir { 36cdf0e10cSrcweir OSL_TRACE("ScVbaToggleButton(ctor)"); 37cdf0e10cSrcweir m_xProps->setPropertyValue( TOGGLE, uno::makeAny( sal_True ) ); 38cdf0e10cSrcweir } 39cdf0e10cSrcweir 40cdf0e10cSrcweir ScVbaToggleButton::~ScVbaToggleButton() 41cdf0e10cSrcweir { 42cdf0e10cSrcweir OSL_TRACE("~ScVbaToggleButton(dtor)"); 43cdf0e10cSrcweir } 44cdf0e10cSrcweir 45cdf0e10cSrcweir // Attributes 46cdf0e10cSrcweir rtl::OUString SAL_CALL 47cdf0e10cSrcweir ScVbaToggleButton::getCaption() throw (css::uno::RuntimeException) 48cdf0e10cSrcweir { 49cdf0e10cSrcweir rtl::OUString Label; 50cdf0e10cSrcweir m_xProps->getPropertyValue( LABEL ) >>= Label; 51cdf0e10cSrcweir return Label; 52cdf0e10cSrcweir } 53cdf0e10cSrcweir 54cdf0e10cSrcweir void SAL_CALL 55cdf0e10cSrcweir ScVbaToggleButton::setCaption( const rtl::OUString& _caption ) throw (::com::sun::star::uno::RuntimeException) 56cdf0e10cSrcweir { 57cdf0e10cSrcweir m_xProps->setPropertyValue( LABEL, uno::makeAny( _caption ) ); 58cdf0e10cSrcweir } 59cdf0e10cSrcweir 60cdf0e10cSrcweir uno::Any SAL_CALL 61cdf0e10cSrcweir ScVbaToggleButton::getValue() throw (uno::RuntimeException) 62cdf0e10cSrcweir { 63cdf0e10cSrcweir sal_Int16 nState = 0; 64cdf0e10cSrcweir m_xProps->getPropertyValue( STATE ) >>= nState; 65cdf0e10cSrcweir return uno::makeAny( nState ? sal_Int16( -1 ) : sal_Int16( 0 ) ); 66cdf0e10cSrcweir } 67cdf0e10cSrcweir 68cdf0e10cSrcweir void SAL_CALL 69cdf0e10cSrcweir ScVbaToggleButton::setValue( const uno::Any& _value ) throw (uno::RuntimeException) 70cdf0e10cSrcweir { 71cdf0e10cSrcweir sal_Int16 nState = 0; 72cdf0e10cSrcweir _value >>= nState; 73cdf0e10cSrcweir OSL_TRACE( "nState - %d", nState ); 74cdf0e10cSrcweir nState = ( nState == -1 ) ? 1 : 0; 75cdf0e10cSrcweir OSL_TRACE( "nState - %d", nState ); 76cdf0e10cSrcweir m_xProps->setPropertyValue( STATE, uno::makeAny( nState ) ); 77cdf0e10cSrcweir } 78cdf0e10cSrcweir 79cdf0e10cSrcweir sal_Bool SAL_CALL ScVbaToggleButton::getAutoSize() throw (uno::RuntimeException) 80cdf0e10cSrcweir { 81cdf0e10cSrcweir return sal_False; 82cdf0e10cSrcweir } 83cdf0e10cSrcweir 84cdf0e10cSrcweir void SAL_CALL ScVbaToggleButton::setAutoSize( sal_Bool /*bAutoSize*/ ) throw (uno::RuntimeException) 85cdf0e10cSrcweir { 86cdf0e10cSrcweir } 87cdf0e10cSrcweir 88cdf0e10cSrcweir sal_Bool SAL_CALL ScVbaToggleButton::getCancel() throw (uno::RuntimeException) 89cdf0e10cSrcweir { 90cdf0e10cSrcweir return sal_False; 91cdf0e10cSrcweir } 92cdf0e10cSrcweir 93cdf0e10cSrcweir void SAL_CALL ScVbaToggleButton::setCancel( sal_Bool /*bCancel*/ ) throw (uno::RuntimeException) 94cdf0e10cSrcweir { 95cdf0e10cSrcweir } 96cdf0e10cSrcweir 97cdf0e10cSrcweir sal_Bool SAL_CALL ScVbaToggleButton::getDefault() throw (uno::RuntimeException) 98cdf0e10cSrcweir { 99cdf0e10cSrcweir return sal_False; 100cdf0e10cSrcweir } 101cdf0e10cSrcweir 102cdf0e10cSrcweir void SAL_CALL ScVbaToggleButton::setDefault( sal_Bool /*bDefault*/ ) throw (uno::RuntimeException) 103cdf0e10cSrcweir { 104cdf0e10cSrcweir } 105cdf0e10cSrcweir 106cdf0e10cSrcweir sal_Int32 SAL_CALL ScVbaToggleButton::getBackColor() throw (uno::RuntimeException) 107cdf0e10cSrcweir { 108cdf0e10cSrcweir return 0; 109cdf0e10cSrcweir } 110cdf0e10cSrcweir 111cdf0e10cSrcweir void SAL_CALL ScVbaToggleButton::setBackColor( sal_Int32 /*nBackColor*/ ) throw (uno::RuntimeException) 112cdf0e10cSrcweir { 113cdf0e10cSrcweir } 114cdf0e10cSrcweir 115cdf0e10cSrcweir sal_Int32 SAL_CALL ScVbaToggleButton::getForeColor() throw (uno::RuntimeException) 116cdf0e10cSrcweir { 117cdf0e10cSrcweir return 0; 118cdf0e10cSrcweir } 119cdf0e10cSrcweir 120cdf0e10cSrcweir void SAL_CALL ScVbaToggleButton::setForeColor( sal_Int32 /*nForeColor*/ ) throw (uno::RuntimeException) 121cdf0e10cSrcweir { 122cdf0e10cSrcweir } 123cdf0e10cSrcweir 124cdf0e10cSrcweir uno::Reference< msforms::XNewFont > SAL_CALL ScVbaToggleButton::getFont() throw (uno::RuntimeException) 125cdf0e10cSrcweir { 126cdf0e10cSrcweir return new VbaNewFont( this, mxContext, m_xProps ); 127cdf0e10cSrcweir } 128cdf0e10cSrcweir 129cdf0e10cSrcweir rtl::OUString& 130cdf0e10cSrcweir ScVbaToggleButton::getServiceImplName() 131cdf0e10cSrcweir { 132cdf0e10cSrcweir static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaToggleButton") ); 133cdf0e10cSrcweir return sImplName; 134cdf0e10cSrcweir } 135cdf0e10cSrcweir 136cdf0e10cSrcweir uno::Sequence< rtl::OUString > 137cdf0e10cSrcweir ScVbaToggleButton::getServiceNames() 138cdf0e10cSrcweir { 139cdf0e10cSrcweir static uno::Sequence< rtl::OUString > aServiceNames; 140cdf0e10cSrcweir if ( aServiceNames.getLength() == 0 ) 141cdf0e10cSrcweir { 142cdf0e10cSrcweir aServiceNames.realloc( 1 ); 143cdf0e10cSrcweir aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.msforms.ToggleButton" ) ); 144cdf0e10cSrcweir } 145cdf0e10cSrcweir return aServiceNames; 146cdf0e10cSrcweir } 147cdf0e10cSrcweir 148