Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / svx / inc / AccessibleTableShape.hxx
blob041457f3a6baf7b0f7115409ca3b30b0e88ee25d
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 /** @descr
52 class AccessibleTableShape : public AccessibleTableShape_Base, public css::accessibility::XAccessibleTableSelection
54 public:
55 AccessibleTableShape( const AccessibleShapeInfo& rShapeInfo, const AccessibleShapeTreeInfo& rShapeTreeInfo );
56 virtual ~AccessibleTableShape( ) override;
57 AccessibleTableShape(const AccessibleTableShape&) = delete;
58 AccessibleTableShape& operator=(const AccessibleTableShape&) = delete;
60 virtual void Init() override;
62 // XInterface
63 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) override;
64 virtual void SAL_CALL acquire( ) throw () override;
65 virtual void SAL_CALL release( ) throw () override;
67 // XAccessibleContext
68 virtual sal_Int32 SAL_CALL getAccessibleChildCount( ) override;
69 virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int32 i ) override;
70 virtual sal_Int16 SAL_CALL getAccessibleRole() override;
72 // XAccessibleTable
73 virtual sal_Int32 SAL_CALL getAccessibleRowCount() override;
74 virtual sal_Int32 SAL_CALL getAccessibleColumnCount( ) override;
75 virtual OUString SAL_CALL getAccessibleRowDescription( sal_Int32 nRow ) override;
76 virtual OUString SAL_CALL getAccessibleColumnDescription( sal_Int32 nColumn ) override;
77 virtual sal_Int32 SAL_CALL getAccessibleRowExtentAt( sal_Int32 nRow, sal_Int32 nColumn ) override;
78 virtual sal_Int32 SAL_CALL getAccessibleColumnExtentAt( sal_Int32 nRow, sal_Int32 nColumn ) override;
79 virtual css::uno::Reference< css::accessibility::XAccessibleTable > SAL_CALL getAccessibleRowHeaders( ) override;
80 virtual css::uno::Reference< css::accessibility::XAccessibleTable > SAL_CALL getAccessibleColumnHeaders( ) override;
81 virtual css::uno::Sequence< sal_Int32 > SAL_CALL getSelectedAccessibleRows( ) override;
82 virtual css::uno::Sequence< sal_Int32 > SAL_CALL getSelectedAccessibleColumns( ) override;
83 virtual sal_Bool SAL_CALL isAccessibleRowSelected( sal_Int32 nRow ) override;
84 virtual sal_Bool SAL_CALL isAccessibleColumnSelected( sal_Int32 nColumn ) override;
85 virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleCellAt( sal_Int32 nRow, sal_Int32 nColumn ) override;
86 virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleCaption( ) override;
87 virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleSummary( ) override;
88 virtual sal_Bool SAL_CALL isAccessibleSelected( sal_Int32 nRow, sal_Int32 nColumn ) override;
89 virtual sal_Int32 SAL_CALL getAccessibleIndex( sal_Int32 nRow, sal_Int32 nColumn ) override;
90 virtual sal_Int32 SAL_CALL getAccessibleRow( sal_Int32 nChildIndex ) override;
91 virtual sal_Int32 SAL_CALL getAccessibleColumn( sal_Int32 nChildIndex ) override;
93 // XAccessibleSelection
94 virtual void SAL_CALL selectAccessibleChild( sal_Int32 nChildIndex ) override;
95 virtual sal_Bool SAL_CALL isAccessibleChildSelected( sal_Int32 nChildIndex ) override;
96 virtual void SAL_CALL clearAccessibleSelection( ) override;
97 virtual void SAL_CALL selectAllAccessibleChildren( ) override;
98 virtual sal_Int32 SAL_CALL getSelectedAccessibleChildCount( ) override;
99 virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex ) override;
100 virtual void SAL_CALL deselectAccessibleChild( sal_Int32 nChildIndex ) override;
101 // XAccessibleTableSelection
102 virtual sal_Bool SAL_CALL selectRow( sal_Int32 row ) override ;
103 virtual sal_Bool SAL_CALL selectColumn( sal_Int32 column ) override ;
104 virtual sal_Bool SAL_CALL unselectRow( sal_Int32 row ) override ;
105 virtual sal_Bool SAL_CALL unselectColumn( sal_Int32 column ) override ;
107 // XServiceInfo
108 virtual OUString SAL_CALL getImplementationName( ) override;
110 // XComponent
111 virtual void SAL_CALL disposing( ) override;
113 // XSelectionChangeListener
114 virtual void SAL_CALL
115 disposing (const css::lang::EventObject& Source) override;
116 virtual void SAL_CALL
117 selectionChanged (const css::lang::EventObject& rEvent) override;
118 sal_Int32 mnPreviousSelectionCount;
119 using AccessibleShape::disposing;
120 friend class AccessibleTableHeaderShape;
122 /// @throws css::lang::IndexOutOfBoundsException
123 void getColumnAndRow( sal_Int32 nChildIndex, sal_Int32& rnColumn, sal_Int32& rnRow );
124 // overwrite the SetState & ResetState to do special operation for table cell's internal text
125 virtual bool SetState (sal_Int16 aState) override;
126 virtual bool ResetState (sal_Int16 aState) override;
127 // The following two methods are used to set state directly on table object, instead of the internal cell or paragraph.
128 bool SetStateDirectly (sal_Int16 aState);
129 bool ResetStateDirectly (sal_Int16 aState);
130 // Get the currently active cell which is text editing
131 AccessibleCell* GetActiveAccessibleCell();
133 protected:
134 virtual OUString CreateAccessibleBaseName() override;
136 sdr::table::SvxTableController* getTableController();
138 /// @throws css::lang::IndexOutOfBoundsException
139 void checkCellPosition( sal_Int32 nCol, sal_Int32 nRow );
141 private:
142 rtl::Reference< AccessibleTableShapeImpl > mxImpl;
143 sal_Int32 GetIndexOfSelectedChild( sal_Int32 nSelectedChildIndex ) const;
146 typedef ::cppu::WeakImplHelper<
147 css::accessibility::XAccessible,
148 css::accessibility::XAccessibleComponent,
149 css::accessibility::XAccessibleContext,
150 css::accessibility::XAccessibleTable,
151 css::accessibility::XAccessibleTableSelection >
152 AccessibleTableHeaderShape_BASE;
154 class AccessibleTableHeaderShape : public MutexOwner,
155 public AccessibleTableHeaderShape_BASE
157 public:
158 // bRow, true means rowheader, false means columnheader
159 AccessibleTableHeaderShape( AccessibleTableShape* pTable, bool bRow );
160 virtual ~AccessibleTableHeaderShape() override;
161 AccessibleTableHeaderShape(const AccessibleTableHeaderShape&) = delete;
162 AccessibleTableHeaderShape& operator=(const AccessibleTableHeaderShape&) = delete;
164 // XAccessible
165 virtual css::uno::Reference< css::accessibility::XAccessibleContext> SAL_CALL getAccessibleContext( ) override;
167 // XAccessibleContext
168 virtual sal_Int32 SAL_CALL getAccessibleChildCount( ) override;
169 virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int32 i ) override;
170 virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleParent( ) override;
171 virtual sal_Int32 SAL_CALL getAccessibleIndexInParent( ) override;
172 virtual sal_Int16 SAL_CALL getAccessibleRole( ) override;
173 virtual OUString SAL_CALL getAccessibleDescription( ) override;
174 virtual OUString SAL_CALL getAccessibleName( ) override;
175 virtual css::uno::Reference< css::accessibility::XAccessibleStateSet > SAL_CALL getAccessibleStateSet( ) override;
176 virtual css::uno::Reference< css::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet( ) override;
177 virtual css::lang::Locale SAL_CALL getLocale( ) override;
179 //XAccessibleComponent
180 virtual sal_Bool SAL_CALL containsPoint( const css::awt::Point& aPoint ) override;
181 virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint( const css::awt::Point& aPoint ) override;
182 virtual css::awt::Rectangle SAL_CALL getBounds( ) override;
183 virtual css::awt::Point SAL_CALL getLocation( ) override;
184 virtual css::awt::Point SAL_CALL getLocationOnScreen( ) override;
185 virtual css::awt::Size SAL_CALL getSize( ) override;
186 virtual sal_Int32 SAL_CALL getForeground( ) override;
187 virtual sal_Int32 SAL_CALL getBackground( ) override;
188 virtual void SAL_CALL grabFocus( ) override;
190 // XAccessibleTable
191 virtual sal_Int32 SAL_CALL getAccessibleRowCount() override;
192 virtual sal_Int32 SAL_CALL getAccessibleColumnCount( ) override;
193 virtual OUString SAL_CALL getAccessibleRowDescription( sal_Int32 nRow ) override;
194 virtual OUString SAL_CALL getAccessibleColumnDescription( sal_Int32 nColumn ) override;
195 virtual sal_Int32 SAL_CALL getAccessibleRowExtentAt( sal_Int32 nRow, sal_Int32 nColumn ) override;
196 virtual sal_Int32 SAL_CALL getAccessibleColumnExtentAt( sal_Int32 nRow, sal_Int32 nColumn ) override;
197 virtual css::uno::Reference< css::accessibility::XAccessibleTable > SAL_CALL getAccessibleRowHeaders( ) override;
198 virtual css::uno::Reference< css::accessibility::XAccessibleTable > SAL_CALL getAccessibleColumnHeaders( ) override;
199 virtual css::uno::Sequence< sal_Int32 > SAL_CALL getSelectedAccessibleRows( ) override;
200 virtual css::uno::Sequence< sal_Int32 > SAL_CALL getSelectedAccessibleColumns( ) override;
201 virtual sal_Bool SAL_CALL isAccessibleRowSelected( sal_Int32 nRow ) override;
202 virtual sal_Bool SAL_CALL isAccessibleColumnSelected( sal_Int32 nColumn ) override;
203 virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleCellAt( sal_Int32 nRow, sal_Int32 nColumn ) override;
204 virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleCaption( ) override;
205 virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleSummary( ) override;
206 virtual sal_Bool SAL_CALL isAccessibleSelected( sal_Int32 nRow, sal_Int32 nColumn ) override;
207 virtual sal_Int32 SAL_CALL getAccessibleIndex( sal_Int32 nRow, sal_Int32 nColumn ) override;
208 virtual sal_Int32 SAL_CALL getAccessibleRow( sal_Int32 nChildIndex ) override;
209 virtual sal_Int32 SAL_CALL getAccessibleColumn( sal_Int32 nChildIndex ) override;
211 // XAccessibleTableSelection
212 virtual sal_Bool SAL_CALL selectRow( sal_Int32 row ) override ;
213 virtual sal_Bool SAL_CALL selectColumn( sal_Int32 column ) override ;
214 virtual sal_Bool SAL_CALL unselectRow( sal_Int32 row ) override ;
215 virtual sal_Bool SAL_CALL unselectColumn( sal_Int32 column ) override ;
216 private:
217 bool mbRow;
218 rtl::Reference< AccessibleTableShape > mpTable;
221 } // end of namespace accessibility
223 #endif
225 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */