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 "acccontext.hxx"
29 
30 class SwTabFrame;
32 class SwTableBox;
33 class SwSelBoxes;
34 
35 namespace sw { namespace access {
36  class SwAccessibleChild;
37 } }
38 
40  public SwAccessibleContext,
41  public css::accessibility::XAccessibleTable,
42  public css::accessibility::XAccessibleSelection,
43  public css::accessibility::XAccessibleTableSelection,
44  public SwClient
45 {
46  std::unique_ptr<SwAccessibleTableData_Impl> mpTableData; // the table's data, protected by SolarMutex
47  OUString m_sDesc;
48  const SwSelBoxes *GetSelBoxes() const;
49 
50  void FireTableChangeEvent( const SwAccessibleTableData_Impl& rTableData );
51 
53  const SwTableBox* GetTableBox( sal_Int32 ) const;
54 
55  bool IsChildSelected( sal_Int32 nChildIndex ) const;
56 
57  sal_Int32 GetIndexOfSelectedChild( sal_Int32 nSelectedChildIndex ) const;
58 
59 protected:
60  // Set states for getAccessibleStateSet.
61  // This derived class additionally sets MULTISELECTABLE(+)
62  virtual void GetStates( ::utl::AccessibleStateSetHelper& rStateSet ) override;
63 
64  virtual ~SwAccessibleTable() override;
65 
66  // #i77106#
67  void SetDesc( const OUString& sNewDesc )
68  {
69  m_sDesc = sNewDesc;
70  }
71 
72  virtual std::unique_ptr<SwAccessibleTableData_Impl> CreateNewTableData(); // #i77106#
73 
74  // force update of table data
75  void UpdateTableData();
76 
77  // remove the current table data
78  void ClearTableData();
79 
80  // get table data, update if necessary
82 
83  // Is table data evailable?
84  bool HasTableData() const { return (mpTableData != nullptr); }
85 
86  virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) override;
87 
88 public:
89  SwAccessibleTable(std::shared_ptr<SwAccessibleMap> const& pInitMap,
90  const SwTabFrame* pTableFrame);
91 
92  // XInterface
93 
94  // (XInterface methods need to be implemented to disambiguate
95  // between those inherited through SwAccessibleContext and
96  // XAccessibleTable).
97 
98  virtual css::uno::Any SAL_CALL queryInterface(
99  const css::uno::Type& aType ) override;
100 
101  virtual void SAL_CALL acquire( ) throw () override
102  { SwAccessibleContext::acquire(); };
103 
104  virtual void SAL_CALL release( ) throw () override
105  { SwAccessibleContext::release(); };
106 
107  // XTypeProvider
108  virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override;
109  virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) override;
110 
111  // XAccessibleContext
112 
114  virtual OUString SAL_CALL
115  getAccessibleDescription() override;
116 
117  // XAccessibleTable
118 
119  virtual sal_Int32 SAL_CALL getAccessibleRowCount() override;
120  virtual sal_Int32 SAL_CALL getAccessibleColumnCount( ) override;
121  virtual OUString SAL_CALL getAccessibleRowDescription(
122  sal_Int32 nRow ) override;
123  virtual OUString SAL_CALL getAccessibleColumnDescription(
124  sal_Int32 nColumn ) override;
125  virtual sal_Int32 SAL_CALL getAccessibleRowExtentAt(
126  sal_Int32 nRow, sal_Int32 nColumn ) override;
127  virtual sal_Int32 SAL_CALL getAccessibleColumnExtentAt(
128  sal_Int32 nRow, sal_Int32 nColumn ) override;
129  virtual css::uno::Reference<
130  css::accessibility::XAccessibleTable >
131  SAL_CALL getAccessibleRowHeaders( ) override;
132  virtual css::uno::Reference<
133  css::accessibility::XAccessibleTable >
134  SAL_CALL getAccessibleColumnHeaders( ) override;
135  virtual css::uno::Sequence< sal_Int32 > SAL_CALL
136  getSelectedAccessibleRows( ) override;
137  virtual css::uno::Sequence< sal_Int32 > SAL_CALL
138  getSelectedAccessibleColumns( ) override;
139  virtual sal_Bool SAL_CALL isAccessibleRowSelected( sal_Int32 nRow ) override;
140  virtual sal_Bool SAL_CALL isAccessibleColumnSelected( sal_Int32 nColumn ) override;
141  virtual css::uno::Reference<
142  css::accessibility::XAccessible > SAL_CALL
143  getAccessibleCellAt( sal_Int32 nRow, sal_Int32 nColumn ) override;
144  virtual css::uno::Reference<
145  css::accessibility::XAccessible > SAL_CALL
146  getAccessibleCaption( ) override;
147  virtual css::uno::Reference<
148  css::accessibility::XAccessible > SAL_CALL
149  getAccessibleSummary( ) override;
150  virtual sal_Bool SAL_CALL isAccessibleSelected(
151  sal_Int32 nRow, sal_Int32 nColumn ) override;
152  virtual sal_Int32 SAL_CALL getAccessibleIndex(
153  sal_Int32 nRow, sal_Int32 nColumn ) override;
154  virtual sal_Int32 SAL_CALL getAccessibleRow( sal_Int32 nChildIndex ) override;
155  virtual sal_Int32 SAL_CALL getAccessibleColumn( sal_Int32 nChildIndex ) override;
156  // XAccessibleTableSelection
157  virtual sal_Bool SAL_CALL selectRow( sal_Int32 row ) override ;
158  virtual sal_Bool SAL_CALL selectColumn( sal_Int32 column ) override ;
159  virtual sal_Bool SAL_CALL unselectRow( sal_Int32 row ) override;
160  virtual sal_Bool SAL_CALL unselectColumn( sal_Int32 column ) override;
161  // XServiceInfo
162 
165  virtual OUString SAL_CALL
166  getImplementationName() override;
167 
170  virtual sal_Bool SAL_CALL
171  supportsService (const OUString& sServiceName) override;
172 
176  virtual css::uno::Sequence< OUString> SAL_CALL
177  getSupportedServiceNames() override;
178 
179  // C++ interface
180 
181  // The object has been moved by the layout
182  virtual void InvalidatePosOrSize( const SwRect& rOldBox ) override;
183 
184  // The object is not visible an longer and should be destroyed
185  virtual void Dispose(bool bRecursive, bool bCanSkipInvisible = true) override;
186 
187  virtual void DisposeChild( const sw::access::SwAccessibleChild& rFrameOrObj,
188  bool bRecursive, bool bCanSkipInvisible ) override;
189  virtual void InvalidateChildPosOrSize( const sw::access::SwAccessibleChild& rFrameOrObj,
190  const SwRect& rFrame ) override;
191 
192  // XAccessibleSelection
193 
194  virtual void SAL_CALL selectAccessibleChild(
195  sal_Int32 nChildIndex ) override;
196 
197  virtual sal_Bool SAL_CALL isAccessibleChildSelected(
198  sal_Int32 nChildIndex ) override;
199 
200  virtual void SAL_CALL clearAccessibleSelection( ) override;
201 
202  virtual void SAL_CALL selectAllAccessibleChildren( ) override;
203 
204  virtual sal_Int32 SAL_CALL getSelectedAccessibleChildCount( ) override;
205 
206  virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getSelectedAccessibleChild(
207  sal_Int32 nSelectedChildIndex ) override;
208 
209  // index has to be treated as global child index.
210  virtual void SAL_CALL deselectAccessibleChild(
211  sal_Int32 nChildIndex ) override;
212 
213  // XAccessibleComponent
214  sal_Int32 SAL_CALL getBackground() override;
215  typedef std::vector< std::pair<SwAccessibleContext*,
216  css::uno::WeakReference<css::accessibility::XAccessible> > > Cells_t;
217  Cells_t m_vecCellAdd;
219  void FireSelectionEvent( );
220  void AddSelectionCell(SwAccessibleContext*, bool bAddOrRemove);
221 };
222 
224 {
225  if( !mpTableData )
226  UpdateTableData();
227  return *mpTableData;
228 }
229 
230 // #i77106# - subclass to represent table column headers
232 {
233 protected:
234  virtual ~SwAccessibleTableColHeaders() override
235  {}
236 
237  virtual std::unique_ptr<SwAccessibleTableData_Impl> CreateNewTableData() override;
238  virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) override;
239 
240 public:
241  SwAccessibleTableColHeaders(std::shared_ptr<SwAccessibleMap> const& pMap,
242  const SwTabFrame *pTabFrame);
243 
244  // XInterface
245 
246  virtual css::uno::Any SAL_CALL queryInterface(
247  const css::uno::Type& aType ) override;
248 
249  // XAccessibleContext
250 
252  virtual sal_Int32 SAL_CALL getAccessibleChildCount() override;
253 
255  virtual css::uno::Reference< css::accessibility::XAccessible> SAL_CALL
256  getAccessibleChild (sal_Int32 nIndex) override;
257 
258  // XAccessibleTable
259 
260  virtual css::uno::Reference<
261  css::accessibility::XAccessibleTable >
262  SAL_CALL getAccessibleRowHeaders( ) override;
263  virtual css::uno::Reference<
264  css::accessibility::XAccessibleTable >
265  SAL_CALL getAccessibleColumnHeaders( ) override;
266 
267  // XServiceInfo
268 
271  virtual OUString SAL_CALL
272  getImplementationName() override;
273 
274 };
275 #endif
276 
277 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void Dispose(bool bRecursive, bool bCanSkipInvisible=true) override
Definition: acctable.cxx:1268
virtual sal_Bool SAL_CALL selectColumn(sal_Int32 column) override
Definition: acctable.cxx:1654
virtual OUString SAL_CALL getImplementationName() override
Returns an identifier for the implementation of this object.
Definition: acctable.cxx:1807
virtual sal_Bool SAL_CALL unselectRow(sal_Int32 row) override
Definition: acctable.cxx:1671
virtual void SAL_CALL selectAllAccessibleChildren() override
Definition: acctable.cxx:1460
sal_Int32 SAL_CALL getBackground() override
Definition: acctable.cxx:1562
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleCaption() override
Definition: acctable.cxx:1102
virtual void SAL_CALL selectAccessibleChild(sal_Int32 nChildIndex) override
Definition: acctable.cxx:1353
virtual void InvalidatePosOrSize(const SwRect &rOldBox) override
Definition: acctable.cxx:1251
virtual OUString SAL_CALL getAccessibleRowDescription(sal_Int32 nRow) override
Definition: acctable.cxx:836
virtual sal_Bool SAL_CALL isAccessibleColumnSelected(sal_Int32 nColumn) override
Definition: acctable.cxx:1058
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:216
virtual void Modify(const SfxPoolItem *pOld, const SfxPoolItem *pNew) override
Definition: acctable.cxx:698
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
Definition: acctable.cxx:778
Cells_t m_vecCellRemove
Definition: acctable.hxx:218
virtual sal_Bool SAL_CALL supportsService(const OUString &sServiceName) override
Return whether the specified service is supported by this class.
Definition: acctable.cxx:1236
Cells_t m_vecCellAdd
Definition: acctable.hxx:217
virtual std::unique_ptr< SwAccessibleTableData_Impl > CreateNewTableData() override
Definition: acctable.cxx:1728
Dialog to specify the properties of drop-down form field.
Definition: accfrmobj.cxx:40
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:1485
void UpdateTableData()
Definition: acctable.cxx:798
virtual OUString SAL_CALL getImplementationName() override
Returns an identifier for the implementation of this object.
Definition: acctable.cxx:1231
virtual sal_Int32 SAL_CALL getAccessibleRowCount() override
Definition: acctable.cxx:818
virtual sal_Int32 SAL_CALL getSelectedAccessibleChildCount() override
Definition: acctable.cxx:1468
OUString m_sDesc
Definition: acctable.hxx:47
virtual sal_Int32 SAL_CALL getAccessibleIndex(sal_Int32 nRow, sal_Int32 nColumn) override
Definition: acctable.cxx:1140
virtual OUString SAL_CALL getAccessibleDescription() override
Return this object's description.
Definition: acctable.cxx:809
virtual sal_Bool SAL_CALL isAccessibleRowSelected(sal_Int32 nRow) override
Definition: acctable.cxx:1033
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleCellAt(sal_Int32 nRow, sal_Int32 nColumn) override
Definition: acctable.cxx:1085
const SwTableBox * GetTableBox(sal_Int32) const
get the SwTableBox* for the given child
Definition: acctable.cxx:599
virtual sal_Bool SAL_CALL isAccessibleSelected(sal_Int32 nRow, sal_Int32 nColumn) override
Definition: acctable.cxx:1114
virtual void Modify(const SfxPoolItem *pOld, const SfxPoolItem *pNew) override
Definition: acctable.cxx:1734
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &aType) override
Definition: acctable.cxx:1739
virtual void SAL_CALL deselectAccessibleChild(sal_Int32 nChildIndex) override
Definition: acctable.cxx:1512
virtual sal_Int32 SAL_CALL getAccessibleRowExtentAt(sal_Int32 nRow, sal_Int32 nColumn) override
Definition: acctable.cxx:902
virtual void SAL_CALL acquire() override
Definition: acctable.hxx:101
virtual sal_Bool SAL_CALL unselectColumn(sal_Int32 column) override
Definition: acctable.cxx:1689
std::unique_ptr< SwAccessibleTableData_Impl > mpTableData
Definition: acctable.hxx:46
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:1782
virtual css::uno::Reference< css::accessibility::XAccessibleTable > SAL_CALL getAccessibleColumnHeaders() override
Definition: acctable.cxx:970
void AddSelectionCell(SwAccessibleContext *, bool bAddOrRemove)
Definition: acctable.cxx:1623
unsigned char sal_Bool
virtual sal_Int32 SAL_CALL getAccessibleChildCount() override
Return the number of currently visible children.
Definition: acctable.cxx:1745
virtual css::uno::Reference< css::accessibility::XAccessibleTable > SAL_CALL getAccessibleColumnHeaders() override
Definition: acctable.cxx:1800
virtual void DisposeChild(const sw::access::SwAccessibleChild &rFrameOrObj, bool bRecursive, bool bCanSkipInvisible) override
Definition: acctable.cxx:1275
virtual sal_Int32 SAL_CALL getAccessibleColumnExtentAt(sal_Int32 nRow, sal_Int32 nColumn) override
Definition: acctable.cxx:932
virtual void InvalidateChildPosOrSize(const sw::access::SwAccessibleChild &rFrameOrObj, const SwRect &rFrame) override
Definition: acctable.cxx:1298
sal_Int32 GetIndexOfSelectedChild(sal_Int32 nSelectedChildIndex) const
Definition: acctable.cxx:637
virtual css::uno::Reference< css::accessibility::XAccessibleTable > SAL_CALL getAccessibleRowHeaders() override
Definition: acctable.cxx:1794
virtual void SAL_CALL clearAccessibleSelection() override
Definition: acctable.cxx:1445
SwAccessibleTable(std::shared_ptr< SwAccessibleMap > const &pInitMap, const SwTabFrame *pTableFrame)
Definition: acctable.cxx:674
bool HasTableData() const
Definition: acctable.hxx:84
SwAccessibleTableData_Impl & GetTableData()
Definition: acctable.hxx:223
void ClearTableData()
Definition: acctable.cxx:804
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Returns a list of all supported services.
Definition: acctable.cxx:1242
virtual sal_Int32 SAL_CALL getAccessibleRow(sal_Int32 nChildIndex) override
Definition: acctable.cxx:1158
void FireTableChangeEvent(const SwAccessibleTableData_Impl &rTableData)
Definition: acctable.cxx:582
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &aType) override
Definition: acctable.cxx:751
virtual ~SwAccessibleTable() override
Definition: acctable.cxx:691
SwTableBox is one table cell in the document model.
Definition: swtable.hxx:386
const SwSelBoxes * GetSelBoxes() const
Definition: acctable.cxx:570
void FireSelectionEvent()
Definition: acctable.cxx:1582
bool IsChildSelected(sal_Int32 nChildIndex) const
Definition: acctable.cxx:623
virtual void GetStates(::utl::AccessibleStateSetHelper &rStateSet) override
Definition: acctable.cxx:661
virtual std::unique_ptr< SwAccessibleTableData_Impl > CreateNewTableData()
Definition: acctable.cxx:792
virtual OUString SAL_CALL getAccessibleColumnDescription(sal_Int32 nColumn) override
Definition: acctable.cxx:869
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleSummary() override
Definition: acctable.cxx:1108
virtual sal_Bool SAL_CALL isAccessibleChildSelected(sal_Int32 nChildIndex) override
Definition: acctable.cxx:1432
SwAccessibleTableColHeaders(std::shared_ptr< SwAccessibleMap > const &pMap, const SwTabFrame *pTabFrame)
Definition: acctable.cxx:1708
virtual sal_Int32 SAL_CALL getAccessibleColumn(sal_Int32 nChildIndex) override
Definition: acctable.cxx:1194
virtual sal_Int32 SAL_CALL getAccessibleColumnCount() override
Definition: acctable.cxx:827
virtual css::uno::Reference< css::accessibility::XAccessibleTable > SAL_CALL getAccessibleRowHeaders() override
Definition: acctable.cxx:963
virtual ~SwAccessibleTableColHeaders() override
Definition: acctable.hxx:234
virtual css::uno::Sequence< sal_Int32 > SAL_CALL getSelectedAccessibleColumns() override
Definition: acctable.cxx:1011
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override
Definition: acctable.cxx:786
const sal_Char sServiceName[]
Definition: accdoc.cxx:61
virtual void SAL_CALL release() override
Definition: acctable.hxx:104
void SetDesc(const OUString &sNewDesc)
Definition: acctable.hxx:67
virtual css::uno::Sequence< sal_Int32 > SAL_CALL getSelectedAccessibleRows() override
Definition: acctable.cxx:988
virtual sal_Bool SAL_CALL selectRow(sal_Int32 row) override
Definition: acctable.cxx:1638