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 ::com::sun::star
;
52 using namespace ::com::sun::star::uno
;
53 using namespace ::com::sun::star::accessibility
;
55 SvxPixelCtlAccessible::SvxPixelCtlAccessible( SvxPixelCtl
& rControl
) :
56 SvxPixelCtlAccessible_BASE(m_aMutex
),
62 SvxPixelCtlAccessible::~SvxPixelCtlAccessible()
66 osl_atomic_increment( &m_refCount
);
67 dispose(); // set mpRepr = NULL & release all children
70 uno::Reference
< XAccessibleContext
> SvxPixelCtlAccessible::getAccessibleContext( )
71 throw (uno::RuntimeException
, std::exception
)
76 sal_Int32
SvxPixelCtlAccessible::getAccessibleChildCount( ) throw (uno::RuntimeException
, std::exception
)
78 ::osl::MutexGuard
aGuard( m_aMutex
);
79 return mrPixelCtl
.GetSquares();
81 uno::Reference
< XAccessible
> SvxPixelCtlAccessible::getAccessibleChild( sal_Int32 i
)
82 throw (lang::IndexOutOfBoundsException
, uno::RuntimeException
, std::exception
)
84 ::osl::MutexGuard
aGuard( m_aMutex
);
85 if ( i
< 0 || i
>= getAccessibleChildCount())
86 throw lang::IndexOutOfBoundsException();
87 uno::Reference
<XAccessible
> xAcc
;
88 return CreateChild(i
, mrPixelCtl
.IndexToPoint(i
));
93 uno::Reference
< XAccessible
> SvxPixelCtlAccessible::getAccessibleParent( )
94 throw (uno::RuntimeException
, std::exception
)
96 ::osl::MutexGuard
aGuard( m_aMutex
);
97 vcl::Window
*pTabPage
= getNonLayoutParent(&mrPixelCtl
);
98 assert(pTabPage
&& WINDOW_TABPAGE
== pTabPage
->GetType());
99 return pTabPage
->GetAccessible( true );
102 sal_Int32
SvxPixelCtlAccessible::getAccessibleIndexInParent( )
103 throw (uno::RuntimeException
, std::exception
)
105 ::osl::MutexGuard
aGuard( m_aMutex
);
107 vcl::Window
*pTabPage
= getNonLayoutParent(&mrPixelCtl
);
108 assert(pTabPage
&& WINDOW_TABPAGE
== pTabPage
->GetType());
109 sal_uInt16 nChildren
= pTabPage
->GetChildCount();
110 for(nIdx
= 0; nIdx
< nChildren
; nIdx
++)
111 if(pTabPage
->GetChild( nIdx
) == &mrPixelCtl
)
115 sal_Int16
SvxPixelCtlAccessible::getAccessibleRole( ) throw (uno::RuntimeException
, std::exception
)
117 return AccessibleRole::LIST
;
120 OUString
SvxPixelCtlAccessible::getAccessibleDescription( )
121 throw (uno::RuntimeException
, std::exception
)
124 ::osl::MutexGuard
aGuard( m_aMutex
);
125 return mrPixelCtl
.GetAccessibleDescription();
128 OUString
SvxPixelCtlAccessible::getAccessibleName( )
129 throw (uno::RuntimeException
, std::exception
)
132 ::osl::MutexGuard
aGuard( m_aMutex
);
133 return mrPixelCtl
.GetAccessibleName();
136 uno::Reference
< XAccessibleRelationSet
> SvxPixelCtlAccessible::getAccessibleRelationSet( )
137 throw (uno::RuntimeException
, std::exception
)
139 ::osl::MutexGuard
aGuard( m_aMutex
);
140 utl::AccessibleRelationSetHelper
* rRelationSet
= new utl::AccessibleRelationSetHelper
;
141 uno::Reference
< css::accessibility::XAccessibleRelationSet
> rSet
= rRelationSet
;
142 vcl::Window
*pLabeledBy
= mrPixelCtl
.GetAccessibleRelationLabeledBy();
143 if ( pLabeledBy
&& pLabeledBy
!= &mrPixelCtl
)
145 uno::Sequence
< uno::Reference
< uno::XInterface
> > aSequence(1);
146 aSequence
[0] = pLabeledBy
->GetAccessible();
147 rRelationSet
->AddRelation( css::accessibility::AccessibleRelation( css::accessibility::AccessibleRelationType::LABELED_BY
, aSequence
) );
150 vcl::Window
* pMemberOf
= mrPixelCtl
.GetAccessibleRelationMemberOf();
151 if ( pMemberOf
&& pMemberOf
!= &mrPixelCtl
)
153 uno::Sequence
< uno::Reference
< uno::XInterface
> > aSequence(1);
154 aSequence
[0] = pMemberOf
->GetAccessible();
155 rRelationSet
->AddRelation( css::accessibility::AccessibleRelation( css::accessibility::AccessibleRelationType::MEMBER_OF
, aSequence
) );
161 uno::Reference
< XAccessibleStateSet
> SvxPixelCtlAccessible::getAccessibleStateSet( )
162 throw (uno::RuntimeException
, std::exception
)
164 ::osl::MutexGuard
aGuard( m_aMutex
);
165 utl::AccessibleStateSetHelper
* pStateSetHelper
= new utl::AccessibleStateSetHelper
;
166 uno::Reference
< XAccessibleStateSet
> xRet
= pStateSetHelper
;
168 const sal_Int16 aStandardStates
[] =
170 AccessibleStateType::FOCUSABLE
,
171 AccessibleStateType::SELECTABLE
,
172 AccessibleStateType::SHOWING
,
173 AccessibleStateType::VISIBLE
,
174 AccessibleStateType::OPAQUE
,
178 sal_Int16 nState
= 0;
179 while(aStandardStates
[nState
])
181 pStateSetHelper
->AddState(aStandardStates
[nState
++]);
183 if(mrPixelCtl
.IsEnabled())
184 pStateSetHelper
->AddState(AccessibleStateType::ENABLED
);
185 if(mrPixelCtl
.HasFocus())
186 pStateSetHelper
->AddState(AccessibleStateType::FOCUSED
);
187 pStateSetHelper
->AddState(AccessibleStateType::MANAGES_DESCENDANTS
);
193 com::sun::star::lang::Locale
SvxPixelCtlAccessible::getLocale( )
194 throw (IllegalAccessibleComponentStateException
, uno::RuntimeException
, std::exception
)
196 ::osl::MutexGuard
aGuard( m_aMutex
);
197 if( getAccessibleParent().is() )
199 uno::Reference
< XAccessibleContext
> xParentContext( getAccessibleParent()->getAccessibleContext() );
200 if( xParentContext
.is() )
201 return xParentContext
->getLocale();
204 // No locale and no parent. Therefore throw exception to indicate this
206 throw IllegalAccessibleComponentStateException();
210 sal_Bool
SvxPixelCtlAccessible::containsPoint( const awt::Point
& aPt
)
211 throw (uno::RuntimeException
, std::exception
)
213 ::osl::MutexGuard
aGuard( m_aMutex
);
214 Point
aPoint(aPt
.X
, aPt
.Y
);
215 return (aPoint
.X() >= 0)
216 && (aPoint
.X() < mrPixelCtl
.GetSizePixel().getWidth())
218 && (aPoint
.Y() < mrPixelCtl
.GetSizePixel().getHeight());
220 uno::Reference
<XAccessible
> SAL_CALL
SvxPixelCtlAccessible::getAccessibleAtPoint (
221 const awt::Point
& aPoint
)
222 throw (uno::RuntimeException
, std::exception
)
224 ::osl::MutexGuard
aGuard( m_aMutex
);
226 uno::Reference
<XAccessible
> xAcc
;
229 childPoint
.X() = aPoint
.X
;
230 childPoint
.Y() = aPoint
.Y
;
232 Point pt
= mrPixelCtl
.PixelToLogic(childPoint
);
233 long nIndex
= mrPixelCtl
.PointToIndex(pt
);
234 return CreateChild(nIndex
, mrPixelCtl
.IndexToPoint(nIndex
));
237 awt::Rectangle
SvxPixelCtlAccessible::getBounds( ) throw (uno::RuntimeException
, std::exception
)
239 ::osl::MutexGuard
aGuard( m_aMutex
);
241 Size aSz
= mrPixelCtl
.GetSizePixel();
242 Point aPos
= mrPixelCtl
.GetPosPixel();
245 aRet
.Width
= aSz
.Width();
246 aRet
.Height
= aSz
.Height();
250 awt::Point
SvxPixelCtlAccessible::getLocation( ) throw (uno::RuntimeException
, std::exception
)
252 ::osl::MutexGuard
aGuard( m_aMutex
);
254 aPos
= mrPixelCtl
.GetPosPixel();
255 awt::Point
aRet(aPos
.X(), aPos
.Y());
259 awt::Point
SvxPixelCtlAccessible::getLocationOnScreen( ) throw (uno::RuntimeException
, std::exception
)
261 ::osl::MutexGuard
aGuard( m_aMutex
);
262 Rectangle rect
= mrPixelCtl
.GetWindowExtentsRelative(NULL
);
263 return awt::Point(rect
.Left(),rect
.Top() );
266 awt::Size
SvxPixelCtlAccessible::getSize( ) throw (uno::RuntimeException
, std::exception
)
268 ::osl::MutexGuard
aGuard( m_aMutex
);
269 Size aSz
= mrPixelCtl
.GetSizePixel();
270 return awt::Size(aSz
.Width(),aSz
.Height());
272 void SvxPixelCtlAccessible::grabFocus( ) throw (uno::RuntimeException
, std::exception
)
274 ::osl::MutexGuard
aGuard( m_aMutex
);
275 mrPixelCtl
.GrabFocus();
278 sal_Int32
SvxPixelCtlAccessible::getForeground( )
279 throw (::com::sun::star::uno::RuntimeException
, std::exception
)
281 ::osl::MutexGuard
aGuard( m_aMutex
);
282 return mrPixelCtl
.GetControlForeground().GetColor();
285 sal_Int32
SvxPixelCtlAccessible::getBackground( )
286 throw (::com::sun::star::uno::RuntimeException
, std::exception
)
288 ::osl::MutexGuard
aGuard( m_aMutex
);
289 return mrPixelCtl
.GetControlBackground().GetColor();
292 OUString
SvxPixelCtlAccessible::getImplementationName( ) throw (uno::RuntimeException
, std::exception
)
294 return OUString("SvxPixelCtlAccessible");
297 sal_Bool
SvxPixelCtlAccessible::supportsService( const OUString
& rServiceName
)
298 throw (uno::RuntimeException
, std::exception
)
300 return cppu::supportsService( this, rServiceName
);
303 uno::Sequence
< OUString
> SvxPixelCtlAccessible::getSupportedServiceNames( )
304 throw (uno::RuntimeException
, std::exception
)
306 uno::Sequence
< OUString
> aRet(2);
307 OUString
* pArray
= aRet
.getArray();
308 pArray
[0] = "Accessible";
309 pArray
[1] = "AccessibleContext";
310 pArray
[2] = "AccessibleComponent";
315 // XAccessibleSelection
317 void SAL_CALL
SvxPixelCtlAccessible::selectAccessibleChild( sal_Int32 nChildIndex
) throw (lang::IndexOutOfBoundsException
, RuntimeException
, std::exception
)
319 ::osl::MutexGuard
aGuard( m_aMutex
);
321 if ( nChildIndex
< 0 || nChildIndex
>= getAccessibleChildCount())
322 throw lang::IndexOutOfBoundsException();
324 long nIndex
= mrPixelCtl
.ShowPosition(mrPixelCtl
.IndexToPoint(nChildIndex
));
325 NotifyChild(nIndex
,true,false);
328 sal_Bool SAL_CALL
SvxPixelCtlAccessible::isAccessibleChildSelected( sal_Int32 nChildIndex
) throw (lang::IndexOutOfBoundsException
, RuntimeException
, std::exception
)
330 ::osl::MutexGuard
aGuard( m_aMutex
);
332 return mrPixelCtl
.GetFoucsPosIndex() == nChildIndex
;
335 void SAL_CALL
SvxPixelCtlAccessible::clearAccessibleSelection( ) throw (RuntimeException
, std::exception
)
339 void SAL_CALL
SvxPixelCtlAccessible::selectAllAccessibleChildren( ) throw (RuntimeException
, std::exception
)
343 sal_Int32 SAL_CALL
SvxPixelCtlAccessible::getSelectedAccessibleChildCount( ) throw (RuntimeException
, std::exception
)
348 uno::Reference
< XAccessible
> SAL_CALL
SvxPixelCtlAccessible::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex
) throw (lang::IndexOutOfBoundsException
, RuntimeException
, std::exception
)
350 ::osl::MutexGuard
aGuard( m_aMutex
);
352 if ( nSelectedChildIndex
>= 1)
353 throw lang::IndexOutOfBoundsException();
355 uno::Reference
< XAccessible
> xChild
;
358 xChild
= m_xCurChild
;
363 void SAL_CALL
SvxPixelCtlAccessible::deselectAccessibleChild( sal_Int32
) throw (lang::IndexOutOfBoundsException
, RuntimeException
, std::exception
)
368 void SvxPixelCtlAccessible::ensureIsAlive() const
369 throw ( lang::DisposedException
)
372 throw lang::DisposedException();
375 //XAccessibleEventBroadcaster
376 void SAL_CALL
SvxPixelCtlAccessible::addAccessibleEventListener( const uno::Reference
< XAccessibleEventListener
>& xListener
) throw( RuntimeException
, std::exception
)
380 ::osl::MutexGuard
aGuard( m_aMutex
);
382 mnClientId
= comphelper::AccessibleEventNotifier::registerClient( );
383 comphelper::AccessibleEventNotifier::addEventListener( mnClientId
, xListener
);
387 void SAL_CALL
SvxPixelCtlAccessible::removeAccessibleEventListener( const uno::Reference
< XAccessibleEventListener
>& xListener
)
388 throw( RuntimeException
, std::exception
)
392 ::osl::MutexGuard
aGuard( m_aMutex
);
394 sal_Int32 nListenerCount
= comphelper::AccessibleEventNotifier::removeEventListener( mnClientId
, xListener
);
395 if ( !nListenerCount
)
397 comphelper::AccessibleEventNotifier::revokeClient( mnClientId
);
402 void SvxPixelCtlAccessible::CommitChange( const AccessibleEventObject
& rEvent
)
405 comphelper::AccessibleEventNotifier::addEvent( mnClientId
, rEvent
);
408 //Solution:Add the event handling method
409 void SvxPixelCtlAccessible::FireAccessibleEvent (short nEventId
, const ::com::sun::star::uno::Any
& rOld
, const ::com::sun::star::uno::Any
& rNew
)
411 const uno::Reference
< XInterface
> xSource( *this );
412 CommitChange( AccessibleEventObject( xSource
, nEventId
, rNew
,rOld
) );
415 void SAL_CALL
SvxPixelCtlAccessible::disposing()
417 if( !rBHelper
.bDisposed
)
420 ::osl::MutexGuard
aGuard( m_aMutex
);
423 comphelper::AccessibleEventNotifier::revokeClientNotifyDisposing( mnClientId
, *this );
427 //mxParent = uno::Reference< XAccessible >();
432 void SvxPixelCtlAccessible::NotifyChild(long nIndex
,bool bSelect
,bool bCheck
)
434 DBG_ASSERT( !(!bSelect
&& !bCheck
),"" );//non is false
436 SvxPixelCtlAccessibleChild
*pChild
= NULL
;
438 if (m_xCurChild
.is())
440 pChild
= static_cast<SvxPixelCtlAccessibleChild
*>(m_xCurChild
.get());
441 DBG_ASSERT(pChild
,"Child Must be Valid");
442 if (pChild
->getAccessibleIndexInParent() == nIndex
)
446 pChild
->SelectChild(true);
450 pChild
->ChangePixelColorOrBG( mrPixelCtl
.GetBitmapPixel(sal_uInt16(nIndex
)) != 0);
451 pChild
->CheckChild();
456 uno::Reference
<XAccessible
> xNewChild
=CreateChild(nIndex
, mrPixelCtl
.IndexToPoint(nIndex
));
457 SvxPixelCtlAccessibleChild
*pNewChild
= static_cast<SvxPixelCtlAccessibleChild
*>(xNewChild
.get());
458 DBG_ASSERT(pNewChild
,"Child Must be Valid");
460 Any aNewValue
,aOldValue
;
461 aNewValue
<<= xNewChild
;
462 FireAccessibleEvent( AccessibleEventId::ACTIVE_DESCENDANT_CHANGED
,
470 pChild
->SelectChild(false);
472 pNewChild
->SelectChild(true);
476 pNewChild
->CheckChild();
478 m_xCurChild
= xNewChild
;
483 uno::Reference
<XAccessible
> SvxPixelCtlAccessible::CreateChild (long nIndex
,Point mPoint
)
485 long nX
= mPoint
.X();
486 long nY
= mPoint
.Y();
487 if( AllSettings::GetLayoutRTL())
489 nX
= (sal_uInt16
) mrPixelCtl
.GetWidth() - 1 - nX
;
492 bool bPixelColorOrBG
= mrPixelCtl
.GetBitmapPixel(sal_uInt16(nIndex
)) != 0;
493 Size
size(mrPixelCtl
.GetWidth() / mrPixelCtl
.GetLineCount(),mrPixelCtl
.GetHeight() / mrPixelCtl
.GetLineCount());
494 uno::Reference
<XAccessible
> xChild
;
495 xChild
= new SvxPixelCtlAccessibleChild(mrPixelCtl
,
498 Rectangle(mPoint
,size
),
506 void SvxPixelCtlAccessible::LoseFocus()
508 m_xCurChild
= uno::Reference
< XAccessible
>() ;
511 void SvxPixelCtlAccessibleChild::CheckChild()
514 aChecked
<<= AccessibleStateType::CHECKED
;
516 if (m_bPixelColorOrBG
)//Current Child State
518 FireAccessibleEvent( AccessibleEventId::STATE_CHANGED
,
524 FireAccessibleEvent( AccessibleEventId::STATE_CHANGED
,
530 void SvxPixelCtlAccessibleChild::SelectChild( bool bSelect
)
533 aSelected
<<= AccessibleStateType::SELECTED
;
537 FireAccessibleEvent( AccessibleEventId::STATE_CHANGED
,
543 FireAccessibleEvent( AccessibleEventId::STATE_CHANGED
,
548 void SvxPixelCtlAccessibleChild::FireAccessibleEvent (
550 const ::com::sun::star::uno::Any
& rOld
,
551 const ::com::sun::star::uno::Any
& rNew
)
553 const uno::Reference
< XInterface
> xSource( *this );
554 CommitChange( AccessibleEventObject( xSource
, nEventId
, rNew
,rOld
) );
557 SvxPixelCtlAccessibleChild::SvxPixelCtlAccessibleChild(
558 SvxPixelCtl
& rWindow
,
559 bool bPixelColorOrBG
,
561 const Rectangle
& rBoundingBox
,
562 const uno::Reference
<XAccessible
>& rxParent
,
563 long nIndexInParent
) :
564 SvxPixelCtlAccessibleChild_BASE( m_aMutex
),
565 mrParentWindow( rWindow
),
567 m_bPixelColorOrBG(bPixelColorOrBG
),
569 mpBoundingBox( new Rectangle( rBoundingBox
) ),
570 mnIndexInParent( nIndexInParent
),
576 SvxPixelCtlAccessibleChild::~SvxPixelCtlAccessibleChild()
580 osl_atomic_increment( &m_refCount
);
581 dispose(); // set mpRepr = NULL & release all children
586 uno::Reference
< XAccessibleContext
> SAL_CALL
SvxPixelCtlAccessibleChild::getAccessibleContext() throw( RuntimeException
, std::exception
)
591 // XAccessibleComponent
592 sal_Bool SAL_CALL
SvxPixelCtlAccessibleChild::containsPoint( const awt::Point
& rPoint
) throw( RuntimeException
, std::exception
)
594 // no guard -> done in getBounds()
595 // return GetBoundingBox().IsInside( VCLPoint( rPoint ) );
596 return Rectangle( Point( 0, 0 ), GetBoundingBox().GetSize() ).IsInside( VCLPoint( rPoint
) );
599 uno::Reference
< XAccessible
> SAL_CALL
SvxPixelCtlAccessibleChild::getAccessibleAtPoint( const awt::Point
& ) throw( RuntimeException
, std::exception
)
601 return uno::Reference
< XAccessible
>();
604 awt::Rectangle SAL_CALL
SvxPixelCtlAccessibleChild::getBounds() throw( RuntimeException
, std::exception
)
606 // no guard -> done in getBoundingBox()
607 //Modified by lq, 09/26
608 //return AWTRectangle( GetBoundingBox() );
609 awt::Rectangle rect
= AWTRectangle( GetBoundingBox() );
610 rect
.X
= rect
.X
+ mrParentWindow
.GetClientWindowExtentsRelative(NULL
).Left()-mrParentWindow
.GetWindowExtentsRelative(NULL
).Left();
611 rect
.Y
= rect
.Y
+ mrParentWindow
.GetClientWindowExtentsRelative(NULL
).Top()-mrParentWindow
.GetWindowExtentsRelative(NULL
).Top();
616 awt::Point SAL_CALL
SvxPixelCtlAccessibleChild::getLocation() throw( RuntimeException
, std::exception
)
618 // no guard -> done in getBoundingBox()
619 return AWTPoint( GetBoundingBox().TopLeft() );
622 awt::Point SAL_CALL
SvxPixelCtlAccessibleChild::getLocationOnScreen() throw( RuntimeException
, std::exception
)
624 // no guard -> done in getBoundingBoxOnScreen()
625 return AWTPoint( GetBoundingBoxOnScreen().TopLeft() );
628 awt::Size SAL_CALL
SvxPixelCtlAccessibleChild::getSize() throw( RuntimeException
, std::exception
)
630 // no guard -> done in getBoundingBox()
631 return AWTSize( GetBoundingBox().GetSize() );
634 void SAL_CALL
SvxPixelCtlAccessibleChild::grabFocus() throw( RuntimeException
, std::exception
)
638 sal_Int32
SvxPixelCtlAccessibleChild::getForeground( )
639 throw (::com::sun::star::uno::RuntimeException
, std::exception
)
641 ::osl::MutexGuard
aGuard( m_aMutex
);
642 ThrowExceptionIfNotAlive();
643 return mrParentWindow
.GetControlForeground().GetColor();
645 sal_Int32
SvxPixelCtlAccessibleChild::getBackground( )
646 throw (::com::sun::star::uno::RuntimeException
, std::exception
)
648 ::osl::MutexGuard
aGuard( m_aMutex
);
650 ThrowExceptionIfNotAlive();
651 return mrParentWindow
.GetControlBackground().GetColor();
654 // XAccessibleContext
655 sal_Int32 SAL_CALL
SvxPixelCtlAccessibleChild::getAccessibleChildCount() throw( RuntimeException
, std::exception
)
660 uno::Reference
< XAccessible
> SAL_CALL
SvxPixelCtlAccessibleChild::getAccessibleChild( sal_Int32
)
661 throw (lang::IndexOutOfBoundsException
, uno::RuntimeException
, std::exception
)
663 throw lang::IndexOutOfBoundsException();
666 uno::Reference
< XAccessible
> SAL_CALL
SvxPixelCtlAccessibleChild::getAccessibleParent() throw( RuntimeException
, std::exception
)
671 sal_Int32 SAL_CALL
SvxPixelCtlAccessibleChild::getAccessibleIndexInParent() throw( RuntimeException
, std::exception
)
673 return mnIndexInParent
;
676 sal_Int16 SAL_CALL
SvxPixelCtlAccessibleChild::getAccessibleRole() throw( RuntimeException
, std::exception
)
678 return AccessibleRole::CHECK_BOX
;
681 OUString SAL_CALL
SvxPixelCtlAccessibleChild::getAccessibleDescription() throw( RuntimeException
, std::exception
)
683 ::osl::MutexGuard
aGuard( m_aMutex
);
688 OUString SAL_CALL
SvxPixelCtlAccessibleChild::getAccessibleName() throw( RuntimeException
, std::exception
)
690 ::osl::MutexGuard
aGuard( m_aMutex
);
694 /** Return empty uno::Reference to indicate that the relation set is not
697 uno::Reference
<XAccessibleRelationSet
> SAL_CALL
SvxPixelCtlAccessibleChild::getAccessibleRelationSet() throw( RuntimeException
, std::exception
)
699 return uno::Reference
< XAccessibleRelationSet
>();
702 uno::Reference
< XAccessibleStateSet
> SAL_CALL
SvxPixelCtlAccessibleChild::getAccessibleStateSet() throw( RuntimeException
, std::exception
)
704 ::osl::MutexGuard
aGuard( m_aMutex
);
705 utl::AccessibleStateSetHelper
* pStateSetHelper
= new utl::AccessibleStateSetHelper
;
710 pStateSetHelper
->AddState( AccessibleStateType::TRANSIENT
);
711 pStateSetHelper
->AddState( AccessibleStateType::ENABLED
);
712 pStateSetHelper
->AddState( AccessibleStateType::OPAQUE
);
713 pStateSetHelper
->AddState( AccessibleStateType::SELECTABLE
);
714 pStateSetHelper
->AddState( AccessibleStateType::SHOWING
);
715 pStateSetHelper
->AddState( AccessibleStateType::VISIBLE
);
717 long nIndex
= mrParentWindow
.GetFoucsPosIndex();
718 if ( nIndex
== mnIndexInParent
)
720 pStateSetHelper
->AddState( AccessibleStateType::SELECTED
);
722 if (mrParentWindow
.GetBitmapPixel(sal_uInt16(mnIndexInParent
)))
724 pStateSetHelper
->AddState( AccessibleStateType::CHECKED
);
728 pStateSetHelper
->AddState( AccessibleStateType::DEFUNC
);
730 return pStateSetHelper
;
733 lang::Locale SAL_CALL
SvxPixelCtlAccessibleChild::getLocale() throw( IllegalAccessibleComponentStateException
, RuntimeException
, std::exception
)
735 ::osl::MutexGuard
aGuard( m_aMutex
);
738 uno::Reference
< XAccessibleContext
> xParentContext( mxParent
->getAccessibleContext() );
739 if( xParentContext
.is() )
740 return xParentContext
->getLocale();
743 // No locale and no parent. Therefore throw exception to indicate this
745 throw IllegalAccessibleComponentStateException();
748 void SAL_CALL
SvxPixelCtlAccessibleChild::addAccessibleEventListener( const uno::Reference
< XAccessibleEventListener
>& xListener
)
749 throw( RuntimeException
, std::exception
)
753 ::osl::MutexGuard
aGuard( m_aMutex
);
755 mnClientId
= comphelper::AccessibleEventNotifier::registerClient( );
756 comphelper::AccessibleEventNotifier::addEventListener( mnClientId
, xListener
);
760 void SAL_CALL
SvxPixelCtlAccessibleChild::removeAccessibleEventListener( const uno::Reference
< XAccessibleEventListener
>& xListener
)
761 throw( RuntimeException
, std::exception
)
765 ::osl::MutexGuard
aGuard( m_aMutex
);
767 sal_Int32 nListenerCount
= comphelper::AccessibleEventNotifier::removeEventListener( mnClientId
, xListener
);
768 if ( !nListenerCount
)
770 // no listeners anymore
771 // -> revoke ourself. This may lead to the notifier thread dying (if we were the last client),
772 // and at least to us not firing any events anymore, in case somebody calls
773 // NotifyAccessibleEvent, again
774 comphelper::AccessibleEventNotifier::revokeClient( mnClientId
);
781 OUString SAL_CALL
SvxPixelCtlAccessibleChild::getImplementationName() throw( RuntimeException
, std::exception
)
783 return OUString( RTL_CONSTASCII_USTRINGPARAM( "SvxPixelCtlAccessibleChild" ) );
786 sal_Bool SAL_CALL
SvxPixelCtlAccessibleChild::supportsService( const OUString
& rServiceName
) throw( RuntimeException
, std::exception
)
788 return cppu::supportsService( this, rServiceName
);
791 Sequence
< OUString
> SAL_CALL
SvxPixelCtlAccessibleChild::getSupportedServiceNames() throw( RuntimeException
, std::exception
)
793 uno::Sequence
< OUString
> aRet(3);
794 OUString
* pArray
= aRet
.getArray();
795 pArray
[0] = "Accessible";
796 pArray
[1] = "AccessibleContext";
797 pArray
[2] = "AccessibleComponent";
802 void SvxPixelCtlAccessibleChild::CommitChange( const AccessibleEventObject
& rEvent
)
805 comphelper::AccessibleEventNotifier::addEvent( mnClientId
, rEvent
);
808 void SAL_CALL
SvxPixelCtlAccessibleChild::disposing()
810 if( !rBHelper
.bDisposed
)
812 ::osl::MutexGuard
aGuard( m_aMutex
);
814 // Send a disposing to all listeners.
817 comphelper::AccessibleEventNotifier::revokeClientNotifyDisposing( mnClientId
, *this );
821 mxParent
= uno::Reference
< XAccessible
>();
823 delete mpBoundingBox
;
827 void SvxPixelCtlAccessibleChild::ThrowExceptionIfNotAlive() throw( lang::DisposedException
)
830 throw lang::DisposedException();
833 Rectangle
SvxPixelCtlAccessibleChild::GetBoundingBoxOnScreen() throw( RuntimeException
)
835 ::osl::MutexGuard
aGuard( m_aMutex
);
837 // no ThrowExceptionIfNotAlive() because its done in GetBoundingBox()
838 Rectangle
aRect( GetBoundingBox() );
840 return Rectangle( mrParentWindow
.OutputToAbsoluteScreenPixel( aRect
.TopLeft() ), aRect
.GetSize() );
843 Rectangle
SvxPixelCtlAccessibleChild::GetBoundingBox() throw( RuntimeException
)
845 // no guard necessary, because no one changes mpBoundingBox after creating it
846 ThrowExceptionIfNotAlive();
848 return *mpBoundingBox
;
851 OUString
SvxPixelCtlAccessibleChild::GetName()
853 sal_Int32 nXIndex
= mnIndexInParent
% mrParentWindow
.GetLineCount();
854 sal_Int32 nYIndex
= mnIndexInParent
/ mrParentWindow
.GetLineCount();
858 str
+= OUString::number(nXIndex
);
860 str
+= OUString::number(nYIndex
);
865 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */