1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <com/sun/star/accessibility/AccessibleRole.hpp>
21 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
22 #include <com/sun/star/accessibility/AccessibleEventId.hpp>
23 #include <com/sun/star/accessibility/XAccessibleEventListener.hpp>
24 #include <com/sun/star/accessibility/AccessibleRelationType.hpp>
25 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
26 #include <cppuhelper/supportsservice.hxx>
27 #include <i18nlangtag/languagetag.hxx>
28 #include <toolkit/awt/vclxaccessiblecomponent.hxx>
29 #include <toolkit/awt/vclxwindow.hxx>
30 #include <toolkit/helper/convert.hxx>
31 #include <toolkit/awt/vclxfont.hxx>
32 #include <vcl/dialog.hxx>
33 #include <vcl/vclevent.hxx>
34 #include <vcl/window.hxx>
35 #include <vcl/edit.hxx>
36 #include <vcl/settings.hxx>
37 #include <tools/debug.hxx>
38 #include <unotools/accessiblestatesethelper.hxx>
39 #include <unotools/accessiblerelationsethelper.hxx>
40 #include <vcl/svapp.hxx>
41 #include <vcl/menu.hxx>
43 using namespace ::com::sun::star
;
44 using namespace ::comphelper
;
46 VCLXAccessibleComponent::VCLXAccessibleComponent( VCLXWindow
* pVCLXWindow
)
48 m_xVCLXWindow
= pVCLXWindow
;
50 DBG_ASSERT( pVCLXWindow
->GetWindow(), "VCLXAccessibleComponent - no window!" );
51 m_xEventSource
= pVCLXWindow
->GetWindow();
54 m_xEventSource
->AddEventListener( LINK( this, VCLXAccessibleComponent
, WindowEventListener
) );
55 m_xEventSource
->AddChildEventListener( LINK( this, VCLXAccessibleComponent
, WindowChildEventListener
) );
58 // announce the XAccessible of our creator to the base class
59 lateInit( pVCLXWindow
);
62 VCLXWindow
* VCLXAccessibleComponent::GetVCLXWindow() const
64 return m_xVCLXWindow
.get();
67 void VCLXAccessibleComponent::DisconnectEvents()
71 m_xEventSource
->RemoveEventListener( LINK( this, VCLXAccessibleComponent
, WindowEventListener
) );
72 m_xEventSource
->RemoveChildEventListener( LINK( this, VCLXAccessibleComponent
, WindowChildEventListener
) );
73 m_xEventSource
.clear();
77 VCLXAccessibleComponent::~VCLXAccessibleComponent()
83 IMPLEMENT_FORWARD_XINTERFACE3( VCLXAccessibleComponent
, OAccessibleExtendedComponentHelper
, OAccessibleImplementationAccess
, VCLXAccessibleComponent_BASE
)
84 IMPLEMENT_FORWARD_XTYPEPROVIDER3( VCLXAccessibleComponent
, OAccessibleExtendedComponentHelper
, OAccessibleImplementationAccess
, VCLXAccessibleComponent_BASE
)
86 OUString
VCLXAccessibleComponent::getImplementationName()
88 return OUString("com.sun.star.comp.toolkit.AccessibleWindow");
91 sal_Bool
VCLXAccessibleComponent::supportsService( const OUString
& rServiceName
)
93 return cppu::supportsService(this, rServiceName
);
96 uno::Sequence
< OUString
> VCLXAccessibleComponent::getSupportedServiceNames()
98 uno::Sequence
< OUString
> aNames
{ "com.sun.star.awt.AccessibleWindow" };
102 IMPL_LINK( VCLXAccessibleComponent
, WindowEventListener
, VclWindowEvent
&, rEvent
, void )
104 /* Ignore VclEventId::WindowEndPopupMode, because the UNO accessibility wrapper
105 * might have been destroyed by the previous VCLEventListener (if no AT tool
106 * is running), e.g. sub-toolbars in impress.
108 if ( m_xVCLXWindow
.is() /* #122218# */ && (rEvent
.GetId() != VclEventId::WindowEndPopupMode
) )
110 DBG_ASSERT( rEvent
.GetWindow(), "Window???" );
111 if( !rEvent
.GetWindow()->IsAccessibilityEventsSuppressed() || ( rEvent
.GetId() == VclEventId::ObjectDying
) )
113 ProcessWindowEvent( rEvent
);
118 IMPL_LINK( VCLXAccessibleComponent
, WindowChildEventListener
, VclWindowEvent
&, rEvent
, void )
120 if ( m_xVCLXWindow
.is() /* #i68079# */ )
122 DBG_ASSERT( rEvent
.GetWindow(), "Window???" );
123 if( !rEvent
.GetWindow()->IsAccessibilityEventsSuppressed() )
125 // #103087# to prevent an early release of the component
126 uno::Reference
< accessibility::XAccessibleContext
> xTmp
= this;
128 ProcessWindowChildEvent( rEvent
);
133 uno::Reference
< accessibility::XAccessible
> VCLXAccessibleComponent::GetChildAccessible( const VclWindowEvent
& rVclWindowEvent
)
135 // checks if the data in the window event is our direct child
136 // and returns its accessible
138 // MT: Change this later, normally a show/hide event shouldn't have the vcl::Window* in pData.
139 vcl::Window
* pChildWindow
= static_cast<vcl::Window
*>(rVclWindowEvent
.GetData());
140 if( pChildWindow
&& GetWindow() == pChildWindow
->GetAccessibleParentWindow() )
141 return pChildWindow
->GetAccessible( rVclWindowEvent
.GetId() == VclEventId::WindowShow
);
143 return uno::Reference
< accessibility::XAccessible
> ();
146 void VCLXAccessibleComponent::ProcessWindowChildEvent( const VclWindowEvent
& rVclWindowEvent
)
148 uno::Any aOldValue
, aNewValue
;
149 uno::Reference
< accessibility::XAccessible
> xAcc
;
151 switch ( rVclWindowEvent
.GetId() )
153 case VclEventId::WindowShow
: // send create on show for direct accessible children
155 xAcc
= GetChildAccessible( rVclWindowEvent
);
159 NotifyAccessibleEvent( accessibility::AccessibleEventId::CHILD
, aOldValue
, aNewValue
);
163 case VclEventId::WindowHide
: // send destroy on hide for direct accessible children
165 xAcc
= GetChildAccessible( rVclWindowEvent
);
169 NotifyAccessibleEvent( accessibility::AccessibleEventId::CHILD
, aOldValue
, aNewValue
);
177 void VCLXAccessibleComponent::ProcessWindowEvent( const VclWindowEvent
& rVclWindowEvent
)
179 uno::Any aOldValue
, aNewValue
;
181 vcl::Window
* pAccWindow
= rVclWindowEvent
.GetWindow();
182 assert(pAccWindow
&& "VCLXAccessibleComponent::ProcessWindowEvent - Window?");
184 switch ( rVclWindowEvent
.GetId() )
186 case VclEventId::ObjectDying
:
189 m_xVCLXWindow
.clear();
192 case VclEventId::WindowChildDestroyed
:
194 vcl::Window
* pWindow
= static_cast<vcl::Window
*>(rVclWindowEvent
.GetData());
195 DBG_ASSERT( pWindow
, "VclEventId::WindowChildDestroyed - Window=?" );
196 if ( pWindow
->GetAccessible( false ).is() )
198 aOldValue
<<= pWindow
->GetAccessible( false );
199 NotifyAccessibleEvent( accessibility::AccessibleEventId::CHILD
, aOldValue
, aNewValue
);
203 case VclEventId::WindowActivate
:
205 sal_Int16 aAccessibleRole
= getAccessibleRole();
206 // avoid notification if a child frame is already active
207 // only one frame may be active at a given time
208 if ( !pAccWindow
->HasActiveChildFrame() &&
209 ( aAccessibleRole
== accessibility::AccessibleRole::FRAME
||
210 aAccessibleRole
== accessibility::AccessibleRole::ALERT
||
211 aAccessibleRole
== accessibility::AccessibleRole::DIALOG
) ) // #i18891#
213 aNewValue
<<= accessibility::AccessibleStateType::ACTIVE
;
214 NotifyAccessibleEvent( accessibility::AccessibleEventId::STATE_CHANGED
, aOldValue
, aNewValue
);
218 case VclEventId::WindowDeactivate
:
220 sal_Int16 aAccessibleRole
= getAccessibleRole();
221 if ( aAccessibleRole
== accessibility::AccessibleRole::FRAME
||
222 aAccessibleRole
== accessibility::AccessibleRole::ALERT
||
223 aAccessibleRole
== accessibility::AccessibleRole::DIALOG
) // #i18891#
225 aOldValue
<<= accessibility::AccessibleStateType::ACTIVE
;
226 NotifyAccessibleEvent( accessibility::AccessibleEventId::STATE_CHANGED
, aOldValue
, aNewValue
);
230 case VclEventId::WindowGetFocus
:
231 case VclEventId::ControlGetFocus
:
233 if( (pAccWindow
->IsCompoundControl() && rVclWindowEvent
.GetId() == VclEventId::ControlGetFocus
) ||
234 (!pAccWindow
->IsCompoundControl() && rVclWindowEvent
.GetId() == VclEventId::WindowGetFocus
) )
236 // if multiple listeners were registered it is possible that the
237 // focus was changed during event processing (eg SfxTopWindow )
238 // #106082# allow ChildPathFocus only for CompoundControls, for windows the focus must be in the window itself
239 if( (pAccWindow
->IsCompoundControl() && pAccWindow
->HasChildPathFocus()) ||
240 (!pAccWindow
->IsCompoundControl() && pAccWindow
->HasFocus()) )
242 aNewValue
<<= accessibility::AccessibleStateType::FOCUSED
;
243 NotifyAccessibleEvent( accessibility::AccessibleEventId::STATE_CHANGED
, aOldValue
, aNewValue
);
248 case VclEventId::WindowLoseFocus
:
249 case VclEventId::ControlLoseFocus
:
251 if( (pAccWindow
->IsCompoundControl() && rVclWindowEvent
.GetId() == VclEventId::ControlLoseFocus
) ||
252 (!pAccWindow
->IsCompoundControl() && rVclWindowEvent
.GetId() == VclEventId::WindowLoseFocus
) )
254 aOldValue
<<= accessibility::AccessibleStateType::FOCUSED
;
255 NotifyAccessibleEvent( accessibility::AccessibleEventId::STATE_CHANGED
, aOldValue
, aNewValue
);
259 case VclEventId::WindowFrameTitleChanged
:
261 OUString
aOldName( *static_cast<OUString
*>(rVclWindowEvent
.GetData()) );
262 OUString
aNewName( getAccessibleName() );
263 aOldValue
<<= aOldName
;
264 aNewValue
<<= aNewName
;
265 NotifyAccessibleEvent( accessibility::AccessibleEventId::NAME_CHANGED
, aOldValue
, aNewValue
);
268 case VclEventId::WindowEnabled
:
270 aNewValue
<<= accessibility::AccessibleStateType::ENABLED
;
271 NotifyAccessibleEvent( accessibility::AccessibleEventId::STATE_CHANGED
, aOldValue
, aNewValue
);
272 aNewValue
<<= accessibility::AccessibleStateType::SENSITIVE
;
273 NotifyAccessibleEvent( accessibility::AccessibleEventId::STATE_CHANGED
, aOldValue
, aNewValue
);
276 case VclEventId::WindowDisabled
:
278 aOldValue
<<= accessibility::AccessibleStateType::SENSITIVE
;
279 NotifyAccessibleEvent( accessibility::AccessibleEventId::STATE_CHANGED
, aOldValue
, aNewValue
);
281 aOldValue
<<= accessibility::AccessibleStateType::ENABLED
;
282 NotifyAccessibleEvent( accessibility::AccessibleEventId::STATE_CHANGED
, aOldValue
, aNewValue
);
285 case VclEventId::WindowMove
:
286 case VclEventId::WindowResize
:
288 NotifyAccessibleEvent( accessibility::AccessibleEventId::BOUNDRECT_CHANGED
, aOldValue
, aNewValue
);
291 case VclEventId::WindowMenubarAdded
:
293 MenuBar
* pMenuBar
= static_cast<MenuBar
*>(rVclWindowEvent
.GetData());
296 uno::Reference
< accessibility::XAccessible
> xChild( pMenuBar
->GetAccessible() );
299 aNewValue
<<= xChild
;
300 NotifyAccessibleEvent( accessibility::AccessibleEventId::CHILD
, aOldValue
, aNewValue
);
305 case VclEventId::WindowMenubarRemoved
:
307 MenuBar
* pMenuBar
= static_cast<MenuBar
*>(rVclWindowEvent
.GetData());
310 uno::Reference
< accessibility::XAccessible
> xChild( pMenuBar
->GetAccessible() );
313 aOldValue
<<= xChild
;
314 NotifyAccessibleEvent( accessibility::AccessibleEventId::CHILD
, aOldValue
, aNewValue
);
319 case VclEventId::WindowMinimize
:
321 aNewValue
<<= accessibility::AccessibleStateType::ICONIFIED
;
322 NotifyAccessibleEvent( accessibility::AccessibleEventId::STATE_CHANGED
, aOldValue
, aNewValue
);
325 case VclEventId::WindowNormalize
:
327 aOldValue
<<= accessibility::AccessibleStateType::ICONIFIED
;
328 NotifyAccessibleEvent( accessibility::AccessibleEventId::STATE_CHANGED
, aOldValue
, aNewValue
);
338 void VCLXAccessibleComponent::disposing()
342 OAccessibleExtendedComponentHelper::disposing();
344 m_xVCLXWindow
.clear();
347 VclPtr
<vcl::Window
> VCLXAccessibleComponent::GetWindow() const
349 return GetVCLXWindow() ? GetVCLXWindow()->GetWindow()
350 : VclPtr
<vcl::Window
>();
353 void VCLXAccessibleComponent::FillAccessibleRelationSet( utl::AccessibleRelationSetHelper
& rRelationSet
)
355 VclPtr
<vcl::Window
> pWindow
= GetWindow();
358 vcl::Window
*pLabeledBy
= pWindow
->GetAccessibleRelationLabeledBy();
359 if ( pLabeledBy
&& pLabeledBy
!= pWindow
)
361 uno::Sequence
< uno::Reference
< uno::XInterface
> > aSequence
{ pLabeledBy
->GetAccessible() };
362 rRelationSet
.AddRelation( accessibility::AccessibleRelation( accessibility::AccessibleRelationType::LABELED_BY
, aSequence
) );
365 vcl::Window
* pLabelFor
= pWindow
->GetAccessibleRelationLabelFor();
366 if ( pLabelFor
&& pLabelFor
!= pWindow
)
368 uno::Sequence
< uno::Reference
< uno::XInterface
> > aSequence
{ pLabelFor
->GetAccessible() };
369 rRelationSet
.AddRelation( accessibility::AccessibleRelation( accessibility::AccessibleRelationType::LABEL_FOR
, aSequence
) );
372 vcl::Window
* pMemberOf
= pWindow
->GetAccessibleRelationMemberOf();
373 if ( pMemberOf
&& pMemberOf
!= pWindow
)
375 uno::Sequence
< uno::Reference
< uno::XInterface
> > aSequence
{ pMemberOf
->GetAccessible() };
376 rRelationSet
.AddRelation( accessibility::AccessibleRelation( accessibility::AccessibleRelationType::MEMBER_OF
, aSequence
) );
379 for (const auto& rExtraRelation
: pWindow
->GetExtraAccessibleRelations())
380 rRelationSet
.AddRelation(rExtraRelation
);
384 void VCLXAccessibleComponent::FillAccessibleStateSet( utl::AccessibleStateSetHelper
& rStateSet
)
386 VclPtr
<vcl::Window
> pWindow
= GetWindow();
389 if ( pWindow
->IsVisible() )
391 rStateSet
.AddState( accessibility::AccessibleStateType::VISIBLE
);
392 rStateSet
.AddState( accessibility::AccessibleStateType::SHOWING
);
396 rStateSet
.AddState( accessibility::AccessibleStateType::INVALID
);
399 if ( pWindow
->IsEnabled() )
401 rStateSet
.AddState( accessibility::AccessibleStateType::ENABLED
);
402 rStateSet
.AddState( accessibility::AccessibleStateType::SENSITIVE
);
405 if ( pWindow
->HasChildPathFocus() &&
406 ( getAccessibleRole() == accessibility::AccessibleRole::FRAME
||
407 getAccessibleRole() == accessibility::AccessibleRole::ALERT
||
408 getAccessibleRole() == accessibility::AccessibleRole::DIALOG
) ) // #i18891#
409 rStateSet
.AddState( accessibility::AccessibleStateType::ACTIVE
);
411 if ( pWindow
->HasFocus() || ( pWindow
->IsCompoundControl() && pWindow
->HasChildPathFocus() ) )
412 rStateSet
.AddState( accessibility::AccessibleStateType::FOCUSED
);
414 if ( pWindow
->IsWait() )
415 rStateSet
.AddState( accessibility::AccessibleStateType::BUSY
);
417 if ( pWindow
->GetStyle() & WB_SIZEABLE
)
418 rStateSet
.AddState( accessibility::AccessibleStateType::RESIZABLE
);
419 // 6. frame doesn't have MOVABLE state
420 // 10. for password text, where is the sensitive state?
421 if( ( getAccessibleRole() == accessibility::AccessibleRole::FRAME
||getAccessibleRole() == accessibility::AccessibleRole::DIALOG
)&& pWindow
->GetStyle() & WB_MOVEABLE
)
422 rStateSet
.AddState( accessibility::AccessibleStateType::MOVEABLE
);
423 if( pWindow
->IsDialog() )
425 Dialog
*pDlg
= static_cast< Dialog
* >( pWindow
.get() );
426 if( pDlg
->IsInExecute() )
427 rStateSet
.AddState( accessibility::AccessibleStateType::MODAL
);
429 //If a combobox or list's edit child isn't read-only,EDITABLE state
431 if( pWindow
&& pWindow
->GetType() == WindowType::COMBOBOX
)
433 if( !( pWindow
->GetStyle() & WB_READONLY
) ||
434 !static_cast<Edit
*>(pWindow
.get())->IsReadOnly() )
435 rStateSet
.AddState( accessibility::AccessibleStateType::EDITABLE
);
438 VclPtr
<vcl::Window
> pChild
= pWindow
->GetWindow( GetWindowType::FirstChild
);
440 while( pWindow
&& pChild
)
442 VclPtr
<vcl::Window
> pWinTemp
= pChild
->GetWindow( GetWindowType::FirstChild
);
443 if( pWinTemp
&& pWinTemp
->GetType() == WindowType::EDIT
)
445 if( !( pWinTemp
->GetStyle() & WB_READONLY
) ||
446 !static_cast<Edit
*>(pWinTemp
.get())->IsReadOnly() )
447 rStateSet
.AddState( accessibility::AccessibleStateType::EDITABLE
);
450 if( pChild
->GetType() == WindowType::EDIT
)
452 if( !( pChild
->GetStyle() & WB_READONLY
) ||
453 !static_cast<Edit
*>(pChild
.get())->IsReadOnly())
454 rStateSet
.AddState( accessibility::AccessibleStateType::EDITABLE
);
457 pChild
= pChild
->GetWindow( GetWindowType::Next
);
462 rStateSet
.AddState( accessibility::AccessibleStateType::DEFUNC
);
467 MUST BE SET FROM DERIVED CLASSES:
490 // accessibility::XAccessibleContext
491 sal_Int32
VCLXAccessibleComponent::getAccessibleChildCount()
493 OExternalLockGuard
aGuard( this );
495 sal_Int32 nChildren
= 0;
497 nChildren
= GetWindow()->GetAccessibleChildWindowCount();
502 uno::Reference
< accessibility::XAccessible
> VCLXAccessibleComponent::getAccessibleChild( sal_Int32 i
)
504 OExternalLockGuard
aGuard( this );
506 if ( i
>= getAccessibleChildCount() )
507 throw lang::IndexOutOfBoundsException();
509 uno::Reference
< accessibility::XAccessible
> xAcc
;
512 vcl::Window
* pChild
= GetWindow()->GetAccessibleChildWindow( static_cast<sal_uInt16
>(i
) );
514 xAcc
= pChild
->GetAccessible();
520 uno::Reference
< accessibility::XAccessible
> VCLXAccessibleComponent::getVclParent() const
522 uno::Reference
< accessibility::XAccessible
> xAcc
;
525 vcl::Window
* pParent
= GetWindow()->GetAccessibleParentWindow();
527 xAcc
= pParent
->GetAccessible();
532 uno::Reference
< accessibility::XAccessible
> VCLXAccessibleComponent::getAccessibleParent( )
534 OExternalLockGuard
aGuard( this );
536 // we do _not_ have a foreign-controlled parent -> default to our VCL parent
537 uno::Reference
< accessibility::XAccessible
> xAcc
= getVclParent();
542 sal_Int32
VCLXAccessibleComponent::getAccessibleIndexInParent( )
544 OExternalLockGuard
aGuard( this );
546 sal_Int32 nIndex
= -1;
550 vcl::Window
* pParent
= GetWindow()->GetAccessibleParentWindow();
553 // Iterate over all the parent's children and search for this object.
554 // this should be compatible with the code in SVX
555 uno::Reference
< accessibility::XAccessible
> xParentAcc( pParent
->GetAccessible() );
556 if ( xParentAcc
.is() )
558 uno::Reference
< accessibility::XAccessibleContext
> xParentContext ( xParentAcc
->getAccessibleContext() );
559 if ( xParentContext
.is() )
561 sal_Int32 nChildCount
= xParentContext
->getAccessibleChildCount();
562 for ( sal_Int32 i
=0; i
<nChildCount
; i
++ )
564 uno::Reference
< accessibility::XAccessible
> xChild( xParentContext
->getAccessibleChild(i
) );
567 uno::Reference
< accessibility::XAccessibleContext
> xChildContext
= xChild
->getAccessibleContext();
568 if ( xChildContext
== static_cast<accessibility::XAccessibleContext
*>(this) )
582 sal_Int16
VCLXAccessibleComponent::getAccessibleRole( )
584 OExternalLockGuard
aGuard( this );
589 nRole
= GetWindow()->GetAccessibleRole();
594 OUString
VCLXAccessibleComponent::getAccessibleDescription( )
596 OExternalLockGuard
aGuard( this );
598 OUString aDescription
;
601 aDescription
= GetWindow()->GetAccessibleDescription();
606 OUString
VCLXAccessibleComponent::getAccessibleName( )
608 OExternalLockGuard
aGuard( this );
613 aName
= GetWindow()->GetAccessibleName();
614 #if OSL_DEBUG_LEVEL > 0
615 aName
+= " (Type = ";
616 aName
+= OUString::number(static_cast<sal_Int32
>(GetWindow()->GetType()));
623 OUString
VCLXAccessibleComponent::getAccessibleId( )
625 OExternalLockGuard
aGuard( this );
630 const OUString
&aWindowId
= GetWindow()->get_id();
636 uno::Reference
< accessibility::XAccessibleRelationSet
> VCLXAccessibleComponent::getAccessibleRelationSet( )
638 OExternalLockGuard
aGuard( this );
640 utl::AccessibleRelationSetHelper
* pRelationSetHelper
= new utl::AccessibleRelationSetHelper
;
641 uno::Reference
< accessibility::XAccessibleRelationSet
> xSet
= pRelationSetHelper
;
642 FillAccessibleRelationSet( *pRelationSetHelper
);
646 uno::Reference
< accessibility::XAccessibleStateSet
> VCLXAccessibleComponent::getAccessibleStateSet( )
648 OExternalLockGuard
aGuard( this );
650 utl::AccessibleStateSetHelper
* pStateSetHelper
= new utl::AccessibleStateSetHelper
;
651 uno::Reference
< accessibility::XAccessibleStateSet
> xSet
= pStateSetHelper
;
652 FillAccessibleStateSet( *pStateSetHelper
);
656 lang::Locale
VCLXAccessibleComponent::getLocale()
658 OExternalLockGuard
aGuard( this );
660 return Application::GetSettings().GetLanguageTag().getLocale();
663 uno::Reference
< accessibility::XAccessible
> VCLXAccessibleComponent::getAccessibleAtPoint( const awt::Point
& rPoint
)
665 OExternalLockGuard
aGuard( this );
667 uno::Reference
< accessibility::XAccessible
> xChild
;
668 for ( sal_uInt32 i
= 0, nCount
= getAccessibleChildCount(); i
< nCount
; ++i
)
670 uno::Reference
< accessibility::XAccessible
> xAcc
= getAccessibleChild( i
);
673 uno::Reference
< accessibility::XAccessibleComponent
> xComp( xAcc
->getAccessibleContext(), uno::UNO_QUERY
);
676 tools::Rectangle aRect
= VCLRectangle( xComp
->getBounds() );
677 Point aPos
= VCLPoint( rPoint
);
678 if ( aRect
.IsInside( aPos
) )
690 // accessibility::XAccessibleComponent
691 awt::Rectangle
VCLXAccessibleComponent::implGetBounds()
693 awt::Rectangle
aBounds ( 0, 0, 0, 0 );
695 VclPtr
<vcl::Window
> pWindow
= GetWindow();
698 tools::Rectangle aRect
= pWindow
->GetWindowExtentsRelative( nullptr );
699 aBounds
= AWTRectangle( aRect
);
700 vcl::Window
* pParent
= pWindow
->GetAccessibleParentWindow();
703 tools::Rectangle aParentRect
= pParent
->GetWindowExtentsRelative( nullptr );
704 awt::Point aParentScreenLoc
= AWTPoint( aParentRect
.TopLeft() );
705 aBounds
.X
-= aParentScreenLoc
.X
;
706 aBounds
.Y
-= aParentScreenLoc
.Y
;
713 awt::Point
VCLXAccessibleComponent::getLocationOnScreen( )
715 OExternalLockGuard
aGuard( this );
720 tools::Rectangle aRect
= GetWindow()->GetWindowExtentsRelative( nullptr );
721 aPos
.X
= aRect
.Left();
722 aPos
.Y
= aRect
.Top();
728 void VCLXAccessibleComponent::grabFocus( )
730 OExternalLockGuard
aGuard( this );
732 uno::Reference
< accessibility::XAccessibleStateSet
> xStates
= getAccessibleStateSet();
733 if ( m_xVCLXWindow
.is() && xStates
.is() && xStates
->contains( accessibility::AccessibleStateType::FOCUSABLE
) )
734 m_xVCLXWindow
->setFocus();
737 sal_Int32 SAL_CALL
VCLXAccessibleComponent::getForeground( )
739 OExternalLockGuard
aGuard( this );
742 VclPtr
<vcl::Window
> pWindow
= GetWindow();
745 if ( pWindow
->IsControlForeground() )
746 nColor
= pWindow
->GetControlForeground();
750 if ( pWindow
->IsControlFont() )
751 aFont
= pWindow
->GetControlFont();
753 aFont
= pWindow
->GetFont();
754 nColor
= aFont
.GetColor();
755 // COL_AUTO is not very meaningful for AT
756 if ( nColor
== COL_AUTO
)
757 nColor
= pWindow
->GetTextColor();
761 return sal_Int32(nColor
);
764 sal_Int32 SAL_CALL
VCLXAccessibleComponent::getBackground( )
766 OExternalLockGuard
aGuard( this );
769 VclPtr
<vcl::Window
> pWindow
= GetWindow();
772 if ( pWindow
->IsControlBackground() )
773 nColor
= pWindow
->GetControlBackground();
775 nColor
= pWindow
->GetBackground().GetColor();
778 return sal_Int32(nColor
);
781 // XAccessibleExtendedComponent
783 uno::Reference
< awt::XFont
> SAL_CALL
VCLXAccessibleComponent::getFont( )
785 OExternalLockGuard
aGuard( this );
787 uno::Reference
< awt::XFont
> xFont
;
788 VclPtr
<vcl::Window
> pWindow
= GetWindow();
791 uno::Reference
< awt::XDevice
> xDev( pWindow
->GetComponentInterface(), uno::UNO_QUERY
);
795 if ( pWindow
->IsControlFont() )
796 aFont
= pWindow
->GetControlFont();
798 aFont
= pWindow
->GetFont();
799 VCLXFont
* pVCLXFont
= new VCLXFont
;
800 pVCLXFont
->Init( *xDev
, aFont
);
808 OUString SAL_CALL
VCLXAccessibleComponent::getTitledBorderText( )
810 OExternalLockGuard
aGuard( this );
814 sRet
= GetWindow()->GetText();
819 OUString SAL_CALL
VCLXAccessibleComponent::getToolTipText( )
821 OExternalLockGuard
aGuard( this );
825 sRet
= GetWindow()->GetQuickHelpText();
830 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */