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/AccessibleBrowseBoxTableCell.hxx"
31 : : #include <svtools/accessibletableprovider.hxx>
32 : : #include "accessibility/extended/AccessibleBrowseBox.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 : 0 : static void checkIndex_Impl( sal_Int32 _nIndex, const ::rtl::OUString& _sText ) throw (::com::sun::star::lang::IndexOutOfBoundsException)
42 : : {
43 [ # # ]: 0 : if ( _nIndex >= _sText.getLength() )
44 [ # # ]: 0 : throw ::com::sun::star::lang::IndexOutOfBoundsException();
45 : 0 : }
46 : :
47 : 0 : static sal_Int32 getIndex_Impl( sal_Int32 _nRow, sal_uInt16 _nColumn, sal_uInt16 _nColumnCount )
48 : : {
49 : 0 : return _nRow * _nColumnCount + _nColumn;
50 : : }
51 : : }
52 : : using namespace ::com::sun::star::lang;
53 : : using namespace utl;
54 : : using namespace comphelper;
55 : : using ::rtl::OUString;
56 : : using ::accessibility::AccessibleBrowseBox;
57 : : using namespace ::com::sun::star::uno;
58 : : using ::com::sun::star::accessibility::XAccessible;
59 : : using namespace ::com::sun::star::accessibility;
60 : : using namespace ::svt;
61 : :
62 : :
63 : : // implementation of a table cell
64 : 0 : ::rtl::OUString AccessibleBrowseBoxTableCell::implGetText()
65 : : {
66 : 0 : ensureIsAlive();
67 [ # # ]: 0 : return mpBrowseBox->GetAccessibleCellText( getRowPos(), static_cast< sal_uInt16 >( getColumnPos() ) );
68 : : }
69 : :
70 : 0 : ::com::sun::star::lang::Locale AccessibleBrowseBoxTableCell::implGetLocale()
71 : : {
72 : 0 : ensureIsAlive();
73 [ # # ][ # # ]: 0 : return mpBrowseBox->GetAccessible()->getAccessibleContext()->getLocale();
[ # # ][ # # ]
74 : : }
75 : :
76 : 0 : void AccessibleBrowseBoxTableCell::implGetSelection( sal_Int32& nStartIndex, sal_Int32& nEndIndex )
77 : : {
78 : 0 : nStartIndex = 0;
79 : 0 : nEndIndex = 0;
80 : 0 : }
81 : :
82 : 0 : AccessibleBrowseBoxTableCell::AccessibleBrowseBoxTableCell(const Reference<XAccessible >& _rxParent,
83 : : IAccessibleTableProvider& _rBrowseBox,
84 : : const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow >& _xFocusWindow,
85 : : sal_Int32 _nRowPos,
86 : : sal_uInt16 _nColPos,
87 : : sal_Int32 _nOffset )
88 [ # # ]: 0 : :AccessibleBrowseBoxCell( _rxParent, _rBrowseBox, _xFocusWindow, _nRowPos, _nColPos )
89 : : {
90 [ # # ]: 0 : m_nOffset = ( OFFSET_DEFAULT == _nOffset ) ? (sal_Int32)BBINDEX_FIRSTCONTROL : _nOffset;
91 [ # # ]: 0 : sal_Int32 nIndex = getIndex_Impl( _nRowPos, _nColPos, _rBrowseBox.GetColumnCount() );
92 [ # # ][ # # ]: 0 : setAccessibleName( _rBrowseBox.GetAccessibleObjectName( BBTYPE_TABLECELL, nIndex ) );
93 [ # # ][ # # ]: 0 : setAccessibleDescription( _rBrowseBox.GetAccessibleObjectDescription( BBTYPE_TABLECELL, nIndex ) );
94 : : // Need to register as event listener
95 [ # # ]: 0 : Reference< XComponent > xComponent(_rxParent, UNO_QUERY);
96 [ # # ]: 0 : if( xComponent.is() )
97 [ # # ][ # # ]: 0 : xComponent->addEventListener(static_cast< XEventListener *> (this));
[ # # ]
98 : 0 : }
99 : :
100 : 0 : void AccessibleBrowseBoxTableCell::nameChanged( const ::rtl::OUString& rNewName, const ::rtl::OUString& rOldName )
101 : : {
102 : 0 : implSetName( rNewName );
103 : 0 : Any aOldValue, aNewValue;
104 [ # # ]: 0 : aOldValue <<= rOldName;
105 [ # # ]: 0 : aNewValue <<= rNewName;
106 [ # # ]: 0 : commitEvent( AccessibleEventId::NAME_CHANGED, aOldValue, aNewValue );
107 : 0 : }
108 : :
109 : : // XInterface -------------------------------------------------------------
110 : :
111 : : /** Queries for a new interface. */
112 : 0 : ::com::sun::star::uno::Any SAL_CALL AccessibleBrowseBoxTableCell::queryInterface(
113 : : const ::com::sun::star::uno::Type& rType )
114 : : throw ( ::com::sun::star::uno::RuntimeException )
115 : : {
116 : 0 : Any aRet = AccessibleBrowseBoxCell::queryInterface(rType);
117 [ # # ]: 0 : if ( !aRet.hasValue() )
118 [ # # ]: 0 : aRet = AccessibleTextHelper_BASE::queryInterface(rType);
119 : 0 : return aRet;
120 : : }
121 : :
122 : : /** Aquires the object (calls acquire() on base class). */
123 : 0 : void SAL_CALL AccessibleBrowseBoxTableCell::acquire() throw ()
124 : : {
125 : 0 : AccessibleBrowseBoxCell::acquire();
126 : 0 : }
127 : :
128 : : /** Releases the object (calls release() on base class). */
129 : 0 : void SAL_CALL AccessibleBrowseBoxTableCell::release() throw ()
130 : : {
131 : 0 : AccessibleBrowseBoxCell::release();
132 : 0 : }
133 : :
134 : 0 : ::com::sun::star::awt::Rectangle SAL_CALL AccessibleBrowseBoxTableCell::getCharacterBounds( sal_Int32 nIndex ) throw (IndexOutOfBoundsException, RuntimeException)
135 : : {
136 [ # # ]: 0 : SolarMutexGuard aSolarGuard;
137 [ # # ]: 0 : ::osl::MutexGuard aGuard( getOslMutex() );
138 : :
139 [ # # ]: 0 : ensureIsAlive();
140 [ # # ][ # # ]: 0 : if ( !implIsValidIndex( nIndex, implGetText().getLength() ) )
[ # # ]
141 [ # # ]: 0 : throw IndexOutOfBoundsException();
142 : :
143 : 0 : ::com::sun::star::awt::Rectangle aRect;
144 : :
145 [ # # ]: 0 : if ( mpBrowseBox )
146 : : {
147 [ # # ][ # # ]: 0 : aRect = AWTRectangle( mpBrowseBox->GetFieldCharacterBounds( getRowPos(), getColumnPos(), nIndex ) );
148 : : }
149 : :
150 [ # # ][ # # ]: 0 : return aRect;
151 : : }
152 : :
153 : 0 : sal_Int32 SAL_CALL AccessibleBrowseBoxTableCell::getIndexAtPoint( const ::com::sun::star::awt::Point& _aPoint ) throw (RuntimeException)
154 : : {
155 : : //! TODO CTL bidi
156 : : // OSL_FAIL("Need to be done by base class!");
157 [ # # ]: 0 : SolarMutexGuard aSolarGuard;
158 [ # # ]: 0 : ::osl::MutexGuard aGuard( getOslMutex() );
159 [ # # ]: 0 : ensureIsAlive();
160 : :
161 [ # # ][ # # ]: 0 : return mpBrowseBox->GetFieldIndexAtPoint( getRowPos(), getColumnPos(), VCLPoint( _aPoint ) );
[ # # ]
162 : : }
163 : :
164 : : /** @return
165 : : The name of this class.
166 : : */
167 : 0 : ::rtl::OUString SAL_CALL AccessibleBrowseBoxTableCell::getImplementationName()
168 : : throw ( ::com::sun::star::uno::RuntimeException )
169 : : {
170 : 0 : return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.svtools.AccessibleBrowseBoxTableCell" ) );
171 : : }
172 : :
173 : : /** @return The count of visible children. */
174 : 0 : sal_Int32 SAL_CALL AccessibleBrowseBoxTableCell::getAccessibleChildCount()
175 : : throw ( ::com::sun::star::uno::RuntimeException )
176 : : {
177 : 0 : return 0;
178 : : }
179 : :
180 : : /** @return The XAccessible interface of the specified child. */
181 : : ::com::sun::star::uno::Reference<
182 : : ::com::sun::star::accessibility::XAccessible > SAL_CALL
183 : 0 : AccessibleBrowseBoxTableCell::getAccessibleChild( sal_Int32 )
184 : : throw ( ::com::sun::star::lang::IndexOutOfBoundsException,
185 : : ::com::sun::star::uno::RuntimeException )
186 : : {
187 [ # # ]: 0 : throw ::com::sun::star::lang::IndexOutOfBoundsException();
188 : : }
189 : :
190 : : /** Creates a new AccessibleStateSetHelper and fills it with states of the
191 : : current object.
192 : : @return
193 : : A filled AccessibleStateSetHelper.
194 : : */
195 : 0 : ::utl::AccessibleStateSetHelper* AccessibleBrowseBoxTableCell::implCreateStateSetHelper()
196 : : {
197 [ # # ]: 0 : SolarMutexGuard aSolarGuard;
198 [ # # ]: 0 : ::osl::MutexGuard aGuard( getOslMutex() );
199 : :
200 [ # # ]: 0 : ::utl::AccessibleStateSetHelper* pStateSetHelper = new ::utl::AccessibleStateSetHelper;
201 : :
202 [ # # ][ # # ]: 0 : if( isAlive() )
203 : : {
204 : : // SHOWING done with mxParent
205 [ # # ][ # # ]: 0 : if( implIsShowing() )
206 [ # # ]: 0 : pStateSetHelper->AddState( AccessibleStateType::SHOWING );
207 : :
208 [ # # ]: 0 : mpBrowseBox->FillAccessibleStateSetForCell( *pStateSetHelper, getRowPos(), static_cast< sal_uInt16 >( getColumnPos() ) );
209 : : }
210 : : else
211 [ # # ]: 0 : pStateSetHelper->AddState( AccessibleStateType::DEFUNC );
212 : :
213 [ # # ][ # # ]: 0 : return pStateSetHelper;
214 : : }
215 : :
216 : :
217 : : // XAccessible ------------------------------------------------------------
218 : :
219 : : /** @return The XAccessibleContext interface of this object. */
220 : 0 : Reference< XAccessibleContext > SAL_CALL AccessibleBrowseBoxTableCell::getAccessibleContext() throw ( RuntimeException )
221 : : {
222 : 0 : ensureIsAlive();
223 : 0 : return this;
224 : : }
225 : :
226 : : // XAccessibleContext -----------------------------------------------------
227 : :
228 : 0 : sal_Int32 SAL_CALL AccessibleBrowseBoxTableCell::getAccessibleIndexInParent()
229 : : throw ( ::com::sun::star::uno::RuntimeException )
230 : : {
231 [ # # ]: 0 : SolarMutexGuard aSolarGuard;
232 [ # # ]: 0 : ::osl::MutexGuard aGuard( getOslMutex() );
233 [ # # ]: 0 : ensureIsAlive();
234 : :
235 [ # # ][ # # ]: 0 : return /*BBINDEX_FIRSTCONTROL*/ m_nOffset + ( getRowPos() * mpBrowseBox->GetColumnCount() ) + getColumnPos();
[ # # ]
236 : : }
237 : :
238 : 0 : sal_Int32 SAL_CALL AccessibleBrowseBoxTableCell::getCaretPosition( ) throw (::com::sun::star::uno::RuntimeException)
239 : : {
240 : 0 : return -1;
241 : : }
242 : 0 : sal_Bool SAL_CALL AccessibleBrowseBoxTableCell::setCaretPosition ( sal_Int32 nIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException)
243 : : {
244 [ # # ]: 0 : SolarMutexGuard aSolarGuard;
245 [ # # ]: 0 : ::osl::MutexGuard aGuard( getOslMutex() );
246 : :
247 [ # # ][ # # ]: 0 : if ( !implIsValidRange( nIndex, nIndex, implGetText().getLength() ) )
[ # # ]
248 [ # # ]: 0 : throw IndexOutOfBoundsException();
249 : :
250 [ # # ][ # # ]: 0 : return sal_False;
251 : : }
252 : 0 : sal_Unicode SAL_CALL AccessibleBrowseBoxTableCell::getCharacter( sal_Int32 nIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException)
253 : : {
254 [ # # ]: 0 : SolarMutexGuard aSolarGuard;
255 [ # # ]: 0 : ::osl::MutexGuard aGuard( getOslMutex() );
256 [ # # ][ # # ]: 0 : return OCommonAccessibleText::getCharacter( nIndex );
[ # # ]
257 : : }
258 : 0 : ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > SAL_CALL AccessibleBrowseBoxTableCell::getCharacterAttributes( sal_Int32 nIndex, const ::com::sun::star::uno::Sequence< ::rtl::OUString >& ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException)
259 : : {
260 [ # # ]: 0 : SolarMutexGuard aSolarGuard;
261 [ # # ]: 0 : ::osl::MutexGuard aGuard( getOslMutex() );
262 : :
263 [ # # ]: 0 : ::rtl::OUString sText( implGetText() );
264 : :
265 [ # # ][ # # ]: 0 : if ( !implIsValidIndex( nIndex, sText.getLength() ) )
266 [ # # ]: 0 : throw IndexOutOfBoundsException();
267 : :
268 [ # # ][ # # ]: 0 : return ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >();
[ # # ]
269 : : }
270 : 0 : sal_Int32 SAL_CALL AccessibleBrowseBoxTableCell::getCharacterCount( ) throw (::com::sun::star::uno::RuntimeException)
271 : : {
272 [ # # ]: 0 : SolarMutexGuard aSolarGuard;
273 [ # # ]: 0 : ::osl::MutexGuard aGuard( getOslMutex() );
274 [ # # ][ # # ]: 0 : return OCommonAccessibleText::getCharacterCount( );
[ # # ]
275 : : }
276 : :
277 : 0 : ::rtl::OUString SAL_CALL AccessibleBrowseBoxTableCell::getSelectedText( ) throw (::com::sun::star::uno::RuntimeException)
278 : : {
279 [ # # ]: 0 : SolarMutexGuard aSolarGuard;
280 [ # # ]: 0 : ::osl::MutexGuard aGuard( getOslMutex() );
281 [ # # ][ # # ]: 0 : return OCommonAccessibleText::getSelectedText( );
[ # # ]
282 : : }
283 : 0 : sal_Int32 SAL_CALL AccessibleBrowseBoxTableCell::getSelectionStart( ) throw (::com::sun::star::uno::RuntimeException)
284 : : {
285 [ # # ]: 0 : SolarMutexGuard aSolarGuard;
286 [ # # ]: 0 : ::osl::MutexGuard aGuard( getOslMutex() );
287 [ # # ][ # # ]: 0 : return OCommonAccessibleText::getSelectionStart( );
[ # # ]
288 : : }
289 : 0 : sal_Int32 SAL_CALL AccessibleBrowseBoxTableCell::getSelectionEnd( ) throw (::com::sun::star::uno::RuntimeException)
290 : : {
291 [ # # ]: 0 : SolarMutexGuard aSolarGuard;
292 [ # # ]: 0 : ::osl::MutexGuard aGuard( getOslMutex() );
293 [ # # ][ # # ]: 0 : return OCommonAccessibleText::getSelectionEnd( );
[ # # ]
294 : : }
295 : 0 : sal_Bool SAL_CALL AccessibleBrowseBoxTableCell::setSelection( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException)
296 : : {
297 [ # # ]: 0 : SolarMutexGuard aSolarGuard;
298 [ # # ]: 0 : ::osl::MutexGuard aGuard( getOslMutex() );
299 [ # # ][ # # ]: 0 : if ( !implIsValidRange( nStartIndex, nEndIndex, implGetText().getLength() ) )
[ # # ]
300 [ # # ]: 0 : throw IndexOutOfBoundsException();
301 : :
302 [ # # ][ # # ]: 0 : return sal_False;
303 : : }
304 : 0 : ::rtl::OUString SAL_CALL AccessibleBrowseBoxTableCell::getText( ) throw (::com::sun::star::uno::RuntimeException)
305 : : {
306 [ # # ]: 0 : SolarMutexGuard aSolarGuard;
307 [ # # ]: 0 : ::osl::MutexGuard aGuard( getOslMutex() );
308 [ # # ][ # # ]: 0 : return OCommonAccessibleText::getText( );
[ # # ]
309 : : }
310 : 0 : ::rtl::OUString SAL_CALL AccessibleBrowseBoxTableCell::getTextRange( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException)
311 : : {
312 [ # # ]: 0 : SolarMutexGuard aSolarGuard;
313 [ # # ]: 0 : ::osl::MutexGuard aGuard( getOslMutex() );
314 [ # # ][ # # ]: 0 : return OCommonAccessibleText::getTextRange( nStartIndex, nEndIndex );
[ # # ]
315 : : }
316 : 0 : ::com::sun::star::accessibility::TextSegment SAL_CALL AccessibleBrowseBoxTableCell::getTextAtIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
317 : : {
318 [ # # ]: 0 : SolarMutexGuard aSolarGuard;
319 [ # # ]: 0 : ::osl::MutexGuard aGuard( getOslMutex() );
320 [ # # ][ # # ]: 0 : return OCommonAccessibleText::getTextAtIndex( nIndex ,aTextType);
[ # # ]
321 : : }
322 : 0 : ::com::sun::star::accessibility::TextSegment SAL_CALL AccessibleBrowseBoxTableCell::getTextBeforeIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
323 : : {
324 [ # # ]: 0 : SolarMutexGuard aSolarGuard;
325 [ # # ]: 0 : ::osl::MutexGuard aGuard( getOslMutex() );
326 [ # # ][ # # ]: 0 : return OCommonAccessibleText::getTextBeforeIndex( nIndex ,aTextType);
[ # # ]
327 : : }
328 : 0 : ::com::sun::star::accessibility::TextSegment SAL_CALL AccessibleBrowseBoxTableCell::getTextBehindIndex( sal_Int32 nIndex, sal_Int16 aTextType ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
329 : : {
330 [ # # ]: 0 : SolarMutexGuard aSolarGuard;
331 [ # # ]: 0 : ::osl::MutexGuard aGuard( getOslMutex() );
332 [ # # ][ # # ]: 0 : return OCommonAccessibleText::getTextBehindIndex( nIndex ,aTextType);
[ # # ]
333 : : }
334 : 0 : sal_Bool SAL_CALL AccessibleBrowseBoxTableCell::copyText( sal_Int32 nStartIndex, sal_Int32 nEndIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException)
335 : : {
336 [ # # ]: 0 : SolarMutexGuard aSolarGuard;
337 [ # # ]: 0 : ::osl::MutexGuard aGuard( getOslMutex() );
338 [ # # ]: 0 : ::rtl::OUString sText = implGetText();
339 [ # # ]: 0 : checkIndex_Impl( nStartIndex, sText );
340 [ # # ]: 0 : checkIndex_Impl( nEndIndex, sText );
341 : :
342 : : //!!! don't know how to put a string into the clipboard
343 [ # # ][ # # ]: 0 : return sal_False;
344 : : }
345 : 0 : void AccessibleBrowseBoxTableCell::disposing( const EventObject& _rSource ) throw (RuntimeException)
346 : : {
347 [ # # ]: 0 : if ( _rSource.Source == mxParent )
348 : : {
349 : 0 : dispose();
350 : : }
351 : 0 : }
352 : :
353 : : }
354 : :
355 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|