Line data Source code
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 : #include "accessibility/extended/AccessibleGridControlHeader.hxx"
21 : #include "accessibility/extended/AccessibleGridControlHeaderCell.hxx"
22 : #include "accessibility/extended/AccessibleGridControlTableCell.hxx"
23 : #include <svtools/accessibletable.hxx>
24 : #include <comphelper/servicehelper.hxx>
25 :
26 :
27 : // ============================================================================
28 :
29 : using ::com::sun::star::uno::Reference;
30 : using ::com::sun::star::uno::Sequence;
31 : using ::com::sun::star::uno::Any;
32 :
33 : using namespace ::com::sun::star::uno;
34 : using namespace ::com::sun::star;
35 : using namespace ::com::sun::star::lang;
36 : using namespace ::com::sun::star::accessibility;
37 : using namespace ::svt;
38 : using namespace ::svt::table;
39 :
40 : // ============================================================================
41 :
42 : namespace accessibility {
43 :
44 : // ============================================================================
45 :
46 0 : AccessibleGridControlHeader::AccessibleGridControlHeader(
47 : const Reference< XAccessible >& rxParent,
48 : ::svt::table::IAccessibleTable& rTable,
49 : ::svt::table::AccessibleTableControlObjType eObjType):
50 0 : AccessibleGridControlTableBase( rxParent, rTable, eObjType )
51 : {
52 : OSL_ENSURE( isRowBar() || isColumnBar(),
53 : "accessibility/extended/AccessibleGridControlHeaderBar - invalid object type" );
54 0 : }
55 :
56 0 : AccessibleGridControlHeader::~AccessibleGridControlHeader()
57 : {
58 0 : }
59 :
60 : // XAccessibleContext ---------------------------------------------------------
61 :
62 : Reference< XAccessible > SAL_CALL
63 0 : AccessibleGridControlHeader::getAccessibleChild( sal_Int32 nChildIndex )
64 : throw ( lang::IndexOutOfBoundsException, uno::RuntimeException )
65 : {
66 0 : SolarMutexGuard aSolarGuard;
67 0 : ::osl::MutexGuard aGuard( getOslMutex() );
68 :
69 0 : if (nChildIndex<0 || nChildIndex>=getAccessibleChildCount())
70 0 : throw IndexOutOfBoundsException();
71 0 : ensureIsAlive();
72 0 : Reference< XAccessible > xChild;
73 0 : if(m_eObjType == svt::table::TCTYPE_COLUMNHEADERBAR)
74 : {
75 0 : AccessibleGridControlHeaderCell* pColHeaderCell = new AccessibleGridControlHeaderCell(nChildIndex, this, m_aTable, svt::table::TCTYPE_COLUMNHEADERCELL);
76 0 : xChild = pColHeaderCell;
77 : }
78 0 : else if(m_eObjType == svt::table::TCTYPE_ROWHEADERBAR)
79 : {
80 0 : AccessibleGridControlHeaderCell* pRowHeaderCell = new AccessibleGridControlHeaderCell(nChildIndex, this, m_aTable, svt::table::TCTYPE_ROWHEADERCELL);
81 0 : xChild = pRowHeaderCell;
82 : }
83 0 : return xChild;
84 : }
85 :
86 0 : sal_Int32 SAL_CALL AccessibleGridControlHeader::getAccessibleIndexInParent()
87 : throw ( uno::RuntimeException )
88 : {
89 0 : ensureIsAlive();
90 0 : if(m_eObjType == svt::table::TCTYPE_ROWHEADERBAR && m_aTable.HasColHeader())
91 0 : return 1;
92 : else
93 0 : return 0;
94 : }
95 :
96 : // XAccessibleComponent -------------------------------------------------------
97 :
98 : Reference< XAccessible > SAL_CALL
99 0 : AccessibleGridControlHeader::getAccessibleAtPoint( const awt::Point& rPoint )
100 : throw ( uno::RuntimeException )
101 : {
102 0 : SolarMutexGuard aSolarGuard;
103 0 : ::osl::MutexGuard aGuard( getOslMutex() );
104 0 : ensureIsAlive();
105 :
106 0 : sal_Int32 nRow = 0;
107 0 : sal_Int32 nColumnPos = 0;
108 0 : sal_Bool bConverted = isRowBar() ?
109 0 : m_aTable.ConvertPointToCellAddress( nRow, nColumnPos, VCLPoint( rPoint ) ) :
110 0 : m_aTable.ConvertPointToCellAddress( nRow, nColumnPos, VCLPoint( rPoint ) );
111 :
112 0 : return bConverted ? implGetChild( nRow, nColumnPos ) : Reference< XAccessible >();
113 : }
114 :
115 0 : void SAL_CALL AccessibleGridControlHeader::grabFocus()
116 : throw ( uno::RuntimeException )
117 : {
118 0 : ensureIsAlive();
119 : // focus on header not supported
120 0 : }
121 :
122 0 : Any SAL_CALL AccessibleGridControlHeader::getAccessibleKeyBinding()
123 : throw ( uno::RuntimeException )
124 : {
125 0 : ensureIsAlive();
126 0 : return Any(); // no special key bindings for header
127 : }
128 :
129 : // XAccessibleTable -----------------------------------------------------------
130 :
131 0 : OUString SAL_CALL AccessibleGridControlHeader::getAccessibleRowDescription( sal_Int32 nRow )
132 : throw ( lang::IndexOutOfBoundsException, uno::RuntimeException )
133 : {
134 0 : SolarMutexGuard aSolarGuard;
135 0 : ::osl::MutexGuard aGuard( getOslMutex() );
136 0 : ensureIsAlive();
137 0 : ensureIsValidRow( nRow );
138 0 : return OUString(); // no headers in headers
139 : }
140 :
141 0 : OUString SAL_CALL AccessibleGridControlHeader::getAccessibleColumnDescription( sal_Int32 nColumn )
142 : throw ( lang::IndexOutOfBoundsException, uno::RuntimeException )
143 : {
144 0 : SolarMutexGuard aSolarGuard;
145 0 : ::osl::MutexGuard aGuard( getOslMutex() );
146 0 : ensureIsAlive();
147 0 : ensureIsValidColumn( nColumn );
148 0 : return OUString(); // no headers in headers
149 : }
150 :
151 0 : Reference< XAccessibleTable > SAL_CALL AccessibleGridControlHeader::getAccessibleRowHeaders()
152 : throw ( uno::RuntimeException )
153 : {
154 0 : ensureIsAlive();
155 0 : return NULL; // no headers in headers
156 : }
157 :
158 0 : Reference< XAccessibleTable > SAL_CALL AccessibleGridControlHeader::getAccessibleColumnHeaders()
159 : throw ( uno::RuntimeException )
160 : {
161 0 : ensureIsAlive();
162 0 : return NULL; // no headers in headers
163 : }
164 : //not selectable
165 0 : Sequence< sal_Int32 > SAL_CALL AccessibleGridControlHeader::getSelectedAccessibleRows()
166 : throw ( uno::RuntimeException )
167 : {
168 0 : Sequence< sal_Int32 > aSelSeq(0);
169 0 : return aSelSeq;
170 : }
171 : //columns aren't selectable
172 0 : Sequence< sal_Int32 > SAL_CALL AccessibleGridControlHeader::getSelectedAccessibleColumns()
173 : throw ( uno::RuntimeException )
174 : {
175 0 : Sequence< sal_Int32 > aSelSeq(0);
176 0 : return aSelSeq;
177 : }
178 : //row headers not selectable
179 0 : sal_Bool SAL_CALL AccessibleGridControlHeader::isAccessibleRowSelected( sal_Int32 /*nRow*/ )
180 : throw ( lang::IndexOutOfBoundsException, uno::RuntimeException )
181 : {
182 0 : return sal_False;
183 : }
184 : //columns aren't selectable
185 0 : sal_Bool SAL_CALL AccessibleGridControlHeader::isAccessibleColumnSelected( sal_Int32 nColumn )
186 : throw ( lang::IndexOutOfBoundsException, uno::RuntimeException )
187 : {
188 : (void)nColumn;
189 0 : return sal_False;
190 : }
191 : //not implemented
192 0 : Reference< XAccessible > SAL_CALL AccessibleGridControlHeader::getAccessibleCellAt(
193 : sal_Int32 /*nRow*/, sal_Int32 /*nColumn*/ )
194 : throw ( lang::IndexOutOfBoundsException, uno::RuntimeException )
195 : {
196 0 : return NULL;
197 : }
198 : // not selectable
199 0 : sal_Bool SAL_CALL AccessibleGridControlHeader::isAccessibleSelected(
200 : sal_Int32 /*nRow*/, sal_Int32 /*nColumn */)
201 : throw ( lang::IndexOutOfBoundsException, uno::RuntimeException )
202 : {
203 0 : return sal_False;
204 : }
205 :
206 : // XServiceInfo ---------------------------------------------------------------
207 :
208 0 : OUString SAL_CALL AccessibleGridControlHeader::getImplementationName()
209 : throw ( uno::RuntimeException )
210 : {
211 0 : return OUString( "com.sun.star.accessibility.AccessibleGridControlHeader" );
212 : }
213 :
214 : namespace
215 : {
216 : class theAccessibleGridControlHeaderImplementationId : public rtl::Static< UnoTunnelIdInit, theAccessibleGridControlHeaderImplementationId > {};
217 : }
218 :
219 0 : Sequence< sal_Int8 > SAL_CALL AccessibleGridControlHeader::getImplementationId()
220 : throw ( uno::RuntimeException )
221 : {
222 0 : return theAccessibleGridControlHeaderImplementationId::get().getSeq();
223 : }
224 :
225 : // internal virtual methods ---------------------------------------------------
226 :
227 0 : Rectangle AccessibleGridControlHeader::implGetBoundingBox()
228 : {
229 0 : Window* pParent = m_aTable.GetAccessibleParentWindow();
230 0 : Rectangle aGridRect( m_aTable.GetWindowExtentsRelative( pParent ) );
231 0 : Rectangle aHeaderRect (m_aTable.calcHeaderRect(isColumnBar()));
232 0 : if(isColumnBar())
233 0 : return Rectangle(aGridRect.TopLeft(), Size(aGridRect.getWidth(),aHeaderRect.getHeight()));
234 : else
235 0 : return Rectangle(aGridRect.TopLeft(), Size(aHeaderRect.getWidth(),aGridRect.getHeight()));
236 :
237 : }
238 :
239 0 : Rectangle AccessibleGridControlHeader::implGetBoundingBoxOnScreen()
240 : {
241 0 : Rectangle aGridRect( m_aTable.GetWindowExtentsRelative( NULL ) );
242 0 : Rectangle aHeaderRect (m_aTable.calcHeaderRect(isColumnBar()));
243 0 : if(isColumnBar())
244 0 : return Rectangle(aGridRect.TopLeft(), Size(aGridRect.getWidth(),aHeaderRect.getHeight()));
245 : else
246 0 : return Rectangle(aGridRect.TopLeft(), Size(aHeaderRect.getWidth(),aGridRect.getHeight()));
247 : }
248 :
249 0 : sal_Int32 AccessibleGridControlHeader::implGetRowCount() const
250 : {
251 0 : return 1;
252 : }
253 :
254 0 : sal_Int32 AccessibleGridControlHeader::implGetColumnCount() const
255 : {
256 0 : return 1;
257 : }
258 :
259 : // internal helper methods ----------------------------------------------------
260 :
261 0 : Reference< XAccessible > AccessibleGridControlHeader::implGetChild(
262 : sal_Int32 nRow, sal_uInt32 nColumnPos )
263 : {
264 0 : Reference< XAccessible > xChild;
265 0 : if(m_eObjType == svt::table::TCTYPE_COLUMNHEADERBAR)
266 : {
267 0 : AccessibleGridControlHeaderCell* pColHeaderCell = new AccessibleGridControlHeaderCell(nColumnPos, this, m_aTable, svt::table::TCTYPE_COLUMNHEADERCELL);
268 0 : xChild = pColHeaderCell;
269 : }
270 0 : else if(m_eObjType == svt::table::TCTYPE_ROWHEADERBAR)
271 : {
272 0 : AccessibleGridControlHeaderCell* pRowHeaderCell = new AccessibleGridControlHeaderCell(nRow, this, m_aTable, svt::table::TCTYPE_ROWHEADERCELL);
273 0 : xChild = pRowHeaderCell;
274 : }
275 0 : return xChild;
276 : }
277 :
278 : // ============================================================================
279 :
280 : } // namespace accessibility
281 :
282 : // ============================================================================
283 :
284 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|