1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #include "vbatogglebutton.hxx"
29 #include "vbanewfont.hxx"
30 
31 using namespace com::sun::star;
32 using namespace ooo::vba;
33 
34 
35 const static rtl::OUString LABEL( RTL_CONSTASCII_USTRINGPARAM("Label") );
36 const static rtl::OUString TOGGLE( RTL_CONSTASCII_USTRINGPARAM("Toggle") );
37 const static rtl::OUString STATE( RTL_CONSTASCII_USTRINGPARAM("State") );
38 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 )
39 {
40     OSL_TRACE("ScVbaToggleButton(ctor)");
41     m_xProps->setPropertyValue( TOGGLE, uno::makeAny( sal_True ) );
42 }
43 
44 ScVbaToggleButton::~ScVbaToggleButton()
45 {
46     OSL_TRACE("~ScVbaToggleButton(dtor)");
47 }
48 
49 // Attributes
50 rtl::OUString SAL_CALL
51 ScVbaToggleButton::getCaption() throw (css::uno::RuntimeException)
52 {
53     rtl::OUString Label;
54     m_xProps->getPropertyValue( LABEL ) >>= Label;
55     return Label;
56 }
57 
58 void SAL_CALL
59 ScVbaToggleButton::setCaption( const rtl::OUString& _caption ) throw (::com::sun::star::uno::RuntimeException)
60 {
61     m_xProps->setPropertyValue( LABEL, uno::makeAny( _caption ) );
62 }
63 
64 uno::Any SAL_CALL
65 ScVbaToggleButton::getValue() throw (uno::RuntimeException)
66 {
67 	sal_Int16 nState = 0;
68     	m_xProps->getPropertyValue( STATE ) >>= nState;
69  	return uno::makeAny( nState ? sal_Int16( -1 ) : sal_Int16( 0 ) );
70 }
71 
72 void SAL_CALL
73 ScVbaToggleButton::setValue( const uno::Any& _value ) throw (uno::RuntimeException)
74 {
75 	sal_Int16 nState = 0;
76 	_value >>= nState;
77         OSL_TRACE( "nState - %d", nState );
78 	nState = ( nState == -1 ) ?  1 : 0;
79         OSL_TRACE( "nState - %d", nState );
80 	m_xProps->setPropertyValue( STATE, uno::makeAny(  nState ) );
81 }
82 
83 sal_Bool SAL_CALL ScVbaToggleButton::getAutoSize() throw (uno::RuntimeException)
84 {
85     return sal_False;
86 }
87 
88 void SAL_CALL ScVbaToggleButton::setAutoSize( sal_Bool /*bAutoSize*/ ) throw (uno::RuntimeException)
89 {
90 }
91 
92 sal_Bool SAL_CALL ScVbaToggleButton::getCancel() throw (uno::RuntimeException)
93 {
94     return sal_False;
95 }
96 
97 void SAL_CALL ScVbaToggleButton::setCancel( sal_Bool /*bCancel*/ ) throw (uno::RuntimeException)
98 {
99 }
100 
101 sal_Bool SAL_CALL ScVbaToggleButton::getDefault() throw (uno::RuntimeException)
102 {
103     return sal_False;
104 }
105 
106 void SAL_CALL ScVbaToggleButton::setDefault( sal_Bool /*bDefault*/ ) throw (uno::RuntimeException)
107 {
108 }
109 
110 sal_Int32 SAL_CALL ScVbaToggleButton::getBackColor() throw (uno::RuntimeException)
111 {
112     return 0;
113 }
114 
115 void SAL_CALL ScVbaToggleButton::setBackColor( sal_Int32 /*nBackColor*/ ) throw (uno::RuntimeException)
116 {
117 }
118 
119 sal_Int32 SAL_CALL ScVbaToggleButton::getForeColor() throw (uno::RuntimeException)
120 {
121     return 0;
122 }
123 
124 void SAL_CALL ScVbaToggleButton::setForeColor( sal_Int32 /*nForeColor*/ ) throw (uno::RuntimeException)
125 {
126 }
127 
128 uno::Reference< msforms::XNewFont > SAL_CALL ScVbaToggleButton::getFont() throw (uno::RuntimeException)
129 {
130     return new VbaNewFont( this, mxContext, m_xProps );
131 }
132 
133 rtl::OUString&
134 ScVbaToggleButton::getServiceImplName()
135 {
136 	static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("ScVbaToggleButton") );
137 	return sImplName;
138 }
139 
140 uno::Sequence< rtl::OUString >
141 ScVbaToggleButton::getServiceNames()
142 {
143 	static uno::Sequence< rtl::OUString > aServiceNames;
144 	if ( aServiceNames.getLength() == 0 )
145 	{
146 		aServiceNames.realloc( 1 );
147 		aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.msforms.ToggleButton" ) );
148 	}
149 	return aServiceNames;
150 }
151 
152