diff options
author | Michael Weghorn <m.weghorn@posteo.de> | 2024-12-17 12:04:04 +0100 |
---|---|---|
committer | Michael Weghorn <m.weghorn@posteo.de> | 2024-12-17 22:56:51 +0100 |
commit | 9283da858506fe3b4383e4cfe0506e470a4356f6 (patch) | |
tree | ef68c38e0acf575aff06d7472e02bda41a2ed495 /vcl/inc/accessibility | |
parent | 90c3d4b17f053de94f098ce807836b974ab97877 (diff) |
a11y: Merge accessibility module into vcl
Now that the accessibility module no longer
depends on toolkit and svtools and there's
therefore no more cyclic dependency, merge it
into the vcl library, where the vcl widgets are located,
for which the classes in the accessibility
module (primarily) provide the a11y classes.
Initially, take over the existing UNO service
"com.sun.star.accessibility.comp.GetStandardAccessibleFactoryService"
to vcl as is. It used to be necessary to break the cyclic
dependency between the vcl, svtools, toolkit and
accessibility module. (vcl is the lowest and
accessibility used to be furthest up in the dependency
chain; yet vcl needed it to create the objects
providing the XAccessible/XAccessibleContext
for its widgets.)
Further simplification can happen in upcoming commits.
Change-Id: Ib46c87446dc9121d3b8e735e0e5a40594da73cc5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178647
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Diffstat (limited to 'vcl/inc/accessibility')
54 files changed, 6790 insertions, 0 deletions
diff --git a/vcl/inc/accessibility/AccessibleBrowseBox.hxx b/vcl/inc/accessibility/AccessibleBrowseBox.hxx new file mode 100644 index 000000000000..ed78bb407044 --- /dev/null +++ b/vcl/inc/accessibility/AccessibleBrowseBox.hxx @@ -0,0 +1,268 @@ +/* -*- 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 <accessibility/AccessibleBrowseBoxBase.hxx> +#include <cppuhelper/weakref.hxx> +#include <vcl/accessibletableprovider.hxx> +#include <mutex> + +namespace accessibility { + + class AccessibleBrowseBoxHeaderBar; + class AccessibleBrowseBoxTable; + + +/** This class represents the complete accessible BrowseBox object. */ +class AccessibleBrowseBox : public AccessibleBrowseBoxBase +{ + friend class AccessibleBrowseBoxAccess; + +protected: + AccessibleBrowseBox( + const css::uno::Reference< css::accessibility::XAccessible >& _rxParent, + const css::uno::Reference< css::accessibility::XAccessible >& _rxCreator, + ::vcl::IAccessibleTableProvider& _rBrowseBox + ); + + virtual ~AccessibleBrowseBox() override; + + /** sets the XAccessible which created the context + + To be called only once, and only if in the ctor NULL was passed. + */ + void setCreator( + const css::uno::Reference< css::accessibility::XAccessible >& _rxCreator + ); + + /** Cleans up members. */ + using AccessibleBrowseBoxBase::disposing; + virtual void SAL_CALL disposing() override; + +protected: + // XAccessibleContext + + /** @return The count of visible children. */ + virtual sal_Int64 SAL_CALL getAccessibleChildCount() override; + + /** @return The XAccessible interface of the specified child. */ + virtual css::uno::Reference< + css::accessibility::XAccessible > SAL_CALL + getAccessibleChild( sal_Int64 nChildIndex ) override; + + // XAccessibleComponent + + /** @return + The accessible child rendered under the given point. + */ + virtual css::uno::Reference< + css::accessibility::XAccessible > SAL_CALL + getAccessibleAtPoint( const css::awt::Point& rPoint ) override; + + /** Grabs the focus to the BrowseBox. */ + virtual void SAL_CALL grabFocus() override; + + // XServiceInfo + + /** @return + The name of this class. + */ + virtual OUString SAL_CALL getImplementationName() override; + +public: + // helper functions + /** commitHeaderBarEvent commit the event at all listeners of the column/row header bar + @param nEventId + the event id + @param rNewValue + the new value + @param rOldValue + the old value + @param _bColumnHeaderBar + true if a column based header bar, false if a row based header bar + */ + void commitHeaderBarEvent(sal_Int16 nEventId, + const css::uno::Any& rNewValue, + const css::uno::Any& rOldValue, bool _bColumnHeaderBar); + + // helper functions + /** commitTableEvent commit the event at all listeners of the table + @param nEventId + the event id + @param rNewValue + the new value + @param rOldValue + the old value + */ + void commitTableEvent(sal_Int16 nEventId, + const css::uno::Any& rNewValue, + const css::uno::Any& rOldValue); + + /** returns the accessible object for the row or the column header bar + */ + css::uno::Reference< + css::accessibility::XAccessible > + getHeaderBar( AccessibleBrowseBoxObjType _eObjType ) + { + return implGetHeaderBar(_eObjType); + } + + /** returns the accessible object for the table representation + */ + css::uno::Reference< + css::accessibility::XAccessible > + getTable( ) + { + return implGetTable(); + } + +protected: + // internal virtual methods + + /** @attention This method requires locked mutex's and a living object. + @return The bounding box (VCL rect.) relative to the parent window. */ + virtual tools::Rectangle implGetBoundingBox() override; + /** @attention This method requires locked mutex's and a living object. + @return The bounding box (VCL rect.) in screen coordinates. */ + virtual AbsoluteScreenPixelRectangle implGetBoundingBoxOnScreen() override; + + // internal helper methods + + /** This method creates (once) and returns the accessible data table child. + @attention This method requires locked mutex's and a living object. + @return The XAccessible interface of the data table. */ + css::uno::Reference< + css::accessibility::XAccessible > implGetTable(); + + /** This method creates (once) and returns the specified header bar. + @attention This method requires locked mutex's and a living object. + @return The XAccessible interface of the header bar. */ + css::uno::Reference< + css::accessibility::XAccessible > + implGetHeaderBar( AccessibleBrowseBoxObjType eObjType ); + + /** This method returns one of the children that are always present: + Data table, row and column header bar or corner control. + @attention This method requires locked mutex's and a living object. + @return The XAccessible interface of the specified child. */ + css::uno::Reference< + css::accessibility::XAccessible > + implGetFixedChild( sal_Int64 nChildIndex ); + + /** This method creates and returns an accessible table. + @return An AccessibleBrowseBoxTable. */ + virtual rtl::Reference<AccessibleBrowseBoxTable> createAccessibleTable(); + +private: + /// the css::accessibility::XAccessible which created the AccessibleBrowseBox + css::uno::WeakReference< css::accessibility::XAccessible > m_aCreator; + + /** The data table child. */ + rtl::Reference<AccessibleBrowseBoxTable> mxTable; + + /** The header bar for rows ("handle column"). */ + rtl::Reference<AccessibleBrowseBoxHeaderBar> mxRowHeaderBar; + + /** The header bar for columns (first row of the table). */ + rtl::Reference<AccessibleBrowseBoxHeaderBar> mxColumnHeaderBar; +}; + + +/** the XAccessible which creates/returns an AccessibleBrowseBox + + The instance holds its XAccessibleContext with a hard reference, while + the context holds this instance weak. +*/ +class AccessibleBrowseBoxAccess final : public ::vcl::IAccessibleBrowseBox +{ +private: + mutable std::mutex m_aMutex; + css::uno::Reference< css::accessibility::XAccessible > + m_xParent; + ::vcl::IAccessibleTableProvider& m_rBrowseBox; + + rtl::Reference<AccessibleBrowseBox> m_xContext; + +public: + AccessibleBrowseBoxAccess( + css::uno::Reference< css::accessibility::XAccessible > _xParent, + ::vcl::IAccessibleTableProvider& _rBrowseBox + ); + +private: + virtual ~AccessibleBrowseBoxAccess() override; + + // XAccessible + virtual css::uno::Reference< css::accessibility::XAccessibleContext > + SAL_CALL getAccessibleContext() override; + + // IAccessibleBrowseBox + void dispose() override; + virtual bool isAlive() const override + { + std::unique_lock aGuard(m_aMutex); + return m_xContext.is() && m_xContext->isAlive(); + } + virtual css::uno::Reference< css::accessibility::XAccessible > + getHeaderBar( AccessibleBrowseBoxObjType _eObjType ) override + { + std::unique_lock aGuard(m_aMutex); + return m_xContext ? m_xContext->getHeaderBar(_eObjType) : nullptr; + } + virtual css::uno::Reference< css::accessibility::XAccessible > + getTable() override + { + std::unique_lock aGuard(m_aMutex); + return m_xContext ? m_xContext->getTable() : nullptr; + } + virtual void commitHeaderBarEvent( sal_Int16 nEventId, const css::uno::Any& rNewValue, + const css::uno::Any& rOldValue, bool _bColumnHeaderBar ) override + { + std::unique_lock aGuard(m_aMutex); + if (m_xContext) + m_xContext->commitHeaderBarEvent( nEventId, rNewValue, rOldValue, _bColumnHeaderBar ); + } + virtual void commitTableEvent( sal_Int16 nEventId, + const css::uno::Any& rNewValue, const css::uno::Any& rOldValue ) override + { + std::unique_lock aGuard(m_aMutex); + if (m_xContext) + m_xContext->commitTableEvent( nEventId, rNewValue, rOldValue ); + } + virtual void commitEvent( sal_Int16 nEventId, + const css::uno::Any& rNewValue, const css::uno::Any& rOldValue ) override + { + std::unique_lock aGuard(m_aMutex); + if (m_xContext) + m_xContext->commitEvent( nEventId, rNewValue, rOldValue ); + } + +private: + AccessibleBrowseBoxAccess( const AccessibleBrowseBoxAccess& ) = delete; + AccessibleBrowseBoxAccess& operator=( const AccessibleBrowseBoxAccess& ) = delete; +}; + + +} // namespace accessibility + + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/accessibility/AccessibleBrowseBoxBase.hxx b/vcl/inc/accessibility/AccessibleBrowseBoxBase.hxx new file mode 100644 index 000000000000..f75aa59c2b16 --- /dev/null +++ b/vcl/inc/accessibility/AccessibleBrowseBoxBase.hxx @@ -0,0 +1,393 @@ +/* -*- 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 <sal/config.h> + +#include <vcl/AccessibleBrowseBoxObjType.hxx> +#include <rtl/ustring.hxx> +#include <tools/gen.hxx> +#include <vcl/svapp.hxx> +#include <cppuhelper/compbase.hxx> +#include <cppuhelper/implbase1.hxx> +#include <cppuhelper/basemutex.hxx> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/awt/XWindow.hpp> +#include <com/sun/star/accessibility/XAccessible.hpp> +#include <com/sun/star/accessibility/XAccessibleContext.hpp> +#include <com/sun/star/accessibility/XAccessibleComponent.hpp> +#include <com/sun/star/accessibility/XAccessibleEventBroadcaster.hpp> +#include <com/sun/star/awt/XFocusListener.hpp> +#include <comphelper/accessibleeventnotifier.hxx> +#include <comphelper/uno3.hxx> + + +namespace vcl { class Window; } + +namespace vcl { + class IAccessibleTableProvider; +} + +namespace accessibility { + +typedef ::cppu::WeakComponentImplHelper< + css::accessibility::XAccessibleContext, + css::accessibility::XAccessibleComponent, + css::accessibility::XAccessibleEventBroadcaster, + css::awt::XFocusListener, + css::lang::XServiceInfo > + AccessibleBrowseBoxImplHelper; + +/** The BrowseBox accessible objects inherit from this base class. It + implements basic functionality for various Accessibility interfaces and + the event broadcaster and contains the osl::Mutex. */ +class AccessibleBrowseBoxBase : + public ::cppu::BaseMutex, + public AccessibleBrowseBoxImplHelper +{ +public: + /** Constructor sets specified name and description. If the constant of a + text is BBTEXT_NONE, the derived class has to set the text via + implSetName() (in Ctor) or later via + setAccessibleName() and setAccessibleDescription() (these methods + notify the listeners about the change). + + @param rxParent XAccessible interface of the parent object. + @param rBrowseBox The BrowseBox control. + @param _xFocusWindow The window that gets all the focus events. + @param eObjType Object type */ + AccessibleBrowseBoxBase( + const css::uno::Reference<css::accessibility::XAccessible>& xParent, + ::vcl::IAccessibleTableProvider& rBrowseBox, + const css::uno::Reference<css::awt::XWindow>& xFocusWindow, + AccessibleBrowseBoxObjType eObjType ); + + /** Constructor sets specified name and description. + @param rxParent XAccessible interface of the parent object. + @param rBrowseBox The BrowseBox control. + @param _xFocusWindow The window that gets all the focus events. + @param eObjType Object type + @param rName The name of this object. + @param rDescription The description text of this object. */ + AccessibleBrowseBoxBase( + css::uno::Reference< css::accessibility::XAccessible > xParent, + ::vcl::IAccessibleTableProvider& rBrowseBox, + css::uno::Reference< css::awt::XWindow > _xFocusWindow, + AccessibleBrowseBoxObjType eObjType, + OUString rName, + OUString rDescription ); + +protected: + virtual ~AccessibleBrowseBoxBase() override; + + /** Commits DeFunc event to listeners and cleans up members. */ + virtual void SAL_CALL disposing() override; + +public: + // XAccessibleContext + + /** @return A reference to the parent accessible object. */ + virtual css::uno::Reference<css::accessibility::XAccessible > SAL_CALL getAccessibleParent() override; + + /** @return The index of this object among the parent's children. */ + virtual sal_Int64 SAL_CALL getAccessibleIndexInParent() override; + + /** @return + The description of this object. + */ + virtual OUString SAL_CALL getAccessibleDescription() override; + + /** @return + The name of this object. + */ + virtual OUString SAL_CALL getAccessibleName() override; + + /** @return + The relation set (the BrowseBox does not have one). + */ + virtual css::uno::Reference< css::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet() override; + + /** @return The set of current states. */ + virtual sal_Int64 SAL_CALL getAccessibleStateSet() override; + + /** @return The parent's locale. */ + virtual css::lang::Locale SAL_CALL getLocale() override; + + /** @return + The role of this object. Panel, ROWHEADER, COLUMNHEADER, TABLE, TABLE_CELL are supported. + */ + virtual sal_Int16 SAL_CALL getAccessibleRole() override; + + /* Derived classes have to implement: + - getAccessibleChildCount, + - getAccessibleChild, + - getAccessibleRole. + Derived classes may overwrite getAccessibleIndexInParent to increase + performance. */ + + // XAccessibleComponent + + /** @return + TRUE, if the point lies within the bounding box of this object. */ + virtual sal_Bool SAL_CALL containsPoint( const css::awt::Point& rPoint ) override; + + /** @return The bounding box of this object. */ + virtual css::awt::Rectangle SAL_CALL getBounds() override; + + /** @return + The upper left corner of the bounding box relative to the parent. */ + virtual css::awt::Point SAL_CALL getLocation() override; + + /** @return + The upper left corner of the bounding box in screen coordinates. */ + virtual css::awt::Point SAL_CALL getLocationOnScreen() override; + + /** @return The size of the bounding box. */ + virtual css::awt::Size SAL_CALL getSize() override; + + virtual sal_Int32 SAL_CALL getForeground( ) override; + virtual sal_Int32 SAL_CALL getBackground( ) override; + + // XFocusListener + virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override; + virtual void SAL_CALL focusGained( const css::awt::FocusEvent& e ) override; + virtual void SAL_CALL focusLost( const css::awt::FocusEvent& e ) override; + + /* Derived classes have to implement: + - getAccessibleAt, + - grabFocus. */ + + /** @return + The accessible child rendered under the given point. + */ + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint( const css::awt::Point& rPoint ) override; + + // XAccessibleEventBroadcaster + + /** Adds a new event listener */ + virtual void SAL_CALL addAccessibleEventListener( + const css::uno::Reference< css::accessibility::XAccessibleEventListener>& rxListener ) override; + + /** Removes an event listener. */ + virtual void SAL_CALL removeAccessibleEventListener( + const css::uno::Reference< css::accessibility::XAccessibleEventListener>& rxListener ) override; + + // XTypeProvider + + /** @return a unique implementation ID. */ + virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override; + + // XServiceInfo + + /** @return Whether the specified service is supported by this class. */ + virtual sal_Bool SAL_CALL supportsService( const OUString& rServiceName ) override; + + /** @return A list of all supported services. */ + virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; + + /* Derived classes have to implement: + - getImplementationName. */ + + // helper methods + + /** @return The BrowseBox object type. */ + inline AccessibleBrowseBoxObjType getType() const; + + /** Changes the name of the object and notifies listeners. */ + void setAccessibleName( const OUString& rName ); + /** Changes the description of the object and notifies listeners. */ + void setAccessibleDescription( const OUString& rDescription ); + + /** Commits an event to all listeners. */ + void commitEvent( + sal_Int16 nEventId, + const css::uno::Any& rNewValue, + const css::uno::Any& rOldValue ); + /** @return TRUE, if the object is not disposed or disposing. */ + bool isAlive() const; + +protected: + // internal virtual methods + + /** Determines whether the BrowseBox control is really showing inside of + its parent accessible window. Derived classes may implement different + behaviour. + @attention This method requires locked mutex's and a living object. + @return TRUE, if the object is really showing. */ + bool implIsShowing(); + + /** Derived classes return the bounding box relative to the parent window. + @attention This method requires locked mutex's and a living object. + @return The bounding box (VCL rect.) relative to the parent window. */ + virtual tools::Rectangle implGetBoundingBox() = 0; + /** Derived classes return the bounding box in screen coordinates. + @attention This method requires locked mutex's and a living object. + @return The bounding box (VCL rect.) in screen coordinates. */ + virtual AbsoluteScreenPixelRectangle implGetBoundingBoxOnScreen() = 0; + + /** Creates a bitset of states of the + current object. This method calls FillStateSet at the BrowseBox which + fills it with more states depending on the object type. Derived classes + may overwrite this method and add more states. + @attention This method requires locked mutex's. + */ + virtual sal_Int64 implCreateStateSet(); + + // internal helper methods + + /** Changes the name of the object (flat assignment, no notify). + @attention This method requires a locked mutex. */ + inline void implSetName( const OUString& rName ); + + /** Locks all mutex's and calculates the bounding box relative to the + parent window. + @return The bounding box (VCL rect.) relative to the parent object. + @throws css::lang::DisposedException + */ + tools::Rectangle getBoundingBox(); + /** Locks all mutex's and calculates the bounding box in screen + coordinates. + @return The bounding box (VCL rect.) in screen coordinates. + @throws css::lang::DisposedException + */ + AbsoluteScreenPixelRectangle getBoundingBoxOnScreen(); + +public: + /** @return The osl::Mutex member provided by the class BaseMutex. */ + ::osl::Mutex& getMutex( ) { return m_aMutex; } + + /** @throws <type>DisposedException</type> If the object is not alive. */ + void ensureIsAlive() const; + + +protected: + // members + + /** The parent accessible object. */ + css::uno::Reference< css::accessibility::XAccessible > mxParent; + /** The VCL BrowseBox control. */ + ::vcl::IAccessibleTableProvider* mpBrowseBox; + + /** This is the window which get all the nice focus events + */ + css::uno::Reference< css::awt::XWindow > m_xFocusWindow; + +private: + ::comphelper::AccessibleEventNotifier::TClientId getClientId() const { return m_aClientId; } + void setClientId(::comphelper::AccessibleEventNotifier::TClientId _aNewClientId) { m_aClientId = _aNewClientId; } + + /** Localized name. */ + OUString maName; + /** Localized description text. */ + OUString maDescription; + + /** The type of this object (for names, descriptions, state sets, ...). */ + AccessibleBrowseBoxObjType meObjType; + + ::comphelper::AccessibleEventNotifier::TClientId m_aClientId; +}; + + +// a version of AccessibleBrowseBoxBase which implements not only the XAccessibleContext, +// but also the XAccessible + +typedef cppu::ImplInheritanceHelper<AccessibleBrowseBoxBase, css::accessibility::XAccessible> + BrowseBoxAccessibleElement_Base; + +class BrowseBoxAccessibleElement : public BrowseBoxAccessibleElement_Base +{ +protected: + /** Constructor sets specified name and description. If the constant of a + text is BBTEXT_NONE, the derived class has to set the text via + implSetName() (in Ctor) or later via + setAccessibleName() and setAccessibleDescription() (these methods + notify the listeners about the change). + + @param rxParent XAccessible interface of the parent object. + @param rBrowseBox The BrowseBox control. + @param eObjType Object type + */ + BrowseBoxAccessibleElement( + const css::uno::Reference< css::accessibility::XAccessible >& rxParent, + ::vcl::IAccessibleTableProvider& rBrowseBox, + AccessibleBrowseBoxObjType eObjType ); + + /** Constructor sets specified name and description. + + @param rxParent XAccessible interface of the parent object. + @param rBrowseBox The BrowseBox control. + @param eObjType Object type + @param rName The name of this object. + @param rDescription The description text of this object. + */ + BrowseBoxAccessibleElement( + const css::uno::Reference< css::accessibility::XAccessible >& rxParent, + ::vcl::IAccessibleTableProvider& rBrowseBox, + AccessibleBrowseBoxObjType eObjType, + const OUString& rName, + const OUString& rDescription ); + +public: + // noncopyable + BrowseBoxAccessibleElement(const BrowseBoxAccessibleElement&) = delete; + const BrowseBoxAccessibleElement& operator=(const BrowseBoxAccessibleElement&) = delete; + +protected: + virtual ~BrowseBoxAccessibleElement() override; + +protected: + // XAccessible + + /** @return The XAccessibleContext interface of this object. */ + virtual css::uno::Reference< css::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext() override; +}; + + +// a helper class for protecting methods which need to lock the solar mutex in addition to the own mutex + +class SolarMethodGuard : public SolarMutexGuard, public osl::MutexGuard +{ +public: + SolarMethodGuard( osl::Mutex& rMutex ) + :SolarMutexGuard( ) + ,osl::MutexGuard( rMutex ) + { + } +}; + +// inlines + +inline AccessibleBrowseBoxObjType AccessibleBrowseBoxBase::getType() const +{ + return meObjType; +} + +inline void AccessibleBrowseBoxBase::implSetName( + const OUString& rName ) +{ + maName = rName; +} + +} // namespace accessibility + + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/accessibility/AccessibleBrowseBoxCheckBoxCell.hxx b/vcl/inc/accessibility/AccessibleBrowseBoxCheckBoxCell.hxx new file mode 100644 index 000000000000..b1b44cc25e26 --- /dev/null +++ b/vcl/inc/accessibility/AccessibleBrowseBoxCheckBoxCell.hxx @@ -0,0 +1,79 @@ +/* -*- 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 <com/sun/star/accessibility/XAccessibleValue.hpp> +#include <com/sun/star/accessibility/XAccessible.hpp> +#include <accessibility/accessiblebrowseboxcell.hxx> +#include <cppuhelper/implbase2.hxx> + +namespace accessibility +{ + + typedef ::cppu::ImplHelper2 < css::accessibility::XAccessible, + css::accessibility::XAccessibleValue + > AccessibleCheckBoxCell_BASE; + + class AccessibleCheckBoxCell final : public AccessibleBrowseBoxCell + ,public AccessibleCheckBoxCell_BASE + { + private: + TriState m_eState; + bool m_bIsTriState; + + virtual ~AccessibleCheckBoxCell() override {} + + virtual sal_Int64 implCreateStateSet() override; + + public: + AccessibleCheckBoxCell(const css::uno::Reference< css::accessibility::XAccessible >& _rxParent, + ::vcl::IAccessibleTableProvider& _rBrowseBox, + sal_Int32 _nRowPos, + sal_uInt16 _nColPos, + const TriState& _eState, + bool _bIsTriState); + + // XInterface + DECLARE_XINTERFACE( ) + // XTypeProvider + DECLARE_XTYPEPROVIDER( ) + + // XAccessible + virtual css::uno::Reference< css::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext( ) override; + + // XAccessibleContext + virtual sal_Int64 SAL_CALL getAccessibleChildCount( ) override; + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int64 i ) override; + virtual OUString SAL_CALL getImplementationName() override; + virtual sal_Int64 SAL_CALL getAccessibleIndexInParent( ) override; + + + // XAccessibleValue + virtual css::uno::Any SAL_CALL getCurrentValue( ) override; + virtual sal_Bool SAL_CALL setCurrentValue( const css::uno::Any& aNumber ) override; + virtual css::uno::Any SAL_CALL getMaximumValue( ) override; + virtual css::uno::Any SAL_CALL getMinimumValue( ) override; + virtual css::uno::Any SAL_CALL getMinimumIncrement( ) override; + + // internal + void SetChecked( bool _bChecked ); + }; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/accessibility/AccessibleBrowseBoxHeaderBar.hxx b/vcl/inc/accessibility/AccessibleBrowseBoxHeaderBar.hxx new file mode 100644 index 000000000000..fdd37cbe3173 --- /dev/null +++ b/vcl/inc/accessibility/AccessibleBrowseBoxHeaderBar.hxx @@ -0,0 +1,218 @@ +/* -*- 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 <accessibility/AccessibleBrowseBoxTableBase.hxx> +#include <cppuhelper/implbase1.hxx> +#include <com/sun/star/accessibility/XAccessibleSelection.hpp> + + +namespace accessibility { + + +typedef ::cppu::ImplHelper1< css::accessibility::XAccessibleSelection > + AccessibleBrowseBoxHeaderBarImplHelper; + +/** This class represents the accessible object of a header bar of a BrowseBox + control (row or column header bar). This object supports the + XAccessibleSelection interface. Selecting a child of this object selects + complete rows or columns of the data table. */ +class AccessibleBrowseBoxHeaderBar final : + public AccessibleBrowseBoxTableBase, + public AccessibleBrowseBoxHeaderBarImplHelper +{ +public: + /** @param rxParent Parent that holds the browsebox headerbar control + @param rBrowseBox The BrowseBox control. + @param eObjType One of the two allowed types AccessibleBrowseBoxObjType::RowHeaderBar or + AccessibleBrowseBoxObjType::ColumnHeaderBar. */ + AccessibleBrowseBoxHeaderBar( + const css::uno::Reference< css::accessibility::XAccessible >& rxParent, + ::vcl::IAccessibleTableProvider& rBrowseBox, + AccessibleBrowseBoxObjType eObjType ); + +private: + virtual ~AccessibleBrowseBoxHeaderBar() override; + +public: + // XAccessibleContext + + /** @return + The XAccessible interface of the specified child. + */ + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL + getAccessibleChild( sal_Int64 nChildIndex ) override; + + /** @return The index of this object among the parent's children. */ + virtual sal_Int64 SAL_CALL getAccessibleIndexInParent() override; + + // XAccessibleComponent + + /** @return The accessible child rendered under the given point. */ + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL + getAccessibleAtPoint( const css::awt::Point& rPoint ) override; + + /** Grabs the focus to (the current cell of) the data table. */ + virtual void SAL_CALL grabFocus() override; + + // XAccessibleTable + + /** @return The description text of the specified row. */ + virtual OUString SAL_CALL + getAccessibleRowDescription( sal_Int32 nRow ) override; + + /** @return The description text of the specified column. */ + virtual OUString SAL_CALL getAccessibleColumnDescription( sal_Int32 nColumn ) override; + + /** @return The XAccessibleTable interface of the row header bar. */ + virtual css::uno::Reference< css::accessibility::XAccessibleTable > SAL_CALL + getAccessibleRowHeaders() override; + + /** @return The XAccessibleTable interface of the column header bar. */ + virtual css::uno::Reference< css::accessibility::XAccessibleTable > SAL_CALL + getAccessibleColumnHeaders() override; + + /** @return An index list of completely selected rows. */ + virtual css::uno::Sequence< sal_Int32 > SAL_CALL + getSelectedAccessibleRows() override; + + /** @return An index list of completely selected columns. */ + virtual css::uno::Sequence< sal_Int32 > SAL_CALL + getSelectedAccessibleColumns() override; + + /** @return TRUE, if the specified row is completely selected. */ + virtual sal_Bool SAL_CALL isAccessibleRowSelected( sal_Int32 nRow ) override; + + /** @return TRUE, if the specified column is completely selected. */ + virtual sal_Bool SAL_CALL isAccessibleColumnSelected( sal_Int32 nColumn ) override; + + /** @return The XAccessible interface of the cell object at the specified + cell position. */ + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL + getAccessibleCellAt( sal_Int32 nRow, sal_Int32 nColumn ) override; + + /** @return TRUE, if the specified cell is selected. */ + virtual sal_Bool SAL_CALL isAccessibleSelected( sal_Int32 nRow, sal_Int32 nColumn ) override; + + // XAccessibleSelection + + /** Selects the specified child (row or column of the table). */ + virtual void SAL_CALL selectAccessibleChild( sal_Int64 nChildIndex ) override; + + /** @return TRUE, if the specified child (row/column) is selected. */ + virtual sal_Bool SAL_CALL isAccessibleChildSelected( sal_Int64 nChildIndex ) override; + + /** Clears the complete selection. */ + virtual void SAL_CALL clearAccessibleSelection() override; + + /** Selects all children or first, if multiselection is not supported. */ + virtual void SAL_CALL selectAllAccessibleChildren() override; + + /** @return The number of selected rows/columns. */ + virtual sal_Int64 SAL_CALL getSelectedAccessibleChildCount() override; + + /** @return The specified selected row/column. */ + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL + getSelectedAccessibleChild( sal_Int64 nSelectedChildIndex ) override; + + /** Removes the specified row/column from the selection. */ + virtual void SAL_CALL deselectAccessibleChild( sal_Int64 nSelectedChildIndex ) override; + + // XInterface + + /** Queries for a new interface. */ + css::uno::Any SAL_CALL queryInterface( const css::uno::Type& rType ) override; + + /** Acquires the object (calls acquire() on base class). */ + virtual void SAL_CALL acquire() noexcept override; + + /** Releases the object (calls release() on base class). */ + virtual void SAL_CALL release() noexcept override; + + // XServiceInfo + + /** @return The name of this class. */ + virtual OUString SAL_CALL getImplementationName() override; + + /** @return a unique implementation ID. */ + virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override; + +private: + // internal virtual methods + + /** @attention This method requires locked mutex's and a living object. + @return The bounding box (VCL rect.) relative to the parent window. */ + virtual tools::Rectangle implGetBoundingBox() override; + /** @attention This method requires locked mutex's and a living object. + @return The bounding box (VCL rect.) in screen coordinates. */ + virtual AbsoluteScreenPixelRectangle implGetBoundingBoxOnScreen() override; + + /** @attention This method requires locked mutex's and a living object. + @return The count of used rows. */ + virtual sal_Int32 implGetRowCount() const override; + /** @attention This method requires locked mutex's and a living object. + @return The count of used columns. */ + virtual sal_Int32 implGetColumnCount() const override; + + // internal helper methods + + /** @return TRUE, if the objects is a header bar for rows. */ + inline bool isRowBar() const; + /** @return TRUE, if the objects is a header bar for columns. */ + inline bool isColumnBar() const; + + /** Returns the specified row or column. Uses one of the parameters, + depending on object type. + @attention This method requires locked mutex's and a living object. + @return The XAccessible interface of the specified column/row. */ + css::uno::Reference< css::accessibility::XAccessible > + implGetChild( sal_Int32 nRow, sal_uInt16 nColumnPos ); + + /** @attention This method requires locked mutex's and a living object. + @return The absolute child index from the index of selected children. + @throws <type>IndexOutOfBoundsException</type> + If the specified index is invalid. */ + sal_Int64 implGetChildIndexFromSelectedIndex( sal_Int64 nSelectedChildIndex ); + + /** @attention This method requires locked mutex's and a living object. + @throws <type>IndexOutOfBoundsException</type> + If the specified row/column index (depending on type) is invalid. */ + void ensureIsValidHeaderIndex( sal_Int32 nIndex ); +}; + +// inlines + +inline bool AccessibleBrowseBoxHeaderBar::isRowBar() const +{ + return getType() == AccessibleBrowseBoxObjType::RowHeaderBar; +} + +inline bool AccessibleBrowseBoxHeaderBar::isColumnBar() const +{ + return getType() == AccessibleBrowseBoxObjType::ColumnHeaderBar; +} + + +} // namespace accessibility + + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/accessibility/AccessibleBrowseBoxHeaderCell.hxx b/vcl/inc/accessibility/AccessibleBrowseBoxHeaderCell.hxx new file mode 100644 index 000000000000..be60bee26c5a --- /dev/null +++ b/vcl/inc/accessibility/AccessibleBrowseBoxHeaderCell.hxx @@ -0,0 +1,68 @@ +/* -*- 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 <accessibility/AccessibleBrowseBoxBase.hxx> + +namespace accessibility +{ + class AccessibleBrowseBoxHeaderCell final : public BrowseBoxAccessibleElement + { + sal_Int32 m_nColumnRowId; + public: + AccessibleBrowseBoxHeaderCell(sal_Int32 _nColumnRowId, + const css::uno::Reference< css::accessibility::XAccessible >& rxParent, + ::vcl::IAccessibleTableProvider& _rBrowseBox, + AccessibleBrowseBoxObjType _eObjType); + /** @return The count of visible children. */ + virtual sal_Int64 SAL_CALL getAccessibleChildCount() override; + + /** @return The XAccessible interface of the specified child. */ + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL + getAccessibleChild( sal_Int64 nChildIndex ) override; + + /** @return The index of this object among the parent's children. */ + virtual sal_Int64 SAL_CALL getAccessibleIndexInParent() override; + + /** Grabs the focus to the BrowseBox. */ + virtual void SAL_CALL grabFocus() override; + + bool isRowBarCell() const + { + return getType() == AccessibleBrowseBoxObjType::RowHeaderCell; + } + + /** @return + The name of this class. + */ + virtual OUString SAL_CALL getImplementationName() override; + + /** Return a bitset of states of the current object. + */ + sal_Int64 implCreateStateSet() override; + + private: + virtual tools::Rectangle implGetBoundingBox() override; + + virtual AbsoluteScreenPixelRectangle implGetBoundingBoxOnScreen() override; + }; +} + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/accessibility/AccessibleBrowseBoxTable.hxx b/vcl/inc/accessibility/AccessibleBrowseBoxTable.hxx new file mode 100644 index 000000000000..abff6092fcff --- /dev/null +++ b/vcl/inc/accessibility/AccessibleBrowseBoxTable.hxx @@ -0,0 +1,129 @@ +/* -*- 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 <accessibility/AccessibleBrowseBoxTableBase.hxx> + + +namespace accessibility { + +/** This class represents the accessible object of the data table of a + BrowseBox control. */ +class AccessibleBrowseBoxTable : public AccessibleBrowseBoxTableBase +{ + friend class AccessibleBrowseBox; // to create header bars + +public: + AccessibleBrowseBoxTable( + const css::uno::Reference< css::accessibility::XAccessible >& rxParent, + ::vcl::IAccessibleTableProvider& rBrowseBox ); + +protected: + virtual ~AccessibleBrowseBoxTable() override; + +public: + // XAccessibleContext + + /** @return The XAccessible interface of the specified child. */ + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL + getAccessibleChild( sal_Int64 nChildIndex ) override; + + /** @return The index of this object among the parent's children. */ + virtual sal_Int64 SAL_CALL getAccessibleIndexInParent() override; + + // XAccessibleComponent + + /** @return The accessible child rendered under the given point. */ + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL + getAccessibleAtPoint( const css::awt::Point& rPoint ) override; + + /** Grabs the focus to (the current cell of) the data table. */ + virtual void SAL_CALL grabFocus() override; + + // XAccessibleTable + + /** @return The description text of the specified row. */ + virtual OUString SAL_CALL getAccessibleRowDescription( sal_Int32 nRow ) override; + + /** @return The description text of the specified column. */ + virtual OUString SAL_CALL getAccessibleColumnDescription( sal_Int32 nColumn ) override; + + /** @return The XAccessibleTable interface of the row header bar. */ + virtual css::uno::Reference< css::accessibility::XAccessibleTable > SAL_CALL + getAccessibleRowHeaders() override; + + /** @return The XAccessibleTable interface of the column header bar. */ + virtual css::uno::Reference< css::accessibility::XAccessibleTable > SAL_CALL + getAccessibleColumnHeaders() override; + + /** @return An index list of completely selected rows. */ + virtual css::uno::Sequence< sal_Int32 > SAL_CALL + getSelectedAccessibleRows() override; + + /** @return An index list of completely selected columns. */ + virtual css::uno::Sequence< sal_Int32 > SAL_CALL + getSelectedAccessibleColumns() override; + + /** @return TRUE, if the specified row is completely selected. */ + virtual sal_Bool SAL_CALL isAccessibleRowSelected( sal_Int32 nRow ) override; + + /** @return TRUE, if the specified column is completely selected. */ + virtual sal_Bool SAL_CALL isAccessibleColumnSelected( sal_Int32 nColumn ) override; + + /** @return The XAccessible interface of the cell object at the specified + cell position. */ + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL + getAccessibleCellAt( sal_Int32 nRow, sal_Int32 nColumn ) override; + + /** @return TRUE, if the specified cell is selected. */ + virtual sal_Bool SAL_CALL isAccessibleSelected( sal_Int32 nRow, sal_Int32 nColumn ) override; + + // XServiceInfo + + /** @return The name of this class. */ + virtual OUString SAL_CALL getImplementationName() override; + +protected: + // internal virtual methods + + /** @attention This method requires locked mutex's and a living object. + @return The bounding box (VCL rect.) relative to the parent window. */ + virtual tools::Rectangle implGetBoundingBox() override; + /** @attention This method requires locked mutex's and a living object. + @return The bounding box (VCL rect.) in screen coordinates. */ + virtual AbsoluteScreenPixelRectangle implGetBoundingBoxOnScreen() override; + + // internal helper methods + + /** @attention This method requires a locked mutex. + @return The XAccessibleTable interface of the specified header bar. + @throws css::uno::RuntimeException + */ + css::uno::Reference< css::accessibility::XAccessibleTable > + implGetHeaderBar( sal_Int32 nChildIndex ); +}; + + +} // namespace accessibility + + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/accessibility/AccessibleBrowseBoxTableBase.hxx b/vcl/inc/accessibility/AccessibleBrowseBoxTableBase.hxx new file mode 100644 index 000000000000..ac7f1dd00362 --- /dev/null +++ b/vcl/inc/accessibility/AccessibleBrowseBoxTableBase.hxx @@ -0,0 +1,218 @@ +/* -*- 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 <accessibility/AccessibleBrowseBoxBase.hxx> +#include <cppuhelper/implbase1.hxx> +#include <com/sun/star/accessibility/XAccessibleTable.hpp> + + +namespace accessibility { + +typedef cppu::ImplInheritanceHelper<BrowseBoxAccessibleElement, css::accessibility::XAccessibleTable> + AccessibleBrowseBoxTableImplHelper; + +/** The BrowseBox accessible table objects inherit from this base class. It + implements basic functionality for the XAccessibleTable interface. + BrowseBox table objects are: the data table, the column header bar and the + row header bar. */ +class AccessibleBrowseBoxTableBase : public AccessibleBrowseBoxTableImplHelper +{ +public: + /** Constructor sets specified name and description. If the constant of a + text is BBTEXT_NONE, the derived class has to set the text via + implSetName() and implSetDescription() (in Ctor) or later via + setAccessibleName() and setAccessibleDescription() (these methods + notify the listeners about the change). + @param rxParent XAccessible interface of the parent object. + @param rBrowseBox The BrowseBox control. + @param eObjType Type of BrowseBox object. */ + AccessibleBrowseBoxTableBase( + const css::uno::Reference< css::accessibility::XAccessible >& rxParent, + ::vcl::IAccessibleTableProvider& rBrowseBox, + AccessibleBrowseBoxObjType eObjType ); + +protected: + virtual ~AccessibleBrowseBoxTableBase() override = default; + +public: + // XAccessibleContext + + /** @return The count of visible children. */ + virtual sal_Int64 SAL_CALL getAccessibleChildCount() override; + + /** @return The role of this object (a table). */ + virtual sal_Int16 SAL_CALL getAccessibleRole() override; + + /* Derived classes have to implement: + - getAccessibleChild, + - getAccessibleIndexInParent. */ + + // XAccessibleComponent + + /* Derived classes have to implement: + - getAccessibleAt, + - grabFocus. */ + + // XAccessibleTable + + /** @return The number of used rows in the table (0 = empty table). */ + virtual sal_Int32 SAL_CALL getAccessibleRowCount() override; + + /** @return The number of used columns in the table (0 = empty table). */ + virtual sal_Int32 SAL_CALL getAccessibleColumnCount() override; + + /** @return The row extent of the specified cell (always 1). */ + virtual sal_Int32 SAL_CALL + getAccessibleRowExtentAt( sal_Int32 nRow, sal_Int32 nColumn ) override; + + /** @return The column extent of the specified cell (always 1). */ + virtual sal_Int32 SAL_CALL + getAccessibleColumnExtentAt( sal_Int32 nRow, sal_Int32 nColumn ) override; + + /** @return The caption cell of the table (not supported). */ + virtual css::uno::Reference< + css::accessibility::XAccessible > SAL_CALL + getAccessibleCaption() override; + + /** @return The summary object of the table (not supported). */ + virtual css::uno::Reference< + css::accessibility::XAccessible > SAL_CALL + getAccessibleSummary() override; + + /** @return The child index of the specified cell. */ + virtual sal_Int64 SAL_CALL getAccessibleIndex( sal_Int32 nRow, sal_Int32 nColumn ) override; + + /** @return The row index of the specified child cell. */ + virtual sal_Int32 SAL_CALL getAccessibleRow( sal_Int64 nChildIndex ) override; + + /** @return The column index of the specified child cell. */ + virtual sal_Int32 SAL_CALL getAccessibleColumn( sal_Int64 nChildIndex ) override; + + /* Derived classes have to implement: + - getAccessibleRowDescription, + - getAccessibleColumnDescription, + - getAccessibleRowHeaders, + - getAccessibleColumnHeaders, + - getSelectedAccessibleRows, + - getSelectedAccessibleColumns, + - isAccessibleRowSelected, + - isAccessibleColumnSelected, + - getAccessibleCellAt, + - isAccessibleSelected. */ + + // XServiceInfo + + /* Derived classes have to implement: + - getImplementationName */ + +protected: + // internal virtual methods + + /** @attention This method requires locked mutex's and a living object. + @return The count of data rows without header bar. */ + virtual sal_Int32 implGetRowCount() const; + /** @attention This method requires locked mutex's and a living object. + @return The count of data columns without "handle column". */ + virtual sal_Int32 implGetColumnCount() const; + + // internal helper methods + + /** @return TRUE, if first BrowseBox column is the "handle column". */ + bool implHasHandleColumn() const; + + /** @attention This method requires locked mutex's and a living object. + @param nColumn + the position of the column in the Accessible world + @return + the position of the column in VCL the Accessible world + */ + sal_uInt16 implToVCLColumnPos( sal_Int32 nColumn ) const; + + /** @attention This method requires locked mutex's and a living object. + @return The number of cells of the table. */ + sal_Int64 implGetChildCount() const; + + /** @attention This method requires locked mutex's and a living object. + @return The row index of the specified cell index. */ + sal_Int32 implGetRow( sal_Int64 nChildIndex ) const; + /** @attention This method requires locked mutex's and a living object. + @return The column index of the specified cell index. */ + sal_Int32 implGetColumn( sal_Int64 nChildIndex ) const; + + /** @attention This method requires locked mutex's and a living object. + @return TRUE, if the specified row is selected. */ + bool implIsRowSelected( sal_Int32 nRow ) const; + /** @attention This method requires locked mutex's and a living object. + @return TRUE, if the specified column is selected. */ + bool implIsColumnSelected( sal_Int32 nColumn ) const; + + /** Selects/deselects a row (tries to expand selection). + @attention This method requires locked mutex's and a living object. + @param nRow Row to select + @param bSelect TRUE = select, FALSE = deselect */ + void implSelectRow( sal_Int32 nRow, bool bSelect ); + /** Selects/deselects a column (tries to expand selection). + @attention This method requires locked mutex's and a living object. + @param nColumnPos column number to select + @param bSelect TRUE = select, FALSE = deselect */ + void implSelectColumn( sal_Int32 nColumnPos, bool bSelect ); + + /** @attention This method requires locked mutex's and a living object. + @return The count of selected rows. */ + sal_Int32 implGetSelectedRowCount() const; + /** @attention This method requires locked mutex's and a living object. + @return The count of selected columns. */ + sal_Int32 implGetSelectedColumnCount() const; + + /** Fills a sequence with sorted indexes of completely selected rows. + @attention This method requires locked mutex's and a living object. + @param rSeq Out-parameter that takes the sorted row index list. */ + void implGetSelectedRows( css::uno::Sequence< sal_Int32 >& rSeq ); + /** Fills a sequence with sorted indexes of completely selected columns. + @attention This method requires locked mutex's and a living object. + @param rSeq Out-parameter that takes the sorted column index list. */ + void implGetSelectedColumns( css::uno::Sequence< sal_Int32 >& rSeq ); + + /** @attention This method requires locked mutex's and a living object. + @throws <type>IndexOutOfBoundsException</type> + If the specified row index is invalid. */ + void ensureIsValidRow( sal_Int32 nRow ); + /** @attention This method requires locked mutex's and a living object. + @throws <type>IndexOutOfBoundsException</type> + If the specified column index is invalid. */ + void ensureIsValidColumn( sal_Int32 nColumn ); + /** @attention This method requires locked mutex's and a living object. + @throws <type>IndexOutOfBoundsException</type> + If the specified cell address is invalid. */ + void ensureIsValidAddress( sal_Int32 nRow, sal_Int32 nColumn ); + /** @attention This method requires locked mutex's and a living object. + @throws <type>IndexOutOfBoundsException</type> + If the specified child index is invalid. */ + void ensureIsValidIndex( sal_Int64 nChildIndex ); +}; + + +} // namespace accessibility + + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/accessibility/AccessibleBrowseBoxTableCell.hxx b/vcl/inc/accessibility/AccessibleBrowseBoxTableCell.hxx new file mode 100644 index 000000000000..3a49ad9eeb59 --- /dev/null +++ b/vcl/inc/accessibility/AccessibleBrowseBoxTableCell.hxx @@ -0,0 +1,118 @@ +/* -*- 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 <accessibility/accessiblebrowseboxcell.hxx> +#include <comphelper/accessibletexthelper.hxx> +#include <cppuhelper/implbase2.hxx> +#include <com/sun/star/accessibility/AccessibleScrollType.hpp> + +namespace accessibility +{ + typedef ::cppu::ImplHelper2 < css::accessibility::XAccessibleText + , css::accessibility::XAccessible + > AccessibleTextHelper_BASE; + + // implementation of a table cell of BrowseBox + class AccessibleBrowseBoxTableCell final : public AccessibleBrowseBoxCell + ,public AccessibleTextHelper_BASE + ,public ::comphelper::OCommonAccessibleText + { + private: + sal_Int32 m_nOffset; + + // OCommonAccessibleText + virtual OUString implGetText() final override; + virtual css::lang::Locale implGetLocale() override; + virtual void implGetSelection( sal_Int32& nStartIndex, sal_Int32& nEndIndex ) override; + + public: + AccessibleBrowseBoxTableCell( const css::uno::Reference< css::accessibility::XAccessible >& _rxParent, + ::vcl::IAccessibleTableProvider& _rBrowseBox, + sal_Int32 _nRowId, + sal_uInt16 _nColId, + sal_Int32 _nOffset ); + + // XInterface ------------------------------------------------------------- + + /** Queries for a new interface. */ + css::uno::Any SAL_CALL queryInterface( const css::uno::Type& rType ) override; + + /** Acquires the object (calls acquire() on base class). */ + virtual void SAL_CALL acquire() noexcept override; + + /** Releases the object (calls release() on base class). */ + virtual void SAL_CALL release() noexcept override; + + // XEventListener + using AccessibleBrowseBoxBase::disposing; + virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override; + + /** @return The index of this object among the parent's children. */ + virtual sal_Int64 SAL_CALL getAccessibleIndexInParent() override; + + /** @return + The name of this class. + */ + virtual OUString SAL_CALL getImplementationName() override; + + /** @return + The count of visible children. + */ + virtual sal_Int64 SAL_CALL getAccessibleChildCount() override; + + /** @return + The XAccessible interface of the specified child. + */ + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL + getAccessibleChild( sal_Int64 nChildIndex ) override; + + /** Return a bitset of states of the current object. + */ + sal_Int64 implCreateStateSet() override; + + // XAccessible ------------------------------------------------------------ + + /** @return The XAccessibleContext interface of this object. */ + virtual css::uno::Reference< css::accessibility::XAccessibleContext > SAL_CALL + getAccessibleContext() override; + + // XAccessibleText + virtual sal_Int32 SAL_CALL getCaretPosition() override; + virtual sal_Bool SAL_CALL setCaretPosition( sal_Int32 nIndex ) override; + virtual sal_Unicode SAL_CALL getCharacter( sal_Int32 nIndex ) override; + virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL getCharacterAttributes( sal_Int32 nIndex, const css::uno::Sequence< OUString >& aRequestedAttributes ) override; + virtual css::awt::Rectangle SAL_CALL getCharacterBounds( sal_Int32 nIndex ) override; + virtual sal_Int32 SAL_CALL getCharacterCount() override; + virtual sal_Int32 SAL_CALL getIndexAtPoint( const css::awt::Point& aPoint ) override; + virtual OUString SAL_CALL getSelectedText() override; + virtual sal_Int32 SAL_CALL getSelectionStart() override; + virtual sal_Int32 SAL_CALL getSelectionEnd() override; + virtual sal_Bool SAL_CALL setSelection( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) override; + virtual OUString SAL_CALL getText() final override; + virtual OUString SAL_CALL getTextRange( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) override; + virtual css::accessibility::TextSegment SAL_CALL getTextAtIndex( sal_Int32 nIndex, sal_Int16 aTextType ) override; + virtual css::accessibility::TextSegment SAL_CALL getTextBeforeIndex( sal_Int32 nIndex, sal_Int16 aTextType ) override; + virtual css::accessibility::TextSegment SAL_CALL getTextBehindIndex( sal_Int32 nIndex, sal_Int16 aTextType ) override; + virtual sal_Bool SAL_CALL copyText( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) override; + virtual sal_Bool SAL_CALL scrollSubstringTo( sal_Int32 nStartIndex, sal_Int32 nEndIndex, css::accessibility::AccessibleScrollType aScrollType) override; + }; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/accessibility/AccessibleGridControl.hxx b/vcl/inc/accessibility/AccessibleGridControl.hxx new file mode 100644 index 000000000000..399a6b453bb5 --- /dev/null +++ b/vcl/inc/accessibility/AccessibleGridControl.hxx @@ -0,0 +1,223 @@ +/* -*- 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 <accessibility/AccessibleGridControlBase.hxx> +#include <accessibility/AccessibleGridControlTable.hxx> +#include <cppuhelper/weakref.hxx> +#include <rtl/ref.hxx> +#include <vcl/accessibletable.hxx> + +namespace accessibility { + + class AccessibleGridControlHeader; + + +/** This class represents the complete accessible Grid Control object. */ +class AccessibleGridControl final : public AccessibleGridControlBase +{ + friend class AccessibleGridControlAccess; + + AccessibleGridControl( + const css::uno::Reference< css::accessibility::XAccessible >& _rxParent, + const css::uno::Reference< css::accessibility::XAccessible >& _rxCreator, + ::vcl::table::IAccessibleTable& _rTable + ); + + virtual ~AccessibleGridControl() override = default; + + /** Cleans up members. */ + using AccessibleGridControlBase::disposing; + virtual void SAL_CALL disposing() override; + + // XAccessibleContext ----------------------------------------------------- + + /** @return The count of visible children. */ + virtual sal_Int64 SAL_CALL getAccessibleChildCount() override; + + /** @return The XAccessible interface of the specified child. */ + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL + getAccessibleChild( sal_Int64 nChildIndex ) override; + + /** @return The role of this object (a table). */ + virtual sal_Int16 SAL_CALL getAccessibleRole() override; + + // XAccessibleComponent --------------------------------------------------- + + /** @return + The accessible child rendered under the given point. + */ + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL + getAccessibleAtPoint( const css::awt::Point& rPoint ) override; + + /** Grabs the focus to the Grid Control. */ + virtual void SAL_CALL grabFocus() override; + + // XServiceInfo ----------------------------------------------------------- + + /** @return + The name of this class. + */ + virtual OUString SAL_CALL getImplementationName() override; + +public: + // helper functions + + /** commitCellEvent commit the event at all listeners of the table + @param nEventId + the event id + @param rNewValue + the new value + @param rOldValue + the old value + */ + void commitCellEvent(sal_Int16 nEventId, const css::uno::Any& rNewValue, + const css::uno::Any& rOldValue); + + /** commitTableEvent commit the event at all listeners of the table + @param nEventId + the event id + @param rNewValue + the new value + @param rOldValue + the old value + */ + void commitTableEvent(sal_Int16 nEventId, const css::uno::Any& rNewValue, + const css::uno::Any& rOldValue); + +private: + // internal virtual methods ----------------------------------------------- + + /** @attention This method requires locked mutex's and a living object. + @return The bounding box (VCL rect.) relative to the parent window. */ + virtual tools::Rectangle implGetBoundingBox() override; + /** @attention This method requires locked mutex's and a living object. + @return The bounding box (VCL rect.) in screen coordinates. */ + virtual AbsoluteScreenPixelRectangle implGetBoundingBoxOnScreen() override; + + // internal helper methods ------------------------------------------------ + + /** This method creates (once) and returns the accessible data table child. + @attention This method requires locked mutex's and a living object. + @return The XAccessible interface of the data table. */ + css::uno::Reference< css::accessibility::XAccessible > implGetTable(); + + /** This method creates (once) and returns the specified header bar. + @attention This method requires locked mutex's and a living object. + @return The XAccessible interface of the header bar. */ + css::uno::Reference< css::accessibility::XAccessible > + implGetHeaderBar( ::vcl::table::AccessibleTableControlObjType eObjType ); + + /** This method returns one of the children that are always present: + Data table, row and column header bar or corner control. + @attention This method requires locked mutex's and a living object. + @return The XAccessible interface of the specified child. */ + css::uno::Reference< css::accessibility::XAccessible > + implGetFixedChild( sal_Int64 nChildIndex ); + + /** This method creates and returns an accessible table. + @return An AccessibleGridControlTable. */ + rtl::Reference<AccessibleGridControlTable> createAccessibleTable(); + + /// the css::accessibility::XAccessible which created the AccessibleGridControl + css::uno::WeakReference< css::accessibility::XAccessible > m_aCreator; + + /** The data table child. */ + rtl::Reference<AccessibleGridControlTable> m_xTable; + + /** The header bar for rows. */ + rtl::Reference<AccessibleGridControlHeader> m_xRowHeaderBar; + + /** The header bar for columns (first row of the table). */ + rtl::Reference<AccessibleGridControlHeader> m_xColumnHeaderBar; + + /** @return The count of visible children. */ + inline sal_Int64 implGetAccessibleChildCount(); +}; + + +/** the XAccessible which creates/returns an AccessibleGridControl + + <p>The instance holds its XAccessibleContext with a hard reference, while + the context holds this instance weak.</p> +*/ + +class AccessibleGridControlAccess final : public ::vcl::table::IAccessibleTableControl +{ +private: + css::uno::Reference< css::accessibility::XAccessible > m_xParent; + ::vcl::table::IAccessibleTable * m_pTable; + rtl::Reference<AccessibleGridControl> m_xContext; + +public: + AccessibleGridControlAccess( + css::uno::Reference< css::accessibility::XAccessible > _xParent, + ::vcl::table::IAccessibleTable& _rTable + ); + + /// returns the AccessibleContext belonging to this Accessible + AccessibleGridControl* getContext() { return m_xContext.get(); } + +private: + virtual ~AccessibleGridControlAccess() override; + + // XAccessible + virtual css::uno::Reference< css::accessibility::XAccessibleContext > + SAL_CALL getAccessibleContext() override; + + // IAccessibleTable + void DisposeAccessImpl() override; + virtual bool isAlive() const override + { + return m_xContext.is() && m_xContext->isAlive(); + } + virtual void commitCellEvent( sal_Int16 nEventId, + const css::uno::Any& rNewValue, const css::uno::Any& rOldValue ) override + { + AccessibleGridControl* pContext( getContext() ); + if ( pContext ) + pContext->commitCellEvent( nEventId, rNewValue, rOldValue ); + } + virtual void commitTableEvent( sal_Int16 nEventId, + const css::uno::Any& rNewValue, const css::uno::Any& rOldValue ) override + { + AccessibleGridControl* pContext( getContext() ); + if ( pContext ) + pContext->commitTableEvent( nEventId, rNewValue, rOldValue ); + } + virtual void commitEvent( sal_Int16 nEventId, + const css::uno::Any& rNewValue ) override + { + AccessibleGridControl* pContext( getContext() ); + if ( pContext ) + pContext->commitEvent( nEventId, rNewValue, css::uno::Any() ); + } + +private: + AccessibleGridControlAccess( const AccessibleGridControlAccess& ) = delete; + AccessibleGridControlAccess& operator=( const AccessibleGridControlAccess& ) = delete; +}; + + +} // namespace accessibility + + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/accessibility/AccessibleGridControlBase.hxx b/vcl/inc/accessibility/AccessibleGridControlBase.hxx new file mode 100644 index 000000000000..4e30bddda541 --- /dev/null +++ b/vcl/inc/accessibility/AccessibleGridControlBase.hxx @@ -0,0 +1,299 @@ +/* -*- 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/accessibletable.hxx> +#include <rtl/ustring.hxx> +#include <rtl/ref.hxx> +#include <tools/gen.hxx> +#include <cppuhelper/compbase.hxx> +#include <cppuhelper/implbase1.hxx> +#include <cppuhelper/basemutex.hxx> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/accessibility/XAccessible.hpp> +#include <com/sun/star/accessibility/XAccessibleContext.hpp> +#include <com/sun/star/accessibility/XAccessibleComponent.hpp> +#include <com/sun/star/accessibility/XAccessibleEventBroadcaster.hpp> +#include <comphelper/accessibleeventnotifier.hxx> +#include <comphelper/uno3.hxx> + + +namespace vcl { class Window; } + + +namespace accessibility { + +typedef ::cppu::WeakComponentImplHelper< + css::accessibility::XAccessibleContext, + css::accessibility::XAccessibleComponent, + css::accessibility::XAccessibleEventBroadcaster, + css::lang::XServiceInfo > + AccessibleGridControlImplHelper; + +/** The GridControl accessible objects inherit from this base class. It + implements basic functionality for various Accessibility interfaces and + the event broadcaster and contains the osl::Mutex. */ +class AccessibleGridControlBase : + public ::cppu::BaseMutex, + public AccessibleGridControlImplHelper +{ +public: + /** Constructor. + @param rxParent XAccessible interface of the parent object. + @param rTable The Table control. + @param eObjType Type of accessible table control. */ + AccessibleGridControlBase( + css::uno::Reference< css::accessibility::XAccessible > xParent, + ::vcl::table::IAccessibleTable& rTable, + ::vcl::table::AccessibleTableControlObjType eObjType ); + +protected: + virtual ~AccessibleGridControlBase() override; + + /** Commits DeFunc event to listeners and cleans up members. */ + virtual void SAL_CALL disposing() override; + +public: + // XAccessibleContext + + /** @return A reference to the parent accessible object. */ + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL + getAccessibleParent() override; + + /** @return The index of this object among the parent's children. */ + virtual sal_Int64 SAL_CALL getAccessibleIndexInParent() override; + + /** @return + The description of this object. + */ + virtual OUString SAL_CALL getAccessibleDescription() override; + + /** @return + The name of this object. + */ + virtual OUString SAL_CALL getAccessibleName() override; + + /** @return + The relation set (the GridControl does not have one). + */ + virtual css::uno::Reference< css::accessibility::XAccessibleRelationSet > SAL_CALL + getAccessibleRelationSet() override; + + /** @return The set of current states. */ + virtual sal_Int64 SAL_CALL getAccessibleStateSet() override; + + /** @return The parent's locale. */ + virtual css::lang::Locale SAL_CALL getLocale() override; + + /** @return + The role of this object. Panel, ROWHEADER, COLUMNHEADER, TABLE, TABLE_CELL are supported. + */ + virtual sal_Int16 SAL_CALL getAccessibleRole() override; + + /* Derived classes have to implement: + - getAccessibleChildCount, + - getAccessibleChild, + - getAccessibleRole. + Derived classes may overwrite getAccessibleIndexInParent to increase + performance. */ + + // XAccessibleComponent + + /** @return + TRUE, if the point lies within the bounding box of this object. */ + virtual sal_Bool SAL_CALL containsPoint( const css::awt::Point& rPoint ) override; + + /** @return The bounding box of this object. */ + virtual css::awt::Rectangle SAL_CALL getBounds() override; + + /** @return + The upper left corner of the bounding box relative to the parent. */ + virtual css::awt::Point SAL_CALL getLocation() override; + + /** @return + The upper left corner of the bounding box in screen coordinates. */ + virtual css::awt::Point SAL_CALL getLocationOnScreen() override; + + /** @return The size of the bounding box. */ + virtual css::awt::Size SAL_CALL getSize() override; + + virtual sal_Int32 SAL_CALL getForeground( ) override; + virtual sal_Int32 SAL_CALL getBackground( ) override; + + + /* Derived classes have to implement: + - getAccessibleAt, + - grabFocus. */ + + /** @return + The accessible child rendered under the given point. + */ + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL + getAccessibleAtPoint( const css::awt::Point& rPoint ) override; + + // XAccessibleEventBroadcaster + + /** Adds a new event listener */ + virtual void SAL_CALL addAccessibleEventListener( + const css::uno::Reference< css::accessibility::XAccessibleEventListener>& rxListener ) override; + + /** Removes an event listener. */ + virtual void SAL_CALL removeAccessibleEventListener( + const css::uno::Reference< css::accessibility::XAccessibleEventListener>& rxListener ) override; + + // XTypeProvider + + /** @return a unique implementation ID. */ + virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override; + + // XServiceInfo + + /** @return Whether the specified service is supported by this class. */ + virtual sal_Bool SAL_CALL supportsService( const OUString& rServiceName ) override; + + /** @return a list of all supported services. */ + virtual css::uno::Sequence< OUString > SAL_CALL + getSupportedServiceNames() override; + + /* Derived classes have to implement: + - getImplementationName. */ + + // helper methods + + /** @return The GridControl object type. */ + inline ::vcl::table::AccessibleTableControlObjType getType() const; + + /** Commits an event to all listeners. */ + virtual void commitEvent(sal_Int16 nEventId, const css::uno::Any& rNewValue, + const css::uno::Any& rOldValue); + /** @return TRUE, if the object is not disposed or disposing. */ + bool isAlive() const; + +protected: + // internal virtual methods + + /** Determines whether the Grid control is really showing inside of + its parent accessible window. Derived classes may implement different + behaviour. + @attention This method requires locked mutex's and a living object. + @return TRUE, if the object is really showing. */ + bool implIsShowing(); + + /** Derived classes return the bounding box relative to the parent window. + @attention This method requires locked mutex's and a living object. + @return The bounding box (VCL rect.) relative to the parent window. */ + virtual tools::Rectangle implGetBoundingBox() = 0; + ///** Derived classes return the bounding box in screen coordinates. + // @attention This method requires locked mutex's and a living object. + // @return The bounding box (VCL rect.) in screen coordinates. */ + virtual AbsoluteScreenPixelRectangle implGetBoundingBoxOnScreen() = 0; + + /** Creates a bitset of states of the + current object. This method calls FillStateSet at the GridControl which + fills it with more states depending on the object type. Derived classes + may overwrite this method and add more states. + @attention This method requires locked mutex's. + */ + virtual sal_Int64 implCreateStateSet(); + + // internal helper methods + + /** @throws <type>DisposedException</type> If the object is not alive. */ + void ensureIsAlive() const; + + /** Locks all mutex's and calculates the bounding box relative to the + parent window. + @return The bounding box (VCL rect.) relative to the parent object. + @throws css::lang::DisposedException + */ + tools::Rectangle getBoundingBox(); + ///** Locks all mutex's and calculates the bounding box in screen + // coordinates. + // @return The bounding box (VCL rect.) in screen coordinates. */ + /// @throws css::lang::DisposedException + AbsoluteScreenPixelRectangle getBoundingBoxOnScreen(); + + ::comphelper::AccessibleEventNotifier::TClientId getClientId() const { return m_aClientId; } + void setClientId(::comphelper::AccessibleEventNotifier::TClientId _aNewClientId) { m_aClientId = _aNewClientId; } + +protected: + // members + + /** The parent accessible object. */ + css::uno::Reference< css::accessibility::XAccessible > m_xParent; + /** The SVT Table control. */ + ::vcl::table::IAccessibleTable& m_aTable; + /** The type of this object (for names, descriptions, state sets, ...). */ + ::vcl::table::AccessibleTableControlObjType m_eObjType; + +private: + ::comphelper::AccessibleEventNotifier::TClientId m_aClientId; +}; + + +// a version of AccessibleGridControlBase which implements not only the XAccessibleContext, +// but also the XAccessible + +typedef cppu::ImplInheritanceHelper <AccessibleGridControlBase, css::accessibility::XAccessible> + GridControlAccessibleElement_Base; + +class GridControlAccessibleElement : public GridControlAccessibleElement_Base +{ +protected: + /** Constructor sets specified name and description. + + @param rxParent XAccessible interface of the parent object. + @param rTable The Table control. + @param eObjType Type of table control + */ + GridControlAccessibleElement( + const css::uno::Reference< css::accessibility::XAccessible >& rxParent, + ::vcl::table::IAccessibleTable& rTable, + ::vcl::table::AccessibleTableControlObjType eObjType ); + +protected: + virtual ~GridControlAccessibleElement() override; + +protected: + // XAccessible + + /** @return The XAccessibleContext interface of this object. */ + virtual css::uno::Reference< css::accessibility::XAccessibleContext > SAL_CALL + getAccessibleContext() override; + +private: + GridControlAccessibleElement( const GridControlAccessibleElement& ) = delete; + GridControlAccessibleElement& operator=( const GridControlAccessibleElement& ) = delete; +}; + +// inlines + +inline ::vcl::table::AccessibleTableControlObjType AccessibleGridControlBase::getType() const +{ + return m_eObjType; +} + + +} // namespace accessibility + + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/accessibility/AccessibleGridControlHeader.hxx b/vcl/inc/accessibility/AccessibleGridControlHeader.hxx new file mode 100644 index 000000000000..d1cabbeb4aeb --- /dev/null +++ b/vcl/inc/accessibility/AccessibleGridControlHeader.hxx @@ -0,0 +1,155 @@ +/* -*- 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 <accessibility/AccessibleGridControlTableBase.hxx> + +namespace accessibility { + +/** This class represents the accessible object of a header bar of a Grid Control + (row or column header bar). This object supports the + XAccessibleSelection interface. Selecting a child of this object selects + complete rows or columns of the data table. */ +class AccessibleGridControlHeader final : public AccessibleGridControlTableBase +{ +public: + /** @param rxParent accessible parent control + @param rTable accessible table + @param eObjType One of the two allowed types AccessibleTableControlObjType::ROWHEADERBAR or + AccessibleTableControlObjType::COLUMNHEADERBAR. */ + AccessibleGridControlHeader( + const css::uno::Reference< + css::accessibility::XAccessible >& rxParent, + ::vcl::table::IAccessibleTable& rTable, + ::vcl::table::AccessibleTableControlObjType eObjType ); + +private: + virtual ~AccessibleGridControlHeader() override = default; + +public: + // XAccessibleContext + + /** @return + The XAccessible interface of the specified child. + */ + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL + getAccessibleChild( sal_Int64 nChildIndex ) override; + + /** @return The index of this object among the parent's children. */ + virtual sal_Int64 SAL_CALL getAccessibleIndexInParent() override; + + // XAccessibleComponent + + /** @return The accessible child rendered under the given point. */ + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL + getAccessibleAtPoint( const css::awt::Point& rPoint ) override; + + /** Grabs the focus to (the current cell of) the data table. */ + virtual void SAL_CALL grabFocus() override; + + // XAccessibleTable + + /** @return The description text of the specified row. */ + virtual OUString SAL_CALL + getAccessibleRowDescription( sal_Int32 nRow ) override; + + /** @return The description text of the specified column. */ + virtual OUString SAL_CALL + getAccessibleColumnDescription( sal_Int32 nColumn ) override; + + /** @return The XAccessibleTable interface of the row header bar. */ + virtual css::uno::Reference< css::accessibility::XAccessibleTable > SAL_CALL + getAccessibleRowHeaders() override; + + /** @return The XAccessibleTable interface of the column header bar. */ + virtual css::uno::Reference< css::accessibility::XAccessibleTable > SAL_CALL + getAccessibleColumnHeaders() override; + + /** @return An index list of completely selected rows. */ + virtual css::uno::Sequence< sal_Int32 > SAL_CALL + getSelectedAccessibleRows() override; + + /** @return An index list of completely selected columns. */ + virtual css::uno::Sequence< sal_Int32 > SAL_CALL + getSelectedAccessibleColumns() override; + + /** @return TRUE, if the specified row is completely selected. */ + virtual sal_Bool SAL_CALL isAccessibleRowSelected( sal_Int32 nRow ) override; + + /** @return TRUE, if the specified column is completely selected. */ + virtual sal_Bool SAL_CALL isAccessibleColumnSelected( sal_Int32 nColumn ) override; + + /** @return The XAccessible interface of the cell object at the specified + cell position. */ + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL + getAccessibleCellAt( sal_Int32 nRow, sal_Int32 nColumn ) override; + + /** @return TRUE, if the specified cell is selected. */ + virtual sal_Bool SAL_CALL isAccessibleSelected( sal_Int32 nRow, sal_Int32 nColumn ) override; + + // XServiceInfo + + /** @return The name of this class. */ + virtual OUString SAL_CALL getImplementationName() override; + + /** @return a unique implementation ID. */ + virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override; + +private: + /** Returns the specified row or column. Uses one of the parameters, + depending on object type. + @attention This method requires locked mutex's and a living object. + @return The XAccessible interface of the specified column/row. */ + css::uno::Reference< css::accessibility::XAccessible > + implGetChild( sal_Int32 nRow, sal_uInt32 nColumnPos ); + /** @attention This method requires locked mutex's and a living object. + @return The bounding box (VCL rect.) relative to the parent window. */ + virtual tools::Rectangle implGetBoundingBox() override; + /** @attention This method requires locked mutex's and a living object. + @return The bounding box (VCL rect.) in screen coordinates. */ + virtual AbsoluteScreenPixelRectangle implGetBoundingBoxOnScreen() override; + + // internal helper methods + + /** @return TRUE, if the objects is a header bar for rows. */ + inline bool isRowBar() const; + /** @return TRUE, if the objects is a header bar for columns. */ + inline bool isColumnBar() const; +}; + +// inlines + +inline bool AccessibleGridControlHeader::isRowBar() const +{ + return getType() == ::vcl::table::AccessibleTableControlObjType::ROWHEADERBAR; +} + +inline bool AccessibleGridControlHeader::isColumnBar() const +{ + return getType() == ::vcl::table::AccessibleTableControlObjType::COLUMNHEADERBAR; +} + + +} // namespace accessibility + + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/accessibility/AccessibleGridControlHeaderCell.hxx b/vcl/inc/accessibility/AccessibleGridControlHeaderCell.hxx new file mode 100644 index 000000000000..cd59894b92bb --- /dev/null +++ b/vcl/inc/accessibility/AccessibleGridControlHeaderCell.hxx @@ -0,0 +1,79 @@ +/* -*- 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 <accessibility/AccessibleGridControlTableCell.hxx> + +namespace accessibility +{ + class AccessibleGridControlHeaderCell final : public AccessibleGridControlCell, public css::accessibility::XAccessible + { + sal_Int32 m_nColumnRowId; + public: + AccessibleGridControlHeaderCell(sal_Int32 _nColumnRowId, + const css::uno::Reference< css::accessibility::XAccessible >& rxParent, + ::vcl::table::IAccessibleTable& _rTable, + ::vcl::table::AccessibleTableControlObjType _eObjType); + /** @return The count of visible children. */ + virtual sal_Int64 SAL_CALL getAccessibleChildCount() override; + + /** @return The XAccessible interface of the specified child. */ + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL + getAccessibleChild( sal_Int64 nChildIndex ) override; + + /** @return The index of this object among the parent's children. */ + virtual sal_Int64 SAL_CALL getAccessibleIndexInParent() override; + + /** Grabs the focus to the GridControl. */ + virtual void SAL_CALL grabFocus() override; + + // XInterface + + /** Queries for a new interface. */ + css::uno::Any SAL_CALL queryInterface( const css::uno::Type& rType ) override; + + /** Acquires the object (calls acquire() on base class). */ + virtual void SAL_CALL acquire() noexcept override; + + /** Releases the object (calls release() on base class). */ + virtual void SAL_CALL release() noexcept override; + // XAccessible + + /** @return The XAccessibleContext interface of this object. */ + virtual css::uno::Reference< css::accessibility::XAccessibleContext > SAL_CALL + getAccessibleContext() override; + + /** @return + The name of this class. + */ + virtual OUString SAL_CALL getImplementationName() override; + + /** Return a bitset of states of the current object. + */ + sal_Int64 implCreateStateSet() override; + + private: + virtual tools::Rectangle implGetBoundingBox() override; + + virtual AbsoluteScreenPixelRectangle implGetBoundingBoxOnScreen() override; + }; +} + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/accessibility/AccessibleGridControlTable.hxx b/vcl/inc/accessibility/AccessibleGridControlTable.hxx new file mode 100644 index 000000000000..5c043f8860a9 --- /dev/null +++ b/vcl/inc/accessibility/AccessibleGridControlTable.hxx @@ -0,0 +1,172 @@ +/* -*- 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 <accessibility/AccessibleGridControlTableBase.hxx> +#include <cppuhelper/implbase1.hxx> +#include <com/sun/star/accessibility/XAccessibleSelection.hpp> +#include <accessibility/AccessibleGridControlTableCell.hxx> + + +namespace accessibility { + + +typedef ::cppu::ImplHelper1 < css::accessibility::XAccessibleSelection > + AccessibleGridControlTableSelectionImplHelper; +/** This class represents the accessible object of the data table of a + Grid control. */ +class AccessibleGridControlTable final : public AccessibleGridControlTableBase, + public AccessibleGridControlTableSelectionImplHelper +{ +public: + AccessibleGridControlTable( + const css::uno::Reference< css::accessibility::XAccessible >& rxParent, + ::vcl::table::IAccessibleTable& rTable); + +private: + virtual ~AccessibleGridControlTable() override = default; + std::vector< rtl::Reference<AccessibleGridControlTableCell> > m_aCellVector; +public: + // XAccessibleContext + + /** @return The XAccessible interface of the specified child. */ + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL + getAccessibleChild( sal_Int64 nChildIndex ) override; + + /** @return The index of this object among the parent's children. */ + virtual sal_Int64 SAL_CALL getAccessibleIndexInParent() override; + + // XAccessibleComponent + + /** @return The accessible child rendered under the given point. */ + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL + getAccessibleAtPoint( const css::awt::Point& rPoint ) override; + + /** Grabs the focus to (the current cell of) the data table. */ + virtual void SAL_CALL grabFocus() override; + + // XAccessibleTable + + /** @return The description text of the specified row. */ + virtual OUString SAL_CALL getAccessibleRowDescription( sal_Int32 nRow ) override; + + /** @return The description text of the specified column. */ + virtual OUString SAL_CALL getAccessibleColumnDescription( sal_Int32 nColumn ) override; + + /** @return The XAccessibleTable interface of the row header bar. */ + virtual css::uno::Reference< css::accessibility::XAccessibleTable > SAL_CALL + getAccessibleRowHeaders() override; + + /** @return The XAccessibleTable interface of the column header bar. */ + virtual css::uno::Reference< css::accessibility::XAccessibleTable > SAL_CALL + getAccessibleColumnHeaders() override; + + /** @return An index list of completely selected rows. */ + virtual css::uno::Sequence< sal_Int32 > SAL_CALL + getSelectedAccessibleRows() override; + + /** @return An index list of completely selected columns. */ + virtual css::uno::Sequence< sal_Int32 > SAL_CALL + getSelectedAccessibleColumns() override; + + /** @return TRUE, if the specified row is completely selected. */ + virtual sal_Bool SAL_CALL isAccessibleRowSelected( sal_Int32 nRow ) override; + + /** @return TRUE, if the specified column is completely selected. */ + virtual sal_Bool SAL_CALL isAccessibleColumnSelected( sal_Int32 nColumn ) override; + + /** @return The XAccessible interface of the cell object at the specified + cell position. */ + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL + getAccessibleCellAt( sal_Int32 nRow, sal_Int32 nColumn ) override; + + /** @return TRUE, if the specified cell is selected. */ + virtual sal_Bool SAL_CALL isAccessibleSelected( sal_Int32 nRow, sal_Int32 nColumn ) override; + + // XAccessibleSelection + + /** Selects the specified child (row or column of the table). */ + virtual void SAL_CALL selectAccessibleChild( sal_Int64 nChildIndex ) override; + + /** @return TRUE, if the specified child (row/column) is selected. */ + virtual sal_Bool SAL_CALL isAccessibleChildSelected( sal_Int64 nChildIndex ) override; + + /** Clears the complete selection. */ + virtual void SAL_CALL clearAccessibleSelection() override; + + /** Selects all children or first, if multiselection is not supported. */ + virtual void SAL_CALL selectAllAccessibleChildren() override; + + /** @return The number of selected rows/columns. */ + virtual sal_Int64 SAL_CALL getSelectedAccessibleChildCount() override; + + /** @return The specified selected row/column. */ + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL + getSelectedAccessibleChild( sal_Int64 nSelectedChildIndex ) override; + + /** Removes the specified row/column from the selection. */ + virtual void SAL_CALL deselectAccessibleChild( sal_Int64 nSelectedChildIndex ) override; + // XInterface + + /** Queries for a new interface. */ + css::uno::Any SAL_CALL queryInterface( const css::uno::Type& rType ) override; + + /** Acquires the object (calls acquire() on base class). */ + virtual void SAL_CALL acquire() noexcept override; + + /** Releases the object (calls release() on base class). */ + virtual void SAL_CALL release() noexcept override; + // XServiceInfo + + /** @return The name of this class. */ + virtual OUString SAL_CALL getImplementationName() override; + + // XComponent + virtual void SAL_CALL dispose() override; + + virtual void commitEvent(sal_Int16 nEventId, const css::uno::Any& rNewValue, + const css::uno::Any& rOldValue) override; + +private: + // internal virtual methods + + /** @attention This method requires locked mutex's and a living object. + @return The bounding box (VCL rect.) relative to the parent window. */ + virtual tools::Rectangle implGetBoundingBox() override; + ///** @attention This method requires locked mutex's and a living object. + // @return The bounding box (VCL rect.) in screen coordinates. */ + virtual AbsoluteScreenPixelRectangle implGetBoundingBoxOnScreen() override; + + + //// internal helper methods + ///** @attention This method requires a locked mutex. + // @return The XAccessibleTable interface of the specified header bar. */ + /// @throws css::uno::RuntimeException + css::uno::Reference< css::accessibility::XAccessibleTable > + implGetHeaderBar( sal_Int32 nChildIndex ); +}; + + +} // namespace accessibility + + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/accessibility/AccessibleGridControlTableBase.hxx b/vcl/inc/accessibility/AccessibleGridControlTableBase.hxx new file mode 100644 index 000000000000..53ca49307e6b --- /dev/null +++ b/vcl/inc/accessibility/AccessibleGridControlTableBase.hxx @@ -0,0 +1,155 @@ +/* -*- 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 <accessibility/AccessibleGridControlBase.hxx> +#include <cppuhelper/implbase1.hxx> +#include <com/sun/star/accessibility/XAccessibleTable.hpp> + + +namespace accessibility { + +typedef cppu::ImplInheritanceHelper<GridControlAccessibleElement, css::accessibility::XAccessibleTable> + AccessibleGridControlTableImplHelper; + +/** The Grid Control accessible table objects inherit from this base class. It + implements basic functionality for the XAccessibleTable interface. + Grid COntrol table objects are: the data table, the column header bar and the + row header bar. */ +class AccessibleGridControlTableBase : + public AccessibleGridControlTableImplHelper +{ +public: + /** Constructor sets specified name and description. + @param rxParent XAccessible interface of the parent object. + @param rTable The Table control. + @param eObjType Type of table control object */ + AccessibleGridControlTableBase( + const css::uno::Reference< css::accessibility::XAccessible >& rxParent, + ::vcl::table::IAccessibleTable& rTable, + ::vcl::table::AccessibleTableControlObjType eObjType ); + +protected: + virtual ~AccessibleGridControlTableBase() override = default; + +public: + // XAccessibleContext + + /** @return The count of visible children. */ + virtual sal_Int64 SAL_CALL getAccessibleChildCount() override; + + /** @return The role of this object (a table). */ + virtual sal_Int16 SAL_CALL getAccessibleRole() override; + + /* Derived classes have to implement: + - getAccessibleChild, + - getAccessibleIndexInParent. */ + + // XAccessibleComponent + + /* Derived classes have to implement: + - getAccessibleAt, + - grabFocus. */ + + // XAccessibleTable + + /** @return The number of used rows in the table (0 = empty table). */ + virtual sal_Int32 SAL_CALL getAccessibleRowCount() override; + + /** @return The number of used columns in the table (0 = empty table). */ + virtual sal_Int32 SAL_CALL getAccessibleColumnCount() override; + + /** @return The row extent of the specified cell (always 1). */ + virtual sal_Int32 SAL_CALL + getAccessibleRowExtentAt( sal_Int32 nRow, sal_Int32 nColumn ) override; + + /** @return The column extent of the specified cell (always 1). */ + virtual sal_Int32 SAL_CALL + getAccessibleColumnExtentAt( sal_Int32 nRow, sal_Int32 nColumn ) override; + + /** @return The caption cell of the table (not supported). */ + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL + getAccessibleCaption() override; + + /** @return The summary object of the table (not supported). */ + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL + getAccessibleSummary() override; + + /** @return The child index of the specified cell. */ + virtual sal_Int64 SAL_CALL getAccessibleIndex( sal_Int32 nRow, sal_Int32 nColumn ) override; + + /** @return The row index of the specified child cell. */ + virtual sal_Int32 SAL_CALL getAccessibleRow( sal_Int64 nChildIndex ) override; + + /** @return The column index of the specified child cell. */ + virtual sal_Int32 SAL_CALL getAccessibleColumn( sal_Int64 nChildIndex ) override; + + /* Derived classes have to implement: + - getAccessibleRowDescription, + - getAccessibleColumnDescription, + - getAccessibleRowHeaders, + - getAccessibleColumnHeaders, + - getSelectedAccessibleRows, + - getSelectedAccessibleColumns, + - isAccessibleRowSelected, + - isAccessibleColumnSelected, + - getAccessibleCellAt, + - isAccessibleSelected. */ + +protected: + // internal helper methods + + /** @attention This method requires locked mutex's and a living object. + @return The row index of the specified cell index. */ + sal_Int32 implGetRow( sal_Int64 nChildIndex ); + /** @attention This method requires locked mutex's and a living object. + @return The column index of the specified cell index. */ + sal_Int32 implGetColumn( sal_Int64 nChildIndex ); + + /** Fills a sequence with sorted indexes of completely selected rows. + @attention This method requires locked mutex's and a living object. + @param rSeq Out-parameter that takes the sorted row index list. */ + void implGetSelectedRows( css::uno::Sequence< sal_Int32 >& rSeq ); + + /** @attention This method requires locked mutex's and a living object. + @throws <type>IndexOutOfBoundsException</type> + If the specified row index is invalid. */ + void ensureIsValidRow( sal_Int32 nRow ); + /** @attention This method requires locked mutex's and a living object. + @throws <type>IndexOutOfBoundsException</type> + If the specified column index is invalid. */ + void ensureIsValidColumn( sal_Int32 nColumn ); + /** @attention This method requires locked mutex's and a living object. + @throws <type>IndexOutOfBoundsException</type> + If the specified cell address is invalid. */ + void ensureIsValidAddress( sal_Int32 nRow, sal_Int32 nColumn ); + /** @attention This method requires locked mutex's and a living object. + @throws <type>IndexOutOfBoundsException</type> + If the specified child index is invalid. */ + void ensureIsValidIndex( sal_Int64 nChildIndex ); +}; + + +} // namespace accessibility + + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/accessibility/AccessibleGridControlTableCell.hxx b/vcl/inc/accessibility/AccessibleGridControlTableCell.hxx new file mode 100644 index 000000000000..7d9053932a36 --- /dev/null +++ b/vcl/inc/accessibility/AccessibleGridControlTableCell.hxx @@ -0,0 +1,147 @@ +/* -*- 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 <comphelper/accessibletexthelper.hxx> +#include <cppuhelper/implbase2.hxx> +#include <accessibility/AccessibleGridControlBase.hxx> +#include <vcl/accessibletable.hxx> +#include <com/sun/star/accessibility/AccessibleScrollType.hpp> + +namespace accessibility +{ + class AccessibleGridControlCell : public AccessibleGridControlBase + { + private: + sal_Int32 m_nRowPos; // the row number of the table cell + sal_Int32 m_nColPos; // the column id of the table cell + + protected: + // attribute access + sal_Int32 getRowPos( ) const { return m_nRowPos; } + sal_Int32 getColumnPos( ) const { return m_nColPos; } + + // XAccessibleComponent + virtual void SAL_CALL grabFocus() override; + + public: + // XAccessibleContext + virtual OUString SAL_CALL getAccessibleName() override; + + protected: + AccessibleGridControlCell( + const css::uno::Reference< css::accessibility::XAccessible >& _rxParent, + ::vcl::table::IAccessibleTable& _rTable, + sal_Int32 _nRowPos, + sal_uInt16 _nColPos, + ::vcl::table::AccessibleTableControlObjType _eType + ); + + virtual ~AccessibleGridControlCell() override = default; + + private: + AccessibleGridControlCell( const AccessibleGridControlCell& ) = delete; + AccessibleGridControlCell& operator=( const AccessibleGridControlCell& ) = delete; + }; + + typedef ::cppu::ImplHelper2 < css::accessibility::XAccessibleText + , css::accessibility::XAccessible + > AccessibleTextHelper_BASE; + // implementation of a table cell of GridControl + class AccessibleGridControlTableCell final :public AccessibleGridControlCell + ,public AccessibleTextHelper_BASE + ,public ::comphelper::OCommonAccessibleText + { + private: + // OCommonAccessibleText + virtual OUString implGetText() override; + virtual css::lang::Locale implGetLocale() override; + virtual void implGetSelection( sal_Int32& nStartIndex, sal_Int32& nEndIndex ) override final; + virtual tools::Rectangle implGetBoundingBox() override; + virtual AbsoluteScreenPixelRectangle implGetBoundingBoxOnScreen() override; + + public: + AccessibleGridControlTableCell( const css::uno::Reference< css::accessibility::XAccessible >& _rxParent, + ::vcl::table::IAccessibleTable& _rTable, + sal_Int32 _nRowId, + sal_uInt16 _nColId); + + // XInterface ------------------------------------------------------------- + + /** Queries for a new interface. */ + css::uno::Any SAL_CALL queryInterface( const css::uno::Type& rType ) override; + + /** Acquires the object (calls acquire() on base class). */ + virtual void SAL_CALL acquire() noexcept override; + + /** Releases the object (calls release() on base class). */ + virtual void SAL_CALL release() noexcept override; + + /** @return The index of this object among the parent's children. */ + virtual sal_Int64 SAL_CALL getAccessibleIndexInParent() override; + + /** @return + The name of this class. + */ + virtual OUString SAL_CALL getImplementationName() override; + + /** @return + The count of visible children. + */ + virtual sal_Int64 SAL_CALL getAccessibleChildCount() override; + + /** @return + The XAccessible interface of the specified child. + */ + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL + getAccessibleChild( sal_Int64 nChildIndex ) override; + + /** Return a bitset of states of the current object. + */ + sal_Int64 implCreateStateSet() override; + + // XAccessible ------------------------------------------------------------ + + /** @return The XAccessibleContext interface of this object. */ + virtual css::uno::Reference< css::accessibility::XAccessibleContext > SAL_CALL + getAccessibleContext() override; + + // XAccessibleText + virtual sal_Int32 SAL_CALL getCaretPosition() override; + virtual sal_Bool SAL_CALL setCaretPosition( sal_Int32 nIndex ) override; + virtual sal_Unicode SAL_CALL getCharacter( sal_Int32 nIndex ) override; + virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL getCharacterAttributes( sal_Int32 nIndex, const css::uno::Sequence< OUString >& aRequestedAttributes ) override; + virtual css::awt::Rectangle SAL_CALL getCharacterBounds( sal_Int32 nIndex ) override; + virtual sal_Int32 SAL_CALL getCharacterCount() override; + virtual sal_Int32 SAL_CALL getIndexAtPoint( const css::awt::Point& aPoint ) override; + virtual OUString SAL_CALL getSelectedText() override; + virtual sal_Int32 SAL_CALL getSelectionStart() override; + virtual sal_Int32 SAL_CALL getSelectionEnd() override; + virtual sal_Bool SAL_CALL setSelection( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) override; + virtual OUString SAL_CALL getText() override; + virtual OUString SAL_CALL getTextRange( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) override; + virtual css::accessibility::TextSegment SAL_CALL getTextAtIndex( sal_Int32 nIndex, sal_Int16 aTextType ) override; + virtual css::accessibility::TextSegment SAL_CALL getTextBeforeIndex( sal_Int32 nIndex, sal_Int16 aTextType ) override; + virtual css::accessibility::TextSegment SAL_CALL getTextBehindIndex( sal_Int32 nIndex, sal_Int16 aTextType ) override; + virtual sal_Bool SAL_CALL copyText( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) override; + virtual sal_Bool SAL_CALL scrollSubstringTo( sal_Int32 nStartIndex, sal_Int32 nEndIndex, css::accessibility::AccessibleScrollType aScrollType) override; + }; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/accessibility/AccessibleIconView.hxx b/vcl/inc/accessibility/AccessibleIconView.hxx new file mode 100644 index 000000000000..5accfbdfe4c5 --- /dev/null +++ b/vcl/inc/accessibility/AccessibleIconView.hxx @@ -0,0 +1,30 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * 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/. + */ + +#pragma once + +#include <sal/config.h> + +#include "accessiblelistbox.hxx" + +namespace accessibility +{ +class AccessibleIconView final : public AccessibleListBox +{ +public: + AccessibleIconView(SvTreeListBox& _rListBox, + const css::uno::Reference<css::accessibility::XAccessible>& _xParent); + +protected: + // VCLXAccessibleComponent + virtual void ProcessWindowEvent(const VclWindowEvent& rVclWindowEvent) override; +}; +} // namespace accessibility + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/vcl/inc/accessibility/IComboListBoxHelper.hxx b/vcl/inc/accessibility/IComboListBoxHelper.hxx new file mode 100644 index 000000000000..43d30aadab74 --- /dev/null +++ b/vcl/inc/accessibility/IComboListBoxHelper.hxx @@ -0,0 +1,69 @@ +/* -*- 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 <com/sun/star/uno/Reference.hxx> + +#include <rtl/ustring.hxx> +#include <vcl/wintypes.hxx> +#include <tools/long.hxx> + +namespace com::sun::star::datatransfer::clipboard { + class XClipboard; +} + +class AbsoluteScreenPixelRectangle; +class Point; +namespace tools { class Rectangle; } +namespace vcl { class Window; } +namespace accessibility +{ + class IComboListBoxHelper + { + public: + virtual ~IComboListBoxHelper() = 0; + + virtual OUString GetEntry( sal_Int32 nPos ) const = 0; + virtual tools::Rectangle GetDropDownPosSizePixel( ) const = 0; + virtual tools::Rectangle GetBoundingRectangle( sal_uInt16 nItem ) const = 0; + virtual AbsoluteScreenPixelRectangle GetWindowExtentsAbsolute() = 0; + virtual bool IsEnabled() const = 0; + virtual bool IsEntryVisible( sal_Int32 nPos ) const = 0; + virtual sal_uInt16 GetDisplayLineCount() const = 0; + virtual void GetMaxVisColumnsAndLines( sal_uInt16& rnCols, sal_uInt16& rnLines ) const = 0; + virtual WinBits GetStyle() const = 0; + virtual bool IsMultiSelectionEnabled() const = 0; + virtual sal_Int32 GetTopEntry() const = 0; + virtual bool IsEntryPosSelected( sal_Int32 nPos ) const = 0; + virtual sal_Int32 GetEntryCount() const = 0; + virtual void Select() = 0; + virtual void SelectEntryPos( sal_Int32 nPos, bool bSelect = true ) = 0; + virtual sal_Int32 GetSelectedEntryCount() const = 0; + virtual void SetNoSelection() = 0; + virtual sal_Int32 GetSelectedEntryPos( sal_Int32 nSelIndex ) const = 0; + virtual bool IsInDropDown() const = 0; + virtual tools::Rectangle GetEntryCharacterBounds( const sal_Int32 _nEntryPos, const sal_Int32 _nCharacterIndex ) const = 0; + virtual tools::Long GetIndexForPoint( const Point& rPoint, sal_Int32 & nPos ) const = 0; + virtual css::uno::Reference< css::datatransfer::clipboard::XClipboard > + GetClipboard() = 0; + }; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ + diff --git a/vcl/inc/accessibility/accessiblebrowseboxcell.hxx b/vcl/inc/accessibility/accessiblebrowseboxcell.hxx new file mode 100644 index 000000000000..c209619dce6c --- /dev/null +++ b/vcl/inc/accessibility/accessiblebrowseboxcell.hxx @@ -0,0 +1,74 @@ +/* -*- 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 <accessibility/AccessibleBrowseBoxBase.hxx> +#include <vcl/AccessibleBrowseBoxObjType.hxx> + +namespace accessibility +{ + + + // = AccessibleBrowseBoxCell + + /** common accessibility-functionality for browse box elements which occupy a cell + */ + class AccessibleBrowseBoxCell : public AccessibleBrowseBoxBase + { + private: + sal_Int32 m_nRowPos; // the row number of the table cell + sal_uInt16 m_nColPos; // the column id of the table cell + + protected: + // attribute access + sal_Int32 getRowPos( ) const { return m_nRowPos; } + sal_Int32 getColumnPos( ) const { return m_nColPos; } + + protected: + // AccessibleBrowseBoxBase overridables + virtual tools::Rectangle implGetBoundingBox() override; + virtual AbsoluteScreenPixelRectangle implGetBoundingBoxOnScreen() override; + + // XAccessibleComponent + virtual void SAL_CALL grabFocus() override; + + protected: + AccessibleBrowseBoxCell( + const css::uno::Reference< css::accessibility::XAccessible >& _rxParent, + ::vcl::IAccessibleTableProvider& _rBrowseBox, + const css::uno::Reference< css::awt::XWindow >& _xFocusWindow, + sal_Int32 _nRowPos, + sal_uInt16 _nColPos, + AccessibleBrowseBoxObjType _eType = AccessibleBrowseBoxObjType::TableCell + ); + + virtual ~AccessibleBrowseBoxCell() override; + + private: + AccessibleBrowseBoxCell( const AccessibleBrowseBoxCell& ) = delete; + AccessibleBrowseBoxCell& operator=( const AccessibleBrowseBoxCell& ) = delete; + }; + + +} // namespace accessibility + + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/accessibility/accessibleeditbrowseboxcell.hxx b/vcl/inc/accessibility/accessibleeditbrowseboxcell.hxx new file mode 100644 index 000000000000..b137eace05cc --- /dev/null +++ b/vcl/inc/accessibility/accessibleeditbrowseboxcell.hxx @@ -0,0 +1,131 @@ +/* -*- 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 <accessibility/accessiblebrowseboxcell.hxx> +#include <com/sun/star/accessibility/XAccessibleRelationSet.hpp> +#include <comphelper/compbase.hxx> +#include <comphelper/accessiblewrapper.hxx> + +namespace accessibility +{ + + // = EditBrowseBoxTableCell + + class EditBrowseBoxTableCell final : public AccessibleBrowseBoxCell + ,public ::comphelper::OAccessibleContextWrapperHelper + { + public: + EditBrowseBoxTableCell( + const css::uno::Reference< css::accessibility::XAccessible >& _rxParent, + const css::uno::Reference< css::accessibility::XAccessible >& _rxOwningAccessible, + const css::uno::Reference< css::accessibility::XAccessibleContext >& _xControlChild, + ::vcl::IAccessibleTableProvider& _rBrowseBox, + const css::uno::Reference< css::awt::XWindow >& _xFocusWindow, + sal_Int32 _nRowPos, + sal_uInt16 _nColPos + ); + + private: + virtual ~EditBrowseBoxTableCell() override; + + // XAccessibleComponent + virtual sal_Int32 SAL_CALL getForeground( ) override ; + virtual sal_Int32 SAL_CALL getBackground( ) override ; + + // XServiceInfo + virtual OUString SAL_CALL getImplementationName() override; + + // XInterface + DECLARE_XINTERFACE( ) + // XTypeProvider + DECLARE_XTYPEPROVIDER( ) + + // XAccessibleContext + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleParent( ) override; + virtual OUString SAL_CALL getAccessibleDescription( ) override; + virtual OUString SAL_CALL getAccessibleName( ) override; + virtual css::uno::Reference< css::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet( ) override; + virtual sal_Int64 SAL_CALL getAccessibleStateSet( ) override; + + sal_Int16 SAL_CALL getAccessibleRole() override; + + virtual sal_Int64 SAL_CALL getAccessibleChildCount( ) override; + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int64 i ) override; + + virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override; + + // OComponentHelper + virtual void SAL_CALL disposing() override; + + // XComponent/OComponentProxyAggregationHelper (needs to be disambiguated) + virtual void SAL_CALL dispose() final override; + + // OAccessibleContextWrapperHelper(); + void notifyTranslatedEvent( const css::accessibility::AccessibleEventObject& _rEvent ) override; + + EditBrowseBoxTableCell( const EditBrowseBoxTableCell& ) = delete; + EditBrowseBoxTableCell& operator=( const EditBrowseBoxTableCell& ) = delete; + }; + + + // = EditBrowseBoxTableCell + + // XAccessible providing an EditBrowseBoxTableCell + class EditBrowseBoxTableCellAccess final : + public comphelper::WeakComponentImplHelper<css::accessibility::XAccessible> + { + css::uno::WeakReference< css::accessibility::XAccessibleContext > + m_aContext; + css::uno::Reference< css::accessibility::XAccessible > + m_xParent; + css::uno::Reference< css::accessibility::XAccessible > + m_xControlAccessible; + css::uno::Reference< css::awt::XWindow > + m_xFocusWindow; + ::vcl::IAccessibleTableProvider* m_pBrowseBox; + sal_Int32 m_nRowPos; + sal_uInt16 m_nColPos; + + public: + EditBrowseBoxTableCellAccess( + css::uno::Reference< css::accessibility::XAccessible > _xParent, + css::uno::Reference< css::accessibility::XAccessible > _xControlAccessible, + css::uno::Reference< css::awt::XWindow > _xFocusWindow, + ::vcl::IAccessibleTableProvider& _rBrowseBox, + sal_Int32 _nRowPos, + sal_uInt16 _nColPos + ); + + private: + virtual ~EditBrowseBoxTableCellAccess() override; + + // XAccessible + virtual css::uno::Reference< css::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext( ) override; + + // XComponent/WeakComponentImplHelper + virtual void disposing(std::unique_lock<std::mutex>&) override; + + EditBrowseBoxTableCellAccess( const EditBrowseBoxTableCellAccess& ) = delete; + EditBrowseBoxTableCellAccess& operator=( const EditBrowseBoxTableCellAccess& ) = delete; + }; +} + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/accessibility/accessibleiconchoicectrl.hxx b/vcl/inc/accessibility/accessibleiconchoicectrl.hxx new file mode 100644 index 000000000000..8cf4e343670f --- /dev/null +++ b/vcl/inc/accessibility/accessibleiconchoicectrl.hxx @@ -0,0 +1,94 @@ +/* -*- 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 <com/sun/star/accessibility/XAccessibleSelection.hpp> +#include <cppuhelper/implbase.hxx> +#include <vcl/accessibility/vclxaccessiblecomponent.hxx> +#include <vcl/vclevent.hxx> + +// class AccessibleListBox ----------------------------------------------- + +class SvtIconChoiceCtrl; + +namespace accessibility +{ + /** the class OAccessibleListBoxEntry represents the base class for an accessible object of a listbox entry + */ + class AccessibleIconChoiceCtrl final : + public cppu::ImplInheritanceHelper< + VCLXAccessibleComponent, + css::accessibility::XAccessible, + css::accessibility::XAccessibleSelection> + { + css::uno::Reference< css::accessibility::XAccessible > m_xParent; + + virtual ~AccessibleIconChoiceCtrl() override = default; + + /** this function is called upon disposing the component */ + virtual void SAL_CALL disposing() override; + + virtual void ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) override; + virtual void FillAccessibleStateSet( sal_Int64& rStateSet ) override; + + VclPtr< SvtIconChoiceCtrl > getCtrl() const; + + public: + /** OAccessibleBase needs a valid view + @param _rIconCtrl + is the box for which we implement an accessible object + @param _xParent + is our parent accessible object + */ + AccessibleIconChoiceCtrl( + SvtIconChoiceCtrl& _rIconCtrl, + const css::uno::Reference<css::accessibility::XAccessible>& _xParent); + + // XServiceInfo + virtual OUString SAL_CALL getImplementationName() override; + virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; + + // XAccessible + virtual css::uno::Reference< css::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext( ) override; + + // XAccessibleContext + virtual sal_Int64 SAL_CALL getAccessibleChildCount( ) override; + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int64 i ) override; + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleParent( ) override; + virtual sal_Int16 SAL_CALL getAccessibleRole( ) override; + virtual OUString SAL_CALL getAccessibleDescription( ) override; + virtual OUString SAL_CALL getAccessibleName( ) override; + + // XAccessibleSelection + void SAL_CALL selectAccessibleChild( sal_Int64 nChildIndex ) override; + sal_Bool SAL_CALL isAccessibleChildSelected( sal_Int64 nChildIndex ) override; + void SAL_CALL clearAccessibleSelection( ) override; + void SAL_CALL selectAllAccessibleChildren( ) override; + sal_Int64 SAL_CALL getSelectedAccessibleChildCount( ) override; + css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getSelectedAccessibleChild( sal_Int64 nSelectedChildIndex ) override; + void SAL_CALL deselectAccessibleChild( sal_Int64 nSelectedChildIndex ) override; + }; + + +}// namespace accessibility + + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/accessibility/accessibleiconchoicectrlentry.hxx b/vcl/inc/accessibility/accessibleiconchoicectrlentry.hxx new file mode 100644 index 000000000000..30ac955caf9c --- /dev/null +++ b/vcl/inc/accessibility/accessibleiconchoicectrlentry.hxx @@ -0,0 +1,164 @@ +/* -*- 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 <com/sun/star/accessibility/AccessibleScrollType.hpp> +#include <com/sun/star/accessibility/XAccessible.hpp> +#include <com/sun/star/accessibility/XAccessibleComponent.hpp> +#include <com/sun/star/accessibility/XAccessibleContext.hpp> +#include <com/sun/star/accessibility/XAccessibleEventBroadcaster.hpp> +#include <com/sun/star/accessibility/XAccessibleAction.hpp> +#include <com/sun/star/lang/XEventListener.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <cppuhelper/basemutex.hxx> +#include <cppuhelper/implbase.hxx> +#include <comphelper/accessibletexthelper.hxx> +#include <tools/gen.hxx> +#include <vcl/vclptr.hxx> + +// forward + +class SvxIconChoiceCtrlEntry; +class SvtIconChoiceCtrl; + +namespace accessibility +{ + + + typedef ::cppu::ImplInheritanceHelper< comphelper::OAccessibleComponentHelper + , css::accessibility::XAccessible + , css::accessibility::XAccessibleText + , css::accessibility::XAccessibleAction + , css::lang::XServiceInfo + , css::lang::XEventListener > AccessibleIconChoiceCtrlEntry_BASE; + + /** the class AccessibleListBoxEntry represents the class for an accessible object of a listbox entry */ + class AccessibleIconChoiceCtrlEntry final : public AccessibleIconChoiceCtrlEntry_BASE, + public ::comphelper::OCommonAccessibleText + { + /** The treelistbox control */ + VclPtr<SvtIconChoiceCtrl> m_pIconCtrl; + sal_Int32 m_nIndex; + + css::uno::Reference< css::accessibility::XAccessible > m_xParent; + + tools::Rectangle GetBoundingBox_Impl() const; + AbsoluteScreenPixelRectangle GetBoundingBoxOnScreen_Impl() const; + bool IsAlive_Impl() const; + bool IsShowing_Impl() const; + + /// @throws css::lang::DisposedException + /// @throws css::uno::RuntimeException + AbsoluteScreenPixelRectangle GetBoundingBoxOnScreen(); + /// @throws css::lang::DisposedException + void EnsureIsAlive() const; + + virtual ~AccessibleIconChoiceCtrlEntry() override; + /** this function is called upon disposing the component + */ + virtual void SAL_CALL disposing() override; + + // OCommonAccessibleComponent + virtual css::awt::Rectangle implGetBounds() override; + + // OCommonAccessibleText + virtual OUString implGetText() override; + virtual css::lang::Locale implGetLocale() override; + virtual void implGetSelection( sal_Int32& nStartIndex, sal_Int32& nEndIndex ) override final; + + public: + /** Ctor() + @param _rIconCtrl + the icon control + @param _nPos + the entry number + @param _xParent + is our parent accessible object + */ + AccessibleIconChoiceCtrlEntry( SvtIconChoiceCtrl& _rIconCtrl, + sal_Int32 _nPos, + const css::uno::Reference< css::accessibility::XAccessible >& _xParent ); + + // XTypeProvider + virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override; + + // XServiceInfo + virtual OUString SAL_CALL getImplementationName() override; + virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override; + virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; + + // XEventListener + virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override; + + // XAccessible + virtual css::uno::Reference< css::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext( ) override; + + // XAccessibleContext + virtual sal_Int64 SAL_CALL getAccessibleChildCount( ) override; + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int64 i ) override; + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleParent( ) override; + virtual sal_Int64 SAL_CALL getAccessibleIndexInParent( ) override; + virtual sal_Int16 SAL_CALL getAccessibleRole( ) override; + virtual OUString SAL_CALL getAccessibleDescription( ) override; + virtual OUString SAL_CALL getAccessibleName( ) override; + virtual css::uno::Reference< css::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet( ) override; + virtual sal_Int64 SAL_CALL getAccessibleStateSet( ) override; + virtual css::lang::Locale SAL_CALL getLocale( ) override; + + // XAccessibleComponent + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint( const css::awt::Point& aPoint ) override; + virtual css::awt::Point SAL_CALL getLocationOnScreen( ) override; + virtual void SAL_CALL grabFocus( ) override; + virtual sal_Int32 SAL_CALL getForeground( ) override; + virtual sal_Int32 SAL_CALL getBackground( ) override; + + // XAccessibleText + virtual sal_Int32 SAL_CALL getCaretPosition() override; + virtual sal_Bool SAL_CALL setCaretPosition( sal_Int32 nIndex ) override; + virtual sal_Unicode SAL_CALL getCharacter( sal_Int32 nIndex ) override; + virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL getCharacterAttributes( sal_Int32 nIndex, const css::uno::Sequence< OUString >& aRequestedAttributes ) override; + virtual css::awt::Rectangle SAL_CALL getCharacterBounds( sal_Int32 nIndex ) override; + virtual sal_Int32 SAL_CALL getCharacterCount() override; + virtual sal_Int32 SAL_CALL getIndexAtPoint( const css::awt::Point& aPoint ) override; + virtual OUString SAL_CALL getSelectedText() override; + virtual sal_Int32 SAL_CALL getSelectionStart() override; + virtual sal_Int32 SAL_CALL getSelectionEnd() override; + virtual sal_Bool SAL_CALL setSelection( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) override; + virtual OUString SAL_CALL getText() override; + virtual OUString SAL_CALL getTextRange( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) override; + virtual css::accessibility::TextSegment SAL_CALL getTextAtIndex( sal_Int32 nIndex, sal_Int16 aTextType ) override; + virtual css::accessibility::TextSegment SAL_CALL getTextBeforeIndex( sal_Int32 nIndex, sal_Int16 aTextType ) override; + virtual css::accessibility::TextSegment SAL_CALL getTextBehindIndex( sal_Int32 nIndex, sal_Int16 aTextType ) override; + virtual sal_Bool SAL_CALL copyText( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) override; + virtual sal_Bool SAL_CALL scrollSubstringTo( sal_Int32 nStartIndex, sal_Int32 nEndIndex, css::accessibility::AccessibleScrollType aScrollType) override; + + // XAccessibleAction + virtual sal_Int32 SAL_CALL getAccessibleActionCount( ) override; + virtual sal_Bool SAL_CALL doAccessibleAction( sal_Int32 nIndex ) override; + virtual OUString SAL_CALL getAccessibleActionDescription( sal_Int32 nIndex ) override; + virtual css::uno::Reference< css::accessibility::XAccessibleKeyBinding > SAL_CALL getAccessibleActionKeyBinding( sal_Int32 nIndex ) override; + }; + + +}// namespace accessibility + + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/accessibility/accessiblelistbox.hxx b/vcl/inc/accessibility/accessiblelistbox.hxx new file mode 100644 index 000000000000..dd7f63c51fd4 --- /dev/null +++ b/vcl/inc/accessibility/accessiblelistbox.hxx @@ -0,0 +1,118 @@ +/* -*- 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 <com/sun/star/accessibility/XAccessibleSelection.hpp> +#include <cppuhelper/implbase.hxx> +#include <vcl/accessibility/vclxaccessiblecomponent.hxx> +#include <vcl/vclevent.hxx> + +#include <unordered_map> + +// class AccessibleListBox ----------------------------------------------- + +class SvTreeListBox; +class SvTreeListEntry; + +namespace accessibility +{ + class AccessibleListBoxEntry; + + /** the class OAccessibleListBoxEntry represents the base class for an accessible object of a listbox entry + */ + class AccessibleListBox : + public cppu::ImplInheritanceHelper< + VCLXAccessibleComponent, + css::accessibility::XAccessible, + css::accessibility::XAccessibleSelection> + { + + css::uno::Reference< css::accessibility::XAccessible > m_xParent; + // OComponentHelper overridables + /** this function is called upon disposing the component */ + virtual void SAL_CALL disposing() override; + + protected: + // VCLXAccessibleComponent + virtual void ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) override; + virtual void FillAccessibleStateSet( sal_Int64& rStateSet ) override; + + private: + VclPtr< SvTreeListBox > getListBox() const; + + void RemoveChildEntries(SvTreeListEntry*); + + sal_Int32 GetRoleType() const; + + public: + /** OAccessibleBase needs a valid view + @param _rListBox + is the box for which we implement an accessible object + @param _xParent + is our parent accessible object + */ + AccessibleListBox(SvTreeListBox& _rListBox, + const css::uno::Reference< css::accessibility::XAccessible >& _xParent ); + + virtual ~AccessibleListBox() override; + + rtl::Reference<AccessibleListBoxEntry> implGetAccessible(SvTreeListEntry & rEntry); + + // XServiceInfo + virtual OUString SAL_CALL getImplementationName() override; + virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; + + // XAccessible + virtual css::uno::Reference< css::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext( ) override; + + // XAccessibleContext + virtual sal_Int64 SAL_CALL getAccessibleChildCount( ) override; + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int64 i ) override; + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleParent( ) override; + virtual sal_Int16 SAL_CALL getAccessibleRole( ) override; + virtual OUString SAL_CALL getAccessibleDescription( ) override; + virtual OUString SAL_CALL getAccessibleName( ) override; + + // XAccessibleSelection + void SAL_CALL selectAccessibleChild( sal_Int64 nChildIndex ) override; + sal_Bool SAL_CALL isAccessibleChildSelected( sal_Int64 nChildIndex ) override; + void SAL_CALL clearAccessibleSelection( ) override; + void SAL_CALL selectAllAccessibleChildren( ) override; + sal_Int64 SAL_CALL getSelectedAccessibleChildCount( ) override; + css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getSelectedAccessibleChild( sal_Int64 nSelectedChildIndex ) override; + void SAL_CALL deselectAccessibleChild( sal_Int64 nSelectedChildIndex ) override; + + private: + + typedef std::unordered_map<SvTreeListEntry*, rtl::Reference<AccessibleListBoxEntry>> MAP_ENTRY; + MAP_ENTRY m_mapEntry; + + rtl::Reference<AccessibleListBoxEntry> m_xFocusedEntry; + + accessibility::AccessibleListBoxEntry* GetCurEventEntry( const VclWindowEvent& rVclWindowEvent ); + + }; + + +}// namespace accessibility + + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/accessibility/accessiblelistboxentry.hxx b/vcl/inc/accessibility/accessiblelistboxentry.hxx new file mode 100644 index 000000000000..050dc948d9c4 --- /dev/null +++ b/vcl/inc/accessibility/accessiblelistboxentry.hxx @@ -0,0 +1,224 @@ +/* -*- 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 <deque> +#include <com/sun/star/accessibility/AccessibleScrollType.hpp> +#include <com/sun/star/accessibility/XAccessible.hpp> +#include <com/sun/star/accessibility/XAccessibleComponent.hpp> +#include <com/sun/star/accessibility/XAccessibleContext.hpp> +#include <com/sun/star/accessibility/XAccessibleEventBroadcaster.hpp> +#include <com/sun/star/accessibility/XAccessibleAction.hpp> +#include <com/sun/star/accessibility/XAccessibleSelection.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/accessibility/XAccessibleValue.hpp> +#include <cppuhelper/compbase.hxx> +#include <cppuhelper/basemutex.hxx> +#include <comphelper/accessibletexthelper.hxx> +#include <vcl/toolkit/treelistentry.hxx> +#include <tools/gen.hxx> +#include <unotools/weakref.hxx> + +// forward --------------------------------------------------------------- + +namespace com::sun::star::awt { + struct Point; + struct Rectangle; + struct Size; + class XFocusListener; +} + +class SvTreeListBox; +class SvTreeListEntry; + + +namespace accessibility +{ + class AccessibleListBox; + +// class AccessibleListBoxEntry ------------------------------------------ + typedef ::cppu::WeakComponentImplHelper< css::accessibility::XAccessible + , css::accessibility::XAccessibleContext + , css::accessibility::XAccessibleComponent + , css::accessibility::XAccessibleEventBroadcaster + , css::accessibility::XAccessibleAction + , css::accessibility::XAccessibleSelection + , css::accessibility::XAccessibleText + , css::accessibility::XAccessibleValue + , css::lang::XServiceInfo > AccessibleListBoxEntry_BASE; + + /** the class AccessibleListBoxEntry represents the class for an accessible object of a listbox entry */ + class AccessibleListBoxEntry final : public ::cppu::BaseMutex + ,public AccessibleListBoxEntry_BASE + ,public ::comphelper::OCommonAccessibleText + { + friend class AccessibleListBox; + + private: + VclPtr<SvTreeListBox> m_pTreeListBox; + /** The treelistbox control */ + std::deque< sal_Int32 > m_aEntryPath; + SvTreeListEntry* m_pSvLBoxEntry; // Needed for a11y focused item... + + + /// client id in the AccessibleEventNotifier queue + sal_uInt32 m_nClientId; + + unotools::WeakReference<AccessibleListBox> m_wListBox; + + tools::Rectangle GetBoundingBox_Impl() const; + tools::Rectangle GetBoundingBoxOnScreen_Impl() const; + bool IsAlive_Impl() const; + bool IsShowing_Impl() const; + + /// @throws css::lang::DisposedException + /// @throws css::uno::RuntimeException + tools::Rectangle GetBoundingBox(); + /// @throws css::lang::DisposedException + /// @throws css::uno::RuntimeException + tools::Rectangle GetBoundingBoxOnScreen(); + /// @throws css::lang::IndexOutOfBoundsException + void CheckActionIndex(sal_Int32 nIndex); + /// @throws css::lang::DisposedException + void EnsureIsAlive() const; + + void NotifyAccessibleEvent( sal_Int16 _nEventId, const css::uno::Any& _aOldValue, const css::uno::Any& _aNewValue ); + + virtual ~AccessibleListBoxEntry() override; + + /** this function is called upon disposing the component + */ + virtual void SAL_CALL disposing() override; + + DECL_LINK( WindowEventListener, VclWindowEvent&, void ); + + // OCommonAccessibleText + virtual OUString implGetText() override; + virtual css::lang::Locale implGetLocale() override; + virtual void implGetSelection( sal_Int32& nStartIndex, sal_Int32& nEndIndex ) override; + + public: + /** Ctor() + @param _rListBox + the view control + @param rEntry + the entry + @param rListBox + the a11y object for _rListBox + */ + AccessibleListBoxEntry( SvTreeListBox& _rListBox, + SvTreeListEntry& rEntry, + AccessibleListBox & rListBox); + + SvTreeListEntry* GetSvLBoxEntry() const { return m_pSvLBoxEntry; } + + + private: + // XTypeProvider + virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override; + + // XServiceInfo + virtual OUString SAL_CALL getImplementationName() override; + virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override; + virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; + + // XAccessible + virtual css::uno::Reference< css::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext( ) override; + + // XAccessibleContext + virtual sal_Int64 SAL_CALL getAccessibleChildCount( ) override; + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int64 i ) override; + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleParent( ) override; + virtual sal_Int64 SAL_CALL getAccessibleIndexInParent( ) override; + virtual sal_Int16 SAL_CALL getAccessibleRole( ) override; + virtual OUString SAL_CALL getAccessibleDescription( ) override; + virtual OUString SAL_CALL getAccessibleName( ) override; + virtual css::uno::Reference< css::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet( ) override; + virtual sal_Int64 SAL_CALL getAccessibleStateSet( ) override; + virtual css::lang::Locale SAL_CALL getLocale( ) override; + + // XAccessibleComponent + virtual sal_Bool SAL_CALL containsPoint( const css::awt::Point& aPoint ) override; + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint( const css::awt::Point& aPoint ) override; + virtual css::awt::Rectangle SAL_CALL getBounds( ) override; + virtual css::awt::Point SAL_CALL getLocation( ) override; + virtual css::awt::Point SAL_CALL getLocationOnScreen( ) override; + virtual css::awt::Size SAL_CALL getSize( ) override; + virtual void SAL_CALL grabFocus( ) override; + virtual sal_Int32 SAL_CALL getForeground( ) override; + virtual sal_Int32 SAL_CALL getBackground( ) override; + + // XAccessibleText + virtual sal_Int32 SAL_CALL getCaretPosition() override; + virtual sal_Bool SAL_CALL setCaretPosition( sal_Int32 nIndex ) override; + virtual sal_Unicode SAL_CALL getCharacter( sal_Int32 nIndex ) override; + virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL getCharacterAttributes( sal_Int32 nIndex, const css::uno::Sequence< OUString >& aRequestedAttributes ) override; + virtual css::awt::Rectangle SAL_CALL getCharacterBounds( sal_Int32 nIndex ) override; + virtual sal_Int32 SAL_CALL getCharacterCount() override; + virtual sal_Int32 SAL_CALL getIndexAtPoint( const css::awt::Point& aPoint ) override; + virtual OUString SAL_CALL getSelectedText() override; + virtual sal_Int32 SAL_CALL getSelectionStart() override; + virtual sal_Int32 SAL_CALL getSelectionEnd() override; + virtual sal_Bool SAL_CALL setSelection( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) override; + virtual OUString SAL_CALL getText() override; + virtual OUString SAL_CALL getTextRange( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) override; + virtual css::accessibility::TextSegment SAL_CALL getTextAtIndex( sal_Int32 nIndex, sal_Int16 aTextType ) override; + virtual css::accessibility::TextSegment SAL_CALL getTextBeforeIndex( sal_Int32 nIndex, sal_Int16 aTextType ) override; + virtual css::accessibility::TextSegment SAL_CALL getTextBehindIndex( sal_Int32 nIndex, sal_Int16 aTextType ) override; + virtual sal_Bool SAL_CALL copyText( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) override; + virtual sal_Bool SAL_CALL scrollSubstringTo( sal_Int32 nStartIndex, sal_Int32 nEndIndex, css::accessibility::AccessibleScrollType aScrollType) override; + + // XAccessibleEventBroadcaster + virtual void SAL_CALL addAccessibleEventListener( const css::uno::Reference< css::accessibility::XAccessibleEventListener >& xListener ) override; + virtual void SAL_CALL removeAccessibleEventListener( const css::uno::Reference< css::accessibility::XAccessibleEventListener >& xListener ) override; + + // XAccessibleAction + virtual sal_Int32 SAL_CALL getAccessibleActionCount( ) override; + virtual sal_Bool SAL_CALL doAccessibleAction( sal_Int32 nIndex ) override; + virtual OUString SAL_CALL getAccessibleActionDescription( sal_Int32 nIndex ) override; + virtual css::uno::Reference< css::accessibility::XAccessibleKeyBinding > SAL_CALL getAccessibleActionKeyBinding( sal_Int32 nIndex ) override; + + // XAccessibleSelection + void SAL_CALL selectAccessibleChild( sal_Int64 nChildIndex ) override; + sal_Bool SAL_CALL isAccessibleChildSelected( sal_Int64 nChildIndex ) override; + void SAL_CALL clearAccessibleSelection( ) override; + void SAL_CALL selectAllAccessibleChildren( ) override; + sal_Int64 SAL_CALL getSelectedAccessibleChildCount( ) override; + css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getSelectedAccessibleChild( sal_Int64 nSelectedChildIndex ) override; + void SAL_CALL deselectAccessibleChild( sal_Int64 nSelectedChildIndex ) override; + + // XAccessibleValue + virtual css::uno::Any SAL_CALL getCurrentValue( ) override; + virtual sal_Bool SAL_CALL setCurrentValue( const css::uno::Any& aNumber ) override; + virtual css::uno::Any SAL_CALL getMaximumValue( ) override; + virtual css::uno::Any SAL_CALL getMinimumValue( ) override; + virtual css::uno::Any SAL_CALL getMinimumIncrement( ) override; + + css::uno::Reference< css::accessibility::XAccessible > implGetParentAccessible( ) const; + SvTreeListEntry* GetRealChild(sal_Int32 nIndex); + sal_Int32 GetRoleType() const; + }; + + +}// namespace accessibility + + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/accessibility/accessibletablistbox.hxx b/vcl/inc/accessibility/accessibletablistbox.hxx new file mode 100644 index 000000000000..ebd532a55bca --- /dev/null +++ b/vcl/inc/accessibility/accessibletablistbox.hxx @@ -0,0 +1,102 @@ +/* -*- 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 <accessibility/AccessibleBrowseBox.hxx> +#include <cppuhelper/implbase1.hxx> +#include <vcl/accessibletableprovider.hxx> + +class SvHeaderTabListBox; + + +namespace accessibility { + +class AccessibleBrowseBoxTable; + +typedef ::cppu::ImplHelper1 < css::accessibility::XAccessible + > AccessibleTabListBox_Base; + +/** !!! */ +class AccessibleTabListBox final + :public AccessibleBrowseBox + ,public AccessibleTabListBox_Base + ,public ::vcl::IAccessibleTabListBox +{ +private: + VclPtr<SvHeaderTabListBox> m_pTabListBox; + +public: + /** ctor() + @param rxParent XAccessible interface of the parent object. + @param rBox The HeaderTabListBox control. */ + AccessibleTabListBox( + const css::uno::Reference< css::accessibility::XAccessible >& rxParent, + SvHeaderTabListBox& rBox ); + + // XInterface + DECLARE_XINTERFACE( ) + // XTypeProvider + DECLARE_XTYPEPROVIDER( ) + + // XAccessibleContext ----------------------------------------------------- + + /** @return The count of visible children. */ + virtual sal_Int64 SAL_CALL getAccessibleChildCount() override; + + /** @return The XAccessible interface of the specified child. */ + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL + getAccessibleChild( sal_Int64 nChildIndex ) override; + + // XAccessibleContext + css::uno::Reference< css::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext() override; + + // IAccessibleTabListBox + virtual css::uno::Reference< css::accessibility::XAccessible > + getMyself() override + { + return this; + } + + css::uno::Reference< css::accessibility::XAccessible > + getHeaderBar() override + { + return AccessibleBrowseBox::getHeaderBar( AccessibleBrowseBoxObjType::ColumnHeaderBar ); + } + + css::uno::Reference<css::accessibility::XAccessible> getTable() override + { + return implGetTable(); + } + +private: + /** dtor() */ + virtual ~AccessibleTabListBox() override; + + /** This method creates and returns an accessible table. + @return An AccessibleBrowseBoxTable. */ + virtual rtl::Reference<AccessibleBrowseBoxTable> createAccessibleTable() override; +}; + + +} // namespace accessibility + + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/accessibility/accessibletablistboxtable.hxx b/vcl/inc/accessibility/accessibletablistboxtable.hxx new file mode 100644 index 000000000000..ec36d413acbe --- /dev/null +++ b/vcl/inc/accessibility/accessibletablistboxtable.hxx @@ -0,0 +1,108 @@ +/* -*- 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 <accessibility/AccessibleBrowseBoxTable.hxx> +#include <comphelper/uno3.hxx> +#include <cppuhelper/implbase1.hxx> +#include <com/sun/star/accessibility/XAccessibleSelection.hpp> + +class SvHeaderTabListBox; + + +namespace accessibility { + +typedef ::cppu::ImplHelper1< css::accessibility::XAccessibleSelection > + AccessibleTabListBoxTableImplHelper; + +class AccessibleTabListBoxTable final : public AccessibleBrowseBoxTable, public AccessibleTabListBoxTableImplHelper +{ +private: + VclPtr<SvHeaderTabListBox> m_pTabListBox; + + css::uno::Reference< css::accessibility::XAccessible > m_xCurChild; + + void ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ); + DECL_LINK( WindowEventListener, VclWindowEvent&, void ); + + // helpers ---------------------------------------------------------------- + + /** Throws an exception, if nIndex is not a valid child index. */ + void ensureValidIndex( sal_Int64 _nIndex ) const; + + /** Selects the specified row. */ + void implSelectRow( sal_Int32 _nRow, bool _bSelect ); + + /** Returns the count of rows in the table. */ + sal_Int32 implGetRowCount() const override; + /** Returns the total column count in the table. */ + sal_Int32 implGetColumnCount() const override; + /** Returns the count of selected rows in the table. */ + sal_Int32 implGetSelRowCount() const; + + /** Returns the row index from cell index. */ + sal_Int32 implGetRow( sal_Int64 _nIndex ) const + { + auto nColCount = implGetColumnCount(); + assert(nColCount != 0); + return _nIndex / nColCount; + } + + /** Returns the absolute row index of the nSelRow-th selected row. */ + sal_Int32 implGetSelRow( sal_Int32 _nSelRow ) const; + +public: + /** ctor() + @param rxParent XAccessible interface of the parent object. + @param rBox The HeaderTabListBox control. */ + AccessibleTabListBoxTable( + const css::uno::Reference< css::accessibility::XAccessible >& rxParent, + SvHeaderTabListBox& rBox ); + +private: + /** dtor() */ + virtual ~AccessibleTabListBoxTable() override; + +public: + // XInterface + DECLARE_XINTERFACE( ) + + // XTypeProvider + DECLARE_XTYPEPROVIDER( ) + + // XServiceInfo + virtual OUString SAL_CALL getImplementationName() override; + + // XAccessibleSelection + void SAL_CALL selectAccessibleChild( sal_Int64 nChildIndex ) override; + sal_Bool SAL_CALL isAccessibleChildSelected( sal_Int64 nChildIndex ) override; + void SAL_CALL clearAccessibleSelection( ) override; + void SAL_CALL selectAllAccessibleChildren( ) override; + sal_Int64 SAL_CALL getSelectedAccessibleChildCount( ) override; + css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getSelectedAccessibleChild( sal_Int64 nSelectedChildIndex ) override; + void SAL_CALL deselectAccessibleChild( sal_Int64 nSelectedChildIndex ) override; +}; + + +} // namespace accessibility + + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/accessibility/floatingwindowaccessible.hxx b/vcl/inc/accessibility/floatingwindowaccessible.hxx new file mode 100644 index 000000000000..240eb27df61f --- /dev/null +++ b/vcl/inc/accessibility/floatingwindowaccessible.hxx @@ -0,0 +1,32 @@ +/* -*- 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/accessibility/vclxaccessiblecomponent.hxx> + +class FloatingWindowAccessible final : public VCLXAccessibleComponent +{ +public: + using VCLXAccessibleComponent::VCLXAccessibleComponent; + + virtual void FillAccessibleRelationSet(utl::AccessibleRelationSetHelper& rRelationSet) override; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/accessibility/listboxhelper.hxx b/vcl/inc/accessibility/listboxhelper.hxx new file mode 100644 index 000000000000..af9c301fcaf8 --- /dev/null +++ b/vcl/inc/accessibility/listboxhelper.hxx @@ -0,0 +1,186 @@ +/* -*- 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 <accessibility/IComboListBoxHelper.hxx> +#include <com/sun/star/datatransfer/clipboard/XClipboard.hpp> +#include <tools/gen.hxx> + + +// globals + + +const sal_Int32 DEFAULT_INDEX_IN_PARENT = -1; + + + + +template< class T > class VCLListBoxHelper final : public ::accessibility::IComboListBoxHelper +{ +private: + T& m_aComboListBox; + +public: + VCLListBoxHelper( T& _pListBox ) : + m_aComboListBox( _pListBox ){} + + + virtual OUString GetEntry( sal_Int32 nPos ) const override + { + return m_aComboListBox.GetEntry( nPos ); + } + + virtual tools::Rectangle GetDropDownPosSizePixel() const override + { + AbsoluteScreenPixelRectangle aTemp = m_aComboListBox.GetWindowExtentsAbsolute(); + tools::Rectangle aRet = m_aComboListBox.GetDropDownPosSizePixel(); + aRet.Move(aTemp.Left(), aTemp.Top()); + return aRet; + } + + virtual tools::Rectangle GetBoundingRectangle( sal_uInt16 nItem ) const override + { + tools::Rectangle aRect; + if ( m_aComboListBox.IsInDropDown() && IsEntryVisible( nItem ) ) + { + tools::Rectangle aTemp = m_aComboListBox.GetDropDownPosSizePixel(); + Size aSize = aTemp.GetSize(); + sal_uInt16 nLineCount = m_aComboListBox.GetDisplayLineCount(); + assert(nLineCount && "div-by-zero"); + aSize.setHeight( aSize.Height() / nLineCount ); + Point aTopLeft = aTemp.TopLeft(); + aTopLeft.AdjustY( aSize.Height() * ( nItem - m_aComboListBox.GetTopEntry() ) ); + aRect = tools::Rectangle( aTopLeft, aSize ); + } + else + aRect = m_aComboListBox.GetBoundingRectangle( nItem ); + return aRect; + } + + virtual AbsoluteScreenPixelRectangle GetWindowExtentsAbsolute() override + { + return m_aComboListBox.GetWindowExtentsAbsolute(); + } + + virtual bool IsEnabled() const override + { + return m_aComboListBox.IsEnabled(); + } + + virtual bool IsEntryVisible( sal_Int32 nPos ) const override + { + sal_Int32 nTopEntry = m_aComboListBox.GetTopEntry(); + sal_uInt16 nLines = m_aComboListBox.GetDisplayLineCount(); + return ( nPos >= nTopEntry && nPos < ( nTopEntry + nLines ) ); + } + + virtual sal_uInt16 GetDisplayLineCount() const override + { + return m_aComboListBox.GetDisplayLineCount(); + } + + virtual void GetMaxVisColumnsAndLines( sal_uInt16& rnCols, sal_uInt16& rnLines ) const override + { + m_aComboListBox.GetMaxVisColumnsAndLines(rnCols,rnLines); + } + + virtual WinBits GetStyle() const override + { + return m_aComboListBox.GetStyle(); + } + + virtual bool IsMultiSelectionEnabled() const override + { + return m_aComboListBox.IsMultiSelectionEnabled(); + } + + virtual sal_Int32 GetTopEntry() const override + { + return m_aComboListBox.GetTopEntry(); + } + + virtual bool IsEntryPosSelected( sal_Int32 nPos ) const override + { + return m_aComboListBox.IsEntryPosSelected(nPos); + } + + virtual sal_Int32 GetEntryCount() const override + { + return m_aComboListBox.GetEntryCount(); + } + + virtual void Select() override + { + m_aComboListBox.Select(); + } + + virtual void SelectEntryPos( sal_Int32 nPos, bool bSelect = true ) override + { + m_aComboListBox.SelectEntryPos(nPos,bSelect); + } + + virtual sal_Int32 GetSelectedEntryCount() const override + { + return m_aComboListBox.GetSelectedEntryCount(); + } + + virtual void SetNoSelection() override + { + m_aComboListBox.SetNoSelection(); + } + + virtual sal_Int32 GetSelectedEntryPos( sal_Int32 nSelIndex = 0 ) const override + { + return m_aComboListBox.GetSelectedEntryPos(nSelIndex); + } + + virtual bool IsInDropDown() const override + { + return m_aComboListBox.IsInDropDown(); + } + + virtual tools::Rectangle GetEntryCharacterBounds( const sal_Int32 _nEntryPos, const sal_Int32 _nCharacterIndex ) const override + { + tools::Rectangle aRect; + + Pair aEntryCharacterRange = m_aComboListBox.GetLineStartEnd( _nEntryPos ); + if ( aEntryCharacterRange.A() + _nCharacterIndex <= aEntryCharacterRange.B() ) + { + tools::Long nIndex = aEntryCharacterRange.A() + _nCharacterIndex; + aRect = m_aComboListBox.GetCharacterBounds( nIndex ); + } + return aRect; + } + + tools::Long GetIndexForPoint( const Point& rPoint, sal_Int32& nPos ) const override + { + return m_aComboListBox.GetIndexForPoint( rPoint, nPos ); + } + + css::uno::Reference< css::datatransfer::clipboard::XClipboard > + GetClipboard() override + { + return m_aComboListBox.GetClipboard(); + } + +}; + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/accessibility/svtaccessiblenumericfield.hxx b/vcl/inc/accessibility/svtaccessiblenumericfield.hxx new file mode 100644 index 000000000000..6b2f1390e8d0 --- /dev/null +++ b/vcl/inc/accessibility/svtaccessiblenumericfield.hxx @@ -0,0 +1,49 @@ +/* -*- 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 <cppuhelper/implbase.hxx> +#include <vcl/toolkit/fmtfield.hxx> +#include <vcl/vclevent.hxx> + +#include <accessibility/vclxaccessibleedit.hxx> + +#include <com/sun/star/accessibility/XAccessibleValue.hpp> + +class SVTXAccessibleNumericField final + : public cppu::ImplInheritanceHelper<VCLXAccessibleEdit, css::accessibility::XAccessibleValue> +{ +public: + SVTXAccessibleNumericField(FormattedField* pFormattedField); + + virtual void ProcessWindowEvent(const VclWindowEvent& rVclWindowEvent) override; + + // XAccessibleContext + virtual sal_Int16 SAL_CALL getAccessibleRole() override; + + // XAccessibleValue + virtual ::css::uno::Any SAL_CALL getCurrentValue() override; + virtual ::sal_Bool SAL_CALL setCurrentValue(const css::uno::Any& aNumber) override; + virtual ::css::uno::Any SAL_CALL getMaximumValue() override; + virtual ::css::uno::Any SAL_CALL getMinimumValue() override; + virtual ::css::uno::Any SAL_CALL getMinimumIncrement() override; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/accessibility/textwindowaccessibility.hxx b/vcl/inc/accessibility/textwindowaccessibility.hxx new file mode 100644 index 000000000000..1a6fa921bb7d --- /dev/null +++ b/vcl/inc/accessibility/textwindowaccessibility.hxx @@ -0,0 +1,576 @@ +/* -*- 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 <svl/lstner.hxx> +#include <vcl/accessibility/vclxaccessiblecomponent.hxx> +#include <vcl/textdata.hxx> +#include <vcl/texteng.hxx> +#include <vcl/textview.hxx> +#include <vcl/window.hxx> +#include <com/sun/star/uno/Reference.hxx> +#include <com/sun/star/accessibility/AccessibleScrollType.hpp> +#include <com/sun/star/accessibility/XAccessible.hpp> +#include <com/sun/star/accessibility/XAccessibleContext.hpp> +#include <com/sun/star/accessibility/XAccessibleEditableText.hpp> +#include <com/sun/star/accessibility/XAccessibleMultiLineText.hpp> +#include <com/sun/star/accessibility/XAccessibleTextAttributes.hpp> +#include <com/sun/star/accessibility/XAccessibleEventBroadcaster.hpp> +#include <com/sun/star/accessibility/XAccessibleComponent.hpp> +#include <cppuhelper/basemutex.hxx> +#include <cppuhelper/compbase.hxx> +#include <comphelper/accessibletexthelper.hxx> +#include <rtl/ref.hxx> +#include <unotools/weakref.hxx> + +#include <unotools/accessiblerelationsethelper.hxx> +#include <queue> +#include <unordered_map> + +class TextEngine; +class TextView; + +namespace accessibility +{ + +class Document; + +class SfxListenerGuard +{ +public: + SfxListenerGuard(::SfxListener & rListener): + m_rListener(rListener), m_pNotifier(nullptr) {} + + ~SfxListenerGuard() { endListening(); } + + // Not thread safe: + void startListening(::SfxBroadcaster & rNotifier); + + // Not thread safe: + void endListening(); + +private: + ::SfxListener & m_rListener; + ::SfxBroadcaster * m_pNotifier; +}; + +class WindowListenerGuard +{ +public: + WindowListenerGuard(::Link<VclWindowEvent&,void> const & rListener): + m_aListener(rListener), m_pNotifier(nullptr) {} + + ~WindowListenerGuard() { endListening(); } + + // Not thread safe: + void startListening(vcl::Window & rNotifier); + + // Not thread safe: + void endListening(); + +private: + ::Link<VclWindowEvent&,void> m_aListener; + VclPtr<vcl::Window> m_pNotifier; +}; + +class Paragraph; + +class ParagraphInfo +{ +public: + ParagraphInfo(::sal_Int32 nHeight): m_nHeight(nHeight) {} + + unotools::WeakReference< Paragraph > const & + getParagraph() const { return m_xParagraph; } + + ::sal_Int32 getHeight() const { return m_nHeight; } + + void setParagraph( rtl::Reference< Paragraph > const & rParagraph) + { m_xParagraph = rParagraph.get(); } + + void changeHeight(::sal_Int32 nHeight) { m_nHeight = nHeight; } + +private: + unotools::WeakReference< Paragraph > m_xParagraph; + ::sal_Int32 m_nHeight; +}; + +typedef std::vector< ParagraphInfo > Paragraphs; + +typedef ::cppu::WeakComponentImplHelper< + css::accessibility::XAccessible, + css::accessibility::XAccessibleContext, + css::accessibility::XAccessibleComponent, + css::accessibility::XAccessibleEditableText, + css::accessibility::XAccessibleMultiLineText, + css::accessibility::XAccessibleTextAttributes, + css::accessibility::XAccessibleEventBroadcaster > ParagraphBase; + +// The Paragraph's number is the absolute position within the text engine (from +// 0 to N - 1), whereas the Paragraph's index is the position within the text +// view/accessible parent (from 0 to M - 1). Paragraphs outside the currently +// visible range have an index of -1. +class Paragraph final: + private cppu::BaseMutex, public ParagraphBase, private ::comphelper::OCommonAccessibleText +{ +public: + Paragraph(::rtl::Reference< Document > xDocument, + Paragraphs::size_type nNumber); + + // Not thread-safe. + Paragraphs::size_type getNumber() const { return m_nNumber; } + + // Not thread-safe. + void numberChanged(bool bIncremented); + + // Not thread-safe. + void textChanged(); + + // Thread-safe. + void notifyEvent(::sal_Int16 nEventId, css::uno::Any const & rOldValue, + css::uno::Any const & rNewValue); + +private: + // OCommonAccessibleText + virtual void implGetParagraphBoundary( const OUString& rText, + css::i18n::Boundary& rBoundary, + ::sal_Int32 nIndex ) override; + virtual void implGetLineBoundary( const OUString& rText, + css::i18n::Boundary& rBoundary, + ::sal_Int32 nIndex ) override; + + virtual css::uno::Reference< css::accessibility::XAccessibleContext > + SAL_CALL getAccessibleContext() override; + + virtual sal_Int64 SAL_CALL getAccessibleChildCount() override; + + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL + getAccessibleChild(sal_Int64 i) override; + + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL + getAccessibleParent() override; + + virtual sal_Int64 SAL_CALL getAccessibleIndexInParent() override; + + virtual ::sal_Int16 SAL_CALL getAccessibleRole() override; + + virtual OUString SAL_CALL getAccessibleDescription() override; + + virtual OUString SAL_CALL getAccessibleName() override; + + virtual + css::uno::Reference< css::accessibility::XAccessibleRelationSet > + SAL_CALL getAccessibleRelationSet() override; + + virtual sal_Int64 SAL_CALL getAccessibleStateSet() override; + + virtual css::lang::Locale SAL_CALL getLocale() override; + + virtual sal_Bool SAL_CALL containsPoint(css::awt::Point const & rPoint) override; + + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL + getAccessibleAtPoint(css::awt::Point const & rPoint) override; + + virtual css::awt::Rectangle SAL_CALL getBounds() override; + + virtual css::awt::Point SAL_CALL getLocation() override; + + virtual css::awt::Point SAL_CALL getLocationOnScreen() override; + + virtual css::awt::Size SAL_CALL getSize() override; + + virtual void SAL_CALL grabFocus() override; + + virtual sal_Int32 SAL_CALL getForeground() override; + + virtual sal_Int32 SAL_CALL getBackground() override; + + virtual ::sal_Int32 SAL_CALL getCaretPosition() override; + + virtual sal_Bool SAL_CALL setCaretPosition(::sal_Int32 nIndex) override; + + virtual ::sal_Unicode SAL_CALL getCharacter(::sal_Int32 nIndex) override; + + virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL + getCharacterAttributes(::sal_Int32 nIndex, const css::uno::Sequence< OUString >& aRequestedAttributes ) override; + + virtual css::awt::Rectangle SAL_CALL + getCharacterBounds(::sal_Int32 nIndex) override; + + virtual ::sal_Int32 SAL_CALL getCharacterCount() override; + + virtual ::sal_Int32 SAL_CALL + getIndexAtPoint(css::awt::Point const & rPoint) override; + + virtual OUString SAL_CALL getSelectedText() override; + + virtual ::sal_Int32 SAL_CALL getSelectionStart() override; + + virtual ::sal_Int32 SAL_CALL getSelectionEnd() override; + + virtual sal_Bool SAL_CALL setSelection(::sal_Int32 nStartIndex, + ::sal_Int32 nEndIndex) override; + + virtual sal_Bool SAL_CALL scrollSubstringTo( sal_Int32 nStartIndex, sal_Int32 nEndIndex, css::accessibility::AccessibleScrollType aScrollType) override; + + virtual OUString SAL_CALL getText() override; + + virtual OUString SAL_CALL getTextRange(::sal_Int32 nStartIndex, + ::sal_Int32 nEndIndex) override; + + virtual css::accessibility::TextSegment SAL_CALL getTextAtIndex( sal_Int32 nIndex, sal_Int16 aTextType ) override; + virtual css::accessibility::TextSegment SAL_CALL getTextBeforeIndex( sal_Int32 nIndex, sal_Int16 aTextType ) override; + virtual css::accessibility::TextSegment SAL_CALL getTextBehindIndex( sal_Int32 nIndex, sal_Int16 aTextType ) override; + + virtual sal_Bool SAL_CALL copyText(::sal_Int32 nStartIndex, + ::sal_Int32 nEndIndex) override; + + virtual sal_Bool SAL_CALL cutText(::sal_Int32 nStartIndex, + ::sal_Int32 nEndIndex) override; + + virtual sal_Bool SAL_CALL pasteText(::sal_Int32 nIndex) override; + + virtual sal_Bool SAL_CALL deleteText(::sal_Int32 nStartIndex, + ::sal_Int32 nEndIndex) override; + + virtual sal_Bool SAL_CALL insertText(OUString const & rText, + ::sal_Int32 nIndex) override; + + virtual sal_Bool SAL_CALL replaceText( + ::sal_Int32 nStartIndex, ::sal_Int32 nEndIndex, + OUString const & rReplacement) override; + + virtual sal_Bool SAL_CALL setAttributes( + ::sal_Int32 nStartIndex, ::sal_Int32 nEndIndex, + css::uno::Sequence< css::beans::PropertyValue > const & + rAttributeSet) override; + + virtual sal_Bool SAL_CALL setText(OUString const & rText) override; + + virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL + getDefaultAttributes(const css::uno::Sequence< OUString >& RequestedAttributes) override; + + virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL + getRunAttributes(::sal_Int32 Index, const css::uno::Sequence< OUString >& RequestedAttributes) override; + + virtual ::sal_Int32 SAL_CALL getLineNumberAtIndex( ::sal_Int32 nIndex ) override; + + virtual css::accessibility::TextSegment SAL_CALL getTextAtLineNumber( ::sal_Int32 nLineNo ) override; + + virtual css::accessibility::TextSegment SAL_CALL getTextAtLineWithCaret( ) override; + + virtual ::sal_Int32 SAL_CALL getNumberOfLineWithCaret( ) override; + + virtual void SAL_CALL addAccessibleEventListener( + css::uno::Reference< + css::accessibility::XAccessibleEventListener > const & rListener) override; + + virtual void SAL_CALL removeAccessibleEventListener( + css::uno::Reference< + css::accessibility::XAccessibleEventListener > const & rListener) override; + + virtual void SAL_CALL disposing() override; + + virtual OUString implGetText() override; + + virtual css::lang::Locale implGetLocale() override; + + virtual void implGetSelection(::sal_Int32 & rStartIndex, + ::sal_Int32 & rEndIndex) override; + + // Throws css::lang::DisposedException: + void checkDisposed(); + + ::rtl::Reference< Document > m_xDocument; + Paragraphs::size_type m_nNumber; + + /// client id in the AccessibleEventNotifier queue + sal_uInt32 m_nClientId; + + OUString m_aParagraphText; +}; + + +typedef std::unordered_map< OUString, + css::beans::PropertyValue > tPropValMap; + +class Document final : public ::VCLXAccessibleComponent, public ::SfxListener +{ +public: + Document(vcl::Window* pWindow, ::TextEngine & rEngine, ::TextView & rView); + + css::uno::Reference<css::accessibility::XAccessible> getAccessible() const; + + css::lang::Locale retrieveLocale(); + + // To make it possible for this method to be (indirectly) called from + // within Paragraph's constructor (i.e., when the Paragraph's ref count is + // still zero), pass a "Paragraph const *" instead of a + // "::rtl::Reference< Paragraph > const &". + ::sal_Int32 retrieveParagraphIndex(Paragraph const * pParagraph); + + // To make it possible for this method to be (indirectly) called from + // within Paragraph's constructor (i.e., when the Paragraph's ref count is + // still zero), pass a "Paragraph const *" instead of a + // "::rtl::Reference< Paragraph > const &". + ::sal_Int64 retrieveParagraphState(Paragraph const * pParagraph); + + // To make it possible for this method to be (indirectly) called from + // within Paragraph's constructor (i.e., when the Paragraph's ref count is + // still zero), pass a "Paragraph const &" instead of a + // "::rtl::Reference< Paragraph > const &". + css::awt::Rectangle + retrieveParagraphBounds(Paragraph const * pParagraph, bool bAbsolute); + + // To make it possible for this method to be (indirectly) called from + // within Paragraph's constructor (i.e., when the Paragraph's ref count is + // still zero), pass a "Paragraph const &" instead of a + // "::rtl::Reference< Paragraph > const &". + OUString retrieveParagraphText(Paragraph const * pParagraph); + + // To make it possible for this method to be (indirectly) called from + // within Paragraph's constructor (i.e., when the Paragraph's ref count is + // still zero), pass a "Paragraph const &" instead of a + // "::rtl::Reference< Paragraph > const &". + void retrieveParagraphSelection(Paragraph const * pParagraph, + ::sal_Int32 * pBegin, ::sal_Int32 * pEnd); + + // To make it possible for this method to be (indirectly) called from + // within Paragraph's constructor (i.e., when the Paragraph's ref count is + // still zero), pass a "Paragraph const *" instead of a + // "::rtl::Reference< Paragraph > const &". + ::sal_Int32 retrieveParagraphCaretPosition(Paragraph const * pParagraph); + + // To make it possible for this method to be (indirectly) called from + // within Paragraph's constructor (i.e., when the Paragraph's ref count is + // still zero), pass a "Paragraph const &" instead of a + // "::rtl::Reference< Paragraph > const &". + // Throws css::lang::IndexOutOfBoundsException. + css::awt::Rectangle + retrieveCharacterBounds(Paragraph const * pParagraph, + ::sal_Int32 nIndex); + + // To make it possible for this method to be (indirectly) called from + // within Paragraph's constructor (i.e., when the Paragraph's ref count is + // still zero), pass a "Paragraph const &" instead of a + // "::rtl::Reference< Paragraph > const &". + ::sal_Int32 retrieveCharacterIndex(Paragraph const * pParagraph, + css::awt::Point const & rPoint); + + // To make it possible for this method to be (indirectly) called from + // within Paragraph's constructor (i.e., when the Paragraph's ref count is + // still zero), pass a "Paragraph const &" instead of a + // "::rtl::Reference< Paragraph > const &". + // Throws css::lang::IndexOutOfBoundsException. + css::uno::Sequence< css::beans::PropertyValue > retrieveCharacterAttributes( + Paragraph const * pParagraph, ::sal_Int32 nIndex, + const css::uno::Sequence< OUString >& aRequestedAttributes); + + // To make it possible for this method to be (indirectly) called from + // within Paragraph's constructor (i.e., when the Paragraph's ref count is + // still zero), pass a "Paragraph const &" instead of a + // "::rtl::Reference< Paragraph > const &". + // Throws css::lang::IndexOutOfBoundsException. + css::uno::Sequence< css::beans::PropertyValue > retrieveRunAttributes( + Paragraph const * pParagraph, ::sal_Int32 Index, + const css::uno::Sequence< OUString >& RequestedAttributes); + + // To make it possible for this method to be (indirectly) called from + // within Paragraph's constructor (i.e., when the Paragraph's ref count is + // still zero), pass a "Paragraph const &" instead of a + // "::rtl::Reference< Paragraph > const &". + void changeParagraphText(Paragraph const * pParagraph, + OUString const & rText); + + // To make it possible for this method to be (indirectly) called from + // within Paragraph's constructor (i.e., when the Paragraph's ref count is + // still zero), pass a "Paragraph const &" instead of a + // "::rtl::Reference< Paragraph > const &". + // Throws css::lang::IndexOutOfBoundsException. + void changeParagraphText(Paragraph const * pParagraph, ::sal_Int32 nBegin, + ::sal_Int32 nEnd, bool bCut, bool bPaste, + OUString const & rText); + + // To make it possible for this method to be (indirectly) called from + // within Paragraph's constructor (i.e., when the Paragraph's ref count is + // still zero), pass a "Paragraph const &" instead of a + // "::rtl::Reference< Paragraph > const &". + // Throws css::lang::IndexOutOfBoundsException. + void copyParagraphText(Paragraph const * pParagraph, + ::sal_Int32 nBegin, ::sal_Int32 nEnd); + + // To make it possible for this method to be (indirectly) called from + // within Paragraph's constructor (i.e., when the Paragraph's ref count is + // still zero), pass a "Paragraph const &" instead of a + // "::rtl::Reference< Paragraph > const &". + // Throws css::lang::IndexOutOfBoundsException. + void changeParagraphAttributes( + Paragraph const * pParagraph, ::sal_Int32 nBegin, ::sal_Int32 nEnd, + css::uno::Sequence< css::beans::PropertyValue > const & + rAttributeSet); + + // To make it possible for this method to be (indirectly) called from + // within Paragraph's constructor (i.e., when the Paragraph's ref count is + // still zero), pass a "Paragraph const &" instead of a + // "::rtl::Reference< Paragraph > const &". + // Throws css::lang::IndexOutOfBoundsException. + void changeParagraphSelection(Paragraph const * pParagraph, + ::sal_Int32 nBegin, ::sal_Int32 nEnd); + + css::i18n::Boundary + retrieveParagraphLineBoundary( Paragraph const * pParagraph, + ::sal_Int32 nIndex, ::sal_Int32 *pLineNo); + + css::i18n::Boundary + retrieveParagraphBoundaryOfLine( Paragraph const * pParagraph, + ::sal_Int32 nIndex ); + + sal_Int32 retrieveParagraphLineWithCursor( Paragraph const * pParagraph ); + + css::uno::Reference< css::accessibility::XAccessibleRelationSet > + retrieveParagraphRelationSet( Paragraph const * pParagraph ); + +private: + virtual sal_Int64 SAL_CALL getAccessibleChildCount() override; + + virtual css::uno::Reference< css::accessibility::XAccessible > + SAL_CALL getAccessibleChild(sal_Int64 i) override; + + virtual ::sal_Int16 SAL_CALL getAccessibleRole() override; + + virtual css::uno::Reference< css::accessibility::XAccessible > + SAL_CALL getAccessibleAtPoint(css::awt::Point const & rPoint) override; + + virtual void FillAccessibleStateSet( sal_Int64& rStateSet ) override; + virtual void FillAccessibleRelationSet( utl::AccessibleRelationSetHelper& rRelationSet ) override; + + // ??? Will be called with both the external (Solar) and internal mutex + // locked: + virtual void SAL_CALL disposing() override; + + // ??? Will be called with the external (Solar) mutex locked. + virtual void Notify(::SfxBroadcaster & rBC, ::SfxHint const & rHint) override; + + // Assuming that this will only be called with the external (Solar) mutex + // locked. + DECL_LINK(WindowEventHandler, VclWindowEvent&, void); + + // Must be called with both the external (Solar) and internal mutex + // locked: + static ::rtl::Reference< Paragraph > + getParagraph(Paragraphs::iterator const & rIt); + + // Must be called with both the external (Solar) and internal mutex + // locked: + // Throws css::uno::RuntimeException. + css::uno::Reference< css::accessibility::XAccessible > + getAccessibleChild(Paragraphs::iterator const & rIt); + + // Must be called with both the external (Solar) and internal mutex + // locked: + void determineVisibleRange(); + + // Must be called with both the external (Solar) and internal mutex + // locked: + void notifyVisibleRangeChanges( + Paragraphs::iterator const & rOldVisibleBegin, + Paragraphs::iterator const & rOldVisibleEnd, + Paragraphs::iterator const & rInserted); + + // Must be called with both the external (Solar) and internal mutex + // locked: + void changeParagraphText(::sal_uInt32 nNumber, ::sal_uInt16 nBegin, ::sal_uInt16 nEnd, + bool bCut, bool bPaste, + OUString const & rText); + + void + handleParagraphNotifications(); + + void handleSelectionChangeNotification(); + + void sendEvent(::sal_Int32 start, ::sal_Int32 end, ::sal_Int16 nEventId); + + void disposeParagraphs(); + + static css::uno::Any mapFontColor(::Color const & rColor); + + static ::Color mapFontColor(css::uno::Any const & rColor); + + static css::uno::Any mapFontWeight(::FontWeight nWeight); + + static ::FontWeight mapFontWeight(css::uno::Any const & rWeight); + + void retrieveRunAttributesImpl( + Paragraph const * pParagraph, ::sal_Int32 Index, + const css::uno::Sequence< OUString >& RequestedAttributes, + tPropValMap& rRunAttrSeq); + + Paragraphs::iterator getIter(Paragraphs::size_type n) { return m_aParagraphs.begin() + std::min(n, m_aParagraphs.size()); } + Paragraphs::iterator visibleBegin() { return getIter(m_nVisibleBegin); } + Paragraphs::iterator visibleEnd() { return getIter(m_nVisibleEnd); } + Paragraphs::iterator focused() { return getIter(m_nFocused); } + + ::TextEngine & m_rEngine; + ::TextView & m_rView; + + SfxListenerGuard m_aEngineListener; + WindowListenerGuard m_aViewListener; + + Paragraphs m_aParagraphs; + + // m_nViewOffset is from the start of the document (0) to the start of the + // current view, and m_nViewHeight is the height of the view: + ::sal_Int32 m_nViewOffset; + ::sal_Int32 m_nViewHeight; + + // m_nVisibleBegin points to the first Paragraph that is (partially) + // contained in the view, and m_nVisibleEnd points past the last Paragraph + // that is (partially) contained. If no Paragraphs are (partially) in the + // view, both m_nVisibleBegin and m_nVisibleEnd are set to + // m_xParagraphs->size(). These values are only changed by + // determineVisibleRange. + Paragraphs::size_type m_nVisibleBegin = 0; + Paragraphs::size_type m_nVisibleEnd = 0; + + // m_nVisibleBeginOffset is from m_nViewOffset back to the start of the + // Paragraph pointed to by m_aVisibleBegin (and always has a non-negative + // value). If m_aVisibleBegin == m_xParagraphs->end(), + // m_nVisibleBeginOffset is set to 0. These values are only changed by + // determineVisibleRange. + ::sal_Int32 m_nVisibleBeginOffset; + + // If no selection has yet been set, all the following four variables are + // set to -1. m_nSelectionLastPara/Pos is also the cursor position. + ::sal_Int32 m_nSelectionFirstPara; + ::sal_Int32 m_nSelectionFirstPos; + ::sal_Int32 m_nSelectionLastPara; + ::sal_Int32 m_nSelectionLastPos; + + Paragraphs::size_type m_nFocused = 0; + + std::queue< ::TextHint > m_aParagraphNotifications; + bool m_bSelectionChangedNotification; + bool m_bInParagraphNotificationsHandler = false; +}; + +} + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/accessibility/vclxaccessiblebox.hxx b/vcl/inc/accessibility/vclxaccessiblebox.hxx new file mode 100644 index 000000000000..e5b360ecc9ae --- /dev/null +++ b/vcl/inc/accessibility/vclxaccessiblebox.hxx @@ -0,0 +1,151 @@ +/* -*- 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 <com/sun/star/accessibility/XAccessible.hpp> +#include <com/sun/star/accessibility/XAccessibleAction.hpp> +#include <com/sun/star/accessibility/XAccessibleKeyBinding.hpp> +#include <com/sun/star/accessibility/XAccessibleValue.hpp> +#include <cppuhelper/implbase.hxx> +#include <vcl/accessibility/vclxaccessiblecomponent.hxx> +#include <vcl/toolkit/lstbox.hxx> + +class VCLXAccessibleList; + +/** Base class for list- and combo boxes. This class manages the box' + children. The classed derived from this one have only to implement the + IsValid method and return the correct implementation name. +*/ +class VCLXAccessibleBox + : public cppu::ImplInheritanceHelper< + VCLXAccessibleComponent, + css::accessibility::XAccessible, + css::accessibility::XAccessibleValue, + css::accessibility::XAccessibleAction> +{ +public: + enum BoxType {COMBOBOX, LISTBOX}; + + /** The constructor is initialized with the box type which may be + either COMBOBOX or LISTBOX and a flag + indicating whether the box is a drop down box. + */ + VCLXAccessibleBox(vcl::Window* pBox, BoxType aType, bool bIsDropDownBox); + + + // XAccessible + + virtual css::uno::Reference< css::accessibility::XAccessibleContext > SAL_CALL + getAccessibleContext( ) override; + + // XAccessibleContext + + /** Each object has one or two children: an optional text field and the + actual list. The text field is not provided for non drop down list + boxes. + */ + sal_Int64 SAL_CALL getAccessibleChildCount() final override; + /** For drop down list boxes the text field is a not editable + VCLXAccessibleTextField, for combo boxes it is an + editable VCLXAccessibleEdit. + */ + css::uno::Reference< css::accessibility::XAccessible> SAL_CALL + getAccessibleChild (sal_Int64 i) override; + + sal_Int16 SAL_CALL getAccessibleRole() override; + + // XAccessibleAction + + /** There is one action for drop down boxes and none for others. + */ + virtual sal_Int32 SAL_CALL getAccessibleActionCount() final override; + /** The action for drop down boxes lets the user toggle the visibility of the + popup menu. + */ + virtual sal_Bool SAL_CALL doAccessibleAction (sal_Int32 nIndex) override; + /** The returned string is associated with resource + RID_STR_ACC_ACTION_TOGGLEPOPUP. + */ + virtual OUString SAL_CALL getAccessibleActionDescription (sal_Int32 nIndex) override; + /** No keybinding returned so far. + */ + virtual css::uno::Reference< css::accessibility::XAccessibleKeyBinding > SAL_CALL + getAccessibleActionKeyBinding( sal_Int32 nIndex ) override; + + // XAccessibleValue + + virtual css::uno::Any SAL_CALL getCurrentValue( ) override; + + virtual sal_Bool SAL_CALL setCurrentValue( + const css::uno::Any& aNumber ) override; + + virtual css::uno::Any SAL_CALL getMaximumValue( ) override; + + virtual css::uno::Any SAL_CALL getMinimumValue( ) override; + + virtual css::uno::Any SAL_CALL getMinimumIncrement( ) override; + +protected: + virtual ~VCLXAccessibleBox() override; + + /** Returns true when the object is valid. + */ + bool IsValid() const; + + virtual void ProcessWindowChildEvent (const VclWindowEvent& rVclWindowEvent) override; + virtual void ProcessWindowEvent (const VclWindowEvent& rVclWindowEvent) override; + + virtual void FillAccessibleStateSet( sal_Int64& rStateSet ) override; + + sal_Int64 implGetAccessibleChildCount(); + +private: + /** Specifies whether the box is a combo box or a list box. List boxes + have multi selection. + */ + BoxType m_aBoxType; + + /// Specifies whether the box is a drop down box and thus has an action. + bool m_bIsDropDownBox; + + /// The child that represents the text field if there is one. + css::uno::Reference< css::accessibility::XAccessible> + m_xText; + + /// The child that contains the items of this box. + rtl::Reference<VCLXAccessibleList> m_xList; + + /** This flag specifies whether an object has a text field as child + regardless of whether that child being currently instantiated or + not. + */ + bool m_bHasTextChild; + + /** This flag specifies whether an object has a list as child regardless + of whether that child being currently instantiated or not. This + flag is always true in the current implementation because the list + child is just another wrapper around this object and thus has the + same life time. + */ + bool m_bHasListChild; +}; + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/accessibility/vclxaccessiblebutton.hxx b/vcl/inc/accessibility/vclxaccessiblebutton.hxx new file mode 100644 index 000000000000..124d3ef6073d --- /dev/null +++ b/vcl/inc/accessibility/vclxaccessiblebutton.hxx @@ -0,0 +1,69 @@ +/* -*- 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 <accessibility/vclxaccessibletextcomponent.hxx> + +#include <com/sun/star/accessibility/XAccessibleAction.hpp> +#include <com/sun/star/accessibility/XAccessibleValue.hpp> + +#include <cppuhelper/implbase.hxx> +#include <vcl/toolkit/button.hxx> + + + + +class VCLXAccessibleButton final : public cppu::ImplInheritanceHelper< + VCLXAccessibleTextComponent, + css::accessibility::XAccessibleAction, + css::accessibility::XAccessibleValue> +{ + virtual ~VCLXAccessibleButton() override = default; + + virtual void ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) override; + virtual void FillAccessibleStateSet( sal_Int64& rStateSet ) override; + +public: + VCLXAccessibleButton(PushButton* pButton) + : ImplInheritanceHelper(pButton) {} + + // XServiceInfo + virtual OUString SAL_CALL getImplementationName() override; + virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; + + // XAccessibleContext + virtual OUString SAL_CALL getAccessibleName( ) override; + + // XAccessibleAction + virtual sal_Int32 SAL_CALL getAccessibleActionCount( ) override; + virtual sal_Bool SAL_CALL doAccessibleAction ( sal_Int32 nIndex ) override; + virtual OUString SAL_CALL getAccessibleActionDescription ( sal_Int32 nIndex ) override; + virtual css::uno::Reference< css::accessibility::XAccessibleKeyBinding > SAL_CALL getAccessibleActionKeyBinding( sal_Int32 nIndex ) override; + + // XAccessibleValue + virtual css::uno::Any SAL_CALL getCurrentValue( ) override; + virtual sal_Bool SAL_CALL setCurrentValue( const css::uno::Any& aNumber ) override; + virtual css::uno::Any SAL_CALL getMaximumValue( ) override; + virtual css::uno::Any SAL_CALL getMinimumValue( ) override; + virtual css::uno::Any SAL_CALL getMinimumIncrement( ) override; +}; + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/accessibility/vclxaccessiblecheckbox.hxx b/vcl/inc/accessibility/vclxaccessiblecheckbox.hxx new file mode 100644 index 000000000000..fa72c12f8f33 --- /dev/null +++ b/vcl/inc/accessibility/vclxaccessiblecheckbox.hxx @@ -0,0 +1,75 @@ +/* -*- 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 <accessibility/vclxaccessibletextcomponent.hxx> + +#include <com/sun/star/accessibility/XAccessibleAction.hpp> +#include <com/sun/star/accessibility/XAccessibleValue.hpp> + +#include <cppuhelper/implbase.hxx> +#include <vcl/toolkit/button.hxx> + + +class VCLXAccessibleCheckBox final : public cppu::ImplInheritanceHelper< + VCLXAccessibleTextComponent, + css::accessibility::XAccessibleAction, + css::accessibility::XAccessibleValue> +{ +private: + bool m_bChecked; + bool m_bIndeterminate; + + virtual ~VCLXAccessibleCheckBox() override = default; + + sal_Int32 implGetMaximumValue(); + + bool IsChecked() const; + bool IsIndeterminate() const; + + void SetChecked( bool bChecked ); + void SetIndeterminate( bool bIndeterminate ); + + virtual void ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) override; + virtual void FillAccessibleStateSet( sal_Int64& rStateSet ) override; + +public: + VCLXAccessibleCheckBox(CheckBox* pCheckBox); + + // XServiceInfo + virtual OUString SAL_CALL getImplementationName() override; + virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; + + // XAccessibleAction + virtual sal_Int32 SAL_CALL getAccessibleActionCount( ) override; + virtual sal_Bool SAL_CALL doAccessibleAction ( sal_Int32 nIndex ) override; + virtual OUString SAL_CALL getAccessibleActionDescription ( sal_Int32 nIndex ) override; + virtual css::uno::Reference< css::accessibility::XAccessibleKeyBinding > SAL_CALL getAccessibleActionKeyBinding( sal_Int32 nIndex ) override; + + // XAccessibleValue + virtual css::uno::Any SAL_CALL getCurrentValue( ) override; + virtual sal_Bool SAL_CALL setCurrentValue( const css::uno::Any& aNumber ) override; + virtual css::uno::Any SAL_CALL getMaximumValue( ) override; + virtual css::uno::Any SAL_CALL getMinimumValue( ) override; + virtual css::uno::Any SAL_CALL getMinimumIncrement( ) override; +}; + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/accessibility/vclxaccessiblecombobox.hxx b/vcl/inc/accessibility/vclxaccessiblecombobox.hxx new file mode 100644 index 000000000000..240874baeab3 --- /dev/null +++ b/vcl/inc/accessibility/vclxaccessiblecombobox.hxx @@ -0,0 +1,46 @@ +/* -*- 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 <accessibility/vclxaccessiblebox.hxx> + +#include <vcl/toolkit/combobox.hxx> + +/** The accessible combobox has two children. The first is the text field + represented by an object of the VCLXAccessibleEdit class. + The second is the list containing all items and is represented by an + object of the VCLXAccessibleList class which does not + support selection at the moment. +*/ +class VCLXAccessibleComboBox final : public VCLXAccessibleBox +{ +public: + VCLXAccessibleComboBox(ComboBox* pComboBox); + + // XServiceInfo + virtual OUString SAL_CALL getImplementationName() override; + // Return combo box specific services. + virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override; + +private: + virtual ~VCLXAccessibleComboBox() override = default; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/accessibility/vclxaccessibledropdowncombobox.hxx b/vcl/inc/accessibility/vclxaccessibledropdowncombobox.hxx new file mode 100644 index 000000000000..b2b0a9f5f7db --- /dev/null +++ b/vcl/inc/accessibility/vclxaccessibledropdowncombobox.hxx @@ -0,0 +1,49 @@ +/* -*- 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 <accessibility/vclxaccessiblebox.hxx> + +#include <vcl/toolkit/combobox.hxx> + +/** The accessible drop down combobox has two children. The first is the + text field represented by an object of the + VCLXAccessibleEdit class. The second is the list + containing all items and is represented by an object of the + VCLXAccessibleList class which does not support selection + at the moment. +*/ +class VCLXAccessibleDropDownComboBox final : public VCLXAccessibleBox +{ +public: + VCLXAccessibleDropDownComboBox(ComboBox* pComboBox); + + // XServiceInfo + virtual OUString SAL_CALL getImplementationName() override; + // Return drop down combo box specific services. + virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override; + +private: + virtual ~VCLXAccessibleDropDownComboBox() override = default; + + virtual void ProcessWindowEvent(const VclWindowEvent& rVclWindowEvent) override; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/accessibility/vclxaccessibledropdownlistbox.hxx b/vcl/inc/accessibility/vclxaccessibledropdownlistbox.hxx new file mode 100644 index 000000000000..ba046c3366a4 --- /dev/null +++ b/vcl/inc/accessibility/vclxaccessibledropdownlistbox.hxx @@ -0,0 +1,45 @@ +/* -*- 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 <accessibility/vclxaccessiblebox.hxx> + +/** The accessible drop down combobox has two children. The first is the + text field represented by an object of the + VCLXAccessibleTextField class which can not be edited. The + second is the list containing all items and is represented by an object + of the VCLXAccessibleListBoxList class which does support + selection. +*/ +class VCLXAccessibleDropDownListBox final : public VCLXAccessibleBox +{ +public: + VCLXAccessibleDropDownListBox(ListBox* pListBox); + + // XServiceInfo + virtual OUString SAL_CALL getImplementationName() override; + // Return drop down list box specific services. + virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override; + +private: + virtual ~VCLXAccessibleDropDownListBox() override = default; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/accessibility/vclxaccessibleedit.hxx b/vcl/inc/accessibility/vclxaccessibleedit.hxx new file mode 100644 index 000000000000..5ced34ebbd9c --- /dev/null +++ b/vcl/inc/accessibility/vclxaccessibleedit.hxx @@ -0,0 +1,109 @@ +/* -*- 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 <accessibility/vclxaccessibletextcomponent.hxx> +#include <com/sun/star/accessibility/AccessibleScrollType.hpp> +#include <com/sun/star/accessibility/XAccessibleEditableText.hpp> +#include <com/sun/star/accessibility/XAccessibleAction.hpp> + +#include <cppuhelper/implbase.hxx> +#include <vcl/toolkit/edit.hxx> + + +class VCLXAccessibleEdit : public cppu::ImplInheritanceHelper< + VCLXAccessibleTextComponent, + css::accessibility::XAccessibleAction, + css::accessibility::XAccessibleEditableText> +{ + friend class VCLXAccessibleBox; + +private: + sal_Int32 m_nCaretPosition; + +protected: + virtual ~VCLXAccessibleEdit() override = default; + + virtual void ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) override; + virtual void FillAccessibleStateSet( sal_Int64& rStateSet ) override; + sal_Int16 implGetAccessibleRole(); + + // OCommonAccessibleText + virtual OUString implGetText() override; + virtual void implGetSelection( sal_Int32& nStartIndex, sal_Int32& nEndIndex ) override; + + // VCLXAccessibleTextComponent + virtual bool PreferFullTextInTextChangedEvent() override; + +public: + VCLXAccessibleEdit(Edit* pEdit); + + // XServiceInfo + virtual OUString SAL_CALL getImplementationName() override; + virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; + + // XAccessibleContext + virtual sal_Int64 SAL_CALL getAccessibleChildCount( ) override; + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int64 i ) override; + virtual OUString SAL_CALL getAccessibleName() override; + virtual sal_Int16 SAL_CALL getAccessibleRole( ) override; + + // XAccessibleAction + virtual sal_Int32 SAL_CALL getAccessibleActionCount( ) override; + virtual sal_Bool SAL_CALL doAccessibleAction ( sal_Int32 nIndex ) override; + virtual OUString SAL_CALL getAccessibleActionDescription ( sal_Int32 nIndex ) override; + virtual css::uno::Reference< css::accessibility::XAccessibleKeyBinding > SAL_CALL getAccessibleActionKeyBinding( sal_Int32 nIndex ) override; + + // XAccessibleText + virtual sal_Int32 SAL_CALL getCaretPosition( ) override; + virtual sal_Bool SAL_CALL setCaretPosition( sal_Int32 nIndex ) override; + virtual sal_Unicode SAL_CALL getCharacter( sal_Int32 nIndex ) override; + virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL getCharacterAttributes( sal_Int32 nIndex, const css::uno::Sequence< OUString >& aRequestedAttributes ) override; + virtual css::awt::Rectangle SAL_CALL getCharacterBounds( sal_Int32 nIndex ) override; + virtual sal_Int32 SAL_CALL getCharacterCount( ) override; + virtual sal_Int32 SAL_CALL getIndexAtPoint( const css::awt::Point& aPoint ) override; + virtual OUString SAL_CALL getSelectedText( ) override; + virtual sal_Int32 SAL_CALL getSelectionStart( ) override; + virtual sal_Int32 SAL_CALL getSelectionEnd( ) override; + virtual sal_Bool SAL_CALL setSelection( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) override; + virtual OUString SAL_CALL getText( ) override; + virtual OUString SAL_CALL getTextRange( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) override; + virtual css::accessibility::TextSegment SAL_CALL getTextAtIndex( sal_Int32 nIndex, sal_Int16 aTextType ) override; + virtual css::accessibility::TextSegment SAL_CALL getTextBeforeIndex( sal_Int32 nIndex, sal_Int16 aTextType ) override; + virtual css::accessibility::TextSegment SAL_CALL getTextBehindIndex( sal_Int32 nIndex, sal_Int16 aTextType ) override; + virtual sal_Bool SAL_CALL copyText( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) override; + virtual sal_Bool SAL_CALL scrollSubstringTo( sal_Int32 nStartIndex, sal_Int32 nEndIndex, css::accessibility::AccessibleScrollType aScrollType) override; + + // XAccessibleEditableText + virtual sal_Bool SAL_CALL cutText( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) override; + virtual sal_Bool SAL_CALL pasteText( sal_Int32 nIndex ) override; + virtual sal_Bool SAL_CALL deleteText( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) override; + virtual sal_Bool SAL_CALL insertText( const OUString& sText, sal_Int32 nIndex ) override; + virtual sal_Bool SAL_CALL replaceText( sal_Int32 nStartIndex, sal_Int32 nEndIndex, const OUString& sReplacement ) override; + virtual sal_Bool SAL_CALL setAttributes( sal_Int32 nStartIndex, sal_Int32 nEndIndex, const css::uno::Sequence< css::beans::PropertyValue >& aAttributeSet ) override; + virtual sal_Bool SAL_CALL setText( const OUString& sText ) override; + +private: + bool isComboBoxChild(); + bool isEditable(); +}; + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/accessibility/vclxaccessiblefixedhyperlink.hxx b/vcl/inc/accessibility/vclxaccessiblefixedhyperlink.hxx new file mode 100644 index 000000000000..be3779248547 --- /dev/null +++ b/vcl/inc/accessibility/vclxaccessiblefixedhyperlink.hxx @@ -0,0 +1,36 @@ +/* -*- 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 <accessibility/vclxaccessibletextcomponent.hxx> + +class VCLXAccessibleFixedHyperlink final : public VCLXAccessibleTextComponent +{ + virtual ~VCLXAccessibleFixedHyperlink() override = default; + +public: + using VCLXAccessibleTextComponent::VCLXAccessibleTextComponent; + + // XServiceInfo + virtual OUString SAL_CALL getImplementationName() override; + virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/accessibility/vclxaccessiblefixedtext.hxx b/vcl/inc/accessibility/vclxaccessiblefixedtext.hxx new file mode 100644 index 000000000000..24b4add3f79c --- /dev/null +++ b/vcl/inc/accessibility/vclxaccessiblefixedtext.hxx @@ -0,0 +1,38 @@ +/* -*- 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 <accessibility/vclxaccessibletextcomponent.hxx> + +class VCLXAccessibleFixedText final : public VCLXAccessibleTextComponent +{ + virtual ~VCLXAccessibleFixedText() override = default; + + virtual void FillAccessibleStateSet(sal_Int64& rStateSet) override; + +public: + using VCLXAccessibleTextComponent::VCLXAccessibleTextComponent; + + // XServiceInfo + virtual OUString SAL_CALL getImplementationName() override; + virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/accessibility/vclxaccessibleheaderbar.hxx b/vcl/inc/accessibility/vclxaccessibleheaderbar.hxx new file mode 100644 index 000000000000..33ac4130e746 --- /dev/null +++ b/vcl/inc/accessibility/vclxaccessibleheaderbar.hxx @@ -0,0 +1,53 @@ +/* -*- 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/accessibility/vclxaccessiblecomponent.hxx> +#include <vcl/headbar.hxx> + +typedef std::vector<css::uno::WeakReference<css::accessibility::XAccessible>> ListItems; + +class VCLXAccessibleHeaderBar final : public VCLXAccessibleComponent +{ + VclPtr<HeaderBar> m_pHeadBar; + +public: + virtual ~VCLXAccessibleHeaderBar() override; + + VCLXAccessibleHeaderBar(HeaderBar* pHeaderBar); + + // XAccessibleContext + virtual sal_Int64 SAL_CALL getAccessibleChildCount() override; + virtual css::uno::Reference<css::accessibility::XAccessible> + SAL_CALL getAccessibleChild(sal_Int64 i) override; + virtual sal_Int16 SAL_CALL getAccessibleRole() override; + + // XServiceInfo + virtual OUString SAL_CALL getImplementationName() override; + virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override; + +public: + virtual void SAL_CALL disposing() override; + css::uno::Reference<css::accessibility::XAccessible> CreateChild(sal_Int32 i); + +private: + ListItems m_aAccessibleChildren; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/accessibility/vclxaccessibleheaderbaritem.hxx b/vcl/inc/accessibility/vclxaccessibleheaderbaritem.hxx new file mode 100644 index 000000000000..337a3db65845 --- /dev/null +++ b/vcl/inc/accessibility/vclxaccessibleheaderbaritem.hxx @@ -0,0 +1,87 @@ +/* -*- 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 <com/sun/star/accessibility/XAccessible.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <comphelper/accessiblecomponenthelper.hxx> +#include <cppuhelper/implbase.hxx> + +#include <vcl/vclptr.hxx> + +class HeaderBar; +class VclSimpleEvent; +class VclWindowEvent; + + +// ---------------------------------------------------- +// class VCLXAccessibleHeaderBarItem +// ---------------------------------------------------- + +class VCLXAccessibleHeaderBarItem final : public cppu::ImplInheritanceHelper< + comphelper::OAccessibleExtendedComponentHelper, + css::accessibility::XAccessible, + css::lang::XServiceInfo> +{ +private: + VclPtr<HeaderBar> m_pHeadBar; + sal_Int32 m_nIndexInParent; + + void FillAccessibleStateSet( sal_Int64& rStateSet ); + + // OCommonAccessibleComponent + virtual css::awt::Rectangle implGetBounds( ) override; + +public: + VCLXAccessibleHeaderBarItem( HeaderBar* pHeadBar, sal_Int32 _nIndexInParent ); + virtual ~VCLXAccessibleHeaderBarItem() override; + + // XServiceInfo + virtual OUString SAL_CALL getImplementationName() override; + virtual sal_Bool SAL_CALL supportsService( const OUString& rServiceName ) override; + virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; + + // XAccessible + virtual css::uno::Reference< css::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext( ) override; + + // XAccessibleContext + virtual sal_Int64 SAL_CALL getAccessibleChildCount( ) override; + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int64 i ) override; + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleParent( ) override; + virtual sal_Int64 SAL_CALL getAccessibleIndexInParent( ) override; + virtual sal_Int16 SAL_CALL getAccessibleRole( ) override; + virtual OUString SAL_CALL getAccessibleDescription( ) override; + virtual OUString SAL_CALL getAccessibleName( ) override; + virtual css::uno::Reference< css::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet( ) override; + virtual sal_Int64 SAL_CALL getAccessibleStateSet( ) override; + virtual css::lang::Locale SAL_CALL getLocale( ) override; + + // XAccessibleComponent + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint( const css::awt::Point& aPoint ) override; + virtual void SAL_CALL grabFocus( ) override {}; + virtual sal_Int32 SAL_CALL getForeground() override; + virtual sal_Int32 SAL_CALL getBackground() override; + + // XAccessibleExtendedComponent + virtual OUString SAL_CALL getTitledBorderText( ) override; + virtual OUString SAL_CALL getToolTipText( ) override; +}; + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/accessibility/vclxaccessiblelist.hxx b/vcl/inc/accessibility/vclxaccessiblelist.hxx new file mode 100644 index 000000000000..b0389c06692c --- /dev/null +++ b/vcl/inc/accessibility/vclxaccessiblelist.hxx @@ -0,0 +1,175 @@ +/* -*- 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 <memory> +#include <vector> +#include <com/sun/star/accessibility/XAccessibleSelection.hpp> +#include <cppuhelper/implbase.hxx> +#include <vcl/accessibility/vclxaccessiblecomponent.hxx> + +class VCLXAccessibleListItem; + +namespace accessibility +{ + class IComboListBoxHelper; +} + + +/** Base class for the list contained in list- and combo boxes. This class + does not support selection because lists of combo boxes give no direct + access to their underlying list implementation. Look into derived + classes for selection. +*/ +class VCLXAccessibleList final + : public cppu::ImplInheritanceHelper< + VCLXAccessibleComponent, + css::accessibility::XAccessible, + css::accessibility::XAccessibleSelection> +{ +public: + enum BoxType {COMBOBOX, LISTBOX}; + + VCLXAccessibleList(vcl::Window* pWindow, BoxType aBoxType, + const css::uno::Reference<css::accessibility::XAccessible>& _xParent); + + /** The index that is passed to this method is returned on following + calls to getAccessibleIndexInParent. + */ + void SetIndexInParent (sal_Int32 nIndex); + + /** Process some of the events and delegate the rest to the base classes. + */ + virtual void ProcessWindowEvent (const VclWindowEvent& rVclWindowEvent) override; + virtual void FillAccessibleRelationSet( utl::AccessibleRelationSetHelper& rRelationSet ) override; + + /** Called on reception of selection events this method checks all known + list items for a possible change in their selection state and + updates that accordingly. No accessibility events are sent because + the XAccessibleSelection interface is not supported and the items + are transient. + @param sTextOfSelectedItem + This string contains the text of the currently selected + item. It is used to retrieve the index of that item. + */ + void UpdateSelection (std::u16string_view sTextOfSelectedItem); + + // XAccessible + virtual css::uno::Reference< css::accessibility::XAccessibleContext> SAL_CALL + getAccessibleContext() override; + + // XAccessibleContext + virtual sal_Int64 SAL_CALL getAccessibleChildCount() override final; + css::uno::Reference< css::accessibility::XAccessible> SAL_CALL + getAccessibleChild (sal_Int64 i) override; + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL + getAccessibleParent( ) override; + + /** The index returned as index in parent is always the one set with the + SetIndexInParent() method. + */ + virtual sal_Int64 SAL_CALL getAccessibleIndexInParent() override; + virtual sal_Int16 SAL_CALL getAccessibleRole() override; + + // XServiceInfo + virtual OUString SAL_CALL getImplementationName() override; + // Return list specific services. + virtual css::uno::Sequence< OUString > SAL_CALL + getSupportedServiceNames() override; + + // XAccessibleSelection + virtual void SAL_CALL selectAccessibleChild( sal_Int64 nChildIndex ) override; + virtual sal_Bool SAL_CALL isAccessibleChildSelected( sal_Int64 nChildIndex ) override; + virtual void SAL_CALL clearAccessibleSelection( ) override; + virtual void SAL_CALL selectAllAccessibleChildren( ) override; + virtual sal_Int64 SAL_CALL getSelectedAccessibleChildCount( ) override; + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getSelectedAccessibleChild( sal_Int64 nSelectedChildIndex ) override; + virtual void SAL_CALL deselectAccessibleChild( sal_Int64 nSelectedChildIndex ) override; + + virtual css::awt::Point SAL_CALL getLocationOnScreen( ) override; + bool IsInDropDown() const; + void HandleDropOpen(); + void ProcessWindowEvent (const VclWindowEvent& rVclWindowEvent, bool b_IsDropDownList); + void UpdateSelection_Acc (std::u16string_view sTextOfSelectedItem, bool b_IsDropDownList); + void UpdateSelection_Impl_Acc (bool b_IsDropDownList); + + static void NotifyListItem(css::uno::Any const & val); + ::accessibility::IComboListBoxHelper* getListBoxHelper() { return m_pListBoxHelper.get(); } +private: + BoxType m_aBoxType; + std::unique_ptr<::accessibility::IComboListBoxHelper> m_pListBoxHelper; + std::vector<rtl::Reference<VCLXAccessibleListItem>> m_aAccessibleChildren; + sal_Int32 m_nVisibleLineCount; + /// Index in parent. This is settable from the outside. + sal_Int32 m_nIndexInParent; + sal_Int32 m_nLastTopEntry; + sal_Int32 m_nLastSelectedPos; + bool m_bDisableProcessEvent; + bool m_bVisible; + sal_Int32 m_nCurSelectedPos; + + + virtual ~VCLXAccessibleList() override = default; + + sal_Int64 implGetAccessibleChildCount(); + + /** This function is called from the implementation helper during a + XComponent::dispose call. Free the list of items and the items themselves. + */ + virtual void SAL_CALL disposing() override; + + void disposeChildren(); + + /** This method adds the states + AccessibleStateType::FOCUSABLE and possibly + AccessibleStateType::MULTI_SELECTABLE to the state set + of the base classes. + */ + virtual void FillAccessibleStateSet (sal_Int64& rStateSet) override; + + /** Create the specified child and insert it into the list of children. + Sets the child's states. + */ + rtl::Reference<VCLXAccessibleListItem> CreateChild (sal_Int32 i); + + /** Call this method when the item list has been changed, i.e. items + have been deleted or inserted. + */ + void HandleChangedItemList(); + + // VCLXAccessibleComponent + virtual css::awt::Rectangle implGetBounds( ) override; + + /** We need to save the accessible parent to return it in getAccessibleParent(), + because this method of the base class returns the wrong parent. + */ + css::uno::Reference< css::accessibility::XAccessible > m_xParent; + + void UpdateEntryRange_Impl(); + void UpdateSelection_Impl(sal_Int32 nPos = 0); + bool checkEntrySelected(sal_Int32 _nPos, + css::uno::Any& _rNewValue, + css::uno::Reference< css::accessibility::XAccessible >& _rxNewAcc); + void notifyVisibleStates(bool _bSetNew ); + void UpdateVisibleLineCount(); +}; + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/accessibility/vclxaccessiblelistbox.hxx b/vcl/inc/accessibility/vclxaccessiblelistbox.hxx new file mode 100644 index 000000000000..e29554288f9c --- /dev/null +++ b/vcl/inc/accessibility/vclxaccessiblelistbox.hxx @@ -0,0 +1,43 @@ +/* -*- 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 <accessibility/vclxaccessiblebox.hxx> + +/** The accessible drop down combobox has one children. It is the list + containing all items and is represented by an object of the + VCLXAccessibleListBoxList class which does support + selection. +*/ +class VCLXAccessibleListBox final : public VCLXAccessibleBox +{ +public: + VCLXAccessibleListBox(ListBox* pListBox); + + // XServiceInfo + virtual OUString SAL_CALL getImplementationName() override; + // Return list box specific services. + virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override; + +private: + virtual ~VCLXAccessibleListBox() override = default; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/accessibility/vclxaccessiblelistitem.hxx b/vcl/inc/accessibility/vclxaccessiblelistitem.hxx new file mode 100644 index 000000000000..b6b1e7e9cc47 --- /dev/null +++ b/vcl/inc/accessibility/vclxaccessiblelistitem.hxx @@ -0,0 +1,156 @@ +/* -*- 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 <com/sun/star/accessibility/AccessibleScrollType.hpp> +#include <com/sun/star/accessibility/XAccessible.hpp> +#include <com/sun/star/accessibility/XAccessibleComponent.hpp> +#include <com/sun/star/accessibility/XAccessibleContext.hpp> +#include <com/sun/star/accessibility/XAccessibleText.hpp> +#include <com/sun/star/accessibility/XAccessibleEventBroadcaster.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <comphelper/compbase.hxx> +#include <comphelper/accessibletexthelper.hxx> +#include <accessibility/vclxaccessiblelist.hxx> + +// forward --------------------------------------------------------------- + +namespace com::sun::star::awt { + struct Point; + struct Rectangle; + struct Size; + class XFocusListener; +} + +// class VCLXAccessibleListItem ------------------------------------------ + +typedef ::comphelper::WeakComponentImplHelper< css::accessibility::XAccessible + , css::accessibility::XAccessibleContext + , css::accessibility::XAccessibleComponent + , css::accessibility::XAccessibleEventBroadcaster + , css::accessibility::XAccessibleText + , css::lang::XServiceInfo > VCLXAccessibleListItem_BASE; + +/** the class OAccessibleListBoxEntry represents the base class for an accessible object of a listbox entry +*/ +class VCLXAccessibleListItem final : + public ::comphelper::OCommonAccessibleText, + public VCLXAccessibleListItem_BASE +{ +private: + OUString m_sEntryText; + sal_Int32 m_nIndexInParent; + bool m_bSelected; + bool m_bVisible; + + /// client id in the AccessibleEventNotifier queue + sal_uInt32 m_nClientId; + + rtl::Reference< VCLXAccessibleList > m_xParent; + + virtual ~VCLXAccessibleListItem() override = default; + /** this function is called upon disposing the component + */ + virtual void disposing(std::unique_lock<std::mutex>& rGuard) override; + + // OCommonAccessibleText + virtual OUString implGetText() override; + virtual css::lang::Locale implGetLocale() override; + virtual void implGetSelection( sal_Int32& nStartIndex, sal_Int32& nEndIndex ) override; + + OUString getTextRangeImpl(std::unique_lock<std::mutex>& rGuard, sal_Int32 nStartIndex, sal_Int32 nEndIndex); + +public: + /** OAccessibleBase needs a valid view + @param _nIndexInParent + is the position of the entry inside the listbox + @param _xParent + is our parent accessible object + */ + VCLXAccessibleListItem(sal_Int32 _nIndexInParent, + rtl::Reference< VCLXAccessibleList > _xParent); + + void NotifyAccessibleEvent( sal_Int16 _nEventId, const css::uno::Any& _aOldValue, const css::uno::Any& _aNewValue ); + + bool IsSelected() const { return m_bSelected; } + void SetSelected( bool _bSelected ); + void SetVisible( bool _bVisible ); + + // XTypeProvider + virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override; + + // XServiceInfo + virtual OUString SAL_CALL getImplementationName() override; + virtual sal_Bool SAL_CALL supportsService( const OUString& rServiceName ) override; + virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; + + // XAccessible + virtual css::uno::Reference< css::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext( ) override; + + // XAccessibleContext + virtual sal_Int64 SAL_CALL getAccessibleChildCount( ) override; + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int64 i ) override; + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleParent( ) override; + virtual sal_Int64 SAL_CALL getAccessibleIndexInParent( ) override; + virtual sal_Int16 SAL_CALL getAccessibleRole( ) override; + virtual OUString SAL_CALL getAccessibleDescription( ) override; + virtual OUString SAL_CALL getAccessibleName( ) override; + virtual css::uno::Reference< css::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet( ) override; + virtual sal_Int64 SAL_CALL getAccessibleStateSet( ) override; + virtual css::lang::Locale SAL_CALL getLocale( ) override; + + // XAccessibleComponent + virtual sal_Bool SAL_CALL containsPoint( const css::awt::Point& aPoint ) override; + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint( const css::awt::Point& aPoint ) override; + virtual css::awt::Rectangle SAL_CALL getBounds( ) override; + virtual css::awt::Point SAL_CALL getLocation( ) override; + virtual css::awt::Point SAL_CALL getLocationOnScreen( ) override; + virtual css::awt::Size SAL_CALL getSize( ) override; + virtual void SAL_CALL grabFocus( ) override; + virtual sal_Int32 SAL_CALL getForeground() override; + virtual sal_Int32 SAL_CALL getBackground() override; + + // XAccessibleText + virtual sal_Int32 SAL_CALL getCaretPosition() override; + virtual sal_Bool SAL_CALL setCaretPosition( sal_Int32 nIndex ) override; + virtual sal_Unicode SAL_CALL getCharacter( sal_Int32 nIndex ) override; + virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL getCharacterAttributes( sal_Int32 nIndex, const css::uno::Sequence< OUString >& aRequestedAttributes ) override; + virtual css::awt::Rectangle SAL_CALL getCharacterBounds( sal_Int32 nIndex ) override; + virtual sal_Int32 SAL_CALL getCharacterCount() override; + virtual sal_Int32 SAL_CALL getIndexAtPoint( const css::awt::Point& aPoint ) override; + virtual OUString SAL_CALL getSelectedText() override; + virtual sal_Int32 SAL_CALL getSelectionStart() override; + virtual sal_Int32 SAL_CALL getSelectionEnd() override; + virtual sal_Bool SAL_CALL setSelection( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) override; + virtual OUString SAL_CALL getText() override; + virtual OUString SAL_CALL getTextRange( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) override; + virtual css::accessibility::TextSegment SAL_CALL getTextAtIndex( sal_Int32 nIndex, sal_Int16 aTextType ) override; + virtual css::accessibility::TextSegment SAL_CALL getTextBeforeIndex( sal_Int32 nIndex, sal_Int16 aTextType ) override; + virtual css::accessibility::TextSegment SAL_CALL getTextBehindIndex( sal_Int32 nIndex, sal_Int16 aTextType ) override; + virtual sal_Bool SAL_CALL copyText( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) override; + virtual sal_Bool SAL_CALL scrollSubstringTo( sal_Int32 nStartIndex, sal_Int32 nEndIndex, css::accessibility::AccessibleScrollType aScrollType) override; + + // XAccessibleEventBroadcaster + virtual void SAL_CALL addAccessibleEventListener( const css::uno::Reference< css::accessibility::XAccessibleEventListener >& xListener ) override; + virtual void SAL_CALL removeAccessibleEventListener( const css::uno::Reference< css::accessibility::XAccessibleEventListener >& xListener ) override; +}; + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/accessibility/vclxaccessibleradiobutton.hxx b/vcl/inc/accessibility/vclxaccessibleradiobutton.hxx new file mode 100644 index 000000000000..34158f283a82 --- /dev/null +++ b/vcl/inc/accessibility/vclxaccessibleradiobutton.hxx @@ -0,0 +1,65 @@ +/* -*- 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 <accessibility/vclxaccessibletextcomponent.hxx> + +#include <com/sun/star/accessibility/XAccessibleAction.hpp> +#include <com/sun/star/accessibility/XAccessibleValue.hpp> + +#include <cppuhelper/implbase.hxx> +#include <vcl/toolkit/button.hxx> + + +class VCLXAccessibleRadioButton final : public cppu::ImplInheritanceHelper< + VCLXAccessibleTextComponent, + css::accessibility::XAccessibleAction, + css::accessibility::XAccessibleValue> +{ + virtual ~VCLXAccessibleRadioButton() override = default; + + virtual void ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) override; + virtual void FillAccessibleRelationSet( utl::AccessibleRelationSetHelper& rRelationSet ) override; + virtual void FillAccessibleStateSet( sal_Int64& rStateSet ) override; + +public: + VCLXAccessibleRadioButton(RadioButton* pRadioButton) + : ImplInheritanceHelper(pRadioButton) {} + + // XServiceInfo + virtual OUString SAL_CALL getImplementationName() override; + virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; + + // XAccessibleAction + virtual sal_Int32 SAL_CALL getAccessibleActionCount( ) override; + virtual sal_Bool SAL_CALL doAccessibleAction ( sal_Int32 nIndex ) override; + virtual OUString SAL_CALL getAccessibleActionDescription ( sal_Int32 nIndex ) override; + virtual css::uno::Reference< css::accessibility::XAccessibleKeyBinding > SAL_CALL getAccessibleActionKeyBinding( sal_Int32 nIndex ) override; + + // XAccessibleValue + virtual css::uno::Any SAL_CALL getCurrentValue( ) override; + virtual sal_Bool SAL_CALL setCurrentValue( const css::uno::Any& aNumber ) override; + virtual css::uno::Any SAL_CALL getMaximumValue( ) override; + virtual css::uno::Any SAL_CALL getMinimumValue( ) override; + virtual css::uno::Any SAL_CALL getMinimumIncrement( ) override; +}; + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/accessibility/vclxaccessiblescrollbar.hxx b/vcl/inc/accessibility/vclxaccessiblescrollbar.hxx new file mode 100644 index 000000000000..761ed2760627 --- /dev/null +++ b/vcl/inc/accessibility/vclxaccessiblescrollbar.hxx @@ -0,0 +1,70 @@ +/* -*- 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 <com/sun/star/accessibility/XAccessibleAction.hpp> +#include <com/sun/star/accessibility/XAccessibleValue.hpp> + +#include <cppuhelper/implbase.hxx> +#include <vcl/accessibility/vclxaccessiblecomponent.hxx> +#include <vcl/toolkit/scrbar.hxx> + + +class VCLXAccessibleScrollBar final : public cppu::ImplInheritanceHelper< + VCLXAccessibleComponent, + css::accessibility::XAccessibleAction, + css::accessibility::XAccessibleValue> +{ + virtual ~VCLXAccessibleScrollBar() override = default; + + virtual void ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) override; + virtual void FillAccessibleStateSet( sal_Int64& rStateSet ) override; + +public: + VCLXAccessibleScrollBar(ScrollBar* pScrollBar) + : ImplInheritanceHelper(pScrollBar) {} + + // XServiceInfo + virtual OUString SAL_CALL getImplementationName() override; + virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; + + // XAccessibleAction + virtual sal_Int32 SAL_CALL getAccessibleActionCount( ) override; + virtual sal_Bool SAL_CALL doAccessibleAction ( sal_Int32 nIndex ) override; + virtual OUString SAL_CALL getAccessibleActionDescription ( sal_Int32 nIndex ) override; + virtual css::uno::Reference< css::accessibility::XAccessibleKeyBinding > SAL_CALL getAccessibleActionKeyBinding( sal_Int32 nIndex ) override; + + // XAccessibleValue + virtual css::uno::Any SAL_CALL getCurrentValue( ) override; + virtual sal_Bool SAL_CALL setCurrentValue( const css::uno::Any& aNumber ) override; + virtual css::uno::Any SAL_CALL getMaximumValue( ) override; + virtual css::uno::Any SAL_CALL getMinimumValue( ) override; + virtual css::uno::Any SAL_CALL getMinimumIncrement( ) override; + + // XAccessibleContext + OUString SAL_CALL getAccessibleName( ) override; + +private: + sal_Int64 GetOrientationState() const; +}; + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/accessibility/vclxaccessiblestatusbar.hxx b/vcl/inc/accessibility/vclxaccessiblestatusbar.hxx new file mode 100644 index 000000000000..855795602842 --- /dev/null +++ b/vcl/inc/accessibility/vclxaccessiblestatusbar.hxx @@ -0,0 +1,68 @@ +/* -*- 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/accessibility/vclxaccessiblecomponent.hxx> +#include <vcl/status.hxx> +#include <vcl/vclptr.hxx> + +#include <vector> + + +class VCLXAccessibleStatusBarItem; + +class VCLXAccessibleStatusBar final : public VCLXAccessibleComponent +{ +private: + typedef std::vector< rtl::Reference< VCLXAccessibleStatusBarItem > > AccessibleChildren; + + AccessibleChildren m_aAccessibleChildren; + VclPtr<StatusBar> m_pStatusBar; + + void UpdateShowing( sal_Int32 i, bool bShowing ); + void UpdateItemName( sal_Int32 i ); + void UpdateItemText( sal_Int32 i ); + + void InsertChild( sal_Int32 i ); + void RemoveChild( sal_Int32 i ); + + virtual void ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) override; + + // XComponent + virtual void SAL_CALL disposing() override; + +public: + VCLXAccessibleStatusBar(vcl::Window* pWindow); + + // XServiceInfo + virtual OUString SAL_CALL getImplementationName() override; + virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; + + // XAccessibleContext + virtual sal_Int64 SAL_CALL getAccessibleChildCount( ) override; + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int64 i ) override; + + // XAccessibleComponent + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint( const css::awt::Point& aPoint ) override; +}; + + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/accessibility/vclxaccessiblestatusbaritem.hxx b/vcl/inc/accessibility/vclxaccessiblestatusbaritem.hxx new file mode 100644 index 000000000000..87bed611bf0a --- /dev/null +++ b/vcl/inc/accessibility/vclxaccessiblestatusbaritem.hxx @@ -0,0 +1,115 @@ +/* -*- 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 <com/sun/star/accessibility/AccessibleScrollType.hpp> +#include <com/sun/star/accessibility/XAccessible.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <comphelper/accessibletexthelper.hxx> +#include <cppuhelper/implbase.hxx> +#include <vcl/status.hxx> +#include <vcl/vclptr.hxx> + + +class VCLXAccessibleStatusBarItem final : public cppu::ImplInheritanceHelper< + comphelper::OAccessibleTextHelper, + css::accessibility::XAccessible, + css::lang::XServiceInfo> +{ + friend class VCLXAccessibleStatusBar; + +private: + VclPtr<StatusBar> m_pStatusBar; + sal_uInt16 m_nItemId; + OUString m_sItemName; + OUString m_sItemText; + bool m_bShowing; + + bool IsShowing(); + void SetShowing( bool bShowing ); + void SetItemName( const OUString& sItemName ); + OUString GetItemName(); + void SetItemText( const OUString& sItemText ); + OUString GetItemText(); + + void FillAccessibleStateSet( sal_Int64& rStateSet ); + + // OCommonAccessibleComponent + virtual css::awt::Rectangle implGetBounds( ) override; + + // OCommonAccessibleText + virtual OUString implGetText() override; + virtual css::lang::Locale implGetLocale() override; + virtual void implGetSelection( sal_Int32& nStartIndex, sal_Int32& nEndIndex ) override; + + // XComponent + virtual void SAL_CALL disposing() override; + +public: + VCLXAccessibleStatusBarItem( StatusBar* pStatusBar, sal_uInt16 nItemId ); + + // XServiceInfo + virtual OUString SAL_CALL getImplementationName() override; + virtual sal_Bool SAL_CALL supportsService( const OUString& rServiceName ) override; + virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; + + // XAccessible + virtual css::uno::Reference< css::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext( ) override; + + // XAccessibleContext + virtual sal_Int64 SAL_CALL getAccessibleChildCount( ) override; + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleChild(sal_Int64) override; + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleParent( ) override; + virtual sal_Int64 SAL_CALL getAccessibleIndexInParent( ) override; + virtual sal_Int16 SAL_CALL getAccessibleRole( ) override; + virtual OUString SAL_CALL getAccessibleDescription( ) override; + virtual OUString SAL_CALL getAccessibleName( ) override; + virtual css::uno::Reference< css::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet( ) override; + virtual sal_Int64 SAL_CALL getAccessibleStateSet( ) override; + virtual css::lang::Locale SAL_CALL getLocale( ) override; + + // XAccessibleComponent + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint( const css::awt::Point& aPoint ) override; + virtual void SAL_CALL grabFocus( ) override; + virtual sal_Int32 SAL_CALL getForeground( ) override; + virtual sal_Int32 SAL_CALL getBackground( ) override; + + // XAccessibleExtendedComponent + virtual OUString SAL_CALL getTitledBorderText( ) override; + virtual OUString SAL_CALL getToolTipText( ) override; + + // XAccessibleText + virtual sal_Int32 SAL_CALL getCaretPosition() override; + virtual sal_Bool SAL_CALL setCaretPosition( sal_Int32 nIndex ) override; + virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL getCharacterAttributes( sal_Int32 nIndex, const css::uno::Sequence< OUString >& aRequestedAttributes ) override; + virtual css::awt::Rectangle SAL_CALL getCharacterBounds( sal_Int32 nIndex ) override; + virtual sal_Int32 SAL_CALL getIndexAtPoint( const css::awt::Point& aPoint ) override; + virtual sal_Bool SAL_CALL setSelection( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) override; + virtual sal_Bool SAL_CALL copyText( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) override; + virtual OUString SAL_CALL getText() override; + virtual sal_Int32 SAL_CALL getCharacterCount() override; + virtual sal_Unicode SAL_CALL getCharacter( sal_Int32 nIndex ) override; + virtual OUString SAL_CALL getTextRange(sal_Int32 nStartIndex, sal_Int32 nEndIndex) override; + virtual sal_Bool SAL_CALL scrollSubstringTo( sal_Int32 nStartIndex, sal_Int32 nEndIndex, css::accessibility::AccessibleScrollType aScrollType) override; + +}; + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/accessibility/vclxaccessibletabcontrol.hxx b/vcl/inc/accessibility/vclxaccessibletabcontrol.hxx new file mode 100644 index 000000000000..5dfa69d3cd93 --- /dev/null +++ b/vcl/inc/accessibility/vclxaccessibletabcontrol.hxx @@ -0,0 +1,87 @@ +/* -*- 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 <com/sun/star/accessibility/XAccessibleSelection.hpp> +#include <cppuhelper/implbase.hxx> +#include <vcl/accessibility/vclxaccessiblecomponent.hxx> +#include <vcl/tabctrl.hxx> +#include <vcl/vclptr.hxx> + +#include <vector> + +class VCLXAccessibleTabPage; + + +class VCLXAccessibleTabControl final : public cppu::ImplInheritanceHelper< + VCLXAccessibleComponent, + css::accessibility::XAccessibleSelection> +{ +private: + typedef std::vector< rtl::Reference< VCLXAccessibleTabPage > > AccessibleChildren; + + AccessibleChildren m_aAccessibleChildren; + VclPtr<TabControl> m_pTabControl; + + css::uno::Reference< css::accessibility::XAccessible > implGetAccessibleChild( sal_Int64 i ); + bool implIsAccessibleChildSelected( sal_Int32 nChildIndex ); + + + void UpdateFocused(); + void UpdateSelected( sal_Int32 i, bool bSelected ); + void UpdatePageText( sal_Int32 i ); + void UpdateTabPage( sal_Int32 i, bool bNew ); + + void InsertChild( sal_Int32 i ); + void RemoveChild( sal_Int32 i ); + + virtual void ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) override; + virtual void ProcessWindowChildEvent( const VclWindowEvent& rVclWindowEvent ) override; + virtual void FillAccessibleStateSet( sal_Int64& rStateSet ) override; + + // XComponent + virtual void SAL_CALL disposing() override; + +public: + VCLXAccessibleTabControl(vcl::Window* pWindow); + + // XServiceInfo + virtual OUString SAL_CALL getImplementationName() override; + virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; + + // XAccessibleContext + virtual sal_Int64 SAL_CALL getAccessibleChildCount( ) override; + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int64 i ) override; + virtual sal_Int16 SAL_CALL getAccessibleRole( ) override; + virtual OUString SAL_CALL getAccessibleName( ) override; + + // XAccessibleSelection + virtual void SAL_CALL selectAccessibleChild( sal_Int64 nChildIndex ) override; + virtual sal_Bool SAL_CALL isAccessibleChildSelected( sal_Int64 nChildIndex ) override; + virtual void SAL_CALL clearAccessibleSelection( ) override; + virtual void SAL_CALL selectAllAccessibleChildren( ) override; + virtual sal_Int64 SAL_CALL getSelectedAccessibleChildCount( ) override; + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getSelectedAccessibleChild( sal_Int64 nSelectedChildIndex ) override; + virtual void SAL_CALL deselectAccessibleChild( sal_Int64 nChildIndex ) override; +}; + + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/accessibility/vclxaccessibletabpage.hxx b/vcl/inc/accessibility/vclxaccessibletabpage.hxx new file mode 100644 index 000000000000..fece8744721a --- /dev/null +++ b/vcl/inc/accessibility/vclxaccessibletabpage.hxx @@ -0,0 +1,124 @@ +/* -*- 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 <com/sun/star/accessibility/AccessibleScrollType.hpp> +#include <com/sun/star/accessibility/XAccessible.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <comphelper/accessibletexthelper.hxx> +#include <cppuhelper/implbase.hxx> +#include <vcl/vclptr.hxx> + + +class TabControl; + + +class VCLXAccessibleTabPage final : public cppu::ImplInheritanceHelper< + comphelper::OAccessibleTextHelper, + css::accessibility::XAccessible, + css::lang::XServiceInfo> +{ + friend class VCLXAccessibleTabControl; + +private: + VclPtr<TabControl> m_pTabControl; + sal_uInt16 m_nPageId; + bool m_bFocused; + bool m_bSelected; + OUString m_sPageText; + + sal_Int64 implGetAccessibleChildCount(); + + bool IsFocused() const; + bool IsSelected() const; + + void SetFocused( bool bFocused ); + void SetSelected( bool bSelected ); + void SetPageText( const OUString& sPageText ); + OUString GetPageText(); + + void Update( bool bNew ); + + sal_uInt16 GetPageId() const { return m_nPageId; } + + void FillAccessibleStateSet( sal_Int64& rStateSet ); + + // OCommonAccessibleComponent + virtual css::awt::Rectangle implGetBounds( ) override; + + // OCommonAccessibleText + virtual OUString implGetText() override; + virtual css::lang::Locale implGetLocale() override; + virtual void implGetSelection( sal_Int32& nStartIndex, sal_Int32& nEndIndex ) override; + + // XComponent + virtual void SAL_CALL disposing() override; + +public: + VCLXAccessibleTabPage( TabControl* pTabControl, sal_uInt16 nPageId ); + virtual ~VCLXAccessibleTabPage() override; + + // XServiceInfo + virtual OUString SAL_CALL getImplementationName() override; + virtual sal_Bool SAL_CALL supportsService( const OUString& rServiceName ) override; + virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; + + // XAccessible + virtual css::uno::Reference< css::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext( ) override; + + // XAccessibleContext + virtual sal_Int64 SAL_CALL getAccessibleChildCount( ) override; + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int64 i ) override; + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleParent( ) override; + virtual sal_Int64 SAL_CALL getAccessibleIndexInParent( ) override; + virtual sal_Int16 SAL_CALL getAccessibleRole( ) override; + virtual OUString SAL_CALL getAccessibleDescription( ) override; + virtual OUString SAL_CALL getAccessibleName( ) override; + virtual css::uno::Reference< css::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet( ) override; + virtual sal_Int64 SAL_CALL getAccessibleStateSet( ) override; + virtual css::lang::Locale SAL_CALL getLocale( ) override; + + // XAccessibleComponent + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint( const css::awt::Point& aPoint ) override; + virtual void SAL_CALL grabFocus( ) override; + virtual sal_Int32 SAL_CALL getForeground( ) override; + virtual sal_Int32 SAL_CALL getBackground( ) override; + + // XAccessibleExtendedComponent + virtual OUString SAL_CALL getTitledBorderText( ) override; + virtual OUString SAL_CALL getToolTipText( ) override; + + // XAccessibleText + virtual OUString SAL_CALL getText() override; + virtual sal_Unicode SAL_CALL getCharacter( sal_Int32 nIndex ) override; + virtual sal_Int32 SAL_CALL getCharacterCount() override; + virtual sal_Int32 SAL_CALL getCaretPosition() override; + virtual sal_Bool SAL_CALL setCaretPosition( sal_Int32 nIndex ) override; + virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL getCharacterAttributes( sal_Int32 nIndex, const css::uno::Sequence< OUString >& aRequestedAttributes ) override; + virtual css::awt::Rectangle SAL_CALL getCharacterBounds( sal_Int32 nIndex ) override; + virtual sal_Int32 SAL_CALL getIndexAtPoint( const css::awt::Point& aPoint ) override; + virtual sal_Bool SAL_CALL setSelection( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) override; + virtual sal_Bool SAL_CALL copyText( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) override; + virtual OUString SAL_CALL getTextRange(sal_Int32 nStartIndex, sal_Int32 nEndIndex) override; + virtual sal_Bool SAL_CALL scrollSubstringTo( sal_Int32 nStartIndex, sal_Int32 nEndIndex, css::accessibility::AccessibleScrollType aScrollType) override; +}; + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/accessibility/vclxaccessibletabpagewindow.hxx b/vcl/inc/accessibility/vclxaccessibletabpagewindow.hxx new file mode 100644 index 000000000000..3d7aa600e526 --- /dev/null +++ b/vcl/inc/accessibility/vclxaccessibletabpagewindow.hxx @@ -0,0 +1,53 @@ +/* -*- 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/accessibility/vclxaccessiblecomponent.hxx> +#include <vcl/tabctrl.hxx> +#include <vcl/tabpage.hxx> +#include <vcl/vclptr.hxx> + + + + +class VCLXAccessibleTabPageWindow final : public VCLXAccessibleComponent +{ +private: + VclPtr<TabControl> m_pTabControl; + VclPtr<TabPage> m_pTabPage; + sal_uInt16 m_nPageId; + + // OCommonAccessibleComponent + virtual css::awt::Rectangle implGetBounds( ) override; + + // XComponent + virtual void SAL_CALL disposing() override; + +public: + VCLXAccessibleTabPageWindow(vcl::Window* pWindow); + + // XAccessibleContext + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleParent( ) override; + virtual sal_Int64 SAL_CALL getAccessibleIndexInParent( ) override; +}; + + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/accessibility/vclxaccessibletextcomponent.hxx b/vcl/inc/accessibility/vclxaccessibletextcomponent.hxx new file mode 100644 index 000000000000..f8c9f99ba4ba --- /dev/null +++ b/vcl/inc/accessibility/vclxaccessibletextcomponent.hxx @@ -0,0 +1,84 @@ +/* -*- 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 <com/sun/star/accessibility/AccessibleScrollType.hpp> +#include <comphelper/accessibletexthelper.hxx> +#include <cppuhelper/implbase.hxx> +#include <vcl/accessibility/vclxaccessiblecomponent.hxx> + + + + +class VCLXAccessibleTextComponent : public cppu::ImplInheritanceHelper< + VCLXAccessibleComponent, + css::accessibility::XAccessibleText>, + public ::comphelper::OCommonAccessibleText +{ + OUString m_sText; + + // accessible name the object had when SetText was called last time + OUString m_sOldName; + +protected: + void SetText( const OUString& sText ); + + // Whether text segments for old/new value in AccessibleEventId::TEXT_CHANGED + // event should always include the whole old and new text instead of just + // the characters that changed between the two + virtual bool PreferFullTextInTextChangedEvent() { return false; }; + + virtual void ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) override; + + // OCommonAccessibleText + virtual OUString implGetText() override; + virtual css::lang::Locale implGetLocale() override; + virtual void implGetSelection( sal_Int32& nStartIndex, sal_Int32& nEndIndex ) override; + + // XComponent + virtual void SAL_CALL disposing() override; + +public: + VCLXAccessibleTextComponent(vcl::Window* pWindow); + + // XAccessibleText + virtual sal_Int32 SAL_CALL getCaretPosition() override; + virtual sal_Bool SAL_CALL setCaretPosition( sal_Int32 nIndex ) override; + virtual sal_Unicode SAL_CALL getCharacter( sal_Int32 nIndex ) override; + virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL getCharacterAttributes( sal_Int32 nIndex, const css::uno::Sequence< OUString >& aRequestedAttributes ) override; + virtual css::awt::Rectangle SAL_CALL getCharacterBounds( sal_Int32 nIndex ) override; + virtual sal_Int32 SAL_CALL getCharacterCount() override; + virtual sal_Int32 SAL_CALL getIndexAtPoint( const css::awt::Point& aPoint ) override; + virtual OUString SAL_CALL getSelectedText() override; + virtual sal_Int32 SAL_CALL getSelectionStart() override; + virtual sal_Int32 SAL_CALL getSelectionEnd() override; + virtual sal_Bool SAL_CALL setSelection( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) override; + virtual OUString SAL_CALL getText() override; + virtual OUString SAL_CALL getTextRange( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) override; + virtual css::accessibility::TextSegment SAL_CALL getTextAtIndex( sal_Int32 nIndex, sal_Int16 aTextType ) override; + virtual css::accessibility::TextSegment SAL_CALL getTextBeforeIndex( sal_Int32 nIndex, sal_Int16 aTextType ) override; + virtual css::accessibility::TextSegment SAL_CALL getTextBehindIndex( sal_Int32 nIndex, sal_Int16 aTextType ) override; + virtual sal_Bool SAL_CALL copyText( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) override; + virtual sal_Bool SAL_CALL scrollSubstringTo( sal_Int32 nStartIndex, sal_Int32 nEndIndex, css::accessibility::AccessibleScrollType aScrollType) override; +}; + + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/accessibility/vclxaccessibletextfield.hxx b/vcl/inc/accessibility/vclxaccessibletextfield.hxx new file mode 100644 index 000000000000..d441037b73ed --- /dev/null +++ b/vcl/inc/accessibility/vclxaccessibletextfield.hxx @@ -0,0 +1,72 @@ +/* -*- 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 <accessibility/vclxaccessibletextcomponent.hxx> + +#include <cppuhelper/implbase.hxx> + +/** This class represents non editable text fields. The object passed to + the constructor is expected to be a list (a ListBox to be + more specific). From this always the selected item is token to be made + accessible by this class. When the selected item changes then also the + exported text changes. +*/ +class VCLXAccessibleTextField final : + public cppu::ImplInheritanceHelper<VCLXAccessibleTextComponent, css::accessibility::XAccessible> +{ +public: + VCLXAccessibleTextField(vcl::Window* pWindow, + const css::uno::Reference<css::accessibility::XAccessible>& _xParent); + + // XAccessible + css::uno::Reference< css::accessibility::XAccessibleContext> SAL_CALL + getAccessibleContext() override; + + // XAccessibleContext + sal_Int64 SAL_CALL getAccessibleChildCount() override; + css::uno::Reference< css::accessibility::XAccessible> SAL_CALL + getAccessibleChild (sal_Int64 i) override; + sal_Int16 SAL_CALL getAccessibleRole() override; + css::uno::Reference< css::accessibility::XAccessible > SAL_CALL + getAccessibleParent( ) override; + + // XServiceInfo + virtual OUString SAL_CALL getImplementationName() override; + // Return text field specific services. + virtual css::uno::Sequence< OUString > SAL_CALL + getSupportedServiceNames() override; + +private: + virtual ~VCLXAccessibleTextField() override = default; + + /** With this method the text of the currently selected item is made + available to the VCLXAccessibleTextComponent base class. + */ + OUString implGetText() override; + + /** We need to save the accessible parent to return it in getAccessibleParent(), + because this method of the base class returns the wrong parent. + */ + css::uno::Reference< css::accessibility::XAccessible > m_xParent; +}; + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/accessibility/vclxaccessibletoolbox.hxx b/vcl/inc/accessibility/vclxaccessibletoolbox.hxx new file mode 100644 index 000000000000..da0090ef5f7c --- /dev/null +++ b/vcl/inc/accessibility/vclxaccessibletoolbox.hxx @@ -0,0 +1,94 @@ +/* -*- 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 <map> +#include <vcl/accessibility/vclxaccessiblecomponent.hxx> +#include <vcl/toolbox.hxx> +#include <com/sun/star/accessibility/XAccessibleSelection.hpp> +#include <cppuhelper/implbase.hxx> + + +class VCLXAccessibleToolBoxItem; +class ToolBox; + +typedef std::map< sal_Int32, rtl::Reference< VCLXAccessibleToolBoxItem > > ToolBoxItemsMap; + +class VCLXAccessibleToolBox final : public cppu::ImplInheritanceHelper<VCLXAccessibleComponent, css::accessibility::XAccessibleSelection> +{ +private: + ToolBoxItemsMap m_aAccessibleChildren; + + VCLXAccessibleToolBoxItem* GetItem_Impl( ToolBox::ImplToolItems::size_type _nPos ); + + void UpdateFocus_Impl(); + void ReleaseFocus_Impl( ToolBox::ImplToolItems::size_type _nPos ); + void UpdateChecked_Impl( ToolBox::ImplToolItems::size_type _nPos ); + void UpdateIndeterminate_Impl( ToolBox::ImplToolItems::size_type _nPos ); + void UpdateItem_Impl( ToolBox::ImplToolItems::size_type _nPos ); + void UpdateAllItems_Impl(); + void UpdateItemName_Impl( ToolBox::ImplToolItems::size_type _nPos ); + void UpdateItemEnabled_Impl( ToolBox::ImplToolItems::size_type _nPos ); + void UpdateCustomPopupItemp_Impl( vcl::Window* pWindow, bool bOpen ); + void HandleSubToolBarEvent( const VclWindowEvent& rVclWindowEvent ); + void ReleaseSubToolBox( ToolBox* _pSubToolBox ); + sal_Int64 implGetAccessibleChildCount(); + + virtual ~VCLXAccessibleToolBox() override; + + virtual void FillAccessibleStateSet( sal_Int64& rStateSet ) override; + virtual void ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent ) override; + virtual void ProcessWindowChildEvent( const VclWindowEvent& rVclWindowEvent ) override; + + virtual css::uno::Reference< css::accessibility::XAccessible > GetChildAccessible( const VclWindowEvent& rVclWindowEvent ) override; + css::uno::Reference< css::accessibility::XAccessible > GetItemWindowAccessible( const VclWindowEvent& rVclWindowEvent ); + + // XComponent + virtual void SAL_CALL disposing() override; + +public: + VCLXAccessibleToolBox(ToolBox* pToolBox); + + // XServiceInfo + virtual OUString SAL_CALL getImplementationName() override; + virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; + + // XAccessibleContext + virtual sal_Int64 SAL_CALL getAccessibleChildCount( ) override; + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int64 i ) override; + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint( const css::awt::Point& aPoint ) override; + + // XAccessibleSelection + virtual void SAL_CALL selectAccessibleChild( sal_Int64 nChildIndex ) override; + virtual sal_Bool SAL_CALL isAccessibleChildSelected( sal_Int64 nChildIndex ) override; + virtual void SAL_CALL clearAccessibleSelection( ) override; + virtual void SAL_CALL selectAllAccessibleChildren( ) override; + virtual sal_Int64 SAL_CALL getSelectedAccessibleChildCount( ) override; + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getSelectedAccessibleChild( sal_Int64 nSelectedChildIndex ) override; + virtual void SAL_CALL deselectAccessibleChild( sal_Int64 nChildIndex ) override; + +private: + void implReleaseToolboxItem( + ToolBoxItemsMap::iterator const & _rMapPos, + bool _bNotifyRemoval + ); +}; + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/accessibility/vclxaccessibletoolboxitem.hxx b/vcl/inc/accessibility/vclxaccessibletoolboxitem.hxx new file mode 100644 index 000000000000..e33e61eb568e --- /dev/null +++ b/vcl/inc/accessibility/vclxaccessibletoolboxitem.hxx @@ -0,0 +1,148 @@ +/* -*- 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 <com/sun/star/accessibility/AccessibleScrollType.hpp> +#include <com/sun/star/accessibility/XAccessible.hpp> +#include <com/sun/star/accessibility/XAccessibleAction.hpp> +#include <com/sun/star/accessibility/XAccessibleContext.hpp> +#include <com/sun/star/accessibility/XAccessibleValue.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <cppuhelper/implbase.hxx> +#include <comphelper/accessibletexthelper.hxx> +#include <vcl/toolbox.hxx> +#include <vcl/vclptr.hxx> + + +class VCLXAccessibleToolBoxItem final : public cppu::ImplInheritanceHelper< + comphelper::OAccessibleTextHelper, + css::accessibility::XAccessible, + css::accessibility::XAccessibleAction, + css::accessibility::XAccessibleValue, + css::lang::XServiceInfo> +{ +private: + OUString m_sOldName; + VclPtr<ToolBox> m_pToolBox; + sal_Int32 m_nIndexInParent; + sal_Int16 m_nRole; + ToolBoxItemId m_nItemId; + bool m_bHasFocus; + bool m_bIsChecked; + bool m_bIndeterminate; + + css::uno::Reference< css::accessibility::XAccessible > m_xChild; + +public: + sal_Int32 getIndexInParent() const { return m_nIndexInParent; } + void setIndexInParent( sal_Int32 _nNewIndex ) { m_nIndexInParent = _nNewIndex; } + +private: + OUString implGetAccessibleName(); + + virtual ~VCLXAccessibleToolBoxItem() override; + + virtual void SAL_CALL disposing() override; + + /// implements the calculation of the bounding rectangle + virtual css::awt::Rectangle implGetBounds( ) override; + + // OCommonAccessibleText + virtual OUString implGetText() override; + virtual css::lang::Locale implGetLocale() override; + virtual void implGetSelection( sal_Int32& nStartIndex, sal_Int32& nEndIndex ) override; + +public: + VCLXAccessibleToolBoxItem( ToolBox* _pToolBox, sal_Int32 _nPos ); + + void SetFocus( bool _bFocus ); + bool HasFocus() const { return m_bHasFocus; } + void SetChecked( bool _bCheck ); + void SetIndeterminate( bool _bIndeterminate ); + void ReleaseToolBox() { m_pToolBox = nullptr; } + void NameChanged(); + void SetChild( const css::uno::Reference< css::accessibility::XAccessible >& _xChild ); + const css::uno::Reference< css::accessibility::XAccessible >& + GetChild() const { return m_xChild; } + void NotifyChildEvent( const css::uno::Reference< css::accessibility::XAccessible >& _xChild, bool _bShow ); + + void ToggleEnableState(); + + // XInterface + css::uno::Any SAL_CALL queryInterface(css::uno::Type const & aType) override; + + // XServiceInfo + virtual OUString SAL_CALL getImplementationName() override; + virtual sal_Bool SAL_CALL supportsService( const OUString& rServiceName ) override; + virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; + + // XAccessible + virtual css::uno::Reference< css::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext( ) override; + + // XAccessibleContext + virtual sal_Int64 SAL_CALL getAccessibleChildCount( ) override; + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int64 i ) override; + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleParent( ) override; + virtual sal_Int64 SAL_CALL getAccessibleIndexInParent( ) override; + virtual sal_Int16 SAL_CALL getAccessibleRole( ) override; + virtual OUString SAL_CALL getAccessibleDescription( ) override; + virtual OUString SAL_CALL getAccessibleName( ) override; + virtual css::uno::Reference< css::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet( ) override; + virtual sal_Int64 SAL_CALL getAccessibleStateSet( ) override; + + // XAccessibleText + virtual OUString SAL_CALL getText() override; + virtual sal_Unicode SAL_CALL getCharacter( sal_Int32 nIndex ) override; + virtual sal_Int32 SAL_CALL getCharacterCount() override; + virtual sal_Int32 SAL_CALL getCaretPosition() override; + virtual sal_Bool SAL_CALL setCaretPosition( sal_Int32 nIndex ) override; + virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL getCharacterAttributes( sal_Int32 nIndex, const css::uno::Sequence< OUString >& aRequestedAttributes ) override; + virtual css::awt::Rectangle SAL_CALL getCharacterBounds( sal_Int32 nIndex ) override; + virtual sal_Int32 SAL_CALL getIndexAtPoint( const css::awt::Point& aPoint ) override; + virtual sal_Bool SAL_CALL setSelection( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) override; + virtual sal_Bool SAL_CALL copyText( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) override; + virtual OUString SAL_CALL getTextRange( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) override; + virtual sal_Bool SAL_CALL scrollSubstringTo( sal_Int32 nStartIndex, sal_Int32 nEndIndex, css::accessibility::AccessibleScrollType aScrollType) override; + + // XAccessibleComponent + virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint( const css::awt::Point& aPoint ) override; + virtual void SAL_CALL grabFocus( ) override; + virtual sal_Int32 SAL_CALL getForeground( ) override; + virtual sal_Int32 SAL_CALL getBackground( ) override; + + // XAccessibleExtendedComponent + virtual OUString SAL_CALL getTitledBorderText( ) override; + virtual OUString SAL_CALL getToolTipText( ) override; + + // XAccessibleAction + virtual sal_Int32 SAL_CALL getAccessibleActionCount( ) override; + virtual sal_Bool SAL_CALL doAccessibleAction ( sal_Int32 nIndex ) override; + virtual OUString SAL_CALL getAccessibleActionDescription ( sal_Int32 nIndex ) override; + virtual css::uno::Reference< css::accessibility::XAccessibleKeyBinding > SAL_CALL getAccessibleActionKeyBinding( sal_Int32 nIndex ) override; + + // XAccessibleValue + virtual css::uno::Any SAL_CALL getCurrentValue( ) override; + virtual sal_Bool SAL_CALL setCurrentValue( const css::uno::Any& aNumber ) override; + virtual css::uno::Any SAL_CALL getMaximumValue( ) override; + virtual css::uno::Any SAL_CALL getMinimumValue( ) override; + virtual css::uno::Any SAL_CALL getMinimumIncrement( ) override; +}; + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |