bump product version to 5.0.4.1
[LibreOffice.git] / basctl / source / accessibility / accessibledialogwindow.cxx
blob1d00867f3894167521801531f4f11f7825564e26
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/accessibility/AccessibleEventId.hpp>
30 #include <com/sun/star/accessibility/AccessibleRole.hpp>
31 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
32 #include <cppuhelper/supportsservice.hxx>
33 #include <unotools/accessiblestatesethelper.hxx>
34 #include <unotools/accessiblerelationsethelper.hxx>
35 #include <toolkit/awt/vclxfont.hxx>
36 #include <toolkit/helper/externallock.hxx>
37 #include <toolkit/helper/convert.hxx>
38 #include <vcl/svapp.hxx>
39 #include <vcl/settings.hxx>
41 namespace basctl
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( 0 )
58 AccessibleDialogWindow::ChildDescriptor::~ChildDescriptor()
64 AccessibleDialogWindow::ChildDescriptor::ChildDescriptor( const ChildDescriptor& rDesc )
65 :pDlgEdObj( rDesc.pDlgEdObj )
66 ,rxAccessible( rDesc.rxAccessible )
72 AccessibleDialogWindow::ChildDescriptor& AccessibleDialogWindow::ChildDescriptor::operator=( const ChildDescriptor& rDesc )
74 pDlgEdObj = rDesc.pDlgEdObj;
75 rxAccessible = rDesc.rxAccessible;
77 return *this;
82 bool AccessibleDialogWindow::ChildDescriptor::operator==( const ChildDescriptor& rDesc )
84 bool bRet = false;
85 if ( pDlgEdObj == rDesc.pDlgEdObj )
86 bRet = true;
88 return bRet;
93 bool AccessibleDialogWindow::ChildDescriptor::operator<( const ChildDescriptor& rDesc ) const
95 bool bRet = false;
96 if ( pDlgEdObj && rDesc.pDlgEdObj && pDlgEdObj->GetOrdNum() < rDesc.pDlgEdObj->GetOrdNum() )
97 bRet = true;
99 return bRet;
103 // class AccessibleDialogWindow
106 AccessibleDialogWindow::AccessibleDialogWindow (basctl::DialogWindow* pDialogWindow)
107 : AccessibleExtendedComponentHelper_BASE( new VCLExternalSolarLock() )
108 , m_pDialogWindow(pDialogWindow)
109 , m_pDlgEditor(NULL)
110 , m_pDlgEdModel(NULL)
112 m_pExternalLock = static_cast< VCLExternalSolarLock* >( getExternalLock() );
114 if ( m_pDialogWindow )
116 SdrPage& rPage = m_pDialogWindow->GetPage();
117 const size_t nCount = rPage.GetObjCount();
119 for ( size_t i = 0; i < nCount; ++i )
121 if (DlgEdObj* pDlgEdObj = dynamic_cast<DlgEdObj*>(rPage.GetObj(i)))
123 ChildDescriptor aDesc( pDlgEdObj );
124 if ( IsChildVisible( aDesc ) )
125 m_aAccessibleChildren.push_back( aDesc );
129 m_pDialogWindow->AddEventListener( LINK( this, AccessibleDialogWindow, WindowEventListener ) );
131 StartListening(m_pDialogWindow->GetEditor());
133 m_pDlgEdModel = &m_pDialogWindow->GetModel();
134 StartListening(*m_pDlgEdModel);
140 AccessibleDialogWindow::~AccessibleDialogWindow()
142 if ( m_pDialogWindow )
143 m_pDialogWindow->RemoveEventListener( LINK( this, AccessibleDialogWindow, WindowEventListener ) );
145 if ( m_pDlgEditor )
146 EndListening( *m_pDlgEditor );
148 if ( m_pDlgEdModel )
149 EndListening( *m_pDlgEdModel );
151 delete m_pExternalLock;
152 m_pExternalLock = NULL;
157 void AccessibleDialogWindow::UpdateFocused()
159 for ( sal_uInt32 i = 0; i < m_aAccessibleChildren.size(); ++i )
161 Reference< XAccessible > xChild( m_aAccessibleChildren[i].rxAccessible );
162 if ( xChild.is() )
164 AccessibleDialogControlShape* pShape = static_cast< AccessibleDialogControlShape* >( xChild.get() );
165 if ( pShape )
166 pShape->SetFocused( pShape->IsFocused() );
173 void AccessibleDialogWindow::UpdateSelected()
175 NotifyAccessibleEvent( AccessibleEventId::SELECTION_CHANGED, Any(), Any() );
177 for ( sal_uInt32 i = 0; i < m_aAccessibleChildren.size(); ++i )
179 Reference< XAccessible > xChild( m_aAccessibleChildren[i].rxAccessible );
180 if ( xChild.is() )
182 AccessibleDialogControlShape* pShape = static_cast< AccessibleDialogControlShape* >( xChild.get() );
183 if ( pShape )
184 pShape->SetSelected( pShape->IsSelected() );
191 void AccessibleDialogWindow::UpdateBounds()
193 for ( sal_uInt32 i = 0; i < m_aAccessibleChildren.size(); ++i )
195 Reference< XAccessible > xChild( m_aAccessibleChildren[i].rxAccessible );
196 if ( xChild.is() )
198 AccessibleDialogControlShape* pShape = static_cast< AccessibleDialogControlShape* >( xChild.get() );
199 if ( pShape )
200 pShape->SetBounds( pShape->GetBounds() );
207 bool AccessibleDialogWindow::IsChildVisible( const ChildDescriptor& rDesc )
209 bool bVisible = false;
211 if ( m_pDialogWindow )
213 // first check, if the shape is in a visible layer
214 SdrLayerAdmin& rLayerAdmin = m_pDialogWindow->GetModel().GetLayerAdmin();
215 DlgEdObj* pDlgEdObj = rDesc.pDlgEdObj;
216 if ( pDlgEdObj )
218 SdrLayerID nLayerId = pDlgEdObj->GetLayer();
219 const SdrLayer* pSdrLayer = rLayerAdmin.GetLayerPerID( nLayerId );
220 if ( pSdrLayer )
222 OUString aLayerName = pSdrLayer->GetName();
223 SdrView& rView = m_pDialogWindow->GetView();
224 if (rView.IsLayerVisible(aLayerName))
226 // get the bounding box of the shape in logic units
227 Rectangle aRect = pDlgEdObj->GetSnapRect();
229 // transform coordinates relative to the parent
230 MapMode aMap = m_pDialogWindow->GetMapMode();
231 Point aOrg = aMap.GetOrigin();
232 aRect.Move( aOrg.X(), aOrg.Y() );
234 // convert logic units to pixel
235 aRect = m_pDialogWindow->LogicToPixel( aRect, MapMode(MAP_100TH_MM) );
237 // check, if the shape's bounding box intersects with the bounding box of its parent
238 Rectangle aParentRect( Point( 0, 0 ), m_pDialogWindow->GetSizePixel() );
239 if ( aParentRect.IsOver( aRect ) )
240 bVisible = true;
246 return bVisible;
251 void AccessibleDialogWindow::InsertChild( const ChildDescriptor& rDesc )
253 // check, if object is already in child list
254 AccessibleChildren::iterator aIter = ::std::find( m_aAccessibleChildren.begin(), m_aAccessibleChildren.end(), rDesc );
256 // if not found, insert in child list
257 if ( aIter == m_aAccessibleChildren.end() )
259 // insert entry in child list
260 m_aAccessibleChildren.push_back( rDesc );
262 // get the accessible of the inserted child
263 Reference< XAccessible > xChild( getAccessibleChild( m_aAccessibleChildren.size() - 1 ) );
265 // sort child list
266 SortChildren();
268 // send accessible child event
269 if ( xChild.is() )
271 Any aOldValue, aNewValue;
272 aNewValue <<= xChild;
273 NotifyAccessibleEvent( AccessibleEventId::CHILD, aOldValue, aNewValue );
280 void AccessibleDialogWindow::RemoveChild( const ChildDescriptor& rDesc )
282 // find object in child list
283 AccessibleChildren::iterator aIter = ::std::find( m_aAccessibleChildren.begin(), m_aAccessibleChildren.end(), rDesc );
285 // if found, remove from child list
286 if ( aIter != m_aAccessibleChildren.end() )
288 // get the accessible of the removed child
289 Reference< XAccessible > xChild( aIter->rxAccessible );
291 // remove entry from child list
292 m_aAccessibleChildren.erase( aIter );
294 // send accessible child event
295 if ( xChild.is() )
297 Any aOldValue, aNewValue;
298 aOldValue <<= xChild;
299 NotifyAccessibleEvent( AccessibleEventId::CHILD, aOldValue, aNewValue );
301 Reference< XComponent > xComponent( xChild, UNO_QUERY );
302 if ( xComponent.is() )
303 xComponent->dispose();
310 void AccessibleDialogWindow::UpdateChild( const ChildDescriptor& rDesc )
312 if ( IsChildVisible( rDesc ) )
314 // if the object is not in the child list, insert child
315 InsertChild( rDesc );
317 else
319 // if the object is in the child list, remove child
320 RemoveChild( rDesc );
326 void AccessibleDialogWindow::UpdateChildren()
328 if ( m_pDialogWindow )
330 SdrPage& rPage = m_pDialogWindow->GetPage();
331 for ( size_t i = 0, nCount = rPage.GetObjCount(); i < nCount; ++i )
332 if (DlgEdObj* pDlgEdObj = dynamic_cast<DlgEdObj*>(rPage.GetObj(i)))
333 UpdateChild( ChildDescriptor( pDlgEdObj ) );
339 void AccessibleDialogWindow::SortChildren()
341 // sort child list
342 ::std::sort( m_aAccessibleChildren.begin(), m_aAccessibleChildren.end() );
347 IMPL_LINK( AccessibleDialogWindow, WindowEventListener, VclSimpleEvent*, pEvent )
349 if (VclWindowEvent* pWinEvent = dynamic_cast<VclWindowEvent*>(pEvent))
351 DBG_ASSERT(pWinEvent->GetWindow(), "AccessibleDialogWindow::WindowEventListener: no window!");
352 if (!pWinEvent->GetWindow()->IsAccessibilityEventsSuppressed() || pEvent->GetId() == VCLEVENT_OBJECT_DYING)
353 ProcessWindowEvent(*pWinEvent);
355 else
356 DBG_ASSERT(false, "AccessibleDialogWindow::WindowEventListener: unknown window event!");
357 return 0;
362 void AccessibleDialogWindow::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
364 Any aOldValue, aNewValue;
366 switch ( rVclWindowEvent.GetId() )
368 case VCLEVENT_WINDOW_ENABLED:
370 aNewValue <<= AccessibleStateType::ENABLED;
371 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
373 break;
374 case VCLEVENT_WINDOW_DISABLED:
376 aOldValue <<= AccessibleStateType::ENABLED;
377 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
379 break;
380 case VCLEVENT_WINDOW_ACTIVATE:
382 aNewValue <<= AccessibleStateType::ACTIVE;
383 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
385 break;
386 case VCLEVENT_WINDOW_DEACTIVATE:
388 aOldValue <<= AccessibleStateType::ACTIVE;
389 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
391 break;
392 case VCLEVENT_WINDOW_GETFOCUS:
394 aNewValue <<= AccessibleStateType::FOCUSED;
395 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
397 break;
398 case VCLEVENT_WINDOW_LOSEFOCUS:
400 aOldValue <<= AccessibleStateType::FOCUSED;
401 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
403 break;
404 case VCLEVENT_WINDOW_SHOW:
406 aNewValue <<= AccessibleStateType::SHOWING;
407 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
409 break;
410 case VCLEVENT_WINDOW_HIDE:
412 aOldValue <<= AccessibleStateType::SHOWING;
413 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
415 break;
416 case VCLEVENT_WINDOW_RESIZE:
418 NotifyAccessibleEvent( AccessibleEventId::BOUNDRECT_CHANGED, aOldValue, aNewValue );
419 UpdateChildren();
420 UpdateBounds();
422 break;
423 case VCLEVENT_OBJECT_DYING:
425 if ( m_pDialogWindow )
427 m_pDialogWindow->RemoveEventListener( LINK( this, AccessibleDialogWindow, WindowEventListener ) );
428 m_pDialogWindow = NULL;
430 if ( m_pDlgEditor )
431 EndListening( *m_pDlgEditor );
432 m_pDlgEditor = NULL;
434 if ( m_pDlgEdModel )
435 EndListening( *m_pDlgEdModel );
436 m_pDlgEdModel = NULL;
438 // dispose all children
439 for ( sal_uInt32 i = 0; i < m_aAccessibleChildren.size(); ++i )
441 Reference< XComponent > xComponent( m_aAccessibleChildren[i].rxAccessible, UNO_QUERY );
442 if ( xComponent.is() )
443 xComponent->dispose();
445 m_aAccessibleChildren.clear();
448 break;
449 default:
452 break;
458 void AccessibleDialogWindow::FillAccessibleStateSet( utl::AccessibleStateSetHelper& rStateSet )
460 if ( m_pDialogWindow )
462 if ( m_pDialogWindow->IsEnabled() )
463 rStateSet.AddState( AccessibleStateType::ENABLED );
465 rStateSet.AddState( AccessibleStateType::FOCUSABLE );
467 if ( m_pDialogWindow->HasFocus() )
468 rStateSet.AddState( AccessibleStateType::FOCUSED );
470 rStateSet.AddState( AccessibleStateType::VISIBLE );
472 if ( m_pDialogWindow->IsVisible() )
473 rStateSet.AddState( AccessibleStateType::SHOWING );
475 rStateSet.AddState( AccessibleStateType::OPAQUE );
477 rStateSet.AddState( AccessibleStateType::RESIZABLE );
482 // OCommonAccessibleComponent
485 awt::Rectangle AccessibleDialogWindow::implGetBounds() throw (RuntimeException)
487 awt::Rectangle aBounds;
488 if ( m_pDialogWindow )
489 aBounds = AWTRectangle( Rectangle( m_pDialogWindow->GetPosPixel(), m_pDialogWindow->GetSizePixel() ) );
491 return aBounds;
495 // SfxListener
498 void AccessibleDialogWindow::Notify( SfxBroadcaster&, const SfxHint& rHint )
500 if (SdrHint const* pSdrHint = dynamic_cast<SdrHint const*>(&rHint))
502 switch ( pSdrHint->GetKind() )
504 case HINT_OBJINSERTED:
506 if (DlgEdObj const* pDlgEdObj = dynamic_cast<DlgEdObj const*>(pSdrHint->GetObject()))
508 ChildDescriptor aDesc(const_cast<DlgEdObj*>(pDlgEdObj));
509 if ( IsChildVisible( aDesc ) )
510 InsertChild( aDesc );
513 break;
514 case HINT_OBJREMOVED:
516 if (DlgEdObj const* pDlgEdObj = dynamic_cast<DlgEdObj const*>(pSdrHint->GetObject()))
517 RemoveChild( ChildDescriptor(const_cast<DlgEdObj*>(pDlgEdObj)) );
519 break;
520 default: ;
523 else if (DlgEdHint const* pDlgEdHint = dynamic_cast<DlgEdHint const*>(&rHint))
525 switch (pDlgEdHint->GetKind())
527 case DlgEdHint::WINDOWSCROLLED:
529 UpdateChildren();
530 UpdateBounds();
532 break;
533 case DlgEdHint::LAYERCHANGED:
535 if (DlgEdObj* pDlgEdObj = pDlgEdHint->GetObject())
536 UpdateChild( ChildDescriptor( pDlgEdObj ) );
538 break;
539 case DlgEdHint::OBJORDERCHANGED:
541 SortChildren();
543 break;
544 case DlgEdHint::SELECTIONCHANGED:
546 UpdateFocused();
547 UpdateSelected();
549 break;
550 default: ;
556 // XInterface
559 IMPLEMENT_FORWARD_XINTERFACE2( AccessibleDialogWindow, AccessibleExtendedComponentHelper_BASE, AccessibleDialogWindow_BASE )
562 // XTypeProvider
565 IMPLEMENT_FORWARD_XTYPEPROVIDER2( AccessibleDialogWindow, AccessibleExtendedComponentHelper_BASE, AccessibleDialogWindow_BASE )
568 // XComponent
571 void AccessibleDialogWindow::disposing()
573 AccessibleExtendedComponentHelper_BASE::disposing();
575 if ( m_pDialogWindow )
577 m_pDialogWindow->RemoveEventListener( LINK( this, AccessibleDialogWindow, WindowEventListener ) );
578 m_pDialogWindow = NULL;
580 if ( m_pDlgEditor )
581 EndListening( *m_pDlgEditor );
582 m_pDlgEditor = NULL;
584 if ( m_pDlgEdModel )
585 EndListening( *m_pDlgEdModel );
586 m_pDlgEdModel = NULL;
588 // dispose all children
589 for ( sal_uInt32 i = 0; i < m_aAccessibleChildren.size(); ++i )
591 Reference< XComponent > xComponent( m_aAccessibleChildren[i].rxAccessible, UNO_QUERY );
592 if ( xComponent.is() )
593 xComponent->dispose();
595 m_aAccessibleChildren.clear();
599 // XServiceInfo
600 OUString AccessibleDialogWindow::getImplementationName() throw (RuntimeException, std::exception)
602 return OUString( "com.sun.star.comp.basctl.AccessibleWindow" );
605 sal_Bool AccessibleDialogWindow::supportsService( const OUString& rServiceName ) throw (RuntimeException, std::exception)
607 return cppu::supportsService(this, rServiceName);
610 Sequence< OUString > AccessibleDialogWindow::getSupportedServiceNames() throw (RuntimeException, std::exception)
612 Sequence< OUString > aNames(1);
613 aNames[0] = "com.sun.star.awt.AccessibleWindow" ;
614 return aNames;
617 // XAccessible
618 Reference< XAccessibleContext > AccessibleDialogWindow::getAccessibleContext( ) throw (RuntimeException, std::exception)
620 OExternalLockGuard aGuard( this );
622 return this;
625 // XAccessibleContext
626 sal_Int32 AccessibleDialogWindow::getAccessibleChildCount() throw (RuntimeException, std::exception)
628 OExternalLockGuard aGuard( this );
630 return m_aAccessibleChildren.size();
635 Reference< XAccessible > AccessibleDialogWindow::getAccessibleChild( sal_Int32 i ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
637 OExternalLockGuard aGuard( this );
639 if ( i < 0 || i >= getAccessibleChildCount() )
640 throw IndexOutOfBoundsException();
642 Reference< XAccessible > xChild = m_aAccessibleChildren[i].rxAccessible;
643 if ( !xChild.is() )
645 if ( m_pDialogWindow )
647 DlgEdObj* pDlgEdObj = m_aAccessibleChildren[i].pDlgEdObj;
648 if ( pDlgEdObj )
650 xChild = new AccessibleDialogControlShape( m_pDialogWindow, pDlgEdObj );
652 // insert into child list
653 m_aAccessibleChildren[i].rxAccessible = xChild;
658 return xChild;
663 Reference< XAccessible > AccessibleDialogWindow::getAccessibleParent( ) throw (RuntimeException, std::exception)
665 OExternalLockGuard aGuard( this );
667 Reference< XAccessible > xParent;
668 if ( m_pDialogWindow )
670 vcl::Window* pParent = m_pDialogWindow->GetAccessibleParentWindow();
671 if ( pParent )
672 xParent = pParent->GetAccessible();
675 return xParent;
680 sal_Int32 AccessibleDialogWindow::getAccessibleIndexInParent( ) throw (RuntimeException, std::exception)
682 OExternalLockGuard aGuard( this );
684 sal_Int32 nIndexInParent = -1;
685 if ( m_pDialogWindow )
687 vcl::Window* pParent = m_pDialogWindow->GetAccessibleParentWindow();
688 if ( pParent )
690 for ( sal_uInt16 i = 0, nCount = pParent->GetAccessibleChildWindowCount(); i < nCount; ++i )
692 vcl::Window* pChild = pParent->GetAccessibleChildWindow( i );
693 if ( pChild == static_cast< vcl::Window* >( m_pDialogWindow ) )
695 nIndexInParent = i;
696 break;
702 return nIndexInParent;
707 sal_Int16 AccessibleDialogWindow::getAccessibleRole( ) throw (RuntimeException, std::exception)
709 OExternalLockGuard aGuard( this );
711 return AccessibleRole::PANEL;
716 OUString AccessibleDialogWindow::getAccessibleDescription( ) throw (RuntimeException, std::exception)
718 OExternalLockGuard aGuard( this );
720 OUString sDescription;
721 if ( m_pDialogWindow )
722 sDescription = m_pDialogWindow->GetAccessibleDescription();
724 return sDescription;
729 OUString AccessibleDialogWindow::getAccessibleName( ) throw (RuntimeException, std::exception)
731 OExternalLockGuard aGuard( this );
733 OUString sName;
734 if ( m_pDialogWindow )
735 sName = m_pDialogWindow->GetAccessibleName();
737 return sName;
742 Reference< XAccessibleRelationSet > AccessibleDialogWindow::getAccessibleRelationSet( ) throw (RuntimeException, std::exception)
744 OExternalLockGuard aGuard( this );
746 utl::AccessibleRelationSetHelper* pRelationSetHelper = new utl::AccessibleRelationSetHelper;
747 Reference< XAccessibleRelationSet > xSet = pRelationSetHelper;
748 return xSet;
753 Reference< XAccessibleStateSet > AccessibleDialogWindow::getAccessibleStateSet( ) throw (RuntimeException, std::exception)
755 OExternalLockGuard aGuard( this );
757 utl::AccessibleStateSetHelper* pStateSetHelper = new utl::AccessibleStateSetHelper;
758 Reference< XAccessibleStateSet > xSet = pStateSetHelper;
760 if ( !rBHelper.bDisposed && !rBHelper.bInDispose )
762 FillAccessibleStateSet( *pStateSetHelper );
764 else
766 pStateSetHelper->AddState( AccessibleStateType::DEFUNC );
769 return xSet;
774 Locale AccessibleDialogWindow::getLocale( ) throw (IllegalAccessibleComponentStateException, RuntimeException, std::exception)
776 OExternalLockGuard aGuard( this );
778 return Application::GetSettings().GetLanguageTag().getLocale();
782 // XAccessibleComponent
785 Reference< XAccessible > AccessibleDialogWindow::getAccessibleAtPoint( const awt::Point& rPoint ) throw (RuntimeException, std::exception)
787 OExternalLockGuard aGuard( this );
789 Reference< XAccessible > xChild;
790 for ( sal_uInt32 i = 0; i < m_aAccessibleChildren.size(); ++i )
792 Reference< XAccessible > xAcc = getAccessibleChild( i );
793 if ( xAcc.is() )
795 Reference< XAccessibleComponent > xComp( xAcc->getAccessibleContext(), UNO_QUERY );
796 if ( xComp.is() )
798 Rectangle aRect = VCLRectangle( xComp->getBounds() );
799 Point aPos = VCLPoint( rPoint );
800 if ( aRect.IsInside( aPos ) )
802 xChild = xAcc;
803 break;
809 return xChild;
814 void AccessibleDialogWindow::grabFocus( ) throw (RuntimeException, std::exception)
816 OExternalLockGuard aGuard( this );
818 if ( m_pDialogWindow )
819 m_pDialogWindow->GrabFocus();
824 sal_Int32 AccessibleDialogWindow::getForeground( ) throw (RuntimeException, std::exception)
826 OExternalLockGuard aGuard( this );
828 sal_Int32 nColor = 0;
829 if ( m_pDialogWindow )
831 if ( m_pDialogWindow->IsControlForeground() )
832 nColor = m_pDialogWindow->GetControlForeground().GetColor();
833 else
835 vcl::Font aFont;
836 if ( m_pDialogWindow->IsControlFont() )
837 aFont = m_pDialogWindow->GetControlFont();
838 else
839 aFont = m_pDialogWindow->GetFont();
840 nColor = aFont.GetColor().GetColor();
844 return nColor;
849 sal_Int32 AccessibleDialogWindow::getBackground( ) throw (RuntimeException, std::exception)
851 OExternalLockGuard aGuard( this );
853 sal_Int32 nColor = 0;
854 if ( m_pDialogWindow )
856 if ( m_pDialogWindow->IsControlBackground() )
857 nColor = m_pDialogWindow->GetControlBackground().GetColor();
858 else
859 nColor = m_pDialogWindow->GetBackground().GetColor().GetColor();
862 return nColor;
866 // XAccessibleExtendedComponent
869 Reference< awt::XFont > AccessibleDialogWindow::getFont( ) throw (RuntimeException, std::exception)
871 OExternalLockGuard aGuard( this );
873 Reference< awt::XFont > xFont;
874 if ( m_pDialogWindow )
876 Reference< awt::XDevice > xDev( m_pDialogWindow->GetComponentInterface(), UNO_QUERY );
877 if ( xDev.is() )
879 vcl::Font aFont;
880 if ( m_pDialogWindow->IsControlFont() )
881 aFont = m_pDialogWindow->GetControlFont();
882 else
883 aFont = m_pDialogWindow->GetFont();
884 VCLXFont* pVCLXFont = new VCLXFont;
885 pVCLXFont->Init( *xDev.get(), aFont );
886 xFont = pVCLXFont;
890 return xFont;
895 OUString AccessibleDialogWindow::getTitledBorderText( ) throw (RuntimeException, std::exception)
897 OExternalLockGuard aGuard( this );
899 return OUString();
904 OUString AccessibleDialogWindow::getToolTipText( ) throw (RuntimeException, std::exception)
906 OExternalLockGuard aGuard( this );
908 OUString sText;
909 if ( m_pDialogWindow )
910 sText = m_pDialogWindow->GetQuickHelpText();
912 return sText;
916 // XAccessibleSelection
919 void AccessibleDialogWindow::selectAccessibleChild( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
921 OExternalLockGuard aGuard( this );
923 if ( nChildIndex < 0 || nChildIndex >= getAccessibleChildCount() )
924 throw IndexOutOfBoundsException();
926 if ( m_pDialogWindow )
928 if (DlgEdObj* pDlgEdObj = m_aAccessibleChildren[nChildIndex].pDlgEdObj)
930 SdrView& rView = m_pDialogWindow->GetView();
931 if (SdrPageView* pPgView = rView.GetSdrPageView())
932 rView.MarkObj(pDlgEdObj, pPgView);
939 sal_Bool AccessibleDialogWindow::isAccessibleChildSelected( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
941 OExternalLockGuard aGuard( this );
943 if ( nChildIndex < 0 || nChildIndex >= getAccessibleChildCount() )
944 throw IndexOutOfBoundsException();
946 if (m_pDialogWindow)
947 if (DlgEdObj* pDlgEdObj = m_aAccessibleChildren[nChildIndex].pDlgEdObj)
948 return m_pDialogWindow->GetView().IsObjMarked(pDlgEdObj);
949 return false;
954 void AccessibleDialogWindow::clearAccessibleSelection()
955 throw (RuntimeException, std::exception)
957 OExternalLockGuard aGuard( this );
959 if ( m_pDialogWindow )
960 m_pDialogWindow->GetView().UnmarkAll();
965 void AccessibleDialogWindow::selectAllAccessibleChildren( ) throw (RuntimeException, std::exception)
967 OExternalLockGuard aGuard( this );
969 if ( m_pDialogWindow )
970 m_pDialogWindow->GetView().MarkAll();
975 sal_Int32 AccessibleDialogWindow::getSelectedAccessibleChildCount( ) throw (RuntimeException, std::exception)
977 OExternalLockGuard aGuard( this );
979 sal_Int32 nRet = 0;
981 for ( sal_Int32 i = 0, nCount = getAccessibleChildCount(); i < nCount; ++i )
983 if ( isAccessibleChildSelected( i ) )
984 ++nRet;
987 return nRet;
992 Reference< XAccessible > AccessibleDialogWindow::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
994 OExternalLockGuard aGuard( this );
996 if ( nSelectedChildIndex < 0 || nSelectedChildIndex >= getSelectedAccessibleChildCount() )
997 throw IndexOutOfBoundsException();
999 Reference< XAccessible > xChild;
1001 for ( sal_Int32 i = 0, j = 0, nCount = getAccessibleChildCount(); i < nCount; ++i )
1003 if ( isAccessibleChildSelected( i ) && ( j++ == nSelectedChildIndex ) )
1005 xChild = getAccessibleChild( i );
1006 break;
1010 return xChild;
1015 void AccessibleDialogWindow::deselectAccessibleChild( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
1017 OExternalLockGuard aGuard( this );
1019 if ( nChildIndex < 0 || nChildIndex >= getAccessibleChildCount() )
1020 throw IndexOutOfBoundsException();
1022 if ( m_pDialogWindow )
1024 if (DlgEdObj* pDlgEdObj = m_aAccessibleChildren[nChildIndex].pDlgEdObj)
1026 SdrView& rView = m_pDialogWindow->GetView();
1027 SdrPageView* pPgView = rView.GetSdrPageView();
1028 if (pPgView)
1029 rView.MarkObj( pDlgEdObj, pPgView, true );
1036 } // namespace basctl
1038 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */