fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / sc / source / ui / inc / AccessibleSpreadsheet.hxx
blob3bc2d3c4377267a9a7c8138842dd8f4b1636f5d7
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 #ifndef INCLUDED_SC_SOURCE_UI_INC_ACCESSIBLESPREADSHEET_HXX
21 #define INCLUDED_SC_SOURCE_UI_INC_ACCESSIBLESPREADSHEET_HXX
23 #include <sal/config.h>
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() : ScAddress() {}
39 ScMyAddress(SCCOL nColP, SCROW nRowP, SCTAB nTabP) : ScAddress(nColP, nRowP, nTabP) {}
40 ScMyAddress(const ScAddress& rAddress) : ScAddress(rAddress) {}
42 bool operator< ( const ScMyAddress& rAddress ) const
44 if( Row() != rAddress.Row() )
45 return (Row() < rAddress.Row());
46 else
47 return (Col() < rAddress.Col());
51 class ScTabViewShell;
52 class ScAccessibleDocument;
53 class ScAccessibleCell;
54 class ScRangeList;
56 /** @descr
57 This base class provides an implementation of the
58 <code>AccessibleTable</code> service.
60 class ScAccessibleSpreadsheet
61 : public ScAccessibleTableBase
63 public:
64 //===== internal ========================================================
65 ScAccessibleSpreadsheet(
66 ScAccessibleDocument* pAccDoc,
67 ScTabViewShell* pViewShell,
68 SCTAB nTab,
69 ScSplitPos eSplitPos);
70 protected:
71 ScAccessibleSpreadsheet(
72 ScAccessibleSpreadsheet& rParent,
73 const ScRange& rRange );
75 virtual ~ScAccessibleSpreadsheet();
77 void ConstructScAccessibleSpreadsheet(
78 ScAccessibleDocument* pAccDoc,
79 ScTabViewShell* pViewShell,
80 SCTAB nTab,
81 ScSplitPos eSplitPos);
83 using ScAccessibleTableBase::IsDefunc;
85 public:
86 using ScAccessibleTableBase::disposing;
88 virtual void SAL_CALL disposing() SAL_OVERRIDE;
90 void CompleteSelectionChanged(bool bNewState);
92 void LostFocus();
93 void GotFocus();
95 void BoundingBoxChanged();
96 void VisAreaChanged();
98 private:
99 ///===== SfxListener =====================================================
100 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) SAL_OVERRIDE;
102 ///===== XAccessibleTable ================================================
104 /// Returns the row headers as an AccessibleTable.
105 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleTable > SAL_CALL
106 getAccessibleRowHeaders( )
107 throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
109 /// Returns the column headers as an AccessibleTable.
110 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleTable > SAL_CALL
111 getAccessibleColumnHeaders( )
112 throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
114 /// Returns the selected rows in a table.
115 virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL
116 getSelectedAccessibleRows( )
117 throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
119 /// Returns the selected columns in a table.
120 virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL
121 getSelectedAccessibleColumns( )
122 throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
124 /// Returns a boolean value indicating whether the specified row is selected.
125 virtual sal_Bool SAL_CALL
126 isAccessibleRowSelected( sal_Int32 nRow )
127 throw (::com::sun::star::uno::RuntimeException,
128 ::com::sun::star::lang::IndexOutOfBoundsException, std::exception) SAL_OVERRIDE;
130 /// Returns a boolean value indicating whether the specified column is selected.
131 virtual sal_Bool SAL_CALL
132 isAccessibleColumnSelected( sal_Int32 nColumn )
133 throw (::com::sun::star::uno::RuntimeException,
134 ::com::sun::star::lang::IndexOutOfBoundsException, std::exception) SAL_OVERRIDE;
136 /// Returns the Accessible at a specified row and column in the table.
137 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL
138 getAccessibleCellAt( sal_Int32 nRow, sal_Int32 nColumn )
139 throw (::com::sun::star::uno::RuntimeException,
140 ::com::sun::star::lang::IndexOutOfBoundsException, std::exception) SAL_OVERRIDE;
142 rtl::Reference<ScAccessibleCell> GetAccessibleCellAt(sal_Int32 nRow, sal_Int32 nColumn);
144 /// Returns a boolean value indicating whether the accessible at a specified row and column is selected.
145 virtual sal_Bool SAL_CALL
146 isAccessibleSelected( sal_Int32 nRow, sal_Int32 nColumn )
147 throw (::com::sun::star::uno::RuntimeException,
148 ::com::sun::star::lang::IndexOutOfBoundsException, std::exception) SAL_OVERRIDE;
150 ///===== XAccessibleComponent ============================================
152 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
153 SAL_CALL getAccessibleAtPoint(
154 const ::com::sun::star::awt::Point& rPoint )
155 throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
157 virtual void SAL_CALL grabFocus( )
158 throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
160 virtual sal_Int32 SAL_CALL getForeground( )
161 throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
163 virtual sal_Int32 SAL_CALL getBackground( )
164 throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
166 ///===== XAccessibleContext ==============================================
168 /// Return NULL to indicate that an empty relation set.
169 virtual ::com::sun::star::uno::Reference<
170 ::com::sun::star::accessibility::XAccessibleRelationSet> SAL_CALL
171 getAccessibleRelationSet()
172 throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
174 /// Return the set of current states.
175 virtual ::com::sun::star::uno::Reference<
176 ::com::sun::star::accessibility::XAccessibleStateSet> SAL_CALL
177 getAccessibleStateSet()
178 throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
180 ///===== XAccessibleSelection ===========================================
182 virtual void SAL_CALL
183 selectAccessibleChild( sal_Int32 nChildIndex )
184 throw (::com::sun::star::lang::IndexOutOfBoundsException,
185 ::com::sun::star::uno::RuntimeException,
186 std::exception) SAL_OVERRIDE;
188 virtual void SAL_CALL
189 clearAccessibleSelection( )
190 throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
192 virtual void SAL_CALL
193 selectAllAccessibleChildren( )
194 throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
196 virtual sal_Int32 SAL_CALL
197 getSelectedAccessibleChildCount( )
198 throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
200 virtual ::com::sun::star::uno::Reference<
201 ::com::sun::star::accessibility::XAccessible > SAL_CALL
202 getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex )
203 throw (::com::sun::star::lang::IndexOutOfBoundsException,
204 ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
206 virtual void SAL_CALL
207 deselectAccessibleChild( sal_Int32 nChildIndex )
208 throw (::com::sun::star::lang::IndexOutOfBoundsException,
209 ::com::sun::star::uno::RuntimeException,
210 std::exception) SAL_OVERRIDE;
212 ///===== XServiceInfo ====================================================
214 /** Returns an identifier for the implementation of this object.
216 virtual OUString SAL_CALL
217 getImplementationName()
218 throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
220 /** Returns a list of all supported services.
222 virtual ::com::sun::star::uno::Sequence< OUString> SAL_CALL
223 getSupportedServiceNames()
224 throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
226 ///===== XTypeProvider ===================================================
228 /** Returns a implementation id.
230 virtual ::com::sun::star::uno::Sequence<sal_Int8> SAL_CALL
231 getImplementationId()
232 throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
234 ///===== XAccessibleEventBroadcaster =====================================
236 /** Add listener that is informed of future changes of name,
237 description and so on events.
239 virtual void SAL_CALL
240 addAccessibleEventListener(
241 const ::com::sun::star::uno::Reference<
242 ::com::sun::star::accessibility::XAccessibleEventListener>& xListener)
243 throw (com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
244 //===== XAccessibleTableSelection ============================================
245 virtual sal_Bool SAL_CALL selectRow( sal_Int32 row )
246 throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException,
247 std::exception) SAL_OVERRIDE;
248 virtual sal_Bool SAL_CALL selectColumn( sal_Int32 column )
249 throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException,
250 std::exception) SAL_OVERRIDE;
251 virtual sal_Bool SAL_CALL unselectRow( sal_Int32 row )
252 throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException,
253 std::exception) SAL_OVERRIDE;
254 virtual sal_Bool SAL_CALL unselectColumn( sal_Int32 column )
255 throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException,
256 std::exception) SAL_OVERRIDE;
258 protected:
259 /// Return the object's current bounding box relative to the desktop.
260 virtual Rectangle GetBoundingBoxOnScreen() const
261 throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
263 /// Return the object's current bounding box relative to the parent object.
264 virtual Rectangle GetBoundingBox() const
265 throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
266 private:
267 ScTabViewShell* mpViewShell;
268 ScRangeList* mpMarkedRanges;
269 std::vector<ScMyAddress>* mpSortedMarkedCells;
270 ScAccessibleDocument* mpAccDoc;
271 rtl::Reference<ScAccessibleCell> mpAccCell;
272 Rectangle maVisCells;
273 ScSplitPos meSplitPos;
274 ScAddress maActiveCell;
275 SCTAB mnTab;
276 bool mbIsSpreadsheet;
277 bool mbHasSelection;
278 bool mbDelIns;
279 bool mbIsFocusSend;
281 bool IsDefunc(
282 const com::sun::star::uno::Reference<
283 ::com::sun::star::accessibility::XAccessibleStateSet>& rxParentStates);
284 bool IsEditable(
285 const com::sun::star::uno::Reference<
286 ::com::sun::star::accessibility::XAccessibleStateSet>& rxParentStates);
287 bool IsFocused();
288 bool IsCompleteSheetSelected();
290 void SelectCell(sal_Int32 nRow, sal_Int32 nCol, bool bDeselect);
291 void CreateSortedMarkedCells();
292 void AddMarkedRange(const ScRange& rRange);
294 static ScDocument* GetDocument(ScTabViewShell* pViewShell);
295 static Rectangle GetVisArea(ScTabViewShell* pViewShell, ScSplitPos eSplitPos);
296 Rectangle GetVisCells(const Rectangle& rVisArea);
297 typedef std::vector<ScMyAddress> VEC_MYADDR;
299 typedef std::map<ScMyAddress,com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > >
300 MAP_ADDR_XACC;
301 MAP_ADDR_XACC m_mapSelectionSend;
302 void RemoveSelection(ScMarkData &refScMarkData);
303 bool IsSameMarkCell();
304 void CommitFocusCell(const ScAddress &aNewCell);
305 public:
306 void FireFirstCellFocus();
307 private:
308 bool m_bFormulaMode;
309 bool m_bFormulaLastMode;
310 ScAddress m_aFormulaActiveCell;
311 MAP_ADDR_XACC m_mapFormulaSelectionSend;
312 VEC_MYADDR m_vecFormulaLastMyAddr;
313 rtl::Reference<ScAccessibleCell> m_pAccFormulaCell;
314 sal_uInt16 m_nMinX;
315 sal_uInt16 m_nMaxX;
316 sal_Int32 m_nMinY;
317 sal_Int32 m_nMaxY;
319 sal_Int32 GetRowAll() const { return m_nMaxY - m_nMinY + 1 ; }
320 sal_uInt16 GetColAll() const { return m_nMaxX - m_nMinX + 1; }
321 void NotifyRefMode();
322 void RemoveFormulaSelection(bool bRemoveAll = false);
323 bool CheckChildIndex(sal_Int32) const;
324 ScAddress GetChildIndexAddress(sal_Int32) const;
325 sal_Int32 GetAccessibleIndexFormula( sal_Int32 nRow, sal_Int32 nColumn );
326 bool GetFormulaCurrentFocusCell(ScAddress &addr);
327 public:
328 ScRange m_aLastWithInMarkRange;
329 OUString m_strCurCellValue;
330 ScRangeList m_LastMarkedRanges;
331 typedef std::vector<ScRange*> VEC_RANGE;
332 VEC_RANGE m_vecTempRange;
333 typedef std::pair<sal_uInt16,sal_uInt16> PAIR_COL;
334 typedef std::vector<PAIR_COL> VEC_COL;
335 VEC_COL m_vecTempCol;
336 OUString m_strOldTabName;
338 ::com::sun::star::uno::Reference < ::com::sun::star::accessibility::XAccessible > GetActiveCell();
339 bool IsScAddrFormulaSel (const ScAddress &addr) const;
340 bool IsFormulaMode();
341 ScMyAddress CalcScAddressFromRangeList(ScRangeList *pMarkedRanges,sal_Int32 nSelectedChildIndex);
342 static bool CalcScRangeDifferenceMax(ScRange *pSrc,ScRange *pDest,int nMax,VEC_MYADDR &vecRet,int &nSize);
343 static bool CalcScRangeListDifferenceMax(ScRangeList *pSrc,ScRangeList *pDest,int nMax,VEC_MYADDR &vecRet);
346 #endif
348 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */