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 .
22 #include <com/sun/star/accessibility/XAccessibleTable.hpp>
23 #include <com/sun/star/accessibility/XAccessibleTableSelection.hpp>
25 #include <com/sun/star/accessibility/XAccessibleSelection.hpp>
27 #include <svl/listener.hxx>
29 #include "acccontext.hxx"
32 class SwAccessibleTableData_Impl
;
36 namespace sw::access
{
37 class SwAccessibleChild
;
40 class SwAccessibleTable
:
41 public SwAccessibleContext
,
42 public css::accessibility::XAccessibleTable
,
43 public css::accessibility::XAccessibleSelection
,
44 public css::accessibility::XAccessibleTableSelection
,
47 std::unique_ptr
<SwAccessibleTableData_Impl
> mpTableData
; // the table's data, protected by SolarMutex
49 typedef std::vector
< std::pair
<SwAccessibleContext
*,
50 css::uno::WeakReference
<css::accessibility::XAccessible
> > > Cells_t
;
52 Cells_t m_vecCellRemove
;
54 const SwSelBoxes
*GetSelBoxes() const;
56 void FireTableChangeEvent( const SwAccessibleTableData_Impl
& rTableData
);
58 /** get the SwTableBox* for the given child */
59 const SwTableBox
* GetTableBox( sal_Int64
) const;
61 bool IsChildSelected( sal_Int64 nChildIndex
) const;
63 sal_Int64
GetIndexOfSelectedChild( sal_Int64 nSelectedChildIndex
) const;
66 // Set states for getAccessibleStateSet.
67 // This derived class additionally sets MULTISELECTABLE(+)
68 virtual void GetStates( sal_Int64
& rStateSet
) override
;
70 virtual ~SwAccessibleTable() override
;
73 void SetDesc( const OUString
& sNewDesc
)
78 virtual std::unique_ptr
<SwAccessibleTableData_Impl
> CreateNewTableData(); // #i77106#
80 // force update of table data
81 void UpdateTableData();
83 // remove the current table data
84 void ClearTableData();
86 // get table data, update if necessary
87 inline SwAccessibleTableData_Impl
& GetTableData();
89 // Is table data evailable?
90 bool HasTableData() const { return (mpTableData
!= nullptr); }
92 virtual void Notify(const SfxHint
&) override
;
95 SwAccessibleTable(std::shared_ptr
<SwAccessibleMap
> const& pInitMap
,
96 const SwTabFrame
* pTableFrame
);
100 // (XInterface methods need to be implemented to disambiguate
101 // between those inherited through SwAccessibleContext and
102 // XAccessibleTable).
104 virtual css::uno::Any SAL_CALL
queryInterface(
105 const css::uno::Type
& aType
) override
;
107 virtual void SAL_CALL
acquire( ) noexcept override
108 { SwAccessibleContext::acquire(); };
110 virtual void SAL_CALL
release( ) noexcept override
111 { SwAccessibleContext::release(); };
114 virtual css::uno::Sequence
< css::uno::Type
> SAL_CALL
getTypes( ) override
;
115 virtual css::uno::Sequence
< sal_Int8
> SAL_CALL
getImplementationId( ) override
;
117 // XAccessibleContext
119 /// Return this object's description.
120 virtual OUString SAL_CALL
121 getAccessibleDescription() override
;
125 virtual sal_Int32 SAL_CALL
getAccessibleRowCount() override
;
126 virtual sal_Int32 SAL_CALL
getAccessibleColumnCount( ) override
;
127 virtual OUString SAL_CALL
getAccessibleRowDescription(
128 sal_Int32 nRow
) override
;
129 virtual OUString SAL_CALL
getAccessibleColumnDescription(
130 sal_Int32 nColumn
) override
;
131 virtual sal_Int32 SAL_CALL
getAccessibleRowExtentAt(
132 sal_Int32 nRow
, sal_Int32 nColumn
) override
;
133 virtual sal_Int32 SAL_CALL
getAccessibleColumnExtentAt(
134 sal_Int32 nRow
, sal_Int32 nColumn
) override
;
135 virtual css::uno::Reference
<
136 css::accessibility::XAccessibleTable
>
137 SAL_CALL
getAccessibleRowHeaders( ) override
;
138 virtual css::uno::Reference
<
139 css::accessibility::XAccessibleTable
>
140 SAL_CALL
getAccessibleColumnHeaders( ) override
;
141 virtual css::uno::Sequence
< sal_Int32
> SAL_CALL
142 getSelectedAccessibleRows( ) override
;
143 virtual css::uno::Sequence
< sal_Int32
> SAL_CALL
144 getSelectedAccessibleColumns( ) override
;
145 virtual sal_Bool SAL_CALL
isAccessibleRowSelected( sal_Int32 nRow
) override
;
146 virtual sal_Bool SAL_CALL
isAccessibleColumnSelected( sal_Int32 nColumn
) override
;
147 virtual css::uno::Reference
<
148 css::accessibility::XAccessible
> SAL_CALL
149 getAccessibleCellAt( sal_Int32 nRow
, sal_Int32 nColumn
) override
;
150 virtual css::uno::Reference
<
151 css::accessibility::XAccessible
> SAL_CALL
152 getAccessibleCaption( ) override
;
153 virtual css::uno::Reference
<
154 css::accessibility::XAccessible
> SAL_CALL
155 getAccessibleSummary( ) override
;
156 virtual sal_Bool SAL_CALL
isAccessibleSelected(
157 sal_Int32 nRow
, sal_Int32 nColumn
) override
;
158 virtual sal_Int64 SAL_CALL
getAccessibleIndex(
159 sal_Int32 nRow
, sal_Int32 nColumn
) override
;
160 virtual sal_Int32 SAL_CALL
getAccessibleRow( sal_Int64 nChildIndex
) override
;
161 virtual sal_Int32 SAL_CALL
getAccessibleColumn( sal_Int64 nChildIndex
) override
;
162 // XAccessibleTableSelection
163 virtual sal_Bool SAL_CALL
selectRow( sal_Int32 row
) override
;
164 virtual sal_Bool SAL_CALL
selectColumn( sal_Int32 column
) override
;
165 virtual sal_Bool SAL_CALL
unselectRow( sal_Int32 row
) override
;
166 virtual sal_Bool SAL_CALL
unselectColumn( sal_Int32 column
) override
;
169 /** Returns an identifier for the implementation of this object.
171 virtual OUString SAL_CALL
172 getImplementationName() override
;
174 /** Return whether the specified service is supported by this class.
176 virtual sal_Bool SAL_CALL
177 supportsService (const OUString
& sServiceName
) override
;
179 /** Returns a list of all supported services. In this case that is just
180 the AccessibleContext service.
182 virtual css::uno::Sequence
< OUString
> SAL_CALL
183 getSupportedServiceNames() override
;
187 // The object has been moved by the layout
188 virtual void InvalidatePosOrSize( const SwRect
& rOldBox
) override
;
190 // The object is not visible any longer and should be destroyed
191 virtual void Dispose(bool bRecursive
, bool bCanSkipInvisible
= true) override
;
193 virtual void DisposeChild( const sw::access::SwAccessibleChild
& rFrameOrObj
,
194 bool bRecursive
, bool bCanSkipInvisible
) override
;
195 virtual void InvalidateChildPosOrSize( const sw::access::SwAccessibleChild
& rFrameOrObj
,
196 const SwRect
& rFrame
) override
;
198 // XAccessibleSelection
200 virtual void SAL_CALL
selectAccessibleChild(
201 sal_Int64 nChildIndex
) override
;
203 virtual sal_Bool SAL_CALL
isAccessibleChildSelected(
204 sal_Int64 nChildIndex
) override
;
206 virtual void SAL_CALL
clearAccessibleSelection( ) override
;
208 virtual void SAL_CALL
selectAllAccessibleChildren( ) override
;
210 virtual sal_Int64 SAL_CALL
getSelectedAccessibleChildCount( ) override
;
212 virtual css::uno::Reference
< css::accessibility::XAccessible
> SAL_CALL
getSelectedAccessibleChild(
213 sal_Int64 nSelectedChildIndex
) override
;
215 // index has to be treated as global child index.
216 virtual void SAL_CALL
deselectAccessibleChild(
217 sal_Int64 nChildIndex
) override
;
219 // XAccessibleComponent
220 sal_Int32 SAL_CALL
getBackground() override
;
222 void FireSelectionEvent( );
223 void AddSelectionCell(SwAccessibleContext
*, bool bAddOrRemove
);
226 inline SwAccessibleTableData_Impl
& SwAccessibleTable::GetTableData()
233 // #i77106# - subclass to represent table column headers
234 class SwAccessibleTableColHeaders
: public SwAccessibleTable
237 virtual ~SwAccessibleTableColHeaders() override
240 virtual std::unique_ptr
<SwAccessibleTableData_Impl
> CreateNewTableData() override
;
241 virtual void Notify(const SfxHint
&) override
;
244 SwAccessibleTableColHeaders(std::shared_ptr
<SwAccessibleMap
> const& pMap
,
245 const SwTabFrame
*pTabFrame
);
249 virtual css::uno::Any SAL_CALL
queryInterface(
250 const css::uno::Type
& aType
) override
;
252 // XAccessibleContext
254 /// Return the number of currently visible children.
255 virtual sal_Int64 SAL_CALL
getAccessibleChildCount() override
;
257 /// Return the specified child or NULL if index is invalid.
258 virtual css::uno::Reference
< css::accessibility::XAccessible
> SAL_CALL
259 getAccessibleChild (sal_Int64 nIndex
) override
;
263 virtual css::uno::Reference
<
264 css::accessibility::XAccessibleTable
>
265 SAL_CALL
getAccessibleRowHeaders( ) override
;
266 virtual css::uno::Reference
<
267 css::accessibility::XAccessibleTable
>
268 SAL_CALL
getAccessibleColumnHeaders( ) override
;
272 /** Returns an identifier for the implementation of this object.
274 virtual OUString SAL_CALL
275 getImplementationName() override
;
279 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */