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 #ifndef INCLUDED_SW_SOURCE_CORE_ACCESS_ACCTABLE_HXX
21 #define INCLUDED_SW_SOURCE_CORE_ACCESS_ACCTABLE_HXX
22 
23 #include <com/sun/star/accessibility/XAccessibleTable.hpp>
24 #include <com/sun/star/accessibility/XAccessibleTableSelection.hpp>
25 #include <vector>
26 #include <com/sun/star/accessibility/XAccessibleSelection.hpp>
27 
28 #include <svl/poolitem.hxx>
29 #include <svl/listener.hxx>
30 
31 #include "acccontext.hxx"
32 
33 class SwTabFrame;
35 class SwTableBox;
36 class SwSelBoxes;
37 
38 namespace sw::access {
39  class SwAccessibleChild;
40 }
41 
43  public SwAccessibleContext,
44  public css::accessibility::XAccessibleTable,
45  public css::accessibility::XAccessibleSelection,
46  public css::accessibility::XAccessibleTableSelection,
47  public SvtListener
48 {
49  std::unique_ptr<SwAccessibleTableData_Impl> mpTableData; // the table's data, protected by SolarMutex
50  OUString m_sDesc;
51  const SwSelBoxes *GetSelBoxes() const;
52 
53  void FireTableChangeEvent( const SwAccessibleTableData_Impl& rTableData );
54 
56  const SwTableBox* GetTableBox( sal_Int32 ) const;
57 
58  bool IsChildSelected( sal_Int32 nChildIndex ) const;
59 
60  sal_Int32 GetIndexOfSelectedChild( sal_Int32 nSelectedChildIndex ) const;
61 
62 protected:
63  // Set states for getAccessibleStateSet.
64  // This derived class additionally sets MULTISELECTABLE(+)
65  virtual void GetStates( ::utl::AccessibleStateSetHelper& rStateSet ) override;
66 
67  virtual ~SwAccessibleTable() override;
68 
69  // #i77106#
70  void SetDesc( const OUString& sNewDesc )
71  {
72  m_sDesc = sNewDesc;
73  }
74 
75  virtual std::unique_ptr<SwAccessibleTableData_Impl> CreateNewTableData(); // #i77106#
76 
77  // force update of table data
78  void UpdateTableData();
79 
80  // remove the current table data
81  void ClearTableData();
82 
83  // get table data, update if necessary
85 
86  // Is table data evailable?
87  bool HasTableData() const { return (mpTableData != nullptr); }
88 
89  virtual void Notify(const SfxHint&) override;
90 
91 public:
92  SwAccessibleTable(std::shared_ptr<SwAccessibleMap> const& pInitMap,
93  const SwTabFrame* pTableFrame);
94 
95  // XInterface
96 
97  // (XInterface methods need to be implemented to disambiguate
98  // between those inherited through SwAccessibleContext and
99  // XAccessibleTable).
100 
101  virtual css::uno::Any SAL_CALL queryInterface(
102  const css::uno::Type& aType ) override;
103 
104  virtual void SAL_CALL acquire( ) throw () override
105  { SwAccessibleContext::acquire(); };
106 
107  virtual void SAL_CALL release( ) throw () override
108  { SwAccessibleContext::release(); };
109 
110  // XTypeProvider
111  virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override;
112  virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) override;
113 
114  // XAccessibleContext
115 
117  virtual OUString SAL_CALL
118  getAccessibleDescription() override;
119 
120  // XAccessibleTable
121 
122  virtual sal_Int32 SAL_CALL getAccessibleRowCount() override;
123  virtual sal_Int32 SAL_CALL getAccessibleColumnCount( ) override;
124  virtual OUString SAL_CALL getAccessibleRowDescription(
125  sal_Int32 nRow ) override;
126  virtual OUString SAL_CALL getAccessibleColumnDescription(
127  sal_Int32 nColumn ) override;
128  virtual sal_Int32 SAL_CALL getAccessibleRowExtentAt(
129  sal_Int32 nRow, sal_Int32 nColumn ) override;
130  virtual sal_Int32 SAL_CALL getAccessibleColumnExtentAt(
131  sal_Int32 nRow, sal_Int32 nColumn ) override;
132  virtual css::uno::Reference<
133  css::accessibility::XAccessibleTable >
134  SAL_CALL getAccessibleRowHeaders( ) override;
135  virtual css::uno::Reference<
136  css::accessibility::XAccessibleTable >
137  SAL_CALL getAccessibleColumnHeaders( ) override;
138  virtual css::uno::Sequence< sal_Int32 > SAL_CALL
139  getSelectedAccessibleRows( ) override;
140  virtual css::uno::Sequence< sal_Int32 > SAL_CALL
141  getSelectedAccessibleColumns( ) override;
142  virtual sal_Bool SAL_CALL isAccessibleRowSelected( sal_Int32 nRow ) override;
143  virtual sal_Bool SAL_CALL isAccessibleColumnSelected( sal_Int32 nColumn ) override;
144  virtual css::uno::Reference<
145  css::accessibility::XAccessible > SAL_CALL
146  getAccessibleCellAt( sal_Int32 nRow, sal_Int32 nColumn ) override;
147  virtual css::uno::Reference<
148  css::accessibility::XAccessible > SAL_CALL
149  getAccessibleCaption( ) override;
150  virtual css::uno::Reference<
151  css::accessibility::XAccessible > SAL_CALL
152  getAccessibleSummary( ) override;
153  virtual sal_Bool SAL_CALL isAccessibleSelected(
154  sal_Int32 nRow, sal_Int32 nColumn ) override;
155  virtual sal_Int32 SAL_CALL getAccessibleIndex(
156  sal_Int32 nRow, sal_Int32 nColumn ) override;
157  virtual sal_Int32 SAL_CALL getAccessibleRow( sal_Int32 nChildIndex ) override;
158  virtual sal_Int32 SAL_CALL getAccessibleColumn( sal_Int32 nChildIndex ) override;
159  // XAccessibleTableSelection
160  virtual sal_Bool SAL_CALL selectRow( sal_Int32 row ) override ;
161  virtual sal_Bool SAL_CALL selectColumn( sal_Int32 column ) override ;
162  virtual sal_Bool SAL_CALL unselectRow( sal_Int32 row ) override;
163  virtual sal_Bool SAL_CALL unselectColumn( sal_Int32 column ) override;
164  // XServiceInfo
165 
168  virtual OUString SAL_CALL
169  getImplementationName() override;
170 
173  virtual sal_Bool SAL_CALL
174  supportsService (const OUString& sServiceName) override;
175 
179  virtual css::uno::Sequence< OUString> SAL_CALL
180  getSupportedServiceNames() override;
181 
182  // C++ interface
183 
184  // The object has been moved by the layout
185  virtual void InvalidatePosOrSize( const SwRect& rOldBox ) override;
186 
187  // The object is not visible any longer and should be destroyed
188  virtual void Dispose(bool bRecursive, bool bCanSkipInvisible = true) override;
189 
190  virtual void DisposeChild( const sw::access::SwAccessibleChild& rFrameOrObj,
191  bool bRecursive, bool bCanSkipInvisible ) override;
192  virtual void InvalidateChildPosOrSize( const sw::access::SwAccessibleChild& rFrameOrObj,
193  const SwRect& rFrame ) override;
194 
195  // XAccessibleSelection
196 
197  virtual void SAL_CALL selectAccessibleChild(
198  sal_Int32 nChildIndex ) override;
199 
200  virtual sal_Bool SAL_CALL isAccessibleChildSelected(
201  sal_Int32 nChildIndex ) override;
202 
203  virtual void SAL_CALL clearAccessibleSelection( ) override;
204 
205  virtual void SAL_CALL selectAllAccessibleChildren( ) override;
206 
207  virtual sal_Int32 SAL_CALL getSelectedAccessibleChildCount( ) override;
208 
209  virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getSelectedAccessibleChild(
210  sal_Int32 nSelectedChildIndex ) override;
211 
212  // index has to be treated as global child index.
213  virtual void SAL_CALL deselectAccessibleChild(
214  sal_Int32 nChildIndex ) override;
215 
216  // XAccessibleComponent
217  sal_Int32 SAL_CALL getBackground() override;
218  typedef std::vector< std::pair<SwAccessibleContext*,
219  css::uno::WeakReference<css::accessibility::XAccessible> > > Cells_t;
220  Cells_t m_vecCellAdd;
222  void FireSelectionEvent( );
223  void AddSelectionCell(SwAccessibleContext*, bool bAddOrRemove);
224 };
225 
227 {
228  if( !mpTableData )
229  UpdateTableData();
230  return *mpTableData;
231 }
232 
233 // #i77106# - subclass to represent table column headers
235 {
236 protected:
237  virtual ~SwAccessibleTableColHeaders() override
238  {}
239 
240  virtual std::unique_ptr<SwAccessibleTableData_Impl> CreateNewTableData() override;
241  virtual void Notify(const SfxHint&) override;
242 
243 public:
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_Int32 SAL_CALL getAccessibleChildCount() override;
256 
258  virtual css::uno::Reference< css::accessibility::XAccessible> SAL_CALL
259  getAccessibleChild (sal_Int32 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 #endif
279 
280 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void Dispose(bool bRecursive, bool bCanSkipInvisible=true) override
Definition: acctable.cxx:1251
virtual sal_Bool SAL_CALL selectColumn(sal_Int32 column) override
Definition: acctable.cxx:1637
virtual OUString SAL_CALL getImplementationName() override
Returns an identifier for the implementation of this object.
Definition: acctable.cxx:1791
virtual sal_Bool SAL_CALL unselectRow(sal_Int32 row) override
Definition: acctable.cxx:1654
virtual void SAL_CALL selectAllAccessibleChildren() override
Definition: acctable.cxx:1443
sal_Int32 SAL_CALL getBackground() override
Definition: acctable.cxx:1545
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleCaption() override
Definition: acctable.cxx:1089
virtual void SAL_CALL selectAccessibleChild(sal_Int32 nChildIndex) override
Definition: acctable.cxx:1336
virtual void InvalidatePosOrSize(const SwRect &rOldBox) override
Definition: acctable.cxx:1234
virtual OUString SAL_CALL getAccessibleRowDescription(sal_Int32 nRow) override
Definition: acctable.cxx:823
virtual sal_Bool SAL_CALL isAccessibleColumnSelected(sal_Int32 nColumn) override
Definition: acctable.cxx:1045
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:219
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
Definition: acctable.cxx:765
Cells_t m_vecCellRemove
Definition: acctable.hxx:221
virtual sal_Bool SAL_CALL supportsService(const OUString &sServiceName) override
Return whether the specified service is supported by this class.
Definition: acctable.cxx:1223
Cells_t m_vecCellAdd
Definition: acctable.hxx:220
virtual std::unique_ptr< SwAccessibleTableData_Impl > CreateNewTableData() override
Definition: acctable.cxx:1712
Of course Writer needs its own rectangles.
Definition: swrect.hxx:34
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getSelectedAccessibleChild(sal_Int32 nSelectedChildIndex) override
Definition: acctable.cxx:1468
virtual void Notify(const SfxHint &) override
Definition: acctable.cxx:694
void UpdateTableData()
Definition: acctable.cxx:785
virtual OUString SAL_CALL getImplementationName() override
Returns an identifier for the implementation of this object.
Definition: acctable.cxx:1218
virtual sal_Int32 SAL_CALL getAccessibleRowCount() override
Definition: acctable.cxx:805
virtual sal_Int32 SAL_CALL getSelectedAccessibleChildCount() override
Definition: acctable.cxx:1451
OUString m_sDesc
Definition: acctable.hxx:50
virtual sal_Int32 SAL_CALL getAccessibleIndex(sal_Int32 nRow, sal_Int32 nColumn) override
Definition: acctable.cxx:1127
virtual OUString SAL_CALL getAccessibleDescription() override
Return this object's description.
Definition: acctable.cxx:796
virtual sal_Bool SAL_CALL isAccessibleRowSelected(sal_Int32 nRow) override
Definition: acctable.cxx:1020
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleCellAt(sal_Int32 nRow, sal_Int32 nColumn) override
Definition: acctable.cxx:1072
const SwTableBox * GetTableBox(sal_Int32) const
get the SwTableBox* for the given child
Definition: acctable.cxx:594
virtual sal_Bool SAL_CALL isAccessibleSelected(sal_Int32 nRow, sal_Int32 nColumn) override
Definition: acctable.cxx:1101
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &aType) override
Definition: acctable.cxx:1723
virtual void SAL_CALL deselectAccessibleChild(sal_Int32 nChildIndex) override
Definition: acctable.cxx:1495
virtual sal_Int32 SAL_CALL getAccessibleRowExtentAt(sal_Int32 nRow, sal_Int32 nColumn) override
Definition: acctable.cxx:889
virtual void SAL_CALL acquire() override
Definition: acctable.hxx:104
virtual sal_Bool SAL_CALL unselectColumn(sal_Int32 column) override
Definition: acctable.cxx:1672
std::unique_ptr< SwAccessibleTableData_Impl > mpTableData
Definition: acctable.hxx:49
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:1766
virtual css::uno::Reference< css::accessibility::XAccessibleTable > SAL_CALL getAccessibleColumnHeaders() override
Definition: acctable.cxx:957
void AddSelectionCell(SwAccessibleContext *, bool bAddOrRemove)
Definition: acctable.cxx:1606
unsigned char sal_Bool
virtual sal_Int32 SAL_CALL getAccessibleChildCount() override
Return the number of currently visible children.
Definition: acctable.cxx:1729
virtual css::uno::Reference< css::accessibility::XAccessibleTable > SAL_CALL getAccessibleColumnHeaders() override
Definition: acctable.cxx:1784
virtual void DisposeChild(const sw::access::SwAccessibleChild &rFrameOrObj, bool bRecursive, bool bCanSkipInvisible) override
Definition: acctable.cxx:1258
virtual sal_Int32 SAL_CALL getAccessibleColumnExtentAt(sal_Int32 nRow, sal_Int32 nColumn) override
Definition: acctable.cxx:919
virtual void InvalidateChildPosOrSize(const sw::access::SwAccessibleChild &rFrameOrObj, const SwRect &rFrame) override
Definition: acctable.cxx:1281
sal_Int32 GetIndexOfSelectedChild(sal_Int32 nSelectedChildIndex) const
Definition: acctable.cxx:632
virtual css::uno::Reference< css::accessibility::XAccessibleTable > SAL_CALL getAccessibleRowHeaders() override
Definition: acctable.cxx:1778
virtual void SAL_CALL clearAccessibleSelection() override
Definition: acctable.cxx:1428
SwAccessibleTable(std::shared_ptr< SwAccessibleMap > const &pInitMap, const SwTabFrame *pTableFrame)
Definition: acctable.cxx:669
bool HasTableData() const
Definition: acctable.hxx:87
SwAccessibleTableData_Impl & GetTableData()
Definition: acctable.hxx:226
void ClearTableData()
Definition: acctable.cxx:791
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Returns a list of all supported services.
Definition: acctable.cxx:1229
virtual sal_Int32 SAL_CALL getAccessibleRow(sal_Int32 nChildIndex) override
Definition: acctable.cxx:1145
void FireTableChangeEvent(const SwAccessibleTableData_Impl &rTableData)
Definition: acctable.cxx:577
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &aType) override
Definition: acctable.cxx:738
virtual ~SwAccessibleTable() override
Definition: acctable.cxx:687
SwTableBox is one table cell in the document model.
Definition: swtable.hxx:386
const SwSelBoxes * GetSelBoxes() const
Definition: acctable.cxx:565
void FireSelectionEvent()
Definition: acctable.cxx:1565
bool IsChildSelected(sal_Int32 nChildIndex) const
Definition: acctable.cxx:618
virtual void GetStates(::utl::AccessibleStateSetHelper &rStateSet) override
Definition: acctable.cxx:656
virtual std::unique_ptr< SwAccessibleTableData_Impl > CreateNewTableData()
Definition: acctable.cxx:779
virtual OUString SAL_CALL getAccessibleColumnDescription(sal_Int32 nColumn) override
Definition: acctable.cxx:856
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleSummary() override
Definition: acctable.cxx:1095
virtual sal_Bool SAL_CALL isAccessibleChildSelected(sal_Int32 nChildIndex) override
Definition: acctable.cxx:1415
SwAccessibleTableColHeaders(std::shared_ptr< SwAccessibleMap > const &pMap, const SwTabFrame *pTabFrame)
Definition: acctable.cxx:1691
virtual sal_Int32 SAL_CALL getAccessibleColumn(sal_Int32 nChildIndex) override
Definition: acctable.cxx:1181
virtual sal_Int32 SAL_CALL getAccessibleColumnCount() override
Definition: acctable.cxx:814
virtual css::uno::Reference< css::accessibility::XAccessibleTable > SAL_CALL getAccessibleRowHeaders() override
Definition: acctable.cxx:950
virtual ~SwAccessibleTableColHeaders() override
Definition: acctable.hxx:237
virtual css::uno::Sequence< sal_Int32 > SAL_CALL getSelectedAccessibleColumns() override
Definition: acctable.cxx:998
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override
Definition: acctable.cxx:773
const sal_Char sServiceName[]
Definition: accdoc.cxx:57
virtual void SAL_CALL release() override
Definition: acctable.hxx:107
void SetDesc(const OUString &sNewDesc)
Definition: acctable.hxx:70
virtual void Notify(const SfxHint &) override
Definition: acctable.cxx:1718
virtual css::uno::Sequence< sal_Int32 > SAL_CALL getSelectedAccessibleRows() override
Definition: acctable.cxx:975
virtual sal_Bool SAL_CALL selectRow(sal_Int32 row) override
Definition: acctable.cxx:1621