Avoid potential negative array index access to cached text.
[LibreOffice.git] / basctl / source / accessibility / accessibledialogwindow.cxx
blobd5c702616d9f350e0aaba66e8614719db3e4b8cd
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();
89 for (const rtl::Reference<SdrObject>& pObj : rPage)
91 if (DlgEdObj* pDlgEdObj = dynamic_cast<DlgEdObj*>(pObj.get()))
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);
108 AccessibleDialogWindow::~AccessibleDialogWindow()
110 if ( m_pDialogWindow )
111 m_pDialogWindow->RemoveEventListener( LINK( this, AccessibleDialogWindow, WindowEventListener ) );
113 if ( m_pDlgEdModel )
114 EndListening( *m_pDlgEdModel );
118 void AccessibleDialogWindow::UpdateFocused()
120 for (const ChildDescriptor & i : m_aAccessibleChildren)
122 if ( i.mxAccessible )
123 i.mxAccessible->SetFocused( i.mxAccessible->IsFocused() );
128 void AccessibleDialogWindow::UpdateSelected()
130 NotifyAccessibleEvent( AccessibleEventId::SELECTION_CHANGED, Any(), Any() );
132 for (const ChildDescriptor & i : m_aAccessibleChildren)
134 if ( i.mxAccessible )
135 i.mxAccessible->SetSelected( i.mxAccessible->IsSelected() );
140 void AccessibleDialogWindow::UpdateBounds()
142 for (const ChildDescriptor & i : m_aAccessibleChildren)
144 if ( i.mxAccessible )
145 i.mxAccessible->SetBounds( i.mxAccessible->GetBounds() );
150 bool AccessibleDialogWindow::IsChildVisible( const ChildDescriptor& rDesc )
152 bool bVisible = false;
154 if ( m_pDialogWindow )
156 // first check, if the shape is in a visible layer
157 SdrLayerAdmin& rLayerAdmin = m_pDialogWindow->GetModel().GetLayerAdmin();
158 DlgEdObj* pDlgEdObj = rDesc.pDlgEdObj;
159 if ( pDlgEdObj )
161 SdrLayerID nLayerId = pDlgEdObj->GetLayer();
162 const SdrLayer* pSdrLayer = rLayerAdmin.GetLayerPerID( nLayerId );
163 if ( pSdrLayer )
165 const OUString& aLayerName = pSdrLayer->GetName();
166 SdrView& rView = m_pDialogWindow->GetView();
167 if (rView.IsLayerVisible(aLayerName))
169 // get the bounding box of the shape in logic units
170 tools::Rectangle aRect = pDlgEdObj->GetSnapRect();
172 // transform coordinates relative to the parent
173 MapMode aMap = m_pDialogWindow->GetMapMode();
174 Point aOrg = aMap.GetOrigin();
175 aRect.Move( aOrg.X(), aOrg.Y() );
177 // convert logic units to pixel
178 aRect = m_pDialogWindow->LogicToPixel( aRect, MapMode(MapUnit::Map100thMM) );
180 // check, if the shape's bounding box intersects with the bounding box of its parent
181 tools::Rectangle aParentRect( Point( 0, 0 ), m_pDialogWindow->GetSizePixel() );
182 if ( aParentRect.Overlaps( aRect ) )
183 bVisible = true;
189 return bVisible;
193 void AccessibleDialogWindow::InsertChild( const ChildDescriptor& rDesc )
195 // check, if object is already in child list
196 AccessibleChildren::iterator aIter = std::find( m_aAccessibleChildren.begin(), m_aAccessibleChildren.end(), rDesc );
198 // if not found, insert in child list
199 if ( aIter != m_aAccessibleChildren.end() )
200 return;
202 // insert entry in child list
203 m_aAccessibleChildren.push_back( rDesc );
205 // get the accessible of the inserted child
206 Reference< XAccessible > xChild( getAccessibleChild( m_aAccessibleChildren.size() - 1 ) );
208 // sort child list
209 SortChildren();
211 // send accessible child event
212 if ( xChild.is() )
214 Any aOldValue, aNewValue;
215 aNewValue <<= xChild;
216 NotifyAccessibleEvent( AccessibleEventId::CHILD, aOldValue, aNewValue );
221 void AccessibleDialogWindow::RemoveChild( const ChildDescriptor& rDesc )
223 // find object in child list
224 AccessibleChildren::iterator aIter = std::find( m_aAccessibleChildren.begin(), m_aAccessibleChildren.end(), rDesc );
226 // if found, remove from child list
227 if ( aIter == m_aAccessibleChildren.end() )
228 return;
230 // get the accessible of the removed child
231 rtl::Reference< AccessibleDialogControlShape > xChild( aIter->mxAccessible );
233 // remove entry from child list
234 m_aAccessibleChildren.erase( aIter );
236 // send accessible child event
237 if ( xChild.is() )
239 Any aOldValue, aNewValue;
240 aOldValue <<= uno::Reference<XAccessible>(xChild);
241 NotifyAccessibleEvent( AccessibleEventId::CHILD, aOldValue, aNewValue );
243 if ( xChild )
244 xChild->dispose();
249 void AccessibleDialogWindow::UpdateChild( const ChildDescriptor& rDesc )
251 if ( IsChildVisible( rDesc ) )
253 // if the object is not in the child list, insert child
254 InsertChild( rDesc );
256 else
258 // if the object is in the child list, remove child
259 RemoveChild( rDesc );
264 void AccessibleDialogWindow::UpdateChildren()
266 if ( m_pDialogWindow )
268 SdrPage& rPage = m_pDialogWindow->GetPage();
269 for (const rtl::Reference<SdrObject>& pObj : rPage)
270 if (DlgEdObj* pDlgEdObj = dynamic_cast<DlgEdObj*>(pObj.get()))
271 UpdateChild( ChildDescriptor( pDlgEdObj ) );
276 void AccessibleDialogWindow::SortChildren()
278 // sort child list
279 std::sort( m_aAccessibleChildren.begin(), m_aAccessibleChildren.end() );
283 IMPL_LINK( AccessibleDialogWindow, WindowEventListener, VclWindowEvent&, rEvent, void )
285 DBG_ASSERT(rEvent.GetWindow(), "AccessibleDialogWindow::WindowEventListener: no window!");
286 if (!rEvent.GetWindow()->IsAccessibilityEventsSuppressed() || rEvent.GetId() == VclEventId::ObjectDying)
287 ProcessWindowEvent(rEvent);
291 void AccessibleDialogWindow::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
293 Any aOldValue, aNewValue;
295 switch ( rVclWindowEvent.GetId() )
297 case VclEventId::WindowEnabled:
299 aNewValue <<= AccessibleStateType::ENABLED;
300 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
302 break;
303 case VclEventId::WindowDisabled:
305 aOldValue <<= AccessibleStateType::ENABLED;
306 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
308 break;
309 case VclEventId::WindowActivate:
311 aNewValue <<= AccessibleStateType::ACTIVE;
312 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
314 break;
315 case VclEventId::WindowDeactivate:
317 aOldValue <<= AccessibleStateType::ACTIVE;
318 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
320 break;
321 case VclEventId::WindowGetFocus:
323 aNewValue <<= AccessibleStateType::FOCUSED;
324 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
326 break;
327 case VclEventId::WindowLoseFocus:
329 aOldValue <<= AccessibleStateType::FOCUSED;
330 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
332 break;
333 case VclEventId::WindowShow:
335 aNewValue <<= AccessibleStateType::SHOWING;
336 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
338 break;
339 case VclEventId::WindowHide:
341 aOldValue <<= AccessibleStateType::SHOWING;
342 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
344 break;
345 case VclEventId::WindowResize:
347 NotifyAccessibleEvent( AccessibleEventId::BOUNDRECT_CHANGED, aOldValue, aNewValue );
348 UpdateChildren();
349 UpdateBounds();
351 break;
352 case VclEventId::ObjectDying:
354 if ( m_pDialogWindow )
356 m_pDialogWindow->RemoveEventListener( LINK( this, AccessibleDialogWindow, WindowEventListener ) );
357 m_pDialogWindow = nullptr;
359 if ( m_pDlgEdModel )
360 EndListening( *m_pDlgEdModel );
361 m_pDlgEdModel = nullptr;
363 // dispose all children
364 for (const ChildDescriptor & i : m_aAccessibleChildren)
366 if ( i.mxAccessible )
367 i.mxAccessible->dispose();
369 m_aAccessibleChildren.clear();
372 break;
373 default:
376 break;
381 void AccessibleDialogWindow::FillAccessibleStateSet( sal_Int64& rStateSet )
383 if ( !m_pDialogWindow )
384 return;
386 if ( m_pDialogWindow->IsEnabled() )
387 rStateSet |= AccessibleStateType::ENABLED;
389 rStateSet |= AccessibleStateType::FOCUSABLE;
391 if ( m_pDialogWindow->HasFocus() )
392 rStateSet |= AccessibleStateType::FOCUSED;
394 rStateSet |= AccessibleStateType::VISIBLE;
396 if ( m_pDialogWindow->IsVisible() )
397 rStateSet |= AccessibleStateType::SHOWING;
399 rStateSet |= AccessibleStateType::OPAQUE;
401 rStateSet |= AccessibleStateType::RESIZABLE;
405 // OCommonAccessibleComponent
408 awt::Rectangle AccessibleDialogWindow::implGetBounds()
410 awt::Rectangle aBounds;
411 if ( m_pDialogWindow )
412 aBounds = AWTRectangle( tools::Rectangle( m_pDialogWindow->GetPosPixel(), m_pDialogWindow->GetSizePixel() ) );
414 return aBounds;
418 // SfxListener
421 void AccessibleDialogWindow::Notify( SfxBroadcaster&, const SfxHint& rHint )
423 if (SdrHint const* pSdrHint = dynamic_cast<SdrHint const*>(&rHint))
425 switch ( pSdrHint->GetKind() )
427 case SdrHintKind::ObjectInserted:
429 if (DlgEdObj const* pDlgEdObj = dynamic_cast<DlgEdObj const*>(pSdrHint->GetObject()))
431 ChildDescriptor aDesc(const_cast<DlgEdObj*>(pDlgEdObj));
432 if ( IsChildVisible( aDesc ) )
433 InsertChild( aDesc );
436 break;
437 case SdrHintKind::ObjectRemoved:
439 if (DlgEdObj const* pDlgEdObj = dynamic_cast<DlgEdObj const*>(pSdrHint->GetObject()))
440 RemoveChild( ChildDescriptor(const_cast<DlgEdObj*>(pDlgEdObj)) );
442 break;
443 default: ;
446 else if (DlgEdHint const* pDlgEdHint = dynamic_cast<DlgEdHint const*>(&rHint))
448 switch (pDlgEdHint->GetKind())
450 case DlgEdHint::WINDOWSCROLLED:
452 UpdateChildren();
453 UpdateBounds();
455 break;
456 case DlgEdHint::LAYERCHANGED:
458 if (DlgEdObj* pDlgEdObj = pDlgEdHint->GetObject())
459 UpdateChild( ChildDescriptor( pDlgEdObj ) );
461 break;
462 case DlgEdHint::OBJORDERCHANGED:
464 SortChildren();
466 break;
467 case DlgEdHint::SELECTIONCHANGED:
469 UpdateFocused();
470 UpdateSelected();
472 break;
473 default: ;
479 // XComponent
482 void AccessibleDialogWindow::disposing()
484 OAccessibleExtendedComponentHelper::disposing();
486 if ( !m_pDialogWindow )
487 return;
489 m_pDialogWindow->RemoveEventListener( LINK( this, AccessibleDialogWindow, WindowEventListener ) );
490 m_pDialogWindow = nullptr;
492 if ( m_pDlgEdModel )
493 EndListening( *m_pDlgEdModel );
494 m_pDlgEdModel = nullptr;
496 // dispose all children
497 for (const ChildDescriptor & i : m_aAccessibleChildren)
499 if ( i.mxAccessible )
500 i.mxAccessible->dispose();
502 m_aAccessibleChildren.clear();
505 // XServiceInfo
506 OUString AccessibleDialogWindow::getImplementationName()
508 return "com.sun.star.comp.basctl.AccessibleWindow";
511 sal_Bool AccessibleDialogWindow::supportsService( const OUString& rServiceName )
513 return cppu::supportsService(this, rServiceName);
516 Sequence< OUString > AccessibleDialogWindow::getSupportedServiceNames()
518 return { "com.sun.star.awt.AccessibleWindow" };
521 // XAccessible
522 Reference< XAccessibleContext > AccessibleDialogWindow::getAccessibleContext( )
524 return this;
527 // XAccessibleContext
528 sal_Int64 AccessibleDialogWindow::getAccessibleChildCount()
530 OExternalLockGuard aGuard( this );
532 return m_aAccessibleChildren.size();
536 Reference< XAccessible > AccessibleDialogWindow::getAccessibleChild( sal_Int64 i )
538 OExternalLockGuard aGuard( this );
540 if ( i < 0 || i >= getAccessibleChildCount() )
541 throw IndexOutOfBoundsException();
543 rtl::Reference< AccessibleDialogControlShape > xChild = m_aAccessibleChildren[i].mxAccessible;
544 if ( !xChild.is() )
546 if ( m_pDialogWindow )
548 DlgEdObj* pDlgEdObj = m_aAccessibleChildren[i].pDlgEdObj;
549 if ( pDlgEdObj )
551 xChild = new AccessibleDialogControlShape( m_pDialogWindow, pDlgEdObj );
553 // insert into child list
554 m_aAccessibleChildren[i].mxAccessible = xChild;
559 return xChild;
563 Reference< XAccessible > AccessibleDialogWindow::getAccessibleParent( )
565 OExternalLockGuard aGuard( this );
567 Reference< XAccessible > xParent;
568 if ( m_pDialogWindow )
570 vcl::Window* pParent = m_pDialogWindow->GetAccessibleParentWindow();
571 if ( pParent )
572 xParent = pParent->GetAccessible();
575 return xParent;
579 sal_Int64 AccessibleDialogWindow::getAccessibleIndexInParent( )
581 OExternalLockGuard aGuard( this );
583 sal_Int64 nIndexInParent = -1;
584 if ( m_pDialogWindow )
586 vcl::Window* pParent = m_pDialogWindow->GetAccessibleParentWindow();
587 if ( pParent )
589 for ( sal_uInt16 i = 0, nCount = pParent->GetAccessibleChildWindowCount(); i < nCount; ++i )
591 vcl::Window* pChild = pParent->GetAccessibleChildWindow( i );
592 if ( pChild == static_cast< vcl::Window* >( m_pDialogWindow ) )
594 nIndexInParent = i;
595 break;
601 return nIndexInParent;
605 sal_Int16 AccessibleDialogWindow::getAccessibleRole( )
607 OExternalLockGuard aGuard( this );
609 return AccessibleRole::PANEL;
613 OUString AccessibleDialogWindow::getAccessibleDescription( )
615 OExternalLockGuard aGuard( this );
617 OUString sDescription;
618 if ( m_pDialogWindow )
619 sDescription = m_pDialogWindow->GetAccessibleDescription();
621 return sDescription;
625 OUString AccessibleDialogWindow::getAccessibleName( )
627 OExternalLockGuard aGuard( this );
629 OUString sName;
630 if ( m_pDialogWindow )
631 sName = m_pDialogWindow->GetAccessibleName();
633 return sName;
637 Reference< XAccessibleRelationSet > AccessibleDialogWindow::getAccessibleRelationSet( )
639 OExternalLockGuard aGuard( this );
641 return new utl::AccessibleRelationSetHelper;
645 sal_Int64 AccessibleDialogWindow::getAccessibleStateSet( )
647 OExternalLockGuard aGuard( this );
649 sal_Int64 nStateSet = 0;
651 if ( !rBHelper.bDisposed && !rBHelper.bInDispose )
653 FillAccessibleStateSet( nStateSet );
655 else
657 nStateSet |= AccessibleStateType::DEFUNC;
660 return nStateSet;
664 Locale AccessibleDialogWindow::getLocale( )
666 OExternalLockGuard aGuard( this );
668 return Application::GetSettings().GetLanguageTag().getLocale();
672 // XAccessibleComponent
675 Reference< XAccessible > AccessibleDialogWindow::getAccessibleAtPoint( const awt::Point& rPoint )
677 OExternalLockGuard aGuard( this );
679 Reference< XAccessible > xChild;
680 for ( size_t i = 0; i < m_aAccessibleChildren.size(); ++i )
682 Reference< XAccessible > xAcc = getAccessibleChild( i );
683 if ( xAcc.is() )
685 Reference< XAccessibleComponent > xComp( xAcc->getAccessibleContext(), UNO_QUERY );
686 if ( xComp.is() )
688 tools::Rectangle aRect = VCLRectangle( xComp->getBounds() );
689 Point aPos = VCLPoint( rPoint );
690 if ( aRect.Contains( aPos ) )
692 xChild = xAcc;
693 break;
699 return xChild;
703 void AccessibleDialogWindow::grabFocus( )
705 OExternalLockGuard aGuard( this );
707 if ( m_pDialogWindow )
708 m_pDialogWindow->GrabFocus();
712 sal_Int32 AccessibleDialogWindow::getForeground( )
714 OExternalLockGuard aGuard( this );
716 Color nColor;
717 if ( m_pDialogWindow )
719 if ( m_pDialogWindow->IsControlForeground() )
720 nColor = m_pDialogWindow->GetControlForeground();
721 else
723 vcl::Font aFont;
724 if ( m_pDialogWindow->IsControlFont() )
725 aFont = m_pDialogWindow->GetControlFont();
726 else
727 aFont = m_pDialogWindow->GetFont();
728 nColor = aFont.GetColor();
732 return sal_Int32(nColor);
736 sal_Int32 AccessibleDialogWindow::getBackground( )
738 OExternalLockGuard aGuard( this );
740 Color nColor;
741 if ( m_pDialogWindow )
743 if ( m_pDialogWindow->IsControlBackground() )
744 nColor = m_pDialogWindow->GetControlBackground();
745 else
746 nColor = m_pDialogWindow->GetBackground().GetColor();
749 return sal_Int32(nColor);
753 // XAccessibleExtendedComponent
756 Reference< awt::XFont > AccessibleDialogWindow::getFont( )
758 OExternalLockGuard aGuard( this );
760 Reference< awt::XFont > xFont;
761 if ( m_pDialogWindow )
763 Reference< awt::XDevice > xDev( m_pDialogWindow->GetComponentInterface(), UNO_QUERY );
764 if ( xDev.is() )
766 vcl::Font aFont;
767 if ( m_pDialogWindow->IsControlFont() )
768 aFont = m_pDialogWindow->GetControlFont();
769 else
770 aFont = m_pDialogWindow->GetFont();
771 rtl::Reference<VCLXFont> pVCLXFont = new VCLXFont;
772 pVCLXFont->Init( *xDev, aFont );
773 xFont = pVCLXFont;
777 return xFont;
781 OUString AccessibleDialogWindow::getTitledBorderText( )
783 OExternalLockGuard aGuard( this );
785 return OUString();
789 OUString AccessibleDialogWindow::getToolTipText( )
791 OExternalLockGuard aGuard( this );
793 OUString sText;
794 if ( m_pDialogWindow )
795 sText = m_pDialogWindow->GetQuickHelpText();
797 return sText;
801 // XAccessibleSelection
804 void AccessibleDialogWindow::selectAccessibleChild( sal_Int64 nChildIndex )
806 OExternalLockGuard aGuard( this );
808 if ( nChildIndex < 0 || nChildIndex >= getAccessibleChildCount() )
809 throw IndexOutOfBoundsException();
811 if ( m_pDialogWindow )
813 if (DlgEdObj* pDlgEdObj = m_aAccessibleChildren[nChildIndex].pDlgEdObj)
815 SdrView& rView = m_pDialogWindow->GetView();
816 if (SdrPageView* pPgView = rView.GetSdrPageView())
817 rView.MarkObj(pDlgEdObj, pPgView);
823 sal_Bool AccessibleDialogWindow::isAccessibleChildSelected( sal_Int64 nChildIndex )
825 OExternalLockGuard aGuard( this );
827 if ( nChildIndex < 0 || nChildIndex >= getAccessibleChildCount() )
828 throw IndexOutOfBoundsException();
830 if (m_pDialogWindow)
831 if (DlgEdObj* pDlgEdObj = m_aAccessibleChildren[nChildIndex].pDlgEdObj)
832 return m_pDialogWindow->GetView().IsObjMarked(pDlgEdObj);
833 return false;
837 void AccessibleDialogWindow::clearAccessibleSelection()
839 OExternalLockGuard aGuard( this );
841 if ( m_pDialogWindow )
842 m_pDialogWindow->GetView().UnmarkAll();
846 void AccessibleDialogWindow::selectAllAccessibleChildren( )
848 OExternalLockGuard aGuard( this );
850 if ( m_pDialogWindow )
851 m_pDialogWindow->GetView().MarkAll();
855 sal_Int64 AccessibleDialogWindow::getSelectedAccessibleChildCount( )
857 OExternalLockGuard aGuard( this );
859 sal_Int64 nRet = 0;
861 for ( sal_Int64 i = 0, nCount = getAccessibleChildCount(); i < nCount; ++i )
863 if ( isAccessibleChildSelected( i ) )
864 ++nRet;
867 return nRet;
871 Reference< XAccessible > AccessibleDialogWindow::getSelectedAccessibleChild( sal_Int64 nSelectedChildIndex )
873 OExternalLockGuard aGuard( this );
875 if ( nSelectedChildIndex < 0 || nSelectedChildIndex >= getSelectedAccessibleChildCount() )
876 throw IndexOutOfBoundsException();
878 Reference< XAccessible > xChild;
880 for ( sal_Int64 i = 0, j = 0, nCount = getAccessibleChildCount(); i < nCount; ++i )
882 if ( isAccessibleChildSelected( i ) && ( j++ == nSelectedChildIndex ) )
884 xChild = getAccessibleChild( i );
885 break;
889 return xChild;
893 void AccessibleDialogWindow::deselectAccessibleChild( sal_Int64 nChildIndex )
895 OExternalLockGuard aGuard( this );
897 if ( nChildIndex < 0 || nChildIndex >= getAccessibleChildCount() )
898 throw IndexOutOfBoundsException();
900 if ( m_pDialogWindow )
902 if (DlgEdObj* pDlgEdObj = m_aAccessibleChildren[nChildIndex].pDlgEdObj)
904 SdrView& rView = m_pDialogWindow->GetView();
905 SdrPageView* pPgView = rView.GetSdrPageView();
906 if (pPgView)
907 rView.MarkObj( pDlgEdObj, pPgView, true );
913 } // namespace basctl
915 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */