LibreOffice Module sc (master)  1
AccessibleSpreadsheet.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_SC_SOURCE_UI_INC_ACCESSIBLESPREADSHEET_HXX
21 #define INCLUDED_SC_SOURCE_UI_INC_ACCESSIBLESPREADSHEET_HXX
22 
23 #include <sal/config.h>
24 
25 #include <rtl/ref.hxx>
26 
27 #include "AccessibleTableBase.hxx"
28 #include "viewdata.hxx"
29 
30 #include <vector>
31 
32 #include <rangelst.hxx>
33 #include <map>
34 
35 class ScMyAddress : public ScAddress
36 {
37 public:
38  ScMyAddress(SCCOL nColP, SCROW nRowP, SCTAB nTabP) : ScAddress(nColP, nRowP, nTabP) {}
39  ScMyAddress(const ScAddress& rAddress) : ScAddress(rAddress) {}
40 
41  bool operator< ( const ScMyAddress& rAddress ) const
42  {
43  if( Row() != rAddress.Row() )
44  return (Row() < rAddress.Row());
45  else
46  return (Col() < rAddress.Col());
47  }
48 };
49 
50 class ScTabViewShell;
52 class ScAccessibleCell;
53 
59 {
60 public:
62  ScAccessibleDocument* pAccDoc,
63  ScTabViewShell* pViewShell,
64  SCTAB nTab,
65  ScSplitPos eSplitPos);
66 
68 
69  virtual void SAL_CALL disposing() override;
70 
71  void CompleteSelectionChanged(bool bNewState);
72 
73  void LostFocus();
74  void GotFocus();
75 
76  void BoundingBoxChanged();
77  void VisAreaChanged();
78  void FireFirstCellFocus();
79 
80  bool IsScAddrFormulaSel (const ScAddress &addr) const;
81  bool IsFormulaMode();
82  ScMyAddress CalcScAddressFromRangeList(ScRangeList *pMarkedRanges,sal_Int32 nSelectedChildIndex);
83  static bool CalcScRangeDifferenceMax(const ScRange & rSrc, const ScRange & rDest,int nMax,std::vector<ScMyAddress> &vecRet,int &nSize);
84  static bool CalcScRangeListDifferenceMax(ScRangeList *pSrc,ScRangeList *pDest,int nMax,std::vector<ScMyAddress> &vecRet);
85 
86 private:
88  ScAccessibleSpreadsheet& rParent,
89  const ScRange& rRange );
90 
91  virtual ~ScAccessibleSpreadsheet() override;
92 
94  ScAccessibleDocument* pAccDoc,
95  ScTabViewShell* pViewShell,
96  SCTAB nTab,
97  ScSplitPos eSplitPos);
98 
100 
102  virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
103 
105 
107  virtual css::uno::Reference< css::accessibility::XAccessibleTable > SAL_CALL
108  getAccessibleRowHeaders( ) override;
109 
111  virtual css::uno::Reference< css::accessibility::XAccessibleTable > SAL_CALL
112  getAccessibleColumnHeaders( ) override;
113 
115  virtual css::uno::Sequence< sal_Int32 > SAL_CALL
116  getSelectedAccessibleRows( ) override;
117 
119  virtual css::uno::Sequence< sal_Int32 > SAL_CALL
120  getSelectedAccessibleColumns( ) override;
121 
123  virtual sal_Bool SAL_CALL
124  isAccessibleRowSelected( sal_Int32 nRow ) override;
125 
127  virtual sal_Bool SAL_CALL
128  isAccessibleColumnSelected( sal_Int32 nColumn ) override;
129 
131  virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL
132  getAccessibleCellAt( sal_Int32 nRow, sal_Int32 nColumn ) override;
133 
134  rtl::Reference<ScAccessibleCell> GetAccessibleCellAt(sal_Int32 nRow, sal_Int32 nColumn);
135 
137  virtual sal_Bool SAL_CALL
138  isAccessibleSelected( sal_Int32 nRow, sal_Int32 nColumn ) override;
139 
141 
142  virtual css::uno::Reference< css::accessibility::XAccessible >
143  SAL_CALL getAccessibleAtPoint(
144  const css::awt::Point& rPoint ) override;
145 
146  virtual void SAL_CALL grabFocus( ) override;
147 
148  virtual sal_Int32 SAL_CALL getForeground( ) override;
149 
150  virtual sal_Int32 SAL_CALL getBackground( ) override;
151 
153 
155  virtual css::uno::Reference<css::accessibility::XAccessibleRelationSet> SAL_CALL
156  getAccessibleRelationSet() override;
157 
159  virtual css::uno::Reference<css::accessibility::XAccessibleStateSet> SAL_CALL
160  getAccessibleStateSet() override;
161 
163 
164  virtual void SAL_CALL
165  selectAccessibleChild( sal_Int32 nChildIndex ) override;
166 
167  virtual void SAL_CALL
168  clearAccessibleSelection( ) override;
169 
170  virtual void SAL_CALL
171  selectAllAccessibleChildren( ) override;
172 
173  virtual sal_Int32 SAL_CALL
175 
176  virtual css::uno::Reference<css::accessibility::XAccessible > SAL_CALL
177  getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex ) override;
178 
179  virtual void SAL_CALL
180  deselectAccessibleChild( sal_Int32 nChildIndex ) override;
181 
183 
186  virtual OUString SAL_CALL
187  getImplementationName() override;
188 
191  virtual css::uno::Sequence< OUString> SAL_CALL
192  getSupportedServiceNames() override;
193 
195 
198  virtual css::uno::Sequence<sal_Int8> SAL_CALL
199  getImplementationId() override;
200 
202 
206  virtual void SAL_CALL
208  const css::uno::Reference<css::accessibility::XAccessibleEventListener>& xListener) override;
209 
210  //===== XAccessibleTableSelection ============================================
211 
212  virtual sal_Bool SAL_CALL selectRow( sal_Int32 row ) override;
213  virtual sal_Bool SAL_CALL selectColumn( sal_Int32 column ) override;
214  virtual sal_Bool SAL_CALL unselectRow( sal_Int32 row ) override;
215  virtual sal_Bool SAL_CALL unselectColumn( sal_Int32 column ) override;
216 
218  virtual tools::Rectangle GetBoundingBoxOnScreen() const override;
219 
221  virtual tools::Rectangle GetBoundingBox() const override;
222 
223  bool IsDefunc(
224  const css::uno::Reference<css::accessibility::XAccessibleStateSet>& rxParentStates);
225  bool IsEditable();
226  bool IsFocused();
228 
229  void SelectCell(sal_Int32 nRow, sal_Int32 nCol, bool bDeselect);
230 
231  static ScDocument* GetDocument(ScTabViewShell* pViewShell);
232 
233  void RemoveSelection(const ScMarkData &refScMarkData);
234  void CommitFocusCell(const ScAddress &aNewCell);
235 
236  sal_Int32 GetRowAll() const { return m_nMaxY - m_nMinY + 1 ; }
237  sal_uInt16 GetColAll() const { return m_nMaxX - m_nMinX + 1; }
238  void NotifyRefMode();
239  void RemoveFormulaSelection(bool bRemoveAll = false);
240  bool CheckChildIndex(sal_Int32) const;
241  ScAddress GetChildIndexAddress(sal_Int32) const;
242  sal_Int32 GetAccessibleIndexFormula( sal_Int32 nRow, sal_Int32 nColumn );
244 
246  std::unique_ptr<ScRangeList> mpMarkedRanges;
253  bool mbDelIns;
255  typedef std::map<ScMyAddress,css::uno::Reference< css::accessibility::XAccessible > >
262  std::vector<ScMyAddress> m_vecFormulaLastMyAddr;
264  sal_uInt16 m_nMinX;
265  sal_uInt16 m_nMaxX;
266  sal_Int32 m_nMinY;
267  sal_Int32 m_nMaxY;
271  std::vector<ScRange> m_vecTempRange;
272  typedef std::pair<sal_uInt16,sal_uInt16> PAIR_COL;
273  std::vector<PAIR_COL> m_vecTempCol;
274  OUString m_strOldTabName;
275 };
276 
277 #endif
278 
279 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint(const css::awt::Point &rPoint) override
===== XAccessibleComponent ============================================
todo: It should be possible to have MarkArrays for each table, in order to enable "search all" across...
Definition: markdata.hxx:43
virtual css::uno::Sequence< sal_Int32 > SAL_CALL getSelectedAccessibleRows() override
Returns the selected rows in a table.
void CommitFocusCell(const ScAddress &aNewCell)
virtual void SAL_CALL addAccessibleEventListener(const css::uno::Reference< css::accessibility::XAccessibleEventListener > &xListener) override
===== XAccessibleEventBroadcaster =====================================
void RemoveSelection(const ScMarkData &refScMarkData)
SCROW Row() const
Definition: address.hxx:262
virtual void SAL_CALL clearAccessibleSelection() override
rtl::Reference< ScAccessibleCell > m_pAccFormulaCell
virtual css::uno::Reference< css::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet() override
===== XAccessibleContext ==============================================
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override
===== SfxListener =====================================================
virtual sal_Bool SAL_CALL unselectColumn(sal_Int32 column) override
virtual css::uno::Reference< css::accessibility::XAccessibleTable > SAL_CALL getAccessibleColumnHeaders() override
Returns the column headers as an AccessibleTable.
virtual sal_Bool SAL_CALL isAccessibleSelected(sal_Int32 nRow, sal_Int32 nColumn) override
Returns a boolean value indicating whether the accessible at a specified row and column is selected...
virtual void SAL_CALL deselectAccessibleChild(sal_Int32 nChildIndex) override
static ScDocument * GetDocument(ScTabViewShell *pViewShell)
void ConstructScAccessibleSpreadsheet(ScAccessibleDocument *pAccDoc, ScTabViewShell *pViewShell, SCTAB nTab, ScSplitPos eSplitPos)
std::vector< PAIR_COL > m_vecTempCol
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleCellAt(sal_Int32 nRow, sal_Int32 nColumn) override
Returns the Accessible at a specified row and column in the table.
virtual void SAL_CALL selectAccessibleChild(sal_Int32 nChildIndex) override
===== XAccessibleSelection ===========================================
ScSplitPos
Definition: viewdata.hxx:45
void RemoveFormulaSelection(bool bRemoveAll=false)
bool operator<(const ScMyAddress &rAddress) const
ScAccessibleSpreadsheet(ScAccessibleDocument *pAccDoc, ScTabViewShell *pViewShell, SCTAB nTab, ScSplitPos eSplitPos)
void SelectCell(sal_Int32 nRow, sal_Int32 nCol, bool bDeselect)
ScMyAddress(SCCOL nColP, SCROW nRowP, SCTAB nTabP)
virtual tools::Rectangle GetBoundingBox() const override
Return the object's current bounding box relative to the parent object.
virtual ~ScAccessibleSpreadsheet() override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Returns a list of all supported services.
virtual sal_Bool SAL_CALL isAccessibleColumnSelected(sal_Int32 nColumn) override
Returns a boolean value indicating whether the specified column is selected.
std::unique_ptr< ScRangeList > mpMarkedRanges
std::vector< ScRange > m_vecTempRange
sal_Int16 SCCOL
Definition: types.hxx:22
rtl::Reference< ScAccessibleCell > GetAccessibleCellAt(sal_Int32 nRow, sal_Int32 nColumn)
ScMyAddress CalcScAddressFromRangeList(ScRangeList *pMarkedRanges, sal_Int32 nSelectedChildIndex)
virtual void SAL_CALL disposing() override
virtual sal_Bool SAL_CALL isAccessibleRowSelected(sal_Int32 nRow) override
Returns a boolean value indicating whether the specified row is selected.
std::vector< ScMyAddress > m_vecFormulaLastMyAddr
unsigned char sal_Bool
virtual OUString SAL_CALL getImplementationName() override
===== XServiceInfo ====================================================
static bool CalcScRangeDifferenceMax(const ScRange &rSrc, const ScRange &rDest, int nMax, std::vector< ScMyAddress > &vecRet, int &nSize)
std::pair< sal_uInt16, sal_uInt16 > PAIR_COL
This base class provides an implementation of the AccessibleCell service.
virtual sal_Bool SAL_CALL selectRow(sal_Int32 row) override
This base class provides an implementation of the AccessibleTable service.
virtual void SAL_CALL grabFocus() override
bool IsScAddrFormulaSel(const ScAddress &addr) const
SCCOL Col() const
Definition: address.hxx:267
virtual sal_Int32 SAL_CALL getSelectedAccessibleChildCount() override
virtual void SAL_CALL disposing() override
ScAccessibleDocument * mpAccDoc
ScAddress GetChildIndexAddress(sal_Int32) const
sal_Int32 SCROW
Definition: types.hxx:18
bool GetFormulaCurrentFocusCell(ScAddress &addr)
rtl::Reference< ScAccessibleCell > mpAccCell
virtual sal_Int32 SAL_CALL getForeground() override
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override
===== XTypeProvider ===================================================
virtual sal_Bool SAL_CALL selectColumn(sal_Int32 column) override
virtual css::uno::Reference< css::accessibility::XAccessibleStateSet > SAL_CALL getAccessibleStateSet() override
Return the set of current states.
ScMyAddress(const ScAddress &rAddress)
virtual sal_Bool SAL_CALL unselectRow(sal_Int32 row) override
virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getSelectedAccessibleChild(sal_Int32 nSelectedChildIndex) override
std::map< ScMyAddress, css::uno::Reference< css::accessibility::XAccessible > > MAP_ADDR_XACC
static bool CalcScRangeListDifferenceMax(ScRangeList *pSrc, ScRangeList *pDest, int nMax, std::vector< ScMyAddress > &vecRet)
sal_Int32 GetAccessibleIndexFormula(sal_Int32 nRow, sal_Int32 nColumn)
virtual tools::Rectangle GetBoundingBoxOnScreen() const override
Return the object's current bounding box relative to the desktop.
virtual css::uno::Reference< css::accessibility::XAccessibleTable > SAL_CALL getAccessibleRowHeaders() override
===== XAccessibleTable ================================================
void CompleteSelectionChanged(bool bNewState)
virtual void SAL_CALL selectAllAccessibleChildren() override
virtual css::uno::Sequence< sal_Int32 > SAL_CALL getSelectedAccessibleColumns() override
Returns the selected columns in a table.
virtual sal_Int32 SAL_CALL getBackground() override
bool CheckChildIndex(sal_Int32) const
sal_Int16 SCTAB
Definition: types.hxx:23