diff options
Diffstat (limited to 'toolkit/inc/controls')
7 files changed, 1233 insertions, 0 deletions
diff --git a/toolkit/inc/controls/table/AccessibleGridControl.hxx b/toolkit/inc/controls/table/AccessibleGridControl.hxx new file mode 100644 index 000000000000..11c08ea321d8 --- /dev/null +++ b/toolkit/inc/controls/table/AccessibleGridControl.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 "AccessibleGridControlBase.hxx" +#include "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/toolkit/inc/controls/table/AccessibleGridControlBase.hxx b/toolkit/inc/controls/table/AccessibleGridControlBase.hxx new file mode 100644 index 000000000000..4e30bddda541 --- /dev/null +++ b/toolkit/inc/controls/table/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/toolkit/inc/controls/table/AccessibleGridControlHeader.hxx b/toolkit/inc/controls/table/AccessibleGridControlHeader.hxx new file mode 100644 index 000000000000..f993907b85a0 --- /dev/null +++ b/toolkit/inc/controls/table/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 <controls/table/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/toolkit/inc/controls/table/AccessibleGridControlHeaderCell.hxx b/toolkit/inc/controls/table/AccessibleGridControlHeaderCell.hxx new file mode 100644 index 000000000000..8f3022807e13 --- /dev/null +++ b/toolkit/inc/controls/table/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 <controls/table/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/toolkit/inc/controls/table/AccessibleGridControlTable.hxx b/toolkit/inc/controls/table/AccessibleGridControlTable.hxx new file mode 100644 index 000000000000..c2da21496119 --- /dev/null +++ b/toolkit/inc/controls/table/AccessibleGridControlTable.hxx @@ -0,0 +1,173 @@ +/* -*- 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 <controls/table/AccessibleGridControlTableBase.hxx> +#include <controls/table/AccessibleGridControlTableCell.hxx> + +#include <cppuhelper/implbase1.hxx> +#include <com/sun/star/accessibility/XAccessibleSelection.hpp> + + +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/toolkit/inc/controls/table/AccessibleGridControlTableBase.hxx b/toolkit/inc/controls/table/AccessibleGridControlTableBase.hxx new file mode 100644 index 000000000000..2da1b6c007a0 --- /dev/null +++ b/toolkit/inc/controls/table/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 <controls/table/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/toolkit/inc/controls/table/AccessibleGridControlTableCell.hxx b/toolkit/inc/controls/table/AccessibleGridControlTableCell.hxx new file mode 100644 index 000000000000..0cf3738b9a79 --- /dev/null +++ b/toolkit/inc/controls/table/AccessibleGridControlTableCell.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 <controls/table/AccessibleGridControlBase.hxx> + +#include <comphelper/accessibletexthelper.hxx> +#include <cppuhelper/implbase2.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: */ |