1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_accessibility.hxx"
26
27
28 #include "accessibility/extended/AccessibleGridControlHeader.hxx"
29 #include "accessibility/extended/AccessibleGridControlHeaderCell.hxx"
30 #include "accessibility/extended/AccessibleGridControlTableCell.hxx"
31 #include <svtools/accessibletable.hxx>
32
33
34 // ============================================================================
35
36 using ::rtl::OUString;
37
38 using ::com::sun::star::uno::Reference;
39 using ::com::sun::star::uno::Sequence;
40 using ::com::sun::star::uno::Any;
41
42 using namespace ::com::sun::star::uno;
43 using namespace ::com::sun::star;
44 using namespace ::com::sun::star::lang;
45 using namespace ::com::sun::star::accessibility;
46 using namespace ::svt;
47 using namespace ::svt::table;
48
49 // ============================================================================
50
51 namespace accessibility {
52
53 // ============================================================================
54
DBG_NAME(AccessibleGridControlHeader)55 DBG_NAME( AccessibleGridControlHeader )
56
57 AccessibleGridControlHeader::AccessibleGridControlHeader(
58 const Reference< XAccessible >& rxParent,
59 ::svt::table::IAccessibleTable& rTable,
60 ::svt::table::AccessibleTableControlObjType eObjType):
61 AccessibleGridControlTableBase( rxParent, rTable, eObjType )
62 {
63 DBG_ASSERT( isRowBar() || isColumnBar(),
64 "accessibility/extended/AccessibleGridControlHeaderBar - invalid object type" );
65 }
66
~AccessibleGridControlHeader()67 AccessibleGridControlHeader::~AccessibleGridControlHeader()
68 {
69 }
70
71 // XAccessibleContext ---------------------------------------------------------
72
73 Reference< XAccessible > SAL_CALL
getAccessibleChild(sal_Int32 nChildIndex)74 AccessibleGridControlHeader::getAccessibleChild( sal_Int32 nChildIndex )
75 {
76 TCSolarGuard aSolarGuard;
77 ::osl::MutexGuard aGuard( getOslMutex() );
78
79 if (nChildIndex<0 || nChildIndex>=getAccessibleChildCount())
80 throw IndexOutOfBoundsException();
81 ensureIsAlive();
82 Reference< XAccessible > xChild;
83 if(m_eObjType == svt::table::TCTYPE_COLUMNHEADERBAR)
84 {
85 AccessibleGridControlHeaderCell* pColHeaderCell = new AccessibleGridControlHeaderCell(nChildIndex, this, m_aTable, svt::table::TCTYPE_COLUMNHEADERCELL);
86 xChild = pColHeaderCell;
87 }
88 else if(m_eObjType == svt::table::TCTYPE_ROWHEADERBAR)
89 {
90 AccessibleGridControlHeaderCell* pRowHeaderCell = new AccessibleGridControlHeaderCell(nChildIndex, this, m_aTable, svt::table::TCTYPE_ROWHEADERCELL);
91 xChild = pRowHeaderCell;
92 }
93 return xChild;
94 }
95
getAccessibleIndexInParent()96 sal_Int32 SAL_CALL AccessibleGridControlHeader::getAccessibleIndexInParent()
97 {
98 ensureIsAlive();
99 if(m_eObjType == svt::table::TCTYPE_ROWHEADERBAR && m_aTable.HasColHeader())
100 return 1;
101 else
102 return 0;
103 }
104
105 // XAccessibleComponent -------------------------------------------------------
106
107 Reference< XAccessible > SAL_CALL
getAccessibleAtPoint(const awt::Point & rPoint)108 AccessibleGridControlHeader::getAccessibleAtPoint( const awt::Point& rPoint )
109 {
110 TCSolarGuard aSolarGuard;
111 ::osl::MutexGuard aGuard( getOslMutex() );
112 ensureIsAlive();
113
114 sal_Int32 nRow = 0;
115 sal_Int32 nColumnPos = 0;
116 sal_Bool bConverted = isRowBar() ?
117 m_aTable.ConvertPointToCellAddress( nRow, nColumnPos, VCLPoint( rPoint ) ) :
118 m_aTable.ConvertPointToCellAddress( nRow, nColumnPos, VCLPoint( rPoint ) );
119
120 return bConverted ? implGetChild( nRow, nColumnPos ) : Reference< XAccessible >();
121 }
122
grabFocus()123 void SAL_CALL AccessibleGridControlHeader::grabFocus()
124 {
125 ensureIsAlive();
126 // focus on header not supported
127 }
128
getAccessibleKeyBinding()129 Any SAL_CALL AccessibleGridControlHeader::getAccessibleKeyBinding()
130 {
131 ensureIsAlive();
132 return Any(); // no special key bindings for header
133 }
134
135 // XAccessibleTable -----------------------------------------------------------
136
getAccessibleRowDescription(sal_Int32 nRow)137 OUString SAL_CALL AccessibleGridControlHeader::getAccessibleRowDescription( sal_Int32 nRow )
138 {
139 TCSolarGuard aSolarGuard;
140 ::osl::MutexGuard aGuard( getOslMutex() );
141 ensureIsAlive();
142 ensureIsValidRow( nRow );
143 return OUString(); // no headers in headers
144 }
145
getAccessibleColumnDescription(sal_Int32 nColumn)146 OUString SAL_CALL AccessibleGridControlHeader::getAccessibleColumnDescription( sal_Int32 nColumn )
147 {
148 TCSolarGuard aSolarGuard;
149 ::osl::MutexGuard aGuard( getOslMutex() );
150 ensureIsAlive();
151 ensureIsValidColumn( nColumn );
152 return OUString(); // no headers in headers
153 }
154
getAccessibleRowHeaders()155 Reference< XAccessibleTable > SAL_CALL AccessibleGridControlHeader::getAccessibleRowHeaders()
156 {
157 ensureIsAlive();
158 return NULL; // no headers in headers
159 }
160
getAccessibleColumnHeaders()161 Reference< XAccessibleTable > SAL_CALL AccessibleGridControlHeader::getAccessibleColumnHeaders()
162 {
163 ensureIsAlive();
164 return NULL; // no headers in headers
165 }
166 //not selectable
getSelectedAccessibleRows()167 Sequence< sal_Int32 > SAL_CALL AccessibleGridControlHeader::getSelectedAccessibleRows()
168 {
169 Sequence< sal_Int32 > aSelSeq(0);
170 return aSelSeq;
171 }
172 //columns aren't selectable
getSelectedAccessibleColumns()173 Sequence< sal_Int32 > SAL_CALL AccessibleGridControlHeader::getSelectedAccessibleColumns()
174 {
175 Sequence< sal_Int32 > aSelSeq(0);
176 return aSelSeq;
177 }
178 //row headers not selectable
isAccessibleRowSelected(sal_Int32)179 sal_Bool SAL_CALL AccessibleGridControlHeader::isAccessibleRowSelected( sal_Int32 /*nRow*/ )
180 {
181 return sal_False;
182 }
183 //columns aren't selectable
isAccessibleColumnSelected(sal_Int32 nColumn)184 sal_Bool SAL_CALL AccessibleGridControlHeader::isAccessibleColumnSelected( sal_Int32 nColumn )
185 {
186 (void)nColumn;
187 return sal_False;
188 }
189 //not implemented
getAccessibleCellAt(sal_Int32,sal_Int32)190 Reference< XAccessible > SAL_CALL AccessibleGridControlHeader::getAccessibleCellAt(
191 sal_Int32 /*nRow*/, sal_Int32 /*nColumn*/ )
192 {
193 return NULL;
194 }
195 // not selectable
isAccessibleSelected(sal_Int32,sal_Int32)196 sal_Bool SAL_CALL AccessibleGridControlHeader::isAccessibleSelected(
197 sal_Int32 /*nRow*/, sal_Int32 /*nColumn */)
198 {
199 return sal_False;
200 }
201
202 // XServiceInfo ---------------------------------------------------------------
203
getImplementationName()204 OUString SAL_CALL AccessibleGridControlHeader::getImplementationName()
205 {
206 return OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.accessibility.AccessibleGridControlHeader" ) );
207 }
208
getImplementationId()209 Sequence< sal_Int8 > SAL_CALL AccessibleGridControlHeader::getImplementationId()
210 {
211 ::osl::MutexGuard aGuard( getOslGlobalMutex() );
212 static Sequence< sal_Int8 > aId;
213 implCreateUuid( aId );
214 return aId;
215 }
216
217 // internal virtual methods ---------------------------------------------------
218
implGetBoundingBox()219 Rectangle AccessibleGridControlHeader::implGetBoundingBox()
220 {
221 Window* pParent = m_aTable.GetAccessibleParentWindow();
222 Rectangle aGridRect( m_aTable.GetWindowExtentsRelative( pParent ) );
223 Rectangle aHeaderRect (m_aTable.calcHeaderRect(isColumnBar()));
224 if(isColumnBar())
225 return Rectangle(aGridRect.TopLeft(), Size(aGridRect.getWidth(),aHeaderRect.getHeight()));
226 else
227 return Rectangle(aGridRect.TopLeft(), Size(aHeaderRect.getWidth(),aGridRect.getHeight()));
228
229 }
230
implGetBoundingBoxOnScreen()231 Rectangle AccessibleGridControlHeader::implGetBoundingBoxOnScreen()
232 {
233 Rectangle aGridRect( m_aTable.GetWindowExtentsRelative( NULL ) );
234 Rectangle aHeaderRect (m_aTable.calcHeaderRect(isColumnBar()));
235 if(isColumnBar())
236 return Rectangle(aGridRect.TopLeft(), Size(aGridRect.getWidth(),aHeaderRect.getHeight()));
237 else
238 return Rectangle(aGridRect.TopLeft(), Size(aHeaderRect.getWidth(),aGridRect.getHeight()));
239 }
240
implGetRowCount() const241 sal_Int32 AccessibleGridControlHeader::implGetRowCount() const
242 {
243 return 1;
244 }
245
implGetColumnCount() const246 sal_Int32 AccessibleGridControlHeader::implGetColumnCount() const
247 {
248 return 1;
249 }
250
251 // internal helper methods ----------------------------------------------------
252
implGetChild(sal_Int32 nRow,sal_uInt32 nColumnPos)253 Reference< XAccessible > AccessibleGridControlHeader::implGetChild(
254 sal_Int32 nRow, sal_uInt32 nColumnPos )
255 {
256 Reference< XAccessible > xChild;
257 if(m_eObjType == svt::table::TCTYPE_COLUMNHEADERBAR)
258 {
259 AccessibleGridControlHeaderCell* pColHeaderCell = new AccessibleGridControlHeaderCell(nColumnPos, this, m_aTable, svt::table::TCTYPE_COLUMNHEADERCELL);
260 xChild = pColHeaderCell;
261 }
262 else if(m_eObjType == svt::table::TCTYPE_ROWHEADERBAR)
263 {
264 AccessibleGridControlHeaderCell* pRowHeaderCell = new AccessibleGridControlHeaderCell(nRow, this, m_aTable, svt::table::TCTYPE_ROWHEADERCELL);
265 xChild = pRowHeaderCell;
266 }
267 return xChild;
268 }
269
270 // ============================================================================
271
272 } // namespace accessibility
273
274 // ============================================================================
275