Version 4.2.0.1, tag libreoffice-4.2.0.1
[LibreOffice.git] / vbahelper / source / msforms / vbatogglebutton.cxx
blobce9c007ea5adf8670e2a2241fed647c77f2b9420
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 "vbatogglebutton.hxx"
21 #include "vbanewfont.hxx"
23 using namespace com::sun::star;
24 using namespace ooo::vba;
27 const static OUString LABEL( "Label" );
28 const static OUString TOGGLE( "Toggle" );
29 const static OUString STATE( "State" );
30 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 )
32 SAL_INFO("vbahelper", "ScVbaToggleButton(ctor)");
33 m_xProps->setPropertyValue( TOGGLE, uno::makeAny( sal_True ) );
36 ScVbaToggleButton::~ScVbaToggleButton()
38 SAL_INFO("vbahelper", "~ScVbaToggleButton(dtor)");
41 // Attributes
42 OUString SAL_CALL
43 ScVbaToggleButton::getCaption() throw (css::uno::RuntimeException)
45 OUString Label;
46 m_xProps->getPropertyValue( LABEL ) >>= Label;
47 return Label;
50 void SAL_CALL
51 ScVbaToggleButton::setCaption( const OUString& _caption ) throw (::com::sun::star::uno::RuntimeException)
53 m_xProps->setPropertyValue( LABEL, uno::makeAny( _caption ) );
56 uno::Any SAL_CALL
57 ScVbaToggleButton::getValue() throw (uno::RuntimeException)
59 sal_Int16 nState = 0;
60 m_xProps->getPropertyValue( STATE ) >>= nState;
61 return uno::makeAny( nState ? sal_Int16( -1 ) : sal_Int16( 0 ) );
65 void SAL_CALL
66 ScVbaToggleButton::setValue( const uno::Any& _value ) throw (uno::RuntimeException)
68 sal_Int16 nState = 0;
69 if ( ! ( _value >>= nState ) )
71 sal_Bool bState = false;
72 _value >>= bState;
73 if ( bState )
74 nState = -1;
76 SAL_INFO("vbahelper", "nState - " << nState );
77 nState = ( nState == -1 ) ? 1 : 0;
78 SAL_INFO("vbahelper", "nState - " << nState );
79 m_xProps->setPropertyValue( STATE, uno::makeAny( nState ) );
82 sal_Bool SAL_CALL ScVbaToggleButton::getAutoSize() throw (uno::RuntimeException)
84 return ScVbaControl::getAutoSize();
87 void SAL_CALL ScVbaToggleButton::setAutoSize( sal_Bool bAutoSize ) throw (uno::RuntimeException)
89 ScVbaControl::setAutoSize( bAutoSize );
92 sal_Bool SAL_CALL ScVbaToggleButton::getCancel() throw (uno::RuntimeException)
94 // #STUB
95 return sal_False;
98 void SAL_CALL ScVbaToggleButton::setCancel( sal_Bool /*bCancel*/ ) throw (uno::RuntimeException)
100 // #STUB
103 sal_Bool SAL_CALL ScVbaToggleButton::getDefault() throw (uno::RuntimeException)
105 // #STUB
106 return sal_False;
109 void SAL_CALL ScVbaToggleButton::setDefault( sal_Bool /*bDefault*/ ) throw (uno::RuntimeException)
111 // #STUB
114 sal_Int32 SAL_CALL ScVbaToggleButton::getBackColor() throw (uno::RuntimeException)
116 return ScVbaControl::getBackColor();
119 void SAL_CALL ScVbaToggleButton::setBackColor( sal_Int32 nBackColor ) throw (uno::RuntimeException)
121 ScVbaControl::setBackColor( nBackColor );
124 sal_Int32 SAL_CALL ScVbaToggleButton::getForeColor() throw (uno::RuntimeException)
126 // #STUB
127 return 0;
130 void SAL_CALL ScVbaToggleButton::setForeColor( sal_Int32 /*nForeColor*/ ) throw (uno::RuntimeException)
132 // #STUB
135 uno::Reference< msforms::XNewFont > SAL_CALL ScVbaToggleButton::getFont() throw (uno::RuntimeException)
137 return new VbaNewFont( this, mxContext, m_xProps );
140 sal_Bool SAL_CALL ScVbaToggleButton::getLocked() throw (uno::RuntimeException)
142 return ScVbaControl::getLocked();
145 void SAL_CALL ScVbaToggleButton::setLocked( sal_Bool bLocked ) throw (uno::RuntimeException)
147 ScVbaControl::setLocked( bLocked );
150 OUString
151 ScVbaToggleButton::getServiceImplName()
153 return OUString( "ScVbaToggleButton" );
156 uno::Sequence< OUString >
157 ScVbaToggleButton::getServiceNames()
159 static uno::Sequence< OUString > aServiceNames;
160 if ( aServiceNames.getLength() == 0 )
162 aServiceNames.realloc( 1 );
163 aServiceNames[ 0 ] = "ooo.vba.msforms.ToggleButton";
165 return aServiceNames;
168 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */