LibreOffice Module svx (master)  1
AccessibleTableShape.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #ifndef INCLUDED_SVX_INC_ACCESSIBLETABLESHAPE_HXX
21 #define INCLUDED_SVX_INC_ACCESSIBLETABLESHAPE_HXX
22 
23 #include <com/sun/star/accessibility/XAccessibleTable.hpp>
24 
25 #include <rtl/ref.hxx>
26 
27 #include <cppuhelper/implbase.hxx>
28 
29 #include <svx/AccessibleShape.hxx>
30 #include <com/sun/star/view/XSelectionChangeListener.hpp>
31 #include <com/sun/star/accessibility/XAccessibleTableSelection.hpp>
32 
33 namespace sdr::table { class SvxTableController; }
34 
35 namespace accessibility
36 {
37  class AccessibleTableShapeImpl;
39 
40  typedef ::cppu::ImplInheritanceHelper< AccessibleShape,
41  css::accessibility::XAccessibleTable,
42  css::view::XSelectionChangeListener
44 class AccessibleTableShape final : public AccessibleTableShape_Base, public css::accessibility::XAccessibleTableSelection
45 {
47 public:
48  AccessibleTableShape( const AccessibleShapeInfo& rShapeInfo, const AccessibleShapeTreeInfo& rShapeTreeInfo );
49  virtual ~AccessibleTableShape( ) override;
52 
53  virtual void Init() override;
54 
55  // XInterface
56  virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) override;
57  virtual void SAL_CALL acquire( ) throw () override;
58  virtual void SAL_CALL release( ) throw () override;
59 
60  // XAccessibleContext
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;
64 
65  // XAccessibleTable
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;
85 
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 ;
99 
100  // XServiceInfo
101  virtual OUString SAL_CALL getImplementationName( ) override;
102 
103  // XComponent
104  virtual void SAL_CALL disposing( ) override;
105 
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;
113 
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
124 
125 private:
126  virtual OUString CreateAccessibleBaseName() override;
127 
128  sdr::table::SvxTableController* getTableController();
129 
131  void checkCellPosition( sal_Int32 nCol, sal_Int32 nRow );
132 
134  sal_Int32 GetIndexOfSelectedChild( sal_Int32 nSelectedChildIndex ) const;
135 };
136 
137 typedef ::cppu::WeakImplHelper<
138  css::accessibility::XAccessible,
139  css::accessibility::XAccessibleComponent,
140  css::accessibility::XAccessibleContext,
141  css::accessibility::XAccessibleTable,
142  css::accessibility::XAccessibleTableSelection >
144 
145 class AccessibleTableHeaderShape : public MutexOwner,
147 {
148 public:
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;
154 
155  // XAccessible
156  virtual css::uno::Reference< css::accessibility::XAccessibleContext> SAL_CALL getAccessibleContext( ) override;
157 
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;
169 
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;
180 
181  // XAccessibleTable
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;
201 
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 ;
207 private:
208  bool mbRow;
210 };
211 
212 } // end of namespace accessibility
213 
214 #endif
215 
216 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual sal_Bool SAL_CALL unselectColumn(sal_Int32 column) override
virtual void SAL_CALL selectAllAccessibleChildren() override
virtual sal_Int32 SAL_CALL getAccessibleRowCount() override
virtual void SAL_CALL selectAccessibleChild(sal_Int32 nChildIndex) override
virtual bool SetState(sal_Int16 aState) override
virtual sal_Bool SAL_CALL selectRow(sal_Int32 row) override
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &aType) override
virtual void SAL_CALL clearAccessibleSelection() override
virtual void SAL_CALL acquire() override
AccessibleTableShape & operator=(const AccessibleTableShape &)=delete
virtual OUString SAL_CALL getAccessibleRowDescription(sal_Int32 nRow) override
void checkCellPosition(sal_Int32 nCol, sal_Int32 nRow)
AccessibleTableShape(const AccessibleShapeInfo &rShapeInfo, const AccessibleShapeTreeInfo &rShapeTreeInfo)
virtual sal_Int32 SAL_CALL getAccessibleChildCount() override
virtual sal_Bool SAL_CALL isAccessibleRowSelected(sal_Int32 nRow) override
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleSummary() override
virtual sal_Bool SAL_CALL unselectRow(sal_Int32 row) override
sal_Int32 GetIndexOfSelectedChild(sal_Int32 nSelectedChildIndex) const
virtual sal_Int16 SAL_CALL getAccessibleRole() override
virtual css::uno::Reference< css::accessibility::XAccessibleTable > SAL_CALL getAccessibleColumnHeaders() override
virtual sal_Int32 SAL_CALL getSelectedAccessibleChildCount() override
sdr::table::SvxTableController * getTableController()
virtual bool ResetState(sal_Int16 aState) override
virtual css::uno::Sequence< sal_Int32 > SAL_CALL getSelectedAccessibleColumns() override
virtual sal_Int32 SAL_CALL getAccessibleColumn(sal_Int32 nChildIndex) override
virtual sal_Int32 SAL_CALL getAccessibleRow(sal_Int32 nChildIndex) override
virtual sal_Bool SAL_CALL isAccessibleSelected(sal_Int32 nRow, sal_Int32 nColumn) override
int i
virtual css::uno::Sequence< sal_Int32 > SAL_CALL getSelectedAccessibleRows() override
rtl::Reference< AccessibleTableShape > mpTable
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleCellAt(sal_Int32 nRow, sal_Int32 nColumn) override
unsigned char sal_Bool
virtual OUString SAL_CALL getImplementationName() override
virtual sal_Bool SAL_CALL isAccessibleColumnSelected(sal_Int32 nColumn) override
virtual css::uno::Reference< css::accessibility::XAccessibleTable > SAL_CALL getAccessibleRowHeaders() override
void getColumnAndRow(sal_Int32 nChildIndex, sal_Int32 &rnColumn, sal_Int32 &rnRow)
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleCaption() override
virtual sal_Int32 SAL_CALL getAccessibleIndex(sal_Int32 nRow, sal_Int32 nColumn) override
This base class provides a base implementation for all shapes.
const LanguageTag & getLocale()
virtual void SAL_CALL deselectAccessibleChild(sal_Int32 nChildIndex) override
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleChild(sal_Int32 i) override
virtual sal_Bool SAL_CALL selectColumn(sal_Int32 column) override
virtual void SAL_CALL disposing() override
virtual void SAL_CALL selectionChanged(const css::lang::EventObject &rEvent) override
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getSelectedAccessibleChild(sal_Int32 nSelectedChildIndex) override
virtual OUString CreateAccessibleBaseName() override
::cppu::WeakImplHelper< css::accessibility::XAccessible, css::accessibility::XAccessibleComponent, css::accessibility::XAccessibleContext, css::accessibility::XAccessibleTable, css::accessibility::XAccessibleTableSelection > AccessibleTableHeaderShape_BASE
virtual sal_Int32 SAL_CALL getAccessibleRowExtentAt(sal_Int32 nRow, sal_Int32 nColumn) override
rtl::Reference< AccessibleTableShapeImpl > mxImpl
::cppu::ImplInheritanceHelper< AccessibleShape, css::accessibility::XAccessibleTable, css::view::XSelectionChangeListener > AccessibleTableShape_Base
This class is a container for the information specific for a single shape that is passed to the const...
virtual sal_Int32 SAL_CALL getAccessibleColumnCount() override
This class bundles all information that is passed down the tree of accessible shapes so that each sha...
virtual sal_Bool SAL_CALL isAccessibleChildSelected(sal_Int32 nChildIndex) override
virtual OUString SAL_CALL getAccessibleColumnDescription(sal_Int32 nColumn) override
virtual sal_Int32 SAL_CALL getAccessibleColumnExtentAt(sal_Int32 nRow, sal_Int32 nColumn) override
virtual void SAL_CALL release() override