Update ooo320-m1
[ooovba.git] / svx / source / accessibility / AccessibleFrameSelector.cxx
blob49287b16b809f9777cd1b91688f95c290fb74953
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: AccessibleFrameSelector.cxx,v $
10 * $Revision: 1.10 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
33 #include "AccessibleFrameSelector.hxx"
34 #include <com/sun/star/awt/KeyEvent.hpp>
35 #include <com/sun/star/awt/KeyModifier.hpp>
36 #include <com/sun/star/awt/Key.hpp>
37 #ifndef _COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLESTATETYPE_HDL_
38 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
39 #endif
40 #ifndef _COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLERELATIONTYPE_HDL_
41 #include <com/sun/star/accessibility/AccessibleRelationType.hpp>
42 #endif
43 #ifndef _COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLEROLE_HDL_
44 #include <com/sun/star/accessibility/AccessibleRole.hpp>
45 #endif
46 #include <com/sun/star/accessibility/AccessibleEventId.hpp>
47 #include <com/sun/star/awt/FocusChangeReason.hpp>
48 #include <unotools/accessiblestatesethelper.hxx>
49 #include <unotools/accessiblerelationsethelper.hxx>
50 #include <vos/mutex.hxx>
51 #include <vcl/svapp.hxx>
52 #include <svx/frmsel.hxx>
53 #include <svx/dialmgr.hxx>
54 #include "unolingu.hxx"
56 #ifndef _SVX_DIALOGS_HRC
57 #include <svx/dialogs.hrc>
58 #endif
59 #ifndef SVX_FRMSEL_HRC
60 #include "frmsel.hrc"
61 #endif
63 #ifndef MNEMONIC_CHAR
64 #define MNEMONIC_CHAR ((sal_Unicode)'~')
65 #endif
67 namespace svx {
68 namespace a11y {
70 using ::rtl::OUString;
71 using ::com::sun::star::uno::Any;
72 using ::com::sun::star::uno::UNO_QUERY;
73 using ::com::sun::star::uno::Reference;
74 using ::com::sun::star::uno::Sequence;
75 using ::com::sun::star::uno::RuntimeException;
76 using ::com::sun::star::uno::XInterface;
77 using ::com::sun::star::lang::Locale;
78 using ::com::sun::star::lang::EventObject;
79 using ::com::sun::star::beans::XPropertyChangeListener;
80 using ::com::sun::star::awt::XFocusListener;
82 using namespace ::com::sun::star::accessibility;
84 namespace AwtKey = ::com::sun::star::awt::Key;
85 namespace AwtKeyModifier = ::com::sun::star::awt::KeyModifier;
86 namespace AwtFocusChangeReason = ::com::sun::star::awt::FocusChangeReason;
88 typedef ::com::sun::star::awt::Point AwtPoint;
89 typedef ::com::sun::star::awt::Size AwtSize;
90 typedef ::com::sun::star::awt::Rectangle AwtRectangle;
91 typedef ::com::sun::star::awt::KeyEvent AwtKeyEvent;
92 typedef ::com::sun::star::awt::FocusEvent AwtFocusEvent;
94 // ============================================================================
96 AccFrameSelector::AccFrameSelector( FrameSelector& rFrameSel, FrameBorderType eBorder ) :
97 Resource( SVX_RES( RID_SVXSTR_BORDER_CONTROL ) ),
98 mpFrameSel( &rFrameSel ),
99 meBorder( eBorder ),
100 maFocusListeners( maFocusMutex ),
101 maPropertyListeners( maPropertyMutex ),
102 maNames( SVX_RES( ARR_TEXTS ) ),
103 maDescriptions( SVX_RES(ARR_DESCRIPTIONS ) ),
104 mnClientId( 0 )
106 FreeResource();
108 if ( mpFrameSel )
110 mpFrameSel->AddEventListener( LINK( this, AccFrameSelector, WindowEventListener ) );
114 // ----------------------------------------------------------------------------
116 AccFrameSelector::~AccFrameSelector()
118 if ( mpFrameSel )
120 mpFrameSel->RemoveEventListener( LINK( this, AccFrameSelector, WindowEventListener ) );
124 // ----------------------------------------------------------------------------
126 Reference< XAccessibleContext > AccFrameSelector::getAccessibleContext( )
127 throw (RuntimeException)
129 return this;
132 // ----------------------------------------------------------------------------
134 sal_Int32 AccFrameSelector::getAccessibleChildCount( ) throw (RuntimeException)
136 vos::OGuard aGuard(Application::GetSolarMutex());
137 IsValid();
138 return (meBorder == FRAMEBORDER_NONE) ? mpFrameSel->GetEnabledBorderCount() : 0;
141 // ----------------------------------------------------------------------------
143 Reference< XAccessible > AccFrameSelector::getAccessibleChild( sal_Int32 i )
144 throw (RuntimeException)
146 vos::OGuard aGuard(Application::GetSolarMutex());
147 IsValid();
148 Reference< XAccessible > xRet;
149 if( meBorder == FRAMEBORDER_NONE )
150 xRet = mpFrameSel->GetChildAccessible( i );
151 if( !xRet.is() )
152 throw RuntimeException();
153 return xRet;
156 // ----------------------------------------------------------------------------
158 Reference< XAccessible > AccFrameSelector::getAccessibleParent( )
159 throw (RuntimeException)
161 vos::OGuard aGuard(Application::GetSolarMutex());
162 IsValid();
163 Reference< XAccessible > xRet;
164 if(meBorder == FRAMEBORDER_NONE)
165 xRet = mpFrameSel->GetParent()->GetAccessible( sal_True );
166 else
167 xRet = mpFrameSel->CreateAccessible();
168 return xRet;
171 // ----------------------------------------------------------------------------
173 sal_Int32 AccFrameSelector::getAccessibleIndexInParent( )
174 throw (RuntimeException)
176 vos::OGuard aGuard(Application::GetSolarMutex());
177 IsValid();
179 sal_Int32 nIdx = 0;
180 if( meBorder == FRAMEBORDER_NONE )
182 Window* pTabPage = mpFrameSel->GetParent();
183 sal_Int32 nChildren = pTabPage->GetChildCount();
184 for( nIdx = 0; nIdx < nChildren; ++nIdx )
185 if( pTabPage->GetChild( static_cast< USHORT >( nIdx ) ) == mpFrameSel )
186 break;
188 else
189 nIdx = mpFrameSel->GetEnabledBorderIndex( meBorder );
191 if( nIdx < 0 )
192 throw RuntimeException();
193 return nIdx;
196 // ----------------------------------------------------------------------------
198 sal_Int16 AccFrameSelector::getAccessibleRole( ) throw (RuntimeException)
200 return AccessibleRole::OPTION_PANE;
203 // ----------------------------------------------------------------------------
205 OUString AccFrameSelector::getAccessibleDescription( )
206 throw (RuntimeException)
208 vos::OGuard aGuard(Application::GetSolarMutex());
209 IsValid();
210 return maDescriptions.GetString(meBorder);
213 // ----------------------------------------------------------------------------
215 OUString AccFrameSelector::getAccessibleName( )
216 throw (RuntimeException)
218 vos::OGuard aGuard(Application::GetSolarMutex());
219 IsValid();
220 return maNames.GetString(meBorder);
223 // ----------------------------------------------------------------------------
225 Reference< XAccessibleRelationSet > AccFrameSelector::getAccessibleRelationSet( )
226 throw (RuntimeException)
228 vos::OGuard aGuard(Application::GetSolarMutex());
229 IsValid();
230 utl::AccessibleRelationSetHelper* pHelper;
231 Reference< XAccessibleRelationSet > xRet = pHelper = new utl::AccessibleRelationSetHelper;
232 if(meBorder == FRAMEBORDER_NONE)
234 //add the label relation
235 Window* pPrev = mpFrameSel->GetWindow( WINDOW_PREV );
236 if(pPrev && WINDOW_FIXEDTEXT == pPrev->GetType())
238 AccessibleRelation aLabelRelation;
239 aLabelRelation.RelationType = AccessibleRelationType::LABELED_BY;
240 aLabelRelation.TargetSet.realloc(1);
241 aLabelRelation.TargetSet.getArray()[0] = pPrev->GetAccessible();
242 pHelper->AddRelation(aLabelRelation);
245 return xRet;
248 // ----------------------------------------------------------------------------
250 Reference< XAccessibleStateSet > AccFrameSelector::getAccessibleStateSet( )
251 throw (RuntimeException)
253 vos::OGuard aGuard(Application::GetSolarMutex());
254 utl::AccessibleStateSetHelper* pStateSetHelper = new utl::AccessibleStateSetHelper;
255 Reference< XAccessibleStateSet > xRet = pStateSetHelper;
257 if(!mpFrameSel)
258 pStateSetHelper->AddState(AccessibleStateType::DEFUNC);
259 else
261 const sal_Int16 aStandardStates[] =
263 AccessibleStateType::EDITABLE,
264 AccessibleStateType::FOCUSABLE,
265 AccessibleStateType::MULTI_SELECTABLE,
266 AccessibleStateType::SELECTABLE,
267 AccessibleStateType::SHOWING,
268 AccessibleStateType::VISIBLE,
269 AccessibleStateType::OPAQUE,
271 sal_Int16 nState = 0;
272 while(aStandardStates[nState])
274 pStateSetHelper->AddState(aStandardStates[nState++]);
276 if(mpFrameSel->IsEnabled())
278 pStateSetHelper->AddState(AccessibleStateType::ENABLED);
279 pStateSetHelper->AddState(AccessibleStateType::SENSITIVE);
282 sal_Bool bIsParent = meBorder == FRAMEBORDER_NONE;
283 if(mpFrameSel->HasFocus() &&
284 (bIsParent || mpFrameSel->IsBorderSelected(meBorder)))
286 pStateSetHelper->AddState(AccessibleStateType::ACTIVE);
287 pStateSetHelper->AddState(AccessibleStateType::FOCUSED);
288 pStateSetHelper->AddState(AccessibleStateType::SELECTED);
291 return xRet;
294 // ----------------------------------------------------------------------------
296 Locale AccFrameSelector::getLocale( )
297 throw (IllegalAccessibleComponentStateException, RuntimeException)
299 Locale aRet;
300 SvxLanguageToLocale( aRet, Application::GetSettings().GetUILanguage() );
301 return aRet;
304 // ----------------------------------------------------------------------------
306 void AccFrameSelector::addPropertyChangeListener(
307 const Reference< XPropertyChangeListener >& xListener )
308 throw (RuntimeException)
310 maPropertyListeners.addInterface( xListener );
313 // ----------------------------------------------------------------------------
315 void AccFrameSelector::removePropertyChangeListener( const Reference< XPropertyChangeListener >& xListener )
316 throw (RuntimeException)
318 maPropertyListeners.removeInterface( xListener );
321 // ----------------------------------------------------------------------------
323 sal_Bool AccFrameSelector::containsPoint( const AwtPoint& aPt )
324 throw (RuntimeException)
326 vos::OGuard aGuard(Application::GetSolarMutex());
327 IsValid();
328 //aPt is relative to the frame selector
329 return mpFrameSel->ContainsClickPoint( Point( aPt.X, aPt.Y ) );
332 // ----------------------------------------------------------------------------
334 Reference< XAccessible > AccFrameSelector::getAccessibleAtPoint(
335 const AwtPoint& aPt )
336 throw (RuntimeException)
338 vos::OGuard aGuard(Application::GetSolarMutex());
339 IsValid();
340 //aPt is relative to the frame selector
341 return mpFrameSel->GetChildAccessible( Point( aPt.X, aPt.Y ) );
344 AwtRectangle AccFrameSelector::getBounds( ) throw (RuntimeException)
346 vos::OGuard aGuard(Application::GetSolarMutex());
347 IsValid();
348 Size aSz;
349 Point aPos;
350 switch(meBorder)
352 case FRAMEBORDER_NONE:
353 aSz = mpFrameSel->GetSizePixel();
354 aPos = mpFrameSel->GetPosPixel();
355 break;
356 default:
357 const Rectangle aSpot = mpFrameSel->GetClickBoundRect( meBorder );
358 aPos = aSpot.TopLeft();
359 aSz = aSpot.GetSize();
361 AwtRectangle aRet;
362 aRet.X = aPos.X();
363 aRet.Y = aPos.Y();
364 aRet.Width = aSz.Width();
365 aRet.Height = aSz.Height();
366 return aRet;
369 // ----------------------------------------------------------------------------
371 AwtPoint AccFrameSelector::getLocation( ) throw (RuntimeException)
373 vos::OGuard aGuard(Application::GetSolarMutex());
374 IsValid();
375 Point aPos;
376 switch(meBorder)
378 case FRAMEBORDER_NONE:
379 aPos = mpFrameSel->GetPosPixel();
380 break;
381 default:
382 const Rectangle aSpot = mpFrameSel->GetClickBoundRect( meBorder );
383 aPos = aSpot.TopLeft();
385 AwtPoint aRet(aPos.X(), aPos.Y());
386 return aRet;
389 // ----------------------------------------------------------------------------
391 AwtPoint AccFrameSelector::getLocationOnScreen( ) throw (RuntimeException)
393 vos::OGuard aGuard(Application::GetSolarMutex());
394 IsValid();
395 Point aPos;
396 switch(meBorder)
398 case FRAMEBORDER_NONE:
399 aPos = mpFrameSel->GetPosPixel();
400 break;
401 default:
402 const Rectangle aSpot = mpFrameSel->GetClickBoundRect( meBorder );
403 aPos = aSpot.TopLeft();
405 aPos = mpFrameSel->OutputToAbsoluteScreenPixel( aPos );
406 AwtPoint aRet(aPos.X(), aPos.Y());
407 return aRet;
410 // ----------------------------------------------------------------------------
412 AwtSize AccFrameSelector::getSize( ) throw (RuntimeException)
414 vos::OGuard aGuard(Application::GetSolarMutex());
415 IsValid();
416 Size aSz;
417 switch(meBorder)
419 case FRAMEBORDER_NONE:
420 aSz = mpFrameSel->GetSizePixel();
421 break;
422 default:
423 const Rectangle aSpot = mpFrameSel->GetClickBoundRect( meBorder );
424 aSz = aSpot.GetSize();
426 AwtSize aRet(aSz.Width(), aSz.Height());
427 return aRet;
430 // ----------------------------------------------------------------------------
432 sal_Bool AccFrameSelector::isShowing( ) throw (RuntimeException)
434 vos::OGuard aGuard(Application::GetSolarMutex());
435 IsValid();
436 return sal_True;
439 // ----------------------------------------------------------------------------
441 sal_Bool AccFrameSelector::isVisible( ) throw (RuntimeException)
443 vos::OGuard aGuard(Application::GetSolarMutex());
444 IsValid();
445 return sal_True;
448 // ----------------------------------------------------------------------------
450 sal_Bool AccFrameSelector::isFocusTraversable( ) throw (RuntimeException)
452 vos::OGuard aGuard(Application::GetSolarMutex());
453 IsValid();
454 return sal_True;
457 // ----------------------------------------------------------------------------
459 void AccFrameSelector::addFocusListener( const Reference< XFocusListener >& xListener ) throw (RuntimeException)
461 maFocusListeners.addInterface( xListener );
464 // ----------------------------------------------------------------------------
466 void AccFrameSelector::removeFocusListener( const Reference< XFocusListener >& xListener ) throw (RuntimeException)
468 maFocusListeners.removeInterface( xListener );
471 // ----------------------------------------------------------------------------
473 void AccFrameSelector::grabFocus( ) throw (RuntimeException)
475 vos::OGuard aGuard(Application::GetSolarMutex());
476 IsValid();
477 mpFrameSel->GrabFocus();
480 // ----------------------------------------------------------------------------
482 Any AccFrameSelector::getAccessibleKeyBinding( ) throw (RuntimeException)
484 Any aRet;
485 vos::OGuard aGuard(Application::GetSolarMutex());
486 IsValid();
487 utl::AccessibleRelationSetHelper* pHelper;
488 Reference< XAccessibleRelationSet > xRet = pHelper = new utl::AccessibleRelationSetHelper;
489 if(meBorder == FRAMEBORDER_NONE)
491 Window* pPrev = mpFrameSel->GetWindow( WINDOW_PREV );
492 if(pPrev && WINDOW_FIXEDTEXT == pPrev->GetType())
494 String sText = pPrev->GetText();
495 xub_StrLen nFound = sText.Search( MNEMONIC_CHAR );
496 if(STRING_NOTFOUND != nFound && ++nFound < sText.Len())
498 sText.ToUpperAscii();
499 sal_Unicode cChar = sText.GetChar(nFound);
500 AwtKeyEvent aEvent;
502 aEvent.KeyCode = 0;
503 aEvent.KeyChar = cChar;
504 aEvent.KeyFunc = 0;
505 if(cChar >= 'A' && cChar <= 'Z')
507 aEvent.KeyCode = AwtKey::A + cChar - 'A';
509 aEvent.Modifiers = AwtKeyModifier::MOD2;
510 aRet <<= aEvent;
514 return aRet;
517 // ----------------------------------------------------------------------------
519 sal_Int32 AccFrameSelector::getForeground( )
520 throw (RuntimeException)
522 Any aRet;
523 vos::OGuard aGuard(Application::GetSolarMutex());
524 IsValid();
525 return mpFrameSel->GetControlForeground().GetColor();
528 // ----------------------------------------------------------------------------
530 sal_Int32 AccFrameSelector::getBackground( )
531 throw (RuntimeException)
533 Any aRet;
534 vos::OGuard aGuard(Application::GetSolarMutex());
535 IsValid();
536 return mpFrameSel->GetControlBackground().GetColor();
539 // ----------------------------------------------------------------------------
541 void AccFrameSelector::addEventListener( const Reference< XAccessibleEventListener >& xListener ) throw (RuntimeException)
543 vos::OGuard aGuard( Application::GetSolarMutex() );
545 if ( xListener.is() )
547 if ( !mnClientId )
549 mnClientId = ::comphelper::AccessibleEventNotifier::registerClient();
551 ::comphelper::AccessibleEventNotifier::addEventListener( mnClientId, xListener );
555 // ----------------------------------------------------------------------------
557 void AccFrameSelector::removeEventListener( const Reference< XAccessibleEventListener >& xListener ) throw (RuntimeException)
559 vos::OGuard aGuard( Application::GetSolarMutex() );
561 if ( xListener.is() && mnClientId != 0 &&
562 ::comphelper::AccessibleEventNotifier::removeEventListener( mnClientId, xListener ) == 0 )
564 // no listeners anymore
565 // -> revoke ourself. This may lead to the notifier thread dying (if we were the last client),
566 // and at least to us not firing any events anymore, in case somebody calls
567 // NotifyAccessibleEvent, again
568 ::comphelper::AccessibleEventNotifier::TClientId nId( mnClientId );
569 mnClientId = 0;
570 ::comphelper::AccessibleEventNotifier::revokeClient( nId );
574 // ----------------------------------------------------------------------------
576 OUString AccFrameSelector::getImplementationName( ) throw (RuntimeException)
578 return OUString::createFromAscii("AccFrameSelector");
581 // ----------------------------------------------------------------------------
583 const sal_Char sAccessible[] = "Accessible";
584 const sal_Char sAccessibleContext[] = "AccessibleContext";
585 const sal_Char sAccessibleComponent[] = "AccessibleComponent";
587 sal_Bool AccFrameSelector::supportsService( const OUString& rServiceName )
588 throw (RuntimeException)
590 return rServiceName.equalsAsciiL( sAccessible , sizeof(sAccessible )-1 ) ||
591 rServiceName.equalsAsciiL( sAccessibleContext , sizeof(sAccessibleContext )-1 ) ||
592 rServiceName.equalsAsciiL( sAccessibleComponent, sizeof(sAccessibleComponent)-1 );
595 // ----------------------------------------------------------------------------
597 Sequence< OUString > AccFrameSelector::getSupportedServiceNames( )
598 throw (RuntimeException)
600 Sequence< OUString > aRet(3);
601 OUString* pArray = aRet.getArray();
602 pArray[0] = OUString( RTL_CONSTASCII_USTRINGPARAM(sAccessible ) );
603 pArray[1] = OUString( RTL_CONSTASCII_USTRINGPARAM(sAccessibleContext ) );
604 pArray[2] = OUString( RTL_CONSTASCII_USTRINGPARAM(sAccessibleComponent) );
605 return aRet;
608 // ----------------------------------------------------------------------------
610 void AccFrameSelector::IsValid() throw (RuntimeException)
612 if(!mpFrameSel)
613 throw RuntimeException();
616 // ----------------------------------------------------------------------------
618 void AccFrameSelector::NotifyFocusListeners(sal_Bool bGetFocus)
620 vos::OGuard aGuard(Application::GetSolarMutex());
621 AwtFocusEvent aEvent;
622 aEvent.FocusFlags = 0;
623 if(bGetFocus)
625 USHORT nFocusFlags = mpFrameSel->GetGetFocusFlags();
626 if(nFocusFlags&GETFOCUS_TAB)
627 aEvent.FocusFlags |= AwtFocusChangeReason::TAB;
628 if(nFocusFlags&GETFOCUS_CURSOR)
629 aEvent.FocusFlags |= AwtFocusChangeReason::CURSOR;
630 if(nFocusFlags&GETFOCUS_MNEMONIC)
631 aEvent.FocusFlags |= AwtFocusChangeReason::MNEMONIC;
632 if(nFocusFlags&GETFOCUS_FORWARD)
633 aEvent.FocusFlags |= AwtFocusChangeReason::FORWARD;
634 if(nFocusFlags&GETFOCUS_BACKWARD)
635 aEvent.FocusFlags |= AwtFocusChangeReason::BACKWARD;
636 if(nFocusFlags&GETFOCUS_AROUND)
637 aEvent.FocusFlags |= AwtFocusChangeReason::AROUND;
638 if(nFocusFlags&GETFOCUS_UNIQUEMNEMONIC)
639 aEvent.FocusFlags |= AwtFocusChangeReason::UNIQUEMNEMONIC;
640 // if(nFocusFlags&GETFOCUS_INIT)
641 // aEvent.FocusFlags |= AwtFocusChangeReason::
643 // else
644 //how can I find the current focus window?
645 // aEvent.NextFocus = ;
646 aEvent.Temporary = sal_False;
648 Reference < XAccessibleContext > xThis( this );
649 aEvent.Source = xThis;
651 ::cppu::OInterfaceIteratorHelper aIter( maFocusListeners );
652 while( aIter.hasMoreElements() )
654 Reference < XFocusListener > xListener( aIter.next(), UNO_QUERY );
655 if(bGetFocus)
656 xListener->focusGained( aEvent );
657 else
658 xListener->focusLost( aEvent );
662 // ----------------------------------------------------------------------------
664 IMPL_LINK( AccFrameSelector, WindowEventListener, VclSimpleEvent*, pEvent )
666 VclWindowEvent* pWinEvent = dynamic_cast< VclWindowEvent* >( pEvent );
667 DBG_ASSERT( pWinEvent, "AccFrameSelector::WindowEventListener - unknown window event" );
668 if ( pWinEvent )
670 Window* pWindow = pWinEvent->GetWindow();
671 DBG_ASSERT( pWindow, "AccFrameSelector::WindowEventListener: no window!" );
672 if ( !pWindow->IsAccessibilityEventsSuppressed() || ( pWinEvent->GetId() == VCLEVENT_OBJECT_DYING ) )
674 ProcessWindowEvent( *pWinEvent );
678 return 0;
681 // ----------------------------------------------------------------------------
683 void AccFrameSelector::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
685 switch ( rVclWindowEvent.GetId() )
687 case VCLEVENT_WINDOW_GETFOCUS:
689 if ( meBorder == FRAMEBORDER_NONE )
691 Any aOldValue, aNewValue;
692 aNewValue <<= AccessibleStateType::FOCUSED;
693 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
696 break;
697 case VCLEVENT_WINDOW_LOSEFOCUS:
699 if ( meBorder == FRAMEBORDER_NONE )
701 Any aOldValue, aNewValue;
702 aOldValue <<= AccessibleStateType::FOCUSED;
703 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
706 break;
707 default:
710 break;
714 // ----------------------------------------------------------------------------
716 void AccFrameSelector::NotifyAccessibleEvent( const sal_Int16 _nEventId,
717 const Any& _rOldValue, const Any& _rNewValue )
719 if ( mnClientId )
721 Reference< XInterface > xSource( *this );
722 AccessibleEventObject aEvent( xSource, _nEventId, _rNewValue, _rOldValue );
723 ::comphelper::AccessibleEventNotifier::addEvent( mnClientId, aEvent );
727 // ----------------------------------------------------------------------------
729 void AccFrameSelector::Invalidate()
731 mpFrameSel = 0;
732 EventObject aEvent;
733 Reference < XAccessibleContext > xThis( this );
734 aEvent.Source = xThis;
735 maFocusListeners.disposeAndClear( aEvent );
736 maPropertyListeners.disposeAndClear( aEvent );
739 // ============================================================================
741 } // namespace a11y
742 } // namespace svx