Files
libreoffice/sw/source/core/access/acccontext.cxx

940 lines
28 KiB
C++
Raw Normal View History

2002-02-04 13:10:18 +00:00
/*************************************************************************
*
* $RCSfile: acccontext.cxx,v $
*
* $Revision: 1.8 $
2002-02-04 13:10:18 +00:00
*
* last change: $Author: mib $ $Date: 2002-02-20 17:55:56 $
2002-02-04 13:10:18 +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): _______________________________________
*
*
************************************************************************/
#ifdef PRECOMPILED
#include "core_pch.hxx"
#endif
2002-02-11 11:51:16 +00:00
#if defined DEBUG && defined TEST_MIB
2002-02-04 13:10:18 +00:00
#ifndef _STRING_HXX
#include <tools/string.hxx>
#endif
#ifndef _STREAM_HXX
#include <tools/stream.hxx>
#endif
#endif
#ifndef _SV_WINDOW_HXX
#include <vcl/window.hxx>
#endif
#ifndef _ERRHDL_HXX
#include "errhdl.hxx"
#endif
#ifndef _SWTYPES_HXX
#include "swtypes.hxx"
#endif
#pragma hdrstop
2002-02-05 14:52:06 +00:00
#ifndef _DRAFTS_COM_SUN_STAR_ACCESSIBILITY_XACCESSIBLESTATESET_HPP_
#include <drafts/com/sun/star/accessibility/XAccessibleStateSet.hpp>
#endif
#ifndef _DRAFTS_COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLESTATETYPE_HPP_
2002-02-18 15:27:35 +00:00
#include <drafts/com/sun/star/accessibility/AccessibleStateType.hpp>
2002-02-05 14:52:06 +00:00
#endif
#ifndef _DRAFTS_COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLEEVENTID_HPP_
#include <drafts/com/sun/star/accessibility/AccessibleEventId.hpp>
#endif
2002-02-18 15:27:35 +00:00
#ifndef _COM_SUN_STAR_BEANS_XPROPERTYCHANGELISTENER_HPP_
#include <com/sun/star/beans/XPropertyChangeListener.hpp>
#endif
2002-02-04 13:10:18 +00:00
#ifndef _VOS_MUTEX_HXX_ //autogen
#include <vos/mutex.hxx>
#endif
#ifndef _SV_SVAPP_HXX //autogen
#include <vcl/svapp.hxx>
#endif
2002-02-05 14:52:06 +00:00
#ifndef _UTL_ACCESSIBLESTATESETHELPER_HXX_
#include <unotools/accessiblestatesethelper.hxx>
2002-02-04 13:10:18 +00:00
#endif
#ifndef _VIEWSH_HXX
#include <viewsh.hxx>
#endif
#ifndef _VIEWIMP_HXX
#include <viewimp.hxx>
#endif
2002-02-04 13:10:18 +00:00
#ifndef _ACCMAP_HXX
#include <accmap.hxx>
#endif
#ifndef _ACCCONTEXT_HXX
#include <acccontext.hxx>
#endif
2002-02-11 11:51:16 +00:00
#if defined DEBUG && defined TEST_MIB
#define DBG_MSG( _msg ) \
lcl_SwAccessibleContext_DbgMsg( this, _msg, 0, sal_False );
#define DBG_MSG_CD( _msg ) \
lcl_SwAccessibleContext_DbgMsg( this, _msg, 0, sal_True );
#define DBG_MSG_PARAM( _msg, _param ) \
lcl_SwAccessibleContext_DbgMsg( this, _msg, _param, sal_False );
#define DBG_MSG_THIS_PARAM( _msg, _this, _param ) \
lcl_SwAccessibleContext_DbgMsg( _this, _msg, _param, sal_False );
void lcl_SwAccessibleContext_DbgMsg( SwAccessibleContext *pThisAcc,
const char *pMsg,
SwAccessibleContext *pChildAcc,
sal_Bool bConstrDestr );
#else
#define DBG_MSG( _msg )
#define DBG_MSG_PARAM( _msg, _param )
#define DBG_MSG_THIS_PARAM( _msg, _this, _param )
2002-02-14 09:54:11 +00:00
#define DBG_MSG_CD( _msg )
2002-02-11 11:51:16 +00:00
#endif
2002-02-04 13:10:18 +00:00
using namespace ::com::sun::star;
using namespace ::com::sun::star::beans;
using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::uno;
using namespace ::drafts::com::sun::star::accessibility;
using namespace ::rtl;
2002-02-11 11:51:16 +00:00
void SwAccessibleContext::_Moved()
{
AccessibleEventObject aEvent;
aEvent.EventId = AccessibleEventId::ACCESSIBLE_VISIBLE_DATA_EVENT;
2002-02-04 13:10:18 +00:00
AccessibleEvent( aEvent );
2002-02-11 11:51:16 +00:00
DBG_MSG( "AccessibleVisibleData" )
}
sal_Bool SwAccessibleContext::ChildScrolledIn( const SwFrm *pFrm )
{
WeakReference < XAccessible > xWeakChild;
SwAccessibleContext *pChildImpl = 0;
if( GetMap() )
2002-02-11 11:51:16 +00:00
{
::vos::ORef < SwAccessibleContext > xChildImpl(
GetMap()->GetContextImpl( pFrm ) );
2002-02-11 11:51:16 +00:00
xChildImpl->SetParent( this );
// The accessible should be freshly created, because it
// was not visisble before. Therfor, its vis area must already
// the scrolling.
ASSERT( GetVisArea() == xChildImpl->GetVisArea(),
"Vis area of child is wrong. Did it exist already?" );
// Send a child event
AccessibleEventObject aEvent;
aEvent.EventId = AccessibleEventId::ACCESSIBLE_CHILD_EVENT;
2002-02-11 11:51:16 +00:00
Reference < XAccessible > xChild( xChildImpl.getBodyPtr() );
aEvent.NewValue <<= xChild;
AccessibleEvent( aEvent );
2002-02-11 11:51:16 +00:00
DBG_MSG_PARAM( "AccessibleChild (added)", xChildImpl.getBodyPtr() )
xWeakChild = xChild;
pChildImpl = xChildImpl.getBodyPtr();
}
Reference < XAccessible > xChild( xWeakChild );
if( xChild.is() )
{
// If the AT tool remembered the child, then we send
// notifcations for the child's children, too. Otherwise
// there is nothing to do, because children can only created
// by a parent itself, so there could in fact be children now,
// but these children already inherited the correct vis area.
// This vis area in update this area is the same as the old one,
// because
pChildImpl->SetVisArea( GetVisArea() );
}
2002-02-04 13:10:18 +00:00
2002-02-11 11:51:16 +00:00
return sal_False;
2002-02-04 13:10:18 +00:00
}
2002-02-11 11:51:16 +00:00
sal_Bool SwAccessibleContext::ChildScrolledOut( const SwFrm *pFrm )
2002-02-04 13:10:18 +00:00
{
2002-02-11 11:51:16 +00:00
sal_Bool bUpdateChildren = sal_True;
WeakReference < XAccessible > xWeakChild;
SwAccessibleContext *pChildImpl = 0;
2002-02-04 13:10:18 +00:00
if( GetMap() )
2002-02-11 11:51:16 +00:00
{
// If the child is existing, the child's chilren have to be
// removed, too. If not, some grandchildren might exist anyway.
// They are removed by seekaing the SwFrm tree. This is indicated
// by the return value.
::vos::ORef < SwAccessibleContext > xChildImpl(
GetMap()->GetContextImpl( pFrm, sal_False ) );
2002-02-11 11:51:16 +00:00
if( xChildImpl.isValid() )
{
xChildImpl->SetVisArea( GetVisArea() );
bUpdateChildren = sal_False;
pChildImpl = xChildImpl.getBodyPtr();
xWeakChild = Reference < XAccessible >( pChildImpl );
}
}
Reference < XAccessible > xChild( xWeakChild );
if( !xChild.is() && GetMap() )
2002-02-11 11:51:16 +00:00
{
::vos::ORef < SwAccessibleContext > xChildImpl(
GetMap()->GetContextImpl( pFrm ) );
2002-02-11 11:51:16 +00:00
pChildImpl = xChildImpl.getBodyPtr();
xChild = pChildImpl;
}
2002-02-04 13:10:18 +00:00
pChildImpl->SetParent( this );
pChildImpl->Dispose();
2002-02-04 13:10:18 +00:00
2002-02-11 11:51:16 +00:00
return bUpdateChildren;
2002-02-04 13:10:18 +00:00
}
2002-02-11 11:51:16 +00:00
sal_Bool SwAccessibleContext::ChildScrolled( const SwFrm *pFrm )
2002-02-04 13:10:18 +00:00
{
2002-02-11 11:51:16 +00:00
sal_Bool bUpdateChildren = sal_True;
2002-02-04 13:10:18 +00:00
// get child
if( GetMap() )
2002-02-11 11:51:16 +00:00
{
::vos::ORef < SwAccessibleContext > xChildImpl(
GetMap()->GetContextImpl( pFrm, sal_False ) );
2002-02-05 14:52:06 +00:00
if( xChildImpl.isValid() )
{
// Now update the frame's children. In fact, they are updated before
// the update event for the parent has been send.
xChildImpl->SetVisArea( GetVisArea() );
2002-02-05 14:52:06 +00:00
xChildImpl->_Moved();
bUpdateChildren = sal_False;
}
2002-02-11 11:51:16 +00:00
}
2002-02-04 13:10:18 +00:00
2002-02-11 11:51:16 +00:00
return bUpdateChildren;
2002-02-04 13:10:18 +00:00
}
sal_Bool SwAccessibleContext::DisposeChild( const SwFrm *pFrm,
sal_Bool bRecursive )
2002-02-04 13:10:18 +00:00
{
sal_Bool bDisposeChildren = sal_True;
if( GetMap() )
{
// If the child is existing, the child's chilren have to be
// removed, too. If not, some grandchildren might exist anyway.
// They are removed by seeking the SwFrm tree. This is indicated
// by the return value.
::vos::ORef < SwAccessibleContext > xChildImpl(
GetMap()->GetContextImpl( pFrm, sal_False ) );
if( xChildImpl.isValid() )
{
xChildImpl->Dispose( bRecursive );
bDisposeChildren = sal_False;
}
}
return bDisposeChildren;
}
void SwAccessibleContext::Dispose( sal_Bool bRecursive )
{
// dispose children
if( bRecursive )
DisposeChildren( bRecursive );
2002-02-11 11:51:16 +00:00
// get parent
Reference< XAccessible > xParent( xWeakParent );
Reference < XAccessibleContext > xThis( this );
2002-02-11 11:51:16 +00:00
if( xParent.is() )
{
SwAccessibleContext *pAcc = (SwAccessibleContext *)xParent.get();
AccessibleEventObject aEvent;
aEvent.EventId = AccessibleEventId::ACCESSIBLE_CHILD_EVENT;
2002-02-11 11:51:16 +00:00
aEvent.OldValue <<= xThis;
pAcc->AccessibleEvent( aEvent );
2002-02-11 11:51:16 +00:00
DBG_MSG_THIS_PARAM( "AccessibleChild (removed)", pAcc, this )
}
{
EventObject aEvent;
aEvent.Source = xThis;
aAccessibleEventListeners.disposeAndClear( aEvent );
aFocusListeners.disposeAndClear( aEvent );
DBG_MSG_CD( "dispose" )
}
ASSERT( GetFrm(), "already disposed" );
if( GetMap() && GetFrm() )
GetMap()->RemoveContext( this );
ClearFrm();
pMap = 0;
2002-02-11 11:51:16 +00:00
}
void SwAccessibleContext::PosChanged()
{
if( IsShowing() )
{
// The frame stays visible -> broadcast event
_Moved();
}
else
{
// The frame is now invisible -> dispose it
Dispose();
}
2002-02-04 13:10:18 +00:00
}
2002-02-11 11:51:16 +00:00
void SwAccessibleContext::ChildPosChanged( const SwFrm *pFrm,
const SwRect& rOldFrm )
{
if( IsShowing( pFrm ) )
{
// If the object was not showing before, than there is nothing to do,
// because no wrapper exists and therefor no one is interested to
// get notified of the movement.
if( rOldFrm.IsEmpty() || !IsShowing( rOldFrm.SVRect() ) )
{
// The frame becomes visible. A child event for the parent
// must be send.
ChildScrolledIn( pFrm );
}
}
else
{
// If the frame was visible before, than a child event for the parent
// needs to be send. However, there is no wrapper existing, and so
// no notifications for grandchildren are required. If the are
// grandgrandchildren, they would be notified by the layout.
if( !rOldFrm.IsEmpty() && IsShowing( rOldFrm.SVRect() ) )
2002-02-11 11:51:16 +00:00
ChildScrolledOut( pFrm );
}
}
void SwAccessibleContext::AccessibleEvent( AccessibleEventObject& rEvent )
2002-02-04 13:10:18 +00:00
{
Reference < XAccessibleContext > xThis( this );
rEvent.Source = xThis;
::cppu::OInterfaceIteratorHelper aIter( aAccessibleEventListeners );
2002-02-04 13:10:18 +00:00
while( aIter.hasMoreElements() )
{
Reference < XAccessibleEventListener > xListener( aIter.next(),
2002-02-04 13:10:18 +00:00
UNO_QUERY );
if( xListener.is() ) // TODO: test is unneccessary soon
xListener->notifyEvent( rEvent );
2002-02-04 13:10:18 +00:00
}
}
2002-02-05 14:52:06 +00:00
void SwAccessibleContext::SetStates(
::utl::AccessibleStateSetHelper& rStateSet )
{
// DEFUNC and SHOWING
if( GetFrm() && GetMap() )
2002-02-05 14:52:06 +00:00
{
2002-02-11 11:51:16 +00:00
ASSERT( IsShowing(),
2002-02-05 14:52:06 +00:00
"invisible object is not disposed" );
rStateSet.AddState( AccessibleStateType::SHOWING );
// EDITABLE
ViewShell *pVSh = GetMap()->GetShell();
if( IsEditable( pVSh ) )
rStateSet.AddState( AccessibleStateType::EDITABLE );
// ENABLED
rStateSet.AddState( AccessibleStateType::ENABLED );
// OPAQUE
if( IsOpaque( pVSh ) )
rStateSet.AddState( AccessibleStateType::OPAQUE );
// VISIBLE
rStateSet.AddState( AccessibleStateType::VISIBLE );
2002-02-05 14:52:06 +00:00
}
else
{
rStateSet.AddState( AccessibleStateType::DEFUNC );
}
}
2002-02-04 13:10:18 +00:00
OUString SwAccessibleContext::GetResource( sal_uInt16 nResId,
const OUString *pArg1,
const OUString *pArg2 ) const
{
String sStr;
{
vos::OGuard aGuard(Application::GetSolarMutex());
sStr = SW_RES( nResId );
}
if( pArg1 )
{
sStr.SearchAndReplace( String::CreateFromAscii(
RTL_CONSTASCII_STRINGPARAM( "$(ARG1)" )),
String( *pArg1 ) );
}
if( pArg2 )
{
sStr.SearchAndReplace( String::CreateFromAscii(
RTL_CONSTASCII_STRINGPARAM( "$(ARG2)" )),
String( *pArg2 ) );
}
return OUString( sStr );
}
Window *SwAccessibleContext::GetWindow()
{
Window *pWin = 0;
if( GetMap() )
{
const ViewShell *pVSh = GetMap()->GetShell();
ASSERT( pVSh, "no view shell" );
if( pVSh )
pWin = pVSh->GetWin();
ASSERT( pWin, "no window" );
}
return pWin;
}
SwAccessibleContext::SwAccessibleContext( SwAccessibleMap *pM,
sal_Int16 nR,
2002-02-04 13:10:18 +00:00
const SwFrm *pF ) :
SwAccessibleFrame( pM->GetShell()->VisArea().SVRect(), pF ),
aAccessibleEventListeners( aMutex ),
2002-02-04 13:10:18 +00:00
aFocusListeners( aMutex ),
pMap( pM ),
2002-02-04 13:10:18 +00:00
nRole( nR )
{
2002-02-11 11:51:16 +00:00
DBG_MSG_CD( "constructed" )
2002-02-04 13:10:18 +00:00
}
SwAccessibleContext::SwAccessibleContext( SwAccessibleMap *pM,
const OUString& rName,
2002-02-04 13:10:18 +00:00
sal_Int16 nR,
const SwFrm *pF ) :
SwAccessibleFrame( pM->GetShell()->VisArea().SVRect(), pF ),
2002-02-04 13:10:18 +00:00
sName( rName ),
aAccessibleEventListeners( aMutex ),
2002-02-04 13:10:18 +00:00
aFocusListeners( aMutex ),
pMap( pM ),
2002-02-04 13:10:18 +00:00
nRole( nR )
{
2002-02-11 11:51:16 +00:00
DBG_MSG_CD( "constructed" )
2002-02-04 13:10:18 +00:00
}
SwAccessibleContext::~SwAccessibleContext()
{
2002-02-11 11:51:16 +00:00
DBG_MSG_CD( "destructed" )
if( GetFrm() && GetMap() )
GetMap()->RemoveContext( this );
2002-02-04 13:10:18 +00:00
}
Reference< XAccessibleContext > SAL_CALL
SwAccessibleContext::getAccessibleContext( void )
2002-02-18 16:09:50 +00:00
throw (::com::sun::star::uno::RuntimeException)
2002-02-04 13:10:18 +00:00
{
Reference < XAccessibleContext > xRet( this );
return xRet;
}
long SAL_CALL SwAccessibleContext::getAccessibleChildCount( void )
throw (::com::sun::star::uno::RuntimeException)
{
vos::OGuard aGuard(Application::GetSolarMutex());
CHECK_FOR_DEFUNC( XAccessibleContext )
2002-02-11 11:51:16 +00:00
return GetChildCount();
2002-02-04 13:10:18 +00:00
}
Reference< XAccessible> SAL_CALL
SwAccessibleContext::getAccessibleChild( long nIndex )
throw (::com::sun::star::uno::RuntimeException,
::com::sun::star::lang::IndexOutOfBoundsException)
{
vos::OGuard aGuard(Application::GetSolarMutex());
CHECK_FOR_DEFUNC( XAccessibleContext )
2002-02-11 11:51:16 +00:00
const SwFrm *pChild = GetChild( nIndex );
2002-02-05 14:52:06 +00:00
if( 0 == pChild )
2002-02-04 13:10:18 +00:00
{
Reference < XAccessibleContext > xThis( this );
2002-02-05 14:52:06 +00:00
IndexOutOfBoundsException aExcept(
OUString( RTL_CONSTASCII_USTRINGPARAM("index out of bounds") ),
xThis ); \
2002-02-04 13:10:18 +00:00
throw aExcept;
}
2002-02-11 11:51:16 +00:00
::vos::ORef < SwAccessibleContext > xChildImpl(
GetMap()->GetContextImpl( pChild ) );
2002-02-11 11:51:16 +00:00
xChildImpl->SetParent( this );
Reference< XAccessible > xChild( xChildImpl.getBodyPtr() );
2002-02-04 13:10:18 +00:00
2002-02-11 11:51:16 +00:00
return xChild;
2002-02-04 13:10:18 +00:00
}
Reference< XAccessible> SAL_CALL SwAccessibleContext::getAccessibleParent (void)
throw (::com::sun::star::uno::RuntimeException)
{
vos::OGuard aGuard(Application::GetSolarMutex());
CHECK_FOR_DEFUNC( XAccessibleContext )
2002-02-11 11:51:16 +00:00
const SwFrm *pUpper = GetParent();
2002-02-04 13:10:18 +00:00
ASSERT( pUpper, "no upper found" );
2002-02-05 14:52:06 +00:00
Reference< XAccessible > xAcc;
2002-02-04 13:10:18 +00:00
if( pUpper )
xAcc = GetMap()->GetContext( pUpper );
2002-02-04 13:10:18 +00:00
2002-02-05 14:52:06 +00:00
ASSERT( xAcc.is(), "no parent found" );
if( !xAcc.is() )
2002-02-04 13:10:18 +00:00
{
THROW_RUNTIME_EXCEPTION( XAccessibleContext, "parent missing" );
}
2002-02-11 11:51:16 +00:00
// Remember the parent as weak ref.
xWeakParent = xAcc;
2002-02-04 13:10:18 +00:00
return xAcc;
}
sal_Int32 SAL_CALL SwAccessibleContext::getAccessibleIndexInParent (void)
throw (::com::sun::star::uno::RuntimeException)
{
vos::OGuard aGuard(Application::GetSolarMutex());
CHECK_FOR_DEFUNC( XAccessibleContext )
2002-02-11 11:51:16 +00:00
const SwFrm *pUpper = GetParent();
2002-02-04 13:10:18 +00:00
ASSERT( pUpper, "no upper found" );
sal_Int32 nIndex = -1;
if( pUpper )
{
2002-02-05 14:52:06 +00:00
::vos::ORef < SwAccessibleContext > xAccImpl(
GetMap()->GetContextImpl( pUpper ) );
2002-02-05 14:52:06 +00:00
ASSERT( xAccImpl.isValid(), "no parent found" );
if( xAccImpl.isValid() )
2002-02-11 11:51:16 +00:00
nIndex = xAccImpl->GetChildIndex( GetFrm() );
2002-02-04 13:10:18 +00:00
}
if( -1 == nIndex )
{
THROW_RUNTIME_EXCEPTION( XAccessibleContext, "child not contained in parent" );
}
return nIndex;
}
sal_Int16 SAL_CALL SwAccessibleContext::getAccessibleRole (void)
throw (::com::sun::star::uno::RuntimeException)
{
return nRole;
}
OUString SAL_CALL SwAccessibleContext::getAccessibleDescription (void)
throw (::com::sun::star::uno::RuntimeException)
{
ASSERT( !this, "description needs to be overloaded" );
THROW_RUNTIME_EXCEPTION( XAccessibleContext, "internal error (method must be overloaded)" );
}
OUString SAL_CALL SwAccessibleContext::getAccessibleName (void)
throw (::com::sun::star::uno::RuntimeException)
{
return sName;
}
Reference< XAccessibleRelationSet> SAL_CALL
SwAccessibleContext::getAccessibleRelationSet (void)
throw (::com::sun::star::uno::RuntimeException)
{
// by default there are no relations
Reference< XAccessibleRelationSet> xRet;
return xRet;
}
Reference<XAccessibleStateSet> SAL_CALL
SwAccessibleContext::getAccessibleStateSet (void)
throw (::com::sun::star::uno::RuntimeException)
{
2002-02-05 14:52:06 +00:00
::utl::AccessibleStateSetHelper *pStateSet =
new ::utl::AccessibleStateSetHelper;
Reference<XAccessibleStateSet> xRet( pStateSet );
SetStates( *pStateSet );
2002-02-04 13:10:18 +00:00
return xRet;
}
Locale SAL_CALL SwAccessibleContext::getLocale (void)
throw (::drafts::com::sun::star::accessibility::IllegalAccessibleComponentStateException, ::com::sun::star::uno::RuntimeException)
{
vos::OGuard aGuard(Application::GetSolarMutex());
2002-02-05 14:52:06 +00:00
Locale aLoc( Application::GetSettings().GetUILocale() );
2002-02-04 13:10:18 +00:00
return aLoc;
}
void SAL_CALL SwAccessibleContext::addPropertyChangeListener (
const Reference< XPropertyChangeListener>& xListener)
throw (com::sun::star::uno::RuntimeException)
{
2002-02-11 11:51:16 +00:00
DBG_MSG( "property change listener added" )
aAccessibleEventListeners.addInterface( xListener );
2002-02-04 13:10:18 +00:00
}
void SAL_CALL SwAccessibleContext::removePropertyChangeListener (
const Reference< XPropertyChangeListener>& xListener)
throw (com::sun::star::uno::RuntimeException)
{
2002-02-11 11:51:16 +00:00
DBG_MSG( "property change listener removed" )
aAccessibleEventListeners.removeInterface( xListener );
}
void SAL_CALL SwAccessibleContext::addEventListener(
const Reference< XAccessibleEventListener >& xListener )
throw (::com::sun::star::uno::RuntimeException)
{
DBG_MSG( "accessible event listener added" )
aAccessibleEventListeners.addInterface( xListener );
}
void SAL_CALL SwAccessibleContext::removeEventListener(
const Reference< XAccessibleEventListener >& xListener )
throw (::com::sun::star::uno::RuntimeException)
{
DBG_MSG( "accessible event listener removed" )
aAccessibleEventListeners.removeInterface( xListener );
2002-02-04 13:10:18 +00:00
}
sal_Bool SAL_CALL SwAccessibleContext::contains(
const ::com::sun::star::awt::Point& aPoint )
throw (RuntimeException)
{
vos::OGuard aGuard(Application::GetSolarMutex());
CHECK_FOR_DEFUNC( XAccessibleComponent )
Window *pWin = GetWindow();
CHECK_FOR_WINDOW( XAccessibleComponent, pWin )
Rectangle aLogBounds( GetBounds( GetFrm() ) ); // twip rel to doc root
Point aPixPoint( aPoint.X, aPoint.Y ); // px rel to window
Point aLogPoint( pWin->PixelToLogic( aPixPoint ) ); // twip rel to doc root
return aLogBounds.IsInside( aLogPoint );
}
Reference< XAccessible > SAL_CALL SwAccessibleContext::getAccessibleAt(
const awt::Point& aPoint )
throw (RuntimeException)
{
vos::OGuard aGuard(Application::GetSolarMutex());
CHECK_FOR_DEFUNC( XAccessibleComponent )
2002-02-05 14:52:06 +00:00
Reference< XAccessible > xAcc;
2002-02-04 13:10:18 +00:00
Window *pWin = GetWindow();
CHECK_FOR_WINDOW( XAccessibleComponent, pWin )
Point aPixPoint( aPoint.X, aPoint.Y ); // px rel to window
Point aLogPoint( pWin->PixelToLogic( aPixPoint ) ); // twip rel to doc root
2002-02-11 11:51:16 +00:00
const SwFrm *pFrm = GetChildAt( aLogPoint );
2002-02-04 13:10:18 +00:00
if( pFrm )
xAcc = GetMap()->GetContext( pFrm );
2002-02-04 13:10:18 +00:00
return xAcc;
}
awt::Rectangle SAL_CALL SwAccessibleContext::getBounds()
throw (RuntimeException)
{
vos::OGuard aGuard(Application::GetSolarMutex());
CHECK_FOR_DEFUNC( XAccessibleComponent )
2002-02-11 11:51:16 +00:00
const SwFrm *pUpper = GetParent();
2002-02-04 13:10:18 +00:00
ASSERT( pUpper, "no upper found" );
Window *pWin = GetWindow();
CHECK_FOR_WINDOW( XAccessibleComponent, pWin && pUpper )
Rectangle aLogBounds( GetBounds( GetFrm() ) ); // twip rel to doc root
Point aUpperLogPos( GetBounds( pUpper ).TopLeft() ); // twip rel to doc root
Rectangle aPixBounds( pWin->LogicToPixel( aLogBounds ) );
awt::Rectangle aBox( aPixBounds.Left(), aPixBounds.Top(),
aPixBounds.GetWidth(), aPixBounds.GetHeight() );
return aBox;
}
awt::Point SAL_CALL SwAccessibleContext::getLocation()
throw (RuntimeException)
{
vos::OGuard aGuard(Application::GetSolarMutex());
CHECK_FOR_DEFUNC( XAccessibleComponent )
2002-02-11 11:51:16 +00:00
const SwFrm *pUpper = GetParent();
2002-02-04 13:10:18 +00:00
ASSERT( pUpper, "no upper found" );
Window *pWin = GetWindow();
CHECK_FOR_WINDOW( XAccessibleComponent, pWin && pUpper )
Point aLogPos( GetBounds( GetFrm() ).TopLeft() ); // twip rel to doc root
Point aUpperLogPos( GetBounds( pUpper ).TopLeft() ); // twip rel to doc root
Point aPixPos( pWin->LogicToPixel( aLogPos ) );
awt::Point aLoc( aPixPos.X(), aPixPos.Y() );
return aLoc;
}
::com::sun::star::awt::Point SAL_CALL SwAccessibleContext::getLocationOnScreen()
throw (RuntimeException)
{
vos::OGuard aGuard(Application::GetSolarMutex());
CHECK_FOR_DEFUNC( XAccessibleComponent )
Window *pWin = GetWindow();
CHECK_FOR_WINDOW( XAccessibleComponent, pWin )
Point aLogPos( GetBounds( GetFrm() ).TopLeft() ); // twip rel to doc root
Point aPixPos( pWin->LogicToPixel( aLogPos ) );
aPixPos = pWin->OutputToAbsoluteScreenPixel( aPixPos );
awt::Point aLoc( aPixPos.X(), aPixPos.Y() );
return aLoc;
}
::com::sun::star::awt::Size SAL_CALL SwAccessibleContext::getSize()
throw (RuntimeException)
{
vos::OGuard aGuard(Application::GetSolarMutex());
CHECK_FOR_DEFUNC( XAccessibleComponent )
Window *pWin = GetWindow();
CHECK_FOR_WINDOW( XAccessibleComponent, pWin )
Size aLogSize( GetBounds( GetFrm() ).GetSize() ); // twip rel to whatever
Size aPixSize( pWin->LogicToPixel( aLogSize ) );
awt::Size aSize( aPixSize.Width(), aPixSize.Height() );
return aSize;
}
sal_Bool SAL_CALL SwAccessibleContext::isShowing()
throw (RuntimeException)
{
2002-02-11 11:51:16 +00:00
return IsShowing();
2002-02-04 13:10:18 +00:00
}
sal_Bool SAL_CALL SwAccessibleContext::isVisible()
throw (RuntimeException)
{
return sal_True;
}
sal_Bool SAL_CALL SwAccessibleContext::isFocusTraversable()
throw (RuntimeException)
{
return sal_False;
}
void SAL_CALL SwAccessibleContext::addFocusListener(
const Reference<
::com::sun::star::awt::XFocusListener >& xListener )
throw (RuntimeException)
{
2002-02-11 11:51:16 +00:00
DBG_MSG( "focus listener added" )
2002-02-04 13:10:18 +00:00
aFocusListeners.addInterface( xListener );
}
void SAL_CALL SwAccessibleContext::removeFocusListener(
const Reference<
::com::sun::star::awt::XFocusListener >& xListener )
throw (RuntimeException)
{
2002-02-11 11:51:16 +00:00
DBG_MSG( "focus listener removed" )
2002-02-04 13:10:18 +00:00
aFocusListeners.removeInterface( xListener );
}
void SAL_CALL SwAccessibleContext::grabFocus()
throw (RuntimeException)
{
// impossible
}
Any SAL_CALL SwAccessibleContext::getAccessibleKeyBinding()
throw (RuntimeException)
{
2002-02-05 14:52:06 +00:00
// There are no key bindings
2002-02-04 13:10:18 +00:00
Any aAny;
return aAny;
}
OUString SAL_CALL SwAccessibleContext::getImplementationName()
throw( RuntimeException )
{
ASSERT( !this, "implementation name needs to be overloaded" );
THROW_RUNTIME_EXCEPTION( XServiceInfo, "implementation name needs to be overloaded" )
}
sal_Bool SAL_CALL
SwAccessibleContext::supportsService (const ::rtl::OUString& sServiceName)
throw (::com::sun::star::uno::RuntimeException)
{
ASSERT( !this, "supports service needs to be overloaded" );
THROW_RUNTIME_EXCEPTION( XServiceInfo, "supports service needs to be overloaded" )
}
Sequence< OUString > SAL_CALL SwAccessibleContext::getSupportedServiceNames()
throw( ::com::sun::star::uno::RuntimeException )
{
ASSERT( !this, "supported services names needs to be overloaded" );
THROW_RUNTIME_EXCEPTION( XServiceInfo, "supported services needs to be overloaded" )
}
2002-02-11 11:51:16 +00:00
#if defined DEBUG && defined TEST_MIB
void lcl_SwAccessibleContext_DbgMsg( SwAccessibleContext *pThisAcc,
const char *pMsg,
SwAccessibleContext *pChildAcc,
sal_Bool bConstrDestr )
2002-02-04 13:10:18 +00:00
{
static SvFileStream aStrm( String::CreateFromAscii("j:\\acc.log"),
STREAM_WRITE|STREAM_TRUNC|STREAM_SHARE_DENYNONE );
2002-02-11 11:51:16 +00:00
ByteString aName( String(pThisAcc->GetName()),
RTL_TEXTENCODING_ISO_8859_1 );
if( aName.Len() )
{
aStrm << aName.GetBuffer()
<< ": ";
}
2002-02-04 13:10:18 +00:00
aStrm << pMsg;
2002-02-11 11:51:16 +00:00
if( pChildAcc )
2002-02-04 13:10:18 +00:00
{
2002-02-11 11:51:16 +00:00
ByteString aChild( String(pChildAcc->GetName()),
RTL_TEXTENCODING_ISO_8859_1 );
aStrm << ": "
<< aChild.GetBuffer();
2002-02-04 13:10:18 +00:00
}
2002-02-11 11:51:16 +00:00
aStrm << "\r\n (";
if( !bConstrDestr )
{
ByteString aDesc( String(pThisAcc->getAccessibleDescription()),
RTL_TEXTENCODING_ISO_8859_1 );
aStrm << aDesc.GetBuffer()
<< ", ";
}
Rectangle aVisArea( pThisAcc->GetVisArea() );
aStrm << "VA: "
<< ByteString::CreateFromInt32( aVisArea.Left() ).GetBuffer()
<< ","
<< ByteString::CreateFromInt32( aVisArea.Top() ).GetBuffer()
<< ","
<< ByteString::CreateFromInt32( aVisArea.GetWidth() ).GetBuffer()
<< ","
<< ByteString::CreateFromInt32( aVisArea.GetHeight() ).GetBuffer();
if( pThisAcc->GetFrm() )
{
Rectangle aBounds( pThisAcc->GetBounds( pThisAcc->GetFrm() ) );
aStrm << ", BB: "
<< ByteString::CreateFromInt32( aBounds.Left() ).GetBuffer()
<< ","
<< ByteString::CreateFromInt32( aBounds.Top() ).GetBuffer()
<< ","
<< ByteString::CreateFromInt32( aBounds.GetWidth() ).GetBuffer()
<< ","
<< ByteString::CreateFromInt32( aBounds.GetHeight() ).GetBuffer()
<< ")\r\n";
}
2002-02-11 11:51:16 +00:00
2002-02-04 13:10:18 +00:00
aStrm.Flush();
}
#endif