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 .
20 #include <com/sun/star/accessibility/AccessibleRole.hpp>
21 #include <com/sun/star/accessibility/AccessibleEventId.hpp>
22 #include <unotools/accessiblestatesethelper.hxx>
23 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
24 #include <com/sun/star/beans/PropertyChangeEvent.hpp>
25 #include <com/sun/star/awt/XWindow.hpp>
26 #include <cppuhelper/supportsservice.hxx>
27 #include <cppuhelper/typeprovider.hxx>
28 #include <toolkit/helper/vclunohelper.hxx>
29 #include <toolkit/helper/convert.hxx>
30 #include <vcl/svapp.hxx>
31 #include <vcl/settings.hxx>
32 #include <osl/mutex.hxx>
34 #include <tools/debug.hxx>
35 #include <tools/gen.hxx>
37 #include <svx/dialogs.hrc>
38 #include "accessibility.hrc"
39 #include <svx/dlgctrl.hxx>
41 #include <svx/dialmgr.hxx>
42 #include <comphelper/accessibleeventnotifier.hxx>
44 #include <unotools/accessiblerelationsethelper.hxx>
46 #include "svxpixelctlaccessiblecontext.hxx"
47 #include <com/sun/star/accessibility/AccessibleRelationType.hpp>
49 using namespace ::cppu
;
50 using namespace ::osl
;
51 using namespace ::rtl
;
52 using namespace ::com::sun::star
;
53 using namespace ::com::sun::star::uno
;
54 using namespace ::com::sun::star::accessibility
;
56 SvxPixelCtlAccessible::SvxPixelCtlAccessible( SvxPixelCtl
& rControl
) :
57 SvxPixelCtlAccessible_BASE(m_aMutex
),
63 SvxPixelCtlAccessible::~SvxPixelCtlAccessible()
67 osl_atomic_increment( &m_refCount
);
68 dispose(); // set mpRepr = NULL & release all childs
71 /*-- 04.02.2002 14:11:55---------------------------------------------------
73 -----------------------------------------------------------------------*/
74 uno::Reference
< XAccessibleContext
> SvxPixelCtlAccessible::getAccessibleContext( )
75 throw (uno::RuntimeException
, std::exception
)
80 sal_Int32
SvxPixelCtlAccessible::getAccessibleChildCount( ) throw (uno::RuntimeException
, std::exception
)
82 ::osl::MutexGuard
aGuard( m_aMutex
);
83 return mrPixelCtl
.GetSquares();
85 /*-- 04.02.2002 14:11:56---------------------------------------------------
87 -----------------------------------------------------------------------*/
88 uno::Reference
< XAccessible
> SvxPixelCtlAccessible::getAccessibleChild( sal_Int32 i
)
89 throw (lang::IndexOutOfBoundsException
, uno::RuntimeException
, std::exception
)
91 ::osl::MutexGuard
aGuard( m_aMutex
);
92 if ( i
< 0 || i
>= getAccessibleChildCount())
93 throw lang::IndexOutOfBoundsException();
94 uno::Reference
<XAccessible
> xAcc
;
95 return CreateChild(i
, mrPixelCtl
.IndexToPoint(i
));
100 uno::Reference
< XAccessible
> SvxPixelCtlAccessible::getAccessibleParent( )
101 throw (uno::RuntimeException
, std::exception
)
103 ::osl::MutexGuard
aGuard( m_aMutex
);
104 Window
*pTabPage
= getNonLayoutParent(&mrPixelCtl
);
105 assert(pTabPage
&& WINDOW_TABPAGE
== pTabPage
->GetType());
106 return pTabPage
->GetAccessible( true );
109 sal_Int32
SvxPixelCtlAccessible::getAccessibleIndexInParent( )
110 throw (uno::RuntimeException
, std::exception
)
112 ::osl::MutexGuard
aGuard( m_aMutex
);
114 Window
*pTabPage
= getNonLayoutParent(&mrPixelCtl
);
115 assert(pTabPage
&& WINDOW_TABPAGE
== pTabPage
->GetType());
116 sal_uInt16 nChildren
= pTabPage
->GetChildCount();
117 for(nIdx
= 0; nIdx
< nChildren
; nIdx
++)
118 if(pTabPage
->GetChild( nIdx
) == &mrPixelCtl
)
122 /*-- 04.02.2002 14:11:57---------------------------------------------------
124 -----------------------------------------------------------------------*/
125 sal_Int16
SvxPixelCtlAccessible::getAccessibleRole( ) throw (uno::RuntimeException
, std::exception
)
127 return AccessibleRole::LIST
;
130 OUString
SvxPixelCtlAccessible::getAccessibleDescription( )
131 throw (uno::RuntimeException
, std::exception
)
134 ::osl::MutexGuard
aGuard( m_aMutex
);
135 return mrPixelCtl
.GetAccessibleDescription();
138 OUString
SvxPixelCtlAccessible::getAccessibleName( )
139 throw (uno::RuntimeException
, std::exception
)
142 ::osl::MutexGuard
aGuard( m_aMutex
);
143 return mrPixelCtl
.GetAccessibleName();
146 uno::Reference
< XAccessibleRelationSet
> SvxPixelCtlAccessible::getAccessibleRelationSet( )
147 throw (uno::RuntimeException
, std::exception
)
149 ::osl::MutexGuard
aGuard( m_aMutex
);
150 utl::AccessibleRelationSetHelper
* rRelationSet
= new utl::AccessibleRelationSetHelper
;
151 uno::Reference
< css::accessibility::XAccessibleRelationSet
> rSet
= rRelationSet
;
152 Window
*pLabeledBy
= mrPixelCtl
.GetAccessibleRelationLabeledBy();
153 if ( pLabeledBy
&& pLabeledBy
!= &mrPixelCtl
)
155 uno::Sequence
< uno::Reference
< uno::XInterface
> > aSequence(1);
156 aSequence
[0] = pLabeledBy
->GetAccessible();
157 rRelationSet
->AddRelation( css::accessibility::AccessibleRelation( css::accessibility::AccessibleRelationType::LABELED_BY
, aSequence
) );
160 Window
* pMemberOf
= mrPixelCtl
.GetAccessibleRelationMemberOf();
161 if ( pMemberOf
&& pMemberOf
!= &mrPixelCtl
)
163 uno::Sequence
< uno::Reference
< uno::XInterface
> > aSequence(1);
164 aSequence
[0] = pMemberOf
->GetAccessible();
165 rRelationSet
->AddRelation( css::accessibility::AccessibleRelation( css::accessibility::AccessibleRelationType::MEMBER_OF
, aSequence
) );
171 uno::Reference
< XAccessibleStateSet
> SvxPixelCtlAccessible::getAccessibleStateSet( )
172 throw (uno::RuntimeException
, std::exception
)
174 ::osl::MutexGuard
aGuard( m_aMutex
);
175 utl::AccessibleStateSetHelper
* pStateSetHelper
= new utl::AccessibleStateSetHelper
;
176 uno::Reference
< XAccessibleStateSet
> xRet
= pStateSetHelper
;
178 const sal_Int16 aStandardStates
[] =
180 AccessibleStateType::FOCUSABLE
,
181 AccessibleStateType::SELECTABLE
,
182 AccessibleStateType::SHOWING
,
183 AccessibleStateType::VISIBLE
,
184 AccessibleStateType::OPAQUE
,
188 sal_Int16 nState
= 0;
189 while(aStandardStates
[nState
])
191 pStateSetHelper
->AddState(aStandardStates
[nState
++]);
193 if(mrPixelCtl
.IsEnabled())
194 pStateSetHelper
->AddState(AccessibleStateType::ENABLED
);
195 if(mrPixelCtl
.HasFocus())
196 pStateSetHelper
->AddState(AccessibleStateType::FOCUSED
);
197 pStateSetHelper
->AddState(AccessibleStateType::MANAGES_DESCENDANTS
);
203 com::sun::star::lang::Locale
SvxPixelCtlAccessible::getLocale( )
204 throw (IllegalAccessibleComponentStateException
, uno::RuntimeException
, std::exception
)
206 ::osl::MutexGuard
aGuard( m_aMutex
);
207 if( getAccessibleParent().is() )
209 uno::Reference
< XAccessibleContext
> xParentContext( getAccessibleParent()->getAccessibleContext() );
210 if( xParentContext
.is() )
211 return xParentContext
->getLocale();
214 // No locale and no parent. Therefore throw exception to indicate this
216 throw IllegalAccessibleComponentStateException();
220 sal_Bool
SvxPixelCtlAccessible::containsPoint( const awt::Point
& aPt
)
221 throw (uno::RuntimeException
, std::exception
)
223 ::osl::MutexGuard
aGuard( m_aMutex
);
224 Point
aPoint(aPt
.X
, aPt
.Y
);
225 return (aPoint
.X() >= 0)
226 && (aPoint
.X() < mrPixelCtl
.GetSizePixel().getWidth())
228 && (aPoint
.Y() < mrPixelCtl
.GetSizePixel().getHeight());
230 uno::Reference
<XAccessible
> SAL_CALL
SvxPixelCtlAccessible::getAccessibleAtPoint (
231 const awt::Point
& aPoint
)
232 throw (uno::RuntimeException
, std::exception
)
234 ::osl::MutexGuard
aGuard( m_aMutex
);
236 uno::Reference
<XAccessible
> xAcc
;
239 childPoint
.X() = aPoint
.X
;
240 childPoint
.Y() = aPoint
.Y
;
242 Point pt
= mrPixelCtl
.PixelToLogic(childPoint
);
243 long nIndex
= mrPixelCtl
.PointToIndex(pt
);
244 return CreateChild(nIndex
, mrPixelCtl
.IndexToPoint(nIndex
));
247 awt::Rectangle
SvxPixelCtlAccessible::getBounds( ) throw (uno::RuntimeException
, std::exception
)
249 ::osl::MutexGuard
aGuard( m_aMutex
);
251 Size aSz
= mrPixelCtl
.GetSizePixel();
252 Point aPos
= mrPixelCtl
.GetPosPixel();
255 aRet
.Width
= aSz
.Width();
256 aRet
.Height
= aSz
.Height();
260 awt::Point
SvxPixelCtlAccessible::getLocation( ) throw (uno::RuntimeException
, std::exception
)
262 ::osl::MutexGuard
aGuard( m_aMutex
);
264 aPos
= mrPixelCtl
.GetPosPixel();
265 awt::Point
aRet(aPos
.X(), aPos
.Y());
269 awt::Point
SvxPixelCtlAccessible::getLocationOnScreen( ) throw (uno::RuntimeException
, std::exception
)
271 ::osl::MutexGuard
aGuard( m_aMutex
);
272 Rectangle rect
= mrPixelCtl
.GetWindowExtentsRelative(NULL
);
273 return awt::Point(rect
.Left(),rect
.Top() );
276 awt::Size
SvxPixelCtlAccessible::getSize( ) throw (uno::RuntimeException
, std::exception
)
278 ::osl::MutexGuard
aGuard( m_aMutex
);
279 Size aSz
= mrPixelCtl
.GetSizePixel();
280 return awt::Size(aSz
.Width(),aSz
.Height());
282 void SvxPixelCtlAccessible::grabFocus( ) throw (uno::RuntimeException
, std::exception
)
284 ::osl::MutexGuard
aGuard( m_aMutex
);
285 mrPixelCtl
.GrabFocus();
288 sal_Int32
SvxPixelCtlAccessible::getForeground( )
289 throw (::com::sun::star::uno::RuntimeException
, std::exception
)
291 ::osl::MutexGuard
aGuard( m_aMutex
);
292 return mrPixelCtl
.GetControlForeground().GetColor();
295 sal_Int32
SvxPixelCtlAccessible::getBackground( )
296 throw (::com::sun::star::uno::RuntimeException
, std::exception
)
298 ::osl::MutexGuard
aGuard( m_aMutex
);
299 return mrPixelCtl
.GetControlBackground().GetColor();
302 OUString
SvxPixelCtlAccessible::getImplementationName( ) throw (uno::RuntimeException
, std::exception
)
304 return OUString("SvxPixelCtlAccessible");
307 sal_Bool
SvxPixelCtlAccessible::supportsService( const OUString
& rServiceName
)
308 throw (uno::RuntimeException
, std::exception
)
310 return cppu::supportsService( this, rServiceName
);
313 uno::Sequence
< OUString
> SvxPixelCtlAccessible::getSupportedServiceNames( )
314 throw (uno::RuntimeException
, std::exception
)
316 uno::Sequence
< OUString
> aRet(2);
317 OUString
* pArray
= aRet
.getArray();
318 pArray
[0] = "Accessible";
319 pArray
[1] = "AccessibleContext";
320 pArray
[2] = "AccessibleComponent";
325 // XAccessibleSelection
327 void SAL_CALL
SvxPixelCtlAccessible::selectAccessibleChild( sal_Int32 nChildIndex
) throw (lang::IndexOutOfBoundsException
, RuntimeException
, std::exception
)
329 ::osl::MutexGuard
aGuard( m_aMutex
);
331 if ( nChildIndex
< 0 || nChildIndex
>= getAccessibleChildCount())
332 throw lang::IndexOutOfBoundsException();
334 long nIndex
= mrPixelCtl
.ShowPosition(mrPixelCtl
.IndexToPoint(nChildIndex
));
335 NotifyChild(nIndex
,true,false);
338 sal_Bool SAL_CALL
SvxPixelCtlAccessible::isAccessibleChildSelected( sal_Int32 nChildIndex
) throw (lang::IndexOutOfBoundsException
, RuntimeException
, std::exception
)
340 ::osl::MutexGuard
aGuard( m_aMutex
);
342 return mrPixelCtl
.GetFoucsPosIndex() == nChildIndex
;
345 void SAL_CALL
SvxPixelCtlAccessible::clearAccessibleSelection( ) throw (RuntimeException
, std::exception
)
349 void SAL_CALL
SvxPixelCtlAccessible::selectAllAccessibleChildren( ) throw (RuntimeException
, std::exception
)
353 sal_Int32 SAL_CALL
SvxPixelCtlAccessible::getSelectedAccessibleChildCount( ) throw (RuntimeException
, std::exception
)
358 uno::Reference
< XAccessible
> SAL_CALL
SvxPixelCtlAccessible::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex
) throw (lang::IndexOutOfBoundsException
, RuntimeException
, std::exception
)
360 ::osl::MutexGuard
aGuard( m_aMutex
);
362 if ( nSelectedChildIndex
>= 1)
363 throw lang::IndexOutOfBoundsException();
365 uno::Reference
< XAccessible
> xChild
;
368 xChild
= m_xCurChild
;
373 void SAL_CALL
SvxPixelCtlAccessible::deselectAccessibleChild( sal_Int32
) throw (lang::IndexOutOfBoundsException
, RuntimeException
, std::exception
)
378 void SvxPixelCtlAccessible::ensureIsAlive() const
379 throw ( lang::DisposedException
)
382 throw lang::DisposedException();
385 //XAccessibleEventBroadcaster
386 void SAL_CALL
SvxPixelCtlAccessible::addAccessibleEventListener( const uno::Reference
< XAccessibleEventListener
>& xListener
) throw( RuntimeException
, std::exception
)
390 ::osl::MutexGuard
aGuard( m_aMutex
);
392 mnClientId
= comphelper::AccessibleEventNotifier::registerClient( );
393 comphelper::AccessibleEventNotifier::addEventListener( mnClientId
, xListener
);
397 void SAL_CALL
SvxPixelCtlAccessible::removeAccessibleEventListener( const uno::Reference
< XAccessibleEventListener
>& xListener
)
398 throw( RuntimeException
, std::exception
)
402 ::osl::MutexGuard
aGuard( m_aMutex
);
404 sal_Int32 nListenerCount
= comphelper::AccessibleEventNotifier::removeEventListener( mnClientId
, xListener
);
405 if ( !nListenerCount
)
407 comphelper::AccessibleEventNotifier::revokeClient( mnClientId
);
412 void SvxPixelCtlAccessible::CommitChange( const AccessibleEventObject
& rEvent
)
415 comphelper::AccessibleEventNotifier::addEvent( mnClientId
, rEvent
);
418 //Solution:Add the event handling method
419 void SvxPixelCtlAccessible::FireAccessibleEvent (short nEventId
, const ::com::sun::star::uno::Any
& rOld
, const ::com::sun::star::uno::Any
& rNew
)
421 const uno::Reference
< XInterface
> xSource( *this );
422 CommitChange( AccessibleEventObject( xSource
, nEventId
, rNew
,rOld
) );
425 void SAL_CALL
SvxPixelCtlAccessible::disposing()
427 if( !rBHelper
.bDisposed
)
430 ::osl::MutexGuard
aGuard( m_aMutex
);
433 comphelper::AccessibleEventNotifier::revokeClientNotifyDisposing( mnClientId
, *this );
437 //mxParent = uno::Reference< XAccessible >();
442 void SvxPixelCtlAccessible::NotifyChild(long nIndex
,bool bSelect
,bool bCheck
)
444 DBG_ASSERT( !(!bSelect
&& !bCheck
),"" );//non is false
446 SvxPixelCtlAccessibleChild
*pChild
= NULL
;
448 if (m_xCurChild
.is())
450 pChild
= static_cast<SvxPixelCtlAccessibleChild
*>(m_xCurChild
.get());
451 DBG_ASSERT(pChild
,"Child Must be Valid");
452 if (pChild
->getAccessibleIndexInParent() == nIndex
)
456 pChild
->SelectChild(true);
460 pChild
->ChangePixelColorOrBG( mrPixelCtl
.GetBitmapPixel(sal_uInt16(nIndex
)) != 0);
461 pChild
->CheckChild();
466 uno::Reference
<XAccessible
> xNewChild
=CreateChild(nIndex
, mrPixelCtl
.IndexToPoint(nIndex
));
467 SvxPixelCtlAccessibleChild
*pNewChild
= static_cast<SvxPixelCtlAccessibleChild
*>(xNewChild
.get());
468 DBG_ASSERT(pNewChild
,"Child Must be Valid");
470 Any aNewValue
,aOldValue
;
471 aNewValue
<<= xNewChild
;
472 FireAccessibleEvent( AccessibleEventId::ACTIVE_DESCENDANT_CHANGED
,
480 pChild
->SelectChild(false);
482 pNewChild
->SelectChild(true);
486 pNewChild
->CheckChild();
488 m_xCurChild
= xNewChild
;
493 uno::Reference
<XAccessible
> SvxPixelCtlAccessible::CreateChild (long nIndex
,Point mPoint
)
495 long nX
= mPoint
.X();
496 long nY
= mPoint
.Y();
497 if( Application::GetSettings().GetLayoutRTL())
499 nX
= (sal_uInt16
) mrPixelCtl
.GetWidth() - 1 - nX
;
502 bool bPixelColorOrBG
= mrPixelCtl
.GetBitmapPixel(sal_uInt16(nIndex
)) != 0;
503 Size
size(mrPixelCtl
.GetWidth() / mrPixelCtl
.GetLineCount(),mrPixelCtl
.GetHeight() / mrPixelCtl
.GetLineCount());
504 uno::Reference
<XAccessible
> xChild
;
505 xChild
= new SvxPixelCtlAccessibleChild(mrPixelCtl
,
508 Rectangle(mPoint
,size
),
516 void SvxPixelCtlAccessible::LoseFocus()
518 m_xCurChild
= uno::Reference
< XAccessible
>() ;
521 void SvxPixelCtlAccessibleChild::CheckChild()
524 aChecked
<<= AccessibleStateType::CHECKED
;
526 if (m_bPixelColorOrBG
)//Current Child State
528 FireAccessibleEvent( AccessibleEventId::STATE_CHANGED
,
534 FireAccessibleEvent( AccessibleEventId::STATE_CHANGED
,
540 void SvxPixelCtlAccessibleChild::SelectChild( bool bSelect
)
543 aSelected
<<= AccessibleStateType::SELECTED
;
547 FireAccessibleEvent( AccessibleEventId::STATE_CHANGED
,
553 FireAccessibleEvent( AccessibleEventId::STATE_CHANGED
,
558 void SvxPixelCtlAccessibleChild::FireAccessibleEvent (
560 const ::com::sun::star::uno::Any
& rOld
,
561 const ::com::sun::star::uno::Any
& rNew
)
563 const uno::Reference
< XInterface
> xSource( *this );
564 CommitChange( AccessibleEventObject( xSource
, nEventId
, rNew
,rOld
) );
567 SvxPixelCtlAccessibleChild::SvxPixelCtlAccessibleChild(
568 SvxPixelCtl
& rWindow
,
569 bool bPixelColorOrBG
,
571 const Rectangle
& rBoundingBox
,
572 const uno::Reference
<XAccessible
>& rxParent
,
573 long nIndexInParent
) :
574 SvxPixelCtlAccessibleChild_BASE( m_aMutex
),
575 mrParentWindow( rWindow
),
577 m_bPixelColorOrBG(bPixelColorOrBG
),
579 mpBoundingBox( new Rectangle( rBoundingBox
) ),
580 mnIndexInParent( nIndexInParent
),
586 SvxPixelCtlAccessibleChild::~SvxPixelCtlAccessibleChild()
590 osl_atomic_increment( &m_refCount
);
591 dispose(); // set mpRepr = NULL & release all childs
595 //===== XAccessible =========================================================
597 uno::Reference
< XAccessibleContext
> SAL_CALL
SvxPixelCtlAccessibleChild::getAccessibleContext( void ) throw( RuntimeException
, std::exception
)
602 //===== XAccessibleComponent ================================================
604 sal_Bool SAL_CALL
SvxPixelCtlAccessibleChild::containsPoint( const awt::Point
& rPoint
) throw( RuntimeException
, std::exception
)
606 // no guard -> done in getBounds()
607 // return GetBoundingBox().IsInside( VCLPoint( rPoint ) );
608 return Rectangle( Point( 0, 0 ), GetBoundingBox().GetSize() ).IsInside( VCLPoint( rPoint
) );
611 uno::Reference
< XAccessible
> SAL_CALL
SvxPixelCtlAccessibleChild::getAccessibleAtPoint( const awt::Point
& ) throw( RuntimeException
, std::exception
)
613 return uno::Reference
< XAccessible
>();
616 awt::Rectangle SAL_CALL
SvxPixelCtlAccessibleChild::getBounds() throw( RuntimeException
, std::exception
)
618 // no guard -> done in getBoundingBox()
619 //Modified by lq, 09/26
620 //return AWTRectangle( GetBoundingBox() );
621 awt::Rectangle rect
= AWTRectangle( GetBoundingBox() );
622 rect
.X
= rect
.X
+ mrParentWindow
.GetClientWindowExtentsRelative(NULL
).Left()-mrParentWindow
.GetWindowExtentsRelative(NULL
).Left();
623 rect
.Y
= rect
.Y
+ mrParentWindow
.GetClientWindowExtentsRelative(NULL
).Top()-mrParentWindow
.GetWindowExtentsRelative(NULL
).Top();
628 awt::Point SAL_CALL
SvxPixelCtlAccessibleChild::getLocation() throw( RuntimeException
, std::exception
)
630 // no guard -> done in getBoundingBox()
631 return AWTPoint( GetBoundingBox().TopLeft() );
634 awt::Point SAL_CALL
SvxPixelCtlAccessibleChild::getLocationOnScreen() throw( RuntimeException
, std::exception
)
636 // no guard -> done in getBoundingBoxOnScreen()
637 return AWTPoint( GetBoundingBoxOnScreen().TopLeft() );
640 awt::Size SAL_CALL
SvxPixelCtlAccessibleChild::getSize() throw( RuntimeException
, std::exception
)
642 // no guard -> done in getBoundingBox()
643 return AWTSize( GetBoundingBox().GetSize() );
646 void SAL_CALL
SvxPixelCtlAccessibleChild::grabFocus() throw( RuntimeException
, std::exception
)
650 sal_Int32
SvxPixelCtlAccessibleChild::getForeground( )
651 throw (::com::sun::star::uno::RuntimeException
, std::exception
)
653 //::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
654 ::osl::MutexGuard
aGuard( m_aMutex
);
655 ThrowExceptionIfNotAlive();
656 return mrParentWindow
.GetControlForeground().GetColor();
658 sal_Int32
SvxPixelCtlAccessibleChild::getBackground( )
659 throw (::com::sun::star::uno::RuntimeException
, std::exception
)
661 //::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
662 ::osl::MutexGuard
aGuard( m_aMutex
);
664 ThrowExceptionIfNotAlive();
665 return mrParentWindow
.GetControlBackground().GetColor();
668 //===== XAccessibleContext ==================================================
670 sal_Int32 SAL_CALL
SvxPixelCtlAccessibleChild::getAccessibleChildCount( void ) throw( RuntimeException
, std::exception
)
675 uno::Reference
< XAccessible
> SAL_CALL
SvxPixelCtlAccessibleChild::getAccessibleChild( sal_Int32
)
676 throw (lang::IndexOutOfBoundsException
, uno::RuntimeException
, std::exception
)
678 throw lang::IndexOutOfBoundsException();
681 uno::Reference
< XAccessible
> SAL_CALL
SvxPixelCtlAccessibleChild::getAccessibleParent( void ) throw( RuntimeException
, std::exception
)
686 sal_Int32 SAL_CALL
SvxPixelCtlAccessibleChild::getAccessibleIndexInParent( void ) throw( RuntimeException
, std::exception
)
688 return mnIndexInParent
;
691 sal_Int16 SAL_CALL
SvxPixelCtlAccessibleChild::getAccessibleRole( void ) throw( RuntimeException
, std::exception
)
693 return AccessibleRole::CHECK_BOX
;
696 OUString SAL_CALL
SvxPixelCtlAccessibleChild::getAccessibleDescription( void ) throw( RuntimeException
, std::exception
)
698 ::osl::MutexGuard
aGuard( m_aMutex
);
703 OUString SAL_CALL
SvxPixelCtlAccessibleChild::getAccessibleName( void ) throw( RuntimeException
, std::exception
)
705 ::osl::MutexGuard
aGuard( m_aMutex
);
709 /** Return empty uno::Reference to indicate that the relation set is not
712 uno::Reference
<XAccessibleRelationSet
> SAL_CALL
SvxPixelCtlAccessibleChild::getAccessibleRelationSet( void ) throw( RuntimeException
, std::exception
)
714 return uno::Reference
< XAccessibleRelationSet
>();
717 uno::Reference
< XAccessibleStateSet
> SAL_CALL
SvxPixelCtlAccessibleChild::getAccessibleStateSet( void ) throw( RuntimeException
, std::exception
)
719 ::osl::MutexGuard
aGuard( m_aMutex
);
720 utl::AccessibleStateSetHelper
* pStateSetHelper
= new utl::AccessibleStateSetHelper
;
725 pStateSetHelper
->AddState( AccessibleStateType::TRANSIENT
);
726 pStateSetHelper
->AddState( AccessibleStateType::ENABLED
);
727 pStateSetHelper
->AddState( AccessibleStateType::OPAQUE
);
728 pStateSetHelper
->AddState( AccessibleStateType::SELECTABLE
);
729 pStateSetHelper
->AddState( AccessibleStateType::SHOWING
);
730 pStateSetHelper
->AddState( AccessibleStateType::VISIBLE
);
732 long nIndex
= mrParentWindow
.GetFoucsPosIndex();
733 if ( nIndex
== mnIndexInParent
)
735 pStateSetHelper
->AddState( AccessibleStateType::SELECTED
);
737 if (mrParentWindow
.GetBitmapPixel(sal_uInt16(mnIndexInParent
)))
739 pStateSetHelper
->AddState( AccessibleStateType::CHECKED
);
743 pStateSetHelper
->AddState( AccessibleStateType::DEFUNC
);
745 return pStateSetHelper
;
748 lang::Locale SAL_CALL
SvxPixelCtlAccessibleChild::getLocale( void ) throw( IllegalAccessibleComponentStateException
, RuntimeException
, std::exception
)
750 ::osl::MutexGuard
aGuard( m_aMutex
);
753 uno::Reference
< XAccessibleContext
> xParentContext( mxParent
->getAccessibleContext() );
754 if( xParentContext
.is() )
755 return xParentContext
->getLocale();
758 // No locale and no parent. Therefore throw exception to indicate this
760 throw IllegalAccessibleComponentStateException();
763 void SAL_CALL
SvxPixelCtlAccessibleChild::addAccessibleEventListener( const uno::Reference
< XAccessibleEventListener
>& xListener
)
764 throw( RuntimeException
, std::exception
)
768 ::osl::MutexGuard
aGuard( m_aMutex
);
770 mnClientId
= comphelper::AccessibleEventNotifier::registerClient( );
771 comphelper::AccessibleEventNotifier::addEventListener( mnClientId
, xListener
);
775 void SAL_CALL
SvxPixelCtlAccessibleChild::removeAccessibleEventListener( const uno::Reference
< XAccessibleEventListener
>& xListener
)
776 throw( RuntimeException
, std::exception
)
780 ::osl::MutexGuard
aGuard( m_aMutex
);
782 sal_Int32 nListenerCount
= comphelper::AccessibleEventNotifier::removeEventListener( mnClientId
, xListener
);
783 if ( !nListenerCount
)
785 // no listeners anymore
786 // -> revoke ourself. This may lead to the notifier thread dying (if we were the last client),
787 // and at least to us not firing any events anymore, in case somebody calls
788 // NotifyAccessibleEvent, again
789 comphelper::AccessibleEventNotifier::revokeClient( mnClientId
);
796 //===== XServiceInfo ========================================================
797 OUString SAL_CALL
SvxPixelCtlAccessibleChild::getImplementationName( void ) throw( RuntimeException
, std::exception
)
799 return OUString( RTL_CONSTASCII_USTRINGPARAM( "SvxPixelCtlAccessibleChild" ) );
802 sal_Bool SAL_CALL
SvxPixelCtlAccessibleChild::supportsService( const OUString
& rServiceName
) throw( RuntimeException
, std::exception
)
804 return cppu::supportsService( this, rServiceName
);
807 Sequence
< OUString
> SAL_CALL
SvxPixelCtlAccessibleChild::getSupportedServiceNames( void ) throw( RuntimeException
, std::exception
)
809 uno::Sequence
< OUString
> aRet(3);
810 OUString
* pArray
= aRet
.getArray();
811 pArray
[0] = "Accessible";
812 pArray
[1] = "AccessibleContext";
813 pArray
[2] = "AccessibleComponent";
817 //===== internal ============================================================
819 void SvxPixelCtlAccessibleChild::CommitChange( const AccessibleEventObject
& rEvent
)
822 comphelper::AccessibleEventNotifier::addEvent( mnClientId
, rEvent
);
825 void SAL_CALL
SvxPixelCtlAccessibleChild::disposing()
827 if( !rBHelper
.bDisposed
)
829 ::osl::MutexGuard
aGuard( m_aMutex
);
831 // Send a disposing to all listeners.
834 comphelper::AccessibleEventNotifier::revokeClientNotifyDisposing( mnClientId
, *this );
838 mxParent
= uno::Reference
< XAccessible
>();
840 delete mpBoundingBox
;
844 void SvxPixelCtlAccessibleChild::ThrowExceptionIfNotAlive( void ) throw( lang::DisposedException
)
847 throw lang::DisposedException();
850 Rectangle
SvxPixelCtlAccessibleChild::GetBoundingBoxOnScreen( void ) throw( RuntimeException
)
852 ::osl::MutexGuard
aGuard( m_aMutex
);
854 // no ThrowExceptionIfNotAlive() because its done in GetBoundingBox()
855 Rectangle
aRect( GetBoundingBox() );
857 return Rectangle( mrParentWindow
.OutputToAbsoluteScreenPixel( aRect
.TopLeft() ), aRect
.GetSize() );
860 Rectangle
SvxPixelCtlAccessibleChild::GetBoundingBox( void ) throw( RuntimeException
)
862 // no guard necessary, because no one changes mpBoundingBox after creating it
863 ThrowExceptionIfNotAlive();
865 return *mpBoundingBox
;
868 OUString
SvxPixelCtlAccessibleChild::GetName()
870 sal_Int32 nXIndex
= mnIndexInParent
% mrParentWindow
.GetLineCount();
871 sal_Int32 nYIndex
= mnIndexInParent
/ mrParentWindow
.GetLineCount();
875 str
+= OUString::number(nXIndex
);
877 str
+= OUString::number(nYIndex
);
882 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */