1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include <accessibledialogwindow.hxx>
22 #include <accessibledialogcontrolshape.hxx>
23 #include <baside3.hxx>
25 #include <dlgedmod.hxx>
26 #include <dlgedpage.hxx>
27 #include <dlgedview.hxx>
28 #include <dlgedobj.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 <toolkit/awt/vclxfont.hxx>
35 #include <toolkit/helper/externallock.hxx>
36 #include <toolkit/helper/convert.hxx>
37 #include <vcl/svapp.hxx>
42 using namespace ::com::sun::star
;
43 using namespace ::com::sun::star::uno
;
44 using namespace ::com::sun::star::lang
;
45 using namespace ::com::sun::star::accessibility
;
46 using namespace ::comphelper
;
48 DBG_NAME( AccessibleDialogWindow
)
51 // -----------------------------------------------------------------------------
52 // class ChildDescriptor
53 // -----------------------------------------------------------------------------
55 AccessibleDialogWindow::ChildDescriptor::ChildDescriptor( DlgEdObj
* _pDlgEdObj
)
56 :pDlgEdObj( _pDlgEdObj
)
61 // -----------------------------------------------------------------------------
63 AccessibleDialogWindow::ChildDescriptor::~ChildDescriptor()
67 // -----------------------------------------------------------------------------
69 AccessibleDialogWindow::ChildDescriptor::ChildDescriptor( const ChildDescriptor
& rDesc
)
70 :pDlgEdObj( rDesc
.pDlgEdObj
)
71 ,rxAccessible( rDesc
.rxAccessible
)
75 // -----------------------------------------------------------------------------
77 AccessibleDialogWindow::ChildDescriptor
& AccessibleDialogWindow::ChildDescriptor::operator=( const ChildDescriptor
& rDesc
)
79 pDlgEdObj
= rDesc
.pDlgEdObj
;
80 rxAccessible
= rDesc
.rxAccessible
;
85 // -----------------------------------------------------------------------------
87 bool AccessibleDialogWindow::ChildDescriptor::operator==( const ChildDescriptor
& rDesc
)
90 if ( pDlgEdObj
== rDesc
.pDlgEdObj
)
96 // -----------------------------------------------------------------------------
98 bool AccessibleDialogWindow::ChildDescriptor::operator<( const ChildDescriptor
& rDesc
) const
101 if ( pDlgEdObj
&& rDesc
.pDlgEdObj
&& pDlgEdObj
->GetOrdNum() < rDesc
.pDlgEdObj
->GetOrdNum() )
107 // -----------------------------------------------------------------------------
108 // class AccessibleDialogWindow
109 // -----------------------------------------------------------------------------
111 AccessibleDialogWindow::AccessibleDialogWindow (basctl::DialogWindow
* pDialogWindow
)
112 :AccessibleExtendedComponentHelper_BASE( new VCLExternalSolarLock() )
113 ,m_pDialogWindow( pDialogWindow
)
115 DBG_CTOR( AccessibleDialogWindow
, NULL
);
116 m_pExternalLock
= static_cast< VCLExternalSolarLock
* >( getExternalLock() );
118 if ( m_pDialogWindow
)
120 SdrPage
& rPage
= m_pDialogWindow
->GetPage();
121 sal_uLong nCount
= rPage
.GetObjCount();
123 for ( sal_uLong i
= 0; i
< nCount
; ++i
)
125 if (DlgEdObj
* pDlgEdObj
= dynamic_cast<DlgEdObj
*>(rPage
.GetObj(i
)))
127 ChildDescriptor
aDesc( pDlgEdObj
);
128 if ( IsChildVisible( aDesc
) )
129 m_aAccessibleChildren
.push_back( aDesc
);
133 m_pDialogWindow
->AddEventListener( LINK( this, AccessibleDialogWindow
, WindowEventListener
) );
135 StartListening(m_pDialogWindow
->GetEditor());
137 m_pDlgEdModel
= &m_pDialogWindow
->GetModel();
138 StartListening(*m_pDlgEdModel
);
142 // -----------------------------------------------------------------------------
144 AccessibleDialogWindow::~AccessibleDialogWindow()
146 DBG_DTOR( AccessibleDialogWindow
, NULL
);
147 if ( m_pDialogWindow
)
148 m_pDialogWindow
->RemoveEventListener( LINK( this, AccessibleDialogWindow
, WindowEventListener
) );
151 EndListening( *m_pDlgEditor
);
154 EndListening( *m_pDlgEdModel
);
156 delete m_pExternalLock
;
157 m_pExternalLock
= NULL
;
160 // -----------------------------------------------------------------------------
162 void AccessibleDialogWindow::UpdateFocused()
164 for ( sal_uInt32 i
= 0; i
< m_aAccessibleChildren
.size(); ++i
)
166 Reference
< XAccessible
> xChild( m_aAccessibleChildren
[i
].rxAccessible
);
169 AccessibleDialogControlShape
* pShape
= static_cast< AccessibleDialogControlShape
* >( xChild
.get() );
171 pShape
->SetFocused( pShape
->IsFocused() );
176 // -----------------------------------------------------------------------------
178 void AccessibleDialogWindow::UpdateSelected()
180 NotifyAccessibleEvent( AccessibleEventId::SELECTION_CHANGED
, Any(), Any() );
182 for ( sal_uInt32 i
= 0; i
< m_aAccessibleChildren
.size(); ++i
)
184 Reference
< XAccessible
> xChild( m_aAccessibleChildren
[i
].rxAccessible
);
187 AccessibleDialogControlShape
* pShape
= static_cast< AccessibleDialogControlShape
* >( xChild
.get() );
189 pShape
->SetSelected( pShape
->IsSelected() );
194 // -----------------------------------------------------------------------------
196 void AccessibleDialogWindow::UpdateBounds()
198 for ( sal_uInt32 i
= 0; i
< m_aAccessibleChildren
.size(); ++i
)
200 Reference
< XAccessible
> xChild( m_aAccessibleChildren
[i
].rxAccessible
);
203 AccessibleDialogControlShape
* pShape
= static_cast< AccessibleDialogControlShape
* >( xChild
.get() );
205 pShape
->SetBounds( pShape
->GetBounds() );
210 // -----------------------------------------------------------------------------
212 bool AccessibleDialogWindow::IsChildVisible( const ChildDescriptor
& rDesc
)
214 bool bVisible
= false;
216 if ( m_pDialogWindow
)
218 // first check, if the shape is in a visible layer
219 SdrLayerAdmin
& rLayerAdmin
= m_pDialogWindow
->GetModel().GetLayerAdmin();
220 DlgEdObj
* pDlgEdObj
= rDesc
.pDlgEdObj
;
223 SdrLayerID nLayerId
= pDlgEdObj
->GetLayer();
224 const SdrLayer
* pSdrLayer
= rLayerAdmin
.GetLayerPerID( nLayerId
);
227 OUString aLayerName
= pSdrLayer
->GetName();
228 SdrView
& rView
= m_pDialogWindow
->GetView();
229 if (rView
.IsLayerVisible(aLayerName
))
231 // get the bounding box of the shape in logic units
232 Rectangle aRect
= pDlgEdObj
->GetSnapRect();
234 // transform coordinates relative to the parent
235 MapMode aMap
= m_pDialogWindow
->GetMapMode();
236 Point aOrg
= aMap
.GetOrigin();
237 aRect
.Move( aOrg
.X(), aOrg
.Y() );
239 // convert logic units to pixel
240 aRect
= m_pDialogWindow
->LogicToPixel( aRect
, MapMode(MAP_100TH_MM
) );
242 // check, if the shape's bounding box intersects with the bounding box of its parent
243 Rectangle
aParentRect( Point( 0, 0 ), m_pDialogWindow
->GetSizePixel() );
244 if ( aParentRect
.IsOver( aRect
) )
254 // -----------------------------------------------------------------------------
256 void AccessibleDialogWindow::InsertChild( const ChildDescriptor
& rDesc
)
258 // check, if object is already in child list
259 AccessibleChildren::iterator aIter
= ::std::find( m_aAccessibleChildren
.begin(), m_aAccessibleChildren
.end(), rDesc
);
261 // if not found, insert in child list
262 if ( aIter
== m_aAccessibleChildren
.end() )
264 // insert entry in child list
265 m_aAccessibleChildren
.push_back( rDesc
);
267 // get the accessible of the inserted child
268 Reference
< XAccessible
> xChild( getAccessibleChild( m_aAccessibleChildren
.size() - 1 ) );
273 // send accessible child event
276 Any aOldValue
, aNewValue
;
277 aNewValue
<<= xChild
;
278 NotifyAccessibleEvent( AccessibleEventId::CHILD
, aOldValue
, aNewValue
);
283 // -----------------------------------------------------------------------------
285 void AccessibleDialogWindow::RemoveChild( const ChildDescriptor
& rDesc
)
287 // find object in child list
288 AccessibleChildren::iterator aIter
= ::std::find( m_aAccessibleChildren
.begin(), m_aAccessibleChildren
.end(), rDesc
);
290 // if found, remove from child list
291 if ( aIter
!= m_aAccessibleChildren
.end() )
293 // get the accessible of the removed child
294 Reference
< XAccessible
> xChild( aIter
->rxAccessible
);
296 // remove entry from child list
297 m_aAccessibleChildren
.erase( aIter
);
299 // send accessible child event
302 Any aOldValue
, aNewValue
;
303 aOldValue
<<= xChild
;
304 NotifyAccessibleEvent( AccessibleEventId::CHILD
, aOldValue
, aNewValue
);
306 Reference
< XComponent
> xComponent( xChild
, UNO_QUERY
);
307 if ( xComponent
.is() )
308 xComponent
->dispose();
313 // -----------------------------------------------------------------------------
315 void AccessibleDialogWindow::UpdateChild( const ChildDescriptor
& rDesc
)
317 if ( IsChildVisible( rDesc
) )
319 // if the object is not in the child list, insert child
320 InsertChild( rDesc
);
324 // if the object is in the child list, remove child
325 RemoveChild( rDesc
);
329 // -----------------------------------------------------------------------------
331 void AccessibleDialogWindow::UpdateChildren()
333 if ( m_pDialogWindow
)
335 SdrPage
& rPage
= m_pDialogWindow
->GetPage();
336 for ( sal_uLong i
= 0, nCount
= rPage
.GetObjCount(); i
< nCount
; ++i
)
337 if (DlgEdObj
* pDlgEdObj
= dynamic_cast<DlgEdObj
*>(rPage
.GetObj(i
)))
338 UpdateChild( ChildDescriptor( pDlgEdObj
) );
342 // -----------------------------------------------------------------------------
344 void AccessibleDialogWindow::SortChildren()
347 ::std::sort( m_aAccessibleChildren
.begin(), m_aAccessibleChildren
.end() );
350 // -----------------------------------------------------------------------------
352 IMPL_LINK( AccessibleDialogWindow
, WindowEventListener
, VclSimpleEvent
*, pEvent
)
354 DBG_CHKTHIS( AccessibleDialogWindow
, 0 );
356 if (VclWindowEvent
* pWinEvent
= dynamic_cast<VclWindowEvent
*>(pEvent
))
358 DBG_ASSERT(pWinEvent
->GetWindow(), "AccessibleDialogWindow::WindowEventListener: no window!");
359 if (!pWinEvent
->GetWindow()->IsAccessibilityEventsSuppressed() || pEvent
->GetId() == VCLEVENT_OBJECT_DYING
)
360 ProcessWindowEvent(*pWinEvent
);
363 DBG_ASSERT(false, "AccessibleDialogWindow::WindowEventListener: unknown window event!");
367 // -----------------------------------------------------------------------------
369 void AccessibleDialogWindow::ProcessWindowEvent( const VclWindowEvent
& rVclWindowEvent
)
371 Any aOldValue
, aNewValue
;
373 switch ( rVclWindowEvent
.GetId() )
375 case VCLEVENT_WINDOW_ENABLED
:
377 aNewValue
<<= AccessibleStateType::ENABLED
;
378 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED
, aOldValue
, aNewValue
);
381 case VCLEVENT_WINDOW_DISABLED
:
383 aOldValue
<<= AccessibleStateType::ENABLED
;
384 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED
, aOldValue
, aNewValue
);
387 case VCLEVENT_WINDOW_ACTIVATE
:
389 aNewValue
<<= AccessibleStateType::ACTIVE
;
390 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED
, aOldValue
, aNewValue
);
393 case VCLEVENT_WINDOW_DEACTIVATE
:
395 aOldValue
<<= AccessibleStateType::ACTIVE
;
396 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED
, aOldValue
, aNewValue
);
399 case VCLEVENT_WINDOW_GETFOCUS
:
401 aNewValue
<<= AccessibleStateType::FOCUSED
;
402 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED
, aOldValue
, aNewValue
);
405 case VCLEVENT_WINDOW_LOSEFOCUS
:
407 aOldValue
<<= AccessibleStateType::FOCUSED
;
408 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED
, aOldValue
, aNewValue
);
411 case VCLEVENT_WINDOW_SHOW
:
413 aNewValue
<<= AccessibleStateType::SHOWING
;
414 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED
, aOldValue
, aNewValue
);
417 case VCLEVENT_WINDOW_HIDE
:
419 aOldValue
<<= AccessibleStateType::SHOWING
;
420 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED
, aOldValue
, aNewValue
);
423 case VCLEVENT_WINDOW_RESIZE
:
425 NotifyAccessibleEvent( AccessibleEventId::BOUNDRECT_CHANGED
, aOldValue
, aNewValue
);
430 case VCLEVENT_OBJECT_DYING
:
432 if ( m_pDialogWindow
)
434 m_pDialogWindow
->RemoveEventListener( LINK( this, AccessibleDialogWindow
, WindowEventListener
) );
435 m_pDialogWindow
= NULL
;
438 EndListening( *m_pDlgEditor
);
442 EndListening( *m_pDlgEdModel
);
443 m_pDlgEdModel
= NULL
;
445 // dispose all children
446 for ( sal_uInt32 i
= 0; i
< m_aAccessibleChildren
.size(); ++i
)
448 Reference
< XComponent
> xComponent( m_aAccessibleChildren
[i
].rxAccessible
, UNO_QUERY
);
449 if ( xComponent
.is() )
450 xComponent
->dispose();
452 m_aAccessibleChildren
.clear();
463 // -----------------------------------------------------------------------------
465 void AccessibleDialogWindow::FillAccessibleStateSet( utl::AccessibleStateSetHelper
& rStateSet
)
467 if ( m_pDialogWindow
)
469 if ( m_pDialogWindow
->IsEnabled() )
470 rStateSet
.AddState( AccessibleStateType::ENABLED
);
472 rStateSet
.AddState( AccessibleStateType::FOCUSABLE
);
474 if ( m_pDialogWindow
->HasFocus() )
475 rStateSet
.AddState( AccessibleStateType::FOCUSED
);
477 rStateSet
.AddState( AccessibleStateType::VISIBLE
);
479 if ( m_pDialogWindow
->IsVisible() )
480 rStateSet
.AddState( AccessibleStateType::SHOWING
);
482 rStateSet
.AddState( AccessibleStateType::OPAQUE
);
484 rStateSet
.AddState( AccessibleStateType::RESIZABLE
);
488 // -----------------------------------------------------------------------------
489 // OCommonAccessibleComponent
490 // -----------------------------------------------------------------------------
492 awt::Rectangle
AccessibleDialogWindow::implGetBounds() throw (RuntimeException
)
494 awt::Rectangle aBounds
;
495 if ( m_pDialogWindow
)
496 aBounds
= AWTRectangle( Rectangle( m_pDialogWindow
->GetPosPixel(), m_pDialogWindow
->GetSizePixel() ) );
501 // -----------------------------------------------------------------------------
503 // -----------------------------------------------------------------------------
505 void AccessibleDialogWindow::Notify( SfxBroadcaster
&, const SfxHint
& rHint
)
507 if (SdrHint
const* pSdrHint
= dynamic_cast<SdrHint
const*>(&rHint
))
509 switch ( pSdrHint
->GetKind() )
511 case HINT_OBJINSERTED
:
513 if (DlgEdObj
const* pDlgEdObj
= dynamic_cast<DlgEdObj
const*>(pSdrHint
->GetObject()))
515 ChildDescriptor
aDesc(const_cast<DlgEdObj
*>(pDlgEdObj
));
516 if ( IsChildVisible( aDesc
) )
517 InsertChild( aDesc
);
521 case HINT_OBJREMOVED
:
523 if (DlgEdObj
const* pDlgEdObj
= dynamic_cast<DlgEdObj
const*>(pSdrHint
->GetObject()))
524 RemoveChild( ChildDescriptor(const_cast<DlgEdObj
*>(pDlgEdObj
)) );
530 else if (DlgEdHint
const* pDlgEdHint
= dynamic_cast<DlgEdHint
const*>(&rHint
))
532 switch (pDlgEdHint
->GetKind())
534 case DlgEdHint::WINDOWSCROLLED
:
540 case DlgEdHint::LAYERCHANGED
:
542 if (DlgEdObj
* pDlgEdObj
= pDlgEdHint
->GetObject())
543 UpdateChild( ChildDescriptor( pDlgEdObj
) );
546 case DlgEdHint::OBJORDERCHANGED
:
551 case DlgEdHint::SELECTIONCHANGED
:
562 // -----------------------------------------------------------------------------
564 // -----------------------------------------------------------------------------
566 IMPLEMENT_FORWARD_XINTERFACE2( AccessibleDialogWindow
, AccessibleExtendedComponentHelper_BASE
, AccessibleDialogWindow_BASE
)
568 // -----------------------------------------------------------------------------
570 // -----------------------------------------------------------------------------
572 IMPLEMENT_FORWARD_XTYPEPROVIDER2( AccessibleDialogWindow
, AccessibleExtendedComponentHelper_BASE
, AccessibleDialogWindow_BASE
)
574 // -----------------------------------------------------------------------------
576 // -----------------------------------------------------------------------------
578 void AccessibleDialogWindow::disposing()
580 AccessibleExtendedComponentHelper_BASE::disposing();
582 if ( m_pDialogWindow
)
584 m_pDialogWindow
->RemoveEventListener( LINK( this, AccessibleDialogWindow
, WindowEventListener
) );
585 m_pDialogWindow
= NULL
;
588 EndListening( *m_pDlgEditor
);
592 EndListening( *m_pDlgEdModel
);
593 m_pDlgEdModel
= NULL
;
595 // dispose all children
596 for ( sal_uInt32 i
= 0; i
< m_aAccessibleChildren
.size(); ++i
)
598 Reference
< XComponent
> xComponent( m_aAccessibleChildren
[i
].rxAccessible
, UNO_QUERY
);
599 if ( xComponent
.is() )
600 xComponent
->dispose();
602 m_aAccessibleChildren
.clear();
606 // -----------------------------------------------------------------------------
608 // -----------------------------------------------------------------------------
610 OUString
AccessibleDialogWindow::getImplementationName() throw (RuntimeException
)
612 return OUString( "com.sun.star.comp.basctl.AccessibleWindow" );
615 // -----------------------------------------------------------------------------
617 sal_Bool
AccessibleDialogWindow::supportsService( const OUString
& rServiceName
) throw (RuntimeException
)
619 Sequence
< OUString
> aNames( getSupportedServiceNames() );
620 const OUString
* pNames
= aNames
.getConstArray();
621 const OUString
* pEnd
= pNames
+ aNames
.getLength();
622 for ( ; pNames
!= pEnd
&& !pNames
->equals( rServiceName
); ++pNames
)
625 return pNames
!= pEnd
;
628 // -----------------------------------------------------------------------------
630 Sequence
< OUString
> AccessibleDialogWindow::getSupportedServiceNames() throw (RuntimeException
)
632 Sequence
< OUString
> aNames(1);
633 aNames
[0] = "com.sun.star.awt.AccessibleWindow" ;
637 // -----------------------------------------------------------------------------
639 // -----------------------------------------------------------------------------
641 Reference
< XAccessibleContext
> AccessibleDialogWindow::getAccessibleContext( ) throw (RuntimeException
)
643 OExternalLockGuard
aGuard( this );
648 // -----------------------------------------------------------------------------
649 // XAccessibleContext
650 // -----------------------------------------------------------------------------
652 sal_Int32
AccessibleDialogWindow::getAccessibleChildCount() throw (RuntimeException
)
654 OExternalLockGuard
aGuard( this );
656 return m_aAccessibleChildren
.size();
659 // -----------------------------------------------------------------------------
661 Reference
< XAccessible
> AccessibleDialogWindow::getAccessibleChild( sal_Int32 i
) throw (IndexOutOfBoundsException
, RuntimeException
)
663 OExternalLockGuard
aGuard( this );
665 if ( i
< 0 || i
>= getAccessibleChildCount() )
666 throw IndexOutOfBoundsException();
668 Reference
< XAccessible
> xChild
= m_aAccessibleChildren
[i
].rxAccessible
;
671 if ( m_pDialogWindow
)
673 DlgEdObj
* pDlgEdObj
= m_aAccessibleChildren
[i
].pDlgEdObj
;
676 xChild
= new AccessibleDialogControlShape( m_pDialogWindow
, pDlgEdObj
);
678 // insert into child list
679 m_aAccessibleChildren
[i
].rxAccessible
= xChild
;
687 // -----------------------------------------------------------------------------
689 Reference
< XAccessible
> AccessibleDialogWindow::getAccessibleParent( ) throw (RuntimeException
)
691 OExternalLockGuard
aGuard( this );
693 Reference
< XAccessible
> xParent
;
694 if ( m_pDialogWindow
)
696 Window
* pParent
= m_pDialogWindow
->GetAccessibleParentWindow();
698 xParent
= pParent
->GetAccessible();
704 // -----------------------------------------------------------------------------
706 sal_Int32
AccessibleDialogWindow::getAccessibleIndexInParent( ) throw (RuntimeException
)
708 OExternalLockGuard
aGuard( this );
710 sal_Int32 nIndexInParent
= -1;
711 if ( m_pDialogWindow
)
713 Window
* pParent
= m_pDialogWindow
->GetAccessibleParentWindow();
716 for ( sal_uInt16 i
= 0, nCount
= pParent
->GetAccessibleChildWindowCount(); i
< nCount
; ++i
)
718 Window
* pChild
= pParent
->GetAccessibleChildWindow( i
);
719 if ( pChild
== static_cast< Window
* >( m_pDialogWindow
) )
728 return nIndexInParent
;
731 // -----------------------------------------------------------------------------
733 sal_Int16
AccessibleDialogWindow::getAccessibleRole( ) throw (RuntimeException
)
735 OExternalLockGuard
aGuard( this );
737 return AccessibleRole::PANEL
;
740 // -----------------------------------------------------------------------------
742 OUString
AccessibleDialogWindow::getAccessibleDescription( ) throw (RuntimeException
)
744 OExternalLockGuard
aGuard( this );
746 OUString sDescription
;
747 if ( m_pDialogWindow
)
748 sDescription
= m_pDialogWindow
->GetAccessibleDescription();
753 // -----------------------------------------------------------------------------
755 OUString
AccessibleDialogWindow::getAccessibleName( ) throw (RuntimeException
)
757 OExternalLockGuard
aGuard( this );
760 if ( m_pDialogWindow
)
761 sName
= m_pDialogWindow
->GetAccessibleName();
766 // -----------------------------------------------------------------------------
768 Reference
< XAccessibleRelationSet
> AccessibleDialogWindow::getAccessibleRelationSet( ) throw (RuntimeException
)
770 OExternalLockGuard
aGuard( this );
772 utl::AccessibleRelationSetHelper
* pRelationSetHelper
= new utl::AccessibleRelationSetHelper
;
773 Reference
< XAccessibleRelationSet
> xSet
= pRelationSetHelper
;
777 // -----------------------------------------------------------------------------
779 Reference
< XAccessibleStateSet
> AccessibleDialogWindow::getAccessibleStateSet( ) throw (RuntimeException
)
781 OExternalLockGuard
aGuard( this );
783 utl::AccessibleStateSetHelper
* pStateSetHelper
= new utl::AccessibleStateSetHelper
;
784 Reference
< XAccessibleStateSet
> xSet
= pStateSetHelper
;
786 if ( !rBHelper
.bDisposed
&& !rBHelper
.bInDispose
)
788 FillAccessibleStateSet( *pStateSetHelper
);
792 pStateSetHelper
->AddState( AccessibleStateType::DEFUNC
);
798 // -----------------------------------------------------------------------------
800 Locale
AccessibleDialogWindow::getLocale( ) throw (IllegalAccessibleComponentStateException
, RuntimeException
)
802 OExternalLockGuard
aGuard( this );
804 return Application::GetSettings().GetLanguageTag().getLocale();
807 // -----------------------------------------------------------------------------
808 // XAccessibleComponent
809 // -----------------------------------------------------------------------------
811 Reference
< XAccessible
> AccessibleDialogWindow::getAccessibleAtPoint( const awt::Point
& rPoint
) throw (RuntimeException
)
813 OExternalLockGuard
aGuard( this );
815 Reference
< XAccessible
> xChild
;
816 for ( sal_uInt32 i
= 0; i
< m_aAccessibleChildren
.size(); ++i
)
818 Reference
< XAccessible
> xAcc
= getAccessibleChild( i
);
821 Reference
< XAccessibleComponent
> xComp( xAcc
->getAccessibleContext(), UNO_QUERY
);
824 Rectangle aRect
= VCLRectangle( xComp
->getBounds() );
825 Point aPos
= VCLPoint( rPoint
);
826 if ( aRect
.IsInside( aPos
) )
838 // -----------------------------------------------------------------------------
840 void AccessibleDialogWindow::grabFocus( ) throw (RuntimeException
)
842 OExternalLockGuard
aGuard( this );
844 if ( m_pDialogWindow
)
845 m_pDialogWindow
->GrabFocus();
848 // -----------------------------------------------------------------------------
850 sal_Int32
AccessibleDialogWindow::getForeground( ) throw (RuntimeException
)
852 OExternalLockGuard
aGuard( this );
854 sal_Int32 nColor
= 0;
855 if ( m_pDialogWindow
)
857 if ( m_pDialogWindow
->IsControlForeground() )
858 nColor
= m_pDialogWindow
->GetControlForeground().GetColor();
862 if ( m_pDialogWindow
->IsControlFont() )
863 aFont
= m_pDialogWindow
->GetControlFont();
865 aFont
= m_pDialogWindow
->GetFont();
866 nColor
= aFont
.GetColor().GetColor();
873 // -----------------------------------------------------------------------------
875 sal_Int32
AccessibleDialogWindow::getBackground( ) throw (RuntimeException
)
877 OExternalLockGuard
aGuard( this );
879 sal_Int32 nColor
= 0;
880 if ( m_pDialogWindow
)
882 if ( m_pDialogWindow
->IsControlBackground() )
883 nColor
= m_pDialogWindow
->GetControlBackground().GetColor();
885 nColor
= m_pDialogWindow
->GetBackground().GetColor().GetColor();
891 // -----------------------------------------------------------------------------
892 // XAccessibleExtendedComponent
893 // -----------------------------------------------------------------------------
895 Reference
< awt::XFont
> AccessibleDialogWindow::getFont( ) throw (RuntimeException
)
897 OExternalLockGuard
aGuard( this );
899 Reference
< awt::XFont
> xFont
;
900 if ( m_pDialogWindow
)
902 Reference
< awt::XDevice
> xDev( m_pDialogWindow
->GetComponentInterface(), UNO_QUERY
);
906 if ( m_pDialogWindow
->IsControlFont() )
907 aFont
= m_pDialogWindow
->GetControlFont();
909 aFont
= m_pDialogWindow
->GetFont();
910 VCLXFont
* pVCLXFont
= new VCLXFont
;
911 pVCLXFont
->Init( *xDev
.get(), aFont
);
919 // -----------------------------------------------------------------------------
921 OUString
AccessibleDialogWindow::getTitledBorderText( ) throw (RuntimeException
)
923 OExternalLockGuard
aGuard( this );
928 // -----------------------------------------------------------------------------
930 OUString
AccessibleDialogWindow::getToolTipText( ) throw (RuntimeException
)
932 OExternalLockGuard
aGuard( this );
935 if ( m_pDialogWindow
)
936 sText
= m_pDialogWindow
->GetQuickHelpText();
941 // -----------------------------------------------------------------------------
942 // XAccessibleSelection
943 // -----------------------------------------------------------------------------
945 void AccessibleDialogWindow::selectAccessibleChild( sal_Int32 nChildIndex
) throw (IndexOutOfBoundsException
, RuntimeException
)
947 OExternalLockGuard
aGuard( this );
949 if ( nChildIndex
< 0 || nChildIndex
>= getAccessibleChildCount() )
950 throw IndexOutOfBoundsException();
952 if ( m_pDialogWindow
)
954 if (DlgEdObj
* pDlgEdObj
= m_aAccessibleChildren
[nChildIndex
].pDlgEdObj
)
956 SdrView
& rView
= m_pDialogWindow
->GetView();
957 if (SdrPageView
* pPgView
= rView
.GetSdrPageView())
958 rView
.MarkObj(pDlgEdObj
, pPgView
);
963 // -----------------------------------------------------------------------------
965 sal_Bool
AccessibleDialogWindow::isAccessibleChildSelected( sal_Int32 nChildIndex
) throw (IndexOutOfBoundsException
, RuntimeException
)
967 OExternalLockGuard
aGuard( this );
969 if ( nChildIndex
< 0 || nChildIndex
>= getAccessibleChildCount() )
970 throw IndexOutOfBoundsException();
973 if (DlgEdObj
* pDlgEdObj
= m_aAccessibleChildren
[nChildIndex
].pDlgEdObj
)
974 return m_pDialogWindow
->GetView().IsObjMarked(pDlgEdObj
);
978 // -----------------------------------------------------------------------------
980 void AccessibleDialogWindow::clearAccessibleSelection( ) throw (RuntimeException
)
982 OExternalLockGuard
aGuard( this );
984 if ( m_pDialogWindow
)
985 m_pDialogWindow
->GetView().UnmarkAll();
988 // -----------------------------------------------------------------------------
990 void AccessibleDialogWindow::selectAllAccessibleChildren( ) throw (RuntimeException
)
992 OExternalLockGuard
aGuard( this );
994 if ( m_pDialogWindow
)
995 m_pDialogWindow
->GetView().MarkAll();
998 // -----------------------------------------------------------------------------
1000 sal_Int32
AccessibleDialogWindow::getSelectedAccessibleChildCount( ) throw (RuntimeException
)
1002 OExternalLockGuard
aGuard( this );
1006 for ( sal_Int32 i
= 0, nCount
= getAccessibleChildCount(); i
< nCount
; ++i
)
1008 if ( isAccessibleChildSelected( i
) )
1015 // -----------------------------------------------------------------------------
1017 Reference
< XAccessible
> AccessibleDialogWindow::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex
) throw (IndexOutOfBoundsException
, RuntimeException
)
1019 OExternalLockGuard
aGuard( this );
1021 if ( nSelectedChildIndex
< 0 || nSelectedChildIndex
>= getSelectedAccessibleChildCount() )
1022 throw IndexOutOfBoundsException();
1024 Reference
< XAccessible
> xChild
;
1026 for ( sal_Int32 i
= 0, j
= 0, nCount
= getAccessibleChildCount(); i
< nCount
; ++i
)
1028 if ( isAccessibleChildSelected( i
) && ( j
++ == nSelectedChildIndex
) )
1030 xChild
= getAccessibleChild( i
);
1038 // -----------------------------------------------------------------------------
1040 void AccessibleDialogWindow::deselectAccessibleChild( sal_Int32 nChildIndex
) throw (IndexOutOfBoundsException
, RuntimeException
)
1042 OExternalLockGuard
aGuard( this );
1044 if ( nChildIndex
< 0 || nChildIndex
>= getAccessibleChildCount() )
1045 throw IndexOutOfBoundsException();
1047 if ( m_pDialogWindow
)
1049 if (DlgEdObj
* pDlgEdObj
= m_aAccessibleChildren
[nChildIndex
].pDlgEdObj
)
1051 SdrView
& rView
= m_pDialogWindow
->GetView();
1052 SdrPageView
* pPgView
= rView
.GetSdrPageView();
1054 rView
.MarkObj( pDlgEdObj
, pPgView
, true );
1059 // -----------------------------------------------------------------------------
1061 } // namespace basctl
1063 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */