Update ooo320-m1
[ooovba.git] / basctl / source / accessibility / accessibledialogwindow.cxx
blob58986634751b559f0d460ece149a5a9ed2cb602d
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: accessibledialogwindow.cxx,v $
10 * $Revision: 1.10 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_basctl.hxx"
33 #include <accessibledialogwindow.hxx>
34 #include <accessibledialogcontrolshape.hxx>
35 #include <baside3.hxx>
36 #include <dlged.hxx>
37 #include <dlgedmod.hxx>
38 #include <dlgedpage.hxx>
39 #include <dlgedview.hxx>
40 #include <dlgedobj.hxx>
41 #include <com/sun/star/accessibility/AccessibleEventId.hpp>
42 #include <com/sun/star/accessibility/AccessibleRole.hpp>
43 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
44 #include <unotools/accessiblestatesethelper.hxx>
45 #include <unotools/accessiblerelationsethelper.hxx>
46 #include <toolkit/awt/vclxfont.hxx>
47 #include <toolkit/helper/externallock.hxx>
48 #include <toolkit/helper/convert.hxx>
49 #include <vcl/svapp.hxx>
51 #include <vector>
52 #include <algorithm>
55 using namespace ::com::sun::star;
56 using namespace ::com::sun::star::uno;
57 using namespace ::com::sun::star::lang;
58 using namespace ::com::sun::star::accessibility;
59 using namespace ::comphelper;
61 DBG_NAME( AccessibleDialogWindow )
64 // -----------------------------------------------------------------------------
65 // class ChildDescriptor
66 // -----------------------------------------------------------------------------
68 AccessibleDialogWindow::ChildDescriptor::ChildDescriptor( DlgEdObj* _pDlgEdObj )
69 :pDlgEdObj( _pDlgEdObj )
70 ,rxAccessible( 0 )
74 // -----------------------------------------------------------------------------
76 AccessibleDialogWindow::ChildDescriptor::~ChildDescriptor()
80 // -----------------------------------------------------------------------------
82 AccessibleDialogWindow::ChildDescriptor::ChildDescriptor( const ChildDescriptor& rDesc )
83 :pDlgEdObj( rDesc.pDlgEdObj )
84 ,rxAccessible( rDesc.rxAccessible )
88 // -----------------------------------------------------------------------------
90 AccessibleDialogWindow::ChildDescriptor& AccessibleDialogWindow::ChildDescriptor::operator=( const ChildDescriptor& rDesc )
92 pDlgEdObj = rDesc.pDlgEdObj;
93 rxAccessible = rDesc.rxAccessible;
95 return *this;
98 // -----------------------------------------------------------------------------
100 bool AccessibleDialogWindow::ChildDescriptor::operator==( const ChildDescriptor& rDesc )
102 bool bRet = false;
103 if ( pDlgEdObj == rDesc.pDlgEdObj )
104 bRet = true;
106 return bRet;
109 // -----------------------------------------------------------------------------
111 bool AccessibleDialogWindow::ChildDescriptor::operator<( const ChildDescriptor& rDesc ) const
113 bool bRet = false;
114 if ( pDlgEdObj && rDesc.pDlgEdObj && pDlgEdObj->GetOrdNum() < rDesc.pDlgEdObj->GetOrdNum() )
115 bRet = true;
117 return bRet;
120 // -----------------------------------------------------------------------------
121 // class AccessibleDialogWindow
122 // -----------------------------------------------------------------------------
124 AccessibleDialogWindow::AccessibleDialogWindow( DialogWindow* pDialogWindow )
125 :AccessibleExtendedComponentHelper_BASE( new VCLExternalSolarLock() )
126 ,m_pDialogWindow( pDialogWindow )
128 DBG_CTOR( AccessibleDialogWindow, NULL );
129 m_pExternalLock = static_cast< VCLExternalSolarLock* >( getExternalLock() );
131 if ( m_pDialogWindow )
133 SdrPage* pSdrPage = m_pDialogWindow->GetPage();
134 if ( pSdrPage )
136 ULONG nCount = pSdrPage->GetObjCount();
138 for ( ULONG i = 0; i < nCount; ++i )
140 SdrObject* pObj = pSdrPage->GetObj( i );
141 DlgEdObj* pDlgEdObj = PTR_CAST( DlgEdObj, pObj );
142 if ( pDlgEdObj )
144 ChildDescriptor aDesc( pDlgEdObj );
145 if ( IsChildVisible( aDesc ) )
146 m_aAccessibleChildren.push_back( aDesc );
151 m_pDialogWindow->AddEventListener( LINK( this, AccessibleDialogWindow, WindowEventListener ) );
153 m_pDlgEditor = m_pDialogWindow->GetEditor();
154 if ( m_pDlgEditor )
155 StartListening( *m_pDlgEditor );
157 m_pDlgEdModel = m_pDialogWindow->GetModel();
158 if ( m_pDlgEdModel )
159 StartListening( *m_pDlgEdModel );
163 // -----------------------------------------------------------------------------
165 AccessibleDialogWindow::~AccessibleDialogWindow()
167 DBG_DTOR( AccessibleDialogWindow, NULL );
168 if ( m_pDialogWindow )
169 m_pDialogWindow->RemoveEventListener( LINK( this, AccessibleDialogWindow, WindowEventListener ) );
171 if ( m_pDlgEditor )
172 EndListening( *m_pDlgEditor );
174 if ( m_pDlgEdModel )
175 EndListening( *m_pDlgEdModel );
177 delete m_pExternalLock;
178 m_pExternalLock = NULL;
181 // -----------------------------------------------------------------------------
183 void AccessibleDialogWindow::UpdateFocused()
185 for ( sal_uInt32 i = 0; i < m_aAccessibleChildren.size(); ++i )
187 Reference< XAccessible > xChild( m_aAccessibleChildren[i].rxAccessible );
188 if ( xChild.is() )
190 AccessibleDialogControlShape* pShape = static_cast< AccessibleDialogControlShape* >( xChild.get() );
191 if ( pShape )
192 pShape->SetFocused( pShape->IsFocused() );
197 // -----------------------------------------------------------------------------
199 void AccessibleDialogWindow::UpdateSelected()
201 NotifyAccessibleEvent( AccessibleEventId::SELECTION_CHANGED, Any(), Any() );
203 for ( sal_uInt32 i = 0; i < m_aAccessibleChildren.size(); ++i )
205 Reference< XAccessible > xChild( m_aAccessibleChildren[i].rxAccessible );
206 if ( xChild.is() )
208 AccessibleDialogControlShape* pShape = static_cast< AccessibleDialogControlShape* >( xChild.get() );
209 if ( pShape )
210 pShape->SetSelected( pShape->IsSelected() );
215 // -----------------------------------------------------------------------------
217 void AccessibleDialogWindow::UpdateBounds()
219 for ( sal_uInt32 i = 0; i < m_aAccessibleChildren.size(); ++i )
221 Reference< XAccessible > xChild( m_aAccessibleChildren[i].rxAccessible );
222 if ( xChild.is() )
224 AccessibleDialogControlShape* pShape = static_cast< AccessibleDialogControlShape* >( xChild.get() );
225 if ( pShape )
226 pShape->SetBounds( pShape->GetBounds() );
231 // -----------------------------------------------------------------------------
233 sal_Bool AccessibleDialogWindow::IsChildVisible( const ChildDescriptor& rDesc )
235 sal_Bool bVisible = sal_False;
237 if ( m_pDialogWindow )
239 // first check, if the shape is in a visible layer
240 SdrModel* pSdrModel = m_pDialogWindow->GetModel();
241 if ( pSdrModel )
243 SdrLayerAdmin& rLayerAdmin = pSdrModel->GetLayerAdmin();
244 DlgEdObj* pDlgEdObj = rDesc.pDlgEdObj;
245 if ( pDlgEdObj )
247 SdrLayerID nLayerId = pDlgEdObj->GetLayer();
248 const SdrLayer* pSdrLayer = rLayerAdmin.GetLayerPerID( nLayerId );
249 if ( pSdrLayer )
251 String aLayerName = pSdrLayer->GetName();
252 SdrView* pSdrView = m_pDialogWindow->GetView();
253 if ( pSdrView && pSdrView->IsLayerVisible( aLayerName ) )
255 // get the bounding box of the shape in logic units
256 Rectangle aRect = pDlgEdObj->GetSnapRect();
258 // transform coordinates relative to the parent
259 MapMode aMap = m_pDialogWindow->GetMapMode();
260 Point aOrg = aMap.GetOrigin();
261 aRect.Move( aOrg.X(), aOrg.Y() );
263 // convert logic units to pixel
264 aRect = m_pDialogWindow->LogicToPixel( aRect, MapMode(MAP_100TH_MM) );
266 // check, if the shape's bounding box intersects with the bounding box of its parent
267 Rectangle aParentRect( Point( 0, 0 ), m_pDialogWindow->GetSizePixel() );
268 if ( aParentRect.IsOver( aRect ) )
269 bVisible = sal_True;
276 return bVisible;
279 // -----------------------------------------------------------------------------
281 void AccessibleDialogWindow::InsertChild( const ChildDescriptor& rDesc )
283 // check, if object is already in child list
284 AccessibleChildren::iterator aIter = ::std::find( m_aAccessibleChildren.begin(), m_aAccessibleChildren.end(), rDesc );
286 // if not found, insert in child list
287 if ( aIter == m_aAccessibleChildren.end() )
289 // insert entry in child list
290 m_aAccessibleChildren.push_back( rDesc );
292 // get the accessible of the inserted child
293 Reference< XAccessible > xChild( getAccessibleChild( m_aAccessibleChildren.size() - 1 ) );
295 // sort child list
296 SortChildren();
298 // send accessible child event
299 if ( xChild.is() )
301 Any aOldValue, aNewValue;
302 aNewValue <<= xChild;
303 NotifyAccessibleEvent( AccessibleEventId::CHILD, aOldValue, aNewValue );
308 // -----------------------------------------------------------------------------
310 void AccessibleDialogWindow::RemoveChild( const ChildDescriptor& rDesc )
312 // find object in child list
313 AccessibleChildren::iterator aIter = ::std::find( m_aAccessibleChildren.begin(), m_aAccessibleChildren.end(), rDesc );
315 // if found, remove from child list
316 if ( aIter != m_aAccessibleChildren.end() )
318 // get the accessible of the removed child
319 Reference< XAccessible > xChild( aIter->rxAccessible );
321 // remove entry from child list
322 m_aAccessibleChildren.erase( aIter );
324 // send accessible child event
325 if ( xChild.is() )
327 Any aOldValue, aNewValue;
328 aOldValue <<= xChild;
329 NotifyAccessibleEvent( AccessibleEventId::CHILD, aOldValue, aNewValue );
331 Reference< XComponent > xComponent( xChild, UNO_QUERY );
332 if ( xComponent.is() )
333 xComponent->dispose();
338 // -----------------------------------------------------------------------------
340 void AccessibleDialogWindow::UpdateChild( const ChildDescriptor& rDesc )
342 if ( IsChildVisible( rDesc ) )
344 // if the object is not in the child list, insert child
345 InsertChild( rDesc );
347 else
349 // if the object is in the child list, remove child
350 RemoveChild( rDesc );
354 // -----------------------------------------------------------------------------
356 void AccessibleDialogWindow::UpdateChildren()
358 if ( m_pDialogWindow )
360 SdrPage* pSdrPage = m_pDialogWindow->GetPage();
361 if ( pSdrPage )
363 for ( ULONG i = 0, nCount = pSdrPage->GetObjCount(); i < nCount; ++i )
365 SdrObject* pObj = pSdrPage->GetObj( i );
366 DlgEdObj* pDlgEdObj = PTR_CAST( DlgEdObj, pObj );
367 if ( pDlgEdObj )
368 UpdateChild( ChildDescriptor( pDlgEdObj ) );
374 // -----------------------------------------------------------------------------
376 void AccessibleDialogWindow::SortChildren()
378 // sort child list
379 ::std::sort( m_aAccessibleChildren.begin(), m_aAccessibleChildren.end() );
382 // -----------------------------------------------------------------------------
384 IMPL_LINK( AccessibleDialogWindow, WindowEventListener, VclSimpleEvent*, pEvent )
386 DBG_CHKTHIS( AccessibleDialogWindow, 0 );
387 DBG_ASSERT( pEvent && pEvent->ISA( VclWindowEvent ), "AccessibleDialogWindow::WindowEventListener: unknown window event!" );
389 if ( pEvent && pEvent->ISA( VclWindowEvent ) )
391 DBG_ASSERT( ((VclWindowEvent*)pEvent)->GetWindow(), "AccessibleDialogWindow::WindowEventListener: no window!" );
392 if ( !((VclWindowEvent*)pEvent)->GetWindow()->IsAccessibilityEventsSuppressed() || ( pEvent->GetId() == VCLEVENT_OBJECT_DYING ) )
394 ProcessWindowEvent( *(VclWindowEvent*)pEvent );
398 return 0;
401 // -----------------------------------------------------------------------------
403 void AccessibleDialogWindow::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
405 Any aOldValue, aNewValue;
407 switch ( rVclWindowEvent.GetId() )
409 case VCLEVENT_WINDOW_ENABLED:
411 aNewValue <<= AccessibleStateType::ENABLED;
412 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
414 break;
415 case VCLEVENT_WINDOW_DISABLED:
417 aOldValue <<= AccessibleStateType::ENABLED;
418 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
420 break;
421 case VCLEVENT_WINDOW_ACTIVATE:
423 aNewValue <<= AccessibleStateType::ACTIVE;
424 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
426 break;
427 case VCLEVENT_WINDOW_DEACTIVATE:
429 aOldValue <<= AccessibleStateType::ACTIVE;
430 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
432 break;
433 case VCLEVENT_WINDOW_GETFOCUS:
435 aNewValue <<= AccessibleStateType::FOCUSED;
436 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
438 break;
439 case VCLEVENT_WINDOW_LOSEFOCUS:
441 aOldValue <<= AccessibleStateType::FOCUSED;
442 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
444 break;
445 case VCLEVENT_WINDOW_SHOW:
447 aNewValue <<= AccessibleStateType::SHOWING;
448 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
450 break;
451 case VCLEVENT_WINDOW_HIDE:
453 aOldValue <<= AccessibleStateType::SHOWING;
454 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
456 break;
457 case VCLEVENT_WINDOW_RESIZE:
459 NotifyAccessibleEvent( AccessibleEventId::BOUNDRECT_CHANGED, aOldValue, aNewValue );
460 UpdateChildren();
461 UpdateBounds();
463 break;
464 case VCLEVENT_OBJECT_DYING:
466 if ( m_pDialogWindow )
468 m_pDialogWindow->RemoveEventListener( LINK( this, AccessibleDialogWindow, WindowEventListener ) );
469 m_pDialogWindow = NULL;
471 if ( m_pDlgEditor )
472 EndListening( *m_pDlgEditor );
473 m_pDlgEditor = NULL;
475 if ( m_pDlgEdModel )
476 EndListening( *m_pDlgEdModel );
477 m_pDlgEdModel = NULL;
479 // dispose all children
480 for ( sal_uInt32 i = 0; i < m_aAccessibleChildren.size(); ++i )
482 Reference< XComponent > xComponent( m_aAccessibleChildren[i].rxAccessible, UNO_QUERY );
483 if ( xComponent.is() )
484 xComponent->dispose();
486 m_aAccessibleChildren.clear();
489 break;
490 default:
493 break;
497 // -----------------------------------------------------------------------------
499 void AccessibleDialogWindow::FillAccessibleStateSet( utl::AccessibleStateSetHelper& rStateSet )
501 if ( m_pDialogWindow )
503 if ( m_pDialogWindow->IsEnabled() )
504 rStateSet.AddState( AccessibleStateType::ENABLED );
506 rStateSet.AddState( AccessibleStateType::FOCUSABLE );
508 if ( m_pDialogWindow->HasFocus() )
509 rStateSet.AddState( AccessibleStateType::FOCUSED );
511 rStateSet.AddState( AccessibleStateType::VISIBLE );
513 if ( m_pDialogWindow->IsVisible() )
514 rStateSet.AddState( AccessibleStateType::SHOWING );
516 rStateSet.AddState( AccessibleStateType::OPAQUE );
518 rStateSet.AddState( AccessibleStateType::RESIZABLE );
522 // -----------------------------------------------------------------------------
523 // OCommonAccessibleComponent
524 // -----------------------------------------------------------------------------
526 awt::Rectangle AccessibleDialogWindow::implGetBounds() throw (RuntimeException)
528 awt::Rectangle aBounds;
529 if ( m_pDialogWindow )
530 aBounds = AWTRectangle( Rectangle( m_pDialogWindow->GetPosPixel(), m_pDialogWindow->GetSizePixel() ) );
532 return aBounds;
535 // -----------------------------------------------------------------------------
536 // SfxListener
537 // -----------------------------------------------------------------------------
539 void AccessibleDialogWindow::Notify( SfxBroadcaster&, const SfxHint& rHint )
541 if ( rHint.ISA( SdrHint ) )
543 SdrHint* pSdrHint = (SdrHint*)&rHint;
544 switch ( pSdrHint->GetKind() )
546 case HINT_OBJINSERTED:
548 SdrObject* pObj = (SdrObject*)pSdrHint->GetObject();
549 DlgEdObj* pDlgEdObj = PTR_CAST( DlgEdObj, pObj );
550 if ( pDlgEdObj )
552 ChildDescriptor aDesc( pDlgEdObj );
553 if ( IsChildVisible( aDesc ) )
554 InsertChild( aDesc );
557 break;
558 case HINT_OBJREMOVED:
560 SdrObject* pObj = (SdrObject*)pSdrHint->GetObject();
561 DlgEdObj* pDlgEdObj = PTR_CAST( DlgEdObj, pObj );
562 if ( pDlgEdObj )
563 RemoveChild( ChildDescriptor( pDlgEdObj ) );
565 break;
566 default: ;
569 else if ( rHint.ISA( DlgEdHint ) )
571 DlgEdHint* pDlgEdHint = (DlgEdHint*)&rHint;
572 switch ( pDlgEdHint->GetKind() )
574 case DLGED_HINT_WINDOWSCROLLED:
576 UpdateChildren();
577 UpdateBounds();
579 break;
580 case DLGED_HINT_LAYERCHANGED:
582 DlgEdObj* pDlgEdObj = pDlgEdHint->GetObject();
583 if ( pDlgEdObj )
584 UpdateChild( ChildDescriptor( pDlgEdObj ) );
586 break;
587 case DLGED_HINT_OBJORDERCHANGED:
589 SortChildren();
591 break;
592 case DLGED_HINT_SELECTIONCHANGED:
594 UpdateFocused();
595 UpdateSelected();
597 break;
598 default: ;
603 // -----------------------------------------------------------------------------
604 // XInterface
605 // -----------------------------------------------------------------------------
607 IMPLEMENT_FORWARD_XINTERFACE2( AccessibleDialogWindow, AccessibleExtendedComponentHelper_BASE, AccessibleDialogWindow_BASE )
609 // -----------------------------------------------------------------------------
610 // XTypeProvider
611 // -----------------------------------------------------------------------------
613 IMPLEMENT_FORWARD_XTYPEPROVIDER2( AccessibleDialogWindow, AccessibleExtendedComponentHelper_BASE, AccessibleDialogWindow_BASE )
615 // -----------------------------------------------------------------------------
616 // XComponent
617 // -----------------------------------------------------------------------------
619 void AccessibleDialogWindow::disposing()
621 AccessibleExtendedComponentHelper_BASE::disposing();
623 if ( m_pDialogWindow )
625 m_pDialogWindow->RemoveEventListener( LINK( this, AccessibleDialogWindow, WindowEventListener ) );
626 m_pDialogWindow = NULL;
628 if ( m_pDlgEditor )
629 EndListening( *m_pDlgEditor );
630 m_pDlgEditor = NULL;
632 if ( m_pDlgEdModel )
633 EndListening( *m_pDlgEdModel );
634 m_pDlgEdModel = NULL;
636 // dispose all children
637 for ( sal_uInt32 i = 0; i < m_aAccessibleChildren.size(); ++i )
639 Reference< XComponent > xComponent( m_aAccessibleChildren[i].rxAccessible, UNO_QUERY );
640 if ( xComponent.is() )
641 xComponent->dispose();
643 m_aAccessibleChildren.clear();
647 // -----------------------------------------------------------------------------
648 // XServiceInfo
649 // -----------------------------------------------------------------------------
651 ::rtl::OUString AccessibleDialogWindow::getImplementationName() throw (RuntimeException)
653 return ::rtl::OUString::createFromAscii( "com.sun.star.comp.basctl.AccessibleWindow" );
656 // -----------------------------------------------------------------------------
658 sal_Bool AccessibleDialogWindow::supportsService( const ::rtl::OUString& rServiceName ) throw (RuntimeException)
660 Sequence< ::rtl::OUString > aNames( getSupportedServiceNames() );
661 const ::rtl::OUString* pNames = aNames.getConstArray();
662 const ::rtl::OUString* pEnd = pNames + aNames.getLength();
663 for ( ; pNames != pEnd && !pNames->equals( rServiceName ); ++pNames )
666 return pNames != pEnd;
669 // -----------------------------------------------------------------------------
671 Sequence< ::rtl::OUString > AccessibleDialogWindow::getSupportedServiceNames() throw (RuntimeException)
673 Sequence< ::rtl::OUString > aNames(1);
674 aNames[0] = ::rtl::OUString::createFromAscii( "com.sun.star.awt.AccessibleWindow" );
675 return aNames;
678 // -----------------------------------------------------------------------------
679 // XAccessible
680 // -----------------------------------------------------------------------------
682 Reference< XAccessibleContext > AccessibleDialogWindow::getAccessibleContext( ) throw (RuntimeException)
684 OExternalLockGuard aGuard( this );
686 return this;
689 // -----------------------------------------------------------------------------
690 // XAccessibleContext
691 // -----------------------------------------------------------------------------
693 sal_Int32 AccessibleDialogWindow::getAccessibleChildCount() throw (RuntimeException)
695 OExternalLockGuard aGuard( this );
697 return m_aAccessibleChildren.size();
700 // -----------------------------------------------------------------------------
702 Reference< XAccessible > AccessibleDialogWindow::getAccessibleChild( sal_Int32 i ) throw (IndexOutOfBoundsException, RuntimeException)
704 OExternalLockGuard aGuard( this );
706 if ( i < 0 || i >= getAccessibleChildCount() )
707 throw IndexOutOfBoundsException();
709 Reference< XAccessible > xChild = m_aAccessibleChildren[i].rxAccessible;
710 if ( !xChild.is() )
712 if ( m_pDialogWindow )
714 DlgEdObj* pDlgEdObj = m_aAccessibleChildren[i].pDlgEdObj;
715 if ( pDlgEdObj )
717 xChild = new AccessibleDialogControlShape( m_pDialogWindow, pDlgEdObj );
719 // insert into child list
720 m_aAccessibleChildren[i].rxAccessible = xChild;
725 return xChild;
728 // -----------------------------------------------------------------------------
730 Reference< XAccessible > AccessibleDialogWindow::getAccessibleParent( ) throw (RuntimeException)
732 OExternalLockGuard aGuard( this );
734 Reference< XAccessible > xParent;
735 if ( m_pDialogWindow )
737 Window* pParent = m_pDialogWindow->GetAccessibleParentWindow();
738 if ( pParent )
739 xParent = pParent->GetAccessible();
742 return xParent;
745 // -----------------------------------------------------------------------------
747 sal_Int32 AccessibleDialogWindow::getAccessibleIndexInParent( ) throw (RuntimeException)
749 OExternalLockGuard aGuard( this );
751 sal_Int32 nIndexInParent = -1;
752 if ( m_pDialogWindow )
754 Window* pParent = m_pDialogWindow->GetAccessibleParentWindow();
755 if ( pParent )
757 for ( USHORT i = 0, nCount = pParent->GetAccessibleChildWindowCount(); i < nCount; ++i )
759 Window* pChild = pParent->GetAccessibleChildWindow( i );
760 if ( pChild == static_cast< Window* >( m_pDialogWindow ) )
762 nIndexInParent = i;
763 break;
769 return nIndexInParent;
772 // -----------------------------------------------------------------------------
774 sal_Int16 AccessibleDialogWindow::getAccessibleRole( ) throw (RuntimeException)
776 OExternalLockGuard aGuard( this );
778 return AccessibleRole::PANEL;
781 // -----------------------------------------------------------------------------
783 ::rtl::OUString AccessibleDialogWindow::getAccessibleDescription( ) throw (RuntimeException)
785 OExternalLockGuard aGuard( this );
787 ::rtl::OUString sDescription;
788 if ( m_pDialogWindow )
789 sDescription = m_pDialogWindow->GetAccessibleDescription();
791 return sDescription;
794 // -----------------------------------------------------------------------------
796 ::rtl::OUString AccessibleDialogWindow::getAccessibleName( ) throw (RuntimeException)
798 OExternalLockGuard aGuard( this );
800 ::rtl::OUString sName;
801 if ( m_pDialogWindow )
802 sName = m_pDialogWindow->GetAccessibleName();
804 return sName;
807 // -----------------------------------------------------------------------------
809 Reference< XAccessibleRelationSet > AccessibleDialogWindow::getAccessibleRelationSet( ) throw (RuntimeException)
811 OExternalLockGuard aGuard( this );
813 utl::AccessibleRelationSetHelper* pRelationSetHelper = new utl::AccessibleRelationSetHelper;
814 Reference< XAccessibleRelationSet > xSet = pRelationSetHelper;
815 return xSet;
818 // -----------------------------------------------------------------------------
820 Reference< XAccessibleStateSet > AccessibleDialogWindow::getAccessibleStateSet( ) throw (RuntimeException)
822 OExternalLockGuard aGuard( this );
824 utl::AccessibleStateSetHelper* pStateSetHelper = new utl::AccessibleStateSetHelper;
825 Reference< XAccessibleStateSet > xSet = pStateSetHelper;
827 if ( !rBHelper.bDisposed && !rBHelper.bInDispose )
829 FillAccessibleStateSet( *pStateSetHelper );
831 else
833 pStateSetHelper->AddState( AccessibleStateType::DEFUNC );
836 return xSet;
839 // -----------------------------------------------------------------------------
841 Locale AccessibleDialogWindow::getLocale( ) throw (IllegalAccessibleComponentStateException, RuntimeException)
843 OExternalLockGuard aGuard( this );
845 return Application::GetSettings().GetLocale();
848 // -----------------------------------------------------------------------------
849 // XAccessibleComponent
850 // -----------------------------------------------------------------------------
852 Reference< XAccessible > AccessibleDialogWindow::getAccessibleAtPoint( const awt::Point& rPoint ) throw (RuntimeException)
854 OExternalLockGuard aGuard( this );
856 Reference< XAccessible > xChild;
857 for ( sal_uInt32 i = 0; i < m_aAccessibleChildren.size(); ++i )
859 Reference< XAccessible > xAcc = getAccessibleChild( i );
860 if ( xAcc.is() )
862 Reference< XAccessibleComponent > xComp( xAcc->getAccessibleContext(), UNO_QUERY );
863 if ( xComp.is() )
865 Rectangle aRect = VCLRectangle( xComp->getBounds() );
866 Point aPos = VCLPoint( rPoint );
867 if ( aRect.IsInside( aPos ) )
869 xChild = xAcc;
870 break;
876 return xChild;
879 // -----------------------------------------------------------------------------
881 void AccessibleDialogWindow::grabFocus( ) throw (RuntimeException)
883 OExternalLockGuard aGuard( this );
885 if ( m_pDialogWindow )
886 m_pDialogWindow->GrabFocus();
889 // -----------------------------------------------------------------------------
891 sal_Int32 AccessibleDialogWindow::getForeground( ) throw (RuntimeException)
893 OExternalLockGuard aGuard( this );
895 sal_Int32 nColor = 0;
896 if ( m_pDialogWindow )
898 if ( m_pDialogWindow->IsControlForeground() )
899 nColor = m_pDialogWindow->GetControlForeground().GetColor();
900 else
902 Font aFont;
903 if ( m_pDialogWindow->IsControlFont() )
904 aFont = m_pDialogWindow->GetControlFont();
905 else
906 aFont = m_pDialogWindow->GetFont();
907 nColor = aFont.GetColor().GetColor();
911 return nColor;
914 // -----------------------------------------------------------------------------
916 sal_Int32 AccessibleDialogWindow::getBackground( ) throw (RuntimeException)
918 OExternalLockGuard aGuard( this );
920 sal_Int32 nColor = 0;
921 if ( m_pDialogWindow )
923 if ( m_pDialogWindow->IsControlBackground() )
924 nColor = m_pDialogWindow->GetControlBackground().GetColor();
925 else
926 nColor = m_pDialogWindow->GetBackground().GetColor().GetColor();
929 return nColor;
932 // -----------------------------------------------------------------------------
933 // XAccessibleExtendedComponent
934 // -----------------------------------------------------------------------------
936 Reference< awt::XFont > AccessibleDialogWindow::getFont( ) throw (RuntimeException)
938 OExternalLockGuard aGuard( this );
940 Reference< awt::XFont > xFont;
941 if ( m_pDialogWindow )
943 Reference< awt::XDevice > xDev( m_pDialogWindow->GetComponentInterface(), UNO_QUERY );
944 if ( xDev.is() )
946 Font aFont;
947 if ( m_pDialogWindow->IsControlFont() )
948 aFont = m_pDialogWindow->GetControlFont();
949 else
950 aFont = m_pDialogWindow->GetFont();
951 VCLXFont* pVCLXFont = new VCLXFont;
952 pVCLXFont->Init( *xDev.get(), aFont );
953 xFont = pVCLXFont;
957 return xFont;
960 // -----------------------------------------------------------------------------
962 ::rtl::OUString AccessibleDialogWindow::getTitledBorderText( ) throw (RuntimeException)
964 OExternalLockGuard aGuard( this );
966 return ::rtl::OUString();
969 // -----------------------------------------------------------------------------
971 ::rtl::OUString AccessibleDialogWindow::getToolTipText( ) throw (RuntimeException)
973 OExternalLockGuard aGuard( this );
975 ::rtl::OUString sText;
976 if ( m_pDialogWindow )
977 sText = m_pDialogWindow->GetQuickHelpText();
979 return sText;
982 // -----------------------------------------------------------------------------
983 // XAccessibleSelection
984 // -----------------------------------------------------------------------------
986 void AccessibleDialogWindow::selectAccessibleChild( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException)
988 OExternalLockGuard aGuard( this );
990 if ( nChildIndex < 0 || nChildIndex >= getAccessibleChildCount() )
991 throw IndexOutOfBoundsException();
993 if ( m_pDialogWindow )
995 DlgEdObj* pDlgEdObj = m_aAccessibleChildren[nChildIndex].pDlgEdObj;
996 if ( pDlgEdObj )
998 SdrView* pSdrView = m_pDialogWindow->GetView();
999 if ( pSdrView )
1001 SdrPageView* pPgView = pSdrView->GetSdrPageView();
1002 if ( pPgView )
1003 pSdrView->MarkObj( pDlgEdObj, pPgView );
1009 // -----------------------------------------------------------------------------
1011 sal_Bool AccessibleDialogWindow::isAccessibleChildSelected( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException)
1013 OExternalLockGuard aGuard( this );
1015 if ( nChildIndex < 0 || nChildIndex >= getAccessibleChildCount() )
1016 throw IndexOutOfBoundsException();
1018 sal_Bool bSelected = sal_False;
1019 if ( m_pDialogWindow )
1021 DlgEdObj* pDlgEdObj = m_aAccessibleChildren[nChildIndex].pDlgEdObj;
1022 if ( pDlgEdObj )
1024 SdrView* pSdrView = m_pDialogWindow->GetView();
1025 if ( pSdrView )
1026 bSelected = pSdrView->IsObjMarked( pDlgEdObj );
1030 return bSelected;
1033 // -----------------------------------------------------------------------------
1035 void AccessibleDialogWindow::clearAccessibleSelection( ) throw (RuntimeException)
1037 OExternalLockGuard aGuard( this );
1039 if ( m_pDialogWindow )
1041 SdrView* pSdrView = m_pDialogWindow->GetView();
1042 if ( pSdrView )
1043 pSdrView->UnmarkAll();
1047 // -----------------------------------------------------------------------------
1049 void AccessibleDialogWindow::selectAllAccessibleChildren( ) throw (RuntimeException)
1051 OExternalLockGuard aGuard( this );
1053 if ( m_pDialogWindow )
1055 SdrView* pSdrView = m_pDialogWindow->GetView();
1056 if ( pSdrView )
1057 pSdrView->MarkAll();
1061 // -----------------------------------------------------------------------------
1063 sal_Int32 AccessibleDialogWindow::getSelectedAccessibleChildCount( ) throw (RuntimeException)
1065 OExternalLockGuard aGuard( this );
1067 sal_Int32 nRet = 0;
1069 for ( sal_Int32 i = 0, nCount = getAccessibleChildCount(); i < nCount; ++i )
1071 if ( isAccessibleChildSelected( i ) )
1072 ++nRet;
1075 return nRet;
1078 // -----------------------------------------------------------------------------
1080 Reference< XAccessible > AccessibleDialogWindow::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex ) throw (IndexOutOfBoundsException, RuntimeException)
1082 OExternalLockGuard aGuard( this );
1084 if ( nSelectedChildIndex < 0 || nSelectedChildIndex >= getSelectedAccessibleChildCount() )
1085 throw IndexOutOfBoundsException();
1087 Reference< XAccessible > xChild;
1089 for ( sal_Int32 i = 0, j = 0, nCount = getAccessibleChildCount(); i < nCount; ++i )
1091 if ( isAccessibleChildSelected( i ) && ( j++ == nSelectedChildIndex ) )
1093 xChild = getAccessibleChild( i );
1094 break;
1098 return xChild;
1101 // -----------------------------------------------------------------------------
1103 void AccessibleDialogWindow::deselectAccessibleChild( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException)
1105 OExternalLockGuard aGuard( this );
1107 if ( nChildIndex < 0 || nChildIndex >= getAccessibleChildCount() )
1108 throw IndexOutOfBoundsException();
1110 if ( m_pDialogWindow )
1112 DlgEdObj* pDlgEdObj = m_aAccessibleChildren[nChildIndex].pDlgEdObj;
1113 if ( pDlgEdObj )
1115 SdrView* pSdrView = m_pDialogWindow->GetView();
1116 if ( pSdrView )
1118 SdrPageView* pPgView = pSdrView->GetSdrPageView();
1119 if ( pPgView )
1120 pSdrView->MarkObj( pDlgEdObj, pPgView, TRUE );
1126 // -----------------------------------------------------------------------------