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

1511 lines
48 KiB
C++
Raw Normal View History

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
re-base on ALv2 code. Includes: Patches contributed by Oliver-Rainer Wittmann sw34bf06: #i117783# - Writer's implementation of XPagePrintable - apply print settings to new printing routines http://svn.apache.org/viewvc?view=revision&revision=1172115 sw34bf06: #o12311627# use <rtl_random> methods to create unique ids for list styles and list ids http://svn.apache.org/viewvc?view=revision&revision=1172112 sw34bf06 #i114725#,#i115828# - method <SwDoc::ClearDoc()> - clear list structures completely http://svn.apache.org/viewvc?view=revision&revision=1172122 i#118572 - remove ui string and help content regarding usage of Java Mail in Writer's Mail Merge as Java Mail is not used. http://svn.apache.org/viewvc?view=revision&revision=1197035 Patches contributed by Mathias Bauer cws mba34issues01: #i117718#: provide filter name in case storage of medium does not allow to detect one http://svn.apache.org/viewvc?view=revision&revision=1172350 cws mba34issues01: #i117721#: directly provide parameters retrieved from SfxMedium http://svn.apache.org/viewvc?view=revision&revision=1172353 gnumake4 work variously http://svn.apache.org/viewvc?view=revision&revision=1394707 http://svn.apache.org/viewvc?view=revision&revision=1394326 http://svn.apache.org/viewvc?view=revision&revision=1396797 http://svn.apache.org/viewvc?view=revision&revision=1397315 cws mba34issues01: #i117723#: convert assertion into trace http://svn.apache.org/viewvc?view=revision&revision=1172355 cws mba34issues01: #i117699#: keep layout alive until swdoc dies http://svn.apache.org/viewvc?view=revision&revision=1172362 cws mba34issues01: #i117943#: missing color attributes in RTF clipboard http://svn.apache.org/viewvc?view=revision&revision=1172363 Patch contributed by Henning Brinkmann imported patch i#103878 http://svn.apache.org/viewvc?view=revision&revision=1172109 Patches contributed by Michael Stahl sw34bf06: #i117955#: WW8 export: disable storing of section breaks in endnotes http://svn.apache.org/viewvc?view=revision&revision=1172119 Patch contributed by imacat Fixed the Asian language work count. http://svn.apache.org/viewvc?view=revision&revision=1241345 Patch contributed by Pedro Giffuni i#20878 - Add comment with BZ issue for reference. http://svn.apache.org/viewvc?view=revision&revision=1244517 Patch contributed by Andre Fischer Do not add targets for junit tests when junit is disabled. http://svn.apache.org/viewvc?view=revision&revision=1241508 add writerperfect dependency.
2011-03-31 10:05:04 +02:00
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
*/
2002-02-04 13:10:18 +00:00
#include <vcl/window.hxx>
#include <swtypes.hxx>
2002-02-04 13:10:18 +00:00
#include <com/sun/star/accessibility/XAccessible.hpp>
#include <com/sun/star/accessibility/XAccessibleStateSet.hpp>
#include <com/sun/star/accessibility/AccessibleStateType.hpp>
#include <com/sun/star/accessibility/AccessibleEventId.hpp>
#include <osl/mutex.hxx>
2002-02-04 13:10:18 +00:00
#include <vcl/svapp.hxx>
#include <vcl/settings.hxx>
2002-02-05 14:52:06 +00:00
#include <unotools/accessiblestatesethelper.hxx>
#include <unotools/accessiblerelationsethelper.hxx>
#include <viewsh.hxx>
#include <crsrsh.hxx>
#include <fesh.hxx>
#include <wrtsh.hxx>
2002-12-05 13:10:33 +00:00
#include <txtfrm.hxx>
#include <ndtxt.hxx>
#include <pagefrm.hxx>
#include <flyfrm.hxx>
#include <dflyobj.hxx>
2002-12-05 13:10:33 +00:00
#include <pam.hxx>
#include <viewimp.hxx>
2002-02-04 13:10:18 +00:00
#include <accmap.hxx>
2002-04-11 13:04:40 +00:00
#include <accfrmobjslist.hxx>
2002-02-04 13:10:18 +00:00
#include <acccontext.hxx>
2002-05-06 11:26:27 +00:00
#include <svx/AccessibleShape.hxx>
#include <comphelper/accessibleeventnotifier.hxx>
#include <cppuhelper/supportsservice.hxx>
#include "accpara.hxx"
#include <PostItMgr.hxx>
2002-02-04 13:10:18 +00:00
using namespace sw::access;
2002-02-04 13:10:18 +00:00
using namespace ::com::sun::star;
using namespace ::com::sun::star::accessibility;
2002-02-04 13:10:18 +00:00
2002-04-11 13:04:40 +00:00
void SwAccessibleContext::InitStates()
{
bIsShowingState = GetMap() ? IsShowing( *(GetMap()) ) : sal_False;
SwViewShell *pVSh = GetMap()->GetShell();
bIsEditableState = pVSh && IsEditable( pVSh );
2002-04-11 13:04:40 +00:00
bIsOpaqueState = pVSh && IsOpaque( pVSh );
bIsDefuncState = sal_False;
}
void SwAccessibleContext::SetParent( SwAccessibleContext *pParent )
{
osl::MutexGuard aGuard( aMutex );
uno::Reference < XAccessible > xParent( pParent );
xWeakParent = xParent;
}
uno::Reference< XAccessible > SwAccessibleContext::GetWeakParent() const
2002-04-05 11:18:25 +00:00
{
osl::MutexGuard aGuard( aMutex );
2002-04-05 11:18:25 +00:00
uno::Reference< XAccessible > xParent( xWeakParent );
2002-04-05 11:18:25 +00:00
return xParent;
}
2002-04-11 13:04:40 +00:00
Window *SwAccessibleContext::GetWindow()
2002-02-11 11:51:16 +00:00
{
2002-04-11 13:04:40 +00:00
Window *pWin = 0;
2002-02-11 11:51:16 +00:00
if( GetMap() )
2002-02-11 11:51:16 +00:00
{
const SwViewShell *pVSh = GetMap()->GetShell();
OSL_ENSURE( pVSh, "no view shell" );
2002-04-11 13:04:40 +00:00
if( pVSh )
pWin = pVSh->GetWin();
2002-02-11 11:51:16 +00:00
OSL_ENSURE( pWin, "no window" );
2002-02-11 11:51:16 +00:00
}
2002-02-04 13:10:18 +00:00
2002-04-11 13:04:40 +00:00
return pWin;
2002-02-04 13:10:18 +00:00
}
// get SwViewShell from accessibility map, and cast to cursor shell
SwCrsrShell* SwAccessibleContext::GetCrsrShell()
{
SwCrsrShell* pCrsrShell;
SwViewShell* pViewShell = GetMap() ? GetMap()->GetShell() : 0;
OSL_ENSURE( pViewShell, "no view shell" );
if( pViewShell && pViewShell->ISA( SwCrsrShell ) )
pCrsrShell = static_cast<SwCrsrShell*>( pViewShell );
else
pCrsrShell = NULL;
return pCrsrShell;
}
const SwCrsrShell* SwAccessibleContext::GetCrsrShell() const
{
// just like non-const GetCrsrShell
const SwCrsrShell* pCrsrShell;
const SwViewShell* pViewShell = GetMap() ? GetMap()->GetShell() : 0;
OSL_ENSURE( pViewShell, "no view shell" );
if( pViewShell && pViewShell->ISA( SwCrsrShell ) )
pCrsrShell = static_cast<const SwCrsrShell*>( pViewShell );
else
pCrsrShell = NULL;
return pCrsrShell;
}
2002-04-11 13:04:40 +00:00
enum Action { NONE, SCROLLED, SCROLLED_WITHIN,
SCROLLED_IN, SCROLLED_OUT };
2002-04-11 13:04:40 +00:00
void SwAccessibleContext::ChildrenScrolled( const SwFrm *pFrm,
const SwRect& rOldVisArea )
2002-02-04 13:10:18 +00:00
{
2002-04-11 13:04:40 +00:00
const SwRect& rNewVisArea = GetVisArea();
const bool bVisibleChildrenOnly = SwAccessibleChild( pFrm ).IsVisibleChildrenOnly();
2002-02-11 11:51:16 +00:00
const SwAccessibleChildSList aList( *pFrm, *(GetMap()) );
SwAccessibleChildSList::const_iterator aIter( aList.begin() );
2002-04-11 13:04:40 +00:00
while( aIter != aList.end() )
{
const SwAccessibleChild& rLower = *aIter;
const SwRect aBox( rLower.GetBox( *(GetMap()) ) );
if( rLower.IsAccessible( GetShell()->IsPreview() ) )
{
2002-04-11 13:04:40 +00:00
Action eAction = NONE;
2002-05-15 12:22:47 +00:00
if( aBox.IsOver( rNewVisArea ) )
2002-04-11 13:04:40 +00:00
{
2002-05-15 12:22:47 +00:00
if( aBox.IsOver( rOldVisArea ) )
2002-04-11 13:04:40 +00:00
{
2002-05-15 12:22:47 +00:00
eAction = SCROLLED_WITHIN;
2002-04-11 13:04:40 +00:00
}
2002-05-15 12:22:47 +00:00
else
2002-04-11 13:04:40 +00:00
{
if ( bVisibleChildrenOnly &&
!rLower.AlwaysIncludeAsChild() )
{
2002-05-15 12:22:47 +00:00
eAction = SCROLLED_IN;
}
2002-04-11 13:04:40 +00:00
else
{
2002-04-11 13:04:40 +00:00
eAction = SCROLLED;
}
2002-04-11 13:04:40 +00:00
}
2002-05-15 12:22:47 +00:00
}
else if( aBox.IsOver( rOldVisArea ) )
{
if ( bVisibleChildrenOnly &&
!rLower.AlwaysIncludeAsChild() )
{
2002-05-15 12:22:47 +00:00
eAction = SCROLLED_OUT;
}
2002-05-15 12:22:47 +00:00
else
{
2002-04-11 13:04:40 +00:00
eAction = SCROLLED;
}
2002-05-15 12:22:47 +00:00
}
else if( !bVisibleChildrenOnly ||
rLower.AlwaysIncludeAsChild() )
2002-05-15 12:22:47 +00:00
{
// This wouldn't be required if the SwAccessibleFrame,
// wouldn't know about the visible area.
2002-05-15 12:22:47 +00:00
eAction = SCROLLED;
}
if( NONE != eAction )
{
if ( rLower.GetSwFrm() )
2002-04-11 13:04:40 +00:00
{
OSL_ENSURE( !rLower.AlwaysIncludeAsChild(),
"<SwAccessibleContext::ChildrenScrolled(..)> - always included child not considered!" );
const SwFrm* pLower( rLower.GetSwFrm() );
2010-10-15 11:44:38 -05:00
::rtl::Reference< SwAccessibleContext > xAccImpl =
GetMap()->GetContextImpl( pLower, true );
2010-10-15 11:44:38 -05:00
if( xAccImpl.is() )
2002-04-11 13:04:40 +00:00
{
switch( eAction )
{
case SCROLLED:
xAccImpl->Scrolled( rOldVisArea );
break;
case SCROLLED_WITHIN:
xAccImpl->ScrolledWithin( rOldVisArea );
break;
case SCROLLED_IN:
xAccImpl->ScrolledIn();
break;
case SCROLLED_OUT:
xAccImpl->ScrolledOut( rOldVisArea );
break;
case NONE:
break;
2002-04-11 13:04:40 +00:00
}
}
else
{
ChildrenScrolled( pLower, rOldVisArea );
}
}
else if ( rLower.GetDrawObject() )
2002-05-15 12:22:47 +00:00
{
OSL_ENSURE( !rLower.AlwaysIncludeAsChild(),
"<SwAccessibleContext::ChildrenScrolled(..)> - always included child not considered!" );
2010-10-15 11:44:38 -05:00
::rtl::Reference< ::accessibility::AccessibleShape > xAccImpl =
GetMap()->GetContextImpl( rLower.GetDrawObject(),
2002-05-15 12:22:47 +00:00
this,
true );
2010-10-15 11:44:38 -05:00
if( xAccImpl.is() )
2002-05-15 12:22:47 +00:00
{
switch( eAction )
{
case SCROLLED:
case SCROLLED_WITHIN:
xAccImpl->ViewForwarderChanged(
::accessibility::IAccessibleViewForwarderListener::VISIBLE_AREA,
2002-05-15 12:22:47 +00:00
GetMap() );
break;
case SCROLLED_IN:
ScrolledInShape( rLower.GetDrawObject(),
2010-10-15 11:44:38 -05:00
xAccImpl.get() );
2002-05-15 12:22:47 +00:00
break;
case SCROLLED_OUT:
{
xAccImpl->ViewForwarderChanged(
::accessibility::IAccessibleViewForwarderListener::VISIBLE_AREA,
2002-05-15 12:22:47 +00:00
GetMap() );
}
break;
case NONE:
break;
2002-05-15 12:22:47 +00:00
}
}
}
else if ( rLower.GetWindow() )
{
// nothing to do - as such children are always included as children.
OSL_ENSURE( rLower.AlwaysIncludeAsChild(),
"<SwAccessibleContext::ChildrenScrolled(..)> - not always included child not considered!" );
}
2002-04-11 13:04:40 +00:00
}
}
else if ( rLower.GetSwFrm() &&
( !bVisibleChildrenOnly ||
aBox.IsOver( rOldVisArea ) ||
aBox.IsOver( rNewVisArea ) ) )
{
2002-04-11 13:04:40 +00:00
// There are no unaccessible SdrObjects that need to be notified
ChildrenScrolled( rLower.GetSwFrm(), rOldVisArea );
}
2002-04-11 13:04:40 +00:00
++aIter;
}
}
2002-04-11 13:04:40 +00:00
void SwAccessibleContext::Scrolled( const SwRect& rOldVisArea )
2002-02-04 13:10:18 +00:00
{
2002-04-11 13:04:40 +00:00
SetVisArea( GetMap()->GetVisArea() );
2002-04-11 13:04:40 +00:00
ChildrenScrolled( GetFrm(), rOldVisArea );
2002-04-11 13:04:40 +00:00
sal_Bool bIsOldShowingState;
sal_Bool bIsNewShowingState = IsShowing( *(GetMap()) );
2002-04-11 13:04:40 +00:00
{
osl::MutexGuard aGuard( aMutex );
2002-04-11 13:04:40 +00:00
bIsOldShowingState = bIsShowingState;
bIsShowingState = bIsNewShowingState;
}
2002-04-11 13:04:40 +00:00
if( bIsOldShowingState != bIsNewShowingState )
FireStateChangedEvent( AccessibleStateType::SHOWING,
bIsNewShowingState );
}
2002-04-11 13:04:40 +00:00
void SwAccessibleContext::ScrolledWithin( const SwRect& rOldVisArea )
{
2002-04-11 13:04:40 +00:00
SetVisArea( GetMap()->GetVisArea() );
2002-04-11 13:04:40 +00:00
ChildrenScrolled( GetFrm(), rOldVisArea );
2002-04-11 13:04:40 +00:00
FireVisibleDataEvent();
}
2002-04-11 13:04:40 +00:00
void SwAccessibleContext::ScrolledIn()
{
2002-04-11 13:04:40 +00:00
// This accessible should be freshly created, because it
2014-04-11 08:22:22 +02:00
// was not visible before. Therefor, its vis area must already
2002-04-11 13:04:40 +00:00
// reflect the scrolling.
OSL_ENSURE( GetVisArea() == GetMap()->GetVisArea(),
2002-04-11 13:04:40 +00:00
"Vis area of child is wrong. Did it exist already?" );
2002-04-11 13:04:40 +00:00
// Send child event at parent. That's all we have to do here.
const SwFrm* pParent = GetParent();
2010-10-15 11:44:38 -05:00
::rtl::Reference< SwAccessibleContext > xParentImpl(
2002-04-11 13:04:40 +00:00
GetMap()->GetContextImpl( pParent, sal_False ) );
uno::Reference < XAccessibleContext > xThis( this );
2010-10-15 11:44:38 -05:00
if( xParentImpl.is() )
2002-02-11 11:51:16 +00:00
{
2010-10-15 11:44:38 -05:00
SetParent( xParentImpl.get() );
2002-02-11 11:51:16 +00:00
AccessibleEventObject aEvent;
aEvent.EventId = AccessibleEventId::CHILD;
2002-04-11 13:04:40 +00:00
aEvent.NewValue <<= xThis;
2002-04-11 13:04:40 +00:00
xParentImpl->FireAccessibleEvent( aEvent );
if( HasCursor() )
{
Window *pWin = GetWindow();
if( pWin && pWin->HasFocus() )
{
FireStateChangedEvent( AccessibleStateType::FOCUSED, sal_True );
}
}
}
2002-02-11 11:51:16 +00:00
}
2002-04-11 13:04:40 +00:00
void SwAccessibleContext::ScrolledOut( const SwRect& rOldVisArea )
2002-02-11 11:51:16 +00:00
{
2002-04-11 13:04:40 +00:00
SetVisArea( GetMap()->GetVisArea() );
// First of all, update the children. That's required to dispose
// all children that are existing only if they are visible. They
2014-04-11 08:23:23 +02:00
// are not disposed by the recursive Dispose call that follows later on,
2002-04-11 13:04:40 +00:00
// because this call will only dispose children that are in the
// new vis area. The children we want to dispode however are in the
// old vis area all.
ChildrenScrolled( GetFrm(), rOldVisArea );
// Broadcast a state changed event for the showing state.
// It might be that the child is freshly created just to send
// the child event. In this case no listener will exist.
FireStateChangedEvent( AccessibleStateType::SHOWING, sal_False );
}
2011-01-30 04:19:53 +09:00
// #i27301# - use new type definition for <_nStates>
void SwAccessibleContext::InvalidateChildrenStates( const SwFrm* _pFrm,
tAccessibleStates _nStates )
2002-04-11 13:04:40 +00:00
{
const SwAccessibleChildSList aVisList( GetVisArea(), *_pFrm, *(GetMap()) );
2002-04-11 13:04:40 +00:00
SwAccessibleChildSList::const_iterator aIter( aVisList.begin() );
2002-04-11 13:04:40 +00:00
while( aIter != aVisList.end() )
2002-02-11 11:51:16 +00:00
{
const SwAccessibleChild& rLower = *aIter;
const SwFrm* pLower = rLower.GetSwFrm();
2002-04-11 13:04:40 +00:00
if( pLower )
{
2010-10-15 11:44:38 -05:00
::rtl::Reference< SwAccessibleContext > xAccImpl;
if( rLower.IsAccessible( GetShell()->IsPreview() ) )
2002-04-11 13:04:40 +00:00
xAccImpl = GetMap()->GetContextImpl( pLower, sal_False );
2010-10-15 11:44:38 -05:00
if( xAccImpl.is() )
xAccImpl->InvalidateStates( _nStates );
2002-04-11 13:04:40 +00:00
else
InvalidateChildrenStates( pLower, _nStates );
}
else if ( rLower.GetDrawObject() )
2002-04-11 13:04:40 +00:00
{
// TODO: SdrObjects
}
else if ( rLower.GetWindow() )
{
// nothing to do ?
}
2002-04-11 13:04:40 +00:00
++aIter;
2002-02-11 11:51:16 +00:00
}
2002-02-04 13:10:18 +00:00
}
2002-04-11 13:04:40 +00:00
void SwAccessibleContext::DisposeChildren( const SwFrm *pFrm,
sal_Bool bRecursive )
2002-02-11 11:51:16 +00:00
{
const SwAccessibleChildSList aVisList( GetVisArea(), *pFrm, *(GetMap()) );
SwAccessibleChildSList::const_iterator aIter( aVisList.begin() );
2002-04-11 13:04:40 +00:00
while( aIter != aVisList.end() )
2002-02-11 11:51:16 +00:00
{
const SwAccessibleChild& rLower = *aIter;
const SwFrm* pLower = rLower.GetSwFrm();
2002-04-11 13:04:40 +00:00
if( pLower )
2002-02-11 11:51:16 +00:00
{
2010-10-15 11:44:38 -05:00
::rtl::Reference< SwAccessibleContext > xAccImpl;
if( rLower.IsAccessible( GetShell()->IsPreview() ) )
2002-04-11 13:04:40 +00:00
xAccImpl = GetMap()->GetContextImpl( pLower, sal_False );
2010-10-15 11:44:38 -05:00
if( xAccImpl.is() )
2002-04-11 13:04:40 +00:00
xAccImpl->Dispose( bRecursive );
else if( bRecursive )
DisposeChildren( pLower, bRecursive );
2002-02-11 11:51:16 +00:00
}
else if ( rLower.GetDrawObject() )
2002-04-11 13:04:40 +00:00
{
2010-10-15 11:44:38 -05:00
::rtl::Reference< ::accessibility::AccessibleShape > xAccImpl(
GetMap()->GetContextImpl( rLower.GetDrawObject(),
2002-05-15 12:22:47 +00:00
this, sal_False ) );
2010-10-15 11:44:38 -05:00
if( xAccImpl.is() )
DisposeShape( rLower.GetDrawObject(), xAccImpl.get() );
}
else if ( rLower.GetWindow() )
{
DisposeChild( rLower, sal_False );
2002-04-11 13:04:40 +00:00
}
++aIter;
2002-02-11 11:51:16 +00:00
}
}
2002-04-11 13:04:40 +00:00
void SwAccessibleContext::_InvalidateContent( sal_Bool )
{
}
2002-04-11 13:04:40 +00:00
void SwAccessibleContext::_InvalidateCursorPos()
{
}
2002-05-16 07:22:32 +00:00
void SwAccessibleContext::_InvalidateFocus()
{
}
void SwAccessibleContext::FireAccessibleEvent( AccessibleEventObject& rEvent )
2002-02-04 13:10:18 +00:00
{
2014-04-11 08:25:35 +02:00
OSL_ENSURE( GetFrm(), "fire event for disposed frame?" );
2002-04-11 13:04:40 +00:00
if( !GetFrm() )
return;
if( !rEvent.Source.is() )
{
uno::Reference < XAccessibleContext > xThis( this );
rEvent.Source = xThis;
}
2002-02-04 13:10:18 +00:00
if (nClientId)
comphelper::AccessibleEventNotifier::addEvent( nClientId, rEvent );
}
2002-04-11 13:04:40 +00:00
void SwAccessibleContext::FireVisibleDataEvent()
2002-03-21 11:50:31 +00:00
{
2002-04-11 13:04:40 +00:00
AccessibleEventObject aEvent;
aEvent.EventId = AccessibleEventId::VISIBLE_DATA_CHANGED;
2002-04-11 13:04:40 +00:00
FireAccessibleEvent( aEvent );
2002-03-21 11:50:31 +00:00
}
2002-04-11 13:04:40 +00:00
void SwAccessibleContext::FireStateChangedEvent( sal_Int16 nState,
sal_Bool bNewState )
{
2002-04-11 13:04:40 +00:00
AccessibleEventObject aEvent;
aEvent.EventId = AccessibleEventId::STATE_CHANGED;
2002-04-11 13:04:40 +00:00
if( bNewState )
aEvent.NewValue <<= nState;
else
aEvent.OldValue <<= nState;
FireAccessibleEvent( aEvent );
}
2002-04-11 13:04:40 +00:00
void SwAccessibleContext::GetStates(
::utl::AccessibleStateSetHelper& rStateSet )
{
SolarMutexGuard aGuard;
2002-04-11 13:04:40 +00:00
// SHOWING
if( bIsShowingState )
rStateSet.AddState( AccessibleStateType::SHOWING );
// EDITABLE
if( bIsEditableState )
//Set editable state to graphic and other object when the document is editable
{
2002-04-11 13:04:40 +00:00
rStateSet.AddState( AccessibleStateType::EDITABLE );
rStateSet.AddState( AccessibleStateType::RESIZABLE );
rStateSet.AddState( AccessibleStateType::MOVEABLE );
}
2002-04-11 13:04:40 +00:00
// ENABLED
rStateSet.AddState( AccessibleStateType::ENABLED );
// OPAQUE
if( bIsOpaqueState )
rStateSet.AddState( AccessibleStateType::OPAQUE );
// VISIBLE
rStateSet.AddState( AccessibleStateType::VISIBLE );
if( bIsDefuncState )
rStateSet.AddState( AccessibleStateType::DEFUNC );
}
sal_Bool SwAccessibleContext::IsEditableState()
{
sal_Bool bRet;
{
osl::MutexGuard aGuard( aMutex );
bRet = bIsEditableState;
}
return bRet;
}
SwAccessibleContext::SwAccessibleContext( SwAccessibleMap *pM,
sal_Int16 nR,
const SwFrm *pF )
: SwAccessibleFrame( pM->GetVisArea().SVRect(), pF,
pM->GetShell()->IsPreview() )
, pMap( pM )
, nClientId(0)
, nRole( nR )
, bDisposing( sal_False )
, bRegisteredAtAccessibleMap( true )
//Initialize the begin document load and IfAsynLoad to true
, bBeginDocumentLoad( sal_True )
, isIfAsynLoad( sal_True )
, bIsSeletedInDoc( sal_False)
2002-02-04 13:10:18 +00:00
{
InitStates();
2002-02-04 13:10:18 +00:00
}
SwAccessibleContext::~SwAccessibleContext()
{
SolarMutexGuard aGuard;
RemoveFrmFromAccessibleMap();
2002-02-04 13:10:18 +00:00
}
uno::Reference< XAccessibleContext > SAL_CALL
2002-02-04 13:10:18 +00:00
SwAccessibleContext::getAccessibleContext( void )
throw (uno::RuntimeException, std::exception)
2002-02-04 13:10:18 +00:00
{
uno::Reference < XAccessibleContext > xRet( this );
2002-02-04 13:10:18 +00:00
return xRet;
}
2002-04-05 11:18:25 +00:00
sal_Int32 SAL_CALL SwAccessibleContext::getAccessibleChildCount( void )
throw (uno::RuntimeException, std::exception)
2002-02-04 13:10:18 +00:00
{
SolarMutexGuard aGuard;
2002-02-04 13:10:18 +00:00
CHECK_FOR_DEFUNC( XAccessibleContext )
//Notify the frame is a document
if( nRole == AccessibleRole::DOCUMENT_TEXT )
bIsAccDocUse = sal_True;
return bDisposing ? 0 : GetChildCount( *(GetMap()) );
2002-02-04 13:10:18 +00:00
}
uno::Reference< XAccessible> SAL_CALL
SwAccessibleContext::getAccessibleChild( sal_Int32 nIndex )
throw (uno::RuntimeException, lang::IndexOutOfBoundsException, std::exception)
2002-02-04 13:10:18 +00:00
{
SolarMutexGuard aGuard;
2002-02-04 13:10:18 +00:00
CHECK_FOR_DEFUNC( XAccessibleContext )
//Notify the frame is a document
if( nRole == AccessibleRole::DOCUMENT_TEXT )
bIsAccDocUse = sal_True;
const SwAccessibleChild aChild( GetChild( *(GetMap()), nIndex ) );
2002-04-05 11:18:25 +00:00
if( !aChild.IsValid() )
2002-02-04 13:10:18 +00:00
{
uno::Reference < XAccessibleContext > xThis( this );
lang::IndexOutOfBoundsException aExcept(
OUString( "index out of bounds" ),
xThis );
2002-02-04 13:10:18 +00:00
throw aExcept;
}
uno::Reference< XAccessible > xChild;
2002-04-05 11:18:25 +00:00
if( aChild.GetSwFrm() )
{
2010-10-15 11:44:38 -05:00
::rtl::Reference < SwAccessibleContext > xChildImpl(
2002-04-05 11:18:25 +00:00
GetMap()->GetContextImpl( aChild.GetSwFrm(), !bDisposing ) );
//Send out accessible event when begin load.
if( bBeginDocumentLoad && nRole == AccessibleRole::DOCUMENT_TEXT )
{
FireStateChangedEvent( AccessibleStateType::FOCUSABLE,sal_True );
FireStateChangedEvent( AccessibleStateType::BUSY,sal_True );
if( !isIfAsynLoad )
{
FireStateChangedEvent( AccessibleStateType::FOCUSED,sal_True );
// OFFSCREEN == !SHOWING, should stay consistent
// FireStateChangedEvent( AccessibleStateType::OFFSCREEN,sal_True );
FireStateChangedEvent( AccessibleStateType::SHOWING,sal_True );
FireStateChangedEvent( AccessibleStateType::BUSY,sal_False );
// OFFSCREEN again?
// FireStateChangedEvent( AccessibleStateType::OFFSCREEN,sal_False );
}
bBeginDocumentLoad = sal_False;
}
2010-10-15 11:44:38 -05:00
if( xChildImpl.is() )
2002-04-05 11:18:25 +00:00
{
xChildImpl->SetParent( this );
2010-10-15 11:44:38 -05:00
xChild = xChildImpl.get();
2002-04-05 11:18:25 +00:00
}
}
else if ( aChild.GetDrawObject() )
2002-04-05 11:18:25 +00:00
{
2010-10-15 11:44:38 -05:00
::rtl::Reference < ::accessibility::AccessibleShape > xChildImpl(
GetMap()->GetContextImpl( aChild.GetDrawObject(),
2002-05-06 11:26:27 +00:00
this, !bDisposing ) );
2010-10-15 11:44:38 -05:00
if( xChildImpl.is() )
xChild = xChildImpl.get();
2002-04-05 11:18:25 +00:00
}
else if ( aChild.GetWindow() )
{
xChild = aChild.GetWindow()->GetAccessible();
}
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
}
uno::Reference< XAccessible> SAL_CALL SwAccessibleContext::getAccessibleParent (void)
throw (uno::RuntimeException, std::exception)
2002-02-04 13:10:18 +00:00
{
SolarMutexGuard aGuard;
2002-02-04 13:10:18 +00:00
CHECK_FOR_DEFUNC( XAccessibleContext )
2002-02-11 11:51:16 +00:00
const SwFrm *pUpper = GetParent();
OSL_ENSURE( pUpper != 0 || bDisposing, "no upper found" );
2002-02-04 13:10:18 +00:00
uno::Reference< XAccessible > xAcc;
2002-02-04 13:10:18 +00:00
if( pUpper )
2002-04-05 11:18:25 +00:00
xAcc = GetMap()->GetContext( pUpper, !bDisposing );
2002-02-04 13:10:18 +00:00
OSL_ENSURE( xAcc.is() || bDisposing, "no parent found" );
2002-02-04 13:10:18 +00:00
2002-02-11 11:51:16 +00:00
// Remember the parent as weak ref.
{
osl::MutexGuard aWeakParentGuard( aMutex );
xWeakParent = xAcc;
}
2002-02-11 11:51:16 +00:00
2002-02-04 13:10:18 +00:00
return xAcc;
}
sal_Int32 SAL_CALL SwAccessibleContext::getAccessibleIndexInParent (void)
throw (uno::RuntimeException, std::exception)
2002-02-04 13:10:18 +00:00
{
SolarMutexGuard aGuard;
2002-02-04 13:10:18 +00:00
CHECK_FOR_DEFUNC( XAccessibleContext )
2002-02-11 11:51:16 +00:00
const SwFrm *pUpper = GetParent();
OSL_ENSURE( pUpper != 0 || bDisposing, "no upper found" );
2002-02-04 13:10:18 +00:00
sal_Int32 nIndex = -1;
if( pUpper )
{
2010-10-15 11:44:38 -05:00
::rtl::Reference < SwAccessibleContext > xAccImpl(
2002-04-05 11:18:25 +00:00
GetMap()->GetContextImpl( pUpper, !bDisposing ) );
OSL_ENSURE( xAccImpl.is() || bDisposing, "no parent found" );
2010-10-15 11:44:38 -05:00
if( xAccImpl.is() )
nIndex = xAccImpl->GetChildIndex( *(GetMap()), SwAccessibleChild(GetFrm()) );
2002-02-04 13:10:18 +00:00
}
return nIndex;
}
sal_Int16 SAL_CALL SwAccessibleContext::getAccessibleRole (void)
throw (uno::RuntimeException, std::exception)
2002-02-04 13:10:18 +00:00
{
return nRole;
}
OUString SAL_CALL SwAccessibleContext::getAccessibleDescription (void)
throw (uno::RuntimeException, std::exception)
2002-02-04 13:10:18 +00:00
{
OSL_ENSURE( !this, "description needs to be overloaded" );
2002-02-04 13:10:18 +00:00
THROW_RUNTIME_EXCEPTION( XAccessibleContext, "internal error (method must be overloaded)" );
}
OUString SAL_CALL SwAccessibleContext::getAccessibleName (void)
throw (uno::RuntimeException, std::exception)
2002-02-04 13:10:18 +00:00
{
return sName;
}
uno::Reference< XAccessibleRelationSet> SAL_CALL
2002-02-04 13:10:18 +00:00
SwAccessibleContext::getAccessibleRelationSet (void)
throw (uno::RuntimeException, std::exception)
2002-02-04 13:10:18 +00:00
{
// by default there are no relations
uno::Reference< XAccessibleRelationSet> xRet( new utl::AccessibleRelationSetHelper() );
2002-02-04 13:10:18 +00:00
return xRet;
}
uno::Reference<XAccessibleStateSet> SAL_CALL
2002-02-04 13:10:18 +00:00
SwAccessibleContext::getAccessibleStateSet (void)
throw (uno::RuntimeException, std::exception)
2002-02-04 13:10:18 +00:00
{
SolarMutexGuard aGuard;
2002-05-03 11:34:00 +00:00
CHECK_FOR_DEFUNC( XAccessibleContext )
2002-02-05 14:52:06 +00:00
::utl::AccessibleStateSetHelper *pStateSet =
new ::utl::AccessibleStateSetHelper;
if( bIsSeletedInDoc )
pStateSet->AddState( AccessibleStateType::SELECTED );
uno::Reference<XAccessibleStateSet> xStateSet( pStateSet );
GetStates( *pStateSet );
2002-02-05 14:52:06 +00:00
return xStateSet;
2002-02-04 13:10:18 +00:00
}
lang::Locale SAL_CALL SwAccessibleContext::getLocale (void)
throw (IllegalAccessibleComponentStateException, uno::RuntimeException, std::exception)
2002-02-04 13:10:18 +00:00
{
SolarMutexGuard aGuard;
2002-02-04 13:10:18 +00:00
lang::Locale aLoc( Application::GetSettings().GetLanguageTag().getLocale() );
2002-02-04 13:10:18 +00:00
return aLoc;
}
void SAL_CALL SwAccessibleContext::addAccessibleEventListener(
const uno::Reference< XAccessibleEventListener >& xListener )
throw (uno::RuntimeException, std::exception)
{
if (xListener.is())
{
SolarMutexGuard aGuard;
if (!nClientId)
nClientId = comphelper::AccessibleEventNotifier::registerClient( );
comphelper::AccessibleEventNotifier::addEventListener( nClientId, xListener );
}
}
void SAL_CALL SwAccessibleContext::removeAccessibleEventListener(
const uno::Reference< XAccessibleEventListener >& xListener )
throw (uno::RuntimeException, std::exception)
{
if (xListener.is())
{
SolarMutexGuard aGuard;
sal_Int32 nListenerCount = comphelper::AccessibleEventNotifier::removeEventListener( nClientId, xListener );
if ( !nListenerCount )
{
// no listeners anymore
// -> revoke ourself. This may lead to the notifier thread dying (if we were the last client),
// and at least to us not firing any events anymore, in case somebody calls
// NotifyAccessibleEvent, again
comphelper::AccessibleEventNotifier::revokeClient( nClientId );
nClientId = 0;
}
}
2002-02-04 13:10:18 +00:00
}
static sal_Bool lcl_PointInRectangle(const awt::Point & aPoint,
const awt::Rectangle & aRect)
2002-02-04 13:10:18 +00:00
{
long nDiffX = aPoint.X - aRect.X;
long nDiffY = aPoint.Y - aRect.Y;
2002-02-04 13:10:18 +00:00
return
nDiffX >= 0 && nDiffX < aRect.Width && nDiffY >= 0 &&
nDiffY < aRect.Height;
2002-02-04 13:10:18 +00:00
}
2002-02-04 13:10:18 +00:00
sal_Bool SAL_CALL SwAccessibleContext::containsPoint(
const awt::Point& aPoint )
throw (uno::RuntimeException, std::exception)
{
awt::Rectangle aPixBounds = getBoundsImpl(sal_True);
aPixBounds.X = 0;
aPixBounds.Y = 0;
2002-02-04 13:10:18 +00:00
return lcl_PointInRectangle(aPoint, aPixBounds);
2002-02-04 13:10:18 +00:00
}
uno::Reference< XAccessible > SAL_CALL SwAccessibleContext::getAccessibleAtPoint(
2002-02-04 13:10:18 +00:00
const awt::Point& aPoint )
throw (uno::RuntimeException, std::exception)
2002-02-04 13:10:18 +00:00
{
SolarMutexGuard aGuard;
2002-02-04 13:10:18 +00:00
CHECK_FOR_DEFUNC( XAccessibleComponent )
uno::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 parent
if( !GetFrm()->IsRootFrm() )
{
SwRect aLogBounds( GetBounds( *(GetMap()), GetFrm() ) ); // twip rel to doc root
Point aPixPos( GetMap()->CoreToPixel( aLogBounds.SVRect() ).TopLeft() );
aPixPoint.setX(aPixPoint.getX() + aPixPos.getX());
aPixPoint.setY(aPixPoint.getY() + aPixPos.getY());
}
2002-02-04 13:10:18 +00:00
const SwAccessibleChild aChild( GetChildAtPixel( aPixPoint, *(GetMap()) ) );
2002-04-05 11:18:25 +00:00
if( aChild.GetSwFrm() )
{
xAcc = GetMap()->GetContext( aChild.GetSwFrm() );
}
else if( aChild.GetDrawObject() )
{
xAcc = GetMap()->GetContext( aChild.GetDrawObject(), this );
}
else if ( aChild.GetWindow() )
2002-04-05 11:18:25 +00:00
{
xAcc = aChild.GetWindow()->GetAccessible();
2002-04-05 11:18:25 +00:00
}
2002-02-04 13:10:18 +00:00
return xAcc;
}
/**
Get bounding box.
There are two modes.
- relative
Return bounding box relative to parent if parent is no root
frame. Otherwise return the absolute bounding box.
- absolute
Return the absolute bounding box.
@param bRelative
true: Use relative mode.
false: Use absolute mode.
*/
awt::Rectangle SAL_CALL SwAccessibleContext::getBoundsImpl(sal_Bool bRelative)
throw (uno::RuntimeException)
2002-02-04 13:10:18 +00:00
{
SolarMutexGuard aGuard;
2002-02-04 13:10:18 +00:00
CHECK_FOR_DEFUNC( XAccessibleComponent )
2002-02-27 08:32:33 +00:00
const SwFrm *pParent = GetParent();
OSL_ENSURE( pParent, "no Parent found" );
2002-02-04 13:10:18 +00:00
Window *pWin = GetWindow();
2002-02-27 08:32:33 +00:00
CHECK_FOR_WINDOW( XAccessibleComponent, pWin && pParent )
2002-02-04 13:10:18 +00:00
SwRect aLogBounds( GetBounds( *(GetMap()), GetFrm() ) ); // twip rel to doc root
2002-04-11 13:04:40 +00:00
Rectangle aPixBounds( 0, 0, 0, 0 );
2002-05-29 13:59:06 +00:00
if( GetFrm()->IsPageFrm() &&
static_cast < const SwPageFrm * >( GetFrm() )->IsEmptyPage() )
{
OSL_ENSURE( GetShell()->IsPreview(), "empty page accessible?" );
if( GetShell()->IsPreview() )
{
// adjust method call <GetMap()->GetPreviewPageSize()>
sal_uInt16 nPageNum =
static_cast < const SwPageFrm * >( GetFrm() )->GetPhyPageNum();
aLogBounds.SSize( GetMap()->GetPreviewPageSize( nPageNum ) );
}
2002-05-29 13:59:06 +00:00
}
2002-04-11 13:04:40 +00:00
if( !aLogBounds.IsEmpty() )
2002-02-27 08:32:33 +00:00
{
2002-05-29 13:59:06 +00:00
aPixBounds = GetMap()->CoreToPixel( aLogBounds.SVRect() );
if( !pParent->IsRootFrm() && bRelative)
2002-04-11 13:04:40 +00:00
{
SwRect aParentLogBounds( GetBounds( *(GetMap()), pParent ) ); // twip rel to doc root
Point aParentPixPos( GetMap()->CoreToPixel( aParentLogBounds.SVRect() ).TopLeft() );
aPixBounds.Move( -aParentPixPos.getX(), -aParentPixPos.getY() );
2002-04-11 13:04:40 +00:00
}
2002-02-27 08:32:33 +00:00
}
2002-02-04 13:10:18 +00:00
awt::Rectangle aBox( aPixBounds.Left(), aPixBounds.Top(),
aPixBounds.GetWidth(), aPixBounds.GetHeight() );
return aBox;
}
awt::Rectangle SAL_CALL SwAccessibleContext::getBounds()
throw (uno::RuntimeException, std::exception)
2002-02-04 13:10:18 +00:00
{
return getBoundsImpl(sal_True);
}
2002-05-29 13:59:06 +00:00
awt::Point SAL_CALL SwAccessibleContext::getLocation()
throw (uno::RuntimeException, std::exception)
{
awt::Rectangle aRect = getBoundsImpl(sal_True);
awt::Point aPoint(aRect.X, aRect.Y);
2002-02-04 13:10:18 +00:00
return aPoint;
2002-02-04 13:10:18 +00:00
}
awt::Point SAL_CALL SwAccessibleContext::getLocationOnScreen()
throw (uno::RuntimeException, std::exception)
2002-02-04 13:10:18 +00:00
{
awt::Rectangle aRect = getBoundsImpl(sal_False);
2002-05-29 13:59:06 +00:00
Point aPixPos(aRect.X, aRect.Y);
2002-05-29 13:59:06 +00:00
/* getBoundsImpl already checked that GetWindow returns valid pointer. */
aPixPos = GetWindow()->OutputToAbsoluteScreenPixel(aPixPos);
awt::Point aPoint(aPixPos.getX(), aPixPos.getY());
2002-02-04 13:10:18 +00:00
return aPoint;
2002-02-04 13:10:18 +00:00
}
awt::Size SAL_CALL SwAccessibleContext::getSize()
throw (uno::RuntimeException, std::exception)
2002-02-04 13:10:18 +00:00
{
awt::Rectangle aRect = getBoundsImpl(sal_False);
awt::Size aSize( aRect.Width, aRect.Height );
2002-02-04 13:10:18 +00:00
return aSize;
}
void SAL_CALL SwAccessibleContext::grabFocus()
throw (uno::RuntimeException, std::exception)
2002-02-04 13:10:18 +00:00
{
SolarMutexGuard aGuard;
2002-12-05 13:10:33 +00:00
CHECK_FOR_DEFUNC( XAccessibleContext );
if( GetFrm()->IsFlyFrm() )
{
const SdrObject *pObj =
static_cast < const SwFlyFrm * >( GetFrm() )->GetVirtDrawObj();
if( pObj )
Select( const_cast < SdrObject * >( pObj ), sal_False );
}
else
{
const SwCntntFrm *pCFrm = 0;
if( GetFrm()->IsCntntFrm() )
pCFrm = static_cast< const SwCntntFrm * >( GetFrm() );
else if( GetFrm()->IsLayoutFrm() )
pCFrm = static_cast< const SwLayoutFrm * >( GetFrm() )->ContainsCntnt();
if( pCFrm && pCFrm->IsTxtFrm() )
{
const SwTxtFrm *pTxtFrm = static_cast< const SwTxtFrm * >( pCFrm );
const SwTxtNode *pTxtNd = pTxtFrm->GetTxtNode();
if( pTxtNd )
{
// create pam for selection
SwIndex aIndex( const_cast< SwTxtNode * >( pTxtNd ),
pTxtFrm->GetOfst() );
SwPosition aStartPos( *pTxtNd, aIndex );
SwPaM aPaM( aStartPos );
// set PaM at cursor shell
Select( aPaM );
}
}
}
2002-02-04 13:10:18 +00:00
}
uno::Any SAL_CALL SwAccessibleContext::getAccessibleKeyBinding()
throw (uno::RuntimeException)
2002-02-04 13:10:18 +00:00
{
2002-02-05 14:52:06 +00:00
// There are no key bindings
return uno::Any();
2002-02-04 13:10:18 +00:00
}
sal_Int32 SAL_CALL SwAccessibleContext::getForeground()
throw (uno::RuntimeException, std::exception)
{
return COL_BLACK;
}
sal_Int32 SAL_CALL SwAccessibleContext::getBackground()
throw (uno::RuntimeException, std::exception)
{
return COL_WHITE;
}
2002-02-04 13:10:18 +00:00
OUString SAL_CALL SwAccessibleContext::getImplementationName()
throw( uno::RuntimeException, std::exception )
2002-02-04 13:10:18 +00:00
{
OSL_ENSURE( !this, "implementation name needs to be overloaded" );
2002-02-04 13:10:18 +00:00
THROW_RUNTIME_EXCEPTION( lang::XServiceInfo, "implementation name needs to be overloaded" )
2002-02-04 13:10:18 +00:00
}
sal_Bool SAL_CALL SwAccessibleContext::supportsService (const OUString& ServiceName)
throw (uno::RuntimeException, std::exception)
2002-02-04 13:10:18 +00:00
{
return cppu::supportsService(this, ServiceName);
2002-02-04 13:10:18 +00:00
}
uno::Sequence< OUString > SAL_CALL SwAccessibleContext::getSupportedServiceNames()
throw( uno::RuntimeException, std::exception )
2002-02-04 13:10:18 +00:00
{
OSL_ENSURE( !this, "supported services names needs to be overloaded" );
THROW_RUNTIME_EXCEPTION( lang::XServiceInfo, "supported services needs to be overloaded" )
2002-02-04 13:10:18 +00:00
}
2002-05-15 12:22:47 +00:00
void SwAccessibleContext::DisposeShape( const SdrObject *pObj,
::accessibility::AccessibleShape *pAccImpl )
2002-05-15 12:22:47 +00:00
{
2010-10-15 11:44:38 -05:00
::rtl::Reference< ::accessibility::AccessibleShape > xAccImpl( pAccImpl );
if( !xAccImpl.is() )
2002-05-15 12:22:47 +00:00
xAccImpl = GetMap()->GetContextImpl( pObj, this, sal_True );
AccessibleEventObject aEvent;
aEvent.EventId = AccessibleEventId::CHILD;
2010-10-15 11:44:38 -05:00
uno::Reference< XAccessible > xAcc( xAccImpl.get() );
2002-05-15 12:22:47 +00:00
aEvent.OldValue <<= xAcc;
FireAccessibleEvent( aEvent );
GetMap()->RemoveContext( pObj );
xAccImpl->dispose();
}
void SwAccessibleContext::ScrolledInShape( const SdrObject* ,
::accessibility::AccessibleShape *pAccImpl )
2002-05-15 12:22:47 +00:00
{
if(NULL == pAccImpl)
{
return ;
}
2002-05-15 12:22:47 +00:00
AccessibleEventObject aEvent;
aEvent.EventId = AccessibleEventId::CHILD;
uno::Reference< XAccessible > xAcc( pAccImpl );
2002-05-15 12:22:47 +00:00
aEvent.NewValue <<= xAcc;
FireAccessibleEvent( aEvent );
if( pAccImpl->GetState( AccessibleStateType::FOCUSED ) )
{
Window *pWin = GetWindow();
if( pWin && pWin->HasFocus() )
{
AccessibleEventObject aStateChangedEvent;
aStateChangedEvent.EventId = AccessibleEventId::STATE_CHANGED;
aStateChangedEvent.NewValue <<= AccessibleStateType::FOCUSED;
aStateChangedEvent.Source = xAcc;
FireAccessibleEvent( aStateChangedEvent );
}
}
2002-05-15 12:22:47 +00:00
}
2002-04-11 13:04:40 +00:00
void SwAccessibleContext::Dispose( sal_Bool bRecursive )
{
SolarMutexGuard aGuard;
2002-04-11 13:04:40 +00:00
OSL_ENSURE( GetFrm() && GetMap(), "already disposed" );
OSL_ENSURE( GetMap()->GetVisArea() == GetVisArea(),
2002-04-11 13:04:40 +00:00
"invalid vis area for dispose" );
bDisposing = sal_True;
// dispose children
if( bRecursive )
DisposeChildren( GetFrm(), bRecursive );
// get parent
uno::Reference< XAccessible > xParent( GetWeakParent() );
uno::Reference < XAccessibleContext > xThis( this );
2002-04-11 13:04:40 +00:00
// send child event at parent
if( xParent.is() )
{
SwAccessibleContext *pAcc = (SwAccessibleContext *)xParent.get();
AccessibleEventObject aEvent;
aEvent.EventId = AccessibleEventId::CHILD;
2002-04-11 13:04:40 +00:00
aEvent.OldValue <<= xThis;
pAcc->FireAccessibleEvent( aEvent );
}
// set defunc state (its not required to broadcast a state changed
2014-04-11 08:25:35 +02:00
// event if the object is disposed afterwards)
2002-04-11 13:04:40 +00:00
{
osl::MutexGuard aDefuncStateGuard( aMutex );
2002-04-11 13:04:40 +00:00
bIsDefuncState = sal_True;
}
// broadcast dispose event
if ( nClientId )
2002-04-11 13:04:40 +00:00
{
comphelper::AccessibleEventNotifier::revokeClientNotifyDisposing( nClientId, *this );
nClientId = 0;
2002-04-11 13:04:40 +00:00
}
RemoveFrmFromAccessibleMap();
2002-04-11 13:04:40 +00:00
ClearFrm();
pMap = 0;
bDisposing = sal_False;
}
void SwAccessibleContext::DisposeChild( const SwAccessibleChild& rChildFrmOrObj,
2002-05-15 12:22:47 +00:00
sal_Bool bRecursive )
2002-04-17 13:07:39 +00:00
{
SolarMutexGuard aGuard;
2002-04-17 13:07:39 +00:00
if ( IsShowing( *(GetMap()), rChildFrmOrObj ) ||
rChildFrmOrObj.AlwaysIncludeAsChild() ||
!SwAccessibleChild( GetFrm() ).IsVisibleChildrenOnly() )
2002-04-17 13:07:39 +00:00
{
// If the object could have existed before, than there is nothing to do,
// because no wrapper exists now and therefor no one is interested to
// get notified of the movement.
2002-05-15 12:22:47 +00:00
if( rChildFrmOrObj.GetSwFrm() )
{
2010-10-15 11:44:38 -05:00
::rtl::Reference< SwAccessibleContext > xAccImpl =
2002-05-15 12:22:47 +00:00
GetMap()->GetContextImpl( rChildFrmOrObj.GetSwFrm(),
sal_True );
xAccImpl->Dispose( bRecursive );
}
else if ( rChildFrmOrObj.GetDrawObject() )
2002-05-15 12:22:47 +00:00
{
2010-10-15 11:44:38 -05:00
::rtl::Reference< ::accessibility::AccessibleShape > xAccImpl =
GetMap()->GetContextImpl( rChildFrmOrObj.GetDrawObject(),
2002-05-15 12:22:47 +00:00
this, sal_True );
DisposeShape( rChildFrmOrObj.GetDrawObject(),
2010-10-15 11:44:38 -05:00
xAccImpl.get() );
2002-05-15 12:22:47 +00:00
}
else if ( rChildFrmOrObj.GetWindow() )
{
AccessibleEventObject aEvent;
aEvent.EventId = AccessibleEventId::CHILD;
uno::Reference< XAccessible > xAcc =
rChildFrmOrObj.GetWindow()->GetAccessible();
aEvent.OldValue <<= xAcc;
FireAccessibleEvent( aEvent );
}
2002-04-17 13:07:39 +00:00
}
2002-05-15 12:22:47 +00:00
else if( bRecursive && rChildFrmOrObj.GetSwFrm() )
DisposeChildren( rChildFrmOrObj.GetSwFrm(), bRecursive );
2002-04-17 13:07:39 +00:00
}
void SwAccessibleContext::InvalidatePosOrSize( const SwRect& )
2002-04-11 13:04:40 +00:00
{
SolarMutexGuard aGuard;
2002-04-11 13:04:40 +00:00
OSL_ENSURE( GetFrm() && !GetFrm()->Frm().IsEmpty(), "context should have a size" );
2002-08-15 10:57:22 +00:00
2002-04-11 13:04:40 +00:00
sal_Bool bIsOldShowingState;
sal_Bool bIsNewShowingState = IsShowing( *(GetMap()) );
2002-04-11 13:04:40 +00:00
{
osl::MutexGuard aShowingStateGuard( aMutex );
2002-04-11 13:04:40 +00:00
bIsOldShowingState = bIsShowingState;
bIsShowingState = bIsNewShowingState;
}
if( bIsOldShowingState != bIsNewShowingState )
{
FireStateChangedEvent( AccessibleStateType::SHOWING,
bIsNewShowingState );
}
else if( bIsNewShowingState )
{
// The frame stays visible -> broadcast event
FireVisibleDataEvent();
}
if( !bIsNewShowingState &&
SwAccessibleChild( GetParent() ).IsVisibleChildrenOnly() )
2002-04-11 13:04:40 +00:00
{
return;
2002-04-11 13:04:40 +00:00
}
_InvalidateContent( sal_True );
2002-04-11 13:04:40 +00:00
}
2002-05-15 12:22:47 +00:00
void SwAccessibleContext::InvalidateChildPosOrSize(
const SwAccessibleChild& rChildFrmOrObj,
2002-05-15 12:22:47 +00:00
const SwRect& rOldFrm )
2002-04-11 13:04:40 +00:00
{
SolarMutexGuard aGuard;
2002-04-11 13:04:40 +00:00
OSL_ENSURE( !rChildFrmOrObj.GetSwFrm() ||
2002-08-15 10:57:22 +00:00
!rChildFrmOrObj.GetSwFrm()->Frm().IsEmpty(),
"child context should have a size" );
if ( rChildFrmOrObj.AlwaysIncludeAsChild() )
{
// nothing to do;
return;
}
const bool bVisibleChildrenOnly = SwAccessibleChild( GetFrm() ).IsVisibleChildrenOnly();
const bool bNew = rOldFrm.IsEmpty() ||
( rOldFrm.Left() == 0 && rOldFrm.Top() == 0 );
if( IsShowing( *(GetMap()), rChildFrmOrObj ) )
2002-04-11 13:04:40 +00:00
{
// If the object could have existed before, than there is nothing to do,
// because no wrapper exists now and therefor no one is interested to
// get notified of the movement.
if( bNew || (bVisibleChildrenOnly && !IsShowing( rOldFrm )) )
2002-04-11 13:04:40 +00:00
{
2002-05-15 12:22:47 +00:00
if( rChildFrmOrObj.GetSwFrm() )
{
// The frame becomes visible. A child event must be send.
2010-10-15 11:44:38 -05:00
::rtl::Reference< SwAccessibleContext > xAccImpl =
2002-05-15 12:22:47 +00:00
GetMap()->GetContextImpl( rChildFrmOrObj.GetSwFrm(),
sal_True );
xAccImpl->ScrolledIn();
}
else if ( rChildFrmOrObj.GetDrawObject() )
2002-05-15 12:22:47 +00:00
{
2010-10-15 11:44:38 -05:00
::rtl::Reference< ::accessibility::AccessibleShape > xAccImpl =
GetMap()->GetContextImpl( rChildFrmOrObj.GetDrawObject(),
2002-05-15 12:22:47 +00:00
this, sal_True );
2011-01-30 04:19:53 +09:00
// #i37790#
2010-10-15 11:44:38 -05:00
if ( xAccImpl.is() )
{
ScrolledInShape( rChildFrmOrObj.GetDrawObject(),
2010-10-15 11:44:38 -05:00
xAccImpl.get() );
}
else
{
OSL_FAIL( "<SwAccessibleContext::InvalidateChildPosOrSize(..)> - no accessible shape found." );
}
2002-05-15 12:22:47 +00:00
}
else if ( rChildFrmOrObj.GetWindow() )
{
AccessibleEventObject aEvent;
aEvent.EventId = AccessibleEventId::CHILD;
aEvent.NewValue <<= (rChildFrmOrObj.GetWindow()->GetAccessible());
FireAccessibleEvent( aEvent );
}
2002-04-11 13:04:40 +00:00
}
}
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( bVisibleChildrenOnly &&
2002-04-11 13:04:40 +00:00
!bNew && IsShowing( rOldFrm ) )
{
2002-05-15 12:22:47 +00:00
if( rChildFrmOrObj.GetSwFrm() )
{
2010-10-15 11:44:38 -05:00
::rtl::Reference< SwAccessibleContext > xAccImpl =
2002-05-15 12:22:47 +00:00
GetMap()->GetContextImpl( rChildFrmOrObj.GetSwFrm(),
sal_True );
xAccImpl->SetParent( this );
xAccImpl->Dispose( sal_True );
}
else if ( rChildFrmOrObj.GetDrawObject() )
2002-05-15 12:22:47 +00:00
{
2010-10-15 11:44:38 -05:00
::rtl::Reference< ::accessibility::AccessibleShape > xAccImpl =
GetMap()->GetContextImpl( rChildFrmOrObj.GetDrawObject(),
2002-05-15 12:22:47 +00:00
this, sal_True );
DisposeShape( rChildFrmOrObj.GetDrawObject(),
2010-10-15 11:44:38 -05:00
xAccImpl.get() );
2002-05-15 12:22:47 +00:00
}
else if ( rChildFrmOrObj.GetWindow() )
{
OSL_FAIL( "<SwAccessibleContext::InvalidateChildPosOrSize(..)> - not expected to handle dispose of child of type <Window>." );
}
2002-04-11 13:04:40 +00:00
}
}
}
void SwAccessibleContext::InvalidateContent()
{
SolarMutexGuard aGuard;
2002-04-11 13:04:40 +00:00
_InvalidateContent( sal_False );
}
void SwAccessibleContext::InvalidateCursorPos()
{
SolarMutexGuard aGuard;
2002-04-11 13:04:40 +00:00
_InvalidateCursorPos();
}
2002-05-16 07:22:32 +00:00
void SwAccessibleContext::InvalidateFocus()
{
SolarMutexGuard aGuard;
2002-05-16 07:22:32 +00:00
_InvalidateFocus();
}
2011-01-30 04:19:53 +09:00
// #i27301# - use new type definition for <_nStates>
void SwAccessibleContext::InvalidateStates( tAccessibleStates _nStates )
2002-04-11 13:04:40 +00:00
{
if( GetMap() )
{
SwViewShell *pVSh = GetMap()->GetShell();
2002-04-11 13:04:40 +00:00
if( pVSh )
{
if( (_nStates & ACC_STATE_EDITABLE) != 0 )
2002-04-11 13:04:40 +00:00
{
sal_Bool bIsOldEditableState;
sal_Bool bIsNewEditableState = IsEditable( pVSh );
{
osl::MutexGuard aGuard( aMutex );
2002-04-11 13:04:40 +00:00
bIsOldEditableState = bIsEditableState;
bIsEditableState = bIsNewEditableState;
}
if( bIsOldEditableState != bIsNewEditableState )
FireStateChangedEvent( AccessibleStateType::EDITABLE,
bIsNewEditableState );
}
if( (_nStates & ACC_STATE_OPAQUE) != 0 )
2002-04-11 13:04:40 +00:00
{
sal_Bool bIsOldOpaqueState;
sal_Bool bIsNewOpaqueState = IsOpaque( pVSh );
{
osl::MutexGuard aGuard( aMutex );
2002-04-11 13:04:40 +00:00
bIsOldOpaqueState = bIsOpaqueState;
bIsOpaqueState = bIsNewOpaqueState;
}
if( bIsOldOpaqueState != bIsNewOpaqueState )
FireStateChangedEvent( AccessibleStateType::OPAQUE,
bIsNewOpaqueState );
}
}
InvalidateChildrenStates( GetFrm(), _nStates );
2002-04-11 13:04:40 +00:00
}
}
void SwAccessibleContext::InvalidateRelation( sal_uInt16 nType )
{
AccessibleEventObject aEvent;
aEvent.EventId = nType;
FireAccessibleEvent( aEvent );
}
2011-01-30 04:19:53 +09:00
/** #i27301# - text selection has changed */
void SwAccessibleContext::InvalidateTextSelection()
{
AccessibleEventObject aEvent;
aEvent.EventId = AccessibleEventId::TEXT_SELECTION_CHANGED;
FireAccessibleEvent( aEvent );
}
2011-01-30 04:19:53 +09:00
/** #i88069# - attributes has changed */
void SwAccessibleContext::InvalidateAttr()
{
AccessibleEventObject aEvent;
aEvent.EventId = AccessibleEventId::TEXT_ATTRIBUTE_CHANGED;
FireAccessibleEvent( aEvent );
}
2002-04-11 13:04:40 +00:00
sal_Bool SwAccessibleContext::HasCursor()
{
return sal_False;
}
sal_Bool SwAccessibleContext::Select( SwPaM *pPaM, SdrObject *pObj,
sal_Bool bAdd )
{
SwCrsrShell* pCrsrShell = GetCrsrShell();
if( !pCrsrShell )
return sal_False;
SwFEShell* pFEShell = pCrsrShell->ISA( SwFEShell )
? static_cast<SwFEShell*>( pCrsrShell )
: 0;
// Get rid of activated OLE object
if( pFEShell )
pFEShell->FinishOLEObj();
SwWrtShell* pWrtShell = pCrsrShell->ISA( SwWrtShell )
? static_cast<SwWrtShell*>( pCrsrShell )
: 0;
sal_Bool bRet = sal_False;
if( pObj )
{
if( pFEShell )
{
Point aDummy;
sal_uInt8 nFlags = bAdd ? SW_ADD_SELECT : 0;
pFEShell->SelectObj( aDummy, nFlags, pObj );
bRet = sal_True;
}
}
else if( pPaM )
{
// Get rid of frame selection. If there is one, make text cursor
// visible again.
sal_Bool bCallShowCrsr = sal_False;
if( pFEShell && (pFEShell->IsFrmSelected() ||
pFEShell->IsObjSelected()) )
{
Point aPt( LONG_MIN, LONG_MIN );
pFEShell->SelectObj( aPt, 0 );
bCallShowCrsr = sal_True;
}
pCrsrShell->KillPams();
if( pWrtShell && pPaM->HasMark() )
// We have to do this or SwWrtShell can't figure out that it needs
// to kill the selection later, when the user moves the cursor.
pWrtShell->SttSelect();
pCrsrShell->SetSelection( *pPaM );
if( pPaM->HasMark() && *pPaM->GetPoint() == *pPaM->GetMark())
// Setting a "Selection" that starts and ends at the same spot
// should remove the selection rather than create an empty one, so
// that we get defined behavior if accessibility sets the cursor
// later.
pCrsrShell->ClearMark();
if( bCallShowCrsr )
pCrsrShell->ShowCrsr();
bRet = sal_True;
}
return bRet;
}
2002-04-11 13:04:40 +00:00
OUString SwAccessibleContext::GetResource( sal_uInt16 nResId,
const OUString *pArg1,
const OUString *pArg2 )
{
OUString sStr;
2002-04-11 13:04:40 +00:00
{
SolarMutexGuard aGuard;
2002-04-11 13:04:40 +00:00
sStr = SW_RESSTR( nResId );
2002-04-11 13:04:40 +00:00
}
if( pArg1 )
{
sStr = sStr.replaceFirst( OUString("$(ARG1)"), *pArg1 );
2002-04-11 13:04:40 +00:00
}
if( pArg2 )
{
sStr = sStr.replaceFirst( OUString("$(ARG2)"), *pArg2 );
2002-04-11 13:04:40 +00:00
}
return sStr;
2002-04-11 13:04:40 +00:00
}
void SwAccessibleContext::RemoveFrmFromAccessibleMap()
{
if( bRegisteredAtAccessibleMap && GetFrm() && GetMap() )
GetMap()->RemoveContext( GetFrm() );
}
bool SwAccessibleContext::HasAdditionalAccessibleChildren()
{
bool bRet( false );
if ( GetFrm()->IsTxtFrm() )
{
SwPostItMgr* pPostItMgr = GetMap()->GetShell()->GetPostItMgr();
if ( pPostItMgr && pPostItMgr->HasNotes() && pPostItMgr->ShowNotes() )
{
bRet = pPostItMgr->HasFrmConnectedSidebarWins( *(GetFrm()) );
}
}
return bRet;
}
2011-01-30 04:19:53 +09:00
/** #i88070# - get additional accessible child by index */
Window* SwAccessibleContext::GetAdditionalAccessibleChild( const sal_Int32 nIndex )
{
Window* pAdditionalAccessibleChild( 0 );
if ( GetFrm()->IsTxtFrm() )
{
SwPostItMgr* pPostItMgr = GetMap()->GetShell()->GetPostItMgr();
if ( pPostItMgr && pPostItMgr->HasNotes() && pPostItMgr->ShowNotes() )
{
pAdditionalAccessibleChild =
pPostItMgr->GetSidebarWinForFrmByIndex( *(GetFrm()), nIndex );
}
}
return pAdditionalAccessibleChild;
}
2011-01-30 04:19:53 +09:00
/** #i88070# - get all additional accessible children */
void SwAccessibleContext::GetAdditionalAccessibleChildren( std::vector< Window* >* pChildren )
{
if ( GetFrm()->IsTxtFrm() )
{
SwPostItMgr* pPostItMgr = GetMap()->GetShell()->GetPostItMgr();
if ( pPostItMgr && pPostItMgr->HasNotes() && pPostItMgr->ShowNotes() )
{
pPostItMgr->GetAllSidebarWinForFrm( *(GetFrm()), pChildren );
}
}
}
2002-04-11 13:04:40 +00:00
sal_Bool SwAccessibleContext::SetSelectedState(sal_Bool bSeleted)
{
if(bIsSeletedInDoc != bSeleted)
{
bIsSeletedInDoc = bSeleted;
FireStateChangedEvent( AccessibleStateType::SELECTED, bSeleted );
return sal_True;
}
return sal_False;
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */