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 <com/sun/star/lang/IndexOutOfBoundsException.hpp>
33 #include <cppuhelper/supportsservice.hxx>
34 #include <unotools/accessiblestatesethelper.hxx>
35 #include <unotools/accessiblerelationsethelper.hxx>
36 #include <toolkit/awt/vclxfont.hxx>
37 #include <toolkit/helper/convert.hxx>
38 #include <vcl/svapp.hxx>
39 #include <vcl/settings.hxx>
44 using namespace ::com::sun::star
;
45 using namespace ::com::sun::star::uno
;
46 using namespace ::com::sun::star::lang
;
47 using namespace ::com::sun::star::accessibility
;
48 using namespace ::comphelper
;
50 AccessibleDialogWindow::ChildDescriptor::ChildDescriptor( DlgEdObj
* _pDlgEdObj
)
51 :pDlgEdObj( _pDlgEdObj
)
52 ,rxAccessible( nullptr )
56 bool AccessibleDialogWindow::ChildDescriptor::operator==( const ChildDescriptor
& rDesc
)
59 if ( pDlgEdObj
== rDesc
.pDlgEdObj
)
66 bool AccessibleDialogWindow::ChildDescriptor::operator<( const ChildDescriptor
& rDesc
) const
69 if ( pDlgEdObj
&& rDesc
.pDlgEdObj
&& pDlgEdObj
->GetOrdNum() < rDesc
.pDlgEdObj
->GetOrdNum() )
76 // class AccessibleDialogWindow
79 AccessibleDialogWindow::AccessibleDialogWindow (basctl::DialogWindow
* pDialogWindow
)
80 : m_pDialogWindow(pDialogWindow
)
81 , m_pDlgEditor(nullptr)
82 , m_pDlgEdModel(nullptr)
84 if ( m_pDialogWindow
)
86 SdrPage
& rPage
= m_pDialogWindow
->GetPage();
87 const size_t nCount
= rPage
.GetObjCount();
89 for ( size_t i
= 0; i
< nCount
; ++i
)
91 if (DlgEdObj
* pDlgEdObj
= dynamic_cast<DlgEdObj
*>(rPage
.GetObj(i
)))
93 ChildDescriptor
aDesc( pDlgEdObj
);
94 if ( IsChildVisible( aDesc
) )
95 m_aAccessibleChildren
.push_back( aDesc
);
99 m_pDialogWindow
->AddEventListener( LINK( this, AccessibleDialogWindow
, WindowEventListener
) );
101 StartListening(m_pDialogWindow
->GetEditor());
103 m_pDlgEdModel
= &m_pDialogWindow
->GetModel();
104 StartListening(*m_pDlgEdModel
);
109 AccessibleDialogWindow::~AccessibleDialogWindow()
111 if ( m_pDialogWindow
)
112 m_pDialogWindow
->RemoveEventListener( LINK( this, AccessibleDialogWindow
, WindowEventListener
) );
115 EndListening( *m_pDlgEditor
);
118 EndListening( *m_pDlgEdModel
);
122 void AccessibleDialogWindow::UpdateFocused()
124 for (ChildDescriptor
& i
: m_aAccessibleChildren
)
126 Reference
< XAccessible
> xChild( i
.rxAccessible
);
129 AccessibleDialogControlShape
* pShape
= static_cast< AccessibleDialogControlShape
* >( xChild
.get() );
131 pShape
->SetFocused( pShape
->IsFocused() );
137 void AccessibleDialogWindow::UpdateSelected()
139 NotifyAccessibleEvent( AccessibleEventId::SELECTION_CHANGED
, Any(), Any() );
141 for (ChildDescriptor
& i
: m_aAccessibleChildren
)
143 Reference
< XAccessible
> xChild( i
.rxAccessible
);
146 AccessibleDialogControlShape
* pShape
= static_cast< AccessibleDialogControlShape
* >( xChild
.get() );
148 pShape
->SetSelected( pShape
->IsSelected() );
154 void AccessibleDialogWindow::UpdateBounds()
156 for (ChildDescriptor
& i
: m_aAccessibleChildren
)
158 Reference
< XAccessible
> xChild( i
.rxAccessible
);
161 AccessibleDialogControlShape
* pShape
= static_cast< AccessibleDialogControlShape
* >( xChild
.get() );
163 pShape
->SetBounds( pShape
->GetBounds() );
169 bool AccessibleDialogWindow::IsChildVisible( const ChildDescriptor
& rDesc
)
171 bool bVisible
= false;
173 if ( m_pDialogWindow
)
175 // first check, if the shape is in a visible layer
176 SdrLayerAdmin
& rLayerAdmin
= m_pDialogWindow
->GetModel().GetLayerAdmin();
177 DlgEdObj
* pDlgEdObj
= rDesc
.pDlgEdObj
;
180 SdrLayerID nLayerId
= pDlgEdObj
->GetLayer();
181 const SdrLayer
* pSdrLayer
= rLayerAdmin
.GetLayerPerID( nLayerId
);
184 OUString aLayerName
= pSdrLayer
->GetName();
185 SdrView
& rView
= m_pDialogWindow
->GetView();
186 if (rView
.IsLayerVisible(aLayerName
))
188 // get the bounding box of the shape in logic units
189 tools::Rectangle aRect
= pDlgEdObj
->GetSnapRect();
191 // transform coordinates relative to the parent
192 MapMode aMap
= m_pDialogWindow
->GetMapMode();
193 Point aOrg
= aMap
.GetOrigin();
194 aRect
.Move( aOrg
.X(), aOrg
.Y() );
196 // convert logic units to pixel
197 aRect
= m_pDialogWindow
->LogicToPixel( aRect
, MapMode(MapUnit::Map100thMM
) );
199 // check, if the shape's bounding box intersects with the bounding box of its parent
200 tools::Rectangle
aParentRect( Point( 0, 0 ), m_pDialogWindow
->GetSizePixel() );
201 if ( aParentRect
.IsOver( aRect
) )
212 void AccessibleDialogWindow::InsertChild( const ChildDescriptor
& rDesc
)
214 // check, if object is already in child list
215 AccessibleChildren::iterator aIter
= std::find( m_aAccessibleChildren
.begin(), m_aAccessibleChildren
.end(), rDesc
);
217 // if not found, insert in child list
218 if ( aIter
== m_aAccessibleChildren
.end() )
220 // insert entry in child list
221 m_aAccessibleChildren
.push_back( rDesc
);
223 // get the accessible of the inserted child
224 Reference
< XAccessible
> xChild( getAccessibleChild( m_aAccessibleChildren
.size() - 1 ) );
229 // send accessible child event
232 Any aOldValue
, aNewValue
;
233 aNewValue
<<= xChild
;
234 NotifyAccessibleEvent( AccessibleEventId::CHILD
, aOldValue
, aNewValue
);
240 void AccessibleDialogWindow::RemoveChild( const ChildDescriptor
& rDesc
)
242 // find object in child list
243 AccessibleChildren::iterator aIter
= std::find( m_aAccessibleChildren
.begin(), m_aAccessibleChildren
.end(), rDesc
);
245 // if found, remove from child list
246 if ( aIter
!= m_aAccessibleChildren
.end() )
248 // get the accessible of the removed child
249 Reference
< XAccessible
> xChild( aIter
->rxAccessible
);
251 // remove entry from child list
252 m_aAccessibleChildren
.erase( aIter
);
254 // send accessible child event
257 Any aOldValue
, aNewValue
;
258 aOldValue
<<= xChild
;
259 NotifyAccessibleEvent( AccessibleEventId::CHILD
, aOldValue
, aNewValue
);
261 Reference
< XComponent
> xComponent( xChild
, UNO_QUERY
);
262 if ( xComponent
.is() )
263 xComponent
->dispose();
269 void AccessibleDialogWindow::UpdateChild( const ChildDescriptor
& rDesc
)
271 if ( IsChildVisible( rDesc
) )
273 // if the object is not in the child list, insert child
274 InsertChild( rDesc
);
278 // if the object is in the child list, remove child
279 RemoveChild( rDesc
);
284 void AccessibleDialogWindow::UpdateChildren()
286 if ( m_pDialogWindow
)
288 SdrPage
& rPage
= m_pDialogWindow
->GetPage();
289 for ( size_t i
= 0, nCount
= rPage
.GetObjCount(); i
< nCount
; ++i
)
290 if (DlgEdObj
* pDlgEdObj
= dynamic_cast<DlgEdObj
*>(rPage
.GetObj(i
)))
291 UpdateChild( ChildDescriptor( pDlgEdObj
) );
296 void AccessibleDialogWindow::SortChildren()
299 std::sort( m_aAccessibleChildren
.begin(), m_aAccessibleChildren
.end() );
303 IMPL_LINK( AccessibleDialogWindow
, WindowEventListener
, VclWindowEvent
&, rEvent
, void )
305 DBG_ASSERT(rEvent
.GetWindow(), "AccessibleDialogWindow::WindowEventListener: no window!");
306 if (!rEvent
.GetWindow()->IsAccessibilityEventsSuppressed() || rEvent
.GetId() == VclEventId::ObjectDying
)
307 ProcessWindowEvent(rEvent
);
311 void AccessibleDialogWindow::ProcessWindowEvent( const VclWindowEvent
& rVclWindowEvent
)
313 Any aOldValue
, aNewValue
;
315 switch ( rVclWindowEvent
.GetId() )
317 case VclEventId::WindowEnabled
:
319 aNewValue
<<= AccessibleStateType::ENABLED
;
320 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED
, aOldValue
, aNewValue
);
323 case VclEventId::WindowDisabled
:
325 aOldValue
<<= AccessibleStateType::ENABLED
;
326 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED
, aOldValue
, aNewValue
);
329 case VclEventId::WindowActivate
:
331 aNewValue
<<= AccessibleStateType::ACTIVE
;
332 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED
, aOldValue
, aNewValue
);
335 case VclEventId::WindowDeactivate
:
337 aOldValue
<<= AccessibleStateType::ACTIVE
;
338 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED
, aOldValue
, aNewValue
);
341 case VclEventId::WindowGetFocus
:
343 aNewValue
<<= AccessibleStateType::FOCUSED
;
344 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED
, aOldValue
, aNewValue
);
347 case VclEventId::WindowLoseFocus
:
349 aOldValue
<<= AccessibleStateType::FOCUSED
;
350 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED
, aOldValue
, aNewValue
);
353 case VclEventId::WindowShow
:
355 aNewValue
<<= AccessibleStateType::SHOWING
;
356 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED
, aOldValue
, aNewValue
);
359 case VclEventId::WindowHide
:
361 aOldValue
<<= AccessibleStateType::SHOWING
;
362 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED
, aOldValue
, aNewValue
);
365 case VclEventId::WindowResize
:
367 NotifyAccessibleEvent( AccessibleEventId::BOUNDRECT_CHANGED
, aOldValue
, aNewValue
);
372 case VclEventId::ObjectDying
:
374 if ( m_pDialogWindow
)
376 m_pDialogWindow
->RemoveEventListener( LINK( this, AccessibleDialogWindow
, WindowEventListener
) );
377 m_pDialogWindow
= nullptr;
380 EndListening( *m_pDlgEditor
);
381 m_pDlgEditor
= nullptr;
384 EndListening( *m_pDlgEdModel
);
385 m_pDlgEdModel
= nullptr;
387 // dispose all children
388 for (ChildDescriptor
& i
: m_aAccessibleChildren
)
390 Reference
< XComponent
> xComponent( i
.rxAccessible
, UNO_QUERY
);
391 if ( xComponent
.is() )
392 xComponent
->dispose();
394 m_aAccessibleChildren
.clear();
406 void AccessibleDialogWindow::FillAccessibleStateSet( utl::AccessibleStateSetHelper
& rStateSet
)
408 if ( m_pDialogWindow
)
410 if ( m_pDialogWindow
->IsEnabled() )
411 rStateSet
.AddState( AccessibleStateType::ENABLED
);
413 rStateSet
.AddState( AccessibleStateType::FOCUSABLE
);
415 if ( m_pDialogWindow
->HasFocus() )
416 rStateSet
.AddState( AccessibleStateType::FOCUSED
);
418 rStateSet
.AddState( AccessibleStateType::VISIBLE
);
420 if ( m_pDialogWindow
->IsVisible() )
421 rStateSet
.AddState( AccessibleStateType::SHOWING
);
423 rStateSet
.AddState( AccessibleStateType::OPAQUE
);
425 rStateSet
.AddState( AccessibleStateType::RESIZABLE
);
430 // OCommonAccessibleComponent
433 awt::Rectangle
AccessibleDialogWindow::implGetBounds()
435 awt::Rectangle aBounds
;
436 if ( m_pDialogWindow
)
437 aBounds
= AWTRectangle( tools::Rectangle( m_pDialogWindow
->GetPosPixel(), m_pDialogWindow
->GetSizePixel() ) );
446 void AccessibleDialogWindow::Notify( SfxBroadcaster
&, const SfxHint
& rHint
)
448 if (SdrHint
const* pSdrHint
= dynamic_cast<SdrHint
const*>(&rHint
))
450 switch ( pSdrHint
->GetKind() )
452 case SdrHintKind::ObjectInserted
:
454 if (DlgEdObj
const* pDlgEdObj
= dynamic_cast<DlgEdObj
const*>(pSdrHint
->GetObject()))
456 ChildDescriptor
aDesc(const_cast<DlgEdObj
*>(pDlgEdObj
));
457 if ( IsChildVisible( aDesc
) )
458 InsertChild( aDesc
);
462 case SdrHintKind::ObjectRemoved
:
464 if (DlgEdObj
const* pDlgEdObj
= dynamic_cast<DlgEdObj
const*>(pSdrHint
->GetObject()))
465 RemoveChild( ChildDescriptor(const_cast<DlgEdObj
*>(pDlgEdObj
)) );
471 else if (DlgEdHint
const* pDlgEdHint
= dynamic_cast<DlgEdHint
const*>(&rHint
))
473 switch (pDlgEdHint
->GetKind())
475 case DlgEdHint::WINDOWSCROLLED
:
481 case DlgEdHint::LAYERCHANGED
:
483 if (DlgEdObj
* pDlgEdObj
= pDlgEdHint
->GetObject())
484 UpdateChild( ChildDescriptor( pDlgEdObj
) );
487 case DlgEdHint::OBJORDERCHANGED
:
492 case DlgEdHint::SELECTIONCHANGED
:
507 IMPLEMENT_FORWARD_XINTERFACE2( AccessibleDialogWindow
, OAccessibleExtendedComponentHelper
, AccessibleDialogWindow_BASE
)
513 IMPLEMENT_FORWARD_XTYPEPROVIDER2( AccessibleDialogWindow
, OAccessibleExtendedComponentHelper
, AccessibleDialogWindow_BASE
)
519 void AccessibleDialogWindow::disposing()
521 OAccessibleExtendedComponentHelper::disposing();
523 if ( m_pDialogWindow
)
525 m_pDialogWindow
->RemoveEventListener( LINK( this, AccessibleDialogWindow
, WindowEventListener
) );
526 m_pDialogWindow
= nullptr;
529 EndListening( *m_pDlgEditor
);
530 m_pDlgEditor
= nullptr;
533 EndListening( *m_pDlgEdModel
);
534 m_pDlgEdModel
= nullptr;
536 // dispose all children
537 for (ChildDescriptor
& i
: m_aAccessibleChildren
)
539 Reference
< XComponent
> xComponent( i
.rxAccessible
, UNO_QUERY
);
540 if ( xComponent
.is() )
541 xComponent
->dispose();
543 m_aAccessibleChildren
.clear();
548 OUString
AccessibleDialogWindow::getImplementationName()
550 return OUString( "com.sun.star.comp.basctl.AccessibleWindow" );
553 sal_Bool
AccessibleDialogWindow::supportsService( const OUString
& rServiceName
)
555 return cppu::supportsService(this, rServiceName
);
558 Sequence
< OUString
> AccessibleDialogWindow::getSupportedServiceNames()
560 return { "com.sun.star.awt.AccessibleWindow" };
564 Reference
< XAccessibleContext
> AccessibleDialogWindow::getAccessibleContext( )
569 // XAccessibleContext
570 sal_Int32
AccessibleDialogWindow::getAccessibleChildCount()
572 OExternalLockGuard
aGuard( this );
574 return m_aAccessibleChildren
.size();
578 Reference
< XAccessible
> AccessibleDialogWindow::getAccessibleChild( sal_Int32 i
)
580 OExternalLockGuard
aGuard( this );
582 if ( i
< 0 || i
>= getAccessibleChildCount() )
583 throw IndexOutOfBoundsException();
585 Reference
< XAccessible
> xChild
= m_aAccessibleChildren
[i
].rxAccessible
;
588 if ( m_pDialogWindow
)
590 DlgEdObj
* pDlgEdObj
= m_aAccessibleChildren
[i
].pDlgEdObj
;
593 xChild
= new AccessibleDialogControlShape( m_pDialogWindow
, pDlgEdObj
);
595 // insert into child list
596 m_aAccessibleChildren
[i
].rxAccessible
= xChild
;
605 Reference
< XAccessible
> AccessibleDialogWindow::getAccessibleParent( )
607 OExternalLockGuard
aGuard( this );
609 Reference
< XAccessible
> xParent
;
610 if ( m_pDialogWindow
)
612 vcl::Window
* pParent
= m_pDialogWindow
->GetAccessibleParentWindow();
614 xParent
= pParent
->GetAccessible();
621 sal_Int32
AccessibleDialogWindow::getAccessibleIndexInParent( )
623 OExternalLockGuard
aGuard( this );
625 sal_Int32 nIndexInParent
= -1;
626 if ( m_pDialogWindow
)
628 vcl::Window
* pParent
= m_pDialogWindow
->GetAccessibleParentWindow();
631 for ( sal_uInt16 i
= 0, nCount
= pParent
->GetAccessibleChildWindowCount(); i
< nCount
; ++i
)
633 vcl::Window
* pChild
= pParent
->GetAccessibleChildWindow( i
);
634 if ( pChild
== static_cast< vcl::Window
* >( m_pDialogWindow
) )
643 return nIndexInParent
;
647 sal_Int16
AccessibleDialogWindow::getAccessibleRole( )
649 OExternalLockGuard
aGuard( this );
651 return AccessibleRole::PANEL
;
655 OUString
AccessibleDialogWindow::getAccessibleDescription( )
657 OExternalLockGuard
aGuard( this );
659 OUString sDescription
;
660 if ( m_pDialogWindow
)
661 sDescription
= m_pDialogWindow
->GetAccessibleDescription();
667 OUString
AccessibleDialogWindow::getAccessibleName( )
669 OExternalLockGuard
aGuard( this );
672 if ( m_pDialogWindow
)
673 sName
= m_pDialogWindow
->GetAccessibleName();
679 Reference
< XAccessibleRelationSet
> AccessibleDialogWindow::getAccessibleRelationSet( )
681 OExternalLockGuard
aGuard( this );
683 utl::AccessibleRelationSetHelper
* pRelationSetHelper
= new utl::AccessibleRelationSetHelper
;
684 Reference
< XAccessibleRelationSet
> xSet
= pRelationSetHelper
;
689 Reference
< XAccessibleStateSet
> AccessibleDialogWindow::getAccessibleStateSet( )
691 OExternalLockGuard
aGuard( this );
693 utl::AccessibleStateSetHelper
* pStateSetHelper
= new utl::AccessibleStateSetHelper
;
694 Reference
< XAccessibleStateSet
> xSet
= pStateSetHelper
;
696 if ( !rBHelper
.bDisposed
&& !rBHelper
.bInDispose
)
698 FillAccessibleStateSet( *pStateSetHelper
);
702 pStateSetHelper
->AddState( AccessibleStateType::DEFUNC
);
709 Locale
AccessibleDialogWindow::getLocale( )
711 OExternalLockGuard
aGuard( this );
713 return Application::GetSettings().GetLanguageTag().getLocale();
717 // XAccessibleComponent
720 Reference
< XAccessible
> AccessibleDialogWindow::getAccessibleAtPoint( const awt::Point
& rPoint
)
722 OExternalLockGuard
aGuard( this );
724 Reference
< XAccessible
> xChild
;
725 for ( size_t i
= 0; i
< m_aAccessibleChildren
.size(); ++i
)
727 Reference
< XAccessible
> xAcc
= getAccessibleChild( i
);
730 Reference
< XAccessibleComponent
> xComp( xAcc
->getAccessibleContext(), UNO_QUERY
);
733 tools::Rectangle aRect
= VCLRectangle( xComp
->getBounds() );
734 Point aPos
= VCLPoint( rPoint
);
735 if ( aRect
.IsInside( aPos
) )
748 void AccessibleDialogWindow::grabFocus( )
750 OExternalLockGuard
aGuard( this );
752 if ( m_pDialogWindow
)
753 m_pDialogWindow
->GrabFocus();
757 sal_Int32
AccessibleDialogWindow::getForeground( )
759 OExternalLockGuard
aGuard( this );
762 if ( m_pDialogWindow
)
764 if ( m_pDialogWindow
->IsControlForeground() )
765 nColor
= m_pDialogWindow
->GetControlForeground();
769 if ( m_pDialogWindow
->IsControlFont() )
770 aFont
= m_pDialogWindow
->GetControlFont();
772 aFont
= m_pDialogWindow
->GetFont();
773 nColor
= aFont
.GetColor();
777 return sal_Int32(nColor
);
781 sal_Int32
AccessibleDialogWindow::getBackground( )
783 OExternalLockGuard
aGuard( this );
786 if ( m_pDialogWindow
)
788 if ( m_pDialogWindow
->IsControlBackground() )
789 nColor
= m_pDialogWindow
->GetControlBackground();
791 nColor
= m_pDialogWindow
->GetBackground().GetColor();
794 return sal_Int32(nColor
);
798 // XAccessibleExtendedComponent
801 Reference
< awt::XFont
> AccessibleDialogWindow::getFont( )
803 OExternalLockGuard
aGuard( this );
805 Reference
< awt::XFont
> xFont
;
806 if ( m_pDialogWindow
)
808 Reference
< awt::XDevice
> xDev( m_pDialogWindow
->GetComponentInterface(), UNO_QUERY
);
812 if ( m_pDialogWindow
->IsControlFont() )
813 aFont
= m_pDialogWindow
->GetControlFont();
815 aFont
= m_pDialogWindow
->GetFont();
816 VCLXFont
* pVCLXFont
= new VCLXFont
;
817 pVCLXFont
->Init( *xDev
.get(), aFont
);
826 OUString
AccessibleDialogWindow::getTitledBorderText( )
828 OExternalLockGuard
aGuard( this );
834 OUString
AccessibleDialogWindow::getToolTipText( )
836 OExternalLockGuard
aGuard( this );
839 if ( m_pDialogWindow
)
840 sText
= m_pDialogWindow
->GetQuickHelpText();
846 // XAccessibleSelection
849 void AccessibleDialogWindow::selectAccessibleChild( sal_Int32 nChildIndex
)
851 OExternalLockGuard
aGuard( this );
853 if ( nChildIndex
< 0 || nChildIndex
>= getAccessibleChildCount() )
854 throw IndexOutOfBoundsException();
856 if ( m_pDialogWindow
)
858 if (DlgEdObj
* pDlgEdObj
= m_aAccessibleChildren
[nChildIndex
].pDlgEdObj
)
860 SdrView
& rView
= m_pDialogWindow
->GetView();
861 if (SdrPageView
* pPgView
= rView
.GetSdrPageView())
862 rView
.MarkObj(pDlgEdObj
, pPgView
);
868 sal_Bool
AccessibleDialogWindow::isAccessibleChildSelected( sal_Int32 nChildIndex
)
870 OExternalLockGuard
aGuard( this );
872 if ( nChildIndex
< 0 || nChildIndex
>= getAccessibleChildCount() )
873 throw IndexOutOfBoundsException();
876 if (DlgEdObj
* pDlgEdObj
= m_aAccessibleChildren
[nChildIndex
].pDlgEdObj
)
877 return m_pDialogWindow
->GetView().IsObjMarked(pDlgEdObj
);
882 void AccessibleDialogWindow::clearAccessibleSelection()
884 OExternalLockGuard
aGuard( this );
886 if ( m_pDialogWindow
)
887 m_pDialogWindow
->GetView().UnmarkAll();
891 void AccessibleDialogWindow::selectAllAccessibleChildren( )
893 OExternalLockGuard
aGuard( this );
895 if ( m_pDialogWindow
)
896 m_pDialogWindow
->GetView().MarkAll();
900 sal_Int32
AccessibleDialogWindow::getSelectedAccessibleChildCount( )
902 OExternalLockGuard
aGuard( this );
906 for ( sal_Int32 i
= 0, nCount
= getAccessibleChildCount(); i
< nCount
; ++i
)
908 if ( isAccessibleChildSelected( i
) )
916 Reference
< XAccessible
> AccessibleDialogWindow::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex
)
918 OExternalLockGuard
aGuard( this );
920 if ( nSelectedChildIndex
< 0 || nSelectedChildIndex
>= getSelectedAccessibleChildCount() )
921 throw IndexOutOfBoundsException();
923 Reference
< XAccessible
> xChild
;
925 for ( sal_Int32 i
= 0, j
= 0, nCount
= getAccessibleChildCount(); i
< nCount
; ++i
)
927 if ( isAccessibleChildSelected( i
) && ( j
++ == nSelectedChildIndex
) )
929 xChild
= getAccessibleChild( i
);
938 void AccessibleDialogWindow::deselectAccessibleChild( sal_Int32 nChildIndex
)
940 OExternalLockGuard
aGuard( this );
942 if ( nChildIndex
< 0 || nChildIndex
>= getAccessibleChildCount() )
943 throw IndexOutOfBoundsException();
945 if ( m_pDialogWindow
)
947 if (DlgEdObj
* pDlgEdObj
= m_aAccessibleChildren
[nChildIndex
].pDlgEdObj
)
949 SdrView
& rView
= m_pDialogWindow
->GetView();
950 SdrPageView
* pPgView
= rView
.GetSdrPageView();
952 rView
.MarkObj( pDlgEdObj
, pPgView
, true );
958 } // namespace basctl
960 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */