Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*
3 : : * This file is part of the LibreOffice project.
4 : : *
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/.
8 : : *
9 : : * This file incorporates work covered by the following license notice:
10 : : *
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 .
18 : : */
19 : :
20 : : #include "vbatogglebutton.hxx"
21 : : #include "vbanewfont.hxx"
22 : :
23 : : using namespace com::sun::star;
24 : : using namespace ooo::vba;
25 : :
26 : :
27 : 0 : const static rtl::OUString LABEL( RTL_CONSTASCII_USTRINGPARAM("Label") );
28 : 0 : const static rtl::OUString TOGGLE( RTL_CONSTASCII_USTRINGPARAM("Toggle") );
29 : 0 : const static rtl::OUString STATE( RTL_CONSTASCII_USTRINGPARAM("State") );
30 : 0 : 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 )
31 : : {
32 : : OSL_TRACE("ScVbaToggleButton(ctor)");
33 : 0 : m_xProps->setPropertyValue( TOGGLE, uno::makeAny( sal_True ) );
34 : 0 : }
35 : :
36 : 0 : ScVbaToggleButton::~ScVbaToggleButton()
37 : : {
38 : : OSL_TRACE("~ScVbaToggleButton(dtor)");
39 : 0 : }
40 : :
41 : : // Attributes
42 : : rtl::OUString SAL_CALL
43 : 0 : ScVbaToggleButton::getCaption() throw (css::uno::RuntimeException)
44 : : {
45 : 0 : rtl::OUString Label;
46 : 0 : m_xProps->getPropertyValue( LABEL ) >>= Label;
47 : 0 : return Label;
48 : : }
49 : :
50 : : void SAL_CALL
51 : 0 : ScVbaToggleButton::setCaption( const rtl::OUString& _caption ) throw (::com::sun::star::uno::RuntimeException)
52 : : {
53 : 0 : m_xProps->setPropertyValue( LABEL, uno::makeAny( _caption ) );
54 : 0 : }
55 : :
56 : : uno::Any SAL_CALL
57 : 0 : ScVbaToggleButton::getValue() throw (uno::RuntimeException)
58 : : {
59 : 0 : sal_Int16 nState = 0;
60 : 0 : m_xProps->getPropertyValue( STATE ) >>= nState;
61 : 0 : return uno::makeAny( nState ? sal_Int16( -1 ) : sal_Int16( 0 ) );
62 : : }
63 : :
64 : :
65 : : void SAL_CALL
66 : 0 : ScVbaToggleButton::setValue( const uno::Any& _value ) throw (uno::RuntimeException)
67 : : {
68 : 0 : sal_Int16 nState = 0;
69 : 0 : if (_value.getValueTypeClass() == uno::TypeClass_BOOLEAN)
70 : : {
71 : : sal_Bool bValue;
72 : 0 : _value >>= bValue;
73 : 0 : nState = static_cast< sal_Int16 >(bValue);
74 : : }
75 : 0 : else if (_value.getValueTypeClass() == uno::TypeClass_BYTE)
76 : : {
77 : : sal_Int8 nValue;
78 : 0 : _value >>= nValue;
79 : 0 : nState = ( nValue == 1) ? 1 : 0;
80 : : }
81 : : else
82 : : {
83 : 0 : _value >>= nState;
84 : : OSL_TRACE( "nState - %d", nState );
85 : 0 : nState = ( nState == -1 ) ? 1 : 0;
86 : : OSL_TRACE( "nState - %d", nState );
87 : : }
88 : 0 : m_xProps->setPropertyValue( STATE, uno::makeAny( nState ) );
89 : 0 : }
90 : :
91 : 0 : sal_Bool SAL_CALL ScVbaToggleButton::getAutoSize() throw (uno::RuntimeException)
92 : : {
93 : 0 : return ScVbaControl::getAutoSize();
94 : : }
95 : :
96 : 0 : void SAL_CALL ScVbaToggleButton::setAutoSize( sal_Bool bAutoSize ) throw (uno::RuntimeException)
97 : : {
98 : 0 : ScVbaControl::setAutoSize( bAutoSize );
99 : 0 : }
100 : :
101 : 0 : sal_Bool SAL_CALL ScVbaToggleButton::getCancel() throw (uno::RuntimeException)
102 : : {
103 : 0 : return sal_False;
104 : : }
105 : :
106 : 0 : void SAL_CALL ScVbaToggleButton::setCancel( sal_Bool /*bCancel*/ ) throw (uno::RuntimeException)
107 : : {
108 : 0 : }
109 : :
110 : 0 : sal_Bool SAL_CALL ScVbaToggleButton::getDefault() throw (uno::RuntimeException)
111 : : {
112 : 0 : return sal_False;
113 : : }
114 : :
115 : 0 : void SAL_CALL ScVbaToggleButton::setDefault( sal_Bool /*bDefault*/ ) throw (uno::RuntimeException)
116 : : {
117 : 0 : }
118 : :
119 : 0 : sal_Int32 SAL_CALL ScVbaToggleButton::getBackColor() throw (uno::RuntimeException)
120 : : {
121 : 0 : return ScVbaControl::getBackColor();
122 : : }
123 : :
124 : 0 : void SAL_CALL ScVbaToggleButton::setBackColor( sal_Int32 nBackColor ) throw (uno::RuntimeException)
125 : : {
126 : 0 : ScVbaControl::setBackColor( nBackColor );
127 : 0 : }
128 : :
129 : 0 : sal_Int32 SAL_CALL ScVbaToggleButton::getForeColor() throw (uno::RuntimeException)
130 : : {
131 : 0 : return 0;
132 : : }
133 : :
134 : 0 : void SAL_CALL ScVbaToggleButton::setForeColor( sal_Int32 /*nForeColor*/ ) throw (uno::RuntimeException)
135 : : {
136 : 0 : }
137 : :
138 : 0 : uno::Reference< msforms::XNewFont > SAL_CALL ScVbaToggleButton::getFont() throw (uno::RuntimeException)
139 : : {
140 : 0 : return new VbaNewFont( this, mxContext, m_xProps );
141 : : }
142 : :
143 : 0 : sal_Bool SAL_CALL ScVbaToggleButton::getLocked() throw (uno::RuntimeException)
144 : : {
145 : 0 : return ScVbaControl::getLocked();
146 : : }
147 : :
148 : 0 : void SAL_CALL ScVbaToggleButton::setLocked( sal_Bool bLocked ) throw (uno::RuntimeException)
149 : : {
150 : 0 : ScVbaControl::setLocked( bLocked );
151 : 0 : }
152 : :
153 : : rtl::OUString
154 : 0 : ScVbaToggleButton::getServiceImplName()
155 : : {
156 : 0 : return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ScVbaToggleButton"));
157 : : }
158 : :
159 : : uno::Sequence< rtl::OUString >
160 : 0 : ScVbaToggleButton::getServiceNames()
161 : : {
162 : 0 : static uno::Sequence< rtl::OUString > aServiceNames;
163 : 0 : if ( aServiceNames.getLength() == 0 )
164 : : {
165 : 0 : aServiceNames.realloc( 1 );
166 : 0 : aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.msforms.ToggleButton" ) );
167 : : }
168 : 0 : return aServiceNames;
169 : 0 : }
170 : :
171 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|