vclxaccessibleradiobutton.cxx (21075d77) vclxaccessibleradiobutton.cxx (15466770)
1/**************************************************************
1/**************************************************************
2 *
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
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 *
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
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.
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 *
19 *
20 *************************************************************/
21
22
23
24// MARKER(update_precomp.py): autogen include statement, do not remove
25#include "precompiled_accessibility.hxx"
26
27// includes --------------------------------------------------------------

--- 38 unchanged lines hidden (view full) ---

66VCLXAccessibleRadioButton::~VCLXAccessibleRadioButton()
67{
68}
69
70// -----------------------------------------------------------------------------
71
72void VCLXAccessibleRadioButton::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
73{
20 *************************************************************/
21
22
23
24// MARKER(update_precomp.py): autogen include statement, do not remove
25#include "precompiled_accessibility.hxx"
26
27// includes --------------------------------------------------------------

--- 38 unchanged lines hidden (view full) ---

66VCLXAccessibleRadioButton::~VCLXAccessibleRadioButton()
67{
68}
69
70// -----------------------------------------------------------------------------
71
72void VCLXAccessibleRadioButton::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
73{
74 switch ( rVclWindowEvent.GetId() )
75 {
74 switch ( rVclWindowEvent.GetId() )
75 {
76 case VCLEVENT_RADIOBUTTON_TOGGLE:
76 case VCLEVENT_RADIOBUTTON_TOGGLE:
77 {
77 {
78 Any aOldValue;
79 Any aNewValue;
80
81 VCLXRadioButton* pVCLXRadioButton = static_cast< VCLXRadioButton* >( GetVCLXWindow() );
82 if ( pVCLXRadioButton && pVCLXRadioButton->getState() )
83 aNewValue <<= AccessibleStateType::CHECKED;
84 else
85 aOldValue <<= AccessibleStateType::CHECKED;
86
78 Any aOldValue;
79 Any aNewValue;
80
81 VCLXRadioButton* pVCLXRadioButton = static_cast< VCLXRadioButton* >( GetVCLXWindow() );
82 if ( pVCLXRadioButton && pVCLXRadioButton->getState() )
83 aNewValue <<= AccessibleStateType::CHECKED;
84 else
85 aOldValue <<= AccessibleStateType::CHECKED;
86
87 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
88 }
89 break;
87 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
88 }
89 break;
90 default:
91 VCLXAccessibleTextComponent::ProcessWindowEvent( rVclWindowEvent );
90 default:
91 VCLXAccessibleTextComponent::ProcessWindowEvent( rVclWindowEvent );
92 }
92 }
93}
94
95// -----------------------------------------------------------------------------
96
97void VCLXAccessibleRadioButton::FillAccessibleRelationSet( utl::AccessibleRelationSetHelper& rRelationSet )
98{
93}
94
95// -----------------------------------------------------------------------------
96
97void VCLXAccessibleRadioButton::FillAccessibleRelationSet( utl::AccessibleRelationSetHelper& rRelationSet )
98{
99 VCLXAccessibleTextComponent::FillAccessibleRelationSet( rRelationSet );
99 VCLXAccessibleTextComponent::FillAccessibleRelationSet( rRelationSet );
100
100
101 RadioButton* pRadioButton = dynamic_cast< RadioButton* >( GetWindow() );
102 if ( pRadioButton )
103 {
104 ::std::vector< RadioButton* > aGroup;
105 pRadioButton->GetRadioButtonGroup( aGroup, true );
106 if ( !aGroup.empty() )
107 {
108 sal_Int32 i = 0;
109 Sequence< Reference< XInterface > > aSequence( static_cast< sal_Int32 >( aGroup.size() ) );
110 ::std::vector< RadioButton* >::const_iterator aEndItr = aGroup.end();
111 for ( ::std::vector< RadioButton* >::const_iterator aItr = aGroup.begin(); aItr < aEndItr; ++aItr )
112 {
113 aSequence[i++] = (*aItr)->GetAccessible();
114 }
115 rRelationSet.AddRelation( AccessibleRelation( AccessibleRelationType::MEMBER_OF, aSequence ) );
116 }
117 }
101 RadioButton* pRadioButton = dynamic_cast< RadioButton* >( GetWindow() );
102 if ( pRadioButton )
103 {
104 ::std::vector< RadioButton* > aGroup;
105 pRadioButton->GetRadioButtonGroup( aGroup, true );
106 if ( !aGroup.empty() )
107 {
108 sal_Int32 i = 0;
109 Sequence< Reference< XInterface > > aSequence( static_cast< sal_Int32 >( aGroup.size() ) );
110 ::std::vector< RadioButton* >::const_iterator aEndItr = aGroup.end();
111 for ( ::std::vector< RadioButton* >::const_iterator aItr = aGroup.begin(); aItr < aEndItr; ++aItr )
112 {
113 aSequence[i++] = (*aItr)->GetAccessible();
114 }
115 rRelationSet.AddRelation( AccessibleRelation( AccessibleRelationType::MEMBER_OF, aSequence ) );
116 }
117 }
118}
119
120// -----------------------------------------------------------------------------
121
122void VCLXAccessibleRadioButton::FillAccessibleStateSet( utl::AccessibleStateSetHelper& rStateSet )
123{
124 VCLXAccessibleTextComponent::FillAccessibleStateSet( rStateSet );
125
126 VCLXRadioButton* pVCLXRadioButton = static_cast< VCLXRadioButton* >( GetVCLXWindow() );
127 if ( pVCLXRadioButton )
128 {
118}
119
120// -----------------------------------------------------------------------------
121
122void VCLXAccessibleRadioButton::FillAccessibleStateSet( utl::AccessibleStateSetHelper& rStateSet )
123{
124 VCLXAccessibleTextComponent::FillAccessibleStateSet( rStateSet );
125
126 VCLXRadioButton* pVCLXRadioButton = static_cast< VCLXRadioButton* >( GetVCLXWindow() );
127 if ( pVCLXRadioButton )
128 {
129 rStateSet.AddState( AccessibleStateType::FOCUSABLE );
129 rStateSet.AddState( AccessibleStateType::FOCUSABLE );
130 if ( pVCLXRadioButton->getState() )
130 if ( pVCLXRadioButton->getState() )
131 rStateSet.AddState( AccessibleStateType::CHECKED );
131 rStateSet.AddState( AccessibleStateType::CHECKED );
132 }
133}
134
135// -----------------------------------------------------------------------------
136// XInterface
137// -----------------------------------------------------------------------------
138
139IMPLEMENT_FORWARD_XINTERFACE2( VCLXAccessibleRadioButton, VCLXAccessibleTextComponent, VCLXAccessibleRadioButton_BASE )

--- 25 unchanged lines hidden (view full) ---

165// -----------------------------------------------------------------------------
166// XAccessibleAction
167// -----------------------------------------------------------------------------
168
169sal_Int32 VCLXAccessibleRadioButton::getAccessibleActionCount( ) throw (RuntimeException)
170{
171 OExternalLockGuard aGuard( this );
172
132 }
133}
134
135// -----------------------------------------------------------------------------
136// XInterface
137// -----------------------------------------------------------------------------
138
139IMPLEMENT_FORWARD_XINTERFACE2( VCLXAccessibleRadioButton, VCLXAccessibleTextComponent, VCLXAccessibleRadioButton_BASE )

--- 25 unchanged lines hidden (view full) ---

165// -----------------------------------------------------------------------------
166// XAccessibleAction
167// -----------------------------------------------------------------------------
168
169sal_Int32 VCLXAccessibleRadioButton::getAccessibleActionCount( ) throw (RuntimeException)
170{
171 OExternalLockGuard aGuard( this );
172
173 return 1;
173 return 1;
174}
175
176// -----------------------------------------------------------------------------
177
178sal_Bool VCLXAccessibleRadioButton::doAccessibleAction ( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
179{
180 OExternalLockGuard aGuard( this );
181
182 if ( nIndex < 0 || nIndex >= getAccessibleActionCount() )
174}
175
176// -----------------------------------------------------------------------------
177
178sal_Bool VCLXAccessibleRadioButton::doAccessibleAction ( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
179{
180 OExternalLockGuard aGuard( this );
181
182 if ( nIndex < 0 || nIndex >= getAccessibleActionCount() )
183 throw IndexOutOfBoundsException();
183 throw IndexOutOfBoundsException();
184
185 VCLXRadioButton* pVCLXRadioButton = static_cast< VCLXRadioButton* >( GetVCLXWindow() );
186 if ( pVCLXRadioButton && !pVCLXRadioButton->getState() )
187 pVCLXRadioButton->setState( sal_True );
188
189 return sal_True;
190}
191
192// -----------------------------------------------------------------------------
193
194::rtl::OUString VCLXAccessibleRadioButton::getAccessibleActionDescription ( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
195{
196 OExternalLockGuard aGuard( this );
197
198 if ( nIndex < 0 || nIndex >= getAccessibleActionCount() )
184
185 VCLXRadioButton* pVCLXRadioButton = static_cast< VCLXRadioButton* >( GetVCLXWindow() );
186 if ( pVCLXRadioButton && !pVCLXRadioButton->getState() )
187 pVCLXRadioButton->setState( sal_True );
188
189 return sal_True;
190}
191
192// -----------------------------------------------------------------------------
193
194::rtl::OUString VCLXAccessibleRadioButton::getAccessibleActionDescription ( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
195{
196 OExternalLockGuard aGuard( this );
197
198 if ( nIndex < 0 || nIndex >= getAccessibleActionCount() )
199 throw IndexOutOfBoundsException();
199 throw IndexOutOfBoundsException();
200 return ::rtl::OUString( TK_RES_STRING( RID_STR_ACC_ACTION_SELECT ) );
201}
202
203// -----------------------------------------------------------------------------
204
205Reference< XAccessibleKeyBinding > VCLXAccessibleRadioButton::getAccessibleActionKeyBinding( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
206{
200 return ::rtl::OUString( TK_RES_STRING( RID_STR_ACC_ACTION_SELECT ) );
201}
202
203// -----------------------------------------------------------------------------
204
205Reference< XAccessibleKeyBinding > VCLXAccessibleRadioButton::getAccessibleActionKeyBinding( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
206{
207 OExternalLockGuard aGuard( this );
207 OExternalLockGuard aGuard( this );
208
208
209 if ( nIndex < 0 || nIndex >= getAccessibleActionCount() )
210 throw IndexOutOfBoundsException();
211
212 OAccessibleKeyBindingHelper* pKeyBindingHelper = new OAccessibleKeyBindingHelper();
213 Reference< XAccessibleKeyBinding > xKeyBinding = pKeyBindingHelper;
209 if ( nIndex < 0 || nIndex >= getAccessibleActionCount() )
210 throw IndexOutOfBoundsException();
214
211
215 Window* pWindow = GetWindow();
216 if ( pWindow )
217 {
218 KeyEvent aKeyEvent = pWindow->GetActivationKey();
219 KeyCode aKeyCode = aKeyEvent.GetKeyCode();
220 if ( aKeyCode.GetCode() != 0 )
221 {
222 awt::KeyStroke aKeyStroke;
223 aKeyStroke.Modifiers = 0;
224 if ( aKeyCode.IsShift() )
225 aKeyStroke.Modifiers |= awt::KeyModifier::SHIFT;
226 if ( aKeyCode.IsMod1() )
227 aKeyStroke.Modifiers |= awt::KeyModifier::MOD1;
228 if ( aKeyCode.IsMod2() )
229 aKeyStroke.Modifiers |= awt::KeyModifier::MOD2;
230 if ( aKeyCode.IsMod3() )
231 aKeyStroke.Modifiers |= awt::KeyModifier::MOD3;
232 aKeyStroke.KeyCode = aKeyCode.GetCode();
233 aKeyStroke.KeyChar = aKeyEvent.GetCharCode();
234 aKeyStroke.KeyFunc = static_cast< sal_Int16 >( aKeyCode.GetFunction() );
235 pKeyBindingHelper->AddKeyBinding( aKeyStroke );
236 }
237 }
212 OAccessibleKeyBindingHelper* pKeyBindingHelper = new OAccessibleKeyBindingHelper();
213 Reference< XAccessibleKeyBinding > xKeyBinding = pKeyBindingHelper;
238
214
239 return xKeyBinding;
215 Window* pWindow = GetWindow();
216 if ( pWindow )
217 {
218 KeyEvent aKeyEvent = pWindow->GetActivationKey();
219 KeyCode aKeyCode = aKeyEvent.GetKeyCode();
220 if ( aKeyCode.GetCode() != 0 )
221 {
222 awt::KeyStroke aKeyStroke;
223 aKeyStroke.Modifiers = 0;
224 if ( aKeyCode.IsShift() )
225 aKeyStroke.Modifiers |= awt::KeyModifier::SHIFT;
226 if ( aKeyCode.IsMod1() )
227 aKeyStroke.Modifiers |= awt::KeyModifier::MOD1;
228 if ( aKeyCode.IsMod2() )
229 aKeyStroke.Modifiers |= awt::KeyModifier::MOD2;
230 if ( aKeyCode.IsMod3() )
231 aKeyStroke.Modifiers |= awt::KeyModifier::MOD3;
232 aKeyStroke.KeyCode = aKeyCode.GetCode();
233 aKeyStroke.KeyChar = aKeyEvent.GetCharCode();
234 aKeyStroke.KeyFunc = static_cast< sal_Int16 >( aKeyCode.GetFunction() );
235 pKeyBindingHelper->AddKeyBinding( aKeyStroke );
236 }
237 }
238
239 return xKeyBinding;
240}
241
242// -----------------------------------------------------------------------------
243// XAccessibleValue
244// -----------------------------------------------------------------------------
245
246Any VCLXAccessibleRadioButton::getCurrentValue( ) throw (RuntimeException)
247{
248 OExternalLockGuard aGuard( this );
249
250 Any aValue;
251
252 VCLXRadioButton* pVCLXRadioButton = static_cast< VCLXRadioButton* >( GetVCLXWindow() );
253 if ( pVCLXRadioButton )
254 aValue <<= (sal_Int32) pVCLXRadioButton->getState();
240}
241
242// -----------------------------------------------------------------------------
243// XAccessibleValue
244// -----------------------------------------------------------------------------
245
246Any VCLXAccessibleRadioButton::getCurrentValue( ) throw (RuntimeException)
247{
248 OExternalLockGuard aGuard( this );
249
250 Any aValue;
251
252 VCLXRadioButton* pVCLXRadioButton = static_cast< VCLXRadioButton* >( GetVCLXWindow() );
253 if ( pVCLXRadioButton )
254 aValue <<= (sal_Int32) pVCLXRadioButton->getState();
255
255
256 return aValue;
257}
258
259// -----------------------------------------------------------------------------
260
261sal_Bool VCLXAccessibleRadioButton::setCurrentValue( const Any& aNumber ) throw (RuntimeException)
262{
263 OExternalLockGuard aGuard( this );

--- 9 unchanged lines hidden (view full) ---

273 if ( nValue < 0 )
274 nValue = 0;
275 else if ( nValue > 1 )
276 nValue = 1;
277
278 pVCLXRadioButton->setState( (sal_Bool) nValue );
279 bReturn = sal_True;
280 }
256 return aValue;
257}
258
259// -----------------------------------------------------------------------------
260
261sal_Bool VCLXAccessibleRadioButton::setCurrentValue( const Any& aNumber ) throw (RuntimeException)
262{
263 OExternalLockGuard aGuard( this );

--- 9 unchanged lines hidden (view full) ---

273 if ( nValue < 0 )
274 nValue = 0;
275 else if ( nValue > 1 )
276 nValue = 1;
277
278 pVCLXRadioButton->setState( (sal_Bool) nValue );
279 bReturn = sal_True;
280 }
281
281
282 return bReturn;
283}
284
285// -----------------------------------------------------------------------------
286
287Any VCLXAccessibleRadioButton::getMaximumValue( ) throw (RuntimeException)
288{
289 OExternalLockGuard aGuard( this );
290
291 Any aValue;
292 aValue <<= (sal_Int32) 1;
282 return bReturn;
283}
284
285// -----------------------------------------------------------------------------
286
287Any VCLXAccessibleRadioButton::getMaximumValue( ) throw (RuntimeException)
288{
289 OExternalLockGuard aGuard( this );
290
291 Any aValue;
292 aValue <<= (sal_Int32) 1;
293
293
294 return aValue;
295}
296
297// -----------------------------------------------------------------------------
298
299Any VCLXAccessibleRadioButton::getMinimumValue( ) throw (RuntimeException)
300{
301 OExternalLockGuard aGuard( this );
302
303 Any aValue;
304 aValue <<= (sal_Int32) 0;
294 return aValue;
295}
296
297// -----------------------------------------------------------------------------
298
299Any VCLXAccessibleRadioButton::getMinimumValue( ) throw (RuntimeException)
300{
301 OExternalLockGuard aGuard( this );
302
303 Any aValue;
304 aValue <<= (sal_Int32) 0;
305
305
306 return aValue;
307}
308
309// -----------------------------------------------------------------------------
306 return aValue;
307}
308
309// -----------------------------------------------------------------------------