1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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"
32 #include "rangelst.hxx"
35 class ScMyAddress
: public ScAddress
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());
46 return (Col() < rAddress
.Col());
51 class ScAccessibleDocument
;
52 class ScAccessibleCell
;
56 This base class provides an implementation of the
57 <code>AccessibleTable</code> service.
59 class ScAccessibleSpreadsheet
60 : public ScAccessibleTableBase
63 //===== internal ========================================================
64 ScAccessibleSpreadsheet(
65 ScAccessibleDocument
* pAccDoc
,
66 ScTabViewShell
* pViewShell
,
68 ScSplitPos eSplitPos
);
70 ScAccessibleSpreadsheet(
71 ScAccessibleSpreadsheet
& rParent
,
72 const ScRange
& rRange
);
74 virtual ~ScAccessibleSpreadsheet();
76 void ConstructScAccessibleSpreadsheet(
77 ScAccessibleDocument
* pAccDoc
,
78 ScTabViewShell
* pViewShell
,
80 ScSplitPos eSplitPos
);
82 using ScAccessibleTableBase::IsDefunc
;
85 using ScAccessibleTableBase::disposing
;
87 virtual void SAL_CALL
disposing() override
;
89 void CompleteSelectionChanged(bool bNewState
);
94 void BoundingBoxChanged();
95 void VisAreaChanged();
98 ///===== SfxListener =====================================================
99 virtual void Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
) override
;
101 ///===== XAccessibleTable ================================================
103 /// Returns the row headers as an AccessibleTable.
104 virtual css::uno::Reference
< css::accessibility::XAccessibleTable
> SAL_CALL
105 getAccessibleRowHeaders( )
106 throw (css::uno::RuntimeException
, std::exception
) override
;
108 /// Returns the column headers as an AccessibleTable.
109 virtual css::uno::Reference
< css::accessibility::XAccessibleTable
> SAL_CALL
110 getAccessibleColumnHeaders( )
111 throw (css::uno::RuntimeException
, std::exception
) override
;
113 /// Returns the selected rows in a table.
114 virtual css::uno::Sequence
< sal_Int32
> SAL_CALL
115 getSelectedAccessibleRows( )
116 throw (css::uno::RuntimeException
, std::exception
) override
;
118 /// Returns the selected columns in a table.
119 virtual css::uno::Sequence
< sal_Int32
> SAL_CALL
120 getSelectedAccessibleColumns( )
121 throw (css::uno::RuntimeException
, std::exception
) override
;
123 /// Returns a boolean value indicating whether the specified row is selected.
124 virtual sal_Bool SAL_CALL
125 isAccessibleRowSelected( sal_Int32 nRow
)
126 throw (css::uno::RuntimeException
,
127 css::lang::IndexOutOfBoundsException
, std::exception
) override
;
129 /// Returns a boolean value indicating whether the specified column is selected.
130 virtual sal_Bool SAL_CALL
131 isAccessibleColumnSelected( sal_Int32 nColumn
)
132 throw (css::uno::RuntimeException
,
133 css::lang::IndexOutOfBoundsException
, std::exception
) override
;
135 /// Returns the Accessible at a specified row and column in the table.
136 virtual css::uno::Reference
< css::accessibility::XAccessible
> SAL_CALL
137 getAccessibleCellAt( sal_Int32 nRow
, sal_Int32 nColumn
)
138 throw (css::uno::RuntimeException
,
139 css::lang::IndexOutOfBoundsException
, std::exception
) override
;
141 rtl::Reference
<ScAccessibleCell
> GetAccessibleCellAt(sal_Int32 nRow
, sal_Int32 nColumn
);
143 /// Returns a boolean value indicating whether the accessible at a specified row and column is selected.
144 virtual sal_Bool SAL_CALL
145 isAccessibleSelected( sal_Int32 nRow
, sal_Int32 nColumn
)
146 throw (css::uno::RuntimeException
,
147 css::lang::IndexOutOfBoundsException
, std::exception
) override
;
149 ///===== XAccessibleComponent ============================================
151 virtual css::uno::Reference
< css::accessibility::XAccessible
>
152 SAL_CALL
getAccessibleAtPoint(
153 const css::awt::Point
& rPoint
)
154 throw (css::uno::RuntimeException
, std::exception
) override
;
156 virtual void SAL_CALL
grabFocus( )
157 throw (css::uno::RuntimeException
, std::exception
) override
;
159 virtual sal_Int32 SAL_CALL
getForeground( )
160 throw (css::uno::RuntimeException
, std::exception
) override
;
162 virtual sal_Int32 SAL_CALL
getBackground( )
163 throw (css::uno::RuntimeException
, std::exception
) override
;
165 ///===== XAccessibleContext ==============================================
167 /// Return NULL to indicate that an empty relation set.
168 virtual css::uno::Reference
<css::accessibility::XAccessibleRelationSet
> SAL_CALL
169 getAccessibleRelationSet()
170 throw (css::uno::RuntimeException
, std::exception
) override
;
172 /// Return the set of current states.
173 virtual css::uno::Reference
<css::accessibility::XAccessibleStateSet
> SAL_CALL
174 getAccessibleStateSet()
175 throw (css::uno::RuntimeException
, std::exception
) override
;
177 ///===== XAccessibleSelection ===========================================
179 virtual void SAL_CALL
180 selectAccessibleChild( sal_Int32 nChildIndex
)
181 throw (css::lang::IndexOutOfBoundsException
,
182 css::uno::RuntimeException
,
183 std::exception
) override
;
185 virtual void SAL_CALL
186 clearAccessibleSelection( )
187 throw (css::uno::RuntimeException
, std::exception
) override
;
189 virtual void SAL_CALL
190 selectAllAccessibleChildren( )
191 throw (css::uno::RuntimeException
, std::exception
) override
;
193 virtual sal_Int32 SAL_CALL
194 getSelectedAccessibleChildCount( )
195 throw (css::uno::RuntimeException
, std::exception
) override
;
197 virtual css::uno::Reference
<css::accessibility::XAccessible
> SAL_CALL
198 getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex
)
199 throw (css::lang::IndexOutOfBoundsException
,
200 css::uno::RuntimeException
, std::exception
) override
;
202 virtual void SAL_CALL
203 deselectAccessibleChild( sal_Int32 nChildIndex
)
204 throw (css::lang::IndexOutOfBoundsException
,
205 css::uno::RuntimeException
,
206 std::exception
) override
;
208 ///===== XServiceInfo ====================================================
210 /** Returns an identifier for the implementation of this object.
212 virtual OUString SAL_CALL
213 getImplementationName()
214 throw (css::uno::RuntimeException
, std::exception
) override
;
216 /** Returns a list of all supported services.
218 virtual css::uno::Sequence
< OUString
> SAL_CALL
219 getSupportedServiceNames()
220 throw (css::uno::RuntimeException
, std::exception
) override
;
222 ///===== XTypeProvider ===================================================
224 /** Returns a implementation id.
226 virtual css::uno::Sequence
<sal_Int8
> SAL_CALL
227 getImplementationId()
228 throw (css::uno::RuntimeException
, std::exception
) override
;
230 ///===== XAccessibleEventBroadcaster =====================================
232 /** Add listener that is informed of future changes of name,
233 description and so on events.
235 virtual void SAL_CALL
236 addAccessibleEventListener(
237 const css::uno::Reference
<css::accessibility::XAccessibleEventListener
>& xListener
)
238 throw (css::uno::RuntimeException
, std::exception
) override
;
239 //===== XAccessibleTableSelection ============================================
240 virtual sal_Bool SAL_CALL
selectRow( sal_Int32 row
)
241 throw (css::lang::IndexOutOfBoundsException
, css::uno::RuntimeException
,
242 std::exception
) override
;
243 virtual sal_Bool SAL_CALL
selectColumn( sal_Int32 column
)
244 throw (css::lang::IndexOutOfBoundsException
, css::uno::RuntimeException
,
245 std::exception
) override
;
246 virtual sal_Bool SAL_CALL
unselectRow( sal_Int32 row
)
247 throw (css::lang::IndexOutOfBoundsException
, css::uno::RuntimeException
,
248 std::exception
) override
;
249 virtual sal_Bool SAL_CALL
unselectColumn( sal_Int32 column
)
250 throw (css::lang::IndexOutOfBoundsException
, css::uno::RuntimeException
,
251 std::exception
) override
;
254 /// Return the object's current bounding box relative to the desktop.
255 virtual Rectangle
GetBoundingBoxOnScreen() const
256 throw (css::uno::RuntimeException
, std::exception
) override
;
258 /// Return the object's current bounding box relative to the parent object.
259 virtual Rectangle
GetBoundingBox() const
260 throw (css::uno::RuntimeException
, std::exception
) override
;
262 ScTabViewShell
* mpViewShell
;
263 ScRangeList
* mpMarkedRanges
;
264 std::vector
<ScMyAddress
>* mpSortedMarkedCells
;
265 ScAccessibleDocument
* mpAccDoc
;
266 rtl::Reference
<ScAccessibleCell
> mpAccCell
;
267 Rectangle maVisCells
;
268 ScSplitPos meSplitPos
;
269 ScAddress maActiveCell
;
271 bool mbIsSpreadsheet
;
277 const css::uno::Reference
<css::accessibility::XAccessibleStateSet
>& rxParentStates
);
279 const css::uno::Reference
<css::accessibility::XAccessibleStateSet
>& rxParentStates
);
281 bool IsCompleteSheetSelected();
283 void SelectCell(sal_Int32 nRow
, sal_Int32 nCol
, bool bDeselect
);
285 static ScDocument
* GetDocument(ScTabViewShell
* pViewShell
);
286 static Rectangle
GetVisArea(ScTabViewShell
* pViewShell
, ScSplitPos eSplitPos
);
287 Rectangle
GetVisCells(const Rectangle
& rVisArea
);
288 typedef std::vector
<ScMyAddress
> VEC_MYADDR
;
290 typedef std::map
<ScMyAddress
,css::uno::Reference
< css::accessibility::XAccessible
> >
292 MAP_ADDR_XACC m_mapSelectionSend
;
293 void RemoveSelection(ScMarkData
&refScMarkData
);
294 bool IsSameMarkCell();
295 void CommitFocusCell(const ScAddress
&aNewCell
);
297 void FireFirstCellFocus();
300 bool m_bFormulaLastMode
;
301 ScAddress m_aFormulaActiveCell
;
302 MAP_ADDR_XACC m_mapFormulaSelectionSend
;
303 VEC_MYADDR m_vecFormulaLastMyAddr
;
304 rtl::Reference
<ScAccessibleCell
> m_pAccFormulaCell
;
310 sal_Int32
GetRowAll() const { return m_nMaxY
- m_nMinY
+ 1 ; }
311 sal_uInt16
GetColAll() const { return m_nMaxX
- m_nMinX
+ 1; }
312 void NotifyRefMode();
313 void RemoveFormulaSelection(bool bRemoveAll
= false);
314 bool CheckChildIndex(sal_Int32
) const;
315 ScAddress
GetChildIndexAddress(sal_Int32
) const;
316 sal_Int32
GetAccessibleIndexFormula( sal_Int32 nRow
, sal_Int32 nColumn
);
317 bool GetFormulaCurrentFocusCell(ScAddress
&addr
);
319 ScRange m_aLastWithInMarkRange
;
320 OUString m_strCurCellValue
;
321 ScRangeList m_LastMarkedRanges
;
322 typedef std::vector
<ScRange
*> VEC_RANGE
;
323 VEC_RANGE m_vecTempRange
;
324 typedef std::pair
<sal_uInt16
,sal_uInt16
> PAIR_COL
;
325 typedef std::vector
<PAIR_COL
> VEC_COL
;
326 VEC_COL m_vecTempCol
;
327 OUString m_strOldTabName
;
329 css::uno::Reference
< css::accessibility::XAccessible
> GetActiveCell();
330 bool IsScAddrFormulaSel (const ScAddress
&addr
) const;
331 bool IsFormulaMode();
332 ScMyAddress
CalcScAddressFromRangeList(ScRangeList
*pMarkedRanges
,sal_Int32 nSelectedChildIndex
);
333 static bool CalcScRangeDifferenceMax(ScRange
*pSrc
,ScRange
*pDest
,int nMax
,VEC_MYADDR
&vecRet
,int &nSize
);
334 static bool CalcScRangeListDifferenceMax(ScRangeList
*pSrc
,ScRangeList
*pDest
,int nMax
,VEC_MYADDR
&vecRet
);
339 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */