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