1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 OSL_TRACE("ScVbaToggleButton(ctor)");
33 m_xProps
->setPropertyValue( TOGGLE
, uno::makeAny( sal_True
) );
36 ScVbaToggleButton::~ScVbaToggleButton()
38 OSL_TRACE("~ScVbaToggleButton(dtor)");
43 ScVbaToggleButton::getCaption() throw (css::uno::RuntimeException
)
46 m_xProps
->getPropertyValue( LABEL
) >>= Label
;
51 ScVbaToggleButton::setCaption( const OUString
& _caption
) throw (::com::sun::star::uno::RuntimeException
)
53 m_xProps
->setPropertyValue( LABEL
, uno::makeAny( _caption
) );
57 ScVbaToggleButton::getValue() throw (uno::RuntimeException
)
60 m_xProps
->getPropertyValue( STATE
) >>= nState
;
61 return uno::makeAny( nState
? sal_Int16( -1 ) : sal_Int16( 0 ) );
66 ScVbaToggleButton::setValue( const uno::Any
& _value
) throw (uno::RuntimeException
)
70 OSL_TRACE( "nState - %d", nState
);
71 nState
= ( nState
== -1 ) ? 1 : 0;
72 OSL_TRACE( "nState - %d", nState
);
73 m_xProps
->setPropertyValue( STATE
, uno::makeAny( nState
) );
76 sal_Bool SAL_CALL
ScVbaToggleButton::getAutoSize() throw (uno::RuntimeException
)
78 return ScVbaControl::getAutoSize();
81 void SAL_CALL
ScVbaToggleButton::setAutoSize( sal_Bool bAutoSize
) throw (uno::RuntimeException
)
83 ScVbaControl::setAutoSize( bAutoSize
);
86 sal_Bool SAL_CALL
ScVbaToggleButton::getCancel() throw (uno::RuntimeException
)
92 void SAL_CALL
ScVbaToggleButton::setCancel( sal_Bool
/*bCancel*/ ) throw (uno::RuntimeException
)
97 sal_Bool SAL_CALL
ScVbaToggleButton::getDefault() throw (uno::RuntimeException
)
103 void SAL_CALL
ScVbaToggleButton::setDefault( sal_Bool
/*bDefault*/ ) throw (uno::RuntimeException
)
108 sal_Int32 SAL_CALL
ScVbaToggleButton::getBackColor() throw (uno::RuntimeException
)
110 return ScVbaControl::getBackColor();
113 void SAL_CALL
ScVbaToggleButton::setBackColor( sal_Int32 nBackColor
) throw (uno::RuntimeException
)
115 ScVbaControl::setBackColor( nBackColor
);
118 sal_Int32 SAL_CALL
ScVbaToggleButton::getForeColor() throw (uno::RuntimeException
)
124 void SAL_CALL
ScVbaToggleButton::setForeColor( sal_Int32
/*nForeColor*/ ) throw (uno::RuntimeException
)
129 uno::Reference
< msforms::XNewFont
> SAL_CALL
ScVbaToggleButton::getFont() throw (uno::RuntimeException
)
131 return new VbaNewFont( this, mxContext
, m_xProps
);
134 sal_Bool SAL_CALL
ScVbaToggleButton::getLocked() throw (uno::RuntimeException
)
136 return ScVbaControl::getLocked();
139 void SAL_CALL
ScVbaToggleButton::setLocked( sal_Bool bLocked
) throw (uno::RuntimeException
)
141 ScVbaControl::setLocked( bLocked
);
145 ScVbaToggleButton::getServiceImplName()
147 return OUString( "ScVbaToggleButton" );
150 uno::Sequence
< OUString
>
151 ScVbaToggleButton::getServiceNames()
153 static uno::Sequence
< OUString
> aServiceNames
;
154 if ( aServiceNames
.getLength() == 0 )
156 aServiceNames
.realloc( 1 );
157 aServiceNames
[ 0 ] = "ooo.vba.msforms.ToggleButton";
159 return aServiceNames
;
162 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */