Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include "accessibility/extended/AccessibleGridControlTableCell.hxx"
31 : : #include <svtools/accessibletable.hxx>
32 : : #include "accessibility/extended/AccessibleGridControl.hxx"
33 : : #include <tools/gen.hxx>
34 : : #include <toolkit/helper/vclunohelper.hxx>
35 : : #include <com/sun/star/accessibility/AccessibleEventId.hpp>
36 : :
37 : : namespace accessibility
38 : : {
39 : : namespace
40 : : {
41 : : // FIXME this is a copy'n'paste from
42 : : // source/extended/AccessibleBrowseBoxTableCell.cxx, get rid of that...
43 : 0 : static void checkIndex_Impl( sal_Int32 _nIndex, const ::rtl::OUString& _sText ) throw (::com::sun::star::lang::IndexOutOfBoundsException)
44 : : {
45 [ # # ]: 0 : if ( _nIndex >= _sText.getLength() )
46 [ # # ]: 0 : throw ::com::sun::star::lang::IndexOutOfBoundsException();
47 : 0 : }
48 : : }
49 : : using namespace ::com::sun::star::lang;
50 : : using namespace utl;
51 : : using namespace comphelper;
52 : : using ::rtl::OUString;
53 : : using ::accessibility::AccessibleGridControl;
54 : : using namespace ::com::sun::star::uno;
55 : : using ::com::sun::star::accessibility::XAccessible;
56 : : using namespace ::com::sun::star::accessibility;
57 : : using namespace ::svt;
58 : : using namespace ::svt::table;
59 : :
60 : :
61 : : // =============================================================================
62 : : // = AccessibleGridControlCell
63 : : // =============================================================================
64 : : // -----------------------------------------------------------------------------
65 : 0 : AccessibleGridControlCell::AccessibleGridControlCell(
66 : : const Reference< XAccessible >& _rxParent, IAccessibleTable& _rTable,
67 : : sal_Int32 _nRowPos, sal_uInt16 _nColPos, AccessibleTableControlObjType _eType )
68 : : :AccessibleGridControlBase( _rxParent, _rTable, _eType )
69 : : ,m_nRowPos( _nRowPos )
70 : 0 : ,m_nColPos( _nColPos )
71 : : {
72 : : // set accessible name here, because for that we need the position of the cell
73 : : // and so the base class isn't capable of doing this
74 : 0 : ::rtl::OUString aAccName;
75 [ # # ]: 0 : if(_eType == TCTYPE_TABLECELL)
76 [ # # ]: 0 : aAccName = _rTable.GetAccessibleObjectName( TCTYPE_TABLECELL, _nRowPos, _nColPos );
77 [ # # ]: 0 : else if(_eType == TCTYPE_ROWHEADERCELL)
78 [ # # ]: 0 : aAccName = _rTable.GetAccessibleObjectName( TCTYPE_ROWHEADERCELL, _nRowPos, 0 );
79 [ # # ]: 0 : else if(_eType == TCTYPE_COLUMNHEADERCELL)
80 [ # # ]: 0 : aAccName = _rTable.GetAccessibleObjectName( TCTYPE_COLUMNHEADERCELL, 0, _nRowPos );
81 : 0 : implSetName( aAccName );
82 : 0 : }
83 : :
84 : : // -----------------------------------------------------------------------------
85 : 0 : AccessibleGridControlCell::~AccessibleGridControlCell()
86 : : {
87 [ # # ]: 0 : }
88 : :
89 : : // -----------------------------------------------------------------------------
90 : 0 : void SAL_CALL AccessibleGridControlCell::grabFocus() throw ( RuntimeException )
91 : : {
92 [ # # ]: 0 : SolarMutexGuard aSolarGuard;
93 [ # # ]: 0 : ::osl::MutexGuard aGuard( getOslMutex() );
94 [ # # ][ # # ]: 0 : m_aTable.GoToCell( m_nColPos, m_nRowPos );
[ # # ]
95 : 0 : }
96 : : //// -----------------------------------------------------------------------------
97 : : // implementation of a table cell
98 : 0 : ::rtl::OUString AccessibleGridControlTableCell::implGetText()
99 : : {
100 : 0 : ensureIsAlive();
101 : 0 : return m_aTable.GetAccessibleCellText( getRowPos(), getColumnPos() );
102 : : }
103 : :
104 : 0 : ::com::sun::star::lang::Locale AccessibleGridControlTableCell::implGetLocale()
105 : : {
106 : 0 : ensureIsAlive();
107 [ # # ][ # # ]: 0 : return m_aTable.GetAccessible()->getAccessibleContext()->getLocale();
[ # # ][ # # ]
108 : : }
109 : :
110 : 0 : void AccessibleGridControlTableCell::implGetSelection( sal_Int32& nStartIndex, sal_Int32& nEndIndex )
111 : : {
112 : 0 : nStartIndex = 0;
113 : 0 : nEndIndex = 0;
114 : 0 : }
115 : :
116 : 0 : AccessibleGridControlTableCell::AccessibleGridControlTableCell(const Reference<XAccessible >& _rxParent,
117 : : IAccessibleTable& _rTable,
118 : : sal_Int32 _nRowPos,
119 : : sal_uInt16 _nColPos,
120 : : AccessibleTableControlObjType eObjType)
121 [ # # ]: 0 : :AccessibleGridControlCell( _rxParent, _rTable, _nRowPos, _nColPos, eObjType )
122 : : {
123 : 0 : }
124 : :
125 : : // XInterface -------------------------------------------------------------
126 : :
127 : : /** Queries for a new interface. */
128 : 0 : ::com::sun::star::uno::Any SAL_CALL AccessibleGridControlTableCell::queryInterface(
129 : : const ::com::sun::star::uno::Type& rType )
130 : : throw ( ::com::sun::star::uno::RuntimeException )
131 : : {
132 : 0 : Any aRet = AccessibleGridControlCell::queryInterface(rType);
133 [ # # ]: 0 : if ( !aRet.hasValue() )
134 [ # # ]: 0 : aRet = AccessibleTextHelper_BASE::queryInterface(rType);
135 : 0 : return aRet;
136 : : }
137 : :
138 : : /** Aquires the object (calls acquire() on base class). */
139 : 0 : void SAL_CALL AccessibleGridControlTableCell::acquire() throw ()
140 : : {
141 : 0 : AccessibleGridControlCell::acquire();
142 : 0 : }
143 : :
144 : : /** Releases the object (calls release() on base class). */
145 : 0 : void SAL_CALL AccessibleGridControlTableCell::release() throw ()
146 : : {
147 : 0 : AccessibleGridControlCell::release();
148 : 0 : }
149 : :
150 : 0 : ::com::sun::star::awt::Rectangle SAL_CALL AccessibleGridControlTableCell::getCharacterBounds( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
151 : : {
152 [ # # ]: 0 : SolarMutexGuard aSolarGuard;
153 [ # # ]: 0 : ::osl::MutexGuard aGuard( getOslMutex() );
154 : :
155 [ # # ]: 0 : ensureIsAlive();
156 [ # # ][ # # ]: 0 : if ( !implIsValidIndex( nIndex, implGetText().getLength() ) )
[ # # ]
157 [ # # ]: 0 : throw IndexOutOfBoundsException();
158 : :
159 : 0 : ::com::sun::star::awt::Rectangle aRect;
160 : :
161 [ # # ]: 0 : if ( &m_aTable )
162 [ # # ][ # # ]: 0 : aRect = AWTRectangle( m_aTable.GetFieldCharacterBounds( getRowPos(), getColumnPos(), nIndex ) );
163 [ # # ][ # # ]: 0 : return aRect;
164 : : }
165 : :
166 : 0 : sal_Int32 SAL_CALL AccessibleGridControlTableCell::getIndexAtPoint( const ::com::sun::star::awt::Point& _aPoint ) throw (RuntimeException)
167 : : {
168 [ # # ]: 0 : SolarMutexGuard aSolarGuard;
169 [ # # ]: 0 : ::osl::MutexGuard aGuard( getOslMutex() );
170 [ # # ]: 0 : ensureIsAlive();
171 : :
172 [ # # ][ # # ]: 0 : return m_aTable.GetFieldIndexAtPoint( getRowPos(), getColumnPos(), VCLPoint( _aPoint ) );
[ # # ]
173 : : }
174 : :
175 : : /** @return
176 : : The name of this class.
177 : : */
178 : 0 : ::rtl::OUString SAL_CALL AccessibleGridControlTableCell::getImplementationName()
179 : : throw ( ::com::sun::star::uno::RuntimeException )
180 : : {
181 : 0 : return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.accessibility.AccessibleGridControlTableCell" ) );
182 : : }
183 : :
184 : : /** @return The count of visible children. */
185 : 0 : sal_Int32 SAL_CALL AccessibleGridControlTableCell::getAccessibleChildCount()
186 : : throw ( ::com::sun::star::uno::RuntimeException )
187 : : {
188 : 0 : return 0;
189 : : }
190 : :
191 : : /** @return The XAccessible interface of the specified child. */
192 : : ::com::sun::star::uno::Reference<
193 : : ::com::sun::star::accessibility::XAccessible > SAL_CALL
194 : 0 : AccessibleGridControlTableCell::getAccessibleChild( sal_Int32 )
195 : : throw ( ::com::sun::star::lang::IndexOutOfBoundsException,
196 : : ::com::sun::star::uno::RuntimeException )
197 : : {
198 [ # # ]: 0 : throw ::com::sun::star::lang::IndexOutOfBoundsException();
199 : : }
200 : :
201 : : /** Creates a new AccessibleStateSetHelper and fills it with states of the
202 : : current object.
203 : : @return
204 : : A filled AccessibleStateSetHelper.
205 : : */
206 : 0 : ::utl::AccessibleStateSetHelper* AccessibleGridControlTableCell::implCreateStateSetHelper()
207 : : {
208 [ # # ]: 0 : SolarMutexGuard aSolarGuard;
209 [ # # ]: 0 : ::osl::MutexGuard aGuard( getOslMutex() );
210 : :
211 [ # # ]: 0 : ::utl::AccessibleStateSetHelper* pStateSetHelper = new ::utl::AccessibleStateSetHelper;
212 : :
213 [ # # ][ # # ]: 0 : if( isAlive() )
214 : : {
215 : : // SHOWING done with mxParent
216 [ # # ][ # # ]: 0 : if( implIsShowing() )
217 [ # # ]: 0 : pStateSetHelper->AddState( AccessibleStateType::SHOWING );
218 : :
219 [ # # ]: 0 : m_aTable.FillAccessibleStateSetForCell( *pStateSetHelper, getRowPos(), static_cast< sal_uInt16 >( getColumnPos() ) );
220 : : }
221 : : else
222 [ # # ]: 0 : pStateSetHelper->AddState( AccessibleStateType::DEFUNC );
223 : :
224 [ # # ][ # # ]: 0 : return pStateSetHelper;
225 : : }
226 : :
227 : :
228 : : // XAccessible ------------------------------------------------------------
229 : :
230 : : /** @return The XAccessibleContext interface of this object. */
231 : 0 : Reference< XAccessibleContext > SAL_CALL AccessibleGridControlTableCell::getAccessibleContext() throw ( RuntimeException )
232 : : {
233 : 0 : ensureIsAlive();
234 : 0 : return this;
235 : : }
236 : :
237 : : // XAccessibleContext -----------------------------------------------------
238 : :
239 : 0 : sal_Int32 SAL_CALL AccessibleGridControlTableCell::getAccessibleIndexInParent()
240 : : throw ( ::com::sun::star::uno::RuntimeException )
241 : : {
242 [ # # ]: 0 : SolarMutexGuard aSolarGuard;
243 [ # # ]: 0 : ::osl::MutexGuard aGuard( getOslMutex() );
244 [ # # ]: 0 : ensureIsAlive();
245 : :
246 [ # # ][ # # ]: 0 : return ( getRowPos() * m_aTable.GetColumnCount() ) + getColumnPos();
[ # # ]
247 : : }
248 : :
249 : 0 : sal_Int32 SAL_CALL AccessibleGridControlTableCell::getCaretPosition( ) throw (::com::sun::star::uno::RuntimeException)
250 : : {
251 : 0 : return -1;
252 : : }
253 : 0 : sal_Bool SAL_CALL AccessibleGridControlTableCell::setCaretPosition ( sal_Int32 nIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException)
254 : : {
255 [ # # ]: 0 : SolarMutexGuard aSolarGuard;
256 [ # # ]: 0 : ::osl::MutexGuard aGuard( getOslMutex() );
257 : :
258 [ # # ][ # # ]: 0 : if ( !implIsValidRange( nIndex, nIndex, implGetText().getLength() ) )
[ # # ]
259 [ # # ]: 0 : throw IndexOutOfBoundsException();
260 : :
261 [ # # ][ # # ]: 0 : return sal_False;
262 : : }
263 : 0 : sal_Unicode SAL_CALL AccessibleGridControlTableCell::getCharacter( sal_Int32 nIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException)
264 : : {
265 [ # # ]: 0 : SolarMutexGuard aSolarGuard;
266 [ # # ]: 0 : ::osl::MutexGuard aGuard( getOslMutex() );
267 [ # # ][ # # ]: 0 : return OCommonAccessibleText::getCharacter( nIndex );
[ # # ]
268 : : }
269 : 0 : ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > SAL_CALL AccessibleGridControlTableCell::getCharacterAttributes( sal_Int32 nIndex, const ::com::sun::star::uno::Sequence< ::rtl::OUString >& ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException)
270 : : {
271 [ # # ]: 0 : SolarMutexGuard aSolarGuard;
272 [ # # ]: 0 : ::osl::MutexGuard aGuard( getOslMutex() );
273 : :
274 [ # # ]: 0 : ::rtl::OUString sText( implGetText() );
275 : :
276 [ # # ][ # # ]: 0 : if ( !implIsValidIndex( nIndex, sText.getLength() ) )
277 [ # # ]: 0 : throw IndexOutOfBoundsException();
278 : :
279 [ # # ][ # # ]: 0 : return ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >();
[ # # ]
280 : : }
281 : 0 : sal_Int32 SAL_CALL AccessibleGridControlTableCell::getCharacterCount( ) throw (::com::sun::star::uno::RuntimeException)
282 : : {
283 [ # # ]: 0 : SolarMutexGuard aSolarGuard;
284 [ # # ]: 0 : ::osl::MutexGuard aGuard( getOslMutex() );
285 [ # # ][ # # ]: 0 : return OCommonAccessibleText::getCharacterCount( );
[ # # ]
286 : : }
287 : :
288 : 0 : ::rtl::OUString SAL_CALL AccessibleGridControlTableCell::getSelectedText( ) throw (::com::sun::star::uno::RuntimeException)
289 : : {
290 [ # # ]: 0 : SolarMutexGuard aSolarGuard;
291 [ # # ]: 0 : ::osl::MutexGuard aGuard( getOslMutex() );
292 [ # # ][ # # ]: 0 : return OCommonAccessibleText::getSelectedText( );
[ # # ]
293 : : }
294 : 0 : sal_Int32 SAL_CALL AccessibleGridControlTableCell::getSelectionStart( ) throw (::com::sun::star::uno::RuntimeException)
295 : : {
296 [ # # ]: 0 : SolarMutexGuard aSolarGuard;
297 [ # # ]: 0 : ::osl::MutexGuard aGuard( getOslMutex() );
298 [ # # ][ # # ]: 0 : return OCommonAccessibleText::getSelectionStart( );
[ # # ]
299 : : }
300 : 0 : sal_Int32 SAL_CALL AccessibleGridControlTableCell::getSelectionEnd( ) throw (::com::sun::star::uno::RuntimeException)
301 : : {
302 [ # # ]: 0 : SolarMutexGuard aSolarGuard;
303 [ # # ]: 0 : ::osl::MutexGuard aGuard( getOslMutex() );
304 [ # # ][ # # ]: 0 : return OCommonAccessibleText::getSelectionEnd( );
[ # # ]
305 : : }
306 : 0 : sal_Bool SAL_CALL AccessibleGridControlTableCell::setSelection( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException)
307 : : {
308 [ # # ]: 0 : SolarMutexGuard aSolarGuard;
309 [ # # ]: 0 : ::osl::MutexGuard aGuard( getOslMutex() );
310 [ # # ][ # # ]: 0 : if ( !implIsValidRange( nStartIndex, nEndIndex, implGetText().getLength() ) )
[ # # ]
311 [ # # ]: 0 : throw IndexOutOfBoundsException();
312 : :
313 [ # # ][ # # ]: 0 : return sal_False;
314 : : }
315 : 0 : ::rtl::OUString SAL_CALL AccessibleGridControlTableCell::getText( ) throw (::com::sun::star::uno::RuntimeException)
316 : : {
317 [ # # ]: 0 : SolarMutexGuard aSolarGuard;
318 [ # # ]: 0 : ::osl::MutexGuard aGuard( getOslMutex() );
319 [ # # ][ # # ]: 0 : return OCommonAccessibleText::getText( );
[ # # ]
320 : : }
321 : 0 : ::rtl::OUString SAL_CALL AccessibleGridControlTableCell::getTextRange( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException)
322 : : {
323 [ # # ]: 0 : SolarMutexGuard aSolarGuard;
324 [ # # ]: 0 : ::osl::MutexGuard aGuard( getOslMutex() );
325 [ # # ][ # # ]: 0 : return OCommonAccessibleText::getTextRange( nStartIndex, nEndIndex );
[ # # ]
326 : : }
327 : 0 : ::com::sun::star::accessibility::TextSegment SAL_CALL AccessibleGridControlTableCell::getTextAtIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
328 : : {
329 [ # # ]: 0 : SolarMutexGuard aSolarGuard;
330 [ # # ]: 0 : ::osl::MutexGuard aGuard( getOslMutex() );
331 [ # # ][ # # ]: 0 : return OCommonAccessibleText::getTextAtIndex( nIndex ,aTextType);
[ # # ]
332 : : }
333 : 0 : ::com::sun::star::accessibility::TextSegment SAL_CALL AccessibleGridControlTableCell::getTextBeforeIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
334 : : {
335 [ # # ]: 0 : SolarMutexGuard aSolarGuard;
336 [ # # ]: 0 : ::osl::MutexGuard aGuard( getOslMutex() );
337 [ # # ][ # # ]: 0 : return OCommonAccessibleText::getTextBeforeIndex( nIndex ,aTextType);
[ # # ]
338 : : }
339 : 0 : ::com::sun::star::accessibility::TextSegment SAL_CALL AccessibleGridControlTableCell::getTextBehindIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
340 : : {
341 [ # # ]: 0 : SolarMutexGuard aSolarGuard;
342 [ # # ]: 0 : ::osl::MutexGuard aGuard( getOslMutex() );
343 [ # # ][ # # ]: 0 : return OCommonAccessibleText::getTextBehindIndex( nIndex ,aTextType);
[ # # ]
344 : : }
345 : 0 : sal_Bool SAL_CALL AccessibleGridControlTableCell::copyText( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException)
346 : : {
347 [ # # ]: 0 : SolarMutexGuard aSolarGuard;
348 [ # # ]: 0 : ::osl::MutexGuard aGuard( getOslMutex() );
349 [ # # ]: 0 : ::rtl::OUString sText = implGetText();
350 [ # # ]: 0 : checkIndex_Impl( nStartIndex, sText );
351 [ # # ]: 0 : checkIndex_Impl( nEndIndex, sText );
352 : :
353 : : //!!! don't know how to put a string into the clipboard
354 [ # # ][ # # ]: 0 : return sal_False;
355 : : }
356 : :
357 : 0 : Rectangle AccessibleGridControlTableCell::implGetBoundingBox()
358 : : {
359 [ # # ]: 0 : return Rectangle(Point(0,0),Point(0,0));//To Do - return headercell rectangle
360 : : }
361 : : // -----------------------------------------------------------------------------
362 : 0 : Rectangle AccessibleGridControlTableCell::implGetBoundingBoxOnScreen()
363 : : {
364 [ # # ]: 0 : return Rectangle(Point(0,0),Point(0,0));//To Do - return headercell rectangle
365 : : }
366 : : }
367 : :
368 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|