LibreOffice Module sw (master) 1
acctable.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#pragma once
21
22#include <com/sun/star/accessibility/XAccessibleTable.hpp>
23#include <com/sun/star/accessibility/XAccessibleTableSelection.hpp>
24#include <vector>
25#include <com/sun/star/accessibility/XAccessibleSelection.hpp>
26
27#include <svl/listener.hxx>
28
29#include "acccontext.hxx"
30
31class SwTabFrame;
33class SwTableBox;
34class SwSelBoxes;
35
36namespace sw::access {
37 class SwAccessibleChild;
38}
39
42 public css::accessibility::XAccessibleTable,
43 public css::accessibility::XAccessibleSelection,
44 public css::accessibility::XAccessibleTableSelection,
45 public SvtListener
46{
47 std::unique_ptr<SwAccessibleTableData_Impl> mpTableData; // the table's data, protected by SolarMutex
48 OUString m_sDesc;
49 typedef std::vector< std::pair<SwAccessibleContext*,
50 css::uno::WeakReference<css::accessibility::XAccessible> > > Cells_t;
53
54 const SwSelBoxes *GetSelBoxes() const;
55
56 void FireTableChangeEvent( const SwAccessibleTableData_Impl& rTableData );
57
59 const SwTableBox* GetTableBox( sal_Int64 ) const;
60
61 bool IsChildSelected( sal_Int64 nChildIndex ) const;
62
63 sal_Int64 GetIndexOfSelectedChild( sal_Int64 nSelectedChildIndex ) const;
64
65protected:
66 // Set states for getAccessibleStateSet.
67 // This derived class additionally sets MULTISELECTABLE(+)
68 virtual void GetStates( sal_Int64& rStateSet ) override;
69
70 virtual ~SwAccessibleTable() override;
71
72 // #i77106#
73 void SetDesc( const OUString& sNewDesc )
74 {
75 m_sDesc = sNewDesc;
76 }
77
78 virtual std::unique_ptr<SwAccessibleTableData_Impl> CreateNewTableData(); // #i77106#
79
80 // force update of table data
81 void UpdateTableData();
82
83 // remove the current table data
84 void ClearTableData();
85
86 // get table data, update if necessary
88
89 // Is table data available?
90 bool HasTableData() const { return (mpTableData != nullptr); }
91
92 virtual void Notify(const SfxHint&) override;
93
94public:
95 SwAccessibleTable(std::shared_ptr<SwAccessibleMap> const& pInitMap,
96 const SwTabFrame* pTableFrame);
97
98 // XInterface
99
100 // (XInterface methods need to be implemented to disambiguate
101 // between those inherited through SwAccessibleContext and
102 // XAccessibleTable).
103
104 virtual css::uno::Any SAL_CALL queryInterface(
105 const css::uno::Type& aType ) override;
106
107 virtual void SAL_CALL acquire( ) noexcept override
108 { SwAccessibleContext::acquire(); };
109
110 virtual void SAL_CALL release( ) noexcept override
111 { SwAccessibleContext::release(); };
112
113 // XTypeProvider
114 virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override;
115 virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) override;
116
117 // XAccessibleContext
118
120 virtual OUString SAL_CALL
121 getAccessibleDescription() override;
122
123 // XAccessibleTable
124
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
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;
167 // XServiceInfo
168
171 virtual OUString SAL_CALL
172 getImplementationName() override;
173
176 virtual sal_Bool SAL_CALL
177 supportsService (const OUString& sServiceName) override;
178
182 virtual css::uno::Sequence< OUString> SAL_CALL
183 getSupportedServiceNames() override;
184
185 // C++ interface
186
187 // The object has been moved by the layout
188 virtual void InvalidatePosOrSize( const SwRect& rOldBox ) override;
189
190 // The object is not visible any longer and should be destroyed
191 virtual void Dispose(bool bRecursive, bool bCanSkipInvisible = true) override;
192
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;
197
198 // XAccessibleSelection
199
200 virtual void SAL_CALL selectAccessibleChild(
201 sal_Int64 nChildIndex ) override;
202
203 virtual sal_Bool SAL_CALL isAccessibleChildSelected(
204 sal_Int64 nChildIndex ) override;
205
206 virtual void SAL_CALL clearAccessibleSelection( ) override;
207
208 virtual void SAL_CALL selectAllAccessibleChildren( ) override;
209
210 virtual sal_Int64 SAL_CALL getSelectedAccessibleChildCount( ) override;
211
212 virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getSelectedAccessibleChild(
213 sal_Int64 nSelectedChildIndex ) override;
214
215 // index has to be treated as global child index.
216 virtual void SAL_CALL deselectAccessibleChild(
217 sal_Int64 nChildIndex ) override;
218
219 // XAccessibleComponent
220 sal_Int32 SAL_CALL getBackground() override;
221
222 void FireSelectionEvent( );
223 void AddSelectionCell(SwAccessibleContext*, bool bAddOrRemove);
224};
225
227{
228 if( !mpTableData )
230 return *mpTableData;
231}
232
233// #i77106# - subclass to represent table column headers
235{
236protected:
238 {}
239
240 virtual std::unique_ptr<SwAccessibleTableData_Impl> CreateNewTableData() override;
241 virtual void Notify(const SfxHint&) override;
242
243public:
244 SwAccessibleTableColHeaders(std::shared_ptr<SwAccessibleMap> const& pMap,
245 const SwTabFrame *pTabFrame);
246
247 // XInterface
248
249 virtual css::uno::Any SAL_CALL queryInterface(
250 const css::uno::Type& aType ) override;
251
252 // XAccessibleContext
253
255 virtual sal_Int64 SAL_CALL getAccessibleChildCount() override;
256
258 virtual css::uno::Reference< css::accessibility::XAccessible> SAL_CALL
259 getAccessibleChild (sal_Int64 nIndex) override;
260
261 // XAccessibleTable
262
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;
269
270 // XServiceInfo
271
274 virtual OUString SAL_CALL
275 getImplementationName() override;
276
277};
278
279/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
constexpr OUStringLiteral sServiceName
Definition: accdoc.cxx:54
virtual ~SwAccessibleTableColHeaders() override
Definition: acctable.hxx:237
virtual css::uno::Reference< css::accessibility::XAccessibleTable > SAL_CALL getAccessibleColumnHeaders() override
Definition: acctable.cxx:1717
virtual css::uno::Reference< css::accessibility::XAccessibleTable > SAL_CALL getAccessibleRowHeaders() override
Definition: acctable.cxx:1711
SwAccessibleTableColHeaders(std::shared_ptr< SwAccessibleMap > const &pMap, const SwTabFrame *pTabFrame)
Definition: acctable.cxx:1624
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &aType) override
Definition: acctable.cxx:1656
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleChild(sal_Int64 nIndex) override
Return the specified child or NULL if index is invalid.
Definition: acctable.cxx:1699
virtual void Notify(const SfxHint &) override
Definition: acctable.cxx:1651
virtual std::unique_ptr< SwAccessibleTableData_Impl > CreateNewTableData() override
Definition: acctable.cxx:1645
virtual sal_Int64 SAL_CALL getAccessibleChildCount() override
Return the number of currently visible children.
Definition: acctable.cxx:1662
virtual OUString SAL_CALL getImplementationName() override
Returns an identifier for the implementation of this object.
Definition: acctable.cxx:1724
virtual void InvalidateChildPosOrSize(const sw::access::SwAccessibleChild &rFrameOrObj, const SwRect &rFrame) override
Definition: acctable.cxx:1214
sal_Int32 SAL_CALL getBackground() override
Definition: acctable.cxx:1478
bool HasTableData() const
Definition: acctable.hxx:90
virtual void SAL_CALL clearAccessibleSelection() override
Definition: acctable.cxx:1361
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleCellAt(sal_Int32 nRow, sal_Int32 nColumn) override
Definition: acctable.cxx:1005
virtual sal_Bool SAL_CALL selectColumn(sal_Int32 column) override
Definition: acctable.cxx:1570
virtual sal_Int64 SAL_CALL getSelectedAccessibleChildCount() override
Definition: acctable.cxx:1384
virtual void DisposeChild(const sw::access::SwAccessibleChild &rFrameOrObj, bool bRecursive, bool bCanSkipInvisible) override
Definition: acctable.cxx:1191
virtual ~SwAccessibleTable() override
Definition: acctable.cxx:626
virtual OUString SAL_CALL getAccessibleDescription() override
Return this object's description.
Definition: acctable.cxx:730
virtual sal_Bool SAL_CALL isAccessibleSelected(sal_Int32 nRow, sal_Int32 nColumn) override
Definition: acctable.cxx:1034
virtual OUString SAL_CALL getAccessibleRowDescription(sal_Int32 nRow) override
Definition: acctable.cxx:757
virtual void InvalidatePosOrSize(const SwRect &rOldBox) override
Definition: acctable.cxx:1167
virtual OUString SAL_CALL getImplementationName() override
Returns an identifier for the implementation of this object.
Definition: acctable.cxx:1151
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Returns a list of all supported services.
Definition: acctable.cxx:1162
virtual css::uno::Sequence< sal_Int32 > SAL_CALL getSelectedAccessibleRows() override
Definition: acctable.cxx:908
virtual sal_Bool SAL_CALL selectRow(sal_Int32 row) override
Definition: acctable.cxx:1554
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleCaption() override
Definition: acctable.cxx:1022
bool IsChildSelected(sal_Int64 nChildIndex) const
Definition: acctable.cxx:558
virtual css::uno::Sequence< sal_Int32 > SAL_CALL getSelectedAccessibleColumns() override
Definition: acctable.cxx:931
virtual sal_Int32 SAL_CALL getAccessibleRowExtentAt(sal_Int32 nRow, sal_Int32 nColumn) override
Definition: acctable.cxx:823
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &aType) override
Definition: acctable.cxx:672
virtual sal_Bool SAL_CALL isAccessibleRowSelected(sal_Int32 nRow) override
Definition: acctable.cxx:953
SwAccessibleTableData_Impl & GetTableData()
Definition: acctable.hxx:226
const SwTableBox * GetTableBox(sal_Int64) const
get the SwTableBox* for the given child
Definition: acctable.cxx:534
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleSummary() override
Definition: acctable.cxx:1028
SwAccessibleTable(std::shared_ptr< SwAccessibleMap > const &pInitMap, const SwTabFrame *pTableFrame)
Definition: acctable.cxx:608
virtual std::unique_ptr< SwAccessibleTableData_Impl > CreateNewTableData()
Definition: acctable.cxx:713
virtual sal_Int64 SAL_CALL getAccessibleIndex(sal_Int32 nRow, sal_Int32 nColumn) override
Definition: acctable.cxx:1060
void AddSelectionCell(SwAccessibleContext *, bool bAddOrRemove)
Definition: acctable.cxx:1539
virtual sal_Bool SAL_CALL isAccessibleColumnSelected(sal_Int32 nColumn) override
Definition: acctable.cxx:978
virtual sal_Bool SAL_CALL unselectColumn(sal_Int32 column) override
Definition: acctable.cxx:1605
virtual void Dispose(bool bRecursive, bool bCanSkipInvisible=true) override
Definition: acctable.cxx:1184
virtual void GetStates(sal_Int64 &rStateSet) override
Definition: acctable.cxx:596
virtual void Notify(const SfxHint &) override
Definition: acctable.cxx:633
void ClearTableData()
Definition: acctable.cxx:725
virtual sal_Int32 SAL_CALL getAccessibleColumnCount() override
Definition: acctable.cxx:748
std::unique_ptr< SwAccessibleTableData_Impl > mpTableData
Definition: acctable.hxx:47
virtual void SAL_CALL release() noexcept override
Definition: acctable.hxx:110
std::vector< std::pair< SwAccessibleContext *, css::uno::WeakReference< css::accessibility::XAccessible > > > Cells_t
Definition: acctable.hxx:50
virtual sal_Int32 SAL_CALL getAccessibleRow(sal_Int64 nChildIndex) override
Definition: acctable.cxx:1078
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
Definition: acctable.cxx:699
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override
Definition: acctable.cxx:707
virtual void SAL_CALL selectAccessibleChild(sal_Int64 nChildIndex) override
Definition: acctable.cxx:1269
virtual void SAL_CALL acquire() noexcept override
Definition: acctable.hxx:107
virtual sal_Int32 SAL_CALL getAccessibleColumn(sal_Int64 nChildIndex) override
Definition: acctable.cxx:1114
virtual sal_Bool SAL_CALL supportsService(const OUString &sServiceName) override
Return whether the specified service is supported by this class.
Definition: acctable.cxx:1156
virtual sal_Bool SAL_CALL unselectRow(sal_Int32 row) override
Definition: acctable.cxx:1587
virtual sal_Bool SAL_CALL isAccessibleChildSelected(sal_Int64 nChildIndex) override
Definition: acctable.cxx:1348
virtual void SAL_CALL selectAllAccessibleChildren() override
Definition: acctable.cxx:1376
virtual void SAL_CALL deselectAccessibleChild(sal_Int64 nChildIndex) override
Definition: acctable.cxx:1428
OUString m_sDesc
Definition: acctable.hxx:48
virtual css::uno::Reference< css::accessibility::XAccessibleTable > SAL_CALL getAccessibleRowHeaders() override
Definition: acctable.cxx:884
virtual sal_Int32 SAL_CALL getAccessibleColumnExtentAt(sal_Int32 nRow, sal_Int32 nColumn) override
Definition: acctable.cxx:853
void UpdateTableData()
Definition: acctable.cxx:719
sal_Int64 GetIndexOfSelectedChild(sal_Int64 nSelectedChildIndex) const
Definition: acctable.cxx:572
virtual OUString SAL_CALL getAccessibleColumnDescription(sal_Int32 nColumn) override
Definition: acctable.cxx:790
virtual css::uno::Reference< css::accessibility::XAccessibleTable > SAL_CALL getAccessibleColumnHeaders() override
Definition: acctable.cxx:891
const SwSelBoxes * GetSelBoxes() const
Definition: acctable.cxx:505
void FireTableChangeEvent(const SwAccessibleTableData_Impl &rTableData)
Definition: acctable.cxx:517
void SetDesc(const OUString &sNewDesc)
Definition: acctable.hxx:73
Cells_t m_vecCellRemove
Definition: acctable.hxx:52
void FireSelectionEvent()
Definition: acctable.cxx:1498
virtual sal_Int32 SAL_CALL getAccessibleRowCount() override
Definition: acctable.cxx:739
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getSelectedAccessibleChild(sal_Int64 nSelectedChildIndex) override
Definition: acctable.cxx:1401
Cells_t m_vecCellAdd
Definition: acctable.hxx:51
Of course Writer needs its own rectangles.
Definition: swrect.hxx:35
SwTabFrame is one table in the document layout, containing rows (which contain cells).
Definition: tabfrm.hxx:49
SwTableBox is one table cell in the document model.
Definition: swtable.hxx:443
unsigned char sal_Bool