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 : : #include <accessibility/extended/accessibletabbarpage.hxx>
30 : : #include <svtools/tabbar.hxx>
31 : : #include <com/sun/star/accessibility/AccessibleEventId.hpp>
32 : : #include <com/sun/star/accessibility/AccessibleRole.hpp>
33 : : #include <com/sun/star/accessibility/AccessibleStateType.hpp>
34 : : #include <unotools/accessiblestatesethelper.hxx>
35 : : #include <unotools/accessiblerelationsethelper.hxx>
36 : : #include <vcl/svapp.hxx>
37 : : #include <toolkit/helper/convert.hxx>
38 : :
39 : :
40 : : //.........................................................................
41 : : namespace accessibility
42 : : {
43 : : //.........................................................................
44 : :
45 : : using namespace ::com::sun::star::accessibility;
46 : : using namespace ::com::sun::star::uno;
47 : : using namespace ::com::sun::star::lang;
48 : : using namespace ::com::sun::star;
49 : : using namespace ::comphelper;
50 : :
51 : : // -----------------------------------------------------------------------------
52 : : // class AccessibleTabBarPage
53 : : // -----------------------------------------------------------------------------
54 : :
55 : 0 : AccessibleTabBarPage::AccessibleTabBarPage( TabBar* pTabBar, sal_uInt16 nPageId, const Reference< XAccessible >& rxParent )
56 : : :AccessibleTabBarBase( pTabBar )
57 : : ,m_nPageId( nPageId )
58 : 0 : ,m_xParent( rxParent )
59 : : {
60 [ # # ]: 0 : m_bEnabled = IsEnabled();
61 [ # # ]: 0 : m_bShowing = IsShowing();
62 : 0 : m_bSelected = IsSelected();
63 : :
64 [ # # ]: 0 : if ( m_pTabBar )
65 [ # # ][ # # ]: 0 : m_sPageText = m_pTabBar->GetPageText( m_nPageId );
[ # # ]
66 : 0 : }
67 : :
68 : : // -----------------------------------------------------------------------------
69 : :
70 : 0 : AccessibleTabBarPage::~AccessibleTabBarPage()
71 : : {
72 [ # # ]: 0 : }
73 : :
74 : : // -----------------------------------------------------------------------------
75 : :
76 : 0 : sal_Bool AccessibleTabBarPage::IsEnabled()
77 : : {
78 [ # # ]: 0 : OExternalLockGuard aGuard( this );
79 : :
80 : 0 : sal_Bool bEnabled = sal_False;
81 [ # # ]: 0 : if ( m_pTabBar )
82 [ # # ]: 0 : bEnabled = m_pTabBar->IsPageEnabled( m_nPageId );
83 : :
84 [ # # ]: 0 : return bEnabled;
85 : : }
86 : :
87 : : // -----------------------------------------------------------------------------
88 : :
89 : 0 : sal_Bool AccessibleTabBarPage::IsShowing()
90 : : {
91 : 0 : sal_Bool bShowing = sal_False;
92 : :
93 [ # # ][ # # ]: 0 : if ( m_pTabBar && m_pTabBar->IsVisible() )
[ # # ]
94 : 0 : bShowing = sal_True;
95 : :
96 : 0 : return bShowing;
97 : : }
98 : :
99 : : // -----------------------------------------------------------------------------
100 : :
101 : 0 : sal_Bool AccessibleTabBarPage::IsSelected()
102 : : {
103 : 0 : sal_Bool bSelected = sal_False;
104 : :
105 [ # # ][ # # ]: 0 : if ( m_pTabBar && m_pTabBar->GetCurPageId() == m_nPageId )
[ # # ]
106 : 0 : bSelected = sal_True;
107 : :
108 : 0 : return bSelected;
109 : : }
110 : :
111 : : // -----------------------------------------------------------------------------
112 : :
113 : 0 : void AccessibleTabBarPage::SetEnabled( sal_Bool bEnabled )
114 : : {
115 [ # # ]: 0 : if ( m_bEnabled != bEnabled )
116 : : {
117 [ # # ][ # # ]: 0 : Any aOldValue[2], aNewValue[2];
118 [ # # ]: 0 : if ( m_bEnabled )
119 : : {
120 [ # # ]: 0 : aOldValue[0] <<= AccessibleStateType::SENSITIVE;
121 [ # # ]: 0 : aOldValue[1] <<= AccessibleStateType::ENABLED;
122 : : }
123 : : else
124 : : {
125 : :
126 [ # # ]: 0 : aNewValue[0] <<= AccessibleStateType::ENABLED;
127 [ # # ]: 0 : aNewValue[1] <<= AccessibleStateType::SENSITIVE;
128 : : }
129 : 0 : m_bEnabled = bEnabled;
130 [ # # ]: 0 : NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue[0], aNewValue[0] );
131 [ # # ][ # # ]: 0 : NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue[1], aNewValue[1] );
[ # # ]
[ # # # # ]
132 : : }
133 : 0 : }
134 : :
135 : : // -----------------------------------------------------------------------------
136 : :
137 : 0 : void AccessibleTabBarPage::SetShowing( sal_Bool bShowing )
138 : : {
139 [ # # ]: 0 : if ( m_bShowing != bShowing )
140 : : {
141 : 0 : Any aOldValue, aNewValue;
142 [ # # ]: 0 : if ( m_bShowing )
143 [ # # ]: 0 : aOldValue <<= AccessibleStateType::SHOWING;
144 : : else
145 [ # # ]: 0 : aNewValue <<= AccessibleStateType::SHOWING;
146 : 0 : m_bShowing = bShowing;
147 [ # # ]: 0 : NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
148 : : }
149 : 0 : }
150 : :
151 : : // -----------------------------------------------------------------------------
152 : :
153 : 0 : void AccessibleTabBarPage::SetSelected( sal_Bool bSelected )
154 : : {
155 [ # # ]: 0 : if ( m_bSelected != bSelected )
156 : : {
157 : 0 : Any aOldValue, aNewValue;
158 [ # # ]: 0 : if ( m_bSelected )
159 [ # # ]: 0 : aOldValue <<= AccessibleStateType::SELECTED;
160 : : else
161 [ # # ]: 0 : aNewValue <<= AccessibleStateType::SELECTED;
162 : 0 : m_bSelected = bSelected;
163 [ # # ]: 0 : NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
164 : : }
165 : 0 : }
166 : :
167 : : // -----------------------------------------------------------------------------
168 : :
169 : 0 : void AccessibleTabBarPage::SetPageText( const ::rtl::OUString& sPageText )
170 : : {
171 [ # # ]: 0 : if ( !m_sPageText.equals( sPageText ) )
172 : : {
173 : 0 : Any aOldValue, aNewValue;
174 [ # # ]: 0 : aOldValue <<= m_sPageText;
175 [ # # ]: 0 : aNewValue <<= sPageText;
176 : 0 : m_sPageText = sPageText;
177 [ # # ]: 0 : NotifyAccessibleEvent( AccessibleEventId::NAME_CHANGED, aOldValue, aNewValue );
178 : : }
179 : 0 : }
180 : :
181 : : // -----------------------------------------------------------------------------
182 : :
183 : 0 : void AccessibleTabBarPage::FillAccessibleStateSet( utl::AccessibleStateSetHelper& rStateSet )
184 : : {
185 [ # # ]: 0 : if ( IsEnabled() )
186 : : {
187 : 0 : rStateSet.AddState( AccessibleStateType::ENABLED );
188 : 0 : rStateSet.AddState( AccessibleStateType::SENSITIVE );
189 : : }
190 : :
191 : 0 : rStateSet.AddState( AccessibleStateType::VISIBLE );
192 : :
193 [ # # ]: 0 : if ( IsShowing() )
194 : 0 : rStateSet.AddState( AccessibleStateType::SHOWING );
195 : :
196 : 0 : rStateSet.AddState( AccessibleStateType::SELECTABLE );
197 : :
198 [ # # ]: 0 : if ( IsSelected() )
199 : 0 : rStateSet.AddState( AccessibleStateType::SELECTED );
200 : 0 : }
201 : :
202 : : // -----------------------------------------------------------------------------
203 : : // OCommonAccessibleComponent
204 : : // -----------------------------------------------------------------------------
205 : :
206 : 0 : awt::Rectangle AccessibleTabBarPage::implGetBounds() throw (RuntimeException)
207 : : {
208 : 0 : awt::Rectangle aBounds;
209 [ # # ]: 0 : if ( m_pTabBar )
210 : : {
211 : : // get bounding rectangle relative to the AccessibleTabBar
212 [ # # ][ # # ]: 0 : aBounds = AWTRectangle( m_pTabBar->GetPageRect( m_nPageId ) );
213 : :
214 : : // get position of the AccessibleTabBarPageList relative to the AccessibleTabBar
215 [ # # ]: 0 : Reference< XAccessible > xParent = getAccessibleParent();
216 [ # # ]: 0 : if ( xParent.is() )
217 : : {
218 [ # # ][ # # ]: 0 : Reference< XAccessibleComponent > xParentComponent( xParent->getAccessibleContext(), UNO_QUERY );
[ # # ]
219 [ # # ]: 0 : if ( xParentComponent.is() )
220 : : {
221 [ # # ][ # # ]: 0 : awt::Point aParentLoc = xParentComponent->getLocation();
222 : :
223 : : // calculate bounding rectangle relative to the AccessibleTabBarPageList
224 : 0 : aBounds.X -= aParentLoc.X;
225 : 0 : aBounds.Y -= aParentLoc.Y;
226 : 0 : }
227 : 0 : }
228 : : }
229 : :
230 : 0 : return aBounds;
231 : : }
232 : :
233 : : // -----------------------------------------------------------------------------
234 : : // XInterface
235 : : // -----------------------------------------------------------------------------
236 : :
237 [ # # ][ # # ]: 0 : IMPLEMENT_FORWARD_XINTERFACE2( AccessibleTabBarPage, AccessibleExtendedComponentHelper_BASE, AccessibleTabBarPage_BASE )
238 : :
239 : : // -----------------------------------------------------------------------------
240 : : // XTypeProvider
241 : : // -----------------------------------------------------------------------------
242 : :
243 [ # # ][ # # ]: 0 : IMPLEMENT_FORWARD_XTYPEPROVIDER2( AccessibleTabBarPage, AccessibleExtendedComponentHelper_BASE, AccessibleTabBarPage_BASE )
[ # # ]
244 : :
245 : : // -----------------------------------------------------------------------------
246 : : // XComponent
247 : : // -----------------------------------------------------------------------------
248 : :
249 : 0 : void AccessibleTabBarPage::disposing()
250 : : {
251 : 0 : AccessibleTabBarBase::disposing();
252 : 0 : m_sPageText = ::rtl::OUString();
253 : 0 : }
254 : :
255 : : // -----------------------------------------------------------------------------
256 : : // XServiceInfo
257 : : // -----------------------------------------------------------------------------
258 : :
259 : 0 : ::rtl::OUString AccessibleTabBarPage::getImplementationName() throw (RuntimeException)
260 : : {
261 : 0 : return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.svtools.AccessibleTabBarPage" ));
262 : : }
263 : :
264 : : // -----------------------------------------------------------------------------
265 : :
266 : 0 : sal_Bool AccessibleTabBarPage::supportsService( const ::rtl::OUString& rServiceName ) throw (RuntimeException)
267 : : {
268 [ # # ]: 0 : Sequence< ::rtl::OUString > aNames( getSupportedServiceNames() );
269 : 0 : const ::rtl::OUString* pNames = aNames.getConstArray();
270 : 0 : const ::rtl::OUString* pEnd = pNames + aNames.getLength();
271 [ # # ][ # # ]: 0 : for ( ; pNames != pEnd && !pNames->equals( rServiceName ); ++pNames )
[ # # ]
272 : : ;
273 : :
274 [ # # ]: 0 : return pNames != pEnd;
275 : : }
276 : :
277 : : // -----------------------------------------------------------------------------
278 : :
279 : 0 : Sequence< ::rtl::OUString > AccessibleTabBarPage::getSupportedServiceNames() throw (RuntimeException)
280 : : {
281 : 0 : Sequence< ::rtl::OUString > aNames(1);
282 [ # # ][ # # ]: 0 : aNames[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.AccessibleTabBarPage" ));
283 : 0 : return aNames;
284 : : }
285 : :
286 : : // -----------------------------------------------------------------------------
287 : : // XAccessible
288 : : // -----------------------------------------------------------------------------
289 : :
290 : 0 : Reference< XAccessibleContext > AccessibleTabBarPage::getAccessibleContext( ) throw (RuntimeException)
291 : : {
292 [ # # ]: 0 : OExternalLockGuard aGuard( this );
293 : :
294 [ # # ][ # # ]: 0 : return this;
295 : : }
296 : :
297 : : // -----------------------------------------------------------------------------
298 : : // XAccessibleContext
299 : : // -----------------------------------------------------------------------------
300 : :
301 : 0 : sal_Int32 AccessibleTabBarPage::getAccessibleChildCount() throw (RuntimeException)
302 : : {
303 [ # # ]: 0 : OExternalLockGuard aGuard( this );
304 : :
305 [ # # ]: 0 : return 0;
306 : : }
307 : :
308 : : // -----------------------------------------------------------------------------
309 : :
310 : 0 : Reference< XAccessible > AccessibleTabBarPage::getAccessibleChild( sal_Int32 i ) throw (IndexOutOfBoundsException, RuntimeException)
311 : : {
312 [ # # ]: 0 : OExternalLockGuard aGuard( this );
313 : :
314 [ # # ][ # # ]: 0 : if ( i < 0 || i >= getAccessibleChildCount() )
[ # # ][ # # ]
315 [ # # ]: 0 : throw IndexOutOfBoundsException();
316 : :
317 [ # # ]: 0 : return Reference< XAccessible >();
318 : : }
319 : :
320 : : // -----------------------------------------------------------------------------
321 : :
322 : 0 : Reference< XAccessible > AccessibleTabBarPage::getAccessibleParent( ) throw (RuntimeException)
323 : : {
324 [ # # ]: 0 : OExternalLockGuard aGuard( this );
325 : :
326 [ # # ]: 0 : return m_xParent;
327 : : }
328 : :
329 : : // -----------------------------------------------------------------------------
330 : :
331 : 0 : sal_Int32 AccessibleTabBarPage::getAccessibleIndexInParent( ) throw (RuntimeException)
332 : : {
333 [ # # ]: 0 : OExternalLockGuard aGuard( this );
334 : :
335 : 0 : sal_Int32 nIndexInParent = -1;
336 [ # # ]: 0 : if ( m_pTabBar )
337 [ # # ]: 0 : nIndexInParent = m_pTabBar->GetPagePos( m_nPageId );
338 : :
339 [ # # ]: 0 : return nIndexInParent;
340 : : }
341 : :
342 : : // -----------------------------------------------------------------------------
343 : :
344 : 0 : sal_Int16 AccessibleTabBarPage::getAccessibleRole( ) throw (RuntimeException)
345 : : {
346 [ # # ]: 0 : OExternalLockGuard aGuard( this );
347 : :
348 [ # # ]: 0 : return AccessibleRole::PAGE_TAB;
349 : : }
350 : :
351 : : // -----------------------------------------------------------------------------
352 : :
353 : 0 : ::rtl::OUString AccessibleTabBarPage::getAccessibleDescription( ) throw (RuntimeException)
354 : : {
355 [ # # ]: 0 : OExternalLockGuard aGuard( this );
356 : :
357 : 0 : ::rtl::OUString sDescription;
358 [ # # ]: 0 : if ( m_pTabBar )
359 [ # # ][ # # ]: 0 : sDescription = m_pTabBar->GetHelpText( m_nPageId );
[ # # ]
360 : :
361 [ # # ]: 0 : return sDescription;
362 : : }
363 : :
364 : : // -----------------------------------------------------------------------------
365 : :
366 : 0 : ::rtl::OUString AccessibleTabBarPage::getAccessibleName( ) throw (RuntimeException)
367 : : {
368 [ # # ]: 0 : OExternalLockGuard aGuard( this );
369 : :
370 [ # # ]: 0 : return m_sPageText;
371 : : }
372 : :
373 : : // -----------------------------------------------------------------------------
374 : :
375 : 0 : Reference< XAccessibleRelationSet > AccessibleTabBarPage::getAccessibleRelationSet( ) throw (RuntimeException)
376 : : {
377 [ # # ]: 0 : OExternalLockGuard aGuard( this );
378 : :
379 [ # # ]: 0 : utl::AccessibleRelationSetHelper* pRelationSetHelper = new utl::AccessibleRelationSetHelper;
380 [ # # ][ # # ]: 0 : Reference< XAccessibleRelationSet > xSet = pRelationSetHelper;
381 [ # # ]: 0 : return xSet;
382 : : }
383 : :
384 : : // -----------------------------------------------------------------------------
385 : :
386 : 0 : Reference< XAccessibleStateSet > AccessibleTabBarPage::getAccessibleStateSet( ) throw (RuntimeException)
387 : : {
388 [ # # ]: 0 : OExternalLockGuard aGuard( this );
389 : :
390 [ # # ]: 0 : utl::AccessibleStateSetHelper* pStateSetHelper = new utl::AccessibleStateSetHelper;
391 [ # # ][ # # ]: 0 : Reference< XAccessibleStateSet > xSet = pStateSetHelper;
392 : :
393 [ # # ][ # # ]: 0 : if ( !rBHelper.bDisposed && !rBHelper.bInDispose )
394 : : {
395 [ # # ]: 0 : FillAccessibleStateSet( *pStateSetHelper );
396 : : }
397 : : else
398 : : {
399 [ # # ]: 0 : pStateSetHelper->AddState( AccessibleStateType::DEFUNC );
400 : : }
401 : :
402 [ # # ]: 0 : return xSet;
403 : : }
404 : :
405 : : // -----------------------------------------------------------------------------
406 : :
407 : 0 : Locale AccessibleTabBarPage::getLocale( ) throw (IllegalAccessibleComponentStateException, RuntimeException)
408 : : {
409 [ # # ]: 0 : OExternalLockGuard aGuard( this );
410 : :
411 [ # # ][ # # ]: 0 : return Application::GetSettings().GetLocale();
[ # # ]
412 : : }
413 : :
414 : : // -----------------------------------------------------------------------------
415 : : // XAccessibleComponent
416 : : // -----------------------------------------------------------------------------
417 : :
418 : 0 : Reference< XAccessible > AccessibleTabBarPage::getAccessibleAtPoint( const awt::Point& ) throw (RuntimeException)
419 : : {
420 [ # # ]: 0 : OExternalLockGuard aGuard( this );
421 : :
422 [ # # ]: 0 : return Reference< XAccessible >();
423 : : }
424 : :
425 : : // -----------------------------------------------------------------------------
426 : :
427 : 0 : void AccessibleTabBarPage::grabFocus( ) throw (RuntimeException)
428 : : {
429 : : // no focus
430 : 0 : }
431 : :
432 : : // -----------------------------------------------------------------------------
433 : :
434 : 0 : sal_Int32 AccessibleTabBarPage::getForeground( ) throw (RuntimeException)
435 : : {
436 [ # # ]: 0 : OExternalLockGuard aGuard( this );
437 : :
438 : 0 : sal_Int32 nColor = 0;
439 [ # # ]: 0 : Reference< XAccessible > xParent = getAccessibleParent();
440 [ # # ]: 0 : if ( xParent.is() )
441 : : {
442 [ # # ][ # # ]: 0 : Reference< XAccessibleComponent > xParentComp( xParent->getAccessibleContext(), UNO_QUERY );
[ # # ]
443 [ # # ]: 0 : if ( xParentComp.is() )
444 [ # # ][ # # ]: 0 : nColor = xParentComp->getForeground();
445 : : }
446 : :
447 [ # # ]: 0 : return nColor;
448 : : }
449 : :
450 : : // -----------------------------------------------------------------------------
451 : :
452 : 0 : sal_Int32 AccessibleTabBarPage::getBackground( ) throw (RuntimeException)
453 : : {
454 [ # # ]: 0 : OExternalLockGuard aGuard( this );
455 : :
456 : 0 : sal_Int32 nColor = 0;
457 [ # # ]: 0 : Reference< XAccessible > xParent = getAccessibleParent();
458 [ # # ]: 0 : if ( xParent.is() )
459 : : {
460 [ # # ][ # # ]: 0 : Reference< XAccessibleComponent > xParentComp( xParent->getAccessibleContext(), UNO_QUERY );
[ # # ]
461 [ # # ]: 0 : if ( xParentComp.is() )
462 [ # # ][ # # ]: 0 : nColor = xParentComp->getBackground();
463 : : }
464 : :
465 [ # # ]: 0 : return nColor;
466 : : }
467 : :
468 : : // -----------------------------------------------------------------------------
469 : : // XAccessibleExtendedComponent
470 : : // -----------------------------------------------------------------------------
471 : :
472 : 0 : Reference< awt::XFont > AccessibleTabBarPage::getFont( ) throw (RuntimeException)
473 : : {
474 [ # # ]: 0 : OExternalLockGuard aGuard( this );
475 : :
476 : 0 : Reference< awt::XFont > xFont;
477 [ # # ]: 0 : Reference< XAccessible > xParent = getAccessibleParent();
478 [ # # ]: 0 : if ( xParent.is() )
479 : : {
480 [ # # ][ # # ]: 0 : Reference< XAccessibleExtendedComponent > xParentComp( xParent->getAccessibleContext(), UNO_QUERY );
[ # # ]
481 [ # # ]: 0 : if ( xParentComp.is() )
482 [ # # ][ # # ]: 0 : xFont = xParentComp->getFont();
[ # # ]
483 : : }
484 : :
485 [ # # ]: 0 : return xFont;
486 : : }
487 : :
488 : : // -----------------------------------------------------------------------------
489 : :
490 : 0 : ::rtl::OUString AccessibleTabBarPage::getTitledBorderText( ) throw (RuntimeException)
491 : : {
492 [ # # ]: 0 : OExternalLockGuard aGuard( this );
493 : :
494 [ # # ]: 0 : return m_sPageText;
495 : : }
496 : :
497 : : // -----------------------------------------------------------------------------
498 : :
499 : 0 : ::rtl::OUString AccessibleTabBarPage::getToolTipText( ) throw (RuntimeException)
500 : : {
501 [ # # ]: 0 : OExternalLockGuard aGuard( this );
502 : :
503 [ # # ]: 0 : return ::rtl::OUString();
504 : : }
505 : :
506 : : // -----------------------------------------------------------------------------
507 : :
508 : : //.........................................................................
509 : : } // namespace accessibility
510 : : //.........................................................................
511 : :
512 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|