Avoid potential negative array index access to cached text.
[LibreOffice.git] / accessibility / inc / extended / AccessibleGridControlHeader.hxx
blob7e1c3e7ab26b4166fb5afd14cd0770e5236e8ece
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #pragma once
23 #include <extended/AccessibleGridControlTableBase.hxx>
25 namespace accessibility {
27 /** This class represents the accessible object of a header bar of a Grid Control
28 (row or column header bar). This object supports the
29 XAccessibleSelection interface. Selecting a child of this object selects
30 complete rows or columns of the data table. */
31 class AccessibleGridControlHeader final : public AccessibleGridControlTableBase
33 public:
34 /** @param rxParent accessible parent control
35 @param rTable accessible table
36 @param eObjType One of the two allowed types AccessibleTableControlObjType::ROWHEADERBAR or
37 AccessibleTableControlObjType::COLUMNHEADERBAR. */
38 AccessibleGridControlHeader(
39 const css::uno::Reference<
40 css::accessibility::XAccessible >& rxParent,
41 ::vcl::table::IAccessibleTable& rTable,
42 ::vcl::table::AccessibleTableControlObjType eObjType );
44 private:
45 virtual ~AccessibleGridControlHeader() override = default;
47 public:
48 // XAccessibleContext
50 /** @return
51 The XAccessible interface of the specified child.
53 virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL
54 getAccessibleChild( sal_Int64 nChildIndex ) override;
56 /** @return The index of this object among the parent's children. */
57 virtual sal_Int64 SAL_CALL getAccessibleIndexInParent() override;
59 // XAccessibleComponent
61 /** @return The accessible child rendered under the given point. */
62 virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL
63 getAccessibleAtPoint( const css::awt::Point& rPoint ) override;
65 /** Grabs the focus to (the current cell of) the data table. */
66 virtual void SAL_CALL grabFocus() override;
68 // XAccessibleTable
70 /** @return The description text of the specified row. */
71 virtual OUString SAL_CALL
72 getAccessibleRowDescription( sal_Int32 nRow ) override;
74 /** @return The description text of the specified column. */
75 virtual OUString SAL_CALL
76 getAccessibleColumnDescription( sal_Int32 nColumn ) override;
78 /** @return The XAccessibleTable interface of the row header bar. */
79 virtual css::uno::Reference< css::accessibility::XAccessibleTable > SAL_CALL
80 getAccessibleRowHeaders() override;
82 /** @return The XAccessibleTable interface of the column header bar. */
83 virtual css::uno::Reference< css::accessibility::XAccessibleTable > SAL_CALL
84 getAccessibleColumnHeaders() override;
86 /** @return An index list of completely selected rows. */
87 virtual css::uno::Sequence< sal_Int32 > SAL_CALL
88 getSelectedAccessibleRows() override;
90 /** @return An index list of completely selected columns. */
91 virtual css::uno::Sequence< sal_Int32 > SAL_CALL
92 getSelectedAccessibleColumns() override;
94 /** @return TRUE, if the specified row is completely selected. */
95 virtual sal_Bool SAL_CALL isAccessibleRowSelected( sal_Int32 nRow ) override;
97 /** @return TRUE, if the specified column is completely selected. */
98 virtual sal_Bool SAL_CALL isAccessibleColumnSelected( sal_Int32 nColumn ) override;
100 /** @return The XAccessible interface of the cell object at the specified
101 cell position. */
102 virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL
103 getAccessibleCellAt( sal_Int32 nRow, sal_Int32 nColumn ) override;
105 /** @return TRUE, if the specified cell is selected. */
106 virtual sal_Bool SAL_CALL isAccessibleSelected( sal_Int32 nRow, sal_Int32 nColumn ) override;
108 // XServiceInfo
110 /** @return The name of this class. */
111 virtual OUString SAL_CALL getImplementationName() override;
113 /** @return a unique implementation ID. */
114 virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override;
116 private:
117 /** Returns the specified row or column. Uses one of the parameters,
118 depending on object type.
119 @attention This method requires locked mutex's and a living object.
120 @return The XAccessible interface of the specified column/row. */
121 css::uno::Reference< css::accessibility::XAccessible >
122 implGetChild( sal_Int32 nRow, sal_uInt32 nColumnPos );
123 /** @attention This method requires locked mutex's and a living object.
124 @return The bounding box (VCL rect.) relative to the parent window. */
125 virtual tools::Rectangle implGetBoundingBox() override;
126 /** @attention This method requires locked mutex's and a living object.
127 @return The bounding box (VCL rect.) in screen coordinates. */
128 virtual AbsoluteScreenPixelRectangle implGetBoundingBoxOnScreen() override;
130 // internal helper methods
132 /** @return TRUE, if the objects is a header bar for rows. */
133 inline bool isRowBar() const;
134 /** @return TRUE, if the objects is a header bar for columns. */
135 inline bool isColumnBar() const;
138 // inlines
140 inline bool AccessibleGridControlHeader::isRowBar() const
142 return getType() == ::vcl::table::AccessibleTableControlObjType::ROWHEADERBAR;
145 inline bool AccessibleGridControlHeader::isColumnBar() const
147 return getType() == ::vcl::table::AccessibleTableControlObjType::COLUMNHEADERBAR;
151 } // namespace accessibility
155 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */