android: Update app-specific/MIME type icons
[LibreOffice.git] / basctl / source / accessibility / accessibledialogwindow.cxx
blob71a41aa6848aaca5c677c473531824bdf6c6c0a6
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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>
24 #include <dlged.hxx>
25 #include <dlgedmod.hxx>
26 #include <dlgedpage.hxx>
27 #include <dlgedview.hxx>
28 #include <dlgedobj.hxx>
29 #include <com/sun/star/awt/XVclWindowPeer.hpp>
30 #include <com/sun/star/accessibility/AccessibleEventId.hpp>
31 #include <com/sun/star/accessibility/AccessibleRole.hpp>
32 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
33 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
34 #include <comphelper/accessiblecontexthelper.hxx>
35 #include <cppuhelper/supportsservice.hxx>
36 #include <tools/debug.hxx>
37 #include <unotools/accessiblerelationsethelper.hxx>
38 #include <toolkit/awt/vclxfont.hxx>
39 #include <toolkit/helper/convert.hxx>
40 #include <vcl/svapp.hxx>
41 #include <vcl/settings.hxx>
42 #include <i18nlangtag/languagetag.hxx>
44 namespace basctl
47 using namespace ::com::sun::star;
48 using namespace ::com::sun::star::uno;
49 using namespace ::com::sun::star::lang;
50 using namespace ::com::sun::star::accessibility;
51 using namespace ::comphelper;
53 AccessibleDialogWindow::ChildDescriptor::ChildDescriptor( DlgEdObj* _pDlgEdObj )
54 :pDlgEdObj( _pDlgEdObj )
58 bool AccessibleDialogWindow::ChildDescriptor::operator==( const ChildDescriptor& rDesc )
60 bool bRet = false;
61 if ( pDlgEdObj == rDesc.pDlgEdObj )
62 bRet = true;
64 return bRet;
68 bool AccessibleDialogWindow::ChildDescriptor::operator<( const ChildDescriptor& rDesc ) const
70 bool bRet = false;
71 if ( pDlgEdObj && rDesc.pDlgEdObj && pDlgEdObj->GetOrdNum() < rDesc.pDlgEdObj->GetOrdNum() )
72 bRet = true;
74 return bRet;
80 AccessibleDialogWindow::AccessibleDialogWindow (basctl::DialogWindow* pDialogWindow)
81 : m_pDialogWindow(pDialogWindow)
82 , m_pDlgEdModel(nullptr)
84 if ( !m_pDialogWindow )
85 return;
87 SdrPage& rPage = m_pDialogWindow->GetPage();
88 const size_t nCount = rPage.GetObjCount();
90 for ( size_t i = 0; i < nCount; ++i )
92 if (DlgEdObj* pDlgEdObj = dynamic_cast<DlgEdObj*>(rPage.GetObj(i)))
94 ChildDescriptor aDesc( pDlgEdObj );
95 if ( IsChildVisible( aDesc ) )
96 m_aAccessibleChildren.push_back( aDesc );
100 m_pDialogWindow->AddEventListener( LINK( this, AccessibleDialogWindow, WindowEventListener ) );
102 StartListening(m_pDialogWindow->GetEditor());
104 m_pDlgEdModel = &m_pDialogWindow->GetModel();
105 StartListening(*m_pDlgEdModel);
109 AccessibleDialogWindow::~AccessibleDialogWindow()
111 if ( m_pDialogWindow )
112 m_pDialogWindow->RemoveEventListener( LINK( this, AccessibleDialogWindow, WindowEventListener ) );
114 if ( m_pDlgEdModel )
115 EndListening( *m_pDlgEdModel );
119 void AccessibleDialogWindow::UpdateFocused()
121 for (const ChildDescriptor & i : m_aAccessibleChildren)
123 Reference< XAccessible > xChild( i.rxAccessible );
124 if ( xChild.is() )
126 AccessibleDialogControlShape* pShape = static_cast< AccessibleDialogControlShape* >( xChild.get() );
127 if ( pShape )
128 pShape->SetFocused( pShape->IsFocused() );
134 void AccessibleDialogWindow::UpdateSelected()
136 NotifyAccessibleEvent( AccessibleEventId::SELECTION_CHANGED, Any(), Any() );
138 for (const ChildDescriptor & i : m_aAccessibleChildren)
140 Reference< XAccessible > xChild( i.rxAccessible );
141 if ( xChild.is() )
143 AccessibleDialogControlShape* pShape = static_cast< AccessibleDialogControlShape* >( xChild.get() );
144 if ( pShape )
145 pShape->SetSelected( pShape->IsSelected() );
151 void AccessibleDialogWindow::UpdateBounds()
153 for (const ChildDescriptor & i : m_aAccessibleChildren)
155 Reference< XAccessible > xChild( i.rxAccessible );
156 if ( xChild.is() )
158 AccessibleDialogControlShape* pShape = static_cast< AccessibleDialogControlShape* >( xChild.get() );
159 if ( pShape )
160 pShape->SetBounds( pShape->GetBounds() );
166 bool AccessibleDialogWindow::IsChildVisible( const ChildDescriptor& rDesc )
168 bool bVisible = false;
170 if ( m_pDialogWindow )
172 // first check, if the shape is in a visible layer
173 SdrLayerAdmin& rLayerAdmin = m_pDialogWindow->GetModel().GetLayerAdmin();
174 DlgEdObj* pDlgEdObj = rDesc.pDlgEdObj;
175 if ( pDlgEdObj )
177 SdrLayerID nLayerId = pDlgEdObj->GetLayer();
178 const SdrLayer* pSdrLayer = rLayerAdmin.GetLayerPerID( nLayerId );
179 if ( pSdrLayer )
181 const OUString& aLayerName = pSdrLayer->GetName();
182 SdrView& rView = m_pDialogWindow->GetView();
183 if (rView.IsLayerVisible(aLayerName))
185 // get the bounding box of the shape in logic units
186 tools::Rectangle aRect = pDlgEdObj->GetSnapRect();
188 // transform coordinates relative to the parent
189 MapMode aMap = m_pDialogWindow->GetMapMode();
190 Point aOrg = aMap.GetOrigin();
191 aRect.Move( aOrg.X(), aOrg.Y() );
193 // convert logic units to pixel
194 aRect = m_pDialogWindow->LogicToPixel( aRect, MapMode(MapUnit::Map100thMM) );
196 // check, if the shape's bounding box intersects with the bounding box of its parent
197 tools::Rectangle aParentRect( Point( 0, 0 ), m_pDialogWindow->GetSizePixel() );
198 if ( aParentRect.Overlaps( aRect ) )
199 bVisible = true;
205 return bVisible;
209 void AccessibleDialogWindow::InsertChild( const ChildDescriptor& rDesc )
211 // check, if object is already in child list
212 AccessibleChildren::iterator aIter = std::find( m_aAccessibleChildren.begin(), m_aAccessibleChildren.end(), rDesc );
214 // if not found, insert in child list
215 if ( aIter != m_aAccessibleChildren.end() )
216 return;
218 // insert entry in child list
219 m_aAccessibleChildren.push_back( rDesc );
221 // get the accessible of the inserted child
222 Reference< XAccessible > xChild( getAccessibleChild( m_aAccessibleChildren.size() - 1 ) );
224 // sort child list
225 SortChildren();
227 // send accessible child event
228 if ( xChild.is() )
230 Any aOldValue, aNewValue;
231 aNewValue <<= xChild;
232 NotifyAccessibleEvent( AccessibleEventId::CHILD, aOldValue, aNewValue );
237 void AccessibleDialogWindow::RemoveChild( const ChildDescriptor& rDesc )
239 // find object in child list
240 AccessibleChildren::iterator aIter = std::find( m_aAccessibleChildren.begin(), m_aAccessibleChildren.end(), rDesc );
242 // if found, remove from child list
243 if ( aIter == m_aAccessibleChildren.end() )
244 return;
246 // get the accessible of the removed child
247 Reference< XAccessible > xChild( aIter->rxAccessible );
249 // remove entry from child list
250 m_aAccessibleChildren.erase( aIter );
252 // send accessible child event
253 if ( xChild.is() )
255 Any aOldValue, aNewValue;
256 aOldValue <<= xChild;
257 NotifyAccessibleEvent( AccessibleEventId::CHILD, aOldValue, aNewValue );
259 Reference< XComponent > xComponent( xChild, UNO_QUERY );
260 if ( xComponent.is() )
261 xComponent->dispose();
266 void AccessibleDialogWindow::UpdateChild( const ChildDescriptor& rDesc )
268 if ( IsChildVisible( rDesc ) )
270 // if the object is not in the child list, insert child
271 InsertChild( rDesc );
273 else
275 // if the object is in the child list, remove child
276 RemoveChild( rDesc );
281 void AccessibleDialogWindow::UpdateChildren()
283 if ( m_pDialogWindow )
285 SdrPage& rPage = m_pDialogWindow->GetPage();
286 for ( size_t i = 0, nCount = rPage.GetObjCount(); i < nCount; ++i )
287 if (DlgEdObj* pDlgEdObj = dynamic_cast<DlgEdObj*>(rPage.GetObj(i)))
288 UpdateChild( ChildDescriptor( pDlgEdObj ) );
293 void AccessibleDialogWindow::SortChildren()
295 // sort child list
296 std::sort( m_aAccessibleChildren.begin(), m_aAccessibleChildren.end() );
300 IMPL_LINK( AccessibleDialogWindow, WindowEventListener, VclWindowEvent&, rEvent, void )
302 DBG_ASSERT(rEvent.GetWindow(), "AccessibleDialogWindow::WindowEventListener: no window!");
303 if (!rEvent.GetWindow()->IsAccessibilityEventsSuppressed() || rEvent.GetId() == VclEventId::ObjectDying)
304 ProcessWindowEvent(rEvent);
308 void AccessibleDialogWindow::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
310 Any aOldValue, aNewValue;
312 switch ( rVclWindowEvent.GetId() )
314 case VclEventId::WindowEnabled:
316 aNewValue <<= AccessibleStateType::ENABLED;
317 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
319 break;
320 case VclEventId::WindowDisabled:
322 aOldValue <<= AccessibleStateType::ENABLED;
323 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
325 break;
326 case VclEventId::WindowActivate:
328 aNewValue <<= AccessibleStateType::ACTIVE;
329 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
331 break;
332 case VclEventId::WindowDeactivate:
334 aOldValue <<= AccessibleStateType::ACTIVE;
335 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
337 break;
338 case VclEventId::WindowGetFocus:
340 aNewValue <<= AccessibleStateType::FOCUSED;
341 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
343 break;
344 case VclEventId::WindowLoseFocus:
346 aOldValue <<= AccessibleStateType::FOCUSED;
347 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
349 break;
350 case VclEventId::WindowShow:
352 aNewValue <<= AccessibleStateType::SHOWING;
353 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
355 break;
356 case VclEventId::WindowHide:
358 aOldValue <<= AccessibleStateType::SHOWING;
359 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
361 break;
362 case VclEventId::WindowResize:
364 NotifyAccessibleEvent( AccessibleEventId::BOUNDRECT_CHANGED, aOldValue, aNewValue );
365 UpdateChildren();
366 UpdateBounds();
368 break;
369 case VclEventId::ObjectDying:
371 if ( m_pDialogWindow )
373 m_pDialogWindow->RemoveEventListener( LINK( this, AccessibleDialogWindow, WindowEventListener ) );
374 m_pDialogWindow = nullptr;
376 if ( m_pDlgEdModel )
377 EndListening( *m_pDlgEdModel );
378 m_pDlgEdModel = nullptr;
380 // dispose all children
381 for (const ChildDescriptor & i : m_aAccessibleChildren)
383 Reference< XComponent > xComponent( i.rxAccessible, UNO_QUERY );
384 if ( xComponent.is() )
385 xComponent->dispose();
387 m_aAccessibleChildren.clear();
390 break;
391 default:
394 break;
399 void AccessibleDialogWindow::FillAccessibleStateSet( sal_Int64& rStateSet )
401 if ( !m_pDialogWindow )
402 return;
404 if ( m_pDialogWindow->IsEnabled() )
405 rStateSet |= AccessibleStateType::ENABLED;
407 rStateSet |= AccessibleStateType::FOCUSABLE;
409 if ( m_pDialogWindow->HasFocus() )
410 rStateSet |= AccessibleStateType::FOCUSED;
412 rStateSet |= AccessibleStateType::VISIBLE;
414 if ( m_pDialogWindow->IsVisible() )
415 rStateSet |= AccessibleStateType::SHOWING;
417 rStateSet |= AccessibleStateType::OPAQUE;
419 rStateSet |= AccessibleStateType::RESIZABLE;
423 // OCommonAccessibleComponent
426 awt::Rectangle AccessibleDialogWindow::implGetBounds()
428 awt::Rectangle aBounds;
429 if ( m_pDialogWindow )
430 aBounds = AWTRectangle( tools::Rectangle( m_pDialogWindow->GetPosPixel(), m_pDialogWindow->GetSizePixel() ) );
432 return aBounds;
436 // SfxListener
439 void AccessibleDialogWindow::Notify( SfxBroadcaster&, const SfxHint& rHint )
441 if (SdrHint const* pSdrHint = dynamic_cast<SdrHint const*>(&rHint))
443 switch ( pSdrHint->GetKind() )
445 case SdrHintKind::ObjectInserted:
447 if (DlgEdObj const* pDlgEdObj = dynamic_cast<DlgEdObj const*>(pSdrHint->GetObject()))
449 ChildDescriptor aDesc(const_cast<DlgEdObj*>(pDlgEdObj));
450 if ( IsChildVisible( aDesc ) )
451 InsertChild( aDesc );
454 break;
455 case SdrHintKind::ObjectRemoved:
457 if (DlgEdObj const* pDlgEdObj = dynamic_cast<DlgEdObj const*>(pSdrHint->GetObject()))
458 RemoveChild( ChildDescriptor(const_cast<DlgEdObj*>(pDlgEdObj)) );
460 break;
461 default: ;
464 else if (DlgEdHint const* pDlgEdHint = dynamic_cast<DlgEdHint const*>(&rHint))
466 switch (pDlgEdHint->GetKind())
468 case DlgEdHint::WINDOWSCROLLED:
470 UpdateChildren();
471 UpdateBounds();
473 break;
474 case DlgEdHint::LAYERCHANGED:
476 if (DlgEdObj* pDlgEdObj = pDlgEdHint->GetObject())
477 UpdateChild( ChildDescriptor( pDlgEdObj ) );
479 break;
480 case DlgEdHint::OBJORDERCHANGED:
482 SortChildren();
484 break;
485 case DlgEdHint::SELECTIONCHANGED:
487 UpdateFocused();
488 UpdateSelected();
490 break;
491 default: ;
497 // XComponent
500 void AccessibleDialogWindow::disposing()
502 OAccessibleExtendedComponentHelper::disposing();
504 if ( !m_pDialogWindow )
505 return;
507 m_pDialogWindow->RemoveEventListener( LINK( this, AccessibleDialogWindow, WindowEventListener ) );
508 m_pDialogWindow = nullptr;
510 if ( m_pDlgEdModel )
511 EndListening( *m_pDlgEdModel );
512 m_pDlgEdModel = nullptr;
514 // dispose all children
515 for (const ChildDescriptor & i : m_aAccessibleChildren)
517 Reference< XComponent > xComponent( i.rxAccessible, UNO_QUERY );
518 if ( xComponent.is() )
519 xComponent->dispose();
521 m_aAccessibleChildren.clear();
524 // XServiceInfo
525 OUString AccessibleDialogWindow::getImplementationName()
527 return "com.sun.star.comp.basctl.AccessibleWindow";
530 sal_Bool AccessibleDialogWindow::supportsService( const OUString& rServiceName )
532 return cppu::supportsService(this, rServiceName);
535 Sequence< OUString > AccessibleDialogWindow::getSupportedServiceNames()
537 return { "com.sun.star.awt.AccessibleWindow" };
540 // XAccessible
541 Reference< XAccessibleContext > AccessibleDialogWindow::getAccessibleContext( )
543 return this;
546 // XAccessibleContext
547 sal_Int64 AccessibleDialogWindow::getAccessibleChildCount()
549 OExternalLockGuard aGuard( this );
551 return m_aAccessibleChildren.size();
555 Reference< XAccessible > AccessibleDialogWindow::getAccessibleChild( sal_Int64 i )
557 OExternalLockGuard aGuard( this );
559 if ( i < 0 || i >= getAccessibleChildCount() )
560 throw IndexOutOfBoundsException();
562 Reference< XAccessible > xChild = m_aAccessibleChildren[i].rxAccessible;
563 if ( !xChild.is() )
565 if ( m_pDialogWindow )
567 DlgEdObj* pDlgEdObj = m_aAccessibleChildren[i].pDlgEdObj;
568 if ( pDlgEdObj )
570 xChild = new AccessibleDialogControlShape( m_pDialogWindow, pDlgEdObj );
572 // insert into child list
573 m_aAccessibleChildren[i].rxAccessible = xChild;
578 return xChild;
582 Reference< XAccessible > AccessibleDialogWindow::getAccessibleParent( )
584 OExternalLockGuard aGuard( this );
586 Reference< XAccessible > xParent;
587 if ( m_pDialogWindow )
589 vcl::Window* pParent = m_pDialogWindow->GetAccessibleParentWindow();
590 if ( pParent )
591 xParent = pParent->GetAccessible();
594 return xParent;
598 sal_Int64 AccessibleDialogWindow::getAccessibleIndexInParent( )
600 OExternalLockGuard aGuard( this );
602 sal_Int64 nIndexInParent = -1;
603 if ( m_pDialogWindow )
605 vcl::Window* pParent = m_pDialogWindow->GetAccessibleParentWindow();
606 if ( pParent )
608 for ( sal_uInt16 i = 0, nCount = pParent->GetAccessibleChildWindowCount(); i < nCount; ++i )
610 vcl::Window* pChild = pParent->GetAccessibleChildWindow( i );
611 if ( pChild == static_cast< vcl::Window* >( m_pDialogWindow ) )
613 nIndexInParent = i;
614 break;
620 return nIndexInParent;
624 sal_Int16 AccessibleDialogWindow::getAccessibleRole( )
626 OExternalLockGuard aGuard( this );
628 return AccessibleRole::PANEL;
632 OUString AccessibleDialogWindow::getAccessibleDescription( )
634 OExternalLockGuard aGuard( this );
636 OUString sDescription;
637 if ( m_pDialogWindow )
638 sDescription = m_pDialogWindow->GetAccessibleDescription();
640 return sDescription;
644 OUString AccessibleDialogWindow::getAccessibleName( )
646 OExternalLockGuard aGuard( this );
648 OUString sName;
649 if ( m_pDialogWindow )
650 sName = m_pDialogWindow->GetAccessibleName();
652 return sName;
656 Reference< XAccessibleRelationSet > AccessibleDialogWindow::getAccessibleRelationSet( )
658 OExternalLockGuard aGuard( this );
660 return new utl::AccessibleRelationSetHelper;
664 sal_Int64 AccessibleDialogWindow::getAccessibleStateSet( )
666 OExternalLockGuard aGuard( this );
668 sal_Int64 nStateSet = 0;
670 if ( !rBHelper.bDisposed && !rBHelper.bInDispose )
672 FillAccessibleStateSet( nStateSet );
674 else
676 nStateSet |= AccessibleStateType::DEFUNC;
679 return nStateSet;
683 Locale AccessibleDialogWindow::getLocale( )
685 OExternalLockGuard aGuard( this );
687 return Application::GetSettings().GetLanguageTag().getLocale();
691 // XAccessibleComponent
694 Reference< XAccessible > AccessibleDialogWindow::getAccessibleAtPoint( const awt::Point& rPoint )
696 OExternalLockGuard aGuard( this );
698 Reference< XAccessible > xChild;
699 for ( size_t i = 0; i < m_aAccessibleChildren.size(); ++i )
701 Reference< XAccessible > xAcc = getAccessibleChild( i );
702 if ( xAcc.is() )
704 Reference< XAccessibleComponent > xComp( xAcc->getAccessibleContext(), UNO_QUERY );
705 if ( xComp.is() )
707 tools::Rectangle aRect = VCLRectangle( xComp->getBounds() );
708 Point aPos = VCLPoint( rPoint );
709 if ( aRect.Contains( aPos ) )
711 xChild = xAcc;
712 break;
718 return xChild;
722 void AccessibleDialogWindow::grabFocus( )
724 OExternalLockGuard aGuard( this );
726 if ( m_pDialogWindow )
727 m_pDialogWindow->GrabFocus();
731 sal_Int32 AccessibleDialogWindow::getForeground( )
733 OExternalLockGuard aGuard( this );
735 Color nColor;
736 if ( m_pDialogWindow )
738 if ( m_pDialogWindow->IsControlForeground() )
739 nColor = m_pDialogWindow->GetControlForeground();
740 else
742 vcl::Font aFont;
743 if ( m_pDialogWindow->IsControlFont() )
744 aFont = m_pDialogWindow->GetControlFont();
745 else
746 aFont = m_pDialogWindow->GetFont();
747 nColor = aFont.GetColor();
751 return sal_Int32(nColor);
755 sal_Int32 AccessibleDialogWindow::getBackground( )
757 OExternalLockGuard aGuard( this );
759 Color nColor;
760 if ( m_pDialogWindow )
762 if ( m_pDialogWindow->IsControlBackground() )
763 nColor = m_pDialogWindow->GetControlBackground();
764 else
765 nColor = m_pDialogWindow->GetBackground().GetColor();
768 return sal_Int32(nColor);
772 // XAccessibleExtendedComponent
775 Reference< awt::XFont > AccessibleDialogWindow::getFont( )
777 OExternalLockGuard aGuard( this );
779 Reference< awt::XFont > xFont;
780 if ( m_pDialogWindow )
782 Reference< awt::XDevice > xDev( m_pDialogWindow->GetComponentInterface(), UNO_QUERY );
783 if ( xDev.is() )
785 vcl::Font aFont;
786 if ( m_pDialogWindow->IsControlFont() )
787 aFont = m_pDialogWindow->GetControlFont();
788 else
789 aFont = m_pDialogWindow->GetFont();
790 rtl::Reference<VCLXFont> pVCLXFont = new VCLXFont;
791 pVCLXFont->Init( *xDev, aFont );
792 xFont = pVCLXFont;
796 return xFont;
800 OUString AccessibleDialogWindow::getTitledBorderText( )
802 OExternalLockGuard aGuard( this );
804 return OUString();
808 OUString AccessibleDialogWindow::getToolTipText( )
810 OExternalLockGuard aGuard( this );
812 OUString sText;
813 if ( m_pDialogWindow )
814 sText = m_pDialogWindow->GetQuickHelpText();
816 return sText;
820 // XAccessibleSelection
823 void AccessibleDialogWindow::selectAccessibleChild( sal_Int64 nChildIndex )
825 OExternalLockGuard aGuard( this );
827 if ( nChildIndex < 0 || nChildIndex >= getAccessibleChildCount() )
828 throw IndexOutOfBoundsException();
830 if ( m_pDialogWindow )
832 if (DlgEdObj* pDlgEdObj = m_aAccessibleChildren[nChildIndex].pDlgEdObj)
834 SdrView& rView = m_pDialogWindow->GetView();
835 if (SdrPageView* pPgView = rView.GetSdrPageView())
836 rView.MarkObj(pDlgEdObj, pPgView);
842 sal_Bool AccessibleDialogWindow::isAccessibleChildSelected( sal_Int64 nChildIndex )
844 OExternalLockGuard aGuard( this );
846 if ( nChildIndex < 0 || nChildIndex >= getAccessibleChildCount() )
847 throw IndexOutOfBoundsException();
849 if (m_pDialogWindow)
850 if (DlgEdObj* pDlgEdObj = m_aAccessibleChildren[nChildIndex].pDlgEdObj)
851 return m_pDialogWindow->GetView().IsObjMarked(pDlgEdObj);
852 return false;
856 void AccessibleDialogWindow::clearAccessibleSelection()
858 OExternalLockGuard aGuard( this );
860 if ( m_pDialogWindow )
861 m_pDialogWindow->GetView().UnmarkAll();
865 void AccessibleDialogWindow::selectAllAccessibleChildren( )
867 OExternalLockGuard aGuard( this );
869 if ( m_pDialogWindow )
870 m_pDialogWindow->GetView().MarkAll();
874 sal_Int64 AccessibleDialogWindow::getSelectedAccessibleChildCount( )
876 OExternalLockGuard aGuard( this );
878 sal_Int64 nRet = 0;
880 for ( sal_Int64 i = 0, nCount = getAccessibleChildCount(); i < nCount; ++i )
882 if ( isAccessibleChildSelected( i ) )
883 ++nRet;
886 return nRet;
890 Reference< XAccessible > AccessibleDialogWindow::getSelectedAccessibleChild( sal_Int64 nSelectedChildIndex )
892 OExternalLockGuard aGuard( this );
894 if ( nSelectedChildIndex < 0 || nSelectedChildIndex >= getSelectedAccessibleChildCount() )
895 throw IndexOutOfBoundsException();
897 Reference< XAccessible > xChild;
899 for ( sal_Int64 i = 0, j = 0, nCount = getAccessibleChildCount(); i < nCount; ++i )
901 if ( isAccessibleChildSelected( i ) && ( j++ == nSelectedChildIndex ) )
903 xChild = getAccessibleChild( i );
904 break;
908 return xChild;
912 void AccessibleDialogWindow::deselectAccessibleChild( sal_Int64 nChildIndex )
914 OExternalLockGuard aGuard( this );
916 if ( nChildIndex < 0 || nChildIndex >= getAccessibleChildCount() )
917 throw IndexOutOfBoundsException();
919 if ( m_pDialogWindow )
921 if (DlgEdObj* pDlgEdObj = m_aAccessibleChildren[nChildIndex].pDlgEdObj)
923 SdrView& rView = m_pDialogWindow->GetView();
924 SdrPageView* pPgView = rView.GetSdrPageView();
925 if (pPgView)
926 rView.MarkObj( pDlgEdObj, pPgView, true );
932 } // namespace basctl
934 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */