svtools a11y: Merge BrowseBoxImpl into BrowseBox

Change-Id: I3667e47867eb85f18cf8ad620cff903cc13f38c3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177352
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
This commit is contained in:
Michael Weghorn
2024-11-26 16:15:25 +01:00
parent 649d2de3dc
commit c630dbc1ab
4 changed files with 69 additions and 118 deletions

View File

@@ -28,10 +28,12 @@
#include <vcl/timer.hxx> #include <vcl/timer.hxx>
#include <vcl/AccessibleBrowseBoxObjType.hxx> #include <vcl/AccessibleBrowseBoxObjType.hxx>
#include <vcl/accessibletableprovider.hxx> #include <vcl/accessibletableprovider.hxx>
#include <vcl/svtaccessiblefactory.hxx>
#include <vector> #include <vector>
#include <stack> #include <stack>
#include <limits.h> #include <limits.h>
#include <map>
#include <memory> #include <memory>
#include <o3tl/typed_flags_set.hxx> #include <o3tl/typed_flags_set.hxx>
@@ -261,9 +263,10 @@ class SVT_DLLPUBLIC BrowseBox
,public vcl::IAccessibleTableProvider ,public vcl::IAccessibleTableProvider
{ {
friend class BrowserDataWin; friend class BrowserDataWin;
friend class ::svt::BrowseBoxImpl;
public: public:
typedef ::std::map<sal_Int32, css::uno::Reference<css::accessibility::XAccessible>> THeaderCellMap;
static const sal_uInt16 HandleColumnId = 0; static const sal_uInt16 HandleColumnId = 0;
private: private:
@@ -342,12 +345,16 @@ private:
std::stack<CursorMoveAttempt> std::stack<CursorMoveAttempt>
m_aGotoStack; m_aGotoStack;
::std::unique_ptr< ::svt::BrowseBoxImpl > m_pImpl; // impl structure of the BrowseBox object
bool m_bFocusOnlyCursor; // hide cursor if we don't have the focus bool m_bFocusOnlyCursor; // hide cursor if we don't have the focus
Color m_aCursorColor; // special color for cursor, COL_TRANSPARENT for usual (VCL-painted) "inverted" cursor Color m_aCursorColor; // special color for cursor, COL_TRANSPARENT for usual (VCL-painted) "inverted" cursor
BrowserMode m_nCurrentMode; // last argument of SetMode (redundant, as our other members represent the current settings, too) BrowserMode m_nCurrentMode; // last argument of SetMode (redundant, as our other members represent the current settings, too)
vcl::AccessibleFactoryAccess m_aFactoryAccess;
rtl::Reference<vcl::IAccessibleBrowseBox> m_pAccessible;
THeaderCellMap m_aColHeaderCellMap;
THeaderCellMap m_aRowHeaderCellMap;
private: private:
SVT_DLLPRIVATE void ExpandRowSelection( const BrowserMouseEvent& rEvt ); SVT_DLLPRIVATE void ExpandRowSelection( const BrowserMouseEvent& rEvt );
SVT_DLLPRIVATE void ToggleSelection(); SVT_DLLPRIVATE void ToggleSelection();
@@ -381,6 +388,14 @@ private:
SAL_DLLPRIVATE sal_uInt16 ToggleSelectedColumn(); SAL_DLLPRIVATE sal_uInt16 ToggleSelectedColumn();
SAL_DLLPRIVATE void SetToggledSelectedColumn(sal_uInt16 _nSelectedColumnId); SAL_DLLPRIVATE void SetToggledSelectedColumn(sal_uInt16 _nSelectedColumnId);
/// @see AccessibleBrowseBox::getHeaderBar
css::uno::Reference<css::accessibility::XAccessible>
getAccessibleHeaderBar(AccessibleBrowseBoxObjType _eObjType);
/// @see AccessibleBrowseBox::getTable
css::uno::Reference<css::accessibility::XAccessible>
getAccessibleTable();
protected: protected:
/// retrieves the XAccessible implementation associated with the BrowseBox instance /// retrieves the XAccessible implementation associated with the BrowseBox instance
SAL_DLLPRIVATE ::vcl::IAccessibleFactory& getAccessibleFactory(); SAL_DLLPRIVATE ::vcl::IAccessibleFactory& getAccessibleFactory();

View File

@@ -17,12 +17,14 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 . * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/ */
#include <comphelper/diagnose_ex.hxx>
#include <svtools/brwbox.hxx> #include <svtools/brwbox.hxx>
#include <svtools/brwhead.hxx> #include <svtools/brwhead.hxx>
#include <svtools/scrolladaptor.hxx> #include <svtools/scrolladaptor.hxx>
#include <o3tl/numeric.hxx> #include <o3tl/numeric.hxx>
#include <o3tl/safeint.hxx> #include <o3tl/safeint.hxx>
#include "datwin.hxx" #include "datwin.hxx"
#include <osl/diagnose.h>
#include <tools/debug.hxx> #include <tools/debug.hxx>
#include <tools/fract.hxx> #include <tools/fract.hxx>
#include <sal/log.hxx> #include <sal/log.hxx>
@@ -34,8 +36,8 @@
#include <com/sun/star/accessibility/AccessibleTableModelChange.hpp> #include <com/sun/star/accessibility/AccessibleTableModelChange.hpp>
#include <com/sun/star/accessibility/AccessibleTableModelChangeType.hpp> #include <com/sun/star/accessibility/AccessibleTableModelChangeType.hpp>
#include <com/sun/star/accessibility/AccessibleEventId.hpp> #include <com/sun/star/accessibility/AccessibleEventId.hpp>
#include <com/sun/star/lang/XComponent.hpp>
#include <tools/multisel.hxx> #include <tools/multisel.hxx>
#include "brwimpl.hxx"
#define SCROLL_FLAGS (ScrollFlags::Clip | ScrollFlags::NoChildren) #define SCROLL_FLAGS (ScrollFlags::Clip | ScrollFlags::NoChildren)
@@ -50,7 +52,7 @@ namespace
{ {
struct THeaderCellMapFunctorDispose struct THeaderCellMapFunctorDispose
{ {
void operator()(const svt::BrowseBoxImpl::THeaderCellMap::value_type& _aType) void operator()(const BrowseBox::THeaderCellMap::value_type& _aType)
{ {
css::uno::Reference<css::lang::XComponent> xComp(_aType.second, css::uno::UNO_QUERY); css::uno::Reference<css::lang::XComponent> xComp(_aType.second, css::uno::UNO_QUERY);
OSL_ENSURE(xComp.is() || !_aType.second.is(), "THeaderCellMapFunctorDispose: invalid accessible cell (no XComponent)!"); OSL_ENSURE(xComp.is() || !_aType.second.is(), "THeaderCellMapFunctorDispose: invalid accessible cell (no XComponent)!");
@@ -66,7 +68,7 @@ namespace
} }
}; };
void disposeAndClearHeaderCell(::svt::BrowseBoxImpl::THeaderCellMap& _rHeaderCell) void disposeAndClearHeaderCell(BrowseBox::THeaderCellMap& _rHeaderCell)
{ {
::std::for_each( ::std::for_each(
_rHeaderCell.begin(), _rHeaderCell.begin(),
@@ -142,7 +144,6 @@ BrowseBox::BrowseBox( vcl::Window* pParent, WinBits nBits, BrowserMode nMode )
pColSel = nullptr; pColSel = nullptr;
pVScroll = nullptr; pVScroll = nullptr;
pDataWin = VclPtr<BrowserDataWin>::Create( this ).get(); pDataWin = VclPtr<BrowserDataWin>::Create( this ).get();
m_pImpl.reset( new ::svt::BrowseBoxImpl() );
InitSettings_Impl( this ); InitSettings_Impl( this );
InitSettings_Impl( pDataWin ); InitSettings_Impl( pDataWin );
@@ -194,12 +195,12 @@ BrowseBox::~BrowseBox()
void BrowseBox::DisposeAccessible() void BrowseBox::DisposeAccessible()
{ {
if (m_pImpl->m_pAccessible ) if (m_pAccessible )
{ {
disposeAndClearHeaderCell(m_pImpl->m_aColHeaderCellMap); disposeAndClearHeaderCell(m_aColHeaderCellMap);
disposeAndClearHeaderCell(m_pImpl->m_aRowHeaderCellMap); disposeAndClearHeaderCell(m_aRowHeaderCellMap);
m_pImpl->m_pAccessible->dispose(); m_pAccessible->dispose();
m_pImpl->m_pAccessible = nullptr; m_pAccessible = nullptr;
} }
} }
@@ -819,13 +820,13 @@ void BrowseBox::RemoveColumns()
commitBrowseBoxEvent( commitBrowseBoxEvent(
AccessibleEventId::CHILD, AccessibleEventId::CHILD,
Any(), Any(),
Any(m_pImpl->getAccessibleHeaderBar(AccessibleBrowseBoxObjType::ColumnHeaderBar)) Any(getAccessibleHeaderBar(AccessibleBrowseBoxObjType::ColumnHeaderBar))
); );
// and now append it again // and now append it again
commitBrowseBoxEvent( commitBrowseBoxEvent(
AccessibleEventId::CHILD, AccessibleEventId::CHILD,
Any(m_pImpl->getAccessibleHeaderBar(AccessibleBrowseBoxObjType::ColumnHeaderBar)), Any(getAccessibleHeaderBar(AccessibleBrowseBoxObjType::ColumnHeaderBar)),
Any() Any()
); );
@@ -1139,13 +1140,13 @@ void BrowseBox::Clear()
commitBrowseBoxEvent( commitBrowseBoxEvent(
AccessibleEventId::CHILD, AccessibleEventId::CHILD,
Any(), Any(),
Any( m_pImpl->getAccessibleHeaderBar( AccessibleBrowseBoxObjType::RowHeaderBar ) ) Any(getAccessibleHeaderBar( AccessibleBrowseBoxObjType::RowHeaderBar))
); );
// and now append it again // and now append it again
commitBrowseBoxEvent( commitBrowseBoxEvent(
AccessibleEventId::CHILD, AccessibleEventId::CHILD,
Any( m_pImpl->getAccessibleHeaderBar( AccessibleBrowseBoxObjType::RowHeaderBar ) ), Any(getAccessibleHeaderBar(AccessibleBrowseBoxObjType::RowHeaderBar)),
Any() Any()
); );
@@ -1382,25 +1383,25 @@ void BrowseBox::RowRemoved( sal_Int32 nRow, sal_Int32 nNumRows, bool bDoPaint )
commitBrowseBoxEvent( commitBrowseBoxEvent(
AccessibleEventId::CHILD, AccessibleEventId::CHILD,
Any(), Any(),
Any( m_pImpl->getAccessibleHeaderBar( AccessibleBrowseBoxObjType::RowHeaderBar ) ) Any(getAccessibleHeaderBar(AccessibleBrowseBoxObjType::RowHeaderBar))
); );
// and now append it again // and now append it again
commitBrowseBoxEvent( commitBrowseBoxEvent(
AccessibleEventId::CHILD, AccessibleEventId::CHILD,
Any(m_pImpl->getAccessibleHeaderBar(AccessibleBrowseBoxObjType::RowHeaderBar)), Any(getAccessibleHeaderBar(AccessibleBrowseBoxObjType::RowHeaderBar)),
Any() Any()
); );
commitBrowseBoxEvent( commitBrowseBoxEvent(
AccessibleEventId::CHILD, AccessibleEventId::CHILD,
Any(), Any(),
Any( m_pImpl->getAccessibleTable() ) Any(getAccessibleTable())
); );
// and now append it again // and now append it again
commitBrowseBoxEvent( commitBrowseBoxEvent(
AccessibleEventId::CHILD, AccessibleEventId::CHILD,
Any( m_pImpl->getAccessibleTable() ), Any(getAccessibleTable()),
Any() Any()
); );
} }

View File

@@ -17,13 +17,13 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 . * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/ */
#include <osl/diagnose.h>
#include <svtools/brwbox.hxx> #include <svtools/brwbox.hxx>
#include <vcl/AccessibleBrowseBoxObjType.hxx> #include <vcl/AccessibleBrowseBoxObjType.hxx>
#include <vcl/accessiblefactory.hxx> #include <vcl/accessiblefactory.hxx>
#include <sal/log.hxx> #include <sal/log.hxx>
#include <tools/debug.hxx> #include <tools/debug.hxx>
#include <tools/multisel.hxx> #include <tools/multisel.hxx>
#include "brwimpl.hxx"
#include <com/sun/star/accessibility/AccessibleStateType.hpp> #include <com/sun/star/accessibility/AccessibleStateType.hpp>
// Accessibility ============================================================== // Accessibility ==============================================================
@@ -35,7 +35,7 @@ using namespace ::com::sun::star::accessibility;
namespace svt namespace svt
{ {
static Reference< XAccessible > getHeaderCell( BrowseBoxImpl::THeaderCellMap& _raHeaderCells, static Reference< XAccessible > getHeaderCell(BrowseBox::THeaderCellMap& _raHeaderCells,
sal_Int32 _nPos, sal_Int32 _nPos,
AccessibleBrowseBoxObjType _eType, AccessibleBrowseBoxObjType _eType,
const Reference< XAccessible >& _rParent, const Reference< XAccessible >& _rParent,
@@ -44,7 +44,7 @@ namespace svt
) )
{ {
Reference< XAccessible > xRet; Reference< XAccessible > xRet;
BrowseBoxImpl::THeaderCellMap::iterator aFind = _raHeaderCells.find( _nPos ); BrowseBox::THeaderCellMap::iterator aFind = _raHeaderCells.find(_nPos);
if ( aFind == _raHeaderCells.end() ) if ( aFind == _raHeaderCells.end() )
{ {
Reference< XAccessible > xAccessible = rFactory.createAccessibleBrowseBoxHeaderCell( Reference< XAccessible > xAccessible = rFactory.createAccessibleBrowseBoxHeaderCell(
@@ -60,42 +60,39 @@ namespace svt
xRet = aFind->second; xRet = aFind->second;
return xRet; return xRet;
} }
Reference< XAccessible > BrowseBoxImpl::getAccessibleHeaderBar( AccessibleBrowseBoxObjType _eObjType )
{
if ( m_pAccessible && m_pAccessible->isAlive() )
return m_pAccessible->getHeaderBar( _eObjType );
return nullptr;
}
Reference< XAccessible > BrowseBoxImpl::getAccessibleTable( )
{
if ( m_pAccessible && m_pAccessible->isAlive() )
return m_pAccessible->getTable( );
return nullptr;
}
} }
Reference<XAccessible> BrowseBox::getAccessibleHeaderBar(AccessibleBrowseBoxObjType _eObjType)
{
if (m_pAccessible && m_pAccessible->isAlive())
return m_pAccessible->getHeaderBar(_eObjType);
return nullptr;
}
Reference<XAccessible> BrowseBox::getAccessibleTable()
{
if (m_pAccessible && m_pAccessible->isAlive())
return m_pAccessible->getTable();
return nullptr;
}
Reference< XAccessible > BrowseBox::CreateAccessible() Reference< XAccessible > BrowseBox::CreateAccessible()
{ {
vcl::Window* pParent = GetAccessibleParentWindow(); vcl::Window* pParent = GetAccessibleParentWindow();
DBG_ASSERT( pParent, "BrowseBox::CreateAccessible - parent not found" ); DBG_ASSERT( pParent, "BrowseBox::CreateAccessible - parent not found" );
if( pParent && !m_pImpl->m_pAccessible) if (pParent && !m_pAccessible)
{ {
Reference< XAccessible > xAccParent = pParent->GetAccessible(); Reference< XAccessible > xAccParent = pParent->GetAccessible();
if( xAccParent.is() ) if( xAccParent.is() )
{ {
m_pImpl->m_pAccessible = getAccessibleFactory().createAccessibleBrowseBox( m_pAccessible = getAccessibleFactory().createAccessibleBrowseBox(
xAccParent, *this xAccParent, *this
); );
} }
} }
return m_pImpl->m_pAccessible; return m_pAccessible;
} }
@@ -104,10 +101,10 @@ Reference< XAccessible > BrowseBox::CreateAccessible()
Reference< XAccessible > BrowseBox::CreateAccessibleCell( sal_Int32 _nRow, sal_uInt16 _nColumnPos ) Reference< XAccessible > BrowseBox::CreateAccessibleCell( sal_Int32 _nRow, sal_uInt16 _nColumnPos )
{ {
// BBINDEX_TABLE must be the table // BBINDEX_TABLE must be the table
OSL_ENSURE(m_pImpl->m_pAccessible,"Invalid call: Accessible is null"); OSL_ENSURE(m_pAccessible,"Invalid call: Accessible is null");
return m_pImpl->m_aFactoryAccess.getFactory().createAccessibleBrowseBoxTableCell( return m_aFactoryAccess.getFactory().createAccessibleBrowseBoxTableCell(
m_pImpl->getAccessibleTable(), getAccessibleTable(),
*this, *this,
nullptr, nullptr,
_nRow, _nRow,
@@ -120,12 +117,12 @@ Reference< XAccessible > BrowseBox::CreateAccessibleCell( sal_Int32 _nRow, sal_u
Reference< XAccessible > BrowseBox::CreateAccessibleRowHeader( sal_Int32 _nRow ) Reference< XAccessible > BrowseBox::CreateAccessibleRowHeader( sal_Int32 _nRow )
{ {
return svt::getHeaderCell( return svt::getHeaderCell(
m_pImpl->m_aRowHeaderCellMap, m_aRowHeaderCellMap,
_nRow, _nRow,
AccessibleBrowseBoxObjType::RowHeaderCell, AccessibleBrowseBoxObjType::RowHeaderCell,
m_pImpl->getAccessibleHeaderBar(AccessibleBrowseBoxObjType::RowHeaderBar), getAccessibleHeaderBar(AccessibleBrowseBoxObjType::RowHeaderBar),
*this, *this,
m_pImpl->m_aFactoryAccess.getFactory() m_aFactoryAccess.getFactory()
); );
} }
@@ -133,12 +130,12 @@ Reference< XAccessible > BrowseBox::CreateAccessibleRowHeader( sal_Int32 _nRow )
Reference< XAccessible > BrowseBox::CreateAccessibleColumnHeader( sal_uInt16 _nColumnPos ) Reference< XAccessible > BrowseBox::CreateAccessibleColumnHeader( sal_uInt16 _nColumnPos )
{ {
return svt::getHeaderCell( return svt::getHeaderCell(
m_pImpl->m_aColHeaderCellMap, m_aColHeaderCellMap,
_nColumnPos, _nColumnPos,
AccessibleBrowseBoxObjType::ColumnHeaderCell, AccessibleBrowseBoxObjType::ColumnHeaderCell,
m_pImpl->getAccessibleHeaderBar(AccessibleBrowseBoxObjType::ColumnHeaderBar), getAccessibleHeaderBar(AccessibleBrowseBoxObjType::ColumnHeaderBar),
*this, *this,
m_pImpl->m_aFactoryAccess.getFactory() m_aFactoryAccess.getFactory()
); );
} }
@@ -398,30 +395,30 @@ void BrowseBox::commitHeaderBarEvent(sal_Int16 nEventId,
const Any& rNewValue, const Any& rOldValue, bool _bColumnHeaderBar ) const Any& rNewValue, const Any& rOldValue, bool _bColumnHeaderBar )
{ {
if ( isAccessibleAlive() ) if ( isAccessibleAlive() )
m_pImpl->m_pAccessible->commitHeaderBarEvent( nEventId, m_pAccessible->commitHeaderBarEvent( nEventId,
rNewValue, rOldValue, _bColumnHeaderBar ); rNewValue, rOldValue, _bColumnHeaderBar );
} }
void BrowseBox::commitTableEvent( sal_Int16 _nEventId, const Any& _rNewValue, const Any& _rOldValue ) void BrowseBox::commitTableEvent( sal_Int16 _nEventId, const Any& _rNewValue, const Any& _rOldValue )
{ {
if ( isAccessibleAlive() ) if ( isAccessibleAlive() )
m_pImpl->m_pAccessible->commitTableEvent( _nEventId, _rNewValue, _rOldValue ); m_pAccessible->commitTableEvent(_nEventId, _rNewValue, _rOldValue);
} }
void BrowseBox::commitBrowseBoxEvent( sal_Int16 _nEventId, const Any& _rNewValue, const Any& _rOldValue ) void BrowseBox::commitBrowseBoxEvent( sal_Int16 _nEventId, const Any& _rNewValue, const Any& _rOldValue )
{ {
if ( isAccessibleAlive() ) if ( isAccessibleAlive() )
m_pImpl->m_pAccessible->commitEvent( _nEventId, _rNewValue, _rOldValue); m_pAccessible->commitEvent( _nEventId, _rNewValue, _rOldValue);
} }
::vcl::IAccessibleFactory& BrowseBox::getAccessibleFactory() ::vcl::IAccessibleFactory& BrowseBox::getAccessibleFactory()
{ {
return m_pImpl->m_aFactoryAccess.getFactory(); return m_aFactoryAccess.getFactory();
} }
bool BrowseBox::isAccessibleAlive( ) const bool BrowseBox::isAccessibleAlive( ) const
{ {
return m_pImpl->m_pAccessible && m_pImpl->m_pAccessible->isAlive(); return m_pAccessible && m_pAccessible->isAlive();
} }
// IAccessibleTableProvider // IAccessibleTableProvider

View File

@@ -1,62 +0,0 @@
/* -*- 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 .
*/
#pragma once
#include <vcl/accessibletableprovider.hxx>
#include <vcl/svtaccessiblefactory.hxx>
#include <com/sun/star/lang/XComponent.hpp>
#include <com/sun/star/accessibility/XAccessible.hpp>
#include <osl/diagnose.h>
#include <comphelper/diagnose_ex.hxx>
#include <map>
namespace svt
{
class BrowseBoxImpl
{
// member
public:
typedef ::std::map< sal_Int32, css::uno::Reference< css::accessibility::XAccessible > > THeaderCellMap;
public:
vcl::AccessibleFactoryAccess m_aFactoryAccess;
rtl::Reference<vcl::IAccessibleBrowseBox> m_pAccessible;
THeaderCellMap m_aColHeaderCellMap;
THeaderCellMap m_aRowHeaderCellMap;
public:
BrowseBoxImpl()
{
}
/// @see AccessibleBrowseBox::getHeaderBar
css::uno::Reference< css::accessibility::XAccessible >
getAccessibleHeaderBar( AccessibleBrowseBoxObjType _eObjType );
/// @see AccessibleBrowseBox::getTable
css::uno::Reference< css::accessibility::XAccessible >
getAccessibleTable( );
};
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */