1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
20 #ifndef INCLUDED_SVX_INC_ACCESSIBLETABLESHAPE_HXX
21 #define INCLUDED_SVX_INC_ACCESSIBLETABLESHAPE_HXX
23 #include <com/sun/star/accessibility/XAccessibleTable.hpp>
25 #include <rtl/ref.hxx>
27 #include <cppuhelper/implbase.hxx>
29 #include <svx/AccessibleShape.hxx>
30 #include <com/sun/star/view/XSelectionChangeListener.hpp>
31 #include <com/sun/star/accessibility/XAccessibleTableSelection.hpp>
33 namespace sdr::table
{ class SvxTableController
; }
35 namespace accessibility
37 class AccessibleTableShapeImpl
;
40 typedef ::cppu::ImplInheritanceHelper
< AccessibleShape
,
41 css::accessibility::XAccessibleTable
,
42 css::view::XSelectionChangeListener
43 > AccessibleTableShape_Base
;
44 class AccessibleTableShape final
: public AccessibleTableShape_Base
, public css::accessibility::XAccessibleTableSelection
46 sal_Int32 mnPreviousSelectionCount
;
48 AccessibleTableShape( const AccessibleShapeInfo
& rShapeInfo
, const AccessibleShapeTreeInfo
& rShapeTreeInfo
);
49 virtual ~AccessibleTableShape( ) override
;
50 AccessibleTableShape(const AccessibleTableShape
&) = delete;
51 AccessibleTableShape
& operator=(const AccessibleTableShape
&) = delete;
53 virtual void Init() override
;
56 virtual css::uno::Any SAL_CALL
queryInterface( const css::uno::Type
& aType
) override
;
57 virtual void SAL_CALL
acquire( ) noexcept override
;
58 virtual void SAL_CALL
release( ) noexcept override
;
61 virtual sal_Int32 SAL_CALL
getAccessibleChildCount( ) override
;
62 virtual css::uno::Reference
< css::accessibility::XAccessible
> SAL_CALL
getAccessibleChild( sal_Int32 i
) override
;
63 virtual sal_Int16 SAL_CALL
getAccessibleRole() override
;
66 virtual sal_Int32 SAL_CALL
getAccessibleRowCount() override
;
67 virtual sal_Int32 SAL_CALL
getAccessibleColumnCount( ) override
;
68 virtual OUString SAL_CALL
getAccessibleRowDescription( sal_Int32 nRow
) override
;
69 virtual OUString SAL_CALL
getAccessibleColumnDescription( sal_Int32 nColumn
) override
;
70 virtual sal_Int32 SAL_CALL
getAccessibleRowExtentAt( sal_Int32 nRow
, sal_Int32 nColumn
) override
;
71 virtual sal_Int32 SAL_CALL
getAccessibleColumnExtentAt( sal_Int32 nRow
, sal_Int32 nColumn
) override
;
72 virtual css::uno::Reference
< css::accessibility::XAccessibleTable
> SAL_CALL
getAccessibleRowHeaders( ) override
;
73 virtual css::uno::Reference
< css::accessibility::XAccessibleTable
> SAL_CALL
getAccessibleColumnHeaders( ) override
;
74 virtual css::uno::Sequence
< sal_Int32
> SAL_CALL
getSelectedAccessibleRows( ) override
;
75 virtual css::uno::Sequence
< sal_Int32
> SAL_CALL
getSelectedAccessibleColumns( ) override
;
76 virtual sal_Bool SAL_CALL
isAccessibleRowSelected( sal_Int32 nRow
) override
;
77 virtual sal_Bool SAL_CALL
isAccessibleColumnSelected( sal_Int32 nColumn
) override
;
78 virtual css::uno::Reference
< css::accessibility::XAccessible
> SAL_CALL
getAccessibleCellAt( sal_Int32 nRow
, sal_Int32 nColumn
) override
;
79 virtual css::uno::Reference
< css::accessibility::XAccessible
> SAL_CALL
getAccessibleCaption( ) override
;
80 virtual css::uno::Reference
< css::accessibility::XAccessible
> SAL_CALL
getAccessibleSummary( ) override
;
81 virtual sal_Bool SAL_CALL
isAccessibleSelected( sal_Int32 nRow
, sal_Int32 nColumn
) override
;
82 virtual sal_Int32 SAL_CALL
getAccessibleIndex( sal_Int32 nRow
, sal_Int32 nColumn
) override
;
83 virtual sal_Int32 SAL_CALL
getAccessibleRow( sal_Int32 nChildIndex
) override
;
84 virtual sal_Int32 SAL_CALL
getAccessibleColumn( sal_Int32 nChildIndex
) override
;
86 // XAccessibleSelection
87 virtual void SAL_CALL
selectAccessibleChild( sal_Int32 nChildIndex
) override
;
88 virtual sal_Bool SAL_CALL
isAccessibleChildSelected( sal_Int32 nChildIndex
) override
;
89 virtual void SAL_CALL
clearAccessibleSelection( ) override
;
90 virtual void SAL_CALL
selectAllAccessibleChildren( ) override
;
91 virtual sal_Int32 SAL_CALL
getSelectedAccessibleChildCount( ) override
;
92 virtual css::uno::Reference
< css::accessibility::XAccessible
> SAL_CALL
getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex
) override
;
93 virtual void SAL_CALL
deselectAccessibleChild( sal_Int32 nChildIndex
) override
;
94 // XAccessibleTableSelection
95 virtual sal_Bool SAL_CALL
selectRow( sal_Int32 row
) override
;
96 virtual sal_Bool SAL_CALL
selectColumn( sal_Int32 column
) override
;
97 virtual sal_Bool SAL_CALL
unselectRow( sal_Int32 row
) override
;
98 virtual sal_Bool SAL_CALL
unselectColumn( sal_Int32 column
) override
;
101 virtual OUString SAL_CALL
getImplementationName( ) override
;
104 virtual void SAL_CALL
disposing( ) override
;
106 // XSelectionChangeListener
107 virtual void SAL_CALL
108 disposing (const css::lang::EventObject
& Source
) override
;
109 virtual void SAL_CALL
110 selectionChanged (const css::lang::EventObject
& rEvent
) override
;
111 using AccessibleShape::disposing
;
112 friend class AccessibleTableHeaderShape
;
114 /// @throws css::lang::IndexOutOfBoundsException
115 void getColumnAndRow( sal_Int32 nChildIndex
, sal_Int32
& rnColumn
, sal_Int32
& rnRow
);
116 // overwrite the SetState & ResetState to do special operation for table cell's internal text
117 virtual bool SetState (sal_Int16 aState
) override
;
118 virtual bool ResetState (sal_Int16 aState
) override
;
119 // The following two methods are used to set state directly on table object, instead of the internal cell or paragraph.
120 bool SetStateDirectly (sal_Int16 aState
);
121 bool ResetStateDirectly (sal_Int16 aState
);
122 // Get the currently active cell which is text editing
123 AccessibleCell
* GetActiveAccessibleCell();
126 virtual OUString
CreateAccessibleBaseName() override
;
128 sdr::table::SvxTableController
* getTableController();
130 /// @throws css::lang::IndexOutOfBoundsException
131 void checkCellPosition( sal_Int32 nCol
, sal_Int32 nRow
);
133 rtl::Reference
< AccessibleTableShapeImpl
> mxImpl
;
134 sal_Int32
GetIndexOfSelectedChild( sal_Int32 nSelectedChildIndex
) const;
137 typedef ::cppu::WeakImplHelper
<
138 css::accessibility::XAccessible
,
139 css::accessibility::XAccessibleComponent
,
140 css::accessibility::XAccessibleContext
,
141 css::accessibility::XAccessibleTable
,
142 css::accessibility::XAccessibleTableSelection
>
143 AccessibleTableHeaderShape_BASE
;
145 class AccessibleTableHeaderShape
: public MutexOwner
,
146 public AccessibleTableHeaderShape_BASE
149 // bRow, true means rowheader, false means columnheader
150 AccessibleTableHeaderShape( AccessibleTableShape
* pTable
, bool bRow
);
151 virtual ~AccessibleTableHeaderShape() override
;
152 AccessibleTableHeaderShape(const AccessibleTableHeaderShape
&) = delete;
153 AccessibleTableHeaderShape
& operator=(const AccessibleTableHeaderShape
&) = delete;
156 virtual css::uno::Reference
< css::accessibility::XAccessibleContext
> SAL_CALL
getAccessibleContext( ) override
;
158 // XAccessibleContext
159 virtual sal_Int32 SAL_CALL
getAccessibleChildCount( ) override
;
160 virtual css::uno::Reference
< css::accessibility::XAccessible
> SAL_CALL
getAccessibleChild( sal_Int32 i
) override
;
161 virtual css::uno::Reference
< css::accessibility::XAccessible
> SAL_CALL
getAccessibleParent( ) override
;
162 virtual sal_Int32 SAL_CALL
getAccessibleIndexInParent( ) override
;
163 virtual sal_Int16 SAL_CALL
getAccessibleRole( ) override
;
164 virtual OUString SAL_CALL
getAccessibleDescription( ) override
;
165 virtual OUString SAL_CALL
getAccessibleName( ) override
;
166 virtual css::uno::Reference
< css::accessibility::XAccessibleStateSet
> SAL_CALL
getAccessibleStateSet( ) override
;
167 virtual css::uno::Reference
< css::accessibility::XAccessibleRelationSet
> SAL_CALL
getAccessibleRelationSet( ) override
;
168 virtual css::lang::Locale SAL_CALL
getLocale( ) override
;
170 //XAccessibleComponent
171 virtual sal_Bool SAL_CALL
containsPoint( const css::awt::Point
& aPoint
) override
;
172 virtual css::uno::Reference
< css::accessibility::XAccessible
> SAL_CALL
getAccessibleAtPoint( const css::awt::Point
& aPoint
) override
;
173 virtual css::awt::Rectangle SAL_CALL
getBounds( ) override
;
174 virtual css::awt::Point SAL_CALL
getLocation( ) override
;
175 virtual css::awt::Point SAL_CALL
getLocationOnScreen( ) override
;
176 virtual css::awt::Size SAL_CALL
getSize( ) override
;
177 virtual sal_Int32 SAL_CALL
getForeground( ) override
;
178 virtual sal_Int32 SAL_CALL
getBackground( ) override
;
179 virtual void SAL_CALL
grabFocus( ) override
;
182 virtual sal_Int32 SAL_CALL
getAccessibleRowCount() override
;
183 virtual sal_Int32 SAL_CALL
getAccessibleColumnCount( ) override
;
184 virtual OUString SAL_CALL
getAccessibleRowDescription( sal_Int32 nRow
) override
;
185 virtual OUString SAL_CALL
getAccessibleColumnDescription( sal_Int32 nColumn
) override
;
186 virtual sal_Int32 SAL_CALL
getAccessibleRowExtentAt( sal_Int32 nRow
, sal_Int32 nColumn
) override
;
187 virtual sal_Int32 SAL_CALL
getAccessibleColumnExtentAt( sal_Int32 nRow
, sal_Int32 nColumn
) override
;
188 virtual css::uno::Reference
< css::accessibility::XAccessibleTable
> SAL_CALL
getAccessibleRowHeaders( ) override
;
189 virtual css::uno::Reference
< css::accessibility::XAccessibleTable
> SAL_CALL
getAccessibleColumnHeaders( ) override
;
190 virtual css::uno::Sequence
< sal_Int32
> SAL_CALL
getSelectedAccessibleRows( ) override
;
191 virtual css::uno::Sequence
< sal_Int32
> SAL_CALL
getSelectedAccessibleColumns( ) override
;
192 virtual sal_Bool SAL_CALL
isAccessibleRowSelected( sal_Int32 nRow
) override
;
193 virtual sal_Bool SAL_CALL
isAccessibleColumnSelected( sal_Int32 nColumn
) override
;
194 virtual css::uno::Reference
< css::accessibility::XAccessible
> SAL_CALL
getAccessibleCellAt( sal_Int32 nRow
, sal_Int32 nColumn
) override
;
195 virtual css::uno::Reference
< css::accessibility::XAccessible
> SAL_CALL
getAccessibleCaption( ) override
;
196 virtual css::uno::Reference
< css::accessibility::XAccessible
> SAL_CALL
getAccessibleSummary( ) override
;
197 virtual sal_Bool SAL_CALL
isAccessibleSelected( sal_Int32 nRow
, sal_Int32 nColumn
) override
;
198 virtual sal_Int32 SAL_CALL
getAccessibleIndex( sal_Int32 nRow
, sal_Int32 nColumn
) override
;
199 virtual sal_Int32 SAL_CALL
getAccessibleRow( sal_Int32 nChildIndex
) override
;
200 virtual sal_Int32 SAL_CALL
getAccessibleColumn( sal_Int32 nChildIndex
) override
;
202 // XAccessibleTableSelection
203 virtual sal_Bool SAL_CALL
selectRow( sal_Int32 row
) override
;
204 virtual sal_Bool SAL_CALL
selectColumn( sal_Int32 column
) override
;
205 virtual sal_Bool SAL_CALL
unselectRow( sal_Int32 row
) override
;
206 virtual sal_Bool SAL_CALL
unselectColumn( sal_Int32 column
) override
;
209 rtl::Reference
< AccessibleTableShape
> mpTable
;
212 } // end of namespace accessibility
216 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */