build fix: no comphelper/profilezone.hxx in this branch
[LibreOffice.git] / basctl / source / accessibility / accessibledialogwindow.cxx
blob653625857043163fedfeed9c7604d2c0a34f8f3f
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( nullptr )
57 AccessibleDialogWindow::ChildDescriptor::~ChildDescriptor()
62 AccessibleDialogWindow::ChildDescriptor::ChildDescriptor( const ChildDescriptor& rDesc )
63 :pDlgEdObj( rDesc.pDlgEdObj )
64 ,rxAccessible( rDesc.rxAccessible )
69 AccessibleDialogWindow::ChildDescriptor& AccessibleDialogWindow::ChildDescriptor::operator=( const ChildDescriptor& rDesc )
71 pDlgEdObj = rDesc.pDlgEdObj;
72 rxAccessible = rDesc.rxAccessible;
74 return *this;
78 bool AccessibleDialogWindow::ChildDescriptor::operator==( const ChildDescriptor& rDesc )
80 bool bRet = false;
81 if ( pDlgEdObj == rDesc.pDlgEdObj )
82 bRet = true;
84 return bRet;
88 bool AccessibleDialogWindow::ChildDescriptor::operator<( const ChildDescriptor& rDesc ) const
90 bool bRet = false;
91 if ( pDlgEdObj && rDesc.pDlgEdObj && pDlgEdObj->GetOrdNum() < rDesc.pDlgEdObj->GetOrdNum() )
92 bRet = true;
94 return bRet;
98 // class AccessibleDialogWindow
101 AccessibleDialogWindow::AccessibleDialogWindow (basctl::DialogWindow* pDialogWindow)
102 : OAccessibleExtendedComponentHelper( new VCLExternalSolarLock() )
103 , m_pDialogWindow(pDialogWindow)
104 , m_pDlgEditor(nullptr)
105 , m_pDlgEdModel(nullptr)
107 m_pExternalLock = static_cast< VCLExternalSolarLock* >( getExternalLock() );
109 if ( m_pDialogWindow )
111 SdrPage& rPage = m_pDialogWindow->GetPage();
112 const size_t nCount = rPage.GetObjCount();
114 for ( size_t i = 0; i < nCount; ++i )
116 if (DlgEdObj* pDlgEdObj = dynamic_cast<DlgEdObj*>(rPage.GetObj(i)))
118 ChildDescriptor aDesc( pDlgEdObj );
119 if ( IsChildVisible( aDesc ) )
120 m_aAccessibleChildren.push_back( aDesc );
124 m_pDialogWindow->AddEventListener( LINK( this, AccessibleDialogWindow, WindowEventListener ) );
126 StartListening(m_pDialogWindow->GetEditor());
128 m_pDlgEdModel = &m_pDialogWindow->GetModel();
129 StartListening(*m_pDlgEdModel);
134 AccessibleDialogWindow::~AccessibleDialogWindow()
136 if ( m_pDialogWindow )
137 m_pDialogWindow->RemoveEventListener( LINK( this, AccessibleDialogWindow, WindowEventListener ) );
139 if ( m_pDlgEditor )
140 EndListening( *m_pDlgEditor );
142 if ( m_pDlgEdModel )
143 EndListening( *m_pDlgEdModel );
145 delete m_pExternalLock;
146 m_pExternalLock = nullptr;
150 void AccessibleDialogWindow::UpdateFocused()
152 for (ChildDescriptor & i : m_aAccessibleChildren)
154 Reference< XAccessible > xChild( i.rxAccessible );
155 if ( xChild.is() )
157 AccessibleDialogControlShape* pShape = static_cast< AccessibleDialogControlShape* >( xChild.get() );
158 if ( pShape )
159 pShape->SetFocused( pShape->IsFocused() );
165 void AccessibleDialogWindow::UpdateSelected()
167 NotifyAccessibleEvent( AccessibleEventId::SELECTION_CHANGED, Any(), Any() );
169 for (ChildDescriptor & i : m_aAccessibleChildren)
171 Reference< XAccessible > xChild( i.rxAccessible );
172 if ( xChild.is() )
174 AccessibleDialogControlShape* pShape = static_cast< AccessibleDialogControlShape* >( xChild.get() );
175 if ( pShape )
176 pShape->SetSelected( pShape->IsSelected() );
182 void AccessibleDialogWindow::UpdateBounds()
184 for (ChildDescriptor & i : m_aAccessibleChildren)
186 Reference< XAccessible > xChild( i.rxAccessible );
187 if ( xChild.is() )
189 AccessibleDialogControlShape* pShape = static_cast< AccessibleDialogControlShape* >( xChild.get() );
190 if ( pShape )
191 pShape->SetBounds( pShape->GetBounds() );
197 bool AccessibleDialogWindow::IsChildVisible( const ChildDescriptor& rDesc )
199 bool bVisible = false;
201 if ( m_pDialogWindow )
203 // first check, if the shape is in a visible layer
204 SdrLayerAdmin& rLayerAdmin = m_pDialogWindow->GetModel().GetLayerAdmin();
205 DlgEdObj* pDlgEdObj = rDesc.pDlgEdObj;
206 if ( pDlgEdObj )
208 SdrLayerID nLayerId = pDlgEdObj->GetLayer();
209 const SdrLayer* pSdrLayer = rLayerAdmin.GetLayerPerID( nLayerId );
210 if ( pSdrLayer )
212 OUString aLayerName = pSdrLayer->GetName();
213 SdrView& rView = m_pDialogWindow->GetView();
214 if (rView.IsLayerVisible(aLayerName))
216 // get the bounding box of the shape in logic units
217 Rectangle aRect = pDlgEdObj->GetSnapRect();
219 // transform coordinates relative to the parent
220 MapMode aMap = m_pDialogWindow->GetMapMode();
221 Point aOrg = aMap.GetOrigin();
222 aRect.Move( aOrg.X(), aOrg.Y() );
224 // convert logic units to pixel
225 aRect = m_pDialogWindow->LogicToPixel( aRect, MapMode(MapUnit::Map100thMM) );
227 // check, if the shape's bounding box intersects with the bounding box of its parent
228 Rectangle aParentRect( Point( 0, 0 ), m_pDialogWindow->GetSizePixel() );
229 if ( aParentRect.IsOver( aRect ) )
230 bVisible = true;
236 return bVisible;
240 void AccessibleDialogWindow::InsertChild( const ChildDescriptor& rDesc )
242 // check, if object is already in child list
243 AccessibleChildren::iterator aIter = ::std::find( m_aAccessibleChildren.begin(), m_aAccessibleChildren.end(), rDesc );
245 // if not found, insert in child list
246 if ( aIter == m_aAccessibleChildren.end() )
248 // insert entry in child list
249 m_aAccessibleChildren.push_back( rDesc );
251 // get the accessible of the inserted child
252 Reference< XAccessible > xChild( getAccessibleChild( m_aAccessibleChildren.size() - 1 ) );
254 // sort child list
255 SortChildren();
257 // send accessible child event
258 if ( xChild.is() )
260 Any aOldValue, aNewValue;
261 aNewValue <<= xChild;
262 NotifyAccessibleEvent( AccessibleEventId::CHILD, aOldValue, aNewValue );
268 void AccessibleDialogWindow::RemoveChild( const ChildDescriptor& rDesc )
270 // find object in child list
271 AccessibleChildren::iterator aIter = ::std::find( m_aAccessibleChildren.begin(), m_aAccessibleChildren.end(), rDesc );
273 // if found, remove from child list
274 if ( aIter != m_aAccessibleChildren.end() )
276 // get the accessible of the removed child
277 Reference< XAccessible > xChild( aIter->rxAccessible );
279 // remove entry from child list
280 m_aAccessibleChildren.erase( aIter );
282 // send accessible child event
283 if ( xChild.is() )
285 Any aOldValue, aNewValue;
286 aOldValue <<= xChild;
287 NotifyAccessibleEvent( AccessibleEventId::CHILD, aOldValue, aNewValue );
289 Reference< XComponent > xComponent( xChild, UNO_QUERY );
290 if ( xComponent.is() )
291 xComponent->dispose();
297 void AccessibleDialogWindow::UpdateChild( const ChildDescriptor& rDesc )
299 if ( IsChildVisible( rDesc ) )
301 // if the object is not in the child list, insert child
302 InsertChild( rDesc );
304 else
306 // if the object is in the child list, remove child
307 RemoveChild( rDesc );
312 void AccessibleDialogWindow::UpdateChildren()
314 if ( m_pDialogWindow )
316 SdrPage& rPage = m_pDialogWindow->GetPage();
317 for ( size_t i = 0, nCount = rPage.GetObjCount(); i < nCount; ++i )
318 if (DlgEdObj* pDlgEdObj = dynamic_cast<DlgEdObj*>(rPage.GetObj(i)))
319 UpdateChild( ChildDescriptor( pDlgEdObj ) );
324 void AccessibleDialogWindow::SortChildren()
326 // sort child list
327 ::std::sort( m_aAccessibleChildren.begin(), m_aAccessibleChildren.end() );
331 IMPL_LINK( AccessibleDialogWindow, WindowEventListener, VclWindowEvent&, rEvent, void )
333 DBG_ASSERT(rEvent.GetWindow(), "AccessibleDialogWindow::WindowEventListener: no window!");
334 if (!rEvent.GetWindow()->IsAccessibilityEventsSuppressed() || rEvent.GetId() == VCLEVENT_OBJECT_DYING)
335 ProcessWindowEvent(rEvent);
339 void AccessibleDialogWindow::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
341 Any aOldValue, aNewValue;
343 switch ( rVclWindowEvent.GetId() )
345 case VCLEVENT_WINDOW_ENABLED:
347 aNewValue <<= AccessibleStateType::ENABLED;
348 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
350 break;
351 case VCLEVENT_WINDOW_DISABLED:
353 aOldValue <<= AccessibleStateType::ENABLED;
354 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
356 break;
357 case VCLEVENT_WINDOW_ACTIVATE:
359 aNewValue <<= AccessibleStateType::ACTIVE;
360 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
362 break;
363 case VCLEVENT_WINDOW_DEACTIVATE:
365 aOldValue <<= AccessibleStateType::ACTIVE;
366 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
368 break;
369 case VCLEVENT_WINDOW_GETFOCUS:
371 aNewValue <<= AccessibleStateType::FOCUSED;
372 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
374 break;
375 case VCLEVENT_WINDOW_LOSEFOCUS:
377 aOldValue <<= AccessibleStateType::FOCUSED;
378 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
380 break;
381 case VCLEVENT_WINDOW_SHOW:
383 aNewValue <<= AccessibleStateType::SHOWING;
384 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
386 break;
387 case VCLEVENT_WINDOW_HIDE:
389 aOldValue <<= AccessibleStateType::SHOWING;
390 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
392 break;
393 case VCLEVENT_WINDOW_RESIZE:
395 NotifyAccessibleEvent( AccessibleEventId::BOUNDRECT_CHANGED, aOldValue, aNewValue );
396 UpdateChildren();
397 UpdateBounds();
399 break;
400 case VCLEVENT_OBJECT_DYING:
402 if ( m_pDialogWindow )
404 m_pDialogWindow->RemoveEventListener( LINK( this, AccessibleDialogWindow, WindowEventListener ) );
405 m_pDialogWindow = nullptr;
407 if ( m_pDlgEditor )
408 EndListening( *m_pDlgEditor );
409 m_pDlgEditor = nullptr;
411 if ( m_pDlgEdModel )
412 EndListening( *m_pDlgEdModel );
413 m_pDlgEdModel = nullptr;
415 // dispose all children
416 for (ChildDescriptor & i : m_aAccessibleChildren)
418 Reference< XComponent > xComponent( i.rxAccessible, UNO_QUERY );
419 if ( xComponent.is() )
420 xComponent->dispose();
422 m_aAccessibleChildren.clear();
425 break;
426 default:
429 break;
434 void AccessibleDialogWindow::FillAccessibleStateSet( utl::AccessibleStateSetHelper& rStateSet )
436 if ( m_pDialogWindow )
438 if ( m_pDialogWindow->IsEnabled() )
439 rStateSet.AddState( AccessibleStateType::ENABLED );
441 rStateSet.AddState( AccessibleStateType::FOCUSABLE );
443 if ( m_pDialogWindow->HasFocus() )
444 rStateSet.AddState( AccessibleStateType::FOCUSED );
446 rStateSet.AddState( AccessibleStateType::VISIBLE );
448 if ( m_pDialogWindow->IsVisible() )
449 rStateSet.AddState( AccessibleStateType::SHOWING );
451 rStateSet.AddState( AccessibleStateType::OPAQUE );
453 rStateSet.AddState( AccessibleStateType::RESIZABLE );
458 // OCommonAccessibleComponent
461 awt::Rectangle AccessibleDialogWindow::implGetBounds() throw (RuntimeException)
463 awt::Rectangle aBounds;
464 if ( m_pDialogWindow )
465 aBounds = AWTRectangle( Rectangle( m_pDialogWindow->GetPosPixel(), m_pDialogWindow->GetSizePixel() ) );
467 return aBounds;
471 // SfxListener
474 void AccessibleDialogWindow::Notify( SfxBroadcaster&, const SfxHint& rHint )
476 if (SdrHint const* pSdrHint = dynamic_cast<SdrHint const*>(&rHint))
478 switch ( pSdrHint->GetKind() )
480 case SdrHintKind::ObjectInserted:
482 if (DlgEdObj const* pDlgEdObj = dynamic_cast<DlgEdObj const*>(pSdrHint->GetObject()))
484 ChildDescriptor aDesc(const_cast<DlgEdObj*>(pDlgEdObj));
485 if ( IsChildVisible( aDesc ) )
486 InsertChild( aDesc );
489 break;
490 case SdrHintKind::ObjectRemoved:
492 if (DlgEdObj const* pDlgEdObj = dynamic_cast<DlgEdObj const*>(pSdrHint->GetObject()))
493 RemoveChild( ChildDescriptor(const_cast<DlgEdObj*>(pDlgEdObj)) );
495 break;
496 default: ;
499 else if (DlgEdHint const* pDlgEdHint = dynamic_cast<DlgEdHint const*>(&rHint))
501 switch (pDlgEdHint->GetKind())
503 case DlgEdHint::WINDOWSCROLLED:
505 UpdateChildren();
506 UpdateBounds();
508 break;
509 case DlgEdHint::LAYERCHANGED:
511 if (DlgEdObj* pDlgEdObj = pDlgEdHint->GetObject())
512 UpdateChild( ChildDescriptor( pDlgEdObj ) );
514 break;
515 case DlgEdHint::OBJORDERCHANGED:
517 SortChildren();
519 break;
520 case DlgEdHint::SELECTIONCHANGED:
522 UpdateFocused();
523 UpdateSelected();
525 break;
526 default: ;
532 // XInterface
535 IMPLEMENT_FORWARD_XINTERFACE2( AccessibleDialogWindow, OAccessibleExtendedComponentHelper, AccessibleDialogWindow_BASE )
538 // XTypeProvider
541 IMPLEMENT_FORWARD_XTYPEPROVIDER2( AccessibleDialogWindow, OAccessibleExtendedComponentHelper, AccessibleDialogWindow_BASE )
544 // XComponent
547 void AccessibleDialogWindow::disposing()
549 OAccessibleExtendedComponentHelper::disposing();
551 if ( m_pDialogWindow )
553 m_pDialogWindow->RemoveEventListener( LINK( this, AccessibleDialogWindow, WindowEventListener ) );
554 m_pDialogWindow = nullptr;
556 if ( m_pDlgEditor )
557 EndListening( *m_pDlgEditor );
558 m_pDlgEditor = nullptr;
560 if ( m_pDlgEdModel )
561 EndListening( *m_pDlgEdModel );
562 m_pDlgEdModel = nullptr;
564 // dispose all children
565 for (ChildDescriptor & i : m_aAccessibleChildren)
567 Reference< XComponent > xComponent( i.rxAccessible, UNO_QUERY );
568 if ( xComponent.is() )
569 xComponent->dispose();
571 m_aAccessibleChildren.clear();
575 // XServiceInfo
576 OUString AccessibleDialogWindow::getImplementationName() throw (RuntimeException, std::exception)
578 return OUString( "com.sun.star.comp.basctl.AccessibleWindow" );
581 sal_Bool AccessibleDialogWindow::supportsService( const OUString& rServiceName ) throw (RuntimeException, std::exception)
583 return cppu::supportsService(this, rServiceName);
586 Sequence< OUString > AccessibleDialogWindow::getSupportedServiceNames() throw (RuntimeException, std::exception)
588 return { "com.sun.star.awt.AccessibleWindow" };
591 // XAccessible
592 Reference< XAccessibleContext > AccessibleDialogWindow::getAccessibleContext( ) throw (RuntimeException, std::exception)
594 OExternalLockGuard aGuard( this );
596 return this;
599 // XAccessibleContext
600 sal_Int32 AccessibleDialogWindow::getAccessibleChildCount() throw (RuntimeException, std::exception)
602 OExternalLockGuard aGuard( this );
604 return m_aAccessibleChildren.size();
608 Reference< XAccessible > AccessibleDialogWindow::getAccessibleChild( sal_Int32 i ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
610 OExternalLockGuard aGuard( this );
612 if ( i < 0 || i >= getAccessibleChildCount() )
613 throw IndexOutOfBoundsException();
615 Reference< XAccessible > xChild = m_aAccessibleChildren[i].rxAccessible;
616 if ( !xChild.is() )
618 if ( m_pDialogWindow )
620 DlgEdObj* pDlgEdObj = m_aAccessibleChildren[i].pDlgEdObj;
621 if ( pDlgEdObj )
623 xChild = new AccessibleDialogControlShape( m_pDialogWindow, pDlgEdObj );
625 // insert into child list
626 m_aAccessibleChildren[i].rxAccessible = xChild;
631 return xChild;
635 Reference< XAccessible > AccessibleDialogWindow::getAccessibleParent( ) throw (RuntimeException, std::exception)
637 OExternalLockGuard aGuard( this );
639 Reference< XAccessible > xParent;
640 if ( m_pDialogWindow )
642 vcl::Window* pParent = m_pDialogWindow->GetAccessibleParentWindow();
643 if ( pParent )
644 xParent = pParent->GetAccessible();
647 return xParent;
651 sal_Int32 AccessibleDialogWindow::getAccessibleIndexInParent( ) throw (RuntimeException, std::exception)
653 OExternalLockGuard aGuard( this );
655 sal_Int32 nIndexInParent = -1;
656 if ( m_pDialogWindow )
658 vcl::Window* pParent = m_pDialogWindow->GetAccessibleParentWindow();
659 if ( pParent )
661 for ( sal_uInt16 i = 0, nCount = pParent->GetAccessibleChildWindowCount(); i < nCount; ++i )
663 vcl::Window* pChild = pParent->GetAccessibleChildWindow( i );
664 if ( pChild == static_cast< vcl::Window* >( m_pDialogWindow ) )
666 nIndexInParent = i;
667 break;
673 return nIndexInParent;
677 sal_Int16 AccessibleDialogWindow::getAccessibleRole( ) throw (RuntimeException, std::exception)
679 OExternalLockGuard aGuard( this );
681 return AccessibleRole::PANEL;
685 OUString AccessibleDialogWindow::getAccessibleDescription( ) throw (RuntimeException, std::exception)
687 OExternalLockGuard aGuard( this );
689 OUString sDescription;
690 if ( m_pDialogWindow )
691 sDescription = m_pDialogWindow->GetAccessibleDescription();
693 return sDescription;
697 OUString AccessibleDialogWindow::getAccessibleName( ) throw (RuntimeException, std::exception)
699 OExternalLockGuard aGuard( this );
701 OUString sName;
702 if ( m_pDialogWindow )
703 sName = m_pDialogWindow->GetAccessibleName();
705 return sName;
709 Reference< XAccessibleRelationSet > AccessibleDialogWindow::getAccessibleRelationSet( ) throw (RuntimeException, std::exception)
711 OExternalLockGuard aGuard( this );
713 utl::AccessibleRelationSetHelper* pRelationSetHelper = new utl::AccessibleRelationSetHelper;
714 Reference< XAccessibleRelationSet > xSet = pRelationSetHelper;
715 return xSet;
719 Reference< XAccessibleStateSet > AccessibleDialogWindow::getAccessibleStateSet( ) throw (RuntimeException, std::exception)
721 OExternalLockGuard aGuard( this );
723 utl::AccessibleStateSetHelper* pStateSetHelper = new utl::AccessibleStateSetHelper;
724 Reference< XAccessibleStateSet > xSet = pStateSetHelper;
726 if ( !rBHelper.bDisposed && !rBHelper.bInDispose )
728 FillAccessibleStateSet( *pStateSetHelper );
730 else
732 pStateSetHelper->AddState( AccessibleStateType::DEFUNC );
735 return xSet;
739 Locale AccessibleDialogWindow::getLocale( ) throw (IllegalAccessibleComponentStateException, RuntimeException, std::exception)
741 OExternalLockGuard aGuard( this );
743 return Application::GetSettings().GetLanguageTag().getLocale();
747 // XAccessibleComponent
750 Reference< XAccessible > AccessibleDialogWindow::getAccessibleAtPoint( const awt::Point& rPoint ) throw (RuntimeException, std::exception)
752 OExternalLockGuard aGuard( this );
754 Reference< XAccessible > xChild;
755 for ( size_t i = 0; i < m_aAccessibleChildren.size(); ++i )
757 Reference< XAccessible > xAcc = getAccessibleChild( i );
758 if ( xAcc.is() )
760 Reference< XAccessibleComponent > xComp( xAcc->getAccessibleContext(), UNO_QUERY );
761 if ( xComp.is() )
763 Rectangle aRect = VCLRectangle( xComp->getBounds() );
764 Point aPos = VCLPoint( rPoint );
765 if ( aRect.IsInside( aPos ) )
767 xChild = xAcc;
768 break;
774 return xChild;
778 void AccessibleDialogWindow::grabFocus( ) throw (RuntimeException, std::exception)
780 OExternalLockGuard aGuard( this );
782 if ( m_pDialogWindow )
783 m_pDialogWindow->GrabFocus();
787 sal_Int32 AccessibleDialogWindow::getForeground( ) throw (RuntimeException, std::exception)
789 OExternalLockGuard aGuard( this );
791 sal_Int32 nColor = 0;
792 if ( m_pDialogWindow )
794 if ( m_pDialogWindow->IsControlForeground() )
795 nColor = m_pDialogWindow->GetControlForeground().GetColor();
796 else
798 vcl::Font aFont;
799 if ( m_pDialogWindow->IsControlFont() )
800 aFont = m_pDialogWindow->GetControlFont();
801 else
802 aFont = m_pDialogWindow->GetFont();
803 nColor = aFont.GetColor().GetColor();
807 return nColor;
811 sal_Int32 AccessibleDialogWindow::getBackground( ) throw (RuntimeException, std::exception)
813 OExternalLockGuard aGuard( this );
815 sal_Int32 nColor = 0;
816 if ( m_pDialogWindow )
818 if ( m_pDialogWindow->IsControlBackground() )
819 nColor = m_pDialogWindow->GetControlBackground().GetColor();
820 else
821 nColor = m_pDialogWindow->GetBackground().GetColor().GetColor();
824 return nColor;
828 // XAccessibleExtendedComponent
831 Reference< awt::XFont > AccessibleDialogWindow::getFont( ) throw (RuntimeException, std::exception)
833 OExternalLockGuard aGuard( this );
835 Reference< awt::XFont > xFont;
836 if ( m_pDialogWindow )
838 Reference< awt::XDevice > xDev( m_pDialogWindow->GetComponentInterface(), UNO_QUERY );
839 if ( xDev.is() )
841 vcl::Font aFont;
842 if ( m_pDialogWindow->IsControlFont() )
843 aFont = m_pDialogWindow->GetControlFont();
844 else
845 aFont = m_pDialogWindow->GetFont();
846 VCLXFont* pVCLXFont = new VCLXFont;
847 pVCLXFont->Init( *xDev.get(), aFont );
848 xFont = pVCLXFont;
852 return xFont;
856 OUString AccessibleDialogWindow::getTitledBorderText( ) throw (RuntimeException, std::exception)
858 OExternalLockGuard aGuard( this );
860 return OUString();
864 OUString AccessibleDialogWindow::getToolTipText( ) throw (RuntimeException, std::exception)
866 OExternalLockGuard aGuard( this );
868 OUString sText;
869 if ( m_pDialogWindow )
870 sText = m_pDialogWindow->GetQuickHelpText();
872 return sText;
876 // XAccessibleSelection
879 void AccessibleDialogWindow::selectAccessibleChild( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
881 OExternalLockGuard aGuard( this );
883 if ( nChildIndex < 0 || nChildIndex >= getAccessibleChildCount() )
884 throw IndexOutOfBoundsException();
886 if ( m_pDialogWindow )
888 if (DlgEdObj* pDlgEdObj = m_aAccessibleChildren[nChildIndex].pDlgEdObj)
890 SdrView& rView = m_pDialogWindow->GetView();
891 if (SdrPageView* pPgView = rView.GetSdrPageView())
892 rView.MarkObj(pDlgEdObj, pPgView);
898 sal_Bool AccessibleDialogWindow::isAccessibleChildSelected( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
900 OExternalLockGuard aGuard( this );
902 if ( nChildIndex < 0 || nChildIndex >= getAccessibleChildCount() )
903 throw IndexOutOfBoundsException();
905 if (m_pDialogWindow)
906 if (DlgEdObj* pDlgEdObj = m_aAccessibleChildren[nChildIndex].pDlgEdObj)
907 return m_pDialogWindow->GetView().IsObjMarked(pDlgEdObj);
908 return false;
912 void AccessibleDialogWindow::clearAccessibleSelection()
913 throw (RuntimeException, std::exception)
915 OExternalLockGuard aGuard( this );
917 if ( m_pDialogWindow )
918 m_pDialogWindow->GetView().UnmarkAll();
922 void AccessibleDialogWindow::selectAllAccessibleChildren( ) throw (RuntimeException, std::exception)
924 OExternalLockGuard aGuard( this );
926 if ( m_pDialogWindow )
927 m_pDialogWindow->GetView().MarkAll();
931 sal_Int32 AccessibleDialogWindow::getSelectedAccessibleChildCount( ) throw (RuntimeException, std::exception)
933 OExternalLockGuard aGuard( this );
935 sal_Int32 nRet = 0;
937 for ( sal_Int32 i = 0, nCount = getAccessibleChildCount(); i < nCount; ++i )
939 if ( isAccessibleChildSelected( i ) )
940 ++nRet;
943 return nRet;
947 Reference< XAccessible > AccessibleDialogWindow::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
949 OExternalLockGuard aGuard( this );
951 if ( nSelectedChildIndex < 0 || nSelectedChildIndex >= getSelectedAccessibleChildCount() )
952 throw IndexOutOfBoundsException();
954 Reference< XAccessible > xChild;
956 for ( sal_Int32 i = 0, j = 0, nCount = getAccessibleChildCount(); i < nCount; ++i )
958 if ( isAccessibleChildSelected( i ) && ( j++ == nSelectedChildIndex ) )
960 xChild = getAccessibleChild( i );
961 break;
965 return xChild;
969 void AccessibleDialogWindow::deselectAccessibleChild( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
971 OExternalLockGuard aGuard( this );
973 if ( nChildIndex < 0 || nChildIndex >= getAccessibleChildCount() )
974 throw IndexOutOfBoundsException();
976 if ( m_pDialogWindow )
978 if (DlgEdObj* pDlgEdObj = m_aAccessibleChildren[nChildIndex].pDlgEdObj)
980 SdrView& rView = m_pDialogWindow->GetView();
981 SdrPageView* pPgView = rView.GetSdrPageView();
982 if (pPgView)
983 rView.MarkObj( pDlgEdObj, pPgView, true );
989 } // namespace basctl
991 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */