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 const SwSelBoxes *GetSelBoxes() const;
50
51 void FireTableChangeEvent( const SwAccessibleTableData_Impl& rTableData );
52
54 const SwTableBox* GetTableBox( sal_Int32 ) const;
55
56 bool IsChildSelected( sal_Int32 nChildIndex ) const;
57
58 sal_Int32 GetIndexOfSelectedChild( sal_Int32 nSelectedChildIndex ) const;
59
60protected:
61 // Set states for getAccessibleStateSet.
62 // This derived class additionally sets MULTISELECTABLE(+)
63 virtual void GetStates( ::utl::AccessibleStateSetHelper& rStateSet ) override;
64
65 virtual ~SwAccessibleTable() override;
66
67 // #i77106#
68 void SetDesc( const OUString& sNewDesc )
69 {
70 m_sDesc = sNewDesc;
71 }
72
73 virtual std::unique_ptr<SwAccessibleTableData_Impl> CreateNewTableData(); // #i77106#
74
75 // force update of table data
76 void UpdateTableData();
77
78 // remove the current table data
79 void ClearTableData();
80
81 // get table data, update if necessary
83
84 // Is table data evailable?
85 bool HasTableData() const { return (mpTableData != nullptr); }
86
87 virtual void Notify(const SfxHint&) override;
88
89public:
90 SwAccessibleTable(std::shared_ptr<SwAccessibleMap> const& pInitMap,
91 const SwTabFrame* pTableFrame);
92
93 // XInterface
94
95 // (XInterface methods need to be implemented to disambiguate
96 // between those inherited through SwAccessibleContext and
97 // XAccessibleTable).
98
99 virtual css::uno::Any SAL_CALL queryInterface(
100 const css::uno::Type& aType ) override;
101
102 virtual void SAL_CALL acquire( ) noexcept override
103 { SwAccessibleContext::acquire(); };
104
105 virtual void SAL_CALL release( ) noexcept override
106 { SwAccessibleContext::release(); };
107
108 // XTypeProvider
109 virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override;
110 virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) override;
111
112 // XAccessibleContext
113
115 virtual OUString SAL_CALL
116 getAccessibleDescription() override;
117
118 // XAccessibleTable
119
120 virtual sal_Int32 SAL_CALL getAccessibleRowCount() override;
121 virtual sal_Int32 SAL_CALL getAccessibleColumnCount( ) override;
122 virtual OUString SAL_CALL getAccessibleRowDescription(
123 sal_Int32 nRow ) override;
124 virtual OUString SAL_CALL getAccessibleColumnDescription(
125 sal_Int32 nColumn ) override;
126 virtual sal_Int32 SAL_CALL getAccessibleRowExtentAt(
127 sal_Int32 nRow, sal_Int32 nColumn ) override;
128 virtual sal_Int32 SAL_CALL getAccessibleColumnExtentAt(
129 sal_Int32 nRow, sal_Int32 nColumn ) override;
130 virtual css::uno::Reference<
131 css::accessibility::XAccessibleTable >
132 SAL_CALL getAccessibleRowHeaders( ) override;
133 virtual css::uno::Reference<
134 css::accessibility::XAccessibleTable >
135 SAL_CALL getAccessibleColumnHeaders( ) override;
136 virtual css::uno::Sequence< sal_Int32 > SAL_CALL
137 getSelectedAccessibleRows( ) override;
138 virtual css::uno::Sequence< sal_Int32 > SAL_CALL
140 virtual sal_Bool SAL_CALL isAccessibleRowSelected( sal_Int32 nRow ) override;
141 virtual sal_Bool SAL_CALL isAccessibleColumnSelected( sal_Int32 nColumn ) override;
142 virtual css::uno::Reference<
143 css::accessibility::XAccessible > SAL_CALL
144 getAccessibleCellAt( sal_Int32 nRow, sal_Int32 nColumn ) override;
145 virtual css::uno::Reference<
146 css::accessibility::XAccessible > SAL_CALL
147 getAccessibleCaption( ) override;
148 virtual css::uno::Reference<
149 css::accessibility::XAccessible > SAL_CALL
150 getAccessibleSummary( ) override;
151 virtual sal_Bool SAL_CALL isAccessibleSelected(
152 sal_Int32 nRow, sal_Int32 nColumn ) override;
153 virtual sal_Int32 SAL_CALL getAccessibleIndex(
154 sal_Int32 nRow, sal_Int32 nColumn ) override;
155 virtual sal_Int32 SAL_CALL getAccessibleRow( sal_Int32 nChildIndex ) override;
156 virtual sal_Int32 SAL_CALL getAccessibleColumn( sal_Int32 nChildIndex ) override;
157 // XAccessibleTableSelection
158 virtual sal_Bool SAL_CALL selectRow( sal_Int32 row ) override ;
159 virtual sal_Bool SAL_CALL selectColumn( sal_Int32 column ) override ;
160 virtual sal_Bool SAL_CALL unselectRow( sal_Int32 row ) override;
161 virtual sal_Bool SAL_CALL unselectColumn( sal_Int32 column ) override;
162 // XServiceInfo
163
166 virtual OUString SAL_CALL
167 getImplementationName() override;
168
171 virtual sal_Bool SAL_CALL
172 supportsService (const OUString& sServiceName) override;
173
177 virtual css::uno::Sequence< OUString> SAL_CALL
178 getSupportedServiceNames() override;
179
180 // C++ interface
181
182 // The object has been moved by the layout
183 virtual void InvalidatePosOrSize( const SwRect& rOldBox ) override;
184
185 // The object is not visible any longer and should be destroyed
186 virtual void Dispose(bool bRecursive, bool bCanSkipInvisible = true) override;
187
188 virtual void DisposeChild( const sw::access::SwAccessibleChild& rFrameOrObj,
189 bool bRecursive, bool bCanSkipInvisible ) override;
190 virtual void InvalidateChildPosOrSize( const sw::access::SwAccessibleChild& rFrameOrObj,
191 const SwRect& rFrame ) override;
192
193 // XAccessibleSelection
194
195 virtual void SAL_CALL selectAccessibleChild(
196 sal_Int32 nChildIndex ) override;
197
198 virtual sal_Bool SAL_CALL isAccessibleChildSelected(
199 sal_Int32 nChildIndex ) override;
200
201 virtual void SAL_CALL clearAccessibleSelection( ) override;
202
203 virtual void SAL_CALL selectAllAccessibleChildren( ) override;
204
205 virtual sal_Int32 SAL_CALL getSelectedAccessibleChildCount( ) override;
206
207 virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getSelectedAccessibleChild(
208 sal_Int32 nSelectedChildIndex ) override;
209
210 // index has to be treated as global child index.
211 virtual void SAL_CALL deselectAccessibleChild(
212 sal_Int32 nChildIndex ) override;
213
214 // XAccessibleComponent
215 sal_Int32 SAL_CALL getBackground() override;
216 typedef std::vector< std::pair<SwAccessibleContext*,
217 css::uno::WeakReference<css::accessibility::XAccessible> > > Cells_t;
220 void FireSelectionEvent( );
221 void AddSelectionCell(SwAccessibleContext*, bool bAddOrRemove);
222};
223
225{
226 if( !mpTableData )
228 return *mpTableData;
229}
230
231// #i77106# - subclass to represent table column headers
233{
234protected:
236 {}
237
238 virtual std::unique_ptr<SwAccessibleTableData_Impl> CreateNewTableData() override;
239 virtual void Notify(const SfxHint&) override;
240
241public:
242 SwAccessibleTableColHeaders(std::shared_ptr<SwAccessibleMap> const& pMap,
243 const SwTabFrame *pTabFrame);
244
245 // XInterface
246
247 virtual css::uno::Any SAL_CALL queryInterface(
248 const css::uno::Type& aType ) override;
249
250 // XAccessibleContext
251
253 virtual sal_Int32 SAL_CALL getAccessibleChildCount() override;
254
256 virtual css::uno::Reference< css::accessibility::XAccessible> SAL_CALL
257 getAccessibleChild (sal_Int32 nIndex) override;
258
259 // XAccessibleTable
260
261 virtual css::uno::Reference<
262 css::accessibility::XAccessibleTable >
263 SAL_CALL getAccessibleRowHeaders( ) override;
264 virtual css::uno::Reference<
265 css::accessibility::XAccessibleTable >
266 SAL_CALL getAccessibleColumnHeaders( ) override;
267
268 // XServiceInfo
269
272 virtual OUString SAL_CALL
273 getImplementationName() override;
274
275};
276
277/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
constexpr OUStringLiteral sServiceName
Definition: accdoc.cxx:55
virtual ~SwAccessibleTableColHeaders() override
Definition: acctable.hxx:235
virtual css::uno::Reference< css::accessibility::XAccessibleTable > SAL_CALL getAccessibleColumnHeaders() override
Definition: acctable.cxx:1725
virtual css::uno::Reference< css::accessibility::XAccessibleTable > SAL_CALL getAccessibleRowHeaders() override
Definition: acctable.cxx:1719
SwAccessibleTableColHeaders(std::shared_ptr< SwAccessibleMap > const &pMap, const SwTabFrame *pTabFrame)
Definition: acctable.cxx:1632
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleChild(sal_Int32 nIndex) override
Return the specified child or NULL if index is invalid.
Definition: acctable.cxx:1707
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &aType) override
Definition: acctable.cxx:1664
virtual void Notify(const SfxHint &) override
Definition: acctable.cxx:1659
virtual sal_Int32 SAL_CALL getAccessibleChildCount() override
Return the number of currently visible children.
Definition: acctable.cxx:1670
virtual std::unique_ptr< SwAccessibleTableData_Impl > CreateNewTableData() override
Definition: acctable.cxx:1653
virtual OUString SAL_CALL getImplementationName() override
Returns an identifier for the implementation of this object.
Definition: acctable.cxx:1732
virtual void InvalidateChildPosOrSize(const sw::access::SwAccessibleChild &rFrameOrObj, const SwRect &rFrame) override
Definition: acctable.cxx:1222
sal_Int32 SAL_CALL getBackground() override
Definition: acctable.cxx:1486
bool HasTableData() const
Definition: acctable.hxx:85
virtual void SAL_CALL clearAccessibleSelection() override
Definition: acctable.cxx:1369
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleCellAt(sal_Int32 nRow, sal_Int32 nColumn) override
Definition: acctable.cxx:1013
virtual sal_Bool SAL_CALL selectColumn(sal_Int32 column) override
Definition: acctable.cxx:1578
virtual void DisposeChild(const sw::access::SwAccessibleChild &rFrameOrObj, bool bRecursive, bool bCanSkipInvisible) override
Definition: acctable.cxx:1199
virtual ~SwAccessibleTable() override
Definition: acctable.cxx:628
virtual void SAL_CALL deselectAccessibleChild(sal_Int32 nChildIndex) override
Definition: acctable.cxx:1436
const SwTableBox * GetTableBox(sal_Int32) const
get the SwTableBox* for the given child
Definition: acctable.cxx:535
virtual OUString SAL_CALL getAccessibleDescription() override
Return this object's description.
Definition: acctable.cxx:738
virtual sal_Bool SAL_CALL isAccessibleSelected(sal_Int32 nRow, sal_Int32 nColumn) override
Definition: acctable.cxx:1042
virtual sal_Bool SAL_CALL isAccessibleChildSelected(sal_Int32 nChildIndex) override
Definition: acctable.cxx:1356
virtual OUString SAL_CALL getAccessibleRowDescription(sal_Int32 nRow) override
Definition: acctable.cxx:765
virtual void InvalidatePosOrSize(const SwRect &rOldBox) override
Definition: acctable.cxx:1175
virtual OUString SAL_CALL getImplementationName() override
Returns an identifier for the implementation of this object.
Definition: acctable.cxx:1159
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Returns a list of all supported services.
Definition: acctable.cxx:1170
virtual css::uno::Sequence< sal_Int32 > SAL_CALL getSelectedAccessibleRows() override
Definition: acctable.cxx:916
virtual sal_Bool SAL_CALL selectRow(sal_Int32 row) override
Definition: acctable.cxx:1562
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleCaption() override
Definition: acctable.cxx:1030
virtual css::uno::Sequence< sal_Int32 > SAL_CALL getSelectedAccessibleColumns() override
Definition: acctable.cxx:939
virtual sal_Int32 SAL_CALL getAccessibleRowExtentAt(sal_Int32 nRow, sal_Int32 nColumn) override
Definition: acctable.cxx:831
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &aType) override
Definition: acctable.cxx:680
virtual sal_Bool SAL_CALL isAccessibleRowSelected(sal_Int32 nRow) override
Definition: acctable.cxx:961
SwAccessibleTableData_Impl & GetTableData()
Definition: acctable.hxx:224
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleSummary() override
Definition: acctable.cxx:1036
SwAccessibleTable(std::shared_ptr< SwAccessibleMap > const &pInitMap, const SwTabFrame *pTableFrame)
Definition: acctable.cxx:610
virtual std::unique_ptr< SwAccessibleTableData_Impl > CreateNewTableData()
Definition: acctable.cxx:721
void AddSelectionCell(SwAccessibleContext *, bool bAddOrRemove)
Definition: acctable.cxx:1547
virtual sal_Bool SAL_CALL isAccessibleColumnSelected(sal_Int32 nColumn) override
Definition: acctable.cxx:986
virtual sal_Bool SAL_CALL unselectColumn(sal_Int32 column) override
Definition: acctable.cxx:1613
virtual void GetStates(::utl::AccessibleStateSetHelper &rStateSet) override
Definition: acctable.cxx:597
virtual sal_Int32 SAL_CALL getAccessibleRow(sal_Int32 nChildIndex) override
Definition: acctable.cxx:1086
virtual void Dispose(bool bRecursive, bool bCanSkipInvisible=true) override
Definition: acctable.cxx:1192
virtual sal_Int32 SAL_CALL getAccessibleIndex(sal_Int32 nRow, sal_Int32 nColumn) override
Definition: acctable.cxx:1068
virtual void Notify(const SfxHint &) override
Definition: acctable.cxx:635
void ClearTableData()
Definition: acctable.cxx:733
virtual sal_Int32 SAL_CALL getAccessibleColumnCount() override
Definition: acctable.cxx:756
virtual sal_Int32 SAL_CALL getSelectedAccessibleChildCount() override
Definition: acctable.cxx:1392
std::unique_ptr< SwAccessibleTableData_Impl > mpTableData
Definition: acctable.hxx:47
virtual void SAL_CALL release() noexcept override
Definition: acctable.hxx:105
std::vector< std::pair< SwAccessibleContext *, css::uno::WeakReference< css::accessibility::XAccessible > > > Cells_t
Definition: acctable.hxx:217
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
Definition: acctable.cxx:707
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override
Definition: acctable.cxx:715
virtual void SAL_CALL acquire() noexcept override
Definition: acctable.hxx:102
bool IsChildSelected(sal_Int32 nChildIndex) const
Definition: acctable.cxx:559
virtual sal_Bool SAL_CALL supportsService(const OUString &sServiceName) override
Return whether the specified service is supported by this class.
Definition: acctable.cxx:1164
virtual sal_Bool SAL_CALL unselectRow(sal_Int32 row) override
Definition: acctable.cxx:1595
virtual void SAL_CALL selectAccessibleChild(sal_Int32 nChildIndex) override
Definition: acctable.cxx:1277
virtual void SAL_CALL selectAllAccessibleChildren() override
Definition: acctable.cxx:1384
virtual sal_Int32 SAL_CALL getAccessibleColumn(sal_Int32 nChildIndex) override
Definition: acctable.cxx:1122
OUString m_sDesc
Definition: acctable.hxx:48
virtual css::uno::Reference< css::accessibility::XAccessibleTable > SAL_CALL getAccessibleRowHeaders() override
Definition: acctable.cxx:892
virtual sal_Int32 SAL_CALL getAccessibleColumnExtentAt(sal_Int32 nRow, sal_Int32 nColumn) override
Definition: acctable.cxx:861
void UpdateTableData()
Definition: acctable.cxx:727
virtual OUString SAL_CALL getAccessibleColumnDescription(sal_Int32 nColumn) override
Definition: acctable.cxx:798
virtual css::uno::Reference< css::accessibility::XAccessibleTable > SAL_CALL getAccessibleColumnHeaders() override
Definition: acctable.cxx:899
const SwSelBoxes * GetSelBoxes() const
Definition: acctable.cxx:506
void FireTableChangeEvent(const SwAccessibleTableData_Impl &rTableData)
Definition: acctable.cxx:518
sal_Int32 GetIndexOfSelectedChild(sal_Int32 nSelectedChildIndex) const
Definition: acctable.cxx:573
void SetDesc(const OUString &sNewDesc)
Definition: acctable.hxx:68
Cells_t m_vecCellRemove
Definition: acctable.hxx:219
void FireSelectionEvent()
Definition: acctable.cxx:1506
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getSelectedAccessibleChild(sal_Int32 nSelectedChildIndex) override
Definition: acctable.cxx:1409
virtual sal_Int32 SAL_CALL getAccessibleRowCount() override
Definition: acctable.cxx:747
Cells_t m_vecCellAdd
Definition: acctable.hxx:218
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:47
SwTableBox is one table cell in the document model.
Definition: swtable.hxx:419
unsigned char sal_Bool