Version 6.4.0.0.beta1, tag libreoffice-6.4.0.0.beta1
[LibreOffice.git] / svx / inc / AccessibleTableShape.hxx
blob238687940dd1e4fd19530948b8244eee4373bbd8
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 .
20 #ifndef INCLUDED_SVX_INC_ACCESSIBLETABLESHAPE_HXX
21 #define INCLUDED_SVX_INC_ACCESSIBLETABLESHAPE_HXX
23 #include <com/sun/star/table/XTable.hpp>
24 #include <com/sun/star/accessibility/XAccessibleTable.hpp>
25 #include <com/sun/star/accessibility/XAccessibleSelection.hpp>
26 #include <com/sun/star/util/XModifyListener.hpp>
28 #include <rtl/ref.hxx>
30 #include <cppuhelper/implbase.hxx>
32 #include <svx/AccessibleShape.hxx>
33 #include <com/sun/star/view/XSelectionChangeListener.hpp>
34 #include <com/sun/star/accessibility/XAccessibleTableSelection.hpp>
35 #include <cppuhelper/compbase.hxx>
37 namespace sdr { namespace table {
38 class SvxTableController;
39 } }
41 namespace accessibility
43 class AccessibleTableShapeImpl;
44 class AccessibleCell;
46 typedef ::cppu::ImplInheritanceHelper< AccessibleShape,
47 css::accessibility::XAccessibleTable,
48 css::view::XSelectionChangeListener
49 > AccessibleTableShape_Base;
50 class AccessibleTableShape final : public AccessibleTableShape_Base, public css::accessibility::XAccessibleTableSelection
52 sal_Int32 mnPreviousSelectionCount;
53 public:
54 AccessibleTableShape( const AccessibleShapeInfo& rShapeInfo, const AccessibleShapeTreeInfo& rShapeTreeInfo );
55 virtual ~AccessibleTableShape( ) override;
56 AccessibleTableShape(const AccessibleTableShape&) = delete;
57 AccessibleTableShape& operator=(const AccessibleTableShape&) = delete;
59 virtual void Init() override;
61 // XInterface
62 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) override;
63 virtual void SAL_CALL acquire( ) throw () override;
64 virtual void SAL_CALL release( ) throw () override;
66 // XAccessibleContext
67 virtual sal_Int32 SAL_CALL getAccessibleChildCount( ) override;
68 virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int32 i ) override;
69 virtual sal_Int16 SAL_CALL getAccessibleRole() override;
71 // XAccessibleTable
72 virtual sal_Int32 SAL_CALL getAccessibleRowCount() override;
73 virtual sal_Int32 SAL_CALL getAccessibleColumnCount( ) override;
74 virtual OUString SAL_CALL getAccessibleRowDescription( sal_Int32 nRow ) override;
75 virtual OUString SAL_CALL getAccessibleColumnDescription( sal_Int32 nColumn ) override;
76 virtual sal_Int32 SAL_CALL getAccessibleRowExtentAt( sal_Int32 nRow, sal_Int32 nColumn ) override;
77 virtual sal_Int32 SAL_CALL getAccessibleColumnExtentAt( sal_Int32 nRow, sal_Int32 nColumn ) override;
78 virtual css::uno::Reference< css::accessibility::XAccessibleTable > SAL_CALL getAccessibleRowHeaders( ) override;
79 virtual css::uno::Reference< css::accessibility::XAccessibleTable > SAL_CALL getAccessibleColumnHeaders( ) override;
80 virtual css::uno::Sequence< sal_Int32 > SAL_CALL getSelectedAccessibleRows( ) override;
81 virtual css::uno::Sequence< sal_Int32 > SAL_CALL getSelectedAccessibleColumns( ) override;
82 virtual sal_Bool SAL_CALL isAccessibleRowSelected( sal_Int32 nRow ) override;
83 virtual sal_Bool SAL_CALL isAccessibleColumnSelected( sal_Int32 nColumn ) override;
84 virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleCellAt( sal_Int32 nRow, sal_Int32 nColumn ) override;
85 virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleCaption( ) override;
86 virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleSummary( ) override;
87 virtual sal_Bool SAL_CALL isAccessibleSelected( sal_Int32 nRow, sal_Int32 nColumn ) override;
88 virtual sal_Int32 SAL_CALL getAccessibleIndex( sal_Int32 nRow, sal_Int32 nColumn ) override;
89 virtual sal_Int32 SAL_CALL getAccessibleRow( sal_Int32 nChildIndex ) override;
90 virtual sal_Int32 SAL_CALL getAccessibleColumn( sal_Int32 nChildIndex ) override;
92 // XAccessibleSelection
93 virtual void SAL_CALL selectAccessibleChild( sal_Int32 nChildIndex ) override;
94 virtual sal_Bool SAL_CALL isAccessibleChildSelected( sal_Int32 nChildIndex ) override;
95 virtual void SAL_CALL clearAccessibleSelection( ) override;
96 virtual void SAL_CALL selectAllAccessibleChildren( ) override;
97 virtual sal_Int32 SAL_CALL getSelectedAccessibleChildCount( ) override;
98 virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex ) override;
99 virtual void SAL_CALL deselectAccessibleChild( sal_Int32 nChildIndex ) override;
100 // XAccessibleTableSelection
101 virtual sal_Bool SAL_CALL selectRow( sal_Int32 row ) override ;
102 virtual sal_Bool SAL_CALL selectColumn( sal_Int32 column ) override ;
103 virtual sal_Bool SAL_CALL unselectRow( sal_Int32 row ) override ;
104 virtual sal_Bool SAL_CALL unselectColumn( sal_Int32 column ) override ;
106 // XServiceInfo
107 virtual OUString SAL_CALL getImplementationName( ) override;
109 // XComponent
110 virtual void SAL_CALL disposing( ) override;
112 // XSelectionChangeListener
113 virtual void SAL_CALL
114 disposing (const css::lang::EventObject& Source) override;
115 virtual void SAL_CALL
116 selectionChanged (const css::lang::EventObject& rEvent) override;
117 using AccessibleShape::disposing;
118 friend class AccessibleTableHeaderShape;
120 /// @throws css::lang::IndexOutOfBoundsException
121 void getColumnAndRow( sal_Int32 nChildIndex, sal_Int32& rnColumn, sal_Int32& rnRow );
122 // overwrite the SetState & ResetState to do special operation for table cell's internal text
123 virtual bool SetState (sal_Int16 aState) override;
124 virtual bool ResetState (sal_Int16 aState) override;
125 // The following two methods are used to set state directly on table object, instead of the internal cell or paragraph.
126 bool SetStateDirectly (sal_Int16 aState);
127 bool ResetStateDirectly (sal_Int16 aState);
128 // Get the currently active cell which is text editing
129 AccessibleCell* GetActiveAccessibleCell();
131 private:
132 virtual OUString CreateAccessibleBaseName() override;
134 sdr::table::SvxTableController* getTableController();
136 /// @throws css::lang::IndexOutOfBoundsException
137 void checkCellPosition( sal_Int32 nCol, sal_Int32 nRow );
139 rtl::Reference< AccessibleTableShapeImpl > mxImpl;
140 sal_Int32 GetIndexOfSelectedChild( sal_Int32 nSelectedChildIndex ) const;
143 typedef ::cppu::WeakImplHelper<
144 css::accessibility::XAccessible,
145 css::accessibility::XAccessibleComponent,
146 css::accessibility::XAccessibleContext,
147 css::accessibility::XAccessibleTable,
148 css::accessibility::XAccessibleTableSelection >
149 AccessibleTableHeaderShape_BASE;
151 class AccessibleTableHeaderShape : public MutexOwner,
152 public AccessibleTableHeaderShape_BASE
154 public:
155 // bRow, true means rowheader, false means columnheader
156 AccessibleTableHeaderShape( AccessibleTableShape* pTable, bool bRow );
157 virtual ~AccessibleTableHeaderShape() override;
158 AccessibleTableHeaderShape(const AccessibleTableHeaderShape&) = delete;
159 AccessibleTableHeaderShape& operator=(const AccessibleTableHeaderShape&) = delete;
161 // XAccessible
162 virtual css::uno::Reference< css::accessibility::XAccessibleContext> SAL_CALL getAccessibleContext( ) override;
164 // XAccessibleContext
165 virtual sal_Int32 SAL_CALL getAccessibleChildCount( ) override;
166 virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int32 i ) override;
167 virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleParent( ) override;
168 virtual sal_Int32 SAL_CALL getAccessibleIndexInParent( ) override;
169 virtual sal_Int16 SAL_CALL getAccessibleRole( ) override;
170 virtual OUString SAL_CALL getAccessibleDescription( ) override;
171 virtual OUString SAL_CALL getAccessibleName( ) override;
172 virtual css::uno::Reference< css::accessibility::XAccessibleStateSet > SAL_CALL getAccessibleStateSet( ) override;
173 virtual css::uno::Reference< css::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet( ) override;
174 virtual css::lang::Locale SAL_CALL getLocale( ) override;
176 //XAccessibleComponent
177 virtual sal_Bool SAL_CALL containsPoint( const css::awt::Point& aPoint ) override;
178 virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint( const css::awt::Point& aPoint ) override;
179 virtual css::awt::Rectangle SAL_CALL getBounds( ) override;
180 virtual css::awt::Point SAL_CALL getLocation( ) override;
181 virtual css::awt::Point SAL_CALL getLocationOnScreen( ) override;
182 virtual css::awt::Size SAL_CALL getSize( ) override;
183 virtual sal_Int32 SAL_CALL getForeground( ) override;
184 virtual sal_Int32 SAL_CALL getBackground( ) override;
185 virtual void SAL_CALL grabFocus( ) override;
187 // XAccessibleTable
188 virtual sal_Int32 SAL_CALL getAccessibleRowCount() override;
189 virtual sal_Int32 SAL_CALL getAccessibleColumnCount( ) override;
190 virtual OUString SAL_CALL getAccessibleRowDescription( sal_Int32 nRow ) override;
191 virtual OUString SAL_CALL getAccessibleColumnDescription( sal_Int32 nColumn ) override;
192 virtual sal_Int32 SAL_CALL getAccessibleRowExtentAt( sal_Int32 nRow, sal_Int32 nColumn ) override;
193 virtual sal_Int32 SAL_CALL getAccessibleColumnExtentAt( sal_Int32 nRow, sal_Int32 nColumn ) override;
194 virtual css::uno::Reference< css::accessibility::XAccessibleTable > SAL_CALL getAccessibleRowHeaders( ) override;
195 virtual css::uno::Reference< css::accessibility::XAccessibleTable > SAL_CALL getAccessibleColumnHeaders( ) override;
196 virtual css::uno::Sequence< sal_Int32 > SAL_CALL getSelectedAccessibleRows( ) override;
197 virtual css::uno::Sequence< sal_Int32 > SAL_CALL getSelectedAccessibleColumns( ) override;
198 virtual sal_Bool SAL_CALL isAccessibleRowSelected( sal_Int32 nRow ) override;
199 virtual sal_Bool SAL_CALL isAccessibleColumnSelected( sal_Int32 nColumn ) override;
200 virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleCellAt( sal_Int32 nRow, sal_Int32 nColumn ) override;
201 virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleCaption( ) override;
202 virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleSummary( ) override;
203 virtual sal_Bool SAL_CALL isAccessibleSelected( sal_Int32 nRow, sal_Int32 nColumn ) override;
204 virtual sal_Int32 SAL_CALL getAccessibleIndex( sal_Int32 nRow, sal_Int32 nColumn ) override;
205 virtual sal_Int32 SAL_CALL getAccessibleRow( sal_Int32 nChildIndex ) override;
206 virtual sal_Int32 SAL_CALL getAccessibleColumn( sal_Int32 nChildIndex ) override;
208 // XAccessibleTableSelection
209 virtual sal_Bool SAL_CALL selectRow( sal_Int32 row ) override ;
210 virtual sal_Bool SAL_CALL selectColumn( sal_Int32 column ) override ;
211 virtual sal_Bool SAL_CALL unselectRow( sal_Int32 row ) override ;
212 virtual sal_Bool SAL_CALL unselectColumn( sal_Int32 column ) override ;
213 private:
214 bool mbRow;
215 rtl::Reference< AccessibleTableShape > mpTable;
218 } // end of namespace accessibility
220 #endif
222 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */