1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: accessibledialogwindow.cxx,v $
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>
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>
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
)
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
;
98 // -----------------------------------------------------------------------------
100 bool AccessibleDialogWindow::ChildDescriptor::operator==( const ChildDescriptor
& rDesc
)
103 if ( pDlgEdObj
== rDesc
.pDlgEdObj
)
109 // -----------------------------------------------------------------------------
111 bool AccessibleDialogWindow::ChildDescriptor::operator<( const ChildDescriptor
& rDesc
) const
114 if ( pDlgEdObj
&& rDesc
.pDlgEdObj
&& pDlgEdObj
->GetOrdNum() < rDesc
.pDlgEdObj
->GetOrdNum() )
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();
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
);
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();
155 StartListening( *m_pDlgEditor
);
157 m_pDlgEdModel
= m_pDialogWindow
->GetModel();
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
) );
172 EndListening( *m_pDlgEditor
);
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
);
190 AccessibleDialogControlShape
* pShape
= static_cast< AccessibleDialogControlShape
* >( xChild
.get() );
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
);
208 AccessibleDialogControlShape
* pShape
= static_cast< AccessibleDialogControlShape
* >( xChild
.get() );
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
);
224 AccessibleDialogControlShape
* pShape
= static_cast< AccessibleDialogControlShape
* >( xChild
.get() );
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();
243 SdrLayerAdmin
& rLayerAdmin
= pSdrModel
->GetLayerAdmin();
244 DlgEdObj
* pDlgEdObj
= rDesc
.pDlgEdObj
;
247 SdrLayerID nLayerId
= pDlgEdObj
->GetLayer();
248 const SdrLayer
* pSdrLayer
= rLayerAdmin
.GetLayerPerID( nLayerId
);
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
) )
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 ) );
298 // send accessible child event
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
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
);
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();
363 for ( ULONG i
= 0, nCount
= pSdrPage
->GetObjCount(); i
< nCount
; ++i
)
365 SdrObject
* pObj
= pSdrPage
->GetObj( i
);
366 DlgEdObj
* pDlgEdObj
= PTR_CAST( DlgEdObj
, pObj
);
368 UpdateChild( ChildDescriptor( pDlgEdObj
) );
374 // -----------------------------------------------------------------------------
376 void AccessibleDialogWindow::SortChildren()
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
);
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
);
415 case VCLEVENT_WINDOW_DISABLED
:
417 aOldValue
<<= AccessibleStateType::ENABLED
;
418 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED
, aOldValue
, aNewValue
);
421 case VCLEVENT_WINDOW_ACTIVATE
:
423 aNewValue
<<= AccessibleStateType::ACTIVE
;
424 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED
, aOldValue
, aNewValue
);
427 case VCLEVENT_WINDOW_DEACTIVATE
:
429 aOldValue
<<= AccessibleStateType::ACTIVE
;
430 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED
, aOldValue
, aNewValue
);
433 case VCLEVENT_WINDOW_GETFOCUS
:
435 aNewValue
<<= AccessibleStateType::FOCUSED
;
436 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED
, aOldValue
, aNewValue
);
439 case VCLEVENT_WINDOW_LOSEFOCUS
:
441 aOldValue
<<= AccessibleStateType::FOCUSED
;
442 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED
, aOldValue
, aNewValue
);
445 case VCLEVENT_WINDOW_SHOW
:
447 aNewValue
<<= AccessibleStateType::SHOWING
;
448 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED
, aOldValue
, aNewValue
);
451 case VCLEVENT_WINDOW_HIDE
:
453 aOldValue
<<= AccessibleStateType::SHOWING
;
454 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED
, aOldValue
, aNewValue
);
457 case VCLEVENT_WINDOW_RESIZE
:
459 NotifyAccessibleEvent( AccessibleEventId::BOUNDRECT_CHANGED
, aOldValue
, aNewValue
);
464 case VCLEVENT_OBJECT_DYING
:
466 if ( m_pDialogWindow
)
468 m_pDialogWindow
->RemoveEventListener( LINK( this, AccessibleDialogWindow
, WindowEventListener
) );
469 m_pDialogWindow
= NULL
;
472 EndListening( *m_pDlgEditor
);
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();
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() ) );
535 // -----------------------------------------------------------------------------
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
);
552 ChildDescriptor
aDesc( pDlgEdObj
);
553 if ( IsChildVisible( aDesc
) )
554 InsertChild( aDesc
);
558 case HINT_OBJREMOVED
:
560 SdrObject
* pObj
= (SdrObject
*)pSdrHint
->GetObject();
561 DlgEdObj
* pDlgEdObj
= PTR_CAST( DlgEdObj
, pObj
);
563 RemoveChild( ChildDescriptor( pDlgEdObj
) );
569 else if ( rHint
.ISA( DlgEdHint
) )
571 DlgEdHint
* pDlgEdHint
= (DlgEdHint
*)&rHint
;
572 switch ( pDlgEdHint
->GetKind() )
574 case DLGED_HINT_WINDOWSCROLLED
:
580 case DLGED_HINT_LAYERCHANGED
:
582 DlgEdObj
* pDlgEdObj
= pDlgEdHint
->GetObject();
584 UpdateChild( ChildDescriptor( pDlgEdObj
) );
587 case DLGED_HINT_OBJORDERCHANGED
:
592 case DLGED_HINT_SELECTIONCHANGED
:
603 // -----------------------------------------------------------------------------
605 // -----------------------------------------------------------------------------
607 IMPLEMENT_FORWARD_XINTERFACE2( AccessibleDialogWindow
, AccessibleExtendedComponentHelper_BASE
, AccessibleDialogWindow_BASE
)
609 // -----------------------------------------------------------------------------
611 // -----------------------------------------------------------------------------
613 IMPLEMENT_FORWARD_XTYPEPROVIDER2( AccessibleDialogWindow
, AccessibleExtendedComponentHelper_BASE
, AccessibleDialogWindow_BASE
)
615 // -----------------------------------------------------------------------------
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
;
629 EndListening( *m_pDlgEditor
);
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 // -----------------------------------------------------------------------------
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" );
678 // -----------------------------------------------------------------------------
680 // -----------------------------------------------------------------------------
682 Reference
< XAccessibleContext
> AccessibleDialogWindow::getAccessibleContext( ) throw (RuntimeException
)
684 OExternalLockGuard
aGuard( 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
;
712 if ( m_pDialogWindow
)
714 DlgEdObj
* pDlgEdObj
= m_aAccessibleChildren
[i
].pDlgEdObj
;
717 xChild
= new AccessibleDialogControlShape( m_pDialogWindow
, pDlgEdObj
);
719 // insert into child list
720 m_aAccessibleChildren
[i
].rxAccessible
= 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();
739 xParent
= pParent
->GetAccessible();
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();
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
) )
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();
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();
807 // -----------------------------------------------------------------------------
809 Reference
< XAccessibleRelationSet
> AccessibleDialogWindow::getAccessibleRelationSet( ) throw (RuntimeException
)
811 OExternalLockGuard
aGuard( this );
813 utl::AccessibleRelationSetHelper
* pRelationSetHelper
= new utl::AccessibleRelationSetHelper
;
814 Reference
< XAccessibleRelationSet
> xSet
= pRelationSetHelper
;
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
);
833 pStateSetHelper
->AddState( AccessibleStateType::DEFUNC
);
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
);
862 Reference
< XAccessibleComponent
> xComp( xAcc
->getAccessibleContext(), UNO_QUERY
);
865 Rectangle aRect
= VCLRectangle( xComp
->getBounds() );
866 Point aPos
= VCLPoint( rPoint
);
867 if ( aRect
.IsInside( aPos
) )
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();
903 if ( m_pDialogWindow
->IsControlFont() )
904 aFont
= m_pDialogWindow
->GetControlFont();
906 aFont
= m_pDialogWindow
->GetFont();
907 nColor
= aFont
.GetColor().GetColor();
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();
926 nColor
= m_pDialogWindow
->GetBackground().GetColor().GetColor();
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
);
947 if ( m_pDialogWindow
->IsControlFont() )
948 aFont
= m_pDialogWindow
->GetControlFont();
950 aFont
= m_pDialogWindow
->GetFont();
951 VCLXFont
* pVCLXFont
= new VCLXFont
;
952 pVCLXFont
->Init( *xDev
.get(), aFont
);
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();
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
;
998 SdrView
* pSdrView
= m_pDialogWindow
->GetView();
1001 SdrPageView
* pPgView
= pSdrView
->GetSdrPageView();
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
;
1024 SdrView
* pSdrView
= m_pDialogWindow
->GetView();
1026 bSelected
= pSdrView
->IsObjMarked( pDlgEdObj
);
1033 // -----------------------------------------------------------------------------
1035 void AccessibleDialogWindow::clearAccessibleSelection( ) throw (RuntimeException
)
1037 OExternalLockGuard
aGuard( this );
1039 if ( m_pDialogWindow
)
1041 SdrView
* pSdrView
= m_pDialogWindow
->GetView();
1043 pSdrView
->UnmarkAll();
1047 // -----------------------------------------------------------------------------
1049 void AccessibleDialogWindow::selectAllAccessibleChildren( ) throw (RuntimeException
)
1051 OExternalLockGuard
aGuard( this );
1053 if ( m_pDialogWindow
)
1055 SdrView
* pSdrView
= m_pDialogWindow
->GetView();
1057 pSdrView
->MarkAll();
1061 // -----------------------------------------------------------------------------
1063 sal_Int32
AccessibleDialogWindow::getSelectedAccessibleChildCount( ) throw (RuntimeException
)
1065 OExternalLockGuard
aGuard( this );
1069 for ( sal_Int32 i
= 0, nCount
= getAccessibleChildCount(); i
< nCount
; ++i
)
1071 if ( isAccessibleChildSelected( i
) )
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
);
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
;
1115 SdrView
* pSdrView
= m_pDialogWindow
->GetView();
1118 SdrPageView
* pPgView
= pSdrView
->GetSdrPageView();
1120 pSdrView
->MarkObj( pDlgEdObj
, pPgView
, TRUE
);
1126 // -----------------------------------------------------------------------------