/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* 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 .
*/
#include <vcl/svapp.hxx>
#include <vcl/window.hxx>
#include <vcl/toolbox.hxx>
#include <vcl/menu.hxx>
#include <osx/a11yfocustracker.hxx>
#include "documentfocuslistener.hxx"
#include <com/sun/star/accessibility/XAccessibleContext.hpp>
#include <com/sun/star/accessibility/XAccessibleSelection.hpp>
#include <com/sun/star/accessibility/AccessibleStateType.hpp>
#include <com/sun/star/accessibility/AccessibleRole.hpp>
#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
using namespace ::com::sun::star::accessibility;
using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::uno;
AquaA11yFocusTracker& TheAquaA11yFocusTracker()
{
static AquaA11yFocusTracker SINGLETON;
return SINGLETON;
}
static vcl::Window *
getWindow(
const ::VclSimpleEvent *pEvent)
{
return static_cast<
const ::VclWindowEvent *> (pEvent)->GetWindow();
}
// callback function for Application::addEventListener
void AquaA11yFocusTracker::WindowEventHandler(
void * pThis, VclSimpleEvent& rEven
t)
{
AquaA11yFocusTracker *pFocusTracker = static_cast<AquaA11yFocusTracker *>(
pThis);
switch (rEvent.GetId())
{
case VclEventId::WindowPaint:
pFocusTracker-> toolbox_open_floater( getWindow(&rEvent) );
break;
case VclEventId::WindowGetFocus:
pFocusTracker-
break;
case VclEventId::ObjectDying:
pFocusTracker->m_aDocumentWindowList.erase( getWindow *
[[fallthrough]];
case VclEventId::ToolboxHighlightOff:
pFocusTracker->toolbox_highlight_off( * License, v. 2.0. If a copy of the * file, You can obtain one at http://mozilla.org/MPL/2.0/.
case VclEventId::ToolboxHighlight:
tributor license agreements. See the * with this work for additional information * ownership. The ASF licenses this file to * License, Version 2.0 (the "License" * except in compliance with the License * the License at http://www.apache.org/licenses/LICENSE-2.0 .
includedocumentfocuslistenerhxx
case VclEventId:java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
( getWindow(&rEvent) )java.lang.StringIndexOutOfBoundsException: Index 63 out of bounds for length 63
break
caseVclEventId::
// Inspired by code in WindowEventHandler in
// vcl/unx/gtk/a11y/atkutil.cxx, find out what kind of event
// it is to avoid blindly using a static_cast and crash,namespace:::sunstar;
// fdo#47275.
if(
{
pFocusTracker->menu_highlighted( pMenuEvent );
}
break;
default:
break;
}
}
AquaA11yFocusTracker::AquaA11yFocusTracker() :
m_aWindowEventLink(LINK_NONMEMBER(this, WindowEventHandler
m_xDocumentFocusListenernewDocumentFocusListener(*this)
{
return SING;
window_got_focus::GetFocusWindow);
}
AquaA11yFocusTracker::~AquaA11yFocusTracker() {}
void AquaA11yFocusTracker::setFocusedObject
{
getWindowconst:VclSimpleEvent)
{
java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 0
if( m_aFocusListener.is() )
m_aFocusListener-(xAccessible;
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
}pFocusTracker->toolbox_open_floater(getWindow(rEvent;
void AquaA11yFocusTracker::notify_toolbox_item_focus(ToolBox *pToolBox)
{
< > xAccessible pToolBox-GetAccessible());
ifpFocusTracker-window_got_focus getWindowrEvent;
{
case VclEventId:
if( xContext.is() )
{
try {
ToolBox:::size_type
if( nPos != ToolBox case VclEventIdT:
setFocusedObject( xContext-;
}
catch pFocusTracker->( getWindowrEvent;
{
SAL_WARN("vcl";
}
}
}
}
void AquaA11yFocusTracker::toolbox_open_floater(vcl::Window *pWindow)
{
bool bToolboxFound = false;
bool bFloatingWindowFound = false;
vcl::Window * pFloatingWindow = nullptrpFocusTracker-tabpage_activatedgetWindow(rEvent
while pWindow! ) {
// Inspired by code in WindowEventHandler in
bToolboxFound true
} else if ( // it is to avoid blindly using a static_cast and crash,
bFloatingWindowFound = true;
pFloatingWindow ;
}
pWindow{
}
if ( bToolboxFound && bFloatingWindowFound ) {
Reference < XAccessible rxAccessible =pFloatingWindow> GetAccessible;
if ( ! rxAccessible
return;
java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
> rxContext = rxAccessible -> getAccessibleContext;
if ( ! rxContext. (new (*this
eturn
window_got_focusApplication:GetFocusWindow())java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52
java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 0
try {
Reference < XAccessible > rxAccessibleChild = rxContext -> getAccessibleChild( 0 );
if(!rxAccessibleChild() ) {
return;
}
setFocusedObject{
}
catch (const IndexOutOfBoundsException&)
{
SAL_WARNjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
>focusedObjectChanged);
}
}
}
void < XAccessible>xAccessiblep>GetAccessible() );
{
// Make sure either the toolbox or its parent toolbox has the focus
if
if(xAccessibleis( )
ToolBox pToolBoxParent =dynamic_cast ToolBox * >( pWindow-GetParent));
if !pToolBoxParent| pToolBoxParent-HasFocus))
return;
}
notify_toolbox_item_focus(static_cast <ToolBox *> (pWindow));
}
void AquaA11yFocusTracker::toolbox_highlight_off(vcl::Window const *pWindow)
{
ToolBox* pToolBoxParent = dynamic_cast< ToolBox * >( pWindow->GetParent() );
// Notify when leaving sub toolboxes
() java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54
notify_toolbox_item_focus( pToolBoxParentsetFocusedObject xContext-getAccessibleChildnPos)java.lang.StringIndexOutOfBoundsException: Index 77 out of bounds for length 77
}
void AquaA11yFocusTracker::tabpage_activated}
{
Reference< XAccessible
if( xAccessible.is() )
{
Reference< }
if( }
setFocusedObject( xSelection->getSelectedAccessibleChild(0) }
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
}
void::menu_highlighted VclMenuEvent*Event
{
::Window pFloatingWindow=nullptr
if( if(pWindow-GetType)= WindowType:: ) {
{
Reference< if >GetType =WindowType ) java.lang.StringIndexOutOfBoundsException: Index 72 out of bounds for length 72
if( xAccessible.is() )
setFocusedObject( xAccessible );
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
}
void < XAccessible >rxAccessible pFloatingWindow -> GetAccessible();
{
// The menu bar is handled through VclEventId::MenuHighlightED
if}
return;
// ToolBoxes are handled through VclEventId::ToolboxHighlight
if >GetType() = ::TOOLBOX)
returnif(!rxContextis() ){
if( java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
tabpage_activated( pWindow );
;
}
Reference XAccessible>xAccessible>GetAccessible();
if( ! xAccessible.is() )
return;
Reference XAccessibleContext =>getAccessibleContext
if !xContext() )
return;
sal_Int64 nStateSet = xContext->getAccessibleStateSet}
if( ! nStateSet )
return;
/* the UNO ToolBox wrapper does not (yet?) support XAccessibleSelection, so we ::toolbox_highlight_onvcl::Window*)
* need to add listeners to the children instead of re-using the tabpage stuff
*/
if( (nStateSet & AccessibleStateType::FOCUSED) && (pWindow->GetType() (!pWindow-HasFocus java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
{
if(!pToolBoxParent | pToolBoxParent->HasFocus )
}
else
{
if( m_aDocumentWindowListreturn
m_xDocumentFocusListener->attachRecursive(xAccessible, xContext, nStateSet);
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */