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 #pragma once
21 
22 #include <sal/config.h>
23 
24 #include <rtl/ref.hxx>
25 
26 #include "AccessibleTableBase.hxx"
27 #include "viewdata.hxx"
28 
29 #include <vector>
30 
31 #include <rangelst.hxx>
32 #include <map>
33 
34 class ScMyAddress : public ScAddress
35 {
36 public:
37  ScMyAddress(SCCOL nColP, SCROW nRowP, SCTAB nTabP) : ScAddress(nColP, nRowP, nTabP) {}
38  ScMyAddress(const ScAddress& rAddress) : ScAddress(rAddress) {}
39 
40  bool operator< ( const ScMyAddress& rAddress ) const
41  {
42  if( Row() != rAddress.Row() )
43  return (Row() < rAddress.Row());
44  else
45  return (Col() < rAddress.Col());
46  }
47 };
48 
49 class ScTabViewShell;
51 class ScAccessibleCell;
52 
58 {
59 public:
61  ScAccessibleDocument* pAccDoc,
62  ScTabViewShell* pViewShell,
63  SCTAB nTab,
64  ScSplitPos eSplitPos);
65 
67 
68  virtual void SAL_CALL disposing() override;
69 
70  void CompleteSelectionChanged(bool bNewState);
71 
72  void LostFocus();
73  void GotFocus();
74 
75  void BoundingBoxChanged();
76  void VisAreaChanged();
77  void FireFirstCellFocus();
78 
79  bool IsScAddrFormulaSel (const ScAddress &addr) const;
80  bool IsFormulaMode();
81  ScMyAddress CalcScAddressFromRangeList(ScRangeList *pMarkedRanges,sal_Int32 nSelectedChildIndex);
82  static bool CalcScRangeDifferenceMax(const ScRange & rSrc, const ScRange & rDest,int nMax,std::vector<ScMyAddress> &vecRet,int &nSize);
83  static bool CalcScRangeListDifferenceMax(ScRangeList *pSrc,ScRangeList *pDest,int nMax,std::vector<ScMyAddress> &vecRet);
84 
85 private:
87  ScAccessibleSpreadsheet& rParent,
88  const ScRange& rRange );
89 
90  virtual ~ScAccessibleSpreadsheet() override;
91 
93  ScAccessibleDocument* pAccDoc,
94  ScTabViewShell* pViewShell,
95  SCTAB nTab,
96  ScSplitPos eSplitPos);
97 
99 
101  virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
102 
104 
106  virtual css::uno::Reference< css::accessibility::XAccessibleTable > SAL_CALL
107  getAccessibleRowHeaders( ) override;
108 
110  virtual css::uno::Reference< css::accessibility::XAccessibleTable > SAL_CALL
111  getAccessibleColumnHeaders( ) override;
112 
114  virtual css::uno::Sequence< sal_Int32 > SAL_CALL
115  getSelectedAccessibleRows( ) override;
116 
118  virtual css::uno::Sequence< sal_Int32 > SAL_CALL
119  getSelectedAccessibleColumns( ) override;
120 
122  virtual sal_Bool SAL_CALL
123  isAccessibleRowSelected( sal_Int32 nRow ) override;
124 
126  virtual sal_Bool SAL_CALL
127  isAccessibleColumnSelected( sal_Int32 nColumn ) override;
128 
130  virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL
131  getAccessibleCellAt( sal_Int32 nRow, sal_Int32 nColumn ) override;
132 
133  rtl::Reference<ScAccessibleCell> GetAccessibleCellAt(sal_Int32 nRow, sal_Int32 nColumn);
134 
136  virtual sal_Bool SAL_CALL
137  isAccessibleSelected( sal_Int32 nRow, sal_Int32 nColumn ) override;
138 
140 
141  virtual css::uno::Reference< css::accessibility::XAccessible >
142  SAL_CALL getAccessibleAtPoint(
143  const css::awt::Point& rPoint ) override;
144 
145  virtual void SAL_CALL grabFocus( ) override;
146 
147  virtual sal_Int32 SAL_CALL getForeground( ) override;
148 
149  virtual sal_Int32 SAL_CALL getBackground( ) override;
150 
152 
154  virtual css::uno::Reference<css::accessibility::XAccessibleRelationSet> SAL_CALL
155  getAccessibleRelationSet() override;
156 
158  virtual css::uno::Reference<css::accessibility::XAccessibleStateSet> SAL_CALL
159  getAccessibleStateSet() override;
160 
162 
163  virtual void SAL_CALL
164  selectAccessibleChild( sal_Int32 nChildIndex ) override;
165 
166  virtual void SAL_CALL
167  clearAccessibleSelection( ) override;
168 
169  virtual void SAL_CALL
170  selectAllAccessibleChildren( ) override;
171 
172  virtual sal_Int32 SAL_CALL
174 
175  virtual css::uno::Reference<css::accessibility::XAccessible > SAL_CALL
176  getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex ) override;
177 
178  virtual void SAL_CALL
179  deselectAccessibleChild( sal_Int32 nChildIndex ) override;
180 
182 
185  virtual OUString SAL_CALL
186  getImplementationName() override;
187 
190  virtual css::uno::Sequence< OUString> SAL_CALL
191  getSupportedServiceNames() override;
192 
194 
197  virtual css::uno::Sequence<sal_Int8> SAL_CALL
198  getImplementationId() override;
199 
201 
205  virtual void SAL_CALL
207  const css::uno::Reference<css::accessibility::XAccessibleEventListener>& xListener) override;
208 
209  //===== XAccessibleTableSelection ============================================
210 
211  virtual sal_Bool SAL_CALL selectRow( sal_Int32 row ) override;
212  virtual sal_Bool SAL_CALL selectColumn( sal_Int32 column ) override;
213  virtual sal_Bool SAL_CALL unselectRow( sal_Int32 row ) override;
214  virtual sal_Bool SAL_CALL unselectColumn( sal_Int32 column ) override;
215 
217  virtual tools::Rectangle GetBoundingBoxOnScreen() const override;
218 
220  virtual tools::Rectangle GetBoundingBox() const override;
221 
222  bool IsDefunc(
223  const css::uno::Reference<css::accessibility::XAccessibleStateSet>& rxParentStates);
224  bool IsEditable();
225  bool IsFocused();
227 
228  void SelectCell(sal_Int32 nRow, sal_Int32 nCol, bool bDeselect);
229 
230  static ScDocument* GetDocument(ScTabViewShell* pViewShell);
231 
232  void RemoveSelection(const ScMarkData &refScMarkData);
233  void CommitFocusCell(const ScAddress &aNewCell);
234 
235  sal_Int32 GetRowAll() const { return m_nMaxY - m_nMinY + 1 ; }
236  sal_uInt16 GetColAll() const { return m_nMaxX - m_nMinX + 1; }
237  void NotifyRefMode();
238  void RemoveFormulaSelection(bool bRemoveAll = false);
239  bool CheckChildIndex(sal_Int32) const;
240  ScAddress GetChildIndexAddress(sal_Int32) const;
241  sal_Int32 GetAccessibleIndexFormula( sal_Int32 nRow, sal_Int32 nColumn );
243 
245  std::unique_ptr<ScRangeList> mpMarkedRanges;
252  bool mbDelIns;
254  typedef std::map<ScMyAddress,css::uno::Reference< css::accessibility::XAccessible > >
261  std::vector<ScMyAddress> m_vecFormulaLastMyAddr;
263  sal_uInt16 m_nMinX;
264  sal_uInt16 m_nMaxX;
265  sal_Int32 m_nMinY;
266  sal_Int32 m_nMaxY;
270  OUString m_strOldTabName;
271 };
272 
273 /* 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:42
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:261
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)
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:44
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
sal_Int16 SCCOL
Definition: types.hxx:21
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)
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:266
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:17
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:22