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 "vbacheckbox.hxx"
21 #include "vbanewfont.hxx"
22 #include <vbahelper/helperdecl.hxx>
24 using namespace com::sun::star
;
25 using namespace ooo::vba
;
27 ScVbaCheckbox::ScVbaCheckbox( const 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
) : CheckBoxImpl_BASE( xParent
, xContext
, xControl
, xModel
, pGeomHelper
)
33 ScVbaCheckbox::getCaption() throw (css::uno::RuntimeException
, std::exception
)
36 m_xProps
->getPropertyValue( "Label" ) >>= Label
;
41 ScVbaCheckbox::setCaption( const OUString
& _caption
) throw (::com::sun::star::uno::RuntimeException
, std::exception
)
43 m_xProps
->setPropertyValue( "Label", uno::makeAny( _caption
) );
47 ScVbaCheckbox::getValue() throw (css::uno::RuntimeException
, std::exception
)
49 sal_Int16 nValue
= -1;
50 m_xProps
->getPropertyValue( "State" ) >>= nValue
;
53 // return uno::makeAny( nValue );
54 // I must be missing something MSO says value should be -1 if selected, 0 if not
56 return uno::makeAny( ( nValue
== -1 ) ? sal_True
: sal_False
);
60 ScVbaCheckbox::setValue( const uno::Any
& _value
) throw (css::uno::RuntimeException
, std::exception
)
63 sal_Int16 nOldValue
= 0;
64 m_xProps
->getPropertyValue( "State" ) >>= nOldValue
;
65 if( !( _value
>>= nValue
) )
75 m_xProps
->setPropertyValue( "State", uno::makeAny( nValue
) );
76 if ( nValue
!= nOldValue
)
80 uno::Reference
< msforms::XNewFont
> SAL_CALL
ScVbaCheckbox::getFont() throw (uno::RuntimeException
, std::exception
)
82 return new VbaNewFont( m_xProps
);
86 ScVbaCheckbox::getServiceImplName()
88 return OUString("ScVbaCheckbox");
91 uno::Sequence
< OUString
>
92 ScVbaCheckbox::getServiceNames()
94 static uno::Sequence
< OUString
> aServiceNames
;
95 if ( aServiceNames
.getLength() == 0 )
97 aServiceNames
.realloc( 1 );
98 aServiceNames
[ 0 ] = "ooo.vba.msforms.CheckBox";
100 return aServiceNames
;
103 sal_Int32 SAL_CALL
ScVbaCheckbox::getBackColor() throw (uno::RuntimeException
, std::exception
)
105 return ScVbaControl::getBackColor();
108 void SAL_CALL
ScVbaCheckbox::setBackColor( sal_Int32 nBackColor
) throw (uno::RuntimeException
, std::exception
)
110 ScVbaControl::setBackColor( nBackColor
);
113 sal_Bool SAL_CALL
ScVbaCheckbox::getAutoSize() throw (uno::RuntimeException
, std::exception
)
115 return ScVbaControl::getAutoSize();
118 void SAL_CALL
ScVbaCheckbox::setAutoSize( sal_Bool bAutoSize
) throw (uno::RuntimeException
, std::exception
)
120 ScVbaControl::setAutoSize( bAutoSize
);
123 sal_Bool SAL_CALL
ScVbaCheckbox::getLocked() throw (uno::RuntimeException
, std::exception
)
125 return ScVbaControl::getLocked();
128 void SAL_CALL
ScVbaCheckbox::setLocked( sal_Bool bLocked
) throw (uno::RuntimeException
, std::exception
)
130 ScVbaControl::setLocked( bLocked
);
132 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */