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 #include <accessibility/extended/accessibletabbarpagelist.hxx>
27 #include <svtools/tabbar.hxx>
28 #include <accessibility/extended/accessibletabbarpage.hxx>
29 #include <com/sun/star/accessibility/AccessibleEventId.hpp>
30 #include <com/sun/star/accessibility/AccessibleRole.hpp>
31 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
32 #include <unotools/accessiblestatesethelper.hxx>
33 #include <unotools/accessiblerelationsethelper.hxx>
34 #include <tools/debug.hxx>
35 #include <vcl/svapp.hxx>
36 #include <toolkit/helper/convert.hxx>
37 
38 
39 //.........................................................................
40 namespace accessibility
41 {
42 //.........................................................................
43 
44 	using namespace ::com::sun::star::accessibility;
45 	using namespace ::com::sun::star::uno;
46 	using namespace ::com::sun::star::lang;
47 	using namespace ::com::sun::star;
48 	using namespace ::comphelper;
49 
DBG_NAME(AccessibleTabBarPageList)50 	DBG_NAME( AccessibleTabBarPageList )
51 
52 	// -----------------------------------------------------------------------------
53 	// class AccessibleTabBarPageList
54 	// -----------------------------------------------------------------------------
55 
56 	AccessibleTabBarPageList::AccessibleTabBarPageList( TabBar* pTabBar, sal_Int32 nIndexInParent )
57         :AccessibleTabBarBase( pTabBar )
58 		,m_nIndexInParent( nIndexInParent )
59 	{
60 	    DBG_CTOR( AccessibleTabBarPageList, NULL );
61 		if ( m_pTabBar )
62 			m_aAccessibleChildren.assign( m_pTabBar->GetPageCount(), Reference< XAccessible >() );
63 	}
64 
65 	// -----------------------------------------------------------------------------
66 
~AccessibleTabBarPageList()67 	AccessibleTabBarPageList::~AccessibleTabBarPageList()
68 	{
69 	    DBG_DTOR( AccessibleTabBarPageList, NULL );
70 	}
71 
72 	// -----------------------------------------------------------------------------
73 
UpdateEnabled(sal_Int32 i,sal_Bool bEnabled)74 	void AccessibleTabBarPageList::UpdateEnabled( sal_Int32 i, sal_Bool bEnabled )
75 	{
76 		if ( i >= 0 && i < (sal_Int32)m_aAccessibleChildren.size() )
77 		{
78 			Reference< XAccessible > xChild( m_aAccessibleChildren[i] );
79 			if ( xChild.is() )
80 			{
81 				AccessibleTabBarPage* pAccessibleTabBarPage = static_cast< AccessibleTabBarPage* >( xChild.get() );
82 				if ( pAccessibleTabBarPage )
83 					pAccessibleTabBarPage->SetEnabled( bEnabled );
84 			}
85 		}
86 	}
87 
88 	// -----------------------------------------------------------------------------
89 
UpdateShowing(sal_Bool bShowing)90 	void AccessibleTabBarPageList::UpdateShowing( sal_Bool bShowing )
91 	{
92 		for ( sal_uInt32 i = 0; i < m_aAccessibleChildren.size(); ++i )
93 		{
94 			Reference< XAccessible > xChild( m_aAccessibleChildren[i] );
95 			if ( xChild.is() )
96 			{
97 				AccessibleTabBarPage* pAccessibleTabBarPage = static_cast< AccessibleTabBarPage* >( xChild.get() );
98 				if ( pAccessibleTabBarPage )
99 					pAccessibleTabBarPage->SetShowing( bShowing );
100 			}
101 		}
102 	}
103 
104 	// -----------------------------------------------------------------------------
105 
UpdateSelected(sal_Int32 i,sal_Bool bSelected)106 	void AccessibleTabBarPageList::UpdateSelected( sal_Int32 i, sal_Bool bSelected )
107 	{
108 		NotifyAccessibleEvent( AccessibleEventId::SELECTION_CHANGED, Any(), Any() );
109 
110 		if ( i >= 0 && i < (sal_Int32)m_aAccessibleChildren.size() )
111 		{
112 			Reference< XAccessible > xChild( m_aAccessibleChildren[i] );
113 			if ( xChild.is() )
114 			{
115 				AccessibleTabBarPage* pAccessibleTabBarPage = static_cast< AccessibleTabBarPage* >( xChild.get() );
116 				if ( pAccessibleTabBarPage )
117 					pAccessibleTabBarPage->SetSelected( bSelected );
118 			}
119 		}
120 	}
121 
122 	// -----------------------------------------------------------------------------
123 
UpdatePageText(sal_Int32 i)124 	void AccessibleTabBarPageList::UpdatePageText( sal_Int32 i )
125 	{
126 		if ( i >= 0 && i < (sal_Int32)m_aAccessibleChildren.size() )
127 		{
128 			Reference< XAccessible > xChild( m_aAccessibleChildren[i] );
129 			if ( xChild.is() )
130 			{
131 				AccessibleTabBarPage* pAccessibleTabBarPage = static_cast< AccessibleTabBarPage* >( xChild.get() );
132 				if ( pAccessibleTabBarPage )
133 				{
134 					if ( m_pTabBar )
135 					{
136 						::rtl::OUString sPageText = m_pTabBar->GetPageText( m_pTabBar->GetPageId( (sal_uInt16)i ) );
137 						pAccessibleTabBarPage->SetPageText( sPageText );
138 					}
139 				}
140 			}
141 		}
142 	}
143 
144 	// -----------------------------------------------------------------------------
145 
InsertChild(sal_Int32 i)146 	void AccessibleTabBarPageList::InsertChild( sal_Int32 i )
147 	{
148 		if ( i >= 0 && i <= (sal_Int32)m_aAccessibleChildren.size() )
149 		{
150 			// insert entry in child list
151 			m_aAccessibleChildren.insert( m_aAccessibleChildren.begin() + i, Reference< XAccessible >() );
152 
153 			// send accessible child event
154 			Reference< XAccessible > xChild( getAccessibleChild( i ) );
155 			if ( xChild.is() )
156 			{
157 				Any aOldValue, aNewValue;
158 				aNewValue <<= xChild;
159 				NotifyAccessibleEvent( AccessibleEventId::CHILD, aOldValue, aNewValue );
160 			}
161 		}
162 	}
163 
164 	// -----------------------------------------------------------------------------
165 
RemoveChild(sal_Int32 i)166 	void AccessibleTabBarPageList::RemoveChild( sal_Int32 i )
167 	{
168 		if ( i >= 0 && i < (sal_Int32)m_aAccessibleChildren.size() )
169 		{
170 			// get the accessible of the removed page
171 			Reference< XAccessible > xChild( m_aAccessibleChildren[i] );
172 
173 			// remove entry in child list
174 			m_aAccessibleChildren.erase( m_aAccessibleChildren.begin() + i );
175 
176 			// send accessible child event
177 			if ( xChild.is() )
178 			{
179 				Any aOldValue, aNewValue;
180 				aOldValue <<= xChild;
181 				NotifyAccessibleEvent( AccessibleEventId::CHILD, aOldValue, aNewValue );
182 
183 				Reference< XComponent > xComponent( xChild, UNO_QUERY );
184 				if ( xComponent.is() )
185 					xComponent->dispose();
186 			}
187 		}
188 	}
189 
190 	// -----------------------------------------------------------------------------
191 
MoveChild(sal_Int32 i,sal_Int32 j)192 	void AccessibleTabBarPageList::MoveChild( sal_Int32 i, sal_Int32 j )
193 	{
194 		if ( i >= 0 && i < (sal_Int32)m_aAccessibleChildren.size() &&
195 			 j >= 0 && j <= (sal_Int32)m_aAccessibleChildren.size() )
196 		{
197 			if ( i < j )
198 				--j;
199 
200 			// get the accessible of the moved page
201 			Reference< XAccessible > xChild( m_aAccessibleChildren[i] );
202 
203 			// remove entry in child list at old position
204 			m_aAccessibleChildren.erase( m_aAccessibleChildren.begin() + i );
205 
206 			// insert entry in child list at new position
207 			m_aAccessibleChildren.insert( m_aAccessibleChildren.begin() + j, xChild );
208 		}
209 	}
210 
211 	// -----------------------------------------------------------------------------
212 
ProcessWindowEvent(const VclWindowEvent & rVclWindowEvent)213 	void AccessibleTabBarPageList::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
214 	{
215          switch ( rVclWindowEvent.GetId() )
216          {
217             case VCLEVENT_WINDOW_ENABLED:
218             {
219                Any aNewValue;
220                 aNewValue <<= AccessibleStateType::SENSITIVE;
221                 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, Any(), aNewValue );
222                 aNewValue <<= AccessibleStateType::ENABLED;
223                 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, Any(), aNewValue );
224             }
225             break;
226             case VCLEVENT_WINDOW_DISABLED:
227             {
228                Any aOldValue;
229                 aOldValue <<= AccessibleStateType::ENABLED;
230                 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, Any() );
231                 aOldValue <<= AccessibleStateType::SENSITIVE;
232                 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, Any() );
233             }
234             break;
235 			case VCLEVENT_WINDOW_SHOW:
236 			{
237 				Any aOldValue, aNewValue;
238 				aNewValue <<= AccessibleStateType::SHOWING;
239 				NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
240 				UpdateShowing( sal_True );
241 			}
242 			break;
243 			case VCLEVENT_WINDOW_HIDE:
244 			{
245 				Any aOldValue, aNewValue;
246 				aOldValue <<= AccessibleStateType::SHOWING;
247 				NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
248 				UpdateShowing( sal_False );
249 			}
250 			break;
251 			case VCLEVENT_TABBAR_PAGEENABLED:
252 			{
253 				if ( m_pTabBar )
254 				{
255                     sal_uInt16 nPageId = (sal_uInt16)(sal_IntPtr) rVclWindowEvent.GetData();
256 					sal_uInt16 nPagePos = m_pTabBar->GetPagePos( nPageId );
257 					UpdateEnabled( nPagePos, sal_True );
258 				}
259 			}
260 			break;
261 			case VCLEVENT_TABBAR_PAGEDISABLED:
262 			{
263 				if ( m_pTabBar )
264 				{
265                     sal_uInt16 nPageId = (sal_uInt16)(sal_IntPtr) rVclWindowEvent.GetData();
266 					sal_uInt16 nPagePos = m_pTabBar->GetPagePos( nPageId );
267 					UpdateEnabled( nPagePos, sal_False );
268 				}
269 			}
270 			break;
271 			case VCLEVENT_TABBAR_PAGESELECTED:
272 			{
273 				// do nothing
274 			}
275 			break;
276 			case VCLEVENT_TABBAR_PAGEACTIVATED:
277 			{
278 				if ( m_pTabBar )
279 				{
280                     sal_uInt16 nPageId = (sal_uInt16)(sal_IntPtr) rVclWindowEvent.GetData();
281 					sal_uInt16 nPagePos = m_pTabBar->GetPagePos( nPageId );
282 					UpdateSelected( nPagePos, sal_True );
283 				}
284 			}
285 			break;
286 			case VCLEVENT_TABBAR_PAGEDEACTIVATED:
287 			{
288 				if ( m_pTabBar )
289 				{
290                     sal_uInt16 nPageId = (sal_uInt16)(sal_IntPtr) rVclWindowEvent.GetData();
291 					sal_uInt16 nPagePos = m_pTabBar->GetPagePos( nPageId );
292 					UpdateSelected( nPagePos, sal_False );
293 				}
294 			}
295 			break;
296 			case VCLEVENT_TABBAR_PAGEINSERTED:
297 			{
298 				if ( m_pTabBar )
299 				{
300                     sal_uInt16 nPageId = (sal_uInt16)(sal_IntPtr) rVclWindowEvent.GetData();
301 					sal_uInt16 nPagePos = m_pTabBar->GetPagePos( nPageId );
302 					InsertChild( nPagePos );
303 				}
304 			}
305 			break;
306 			case VCLEVENT_TABBAR_PAGEREMOVED:
307 			{
308 				if ( m_pTabBar )
309 				{
310                     sal_uInt16 nPageId = (sal_uInt16)(sal_IntPtr) rVclWindowEvent.GetData();
311 
312                     if ( nPageId == TabBar::PAGE_NOT_FOUND )
313 					{
314 						for ( sal_Int32 i = m_aAccessibleChildren.size() - 1; i >= 0; --i )
315 							RemoveChild( i );
316 					}
317 					else
318 					{
319 						for ( sal_Int32 i = 0, nCount = getAccessibleChildCount(); i < nCount; ++i )
320 						{
321 							Reference< XAccessible > xChild( getAccessibleChild( i ) );
322 							if ( xChild.is() )
323 							{
324 								AccessibleTabBarPage* pAccessibleTabBarPage = static_cast< AccessibleTabBarPage* >( xChild.get() );
325 								if ( pAccessibleTabBarPage && pAccessibleTabBarPage->GetPageId() == nPageId )
326 								{
327 									RemoveChild( i );
328 									break;
329 								}
330 							}
331 						}
332 					}
333 				}
334 			}
335 			break;
336 			case VCLEVENT_TABBAR_PAGEMOVED:
337 			{
338 			    Pair* pPair = (Pair*) rVclWindowEvent.GetData();
339 				if ( pPair )
340 					MoveChild( pPair->A(), pPair->B() );
341 			}
342 			break;
343 			case VCLEVENT_TABBAR_PAGETEXTCHANGED:
344 			{
345                 sal_uInt16 nPageId = (sal_uInt16)(sal_IntPtr) rVclWindowEvent.GetData();
346 				sal_uInt16 nPagePos = m_pTabBar->GetPagePos( nPageId );
347 				UpdatePageText( nPagePos );
348 			}
349 			break;
350 			default:
351 			{
352                 AccessibleTabBarBase::ProcessWindowEvent( rVclWindowEvent );
353 			}
354 			break;
355 		}
356 	}
357 
358 	// -----------------------------------------------------------------------------
359 
FillAccessibleStateSet(utl::AccessibleStateSetHelper & rStateSet)360 	void AccessibleTabBarPageList::FillAccessibleStateSet( utl::AccessibleStateSetHelper& rStateSet )
361 	{
362 		if ( m_pTabBar )
363 		{
364 			if ( m_pTabBar->IsEnabled() )
365             {
366                 rStateSet.AddState( AccessibleStateType::ENABLED );
367                 rStateSet.AddState( AccessibleStateType::SENSITIVE );
368             }
369 
370 			rStateSet.AddState( AccessibleStateType::VISIBLE );
371 
372 			if ( m_pTabBar->IsVisible() )
373 				rStateSet.AddState( AccessibleStateType::SHOWING );
374 		}
375 	}
376 
377 	// -----------------------------------------------------------------------------
378 	// OCommonAccessibleComponent
379 	// -----------------------------------------------------------------------------
380 
implGetBounds()381 	awt::Rectangle AccessibleTabBarPageList::implGetBounds() throw (RuntimeException)
382 	{
383 		awt::Rectangle aBounds;
384 		if ( m_pTabBar )
385 			aBounds = AWTRectangle( m_pTabBar->GetPageArea() );
386 
387 		return aBounds;
388 	}
389 
390 	// -----------------------------------------------------------------------------
391 	// XInterface
392 	// -----------------------------------------------------------------------------
393 
IMPLEMENT_FORWARD_XINTERFACE2(AccessibleTabBarPageList,AccessibleExtendedComponentHelper_BASE,AccessibleTabBarPageList_BASE)394 	IMPLEMENT_FORWARD_XINTERFACE2( AccessibleTabBarPageList, AccessibleExtendedComponentHelper_BASE, AccessibleTabBarPageList_BASE )
395 
396 	// -----------------------------------------------------------------------------
397 	// XTypeProvider
398 	// -----------------------------------------------------------------------------
399 
400 	IMPLEMENT_FORWARD_XTYPEPROVIDER2( AccessibleTabBarPageList, AccessibleExtendedComponentHelper_BASE, AccessibleTabBarPageList_BASE )
401 
402 	// -----------------------------------------------------------------------------
403 	// XComponent
404 	// -----------------------------------------------------------------------------
405 
406 	void AccessibleTabBarPageList::disposing()
407 	{
408         AccessibleTabBarBase::disposing();
409 
410         // dispose all children
411         for ( sal_uInt32 i = 0; i < m_aAccessibleChildren.size(); ++i )
412         {
413             Reference< XComponent > xComponent( m_aAccessibleChildren[i], UNO_QUERY );
414             if ( xComponent.is() )
415                 xComponent->dispose();
416         }
417         m_aAccessibleChildren.clear();
418 	}
419 
420 	// -----------------------------------------------------------------------------
421 	// XServiceInfo
422 	// -----------------------------------------------------------------------------
423 
getImplementationName()424 	::rtl::OUString AccessibleTabBarPageList::getImplementationName() throw (RuntimeException)
425 	{
426 		return ::rtl::OUString::createFromAscii( "com.sun.star.comp.svtools.AccessibleTabBarPageList" );
427 	}
428 
429 	// -----------------------------------------------------------------------------
430 
supportsService(const::rtl::OUString & rServiceName)431 	sal_Bool AccessibleTabBarPageList::supportsService( const ::rtl::OUString& rServiceName ) throw (RuntimeException)
432 	{
433 		Sequence< ::rtl::OUString > aNames( getSupportedServiceNames() );
434 		const ::rtl::OUString* pNames = aNames.getConstArray();
435 		const ::rtl::OUString* pEnd = pNames + aNames.getLength();
436 		for ( ; pNames != pEnd && !pNames->equals( rServiceName ); ++pNames )
437 			;
438 
439 		return pNames != pEnd;
440 	}
441 
442 	// -----------------------------------------------------------------------------
443 
getSupportedServiceNames()444 	Sequence< ::rtl::OUString > AccessibleTabBarPageList::getSupportedServiceNames() throw (RuntimeException)
445 	{
446 		Sequence< ::rtl::OUString > aNames(1);
447 		aNames[0] = ::rtl::OUString::createFromAscii( "com.sun.star.awt.AccessibleTabBarPageList" );
448 		return aNames;
449 	}
450 
451 	// -----------------------------------------------------------------------------
452 	// XAccessible
453 	// -----------------------------------------------------------------------------
454 
getAccessibleContext()455 	Reference< XAccessibleContext > AccessibleTabBarPageList::getAccessibleContext(  ) throw (RuntimeException)
456 	{
457 		OExternalLockGuard aGuard( this );
458 
459 		return this;
460 	}
461 
462 	// -----------------------------------------------------------------------------
463 	// XAccessibleContext
464 	// -----------------------------------------------------------------------------
465 
getAccessibleChildCount()466 	sal_Int32 AccessibleTabBarPageList::getAccessibleChildCount() throw (RuntimeException)
467 	{
468 		OExternalLockGuard aGuard( this );
469 
470 		return m_aAccessibleChildren.size();
471 	}
472 
473 	// -----------------------------------------------------------------------------
474 
getAccessibleChild(sal_Int32 i)475 	Reference< XAccessible > AccessibleTabBarPageList::getAccessibleChild( sal_Int32 i ) throw (IndexOutOfBoundsException, RuntimeException)
476 	{
477 		OExternalLockGuard aGuard( this );
478 
479 		if ( i < 0 || i >= getAccessibleChildCount() )
480 			throw IndexOutOfBoundsException();
481 
482 		Reference< XAccessible > xChild = m_aAccessibleChildren[i];
483 		if ( !xChild.is() )
484 		{
485 			if ( m_pTabBar )
486 			{
487 				sal_uInt16 nPageId = m_pTabBar->GetPageId( (sal_uInt16)i );
488 
489 				xChild = new AccessibleTabBarPage( m_pTabBar, nPageId, this );
490 
491 				// insert into child list
492 				m_aAccessibleChildren[i] = xChild;
493 			}
494 		}
495 
496 		return xChild;
497 	}
498 
499 	// -----------------------------------------------------------------------------
500 
getAccessibleParent()501 	Reference< XAccessible > AccessibleTabBarPageList::getAccessibleParent(  ) throw (RuntimeException)
502 	{
503 		OExternalLockGuard aGuard( this );
504 
505 		Reference< XAccessible > xParent;
506 		if ( m_pTabBar )
507 			xParent = m_pTabBar->GetAccessible();
508 
509 		return xParent;
510 	}
511 
512 	// -----------------------------------------------------------------------------
513 
getAccessibleIndexInParent()514 	sal_Int32 AccessibleTabBarPageList::getAccessibleIndexInParent(  ) throw (RuntimeException)
515 	{
516 		OExternalLockGuard aGuard( this );
517 
518 		return m_nIndexInParent;
519 	}
520 
521 	// -----------------------------------------------------------------------------
522 
getAccessibleRole()523 	sal_Int16 AccessibleTabBarPageList::getAccessibleRole(  ) throw (RuntimeException)
524 	{
525 		OExternalLockGuard aGuard( this );
526 
527 		return AccessibleRole::PAGE_TAB_LIST;
528 	}
529 
530 	// -----------------------------------------------------------------------------
531 
getAccessibleDescription()532 	::rtl::OUString AccessibleTabBarPageList::getAccessibleDescription(	) throw (RuntimeException)
533 	{
534 		OExternalLockGuard aGuard( this );
535 
536 		return ::rtl::OUString();
537 	}
538 
539 	// -----------------------------------------------------------------------------
540 
getAccessibleName()541 	::rtl::OUString AccessibleTabBarPageList::getAccessibleName(  ) throw (RuntimeException)
542 	{
543 		OExternalLockGuard aGuard( this );
544 
545 		return ::rtl::OUString();
546 	}
547 
548 	// -----------------------------------------------------------------------------
549 
getAccessibleRelationSet()550 	Reference< XAccessibleRelationSet > AccessibleTabBarPageList::getAccessibleRelationSet(  ) throw (RuntimeException)
551 	{
552 		OExternalLockGuard aGuard( this );
553 
554 		utl::AccessibleRelationSetHelper* pRelationSetHelper = new utl::AccessibleRelationSetHelper;
555 		Reference< XAccessibleRelationSet > xSet = pRelationSetHelper;
556 		return xSet;
557 	}
558 
559 	// -----------------------------------------------------------------------------
560 
getAccessibleStateSet()561 	Reference< XAccessibleStateSet > AccessibleTabBarPageList::getAccessibleStateSet(  ) throw (RuntimeException)
562 	{
563 		OExternalLockGuard aGuard( this );
564 
565 		utl::AccessibleStateSetHelper* pStateSetHelper = new utl::AccessibleStateSetHelper;
566 		Reference< XAccessibleStateSet > xSet = pStateSetHelper;
567 
568 		if ( !rBHelper.bDisposed && !rBHelper.bInDispose )
569 		{
570 			FillAccessibleStateSet( *pStateSetHelper );
571 		}
572 		else
573 		{
574 			pStateSetHelper->AddState( AccessibleStateType::DEFUNC );
575 		}
576 
577 		return xSet;
578 	}
579 
580 	// -----------------------------------------------------------------------------
581 
getLocale()582 	Locale AccessibleTabBarPageList::getLocale(  ) throw (IllegalAccessibleComponentStateException, RuntimeException)
583 	{
584 		OExternalLockGuard aGuard( this );
585 
586 		return Application::GetSettings().GetLocale();
587 	}
588 
589 	// -----------------------------------------------------------------------------
590 	// XAccessibleComponent
591 	// -----------------------------------------------------------------------------
592 
getAccessibleAtPoint(const awt::Point & rPoint)593 	Reference< XAccessible > AccessibleTabBarPageList::getAccessibleAtPoint( const awt::Point& rPoint ) throw (RuntimeException)
594 	{
595 		OExternalLockGuard aGuard( this );
596 
597 		Reference< XAccessible > xChild;
598 		for ( sal_uInt32 i = 0; i < m_aAccessibleChildren.size(); ++i )
599 		{
600 			Reference< XAccessible > xAcc = getAccessibleChild( i );
601 			if ( xAcc.is() )
602 			{
603 				Reference< XAccessibleComponent > xComp( xAcc->getAccessibleContext(), UNO_QUERY );
604 				if ( xComp.is() )
605 				{
606 					Rectangle aRect = VCLRectangle( xComp->getBounds() );
607 					Point aPos = VCLPoint( rPoint );
608 					if ( aRect.IsInside( aPos ) )
609 					{
610 						xChild = xAcc;
611 						break;
612 					}
613 				}
614 			}
615 		}
616 
617 		return xChild;
618 	}
619 
620 	// -----------------------------------------------------------------------------
621 
grabFocus()622 	void AccessibleTabBarPageList::grabFocus(  ) throw (RuntimeException)
623 	{
624 		// no focus
625 	}
626 
627 	// -----------------------------------------------------------------------------
628 
getForeground()629 	sal_Int32 AccessibleTabBarPageList::getForeground(	) throw (RuntimeException)
630 	{
631 		OExternalLockGuard aGuard( this );
632 
633 		sal_Int32 nColor = 0;
634 		Reference< XAccessible > xParent = getAccessibleParent();
635 		if ( xParent.is() )
636 		{
637 			Reference< XAccessibleComponent > xParentComp( xParent->getAccessibleContext(), UNO_QUERY );
638 			if ( xParentComp.is() )
639 				nColor = xParentComp->getForeground();
640 		}
641 
642 		return nColor;
643 	}
644 
645 	// -----------------------------------------------------------------------------
646 
getBackground()647 	sal_Int32 AccessibleTabBarPageList::getBackground(  ) throw (RuntimeException)
648 	{
649 		OExternalLockGuard aGuard( this );
650 
651 		sal_Int32 nColor = 0;
652 		Reference< XAccessible > xParent = getAccessibleParent();
653 		if ( xParent.is() )
654 		{
655 			Reference< XAccessibleComponent > xParentComp( xParent->getAccessibleContext(), UNO_QUERY );
656 			if ( xParentComp.is() )
657 				nColor = xParentComp->getBackground();
658 		}
659 
660 		return nColor;
661 	}
662 
663 	// -----------------------------------------------------------------------------
664 	// XAccessibleExtendedComponent
665 	// -----------------------------------------------------------------------------
666 
getFont()667 	Reference< awt::XFont > AccessibleTabBarPageList::getFont(  ) throw (RuntimeException)
668 	{
669 		OExternalLockGuard aGuard( this );
670 
671 		Reference< awt::XFont > xFont;
672 		Reference< XAccessible > xParent = getAccessibleParent();
673 		if ( xParent.is() )
674 		{
675 			Reference< XAccessibleExtendedComponent > xParentComp( xParent->getAccessibleContext(), UNO_QUERY );
676 			if ( xParentComp.is() )
677 				xFont = xParentComp->getFont();
678 		}
679 
680 		return xFont;
681 	}
682 
683 	// -----------------------------------------------------------------------------
684 
getTitledBorderText()685 	::rtl::OUString AccessibleTabBarPageList::getTitledBorderText(  ) throw (RuntimeException)
686 	{
687 		OExternalLockGuard aGuard( this );
688 
689 		return ::rtl::OUString();
690 	}
691 
692 	// -----------------------------------------------------------------------------
693 
getToolTipText()694 	::rtl::OUString AccessibleTabBarPageList::getToolTipText(  ) throw (RuntimeException)
695 	{
696 		OExternalLockGuard aGuard( this );
697 
698 		return ::rtl::OUString();
699 	}
700 
701 	// -----------------------------------------------------------------------------
702 	// XAccessibleSelection
703 	// -----------------------------------------------------------------------------
704 
selectAccessibleChild(sal_Int32 nChildIndex)705 	void AccessibleTabBarPageList::selectAccessibleChild( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException)
706 	{
707 		OExternalLockGuard aGuard( this );
708 
709 		if ( nChildIndex < 0 || nChildIndex >= getAccessibleChildCount() )
710 			throw IndexOutOfBoundsException();
711 
712 		if ( m_pTabBar )
713 		{
714 			m_pTabBar->SetCurPageId( m_pTabBar->GetPageId( (sal_uInt16)nChildIndex ) );
715 			m_pTabBar->Update();
716 			m_pTabBar->ActivatePage();
717 			m_pTabBar->Select();
718 		}
719 	}
720 
721 	// -----------------------------------------------------------------------------
722 
isAccessibleChildSelected(sal_Int32 nChildIndex)723 	sal_Bool AccessibleTabBarPageList::isAccessibleChildSelected( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException)
724 	{
725 		OExternalLockGuard aGuard( this );
726 
727 		if ( nChildIndex < 0 || nChildIndex >= getAccessibleChildCount() )
728 			throw IndexOutOfBoundsException();
729 
730 		sal_Bool bSelected = sal_False;
731 		if ( m_pTabBar && m_pTabBar->GetCurPageId() == m_pTabBar->GetPageId( (sal_uInt16)nChildIndex ) )
732 			bSelected = sal_True;
733 
734 		return bSelected;
735 	}
736 
737 	// -----------------------------------------------------------------------------
738 
clearAccessibleSelection()739 	void AccessibleTabBarPageList::clearAccessibleSelection(  ) throw (RuntimeException)
740 	{
741 		// This method makes no sense in a TabBar, and so does nothing.
742 	}
743 
744 	// -----------------------------------------------------------------------------
745 
selectAllAccessibleChildren()746 	void AccessibleTabBarPageList::selectAllAccessibleChildren(  ) throw (RuntimeException)
747 	{
748 		OExternalLockGuard aGuard( this );
749 
750 		selectAccessibleChild( 0 );
751 	}
752 
753 	// -----------------------------------------------------------------------------
754 
getSelectedAccessibleChildCount()755 	sal_Int32 AccessibleTabBarPageList::getSelectedAccessibleChildCount(  ) throw (RuntimeException)
756 	{
757 		OExternalLockGuard aGuard( this );
758 
759 		return 1;
760 	}
761 
762 	// -----------------------------------------------------------------------------
763 
getSelectedAccessibleChild(sal_Int32 nSelectedChildIndex)764 	Reference< XAccessible > AccessibleTabBarPageList::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex ) throw (IndexOutOfBoundsException, RuntimeException)
765 	{
766 		OExternalLockGuard aGuard( this );
767 
768 		if ( nSelectedChildIndex < 0 || nSelectedChildIndex >= getSelectedAccessibleChildCount() )
769 			throw IndexOutOfBoundsException();
770 
771 		Reference< XAccessible > xChild;
772 
773 		for ( sal_Int32 i = 0, j = 0, nCount = getAccessibleChildCount(); i < nCount; i++ )
774 		{
775 			if ( isAccessibleChildSelected( i ) && ( j++ == nSelectedChildIndex ) )
776 			{
777 				xChild = getAccessibleChild( i );
778 				break;
779 			}
780 		}
781 
782 		return xChild;
783 	}
784 
785 	// -----------------------------------------------------------------------------
786 
deselectAccessibleChild(sal_Int32 nChildIndex)787 	void AccessibleTabBarPageList::deselectAccessibleChild( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException)
788 	{
789 		OExternalLockGuard aGuard( this );
790 
791 		if ( nChildIndex < 0 || nChildIndex >= getAccessibleChildCount() )
792 			throw IndexOutOfBoundsException();
793 
794 		// This method makes no sense in a TabBar, and so does nothing.
795 	}
796 
797 	// -----------------------------------------------------------------------------
798 
799 //.........................................................................
800 }	// namespace accessibility
801 //.........................................................................
802