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 
31 class SwTabFrame;
33 class SwTableBox;
34 class SwSelBoxes;
35 
36 namespace sw::access {
37  class SwAccessibleChild;
38 }
39 
41  public SwAccessibleContext,
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 
60 protected:
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 
89 public:
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( ) throw () override
103  { SwAccessibleContext::acquire(); };
104 
105  virtual void SAL_CALL release( ) throw () 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
139  getSelectedAccessibleColumns( ) override;
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;
218  Cells_t m_vecCellAdd;
220  void FireSelectionEvent( );
221  void AddSelectionCell(SwAccessibleContext*, bool bAddOrRemove);
222 };
223 
225 {
226  if( !mpTableData )
227  UpdateTableData();
228  return *mpTableData;
229 }
230 
231 // #i77106# - subclass to represent table column headers
233 {
234 protected:
235  virtual ~SwAccessibleTableColHeaders() override
236  {}
237 
238  virtual std::unique_ptr<SwAccessibleTableData_Impl> CreateNewTableData() override;
239  virtual void Notify(const SfxHint&) override;
240 
241 public:
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: */
virtual void Dispose(bool bRecursive, bool bCanSkipInvisible=true) override
Definition: acctable.cxx:1191
virtual sal_Bool SAL_CALL selectColumn(sal_Int32 column) override
Definition: acctable.cxx:1577
virtual OUString SAL_CALL getImplementationName() override
Returns an identifier for the implementation of this object.
Definition: acctable.cxx:1731
virtual sal_Bool SAL_CALL unselectRow(sal_Int32 row) override
Definition: acctable.cxx:1594
virtual void SAL_CALL selectAllAccessibleChildren() override
Definition: acctable.cxx:1383
sal_Int32 SAL_CALL getBackground() override
Definition: acctable.cxx:1485
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleCaption() override
Definition: acctable.cxx:1029
virtual void SAL_CALL selectAccessibleChild(sal_Int32 nChildIndex) override
Definition: acctable.cxx:1276
virtual void InvalidatePosOrSize(const SwRect &rOldBox) override
Definition: acctable.cxx:1174
virtual OUString SAL_CALL getAccessibleRowDescription(sal_Int32 nRow) override
Definition: acctable.cxx:764
virtual sal_Bool SAL_CALL isAccessibleColumnSelected(sal_Int32 nColumn) override
Definition: acctable.cxx:985
SwTabFrame is one table in the document layout, containing rows (which contain cells).
Definition: tabfrm.hxx:30
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:706
Cells_t m_vecCellRemove
Definition: acctable.hxx:219
virtual sal_Bool SAL_CALL supportsService(const OUString &sServiceName) override
Return whether the specified service is supported by this class.
Definition: acctable.cxx:1163
Cells_t m_vecCellAdd
Definition: acctable.hxx:218
virtual std::unique_ptr< SwAccessibleTableData_Impl > CreateNewTableData() override
Definition: acctable.cxx:1652
Of course Writer needs its own rectangles.
Definition: swrect.hxx:35
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getSelectedAccessibleChild(sal_Int32 nSelectedChildIndex) override
Definition: acctable.cxx:1408
virtual void Notify(const SfxHint &) override
Definition: acctable.cxx:635
void UpdateTableData()
Definition: acctable.cxx:726
virtual OUString SAL_CALL getImplementationName() override
Returns an identifier for the implementation of this object.
Definition: acctable.cxx:1158
virtual sal_Int32 SAL_CALL getAccessibleRowCount() override
Definition: acctable.cxx:746
virtual sal_Int32 SAL_CALL getSelectedAccessibleChildCount() override
Definition: acctable.cxx:1391
OUString m_sDesc
Definition: acctable.hxx:48
virtual sal_Int32 SAL_CALL getAccessibleIndex(sal_Int32 nRow, sal_Int32 nColumn) override
Definition: acctable.cxx:1067
constexpr OUStringLiteral sServiceName
Definition: accdoc.cxx:55
virtual OUString SAL_CALL getAccessibleDescription() override
Return this object's description.
Definition: acctable.cxx:737
virtual sal_Bool SAL_CALL isAccessibleRowSelected(sal_Int32 nRow) override
Definition: acctable.cxx:960
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleCellAt(sal_Int32 nRow, sal_Int32 nColumn) override
Definition: acctable.cxx:1012
const SwTableBox * GetTableBox(sal_Int32) const
get the SwTableBox* for the given child
Definition: acctable.cxx:535
virtual sal_Bool SAL_CALL isAccessibleSelected(sal_Int32 nRow, sal_Int32 nColumn) override
Definition: acctable.cxx:1041
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &aType) override
Definition: acctable.cxx:1663
virtual void SAL_CALL deselectAccessibleChild(sal_Int32 nChildIndex) override
Definition: acctable.cxx:1435
virtual sal_Int32 SAL_CALL getAccessibleRowExtentAt(sal_Int32 nRow, sal_Int32 nColumn) override
Definition: acctable.cxx:830
virtual void SAL_CALL acquire() override
Definition: acctable.hxx:102
virtual sal_Bool SAL_CALL unselectColumn(sal_Int32 column) override
Definition: acctable.cxx:1612
std::unique_ptr< SwAccessibleTableData_Impl > mpTableData
Definition: acctable.hxx:47
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:1706
virtual css::uno::Reference< css::accessibility::XAccessibleTable > SAL_CALL getAccessibleColumnHeaders() override
Definition: acctable.cxx:898
void AddSelectionCell(SwAccessibleContext *, bool bAddOrRemove)
Definition: acctable.cxx:1546
unsigned char sal_Bool
virtual sal_Int32 SAL_CALL getAccessibleChildCount() override
Return the number of currently visible children.
Definition: acctable.cxx:1669
virtual css::uno::Reference< css::accessibility::XAccessibleTable > SAL_CALL getAccessibleColumnHeaders() override
Definition: acctable.cxx:1724
virtual void DisposeChild(const sw::access::SwAccessibleChild &rFrameOrObj, bool bRecursive, bool bCanSkipInvisible) override
Definition: acctable.cxx:1198
virtual sal_Int32 SAL_CALL getAccessibleColumnExtentAt(sal_Int32 nRow, sal_Int32 nColumn) override
Definition: acctable.cxx:860
virtual void InvalidateChildPosOrSize(const sw::access::SwAccessibleChild &rFrameOrObj, const SwRect &rFrame) override
Definition: acctable.cxx:1221
sal_Int32 GetIndexOfSelectedChild(sal_Int32 nSelectedChildIndex) const
Definition: acctable.cxx:573
virtual css::uno::Reference< css::accessibility::XAccessibleTable > SAL_CALL getAccessibleRowHeaders() override
Definition: acctable.cxx:1718
virtual void SAL_CALL clearAccessibleSelection() override
Definition: acctable.cxx:1368
SwAccessibleTable(std::shared_ptr< SwAccessibleMap > const &pInitMap, const SwTabFrame *pTableFrame)
Definition: acctable.cxx:610
bool HasTableData() const
Definition: acctable.hxx:85
SwAccessibleTableData_Impl & GetTableData()
Definition: acctable.hxx:224
void ClearTableData()
Definition: acctable.cxx:732
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Returns a list of all supported services.
Definition: acctable.cxx:1169
virtual sal_Int32 SAL_CALL getAccessibleRow(sal_Int32 nChildIndex) override
Definition: acctable.cxx:1085
void FireTableChangeEvent(const SwAccessibleTableData_Impl &rTableData)
Definition: acctable.cxx:518
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &aType) override
Definition: acctable.cxx:679
virtual ~SwAccessibleTable() override
Definition: acctable.cxx:628
SwTableBox is one table cell in the document model.
Definition: swtable.hxx:392
const SwSelBoxes * GetSelBoxes() const
Definition: acctable.cxx:506
void FireSelectionEvent()
Definition: acctable.cxx:1505
bool IsChildSelected(sal_Int32 nChildIndex) const
Definition: acctable.cxx:559
virtual void GetStates(::utl::AccessibleStateSetHelper &rStateSet) override
Definition: acctable.cxx:597
virtual std::unique_ptr< SwAccessibleTableData_Impl > CreateNewTableData()
Definition: acctable.cxx:720
virtual OUString SAL_CALL getAccessibleColumnDescription(sal_Int32 nColumn) override
Definition: acctable.cxx:797
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleSummary() override
Definition: acctable.cxx:1035
virtual sal_Bool SAL_CALL isAccessibleChildSelected(sal_Int32 nChildIndex) override
Definition: acctable.cxx:1355
SwAccessibleTableColHeaders(std::shared_ptr< SwAccessibleMap > const &pMap, const SwTabFrame *pTabFrame)
Definition: acctable.cxx:1631
virtual sal_Int32 SAL_CALL getAccessibleColumn(sal_Int32 nChildIndex) override
Definition: acctable.cxx:1121
virtual sal_Int32 SAL_CALL getAccessibleColumnCount() override
Definition: acctable.cxx:755
virtual css::uno::Reference< css::accessibility::XAccessibleTable > SAL_CALL getAccessibleRowHeaders() override
Definition: acctable.cxx:891
virtual ~SwAccessibleTableColHeaders() override
Definition: acctable.hxx:235
virtual css::uno::Sequence< sal_Int32 > SAL_CALL getSelectedAccessibleColumns() override
Definition: acctable.cxx:938
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override
Definition: acctable.cxx:714
virtual void SAL_CALL release() override
Definition: acctable.hxx:105
void SetDesc(const OUString &sNewDesc)
Definition: acctable.hxx:68
virtual void Notify(const SfxHint &) override
Definition: acctable.cxx:1658
virtual css::uno::Sequence< sal_Int32 > SAL_CALL getSelectedAccessibleRows() override
Definition: acctable.cxx:915
virtual sal_Bool SAL_CALL selectRow(sal_Int32 row) override
Definition: acctable.cxx:1561