tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / sc / source / ui / inc / AccessibleSpreadsheet.hxx
blob49c9f1c27946395ce6d3fe405241312b2f2e3592
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #pragma once
22 #include <sal/config.h>
23 #include <unotools/weakref.hxx>
25 #include <rtl/ref.hxx>
27 #include "AccessibleTableBase.hxx"
28 #include "viewdata.hxx"
30 #include <vector>
32 #include <rangelst.hxx>
33 #include <map>
35 class ScMyAddress : public ScAddress
37 public:
38 ScMyAddress(SCCOL nColP, SCROW nRowP, SCTAB nTabP) : ScAddress(nColP, nRowP, nTabP) {}
39 ScMyAddress(const ScAddress& rAddress) : ScAddress(rAddress) {}
41 bool operator< ( const ScMyAddress& rAddress ) const
43 if( Row() != rAddress.Row() )
44 return (Row() < rAddress.Row());
45 else
46 return (Col() < rAddress.Col());
50 class ScTabViewShell;
51 class ScAccessibleDocument;
52 class ScAccessibleCell;
54 /** @descr
55 This base class provides an implementation of the
56 <code>AccessibleTable</code> service.
58 class ScAccessibleSpreadsheet final : public ScAccessibleTableBase
60 public:
61 ScAccessibleSpreadsheet(
62 ScAccessibleDocument* pAccDoc,
63 ScTabViewShell* pViewShell,
64 SCTAB nTab,
65 ScSplitPos eSplitPos);
67 using ScAccessibleTableBase::disposing;
69 virtual void SAL_CALL disposing() override;
71 void CompleteSelectionChanged(bool bNewState);
73 void LostFocus();
74 void GotFocus();
76 void BoundingBoxChanged();
77 void VisAreaChanged();
78 void FireFirstCellFocus();
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);
86 private:
87 ScAccessibleSpreadsheet(
88 ScAccessibleSpreadsheet& rParent,
89 const ScRange& rRange );
91 virtual ~ScAccessibleSpreadsheet() override;
93 void ConstructScAccessibleSpreadsheet(
94 ScAccessibleDocument* pAccDoc,
95 ScTabViewShell* pViewShell,
96 SCTAB nTab,
97 ScSplitPos eSplitPos);
99 using ScAccessibleTableBase::IsDefunc;
101 ///===== SfxListener =====================================================
102 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
104 ///===== XAccessibleTable ================================================
106 /// Returns the row headers as an AccessibleTable.
107 virtual css::uno::Reference< css::accessibility::XAccessibleTable > SAL_CALL
108 getAccessibleRowHeaders( ) override;
110 /// Returns the column headers as an AccessibleTable.
111 virtual css::uno::Reference< css::accessibility::XAccessibleTable > SAL_CALL
112 getAccessibleColumnHeaders( ) override;
114 /// Returns the selected rows in a table.
115 virtual css::uno::Sequence< sal_Int32 > SAL_CALL
116 getSelectedAccessibleRows( ) override;
118 /// Returns the selected columns in a table.
119 virtual css::uno::Sequence< sal_Int32 > SAL_CALL
120 getSelectedAccessibleColumns( ) override;
122 /// Returns a boolean value indicating whether the specified row is selected.
123 virtual sal_Bool SAL_CALL
124 isAccessibleRowSelected( sal_Int32 nRow ) override;
126 /// Returns a boolean value indicating whether the specified column is selected.
127 virtual sal_Bool SAL_CALL
128 isAccessibleColumnSelected( sal_Int32 nColumn ) override;
130 /// Returns the Accessible at a specified row and column in the table.
131 virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL
132 getAccessibleCellAt( sal_Int32 nRow, sal_Int32 nColumn ) override;
134 rtl::Reference<ScAccessibleCell> GetAccessibleCellAt(sal_Int32 nRow, sal_Int32 nColumn);
136 /// Returns a boolean value indicating whether the accessible at a specified row and column is selected.
137 virtual sal_Bool SAL_CALL
138 isAccessibleSelected( sal_Int32 nRow, sal_Int32 nColumn ) override;
140 ///===== XAccessibleComponent ============================================
142 virtual css::uno::Reference< css::accessibility::XAccessible >
143 SAL_CALL getAccessibleAtPoint(
144 const css::awt::Point& rPoint ) override;
146 virtual void SAL_CALL grabFocus( ) override;
148 virtual sal_Int32 SAL_CALL getForeground( ) override;
150 virtual sal_Int32 SAL_CALL getBackground( ) override;
152 ///===== XAccessibleContext ==============================================
154 /// Return NULL to indicate that an empty relation set.
155 virtual css::uno::Reference<css::accessibility::XAccessibleRelationSet> SAL_CALL
156 getAccessibleRelationSet() override;
158 /// Return the set of current states.
159 virtual sal_Int64 SAL_CALL
160 getAccessibleStateSet() override;
162 ///===== XAccessibleSelection ===========================================
164 virtual void SAL_CALL
165 selectAccessibleChild( sal_Int64 nChildIndex ) override;
167 virtual void SAL_CALL
168 clearAccessibleSelection( ) override;
170 virtual void SAL_CALL
171 selectAllAccessibleChildren( ) override;
173 virtual sal_Int64 SAL_CALL
174 getSelectedAccessibleChildCount( ) override;
176 virtual css::uno::Reference<css::accessibility::XAccessible > SAL_CALL
177 getSelectedAccessibleChild( sal_Int64 nSelectedChildIndex ) override;
179 virtual void SAL_CALL
180 deselectAccessibleChild( sal_Int64 nChildIndex ) override;
182 ///===== XServiceInfo ====================================================
184 /** Returns an identifier for the implementation of this object.
186 virtual OUString SAL_CALL
187 getImplementationName() override;
189 /** Returns a list of all supported services.
191 virtual css::uno::Sequence< OUString> SAL_CALL
192 getSupportedServiceNames() override;
194 ///===== XTypeProvider ===================================================
196 /** Returns an implementation id.
198 virtual css::uno::Sequence<sal_Int8> SAL_CALL
199 getImplementationId() override;
201 ///===== XAccessibleEventBroadcaster =====================================
203 /** Add listener that is informed of future changes of name,
204 description and so on events.
206 virtual void SAL_CALL
207 addAccessibleEventListener(
208 const css::uno::Reference<css::accessibility::XAccessibleEventListener>& xListener) override;
210 //===== XAccessibleTableSelection ============================================
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;
217 /// Return the object's current bounding box relative to the desktop.
218 virtual AbsoluteScreenPixelRectangle GetBoundingBoxOnScreen() const override;
220 /// Return the object's current bounding box relative to the parent object.
221 virtual tools::Rectangle GetBoundingBox() const override;
223 bool IsDefunc(sal_Int64 nParentStates);
224 bool IsEditable();
225 bool IsFocused();
226 bool IsCompleteSheetSelected();
228 void SelectCell(sal_Int32 nRow, sal_Int32 nCol, bool bDeselect);
230 static ScDocument* GetDocument(ScTabViewShell* pViewShell);
232 void RemoveSelection(const ScMarkData &refScMarkData);
233 void CommitFocusCell(const ScAddress &aNewCell);
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_Int64) const;
240 ScAddress GetChildIndexAddress(sal_Int64) const;
241 sal_Int64 GetAccessibleIndexFormula( sal_Int32 nRow, sal_Int32 nColumn );
242 bool GetFormulaCurrentFocusCell(ScAddress &addr);
244 ScTabViewShell* mpViewShell;
245 std::unique_ptr<ScRangeList> mpMarkedRanges;
246 ScAccessibleDocument* mpAccDoc;
247 rtl::Reference<ScAccessibleCell> mpAccCell;
248 ScSplitPos meSplitPos;
249 ScAddress maActiveCell;
250 SCTAB mnTab;
251 bool mbIsSpreadsheet;
252 bool mbDelIns;
253 bool mbIsFocusSend;
254 typedef std::map<ScMyAddress,css::uno::Reference< css::accessibility::XAccessible > >
255 MAP_ADDR_XACC;
256 MAP_ADDR_XACC m_mapSelectionSend;
257 bool m_bFormulaMode;
258 bool m_bFormulaLastMode;
259 ScAddress m_aFormulaActiveCell;
260 MAP_ADDR_XACC m_mapFormulaSelectionSend;
261 std::vector<ScMyAddress> m_vecFormulaLastMyAddr;
262 rtl::Reference<ScAccessibleCell> m_pAccFormulaCell;
263 sal_uInt16 m_nMinX;
264 sal_uInt16 m_nMaxX;
265 sal_Int32 m_nMinY;
266 sal_Int32 m_nMaxY;
267 ScRange m_aLastWithInMarkRange;
268 OUString m_strCurCellValue;
269 ScRangeList m_LastMarkedRanges;
270 OUString m_strOldTabName;
271 std::map<ScAddress, unotools::WeakReference<ScAccessibleCell>> m_mapCells;
274 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */