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 <unotools/accessiblestatesethelper.hxx>
21 #include <vcl/svapp.hxx>
23 #include <svx/charmap.hxx>
24 #include "charmapacc.hxx"
25 #include <com/sun/star/accessibility/AccessibleRole.hpp>
26 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
27 #include <toolkit/helper/externallock.hxx>
28 #include <toolkit/helper/convert.hxx>
29 #include <osl/interlck.h>
30 #include <svx/dialmgr.hxx>
31 #include "accessibility.hrc"
32 #include <comphelper/types.hxx>
36 using namespace comphelper
;
37 using namespace ::com::sun::star
;
38 using namespace ::com::sun::star::uno
;
39 using namespace ::com::sun::star::lang
;
40 using namespace ::com::sun::star::accessibility
;
43 // - SvxShowCharSetVirtualAcc -
45 SvxShowCharSetVirtualAcc::SvxShowCharSetVirtualAcc( SvxShowCharSet
* pParent
) : OAccessibleComponentHelper(new VCLExternalSolarLock())
49 osl_atomic_increment(&m_refCount
);
53 osl_atomic_decrement(&m_refCount
);
56 // -----------------------------------------------------------------------------
58 SvxShowCharSetVirtualAcc::~SvxShowCharSetVirtualAcc()
61 delete getExternalLock();
63 // -----------------------------------------------------------------------------
64 IMPLEMENT_FORWARD_XINTERFACE2( SvxShowCharSetVirtualAcc
, OAccessibleComponentHelper
, OAccessibleHelper_Base_2
)
65 IMPLEMENT_FORWARD_XTYPEPROVIDER2( SvxShowCharSetVirtualAcc
, OAccessibleComponentHelper
, OAccessibleHelper_Base_2
)
67 void SAL_CALL
SvxShowCharSetVirtualAcc::fireEvent(
68 const sal_Int16 _nEventId
,
69 const ::com::sun::star::uno::Any
& _rOldValue
,
70 const ::com::sun::star::uno::Any
& _rNewValue
74 m_pTable
->fireEvent(_nEventId
,_rOldValue
,_rNewValue
);
76 // -----------------------------------------------------------------------------
77 sal_Int32 SAL_CALL
SvxShowCharSetVirtualAcc::getAccessibleChildCount( ) throw (RuntimeException
)
79 OExternalLockGuard
aGuard( this );
81 return ( mpParent
->getScrollBar()->IsVisible() ) ? 2 : 1;
83 // -----------------------------------------------------------------------------
84 uno::Reference
< css::accessibility::XAccessible
> SAL_CALL
SvxShowCharSetVirtualAcc::getAccessibleAtPoint( const awt::Point
& aPoint
)
85 throw (uno::RuntimeException
)
87 OExternalLockGuard
aGuard( this );
90 uno::Reference
< css::accessibility::XAccessible
> xRet
;
91 const sal_uInt16 nItemId
= sal::static_int_cast
<sal_uInt16
>(mpParent
->PixelToMapIndex( Point( aPoint
.X
, aPoint
.Y
) ));
93 if( sal_uInt16(-1) != nItemId
)
96 m_pTable
= new SvxShowCharSetAcc(this);
99 else if ( mpParent
->getScrollBar()->IsVisible() )
101 const Point
aOutPos( mpParent
->getScrollBar()->GetPosPixel() );
102 const Size aScrollBar
= mpParent
->getScrollBar()->GetOutputSizePixel();
103 Rectangle
aRect(aOutPos
,aScrollBar
);
105 if ( aRect
.IsInside(VCLPoint(aPoint
)) )
106 xRet
= mpParent
->getScrollBar()->GetAccessible();
110 // -----------------------------------------------------------------------------
111 uno::Any SAL_CALL
SvxShowCharSetVirtualAcc::getAccessibleKeyBinding()
112 throw (uno::RuntimeException
)
116 // -----------------------------------------------------------------------------
117 void SAL_CALL
SvxShowCharSetVirtualAcc::grabFocus()
118 throw (uno::RuntimeException
)
120 OExternalLockGuard
aGuard( this );
122 mpParent
->GrabFocus();
126 // -----------------------------------------------------------------------------
127 Reference
< XAccessible
> SAL_CALL
SvxShowCharSetVirtualAcc::getAccessibleChild( sal_Int32 i
) throw (IndexOutOfBoundsException
, RuntimeException
)
129 OExternalLockGuard
aGuard( this );
131 if ( mpParent
->getScrollBar()->IsVisible() && i
== 0 )
132 return mpParent
->getScrollBar()->GetAccessible();
137 m_pTable
= new SvxShowCharSetAcc(this);
142 throw IndexOutOfBoundsException();
145 // -----------------------------------------------------------------------------
146 Reference
< XAccessible
> SAL_CALL
SvxShowCharSetVirtualAcc::getAccessibleParent( ) throw (RuntimeException
)
148 OExternalLockGuard
aGuard( this );
150 Window
* pParent
= mpParent
->GetParent();
151 uno::Reference
< css::accessibility::XAccessible
> xRet
;
154 xRet
= pParent
->GetAccessible();
158 // -----------------------------------------------------------------------------
159 ::com::sun::star::awt::Rectangle SAL_CALL
SvxShowCharSetVirtualAcc::implGetBounds( ) throw (RuntimeException
)
161 const Point
aOutPos( mpParent
->GetPosPixel() );
162 Size
aOutSize( mpParent
->GetOutputSizePixel() );
163 if ( mpParent
->getScrollBar()->IsVisible() )
165 const Size aScrollBar
= mpParent
->getScrollBar()->GetOutputSizePixel();
166 aOutSize
.Width() -= aScrollBar
.Width();
167 aOutSize
.Height() -= aScrollBar
.Height();
172 aRet
.X
= aOutPos
.X();
173 aRet
.Y
= aOutPos
.Y();
174 aRet
.Width
= aOutSize
.Width();
175 aRet
.Height
= aOutSize
.Height();
179 // -----------------------------------------------------------------------------
180 sal_Int16 SAL_CALL
SvxShowCharSetVirtualAcc::getAccessibleRole( ) throw (RuntimeException
)
182 return css::accessibility::AccessibleRole::SCROLL_PANE
;
184 // -----------------------------------------------------------------------------
185 OUString SAL_CALL
SvxShowCharSetVirtualAcc::getAccessibleDescription( ) throw (RuntimeException
)
187 OExternalLockGuard
aGuard( this );
188 return SVX_RESSTR( RID_SVXSTR_CHARACTER_SELECTION
);
190 // -----------------------------------------------------------------------------
191 OUString SAL_CALL
SvxShowCharSetVirtualAcc::getAccessibleName( ) throw (RuntimeException
)
193 OExternalLockGuard
aGuard( this );
194 return SVX_RESSTR( RID_SVXSTR_CHAR_SEL_DESC
);
196 // -----------------------------------------------------------------------------
197 Reference
< XAccessibleRelationSet
> SAL_CALL
SvxShowCharSetVirtualAcc::getAccessibleRelationSet( ) throw (RuntimeException
)
199 return Reference
< XAccessibleRelationSet
>();
201 // -----------------------------------------------------------------------------
202 Reference
< XAccessibleStateSet
> SAL_CALL
SvxShowCharSetVirtualAcc::getAccessibleStateSet( ) throw (RuntimeException
)
204 OExternalLockGuard
aGuard( this );
206 ::utl::AccessibleStateSetHelper
* pStateSet
= new ::utl::AccessibleStateSetHelper
;
211 pStateSet
->AddState( AccessibleStateType::FOCUSABLE
);
212 if ( mpParent
->HasFocus() )
213 pStateSet
->AddState( AccessibleStateType::FOCUSED
);
214 if ( mpParent
->IsActive() )
215 pStateSet
->AddState( AccessibleStateType::ACTIVE
);
216 if ( mpParent
->IsEnabled() )
218 pStateSet
->AddState( AccessibleStateType::ENABLED
);
219 pStateSet
->AddState( AccessibleStateType::SENSITIVE
);
221 if ( mpParent
->IsReallyVisible() )
222 pStateSet
->AddState( AccessibleStateType::VISIBLE
);
227 // -----------------------------------------------------------------------------
228 void SAL_CALL
SvxShowCharSetVirtualAcc::disposing()
230 OAccessibleContextHelper::disposing();
235 // -----------------------------------------------------------------------------
237 // - SvxShowCharSetItem -
240 SvxShowCharSetItem::SvxShowCharSetItem( SvxShowCharSet
& rParent
,SvxShowCharSetAcc
* _pParent
,sal_uInt16 _nPos
) :
247 // -----------------------------------------------------------------------
249 SvxShowCharSetItem::~SvxShowCharSetItem()
253 m_pItem
->ParentDestroyed();
258 // -----------------------------------------------------------------------
260 uno::Reference
< css::accessibility::XAccessible
> SvxShowCharSetItem::GetAccessible()
264 m_pItem
= new SvxShowCharSetItemAcc( this );
271 // -----------------------------------------------------------------------
273 void SvxShowCharSetItem::ClearAccessible()
284 // - SvxShowCharSetAcc -
287 SvxShowCharSetAcc::SvxShowCharSetAcc( SvxShowCharSetVirtualAcc
* _pParent
) : OAccessibleSelectionHelper(new VCLExternalSolarLock())
288 ,m_pParent( _pParent
)
290 osl_atomic_increment(&m_refCount
);
294 osl_atomic_decrement(&m_refCount
);
297 // -----------------------------------------------------------------------------
299 SvxShowCharSetAcc::~SvxShowCharSetAcc()
302 delete getExternalLock();
304 // -----------------------------------------------------------------------------
305 void SAL_CALL
SvxShowCharSetAcc::disposing()
307 OAccessibleSelectionHelper::disposing();
308 ::std::vector
< Reference
< XAccessible
> >::iterator aIter
= m_aChildren
.begin();
309 ::std::vector
< Reference
< XAccessible
> >::iterator aEnd
= m_aChildren
.end();
310 for (;aIter
!= aEnd
; ++aIter
)
311 ::comphelper::disposeComponent(*aIter
);
317 // -----------------------------------------------------------------------------
318 IMPLEMENT_FORWARD_XINTERFACE2( SvxShowCharSetAcc
, OAccessibleSelectionHelper
, OAccessibleHelper_Base
)
319 IMPLEMENT_FORWARD_XTYPEPROVIDER2( SvxShowCharSetAcc
, OAccessibleSelectionHelper
, OAccessibleHelper_Base
)
320 // -----------------------------------------------------------------------
321 sal_Bool
SvxShowCharSetAcc::implIsSelected( sal_Int32 nAccessibleChildIndex
) throw (RuntimeException
)
323 return m_pParent
&& m_pParent
->getCharSetControl()->IsSelected(
324 sal::static_int_cast
<sal_uInt16
>(nAccessibleChildIndex
));
326 // -----------------------------------------------------------------------------
327 // select the specified child => watch for special ChildIndexes (ACCESSIBLE_SELECTION_CHILD_xxx)
328 void SvxShowCharSetAcc::implSelect( sal_Int32 nAccessibleChildIndex
, sal_Bool bSelect
) throw (IndexOutOfBoundsException
, RuntimeException
)
333 m_pParent
->getCharSetControl()->SelectIndex(nAccessibleChildIndex
,sal_True
);
335 m_pParent
->getCharSetControl()->DeSelect();
338 // -----------------------------------------------------------------------------
339 ::com::sun::star::awt::Rectangle SAL_CALL
SvxShowCharSetAcc::implGetBounds( ) throw (RuntimeException
)
341 const Point
aOutPos( m_pParent
->getCharSetControl()->GetPosPixel() );
342 Size
aOutSize( m_pParent
->getCharSetControl()->GetOutputSizePixel());
343 if ( m_pParent
->getCharSetControl()->getScrollBar()->IsVisible() )
345 const Size aScrollBar
= m_pParent
->getCharSetControl()->getScrollBar()->GetOutputSizePixel();
346 aOutSize
.Width() -= aScrollBar
.Width();
347 aOutSize
.Height() -= aScrollBar
.Height();
352 aRet
.X
= aOutPos
.X();
353 aRet
.Y
= aOutPos
.Y();
354 aRet
.Width
= aOutSize
.Width();
355 aRet
.Height
= aOutSize
.Height();
359 // -----------------------------------------------------------------------------
360 sal_Int32 SAL_CALL
SvxShowCharSetAcc::getAccessibleChildCount()
361 throw (uno::RuntimeException
)
363 OExternalLockGuard
aGuard( this );
365 return m_pParent
->getCharSetControl()->getMaxCharCount();
368 // -----------------------------------------------------------------------------
370 uno::Reference
< css::accessibility::XAccessible
> SAL_CALL
SvxShowCharSetAcc::getAccessibleChild( sal_Int32 i
)
371 throw (lang::IndexOutOfBoundsException
, uno::RuntimeException
)
373 OExternalLockGuard
aGuard( this );
375 uno::Reference
< css::accessibility::XAccessible
> xRet
;
376 SvxShowCharSetItem
* pItem
= m_pParent
->getCharSetControl()->ImplGetItem( static_cast< sal_uInt16
>( i
) );
380 pItem
->m_pParent
= this;
381 xRet
= pItem
->GetAccessible();
382 m_aChildren
.push_back(xRet
);
385 throw lang::IndexOutOfBoundsException();
390 // -----------------------------------------------------------------------------
392 uno::Reference
< css::accessibility::XAccessible
> SAL_CALL
SvxShowCharSetAcc::getAccessibleParent()
393 throw (uno::RuntimeException
)
395 OExternalLockGuard
aGuard( this );
400 // -----------------------------------------------------------------------------
402 sal_Int16 SAL_CALL
SvxShowCharSetAcc::getAccessibleRole()
403 throw (uno::RuntimeException
)
405 return css::accessibility::AccessibleRole::TABLE
;
408 // -----------------------------------------------------------------------------
410 OUString SAL_CALL
SvxShowCharSetAcc::getAccessibleDescription()
411 throw (uno::RuntimeException
)
413 OExternalLockGuard
aGuard( this );
414 return SVX_RESSTR( RID_SVXSTR_CHARACTER_SELECTION
);
417 // -----------------------------------------------------------------------------
419 OUString SAL_CALL
SvxShowCharSetAcc::getAccessibleName()
420 throw (uno::RuntimeException
)
422 OExternalLockGuard
aGuard( this );
424 return SVX_RESSTR( RID_SVXSTR_CHAR_SEL_DESC
);
427 // -----------------------------------------------------------------------------
429 uno::Reference
< css::accessibility::XAccessibleRelationSet
> SAL_CALL
SvxShowCharSetAcc::getAccessibleRelationSet()
430 throw (uno::RuntimeException
)
432 return uno::Reference
< css::accessibility::XAccessibleRelationSet
>();
435 // -----------------------------------------------------------------------------
437 uno::Reference
< css::accessibility::XAccessibleStateSet
> SAL_CALL
SvxShowCharSetAcc::getAccessibleStateSet()
438 throw (uno::RuntimeException
)
440 OExternalLockGuard
aGuard( this );
442 ::utl::AccessibleStateSetHelper
* pStateSet
= new ::utl::AccessibleStateSetHelper
;
444 if( m_pParent
->getCharSetControl() )
447 pStateSet
->AddState( AccessibleStateType::FOCUSABLE
);
448 if ( m_pParent
->getCharSetControl()->HasFocus() )
449 pStateSet
->AddState( AccessibleStateType::FOCUSED
);
450 if ( m_pParent
->getCharSetControl()->IsActive() )
451 pStateSet
->AddState( AccessibleStateType::ACTIVE
);
452 if ( m_pParent
->getCharSetControl()->IsEnabled() )
454 pStateSet
->AddState( AccessibleStateType::ENABLED
);
455 pStateSet
->AddState( AccessibleStateType::SENSITIVE
);
457 if ( m_pParent
->getCharSetControl()->IsReallyVisible() )
458 pStateSet
->AddState( AccessibleStateType::VISIBLE
);
460 pStateSet
->AddState( AccessibleStateType::MANAGES_DESCENDANTS
);
465 // -----------------------------------------------------------------------------
467 uno::Reference
< css::accessibility::XAccessible
> SAL_CALL
SvxShowCharSetAcc::getAccessibleAtPoint( const awt::Point
& aPoint
)
468 throw (uno::RuntimeException
)
470 OExternalLockGuard
aGuard( this );
473 uno::Reference
< css::accessibility::XAccessible
> xRet
;
474 const sal_uInt16 nItemId
= sal::static_int_cast
<sal_uInt16
>(
475 m_pParent
->getCharSetControl()->PixelToMapIndex( Point( aPoint
.X
, aPoint
.Y
) ));
477 if( sal_uInt16(-1) != nItemId
)
479 SvxShowCharSetItem
* pItem
= m_pParent
->getCharSetControl()->ImplGetItem( nItemId
);
480 xRet
= pItem
->GetAccessible();
485 // -----------------------------------------------------------------------------
486 // -----------------------------------------------------------------------------
488 void SAL_CALL
SvxShowCharSetAcc::grabFocus()
489 throw (uno::RuntimeException
)
491 OExternalLockGuard
aGuard( this );
493 m_pParent
->getCharSetControl()->GrabFocus();
496 // -----------------------------------------------------------------------------
498 uno::Any SAL_CALL
SvxShowCharSetAcc::getAccessibleKeyBinding()
499 throw (uno::RuntimeException
)
503 // -----------------------------------------------------------------------------
504 sal_Int32 SAL_CALL
SvxShowCharSetAcc::getAccessibleRowCount( ) throw (RuntimeException
)
506 return ((getAccessibleChildCount()-1) / COLUMN_COUNT
) + 1;
508 // -----------------------------------------------------------------------------
509 sal_Int32 SAL_CALL
SvxShowCharSetAcc::getAccessibleColumnCount( ) throw (RuntimeException
)
513 // -----------------------------------------------------------------------------
514 OUString SAL_CALL
SvxShowCharSetAcc::getAccessibleRowDescription( sal_Int32
/*nRow*/ ) throw (IndexOutOfBoundsException
, RuntimeException
)
518 // -----------------------------------------------------------------------------
519 OUString SAL_CALL
SvxShowCharSetAcc::getAccessibleColumnDescription( sal_Int32
/*nColumn*/ ) throw (IndexOutOfBoundsException
, RuntimeException
)
523 // -----------------------------------------------------------------------------
524 sal_Int32 SAL_CALL
SvxShowCharSetAcc::getAccessibleRowExtentAt( sal_Int32
/*nRow*/, sal_Int32
/*nColumn*/ ) throw (IndexOutOfBoundsException
, RuntimeException
)
528 // -----------------------------------------------------------------------------
529 sal_Int32 SAL_CALL
SvxShowCharSetAcc::getAccessibleColumnExtentAt( sal_Int32
/*nRow*/, sal_Int32
/*nColumn*/ ) throw (IndexOutOfBoundsException
, RuntimeException
)
533 // -----------------------------------------------------------------------------
534 Reference
< XAccessibleTable
> SAL_CALL
SvxShowCharSetAcc::getAccessibleRowHeaders( ) throw (RuntimeException
)
536 return Reference
< XAccessibleTable
>();
538 // -----------------------------------------------------------------------------
539 Reference
< XAccessibleTable
> SAL_CALL
SvxShowCharSetAcc::getAccessibleColumnHeaders( ) throw (RuntimeException
)
541 return Reference
< XAccessibleTable
>();
543 // -----------------------------------------------------------------------------
544 Sequence
< sal_Int32
> SAL_CALL
SvxShowCharSetAcc::getSelectedAccessibleRows( ) throw (RuntimeException
)
546 OExternalLockGuard
aGuard( this );
548 Sequence
< sal_Int32
> aSel(1);
549 aSel
[0] = m_pParent
->getCharSetControl()->GetRowPos(m_pParent
->getCharSetControl()->GetSelectIndexId());
552 // -----------------------------------------------------------------------------
553 Sequence
< sal_Int32
> SAL_CALL
SvxShowCharSetAcc::getSelectedAccessibleColumns( ) throw (RuntimeException
)
555 OExternalLockGuard
aGuard( this );
557 Sequence
< sal_Int32
> aSel(1);
558 aSel
[0] = m_pParent
->getCharSetControl()->GetColumnPos(m_pParent
->getCharSetControl()->GetSelectIndexId());
561 // -----------------------------------------------------------------------------
562 sal_Bool SAL_CALL
SvxShowCharSetAcc::isAccessibleRowSelected( sal_Int32 nRow
) throw (IndexOutOfBoundsException
, RuntimeException
)
564 OExternalLockGuard
aGuard( this );
566 return m_pParent
->getCharSetControl()->GetRowPos(m_pParent
->getCharSetControl()->GetSelectIndexId()) == nRow
;
568 // -----------------------------------------------------------------------------
569 sal_Bool SAL_CALL
SvxShowCharSetAcc::isAccessibleColumnSelected( sal_Int32 nColumn
) throw (IndexOutOfBoundsException
, RuntimeException
)
571 OExternalLockGuard
aGuard( this );
573 return m_pParent
->getCharSetControl()->GetColumnPos(m_pParent
->getCharSetControl()->GetSelectIndexId()) == nColumn
;
575 // -----------------------------------------------------------------------------
576 Reference
< XAccessible
> SAL_CALL
SvxShowCharSetAcc::getAccessibleCellAt( sal_Int32 nRow
, sal_Int32 nColumn
) throw (IndexOutOfBoundsException
, RuntimeException
)
578 OExternalLockGuard
aGuard( this );
580 ::svx::SvxShowCharSetItem
* pItem
= m_pParent
->getCharSetControl()->ImplGetItem(
581 sal::static_int_cast
<sal_uInt16
>(getAccessibleIndex(nRow
,nColumn
) ));
583 throw IndexOutOfBoundsException();
584 return pItem
->GetAccessible();
586 // -----------------------------------------------------------------------------
587 Reference
< XAccessible
> SAL_CALL
SvxShowCharSetAcc::getAccessibleCaption( ) throw (RuntimeException
)
589 return Reference
< XAccessible
>();
591 // -----------------------------------------------------------------------------
592 Reference
< XAccessible
> SAL_CALL
SvxShowCharSetAcc::getAccessibleSummary( ) throw (RuntimeException
)
594 return Reference
< XAccessible
>();
596 // -----------------------------------------------------------------------------
597 sal_Bool SAL_CALL
SvxShowCharSetAcc::isAccessibleSelected( sal_Int32 nRow
, sal_Int32 nColumn
) throw (IndexOutOfBoundsException
, RuntimeException
)
599 OExternalLockGuard
aGuard( this );
601 return m_pParent
->getCharSetControl()->GetSelectIndexId() == getAccessibleIndex(nRow
,nColumn
);
603 // -----------------------------------------------------------------------------
604 sal_Int32 SAL_CALL
SvxShowCharSetAcc::getAccessibleIndex( sal_Int32 nRow
, sal_Int32 nColumn
) throw (IndexOutOfBoundsException
, RuntimeException
)
606 return (nRow
*COLUMN_COUNT
) + nColumn
;
608 // -----------------------------------------------------------------------------
609 sal_Int32 SAL_CALL
SvxShowCharSetAcc::getAccessibleRow( sal_Int32 nChildIndex
) throw (IndexOutOfBoundsException
, RuntimeException
)
611 OExternalLockGuard
aGuard( this );
613 return m_pParent
->getCharSetControl()->GetRowPos(sal::static_int_cast
<sal_uInt16
>(nChildIndex
));
615 // -----------------------------------------------------------------------------
616 sal_Int32 SAL_CALL
SvxShowCharSetAcc::getAccessibleColumn( sal_Int32 nChildIndex
) throw (IndexOutOfBoundsException
, RuntimeException
)
618 OExternalLockGuard
aGuard( this );
620 return m_pParent
->getCharSetControl()->GetColumnPos(sal::static_int_cast
<sal_uInt16
>(nChildIndex
));
622 // -----------------------------------------------------------------------------
624 // -----------------------------------------------------------------------------
626 // - SvxShowCharSetItemAcc -
629 SvxShowCharSetItemAcc::SvxShowCharSetItemAcc( SvxShowCharSetItem
* pParent
) : OAccessibleComponentHelper(new VCLExternalSolarLock())
632 OSL_ENSURE(pParent
,"NO parent supplied!");
633 osl_atomic_increment(&m_refCount
);
637 osl_atomic_decrement(&m_refCount
);
640 // -----------------------------------------------------------------------------
642 SvxShowCharSetItemAcc::~SvxShowCharSetItemAcc()
645 delete getExternalLock();
647 // -----------------------------------------------------------------------------
648 IMPLEMENT_FORWARD_XINTERFACE2( SvxShowCharSetItemAcc
, OAccessibleComponentHelper
, OAccessibleHelper_Base_2
)
649 IMPLEMENT_FORWARD_XTYPEPROVIDER2( SvxShowCharSetItemAcc
, OAccessibleComponentHelper
, OAccessibleHelper_Base_2
)
650 // -----------------------------------------------------------------------------
652 void SvxShowCharSetItemAcc::ParentDestroyed()
654 const ::osl::MutexGuard
aGuard( GetMutex() );
658 // -----------------------------------------------------------------------------
660 sal_Int32 SAL_CALL
SvxShowCharSetItemAcc::getAccessibleChildCount()
661 throw (uno::RuntimeException
)
666 // -----------------------------------------------------------------------------
668 uno::Reference
< css::accessibility::XAccessible
> SAL_CALL
SvxShowCharSetItemAcc::getAccessibleChild( sal_Int32
/*i*/ )
669 throw (lang::IndexOutOfBoundsException
, uno::RuntimeException
)
671 throw lang::IndexOutOfBoundsException();
674 // -----------------------------------------------------------------------------
676 uno::Reference
< css::accessibility::XAccessible
> SAL_CALL
SvxShowCharSetItemAcc::getAccessibleParent()
677 throw (uno::RuntimeException
)
679 OExternalLockGuard
aGuard( this );
681 return mpParent
->m_pParent
;
684 // -----------------------------------------------------------------------------
686 sal_Int16 SAL_CALL
SvxShowCharSetItemAcc::getAccessibleRole()
687 throw (uno::RuntimeException
)
689 return css::accessibility::AccessibleRole::LABEL
;
692 // -----------------------------------------------------------------------------
694 OUString SAL_CALL
SvxShowCharSetItemAcc::getAccessibleDescription()
695 throw (uno::RuntimeException
)
697 OExternalLockGuard
aGuard( this );
699 String sDescription
= SVX_RESSTR( RID_SVXSTR_CHARACTER_CODE
);
701 sal_Unicode c
= mpParent
->maText
[0];
702 char buf
[16] = "0x0000";
703 sal_Unicode c_Shifted
= c
;
704 for( int i
= 0; i
< 4; ++i
)
706 char h
= (char)(c_Shifted
& 0x0F);
707 buf
[5-i
] = (h
> 9) ? (h
- 10 + 'A') : (h
+ '0');
711 snprintf( buf
+6, 10, " (%d)", c
);
712 sDescription
.AppendAscii(buf
);
717 // -----------------------------------------------------------------------------
719 OUString SAL_CALL
SvxShowCharSetItemAcc::getAccessibleName()
720 throw (uno::RuntimeException
)
722 OExternalLockGuard
aGuard( this );
728 aRet
= mpParent
->maText
;
731 aRet
= getAccessibleDescription();
737 // -----------------------------------------------------------------------------
739 uno::Reference
< css::accessibility::XAccessibleRelationSet
> SAL_CALL
SvxShowCharSetItemAcc::getAccessibleRelationSet()
740 throw (uno::RuntimeException
)
742 return uno::Reference
< css::accessibility::XAccessibleRelationSet
>();
745 // -----------------------------------------------------------------------------
747 uno::Reference
< css::accessibility::XAccessibleStateSet
> SAL_CALL
SvxShowCharSetItemAcc::getAccessibleStateSet()
748 throw (uno::RuntimeException
)
750 OExternalLockGuard
aGuard( this );
753 ::utl::AccessibleStateSetHelper
* pStateSet
= new ::utl::AccessibleStateSetHelper
;
758 pStateSet
->AddState( css::accessibility::AccessibleStateType::SELECTABLE
);
759 pStateSet
->AddState( css::accessibility::AccessibleStateType::FOCUSABLE
);
762 if( mpParent
->mrParent
.GetSelectIndexId() == mpParent
->mnId
)
764 pStateSet
->AddState( css::accessibility::AccessibleStateType::SELECTED
);
765 pStateSet
->AddState( css::accessibility::AccessibleStateType::FOCUSED
);
767 if ( mpParent
->mnId
>= mpParent
->mrParent
.FirstInView() && mpParent
->mnId
<= mpParent
->mrParent
.LastInView() )
768 pStateSet
->AddState( AccessibleStateType::VISIBLE
);
769 pStateSet
->AddState( AccessibleStateType::TRANSIENT
);
775 // -----------------------------------------------------------------------------
776 void SAL_CALL
SvxShowCharSetItemAcc::grabFocus()
777 throw (uno::RuntimeException
)
782 // -----------------------------------------------------------------------------
784 uno::Any SAL_CALL
SvxShowCharSetItemAcc::getAccessibleKeyBinding()
785 throw (uno::RuntimeException
)
789 // -----------------------------------------------------------------------------
790 awt::Rectangle SAL_CALL
SvxShowCharSetItemAcc::implGetBounds( ) throw (RuntimeException
)
796 Rectangle
aRect( mpParent
->maRect
);
798 Rectangle
aParentRect( aOrigin
, mpParent
->mrParent
.GetOutputSizePixel() );
800 aRect
.Intersection( aParentRect
);
802 aRet
.X
= aRect
.Left();
803 aRet
.Y
= aRect
.Top();
804 aRet
.Width
= aRect
.GetWidth();
805 aRet
.Height
= aRect
.GetHeight();
810 // -----------------------------------------------------------------------------
811 uno::Reference
< css::accessibility::XAccessible
> SAL_CALL
SvxShowCharSetItemAcc::getAccessibleAtPoint( const awt::Point
& /*aPoint*/ )
812 throw (uno::RuntimeException
)
814 return uno::Reference
< css::accessibility::XAccessible
>();
816 // -----------------------------------------------------------------------------
817 sal_Int32 SAL_CALL
SvxShowCharSetVirtualAcc::getForeground( ) throw (RuntimeException
)
819 OExternalLockGuard
aGuard( this );
821 sal_Int32 nColor
= 0;
824 if ( mpParent
->IsControlForeground() )
825 nColor
= mpParent
->GetControlForeground().GetColor();
829 if ( mpParent
->IsControlFont() )
830 aFont
= mpParent
->GetControlFont();
832 aFont
= mpParent
->GetFont();
833 nColor
= aFont
.GetColor().GetColor();
839 // -----------------------------------------------------------------------------
840 sal_Int32 SAL_CALL
SvxShowCharSetVirtualAcc::getBackground( ) throw (RuntimeException
)
842 OExternalLockGuard
aGuard( this );
843 sal_Int32 nColor
= 0;
846 if ( mpParent
->IsControlBackground() )
847 nColor
= mpParent
->GetControlBackground().GetColor();
849 nColor
= mpParent
->GetBackground().GetColor().GetColor();
854 // -----------------------------------------------------------------------------
855 sal_Int32 SAL_CALL
SvxShowCharSetAcc::getForeground( ) throw (RuntimeException
)
857 OExternalLockGuard
aGuard( this );
859 sal_Int32 nColor
= 0;
861 nColor
= m_pParent
->getForeground();
864 // -----------------------------------------------------------------------------
865 sal_Int32 SAL_CALL
SvxShowCharSetAcc::getBackground( ) throw (RuntimeException
)
867 OExternalLockGuard
aGuard( this );
868 sal_Int32 nColor
= 0;
870 nColor
= m_pParent
->getBackground();
873 // -----------------------------------------------------------------------------
875 // -----------------------------------------------------------------------------
877 // -----------------------------------------------------------------------------
880 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */