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/poolitem.hxx>
28 #include <svl/listener.hxx>
29 
30 #include "acccontext.hxx"
31 
32 class SwTabFrame;
34 class SwTableBox;
35 class SwSelBoxes;
36 
37 namespace sw::access {
38  class SwAccessibleChild;
39 }
40 
42  public SwAccessibleContext,
43  public css::accessibility::XAccessibleTable,
44  public css::accessibility::XAccessibleSelection,
45  public css::accessibility::XAccessibleTableSelection,
46  public SvtListener
47 {
48  std::unique_ptr<SwAccessibleTableData_Impl> mpTableData; // the table's data, protected by SolarMutex
49  OUString m_sDesc;
50  const SwSelBoxes *GetSelBoxes() const;
51 
52  void FireTableChangeEvent( const SwAccessibleTableData_Impl& rTableData );
53 
55  const SwTableBox* GetTableBox( sal_Int32 ) const;
56 
57  bool IsChildSelected( sal_Int32 nChildIndex ) const;
58 
59  sal_Int32 GetIndexOfSelectedChild( sal_Int32 nSelectedChildIndex ) const;
60 
61 protected:
62  // Set states for getAccessibleStateSet.
63  // This derived class additionally sets MULTISELECTABLE(+)
64  virtual void GetStates( ::utl::AccessibleStateSetHelper& rStateSet ) override;
65 
66  virtual ~SwAccessibleTable() override;
67 
68  // #i77106#
69  void SetDesc( const OUString& sNewDesc )
70  {
71  m_sDesc = sNewDesc;
72  }
73 
74  virtual std::unique_ptr<SwAccessibleTableData_Impl> CreateNewTableData(); // #i77106#
75 
76  // force update of table data
77  void UpdateTableData();
78 
79  // remove the current table data
80  void ClearTableData();
81 
82  // get table data, update if necessary
84 
85  // Is table data evailable?
86  bool HasTableData() const { return (mpTableData != nullptr); }
87 
88  virtual void Notify(const SfxHint&) override;
89 
90 public:
91  SwAccessibleTable(std::shared_ptr<SwAccessibleMap> const& pInitMap,
92  const SwTabFrame* pTableFrame);
93 
94  // XInterface
95 
96  // (XInterface methods need to be implemented to disambiguate
97  // between those inherited through SwAccessibleContext and
98  // XAccessibleTable).
99 
100  virtual css::uno::Any SAL_CALL queryInterface(
101  const css::uno::Type& aType ) override;
102 
103  virtual void SAL_CALL acquire( ) throw () override
104  { SwAccessibleContext::acquire(); };
105 
106  virtual void SAL_CALL release( ) throw () override
107  { SwAccessibleContext::release(); };
108 
109  // XTypeProvider
110  virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override;
111  virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) override;
112 
113  // XAccessibleContext
114 
116  virtual OUString SAL_CALL
117  getAccessibleDescription() override;
118 
119  // XAccessibleTable
120 
121  virtual sal_Int32 SAL_CALL getAccessibleRowCount() override;
122  virtual sal_Int32 SAL_CALL getAccessibleColumnCount( ) override;
123  virtual OUString SAL_CALL getAccessibleRowDescription(
124  sal_Int32 nRow ) override;
125  virtual OUString SAL_CALL getAccessibleColumnDescription(
126  sal_Int32 nColumn ) override;
127  virtual sal_Int32 SAL_CALL getAccessibleRowExtentAt(
128  sal_Int32 nRow, sal_Int32 nColumn ) override;
129  virtual sal_Int32 SAL_CALL getAccessibleColumnExtentAt(
130  sal_Int32 nRow, sal_Int32 nColumn ) override;
131  virtual css::uno::Reference<
132  css::accessibility::XAccessibleTable >
133  SAL_CALL getAccessibleRowHeaders( ) override;
134  virtual css::uno::Reference<
135  css::accessibility::XAccessibleTable >
136  SAL_CALL getAccessibleColumnHeaders( ) override;
137  virtual css::uno::Sequence< sal_Int32 > SAL_CALL
138  getSelectedAccessibleRows( ) override;
139  virtual css::uno::Sequence< sal_Int32 > SAL_CALL
140  getSelectedAccessibleColumns( ) override;
141  virtual sal_Bool SAL_CALL isAccessibleRowSelected( sal_Int32 nRow ) override;
142  virtual sal_Bool SAL_CALL isAccessibleColumnSelected( sal_Int32 nColumn ) override;
143  virtual css::uno::Reference<
144  css::accessibility::XAccessible > SAL_CALL
145  getAccessibleCellAt( sal_Int32 nRow, sal_Int32 nColumn ) override;
146  virtual css::uno::Reference<
147  css::accessibility::XAccessible > SAL_CALL
148  getAccessibleCaption( ) override;
149  virtual css::uno::Reference<
150  css::accessibility::XAccessible > SAL_CALL
151  getAccessibleSummary( ) override;
152  virtual sal_Bool SAL_CALL isAccessibleSelected(
153  sal_Int32 nRow, sal_Int32 nColumn ) override;
154  virtual sal_Int32 SAL_CALL getAccessibleIndex(
155  sal_Int32 nRow, sal_Int32 nColumn ) override;
156  virtual sal_Int32 SAL_CALL getAccessibleRow( sal_Int32 nChildIndex ) override;
157  virtual sal_Int32 SAL_CALL getAccessibleColumn( sal_Int32 nChildIndex ) override;
158  // XAccessibleTableSelection
159  virtual sal_Bool SAL_CALL selectRow( sal_Int32 row ) override ;
160  virtual sal_Bool SAL_CALL selectColumn( sal_Int32 column ) override ;
161  virtual sal_Bool SAL_CALL unselectRow( sal_Int32 row ) override;
162  virtual sal_Bool SAL_CALL unselectColumn( sal_Int32 column ) override;
163  // XServiceInfo
164 
167  virtual OUString SAL_CALL
168  getImplementationName() override;
169 
172  virtual sal_Bool SAL_CALL
173  supportsService (const OUString& sServiceName) override;
174 
178  virtual css::uno::Sequence< OUString> SAL_CALL
179  getSupportedServiceNames() override;
180 
181  // C++ interface
182 
183  // The object has been moved by the layout
184  virtual void InvalidatePosOrSize( const SwRect& rOldBox ) override;
185 
186  // The object is not visible any longer and should be destroyed
187  virtual void Dispose(bool bRecursive, bool bCanSkipInvisible = true) override;
188 
189  virtual void DisposeChild( const sw::access::SwAccessibleChild& rFrameOrObj,
190  bool bRecursive, bool bCanSkipInvisible ) override;
191  virtual void InvalidateChildPosOrSize( const sw::access::SwAccessibleChild& rFrameOrObj,
192  const SwRect& rFrame ) override;
193 
194  // XAccessibleSelection
195 
196  virtual void SAL_CALL selectAccessibleChild(
197  sal_Int32 nChildIndex ) override;
198 
199  virtual sal_Bool SAL_CALL isAccessibleChildSelected(
200  sal_Int32 nChildIndex ) override;
201 
202  virtual void SAL_CALL clearAccessibleSelection( ) override;
203 
204  virtual void SAL_CALL selectAllAccessibleChildren( ) override;
205 
206  virtual sal_Int32 SAL_CALL getSelectedAccessibleChildCount( ) override;
207 
208  virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getSelectedAccessibleChild(
209  sal_Int32 nSelectedChildIndex ) override;
210 
211  // index has to be treated as global child index.
212  virtual void SAL_CALL deselectAccessibleChild(
213  sal_Int32 nChildIndex ) override;
214 
215  // XAccessibleComponent
216  sal_Int32 SAL_CALL getBackground() override;
217  typedef std::vector< std::pair<SwAccessibleContext*,
218  css::uno::WeakReference<css::accessibility::XAccessible> > > Cells_t;
219  Cells_t m_vecCellAdd;
221  void FireSelectionEvent( );
222  void AddSelectionCell(SwAccessibleContext*, bool bAddOrRemove);
223 };
224 
226 {
227  if( !mpTableData )
228  UpdateTableData();
229  return *mpTableData;
230 }
231 
232 // #i77106# - subclass to represent table column headers
234 {
235 protected:
236  virtual ~SwAccessibleTableColHeaders() override
237  {}
238 
239  virtual std::unique_ptr<SwAccessibleTableData_Impl> CreateNewTableData() override;
240  virtual void Notify(const SfxHint&) override;
241 
242 public:
243  SwAccessibleTableColHeaders(std::shared_ptr<SwAccessibleMap> const& pMap,
244  const SwTabFrame *pTabFrame);
245 
246  // XInterface
247 
248  virtual css::uno::Any SAL_CALL queryInterface(
249  const css::uno::Type& aType ) override;
250 
251  // XAccessibleContext
252 
254  virtual sal_Int32 SAL_CALL getAccessibleChildCount() override;
255 
257  virtual css::uno::Reference< css::accessibility::XAccessible> SAL_CALL
258  getAccessibleChild (sal_Int32 nIndex) override;
259 
260  // XAccessibleTable
261 
262  virtual css::uno::Reference<
263  css::accessibility::XAccessibleTable >
264  SAL_CALL getAccessibleRowHeaders( ) override;
265  virtual css::uno::Reference<
266  css::accessibility::XAccessibleTable >
267  SAL_CALL getAccessibleColumnHeaders( ) override;
268 
269  // XServiceInfo
270 
273  virtual OUString SAL_CALL
274  getImplementationName() override;
275 
276 };
277 
278 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void Dispose(bool bRecursive, bool bCanSkipInvisible=true) override
Definition: acctable.cxx:1193
virtual sal_Bool SAL_CALL selectColumn(sal_Int32 column) override
Definition: acctable.cxx:1579
virtual OUString SAL_CALL getImplementationName() override
Returns an identifier for the implementation of this object.
Definition: acctable.cxx:1733
virtual sal_Bool SAL_CALL unselectRow(sal_Int32 row) override
Definition: acctable.cxx:1596
virtual void SAL_CALL selectAllAccessibleChildren() override
Definition: acctable.cxx:1385
sal_Int32 SAL_CALL getBackground() override
Definition: acctable.cxx:1487
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleCaption() override
Definition: acctable.cxx:1031
virtual void SAL_CALL selectAccessibleChild(sal_Int32 nChildIndex) override
Definition: acctable.cxx:1278
virtual void InvalidatePosOrSize(const SwRect &rOldBox) override
Definition: acctable.cxx:1176
virtual OUString SAL_CALL getAccessibleRowDescription(sal_Int32 nRow) override
Definition: acctable.cxx:765
virtual sal_Bool SAL_CALL isAccessibleColumnSelected(sal_Int32 nColumn) override
Definition: acctable.cxx:987
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:218
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
Definition: acctable.cxx:707
Cells_t m_vecCellRemove
Definition: acctable.hxx:220
virtual sal_Bool SAL_CALL supportsService(const OUString &sServiceName) override
Return whether the specified service is supported by this class.
Definition: acctable.cxx:1165
Cells_t m_vecCellAdd
Definition: acctable.hxx:219
virtual std::unique_ptr< SwAccessibleTableData_Impl > CreateNewTableData() override
Definition: acctable.cxx:1654
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:1410
virtual void Notify(const SfxHint &) override
Definition: acctable.cxx:636
void UpdateTableData()
Definition: acctable.cxx:727
virtual OUString SAL_CALL getImplementationName() override
Returns an identifier for the implementation of this object.
Definition: acctable.cxx:1160
virtual sal_Int32 SAL_CALL getAccessibleRowCount() override
Definition: acctable.cxx:747
virtual sal_Int32 SAL_CALL getSelectedAccessibleChildCount() override
Definition: acctable.cxx:1393
OUString m_sDesc
Definition: acctable.hxx:49
virtual sal_Int32 SAL_CALL getAccessibleIndex(sal_Int32 nRow, sal_Int32 nColumn) override
Definition: acctable.cxx:1069
virtual OUString SAL_CALL getAccessibleDescription() override
Return this object's description.
Definition: acctable.cxx:738
virtual sal_Bool SAL_CALL isAccessibleRowSelected(sal_Int32 nRow) override
Definition: acctable.cxx:962
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleCellAt(sal_Int32 nRow, sal_Int32 nColumn) override
Definition: acctable.cxx:1014
const SwTableBox * GetTableBox(sal_Int32) const
get the SwTableBox* for the given child
Definition: acctable.cxx:536
virtual sal_Bool SAL_CALL isAccessibleSelected(sal_Int32 nRow, sal_Int32 nColumn) override
Definition: acctable.cxx:1043
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &aType) override
Definition: acctable.cxx:1665
virtual void SAL_CALL deselectAccessibleChild(sal_Int32 nChildIndex) override
Definition: acctable.cxx:1437
virtual sal_Int32 SAL_CALL getAccessibleRowExtentAt(sal_Int32 nRow, sal_Int32 nColumn) override
Definition: acctable.cxx:831
virtual void SAL_CALL acquire() override
Definition: acctable.hxx:103
virtual sal_Bool SAL_CALL unselectColumn(sal_Int32 column) override
Definition: acctable.cxx:1614
std::unique_ptr< SwAccessibleTableData_Impl > mpTableData
Definition: acctable.hxx:48
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:1708
virtual css::uno::Reference< css::accessibility::XAccessibleTable > SAL_CALL getAccessibleColumnHeaders() override
Definition: acctable.cxx:899
void AddSelectionCell(SwAccessibleContext *, bool bAddOrRemove)
Definition: acctable.cxx:1548
unsigned char sal_Bool
virtual sal_Int32 SAL_CALL getAccessibleChildCount() override
Return the number of currently visible children.
Definition: acctable.cxx:1671
virtual css::uno::Reference< css::accessibility::XAccessibleTable > SAL_CALL getAccessibleColumnHeaders() override
Definition: acctable.cxx:1726
virtual void DisposeChild(const sw::access::SwAccessibleChild &rFrameOrObj, bool bRecursive, bool bCanSkipInvisible) override
Definition: acctable.cxx:1200
virtual sal_Int32 SAL_CALL getAccessibleColumnExtentAt(sal_Int32 nRow, sal_Int32 nColumn) override
Definition: acctable.cxx:861
virtual void InvalidateChildPosOrSize(const sw::access::SwAccessibleChild &rFrameOrObj, const SwRect &rFrame) override
Definition: acctable.cxx:1223
sal_Int32 GetIndexOfSelectedChild(sal_Int32 nSelectedChildIndex) const
Definition: acctable.cxx:574
virtual css::uno::Reference< css::accessibility::XAccessibleTable > SAL_CALL getAccessibleRowHeaders() override
Definition: acctable.cxx:1720
virtual void SAL_CALL clearAccessibleSelection() override
Definition: acctable.cxx:1370
SwAccessibleTable(std::shared_ptr< SwAccessibleMap > const &pInitMap, const SwTabFrame *pTableFrame)
Definition: acctable.cxx:611
bool HasTableData() const
Definition: acctable.hxx:86
SwAccessibleTableData_Impl & GetTableData()
Definition: acctable.hxx:225
void ClearTableData()
Definition: acctable.cxx:733
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Returns a list of all supported services.
Definition: acctable.cxx:1171
virtual sal_Int32 SAL_CALL getAccessibleRow(sal_Int32 nChildIndex) override
Definition: acctable.cxx:1087
void FireTableChangeEvent(const SwAccessibleTableData_Impl &rTableData)
Definition: acctable.cxx:519
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &aType) override
Definition: acctable.cxx:680
virtual ~SwAccessibleTable() override
Definition: acctable.cxx:629
SwTableBox is one table cell in the document model.
Definition: swtable.hxx:393
const SwSelBoxes * GetSelBoxes() const
Definition: acctable.cxx:507
void FireSelectionEvent()
Definition: acctable.cxx:1507
bool IsChildSelected(sal_Int32 nChildIndex) const
Definition: acctable.cxx:560
virtual void GetStates(::utl::AccessibleStateSetHelper &rStateSet) override
Definition: acctable.cxx:598
virtual std::unique_ptr< SwAccessibleTableData_Impl > CreateNewTableData()
Definition: acctable.cxx:721
virtual OUString SAL_CALL getAccessibleColumnDescription(sal_Int32 nColumn) override
Definition: acctable.cxx:798
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleSummary() override
Definition: acctable.cxx:1037
virtual sal_Bool SAL_CALL isAccessibleChildSelected(sal_Int32 nChildIndex) override
Definition: acctable.cxx:1357
const char sServiceName[]
Definition: accdoc.cxx:56
SwAccessibleTableColHeaders(std::shared_ptr< SwAccessibleMap > const &pMap, const SwTabFrame *pTabFrame)
Definition: acctable.cxx:1633
virtual sal_Int32 SAL_CALL getAccessibleColumn(sal_Int32 nChildIndex) override
Definition: acctable.cxx:1123
virtual sal_Int32 SAL_CALL getAccessibleColumnCount() override
Definition: acctable.cxx:756
virtual css::uno::Reference< css::accessibility::XAccessibleTable > SAL_CALL getAccessibleRowHeaders() override
Definition: acctable.cxx:892
virtual ~SwAccessibleTableColHeaders() override
Definition: acctable.hxx:236
virtual css::uno::Sequence< sal_Int32 > SAL_CALL getSelectedAccessibleColumns() override
Definition: acctable.cxx:940
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override
Definition: acctable.cxx:715
virtual void SAL_CALL release() override
Definition: acctable.hxx:106
void SetDesc(const OUString &sNewDesc)
Definition: acctable.hxx:69
virtual void Notify(const SfxHint &) override
Definition: acctable.cxx:1660
virtual css::uno::Sequence< sal_Int32 > SAL_CALL getSelectedAccessibleRows() override
Definition: acctable.cxx:917
virtual sal_Bool SAL_CALL selectRow(sal_Int32 row) override
Definition: acctable.cxx:1563