Files
libreoffice/toolkit/source/awt/vclxaccessiblecomponent.cxx

733 lines
23 KiB
C++
Raw Normal View History

2002-02-14 16:23:20 +00:00
/*************************************************************************
*
* $RCSfile: vclxaccessiblecomponent.cxx,v $
*
* $Revision: 1.13 $
2002-02-14 16:23:20 +00:00
*
* last change: $Author: fs $ $Date: 2002-05-08 15:44:41 $
2002-02-14 16:23:20 +00:00
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifndef _DRAFTS_COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLEROLE_HPP_
#include <drafts/com/sun/star/accessibility/AccessibleRole.hpp>
#endif
#ifndef _DRAFTS_COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLESTATETYPE_HPP_
#include <drafts/com/sun/star/accessibility/AccessibleStateType.hpp>
#endif
2002-03-04 14:47:34 +00:00
#ifndef _DRAFTS_COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLEEVENTID_HPP_
#include <drafts/com/sun/star/accessibility/AccessibleEventId.hpp>
#endif
#ifndef _DRAFTS_COM_SUN_STAR_ACCESSIBILITY_XACCESSIBLEEVENTLISTENER_HPP_
#include <drafts/com/sun/star/accessibility/XAccessibleEventListener.hpp>
#endif
#ifndef _COM_SUN_STAR_AWT_KEYEVENT_HPP_
#include <com/sun/star/awt/KeyEvent.hpp>
#endif
#ifndef _COM_SUN_STAR_AWT_KEYMODIFIER_HPP_
#include <com/sun/star/awt/KeyModifier.hpp>
#endif
#ifndef _COM_SUN_STAR_AWT_KEY_HPP_
#include <com/sun/star/awt/Key.hpp>
#endif
2002-02-14 16:23:20 +00:00
#ifndef _TOOLKIT_AWT_VCLXACCESSIBLECOMPONENT_HXX_
2002-02-14 16:23:20 +00:00
#include <toolkit/awt/vclxaccessiblecomponent.hxx>
#endif
#ifndef _TOOLKIT_AWT_VCLXWINDOW_HXX_
2002-02-14 16:23:20 +00:00
#include <toolkit/awt/vclxwindow.hxx>
#endif
#ifndef _TOOLKIT_HELPER_CONVERT_HXX_
2002-02-14 16:23:20 +00:00
#include <toolkit/helper/convert.hxx>
#endif
#ifndef _SV_WINDOW_HXX
2002-02-14 16:23:20 +00:00
#include <vcl/window.hxx>
#endif
#ifndef _TOOLS_DEBUG_HXX
2002-02-27 08:40:21 +00:00
#include <tools/debug.hxx>
#endif
2002-02-14 16:23:20 +00:00
#ifndef _UTL_ACCESSIBLESTATESETHELPER_HXX_
2002-02-14 16:23:20 +00:00
#include <unotools/accessiblestatesethelper.hxx>
#endif
#ifndef _SV_SVAPP_HXX
#include <vcl/svapp.hxx>
#endif
2002-02-14 16:23:20 +00:00
#ifndef MNEMONIC_CHAR
#define MNEMONIC_CHAR ((sal_Unicode)'~')
#endif
2002-03-04 14:47:34 +00:00
using namespace ::com::sun::star;
using namespace ::drafts::com::sun::star;
using namespace ::comphelper;
2002-03-04 14:47:34 +00:00
// ----------------------------------------------------
// class VCLExternalSolarLock
// ----------------------------------------------------
class VCLExternalSolarLock : public ::comphelper::IMutex
{
public:
virtual void acquire();
virtual void release();
};
//......................................................
void VCLExternalSolarLock::acquire()
{
Application::GetSolarMutex().acquire();
}
//......................................................
void VCLExternalSolarLock::release()
{
Application::GetSolarMutex().release();
}
2002-02-14 16:23:20 +00:00
// ----------------------------------------------------
// class VCLXAccessibleComponent
// ----------------------------------------------------
VCLXAccessibleComponent::VCLXAccessibleComponent( VCLXWindow* pVCLXindow )
: VCLXAccessibleComponentBase( new VCLExternalSolarLock() )
, OAccessibleImplementationAccess( )
2002-02-14 16:23:20 +00:00
{
mpVCLXindow = pVCLXindow;
mxWindow = pVCLXindow;
2002-02-27 08:40:21 +00:00
m_pSolarLock = static_cast< VCLExternalSolarLock* >( getExternalLock( ) );
DBG_ASSERT( pVCLXindow->GetWindow(), "VCLXAccessibleComponent - no window!" );
if ( pVCLXindow->GetWindow() )
2002-02-27 08:40:21 +00:00
pVCLXindow->GetWindow()->AddEventListener( LINK( this, VCLXAccessibleComponent, WindowEventListener ) );
// announce the XAccessible of our creator to the base class
lateInit( pVCLXindow );
2002-02-14 16:23:20 +00:00
}
VCLXAccessibleComponent::~VCLXAccessibleComponent()
{
ensureDisposed();
if ( mpVCLXindow && mpVCLXindow->GetWindow() )
mpVCLXindow->GetWindow()->RemoveEventListener( LINK( this, VCLXAccessibleComponent, WindowEventListener ) );
delete m_pSolarLock;
m_pSolarLock = NULL;
// This is not completely sure. If we assume that the base class dtor calls some method which
// uses this lock, the we crash. However, as the base class' dtor does not have a chance to call _out_
// virtual methods, this is no problem as long as the base class is safe, i.e. does not use the external
// lock from within it's dtor. At the moment, we _know_ the base class is safe in this respect, so
// let's assume it keeps this way.
// @see OAccessibleContextHelper::OAccessibleContextHelper( IMutex* )
2002-02-27 08:40:21 +00:00
}
IMPLEMENT_FORWARD_XINTERFACE2( VCLXAccessibleComponent, VCLXAccessibleComponentBase, OAccessibleImplementationAccess )
IMPLEMENT_FORWARD_XTYPEPROVIDER2( VCLXAccessibleComponent, VCLXAccessibleComponentBase, OAccessibleImplementationAccess )
2002-02-27 08:40:21 +00:00
IMPL_LINK( VCLXAccessibleComponent, WindowEventListener, VclSimpleEvent*, pEvent )
{
DBG_ASSERT( pEvent && pEvent->ISA( VclWindowEvent ), "Unknown WindowEvent!" );
if ( pEvent && pEvent->ISA( VclWindowEvent ) )
{
2002-03-13 11:17:30 +00:00
DBG_ASSERT( ((VclWindowEvent*)pEvent)->GetWindow(), "Window???" );
2002-02-27 08:40:21 +00:00
ProcessWindowEvent( *(VclWindowEvent*)pEvent );
}
return 0;
}
void VCLXAccessibleComponent::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
{
2002-03-13 11:17:30 +00:00
uno::Any aOldValue, aNewValue;
Window* pWindow = rVclWindowEvent.GetWindow();
DBG_ASSERT( pWindow, "VCLXAccessibleComponent::ProcessWindowEvent - Window?" );
2002-02-27 08:40:21 +00:00
switch ( rVclWindowEvent.GetId() )
{
2002-04-29 09:52:27 +00:00
case VCLEVENT_WINDOW_CHILDCREATED:
{
Window* pWindow = (Window*) rVclWindowEvent.GetData();
DBG_ASSERT( pWindow, "VCLEVENT_WINDOW_CHILDCREATED - Window=?" );
// aNewValue <<= pWindow->GetAccessible();
NotifyAccessibleEvent( accessibility::AccessibleEventId::ACCESSIBLE_CHILD_EVENT, aOldValue, aNewValue );
}
break;
case VCLEVENT_WINDOW_CHILDDESTROYED:
{
Window* pWindow = (Window*) rVclWindowEvent.GetData();
DBG_ASSERT( pWindow, "VCLEVENT_WINDOW_CHILDDESTROYED - Window=?" );
// aOldValue <<= pWindow->GetAccessible();
NotifyAccessibleEvent( accessibility::AccessibleEventId::ACCESSIBLE_CHILD_EVENT, aOldValue, aNewValue );
}
break;
2002-03-04 14:47:34 +00:00
case VCLEVENT_WINDOW_SHOW:
2002-03-13 11:17:30 +00:00
{
aNewValue <<= accessibility::AccessibleStateType::VISIBLE;
NotifyAccessibleEvent( accessibility::AccessibleEventId::ACCESSIBLE_STATE_EVENT, aOldValue, aNewValue );
aNewValue <<= accessibility::AccessibleStateType::SHOWING;
NotifyAccessibleEvent( accessibility::AccessibleEventId::ACCESSIBLE_STATE_EVENT, aOldValue, aNewValue );
aNewValue.clear();
aOldValue <<= accessibility::AccessibleStateType::INVALID;
NotifyAccessibleEvent( accessibility::AccessibleEventId::ACCESSIBLE_STATE_EVENT, aOldValue, aNewValue );
}
break;
2002-03-04 14:47:34 +00:00
case VCLEVENT_WINDOW_HIDE:
2002-03-13 11:17:30 +00:00
{
aOldValue <<= accessibility::AccessibleStateType::VISIBLE;
NotifyAccessibleEvent( accessibility::AccessibleEventId::ACCESSIBLE_STATE_EVENT, aOldValue, aNewValue );
aOldValue <<= accessibility::AccessibleStateType::SHOWING;
NotifyAccessibleEvent( accessibility::AccessibleEventId::ACCESSIBLE_STATE_EVENT, aOldValue, aNewValue );
aOldValue.clear();
aNewValue <<= accessibility::AccessibleStateType::INVALID;
NotifyAccessibleEvent( accessibility::AccessibleEventId::ACCESSIBLE_STATE_EVENT, aOldValue, aNewValue );
}
break;
2002-03-04 14:47:34 +00:00
case VCLEVENT_WINDOW_ACTIVATE:
2002-03-13 11:17:30 +00:00
{
aNewValue <<= accessibility::AccessibleStateType::ACTIVE;
NotifyAccessibleEvent( accessibility::AccessibleEventId::ACCESSIBLE_STATE_EVENT, aOldValue, aNewValue );
}
break;
2002-03-04 14:47:34 +00:00
case VCLEVENT_WINDOW_DEACTIVATE:
2002-03-13 11:17:30 +00:00
{
aOldValue <<= accessibility::AccessibleStateType::ACTIVE;
NotifyAccessibleEvent( accessibility::AccessibleEventId::ACCESSIBLE_STATE_EVENT, aOldValue, aNewValue );
}
break;
2002-03-04 14:47:34 +00:00
case VCLEVENT_WINDOW_GETFOCUS:
case VCLEVENT_CONTROL_GETFOCUS:
{
2002-03-13 11:17:30 +00:00
aNewValue <<= accessibility::AccessibleStateType::FOCUSED;
NotifyAccessibleEvent( accessibility::AccessibleEventId::ACCESSIBLE_STATE_EVENT, aOldValue, aNewValue );
2002-03-04 14:47:34 +00:00
}
break;
2002-03-13 11:17:30 +00:00
case VCLEVENT_WINDOW_LOSEFOCUS:
case VCLEVENT_CONTROL_LOSEFOCUS:
2002-03-04 14:47:34 +00:00
{
2002-03-13 11:17:30 +00:00
aOldValue <<= accessibility::AccessibleStateType::FOCUSED;
NotifyAccessibleEvent( accessibility::AccessibleEventId::ACCESSIBLE_STATE_EVENT, aOldValue, aNewValue );
2002-03-04 14:47:34 +00:00
}
break;
2002-03-13 11:17:30 +00:00
// MT: Missing event for enabled !!!
}
2002-02-14 16:23:20 +00:00
}
void VCLXAccessibleComponent::disposing()
{
if ( mpVCLXindow && mpVCLXindow->GetWindow() )
mpVCLXindow->GetWindow()->RemoveEventListener( LINK( this, VCLXAccessibleComponent, WindowEventListener ) );
2002-02-27 08:40:21 +00:00
VCLXAccessibleComponentBase::disposing();
2002-03-04 14:47:34 +00:00
2002-02-14 16:23:20 +00:00
mxWindow.clear();
2002-02-27 08:40:21 +00:00
mpVCLXindow = NULL;
2002-02-14 16:23:20 +00:00
}
Window* VCLXAccessibleComponent::GetWindow() const
{
return GetVCLXWindow() ? GetVCLXWindow()->GetWindow() : NULL;
}
2002-02-14 18:45:43 +00:00
void VCLXAccessibleComponent::FillAccessibleStateSet( utl::AccessibleStateSetHelper& rStateSet )
2002-02-14 16:23:20 +00:00
{
Window* pWindow = GetWindow();
if ( pWindow )
{
if ( pWindow->IsVisible() )
{
rStateSet.AddState( accessibility::AccessibleStateType::VISIBLE );
rStateSet.AddState( accessibility::AccessibleStateType::SHOWING );
}
else
{
rStateSet.AddState( accessibility::AccessibleStateType::INVALID );
}
if ( pWindow->IsEnabled() )
rStateSet.AddState( accessibility::AccessibleStateType::ENABLED );
if ( pWindow->HasChildPathFocus() )
rStateSet.AddState( accessibility::AccessibleStateType::ACTIVE );
if ( pWindow->HasFocus() )
rStateSet.AddState( accessibility::AccessibleStateType::FOCUSED );
if ( pWindow->IsWait() )
rStateSet.AddState( accessibility::AccessibleStateType::BUSY );
if ( pWindow->GetStyle() & WB_SIZEABLE )
rStateSet.AddState( accessibility::AccessibleStateType::RESIZABLE );
}
else
{
rStateSet.AddState( accessibility::AccessibleStateType::DEFUNC );
}
/*
MUST BE SET FROM DERIVED CLASSES:
CHECKED
COLLAPSED
EXPANDED
EXPANDABLE
EDITABLE
FOCUSABLE
HORIZONTAL
VERTICAL
ICONIFIED
MODAL
MULTILINE
MULTISELECTABLE
PRESSED
SELECTABLE
SELECTED
SINGLE_LINE
TRANSIENT
*/
2002-02-14 16:23:20 +00:00
}
2002-03-04 14:47:34 +00:00
// accessibility::XAccessibleContext
sal_Int32 VCLXAccessibleComponent::getAccessibleChildCount() throw (uno::RuntimeException)
2002-02-14 16:23:20 +00:00
{
OContextEntryGuard( this );
2002-02-14 16:23:20 +00:00
sal_Int32 nChildren = 0;
if ( GetWindow() )
2002-02-14 16:48:20 +00:00
nChildren = GetWindow()->GetAccessibleChildWindowCount();
2002-02-14 16:23:20 +00:00
return nChildren;
}
2002-03-04 14:47:34 +00:00
uno::Reference< accessibility::XAccessible > VCLXAccessibleComponent::getAccessibleChild( sal_Int32 i ) throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
2002-02-14 16:23:20 +00:00
{
2002-02-14 18:45:43 +00:00
if ( i >= getAccessibleChildCount() )
2002-03-04 14:47:34 +00:00
throw lang::IndexOutOfBoundsException();
2002-02-14 18:45:43 +00:00
OContextEntryGuard( this );
2002-02-14 16:23:20 +00:00
2002-03-04 14:47:34 +00:00
uno::Reference< accessibility::XAccessible > xAcc;
2002-02-14 16:23:20 +00:00
if ( GetWindow() )
{
Window* pChild = GetWindow()->GetAccessibleChildWindow( (USHORT)i );
if ( pChild )
xAcc = pChild->GetAccessible();
}
return xAcc;
}
uno::Reference< accessibility::XAccessible > VCLXAccessibleComponent::getVclParent() const
2002-02-14 16:23:20 +00:00
{
2002-03-04 14:47:34 +00:00
uno::Reference< accessibility::XAccessible > xAcc;
2002-02-14 16:23:20 +00:00
if ( GetWindow() )
{
Window* pParent = GetWindow()->GetAccessibleParentWindow();
if ( pParent )
2002-02-14 18:45:43 +00:00
xAcc = pParent->GetAccessible();
2002-02-14 16:23:20 +00:00
}
return xAcc;
}
uno::Reference< accessibility::XAccessible > VCLXAccessibleComponent::getAccessibleParent( ) throw (uno::RuntimeException)
{
OContextEntryGuard( this );
uno::Reference< accessibility::XAccessible > xAcc( implGetForeignControlledParent() );
if ( !xAcc.is() )
// we do _not_ have a foreign-controlled parent -> default to our VCL parent
xAcc = getVclParent();
2002-02-14 16:23:20 +00:00
return xAcc;
}
2002-03-04 14:47:34 +00:00
sal_Int32 VCLXAccessibleComponent::getAccessibleIndexInParent( ) throw (uno::RuntimeException)
2002-02-14 16:23:20 +00:00
{
OContextEntryGuard( this );
2002-02-14 16:23:20 +00:00
sal_Int32 nIndex = -1;
uno::Reference< accessibility::XAccessible > xAcc( implGetForeignControlledParent() );
if ( xAcc.is() )
{ // we _do_ have a foreign-controlled parent -> use the base class' implementation,
// which goes the UNO way
nIndex = VCLXAccessibleComponentBase::getAccessibleIndexInParent( );
}
else
2002-02-14 16:23:20 +00:00
{
if ( GetWindow() )
2002-02-14 16:23:20 +00:00
{
Window* pParent = GetWindow()->GetAccessibleParentWindow();
if ( pParent )
2002-02-14 16:23:20 +00:00
{
for ( USHORT n = pParent->GetAccessibleChildWindowCount(); n; )
2002-02-14 16:23:20 +00:00
{
Window* pChild = pParent->GetAccessibleChildWindow( --n );
if ( pChild == GetWindow() )
{
nIndex = n;
break;
}
2002-02-14 16:23:20 +00:00
}
}
}
}
return nIndex;
}
2002-03-04 14:47:34 +00:00
sal_Int16 VCLXAccessibleComponent::getAccessibleRole( ) throw (uno::RuntimeException)
2002-02-14 16:23:20 +00:00
{
OContextEntryGuard( this );
2002-02-14 16:23:20 +00:00
sal_Int16 nRole = 0;
2002-02-14 18:45:43 +00:00
2002-02-14 16:23:20 +00:00
if ( GetWindow() )
2002-02-14 18:45:43 +00:00
nRole = GetWindow()->GetAccessibleRole();
2002-02-14 16:23:20 +00:00
return nRole;
}
2002-03-04 14:47:34 +00:00
::rtl::OUString VCLXAccessibleComponent::getAccessibleDescription( ) throw (uno::RuntimeException)
2002-02-14 16:23:20 +00:00
{
OContextEntryGuard( this );
2002-02-14 16:23:20 +00:00
::rtl::OUString aDescription;
2002-02-14 18:45:43 +00:00
2002-02-14 16:23:20 +00:00
if ( GetWindow() )
2002-02-14 18:45:43 +00:00
aDescription = GetWindow()->GetAccessibleDescription();
2002-02-14 16:23:20 +00:00
return aDescription;
}
2002-03-04 14:47:34 +00:00
::rtl::OUString VCLXAccessibleComponent::getAccessibleName( ) throw (uno::RuntimeException)
2002-02-14 16:23:20 +00:00
{
OContextEntryGuard( this );
2002-02-14 16:23:20 +00:00
::rtl::OUString aName;
if ( GetWindow() )
{
2002-02-14 18:45:43 +00:00
aName = GetWindow()->GetAccessibleName();
2002-02-14 16:23:20 +00:00
#ifdef DEBUG
aName += String( RTL_CONSTASCII_USTRINGPARAM( " (Type = " ) );
aName += String::CreateFromInt32( GetWindow()->GetType() );
aName += String( RTL_CONSTASCII_USTRINGPARAM( ")" ) );
#endif
}
return aName;
}
2002-03-04 14:47:34 +00:00
uno::Reference< accessibility::XAccessibleRelationSet > VCLXAccessibleComponent::getAccessibleRelationSet( ) throw (uno::RuntimeException)
2002-02-14 16:23:20 +00:00
{
OContextEntryGuard( this );
2002-02-14 16:23:20 +00:00
return NULL;
}
2002-03-04 14:47:34 +00:00
uno::Reference< accessibility::XAccessibleStateSet > VCLXAccessibleComponent::getAccessibleStateSet( ) throw (uno::RuntimeException)
2002-02-14 16:23:20 +00:00
{
OContextEntryGuard( this );
2002-02-14 16:23:20 +00:00
2002-02-14 18:45:43 +00:00
utl::AccessibleStateSetHelper* pStateSetHelper = new utl::AccessibleStateSetHelper;
2002-03-04 14:47:34 +00:00
uno::Reference< accessibility::XAccessibleStateSet > xSet = pStateSetHelper;
2002-02-14 18:45:43 +00:00
FillAccessibleStateSet( *pStateSetHelper );
return xSet;
// return NULL;
2002-02-14 16:23:20 +00:00
}
2002-03-04 14:47:34 +00:00
lang::Locale VCLXAccessibleComponent::getLocale() throw (accessibility::IllegalAccessibleComponentStateException, uno::RuntimeException)
2002-02-14 16:23:20 +00:00
{
OContextEntryGuard( this );
2002-02-14 16:23:20 +00:00
2002-03-04 14:47:34 +00:00
lang::Locale aLocale;
2002-02-14 16:23:20 +00:00
if ( GetWindow() )
aLocale = GetWindow()->GetSettings().GetUILocale();
return aLocale;
}
2002-03-04 14:47:34 +00:00
uno::Reference< accessibility::XAccessible > VCLXAccessibleComponent::getAccessibleAt( const awt::Point& rPoint ) throw (uno::RuntimeException)
2002-02-14 16:23:20 +00:00
{
OContextEntryGuard( this );
2002-02-14 16:23:20 +00:00
2002-03-04 14:47:34 +00:00
uno::Reference< accessibility::XAccessible > xAcc;
2002-02-14 16:23:20 +00:00
if ( GetWindow() )
{
Window* pWindow = GetWindow()->FindWindow( VCLPoint( rPoint ) );
if ( pWindow && pWindow != GetWindow() )
xAcc = pWindow->GetAccessible();
2002-02-14 16:23:20 +00:00
}
return xAcc;
}
// accessibility::XAccessibleComponent
awt::Rectangle VCLXAccessibleComponent::implGetBounds() throw (uno::RuntimeException)
2002-02-14 16:23:20 +00:00
{
2002-03-04 14:47:34 +00:00
awt::Rectangle aBounds;
2002-02-14 16:23:20 +00:00
if ( mxWindow.is() )
aBounds = mxWindow->getPosSize();
uno::Reference< accessibility::XAccessible > xParent( implGetForeignControlledParent() );
if ( xParent.is() )
{ // hmm, we can't rely on our VCL coordinates, as in the Accessibility Hierarchy, somebody gave
// us a parent which is different from our VCL parent
// (actually, we did not check if it's really different ...)
// the screen location of the foreign parent
uno::Reference< accessibility::XAccessibleComponent > xParentComponent( xParent->getAccessibleContext(), uno::UNO_QUERY );
DBG_ASSERT( xParentComponent.is(), "VCLXAccessibleComponent::implGetBounds: invalid (foreign) parent component!" );
awt::Point aScreenLocForeign( 0, 0 );
if ( xParentComponent.is() )
aScreenLocForeign = xParentComponent->getLocationOnScreen();
// the screen location of the VCL parent
xParent = getVclParent();
if ( xParent.is() )
xParentComponent = xParentComponent.query( xParent->getAccessibleContext() );
awt::Point aScreenLocVCL( 0, 0 );
if ( xParentComponent.is() )
aScreenLocVCL = xParentComponent->getLocationOnScreen();
// the difference between them
awt::Size aOffset( aScreenLocVCL.X - aScreenLocForeign.X, aScreenLocVCL.Y - aScreenLocForeign.Y );
// move the bounds
aBounds.X += aOffset.Width;
aBounds.Y += aOffset.Height;
2002-02-14 16:23:20 +00:00
}
return aBounds;
2002-02-14 16:23:20 +00:00
}
2002-03-04 14:47:34 +00:00
awt::Point VCLXAccessibleComponent::getLocationOnScreen( ) throw (uno::RuntimeException)
2002-02-14 16:23:20 +00:00
{
OContextEntryGuard( this );
2002-02-14 16:23:20 +00:00
2002-03-04 14:47:34 +00:00
awt::Point aPos;
2002-02-14 16:23:20 +00:00
if ( GetWindow() )
{
Rectangle aRect = GetWindow()->GetWindowExtentsRelative( NULL );
aPos.X = aRect.Left();
aPos.Y = aRect.Top();
}
return aPos;
}
2002-03-04 14:47:34 +00:00
sal_Bool VCLXAccessibleComponent::isShowing() throw (uno::RuntimeException)
2002-02-14 16:23:20 +00:00
{
OContextEntryGuard( this );
2002-02-14 16:23:20 +00:00
sal_Bool bShowing = sal_False;
if ( GetWindow() && GetWindow()->IsVisible() )
bShowing = GetWindow()->IsReallyVisible(); // I hope IsReallyVisible is doing everything I need?
return bShowing;
}
2002-03-04 14:47:34 +00:00
sal_Bool VCLXAccessibleComponent::isVisible() throw (uno::RuntimeException)
2002-02-14 16:23:20 +00:00
{
OContextEntryGuard( this );
2002-02-14 16:23:20 +00:00
sal_Bool bVisible = sal_False;
if ( GetWindow() )
bVisible = GetWindow()->IsVisible();
return bVisible;
}
2002-03-04 14:47:34 +00:00
sal_Bool VCLXAccessibleComponent::isFocusTraversable() throw (uno::RuntimeException)
2002-02-14 16:23:20 +00:00
{
return FALSE;
}
2002-03-04 14:47:34 +00:00
void VCLXAccessibleComponent::addFocusListener( const uno::Reference< awt::XFocusListener >& xListener ) throw (uno::RuntimeException)
2002-02-14 16:23:20 +00:00
{
OContextEntryGuard( this );
2002-02-14 16:23:20 +00:00
if ( mxWindow.is() )
mxWindow->addFocusListener( xListener );
}
2002-03-04 14:47:34 +00:00
void VCLXAccessibleComponent::removeFocusListener( const uno::Reference< awt::XFocusListener >& xListener ) throw (uno::RuntimeException)
2002-02-14 16:23:20 +00:00
{
OContextEntryGuard( this );
2002-02-14 16:23:20 +00:00
if ( mxWindow.is() )
mxWindow->removeFocusListener( xListener );
}
2002-03-04 14:47:34 +00:00
void VCLXAccessibleComponent::grabFocus( ) throw (uno::RuntimeException)
2002-02-14 16:23:20 +00:00
{
OContextEntryGuard( this );
2002-02-14 16:23:20 +00:00
if ( mxWindow.is() && isFocusTraversable() )
mxWindow->setFocus();
}
2002-03-04 14:47:34 +00:00
uno::Any VCLXAccessibleComponent::getAccessibleKeyBinding() throw (uno::RuntimeException)
2002-02-14 16:23:20 +00:00
{
OContextEntryGuard( this );
uno::Any aRet;
if ( GetWindow() )
{
String sText = GetWindow()->GetText();
xub_StrLen nFound = sText.Search( MNEMONIC_CHAR );
if ( STRING_NOTFOUND != nFound && ++nFound < sText.Len() )
{
sText.ToUpperAscii();
sal_Unicode cChar = sText.GetChar( nFound );
if ( ( cChar >= '0' && cChar <= '9' ) || ( cChar >= 'A' && cChar <= 'Z' ) )
{
awt::KeyEvent aEvent;
if ( cChar >= '0' && cChar <= '9' )
aEvent.KeyCode = awt::Key::NUM0 + cChar - '0';
else if ( cChar >= 'A' && cChar <= 'Z' )
aEvent.KeyCode = awt::Key::A + cChar - 'A';
aEvent.KeyChar = cChar;
aEvent.KeyFunc = 0;
aEvent.Modifiers = awt::KeyModifier::MOD2;
aRet <<= aEvent;
}
}
}
return aRet;
2002-02-14 16:23:20 +00:00
}
// XAccessibleExtendedComponent
sal_Int32 SAL_CALL VCLXAccessibleComponent::getForeground( ) throw (uno::RuntimeException)
{
OContextEntryGuard( this );
sal_Int32 nColor = 0;
if ( GetWindow() )
nColor = GetWindow()->GetControlForeground().GetColor();
return nColor;
}
sal_Int32 SAL_CALL VCLXAccessibleComponent::getBackground( ) throw (uno::RuntimeException)
{
OContextEntryGuard( this );
sal_Int32 nColor = 0;
if ( GetWindow() )
nColor = GetWindow()->GetControlBackground().GetColor();
return nColor;
}
uno::Reference< awt::XFont > SAL_CALL VCLXAccessibleComponent::getFont( ) throw (uno::RuntimeException)
{
return uno::Reference< awt::XFont >();
}
awt::FontDescriptor SAL_CALL VCLXAccessibleComponent::getFontMetrics( const uno::Reference< awt::XFont >& xFont ) throw (uno::RuntimeException)
{
return xFont->getFontDescriptor();
}
sal_Bool SAL_CALL VCLXAccessibleComponent::isEnabled( ) throw (uno::RuntimeException)
{
OContextEntryGuard( this );
sal_Bool bEnabled = sal_False;
if ( GetWindow() )
bEnabled = GetWindow()->IsEnabled();
return bEnabled;
}
::rtl::OUString SAL_CALL VCLXAccessibleComponent::getTitledBorderText( ) throw (uno::RuntimeException)
{
OContextEntryGuard( this );
::rtl::OUString sRet;
if ( GetWindow() )
sRet = GetWindow()->GetText();
return sRet;
}
::rtl::OUString SAL_CALL VCLXAccessibleComponent::getToolTipText( ) throw (uno::RuntimeException)
{
OContextEntryGuard( this );
::rtl::OUString sRet;
if ( GetWindow() )
sRet = GetWindow()->GetQuickHelpText();
return sRet;
}