1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include <accessibledialogwindow.hxx>
22 #include <accessibledialogcontrolshape.hxx>
23 #include <baside3.hxx>
25 #include <dlgedmod.hxx>
26 #include <dlgedpage.hxx>
27 #include <dlgedview.hxx>
28 #include <dlgedobj.hxx>
29 #include <com/sun/star/accessibility/AccessibleEventId.hpp>
30 #include <com/sun/star/accessibility/AccessibleRole.hpp>
31 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
32 #include <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>
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
)
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
;
82 bool AccessibleDialogWindow::ChildDescriptor::operator==( const ChildDescriptor
& rDesc
)
85 if ( pDlgEdObj
== rDesc
.pDlgEdObj
)
93 bool AccessibleDialogWindow::ChildDescriptor::operator<( const ChildDescriptor
& rDesc
) const
96 if ( pDlgEdObj
&& rDesc
.pDlgEdObj
&& pDlgEdObj
->GetOrdNum() < rDesc
.pDlgEdObj
->GetOrdNum() )
103 // class AccessibleDialogWindow
106 AccessibleDialogWindow::AccessibleDialogWindow (basctl::DialogWindow
* pDialogWindow
)
107 : AccessibleExtendedComponentHelper_BASE( new VCLExternalSolarLock() )
108 , m_pDialogWindow(pDialogWindow
)
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
) );
146 EndListening( *m_pDlgEditor
);
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
);
164 AccessibleDialogControlShape
* pShape
= static_cast< AccessibleDialogControlShape
* >( xChild
.get() );
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
);
182 AccessibleDialogControlShape
* pShape
= static_cast< AccessibleDialogControlShape
* >( xChild
.get() );
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
);
198 AccessibleDialogControlShape
* pShape
= static_cast< AccessibleDialogControlShape
* >( xChild
.get() );
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
;
218 SdrLayerID nLayerId
= pDlgEdObj
->GetLayer();
219 const SdrLayer
* pSdrLayer
= rLayerAdmin
.GetLayerPerID( nLayerId
);
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
) )
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 ) );
268 // send accessible child event
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
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
);
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()
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
);
356 DBG_ASSERT(false, "AccessibleDialogWindow::WindowEventListener: unknown window event!");
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
);
374 case VCLEVENT_WINDOW_DISABLED
:
376 aOldValue
<<= AccessibleStateType::ENABLED
;
377 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED
, aOldValue
, aNewValue
);
380 case VCLEVENT_WINDOW_ACTIVATE
:
382 aNewValue
<<= AccessibleStateType::ACTIVE
;
383 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED
, aOldValue
, aNewValue
);
386 case VCLEVENT_WINDOW_DEACTIVATE
:
388 aOldValue
<<= AccessibleStateType::ACTIVE
;
389 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED
, aOldValue
, aNewValue
);
392 case VCLEVENT_WINDOW_GETFOCUS
:
394 aNewValue
<<= AccessibleStateType::FOCUSED
;
395 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED
, aOldValue
, aNewValue
);
398 case VCLEVENT_WINDOW_LOSEFOCUS
:
400 aOldValue
<<= AccessibleStateType::FOCUSED
;
401 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED
, aOldValue
, aNewValue
);
404 case VCLEVENT_WINDOW_SHOW
:
406 aNewValue
<<= AccessibleStateType::SHOWING
;
407 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED
, aOldValue
, aNewValue
);
410 case VCLEVENT_WINDOW_HIDE
:
412 aOldValue
<<= AccessibleStateType::SHOWING
;
413 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED
, aOldValue
, aNewValue
);
416 case VCLEVENT_WINDOW_RESIZE
:
418 NotifyAccessibleEvent( AccessibleEventId::BOUNDRECT_CHANGED
, aOldValue
, aNewValue
);
423 case VCLEVENT_OBJECT_DYING
:
425 if ( m_pDialogWindow
)
427 m_pDialogWindow
->RemoveEventListener( LINK( this, AccessibleDialogWindow
, WindowEventListener
) );
428 m_pDialogWindow
= NULL
;
431 EndListening( *m_pDlgEditor
);
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();
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() ) );
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
);
514 case HINT_OBJREMOVED
:
516 if (DlgEdObj
const* pDlgEdObj
= dynamic_cast<DlgEdObj
const*>(pSdrHint
->GetObject()))
517 RemoveChild( ChildDescriptor(const_cast<DlgEdObj
*>(pDlgEdObj
)) );
523 else if (DlgEdHint
const* pDlgEdHint
= dynamic_cast<DlgEdHint
const*>(&rHint
))
525 switch (pDlgEdHint
->GetKind())
527 case DlgEdHint::WINDOWSCROLLED
:
533 case DlgEdHint::LAYERCHANGED
:
535 if (DlgEdObj
* pDlgEdObj
= pDlgEdHint
->GetObject())
536 UpdateChild( ChildDescriptor( pDlgEdObj
) );
539 case DlgEdHint::OBJORDERCHANGED
:
544 case DlgEdHint::SELECTIONCHANGED
:
559 IMPLEMENT_FORWARD_XINTERFACE2( AccessibleDialogWindow
, AccessibleExtendedComponentHelper_BASE
, AccessibleDialogWindow_BASE
)
565 IMPLEMENT_FORWARD_XTYPEPROVIDER2( AccessibleDialogWindow
, AccessibleExtendedComponentHelper_BASE
, AccessibleDialogWindow_BASE
)
571 void AccessibleDialogWindow::disposing()
573 AccessibleExtendedComponentHelper_BASE::disposing();
575 if ( m_pDialogWindow
)
577 m_pDialogWindow
->RemoveEventListener( LINK( this, AccessibleDialogWindow
, WindowEventListener
) );
578 m_pDialogWindow
= NULL
;
581 EndListening( *m_pDlgEditor
);
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();
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" ;
618 Reference
< XAccessibleContext
> AccessibleDialogWindow::getAccessibleContext( ) throw (RuntimeException
, std::exception
)
620 OExternalLockGuard
aGuard( 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
;
645 if ( m_pDialogWindow
)
647 DlgEdObj
* pDlgEdObj
= m_aAccessibleChildren
[i
].pDlgEdObj
;
650 xChild
= new AccessibleDialogControlShape( m_pDialogWindow
, pDlgEdObj
);
652 // insert into child list
653 m_aAccessibleChildren
[i
].rxAccessible
= 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();
672 xParent
= pParent
->GetAccessible();
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();
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
) )
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();
729 OUString
AccessibleDialogWindow::getAccessibleName( ) throw (RuntimeException
, std::exception
)
731 OExternalLockGuard
aGuard( this );
734 if ( m_pDialogWindow
)
735 sName
= m_pDialogWindow
->GetAccessibleName();
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
;
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
);
766 pStateSetHelper
->AddState( AccessibleStateType::DEFUNC
);
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
);
795 Reference
< XAccessibleComponent
> xComp( xAcc
->getAccessibleContext(), UNO_QUERY
);
798 Rectangle aRect
= VCLRectangle( xComp
->getBounds() );
799 Point aPos
= VCLPoint( rPoint
);
800 if ( aRect
.IsInside( aPos
) )
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();
836 if ( m_pDialogWindow
->IsControlFont() )
837 aFont
= m_pDialogWindow
->GetControlFont();
839 aFont
= m_pDialogWindow
->GetFont();
840 nColor
= aFont
.GetColor().GetColor();
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();
859 nColor
= m_pDialogWindow
->GetBackground().GetColor().GetColor();
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
);
880 if ( m_pDialogWindow
->IsControlFont() )
881 aFont
= m_pDialogWindow
->GetControlFont();
883 aFont
= m_pDialogWindow
->GetFont();
884 VCLXFont
* pVCLXFont
= new VCLXFont
;
885 pVCLXFont
->Init( *xDev
.get(), aFont
);
895 OUString
AccessibleDialogWindow::getTitledBorderText( ) throw (RuntimeException
, std::exception
)
897 OExternalLockGuard
aGuard( this );
904 OUString
AccessibleDialogWindow::getToolTipText( ) throw (RuntimeException
, std::exception
)
906 OExternalLockGuard
aGuard( this );
909 if ( m_pDialogWindow
)
910 sText
= m_pDialogWindow
->GetQuickHelpText();
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();
947 if (DlgEdObj
* pDlgEdObj
= m_aAccessibleChildren
[nChildIndex
].pDlgEdObj
)
948 return m_pDialogWindow
->GetView().IsObjMarked(pDlgEdObj
);
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 );
981 for ( sal_Int32 i
= 0, nCount
= getAccessibleChildCount(); i
< nCount
; ++i
)
983 if ( isAccessibleChildSelected( i
) )
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
);
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();
1029 rView
.MarkObj( pDlgEdObj
, pPgView
, true );
1036 } // namespace basctl
1038 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */