1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: charmapacc.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
34 #define _SVX_CHARMAP_CXX_
35 #include <unotools/accessiblestatesethelper.hxx>
36 #include <vcl/svapp.hxx>
38 #include <svx/charmap.hxx>
39 #include "charmapacc.hxx"
40 #include <com/sun/star/accessibility/AccessibleRole.hpp>
41 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
42 #include <toolkit/helper/externallock.hxx>
43 #include <toolkit/helper/convert.hxx>
44 #include <osl/interlck.h>
45 #include <svx/dialmgr.hxx>
46 #include "accessibility.hrc"
47 #include <comphelper/types.hxx>
51 using namespace comphelper
;
52 using namespace ::com::sun::star
;
53 using namespace ::com::sun::star::uno
;
54 using namespace ::com::sun::star::lang
;
55 using namespace ::com::sun::star::accessibility
;
58 // - SvxShowCharSetVirtualAcc -
60 SvxShowCharSetVirtualAcc::SvxShowCharSetVirtualAcc( SvxShowCharSet
* pParent
) : OAccessibleComponentHelper(new VCLExternalSolarLock())
64 osl_incrementInterlockedCount(&m_refCount
);
68 osl_decrementInterlockedCount(&m_refCount
);
71 // -----------------------------------------------------------------------------
73 SvxShowCharSetVirtualAcc::~SvxShowCharSetVirtualAcc()
76 delete getExternalLock();
78 // -----------------------------------------------------------------------------
79 IMPLEMENT_FORWARD_XINTERFACE2( SvxShowCharSetVirtualAcc
, OAccessibleComponentHelper
, OAccessibleHelper_Base_2
)
80 IMPLEMENT_FORWARD_XTYPEPROVIDER2( SvxShowCharSetVirtualAcc
, OAccessibleComponentHelper
, OAccessibleHelper_Base_2
)
82 void SAL_CALL
SvxShowCharSetVirtualAcc::fireEvent(
83 const sal_Int16 _nEventId
,
84 const ::com::sun::star::uno::Any
& _rOldValue
,
85 const ::com::sun::star::uno::Any
& _rNewValue
89 m_pTable
->fireEvent(_nEventId
,_rOldValue
,_rNewValue
);
91 // -----------------------------------------------------------------------------
92 sal_Int32 SAL_CALL
SvxShowCharSetVirtualAcc::getAccessibleChildCount( ) throw (RuntimeException
)
94 OExternalLockGuard
aGuard( this );
96 return ( mpParent
->getScrollBar()->IsVisible() ) ? 2 : 1;
98 // -----------------------------------------------------------------------------
99 uno::Reference
< accessibility::XAccessible
> SAL_CALL
SvxShowCharSetVirtualAcc::getAccessibleAtPoint( const awt::Point
& aPoint
)
100 throw (uno::RuntimeException
)
102 OExternalLockGuard
aGuard( this );
105 uno::Reference
< accessibility::XAccessible
> xRet
;
106 const USHORT nItemId
= sal::static_int_cast
<USHORT
>(mpParent
->PixelToMapIndex( Point( aPoint
.X
, aPoint
.Y
) ));
108 if( USHORT(-1) != nItemId
)
111 m_pTable
= new SvxShowCharSetAcc(this);
114 else if ( mpParent
->getScrollBar()->IsVisible() )
116 const Point
aOutPos( mpParent
->getScrollBar()->GetPosPixel() );
117 const Size aScrollBar
= mpParent
->getScrollBar()->GetOutputSizePixel();
118 Rectangle
aRect(aOutPos
,aScrollBar
);
120 if ( aRect
.IsInside(VCLPoint(aPoint
)) )
121 xRet
= mpParent
->getScrollBar()->GetAccessible();
125 // -----------------------------------------------------------------------------
126 uno::Any SAL_CALL
SvxShowCharSetVirtualAcc::getAccessibleKeyBinding()
127 throw (uno::RuntimeException
)
131 // -----------------------------------------------------------------------------
132 void SAL_CALL
SvxShowCharSetVirtualAcc::grabFocus()
133 throw (uno::RuntimeException
)
135 OExternalLockGuard
aGuard( this );
137 mpParent
->GrabFocus();
141 // -----------------------------------------------------------------------------
142 Reference
< XAccessible
> SAL_CALL
SvxShowCharSetVirtualAcc::getAccessibleChild( sal_Int32 i
) throw (IndexOutOfBoundsException
, RuntimeException
)
144 OExternalLockGuard
aGuard( this );
146 if ( mpParent
->getScrollBar()->IsVisible() && i
== 0 )
147 return mpParent
->getScrollBar()->GetAccessible();
152 m_pTable
= new SvxShowCharSetAcc(this);
157 throw IndexOutOfBoundsException();
160 // -----------------------------------------------------------------------------
161 Reference
< XAccessible
> SAL_CALL
SvxShowCharSetVirtualAcc::getAccessibleParent( ) throw (RuntimeException
)
163 OExternalLockGuard
aGuard( this );
165 Window
* pParent
= mpParent
->GetParent();
166 uno::Reference
< accessibility::XAccessible
> xRet
;
169 xRet
= pParent
->GetAccessible();
173 // -----------------------------------------------------------------------------
174 ::com::sun::star::awt::Rectangle SAL_CALL
SvxShowCharSetVirtualAcc::implGetBounds( ) throw (RuntimeException
)
176 const Point
aOutPos( mpParent
->GetPosPixel() );
177 Size
aOutSize( mpParent
->GetOutputSizePixel() );
178 if ( mpParent
->getScrollBar()->IsVisible() )
180 const Size aScrollBar
= mpParent
->getScrollBar()->GetOutputSizePixel();
181 aOutSize
.Width() -= aScrollBar
.Width();
182 aOutSize
.Height() -= aScrollBar
.Height();
187 aRet
.X
= aOutPos
.X();
188 aRet
.Y
= aOutPos
.Y();
189 aRet
.Width
= aOutSize
.Width();
190 aRet
.Height
= aOutSize
.Height();
194 // -----------------------------------------------------------------------------
195 sal_Int16 SAL_CALL
SvxShowCharSetVirtualAcc::getAccessibleRole( ) throw (RuntimeException
)
197 return accessibility::AccessibleRole::SCROLL_PANE
;
199 // -----------------------------------------------------------------------------
200 ::rtl::OUString SAL_CALL
SvxShowCharSetVirtualAcc::getAccessibleDescription( ) throw (RuntimeException
)
202 OExternalLockGuard
aGuard( this );
203 return SVX_RESSTR( RID_SVXSTR_CHARACTER_SELECTION
);
205 // -----------------------------------------------------------------------------
206 ::rtl::OUString SAL_CALL
SvxShowCharSetVirtualAcc::getAccessibleName( ) throw (RuntimeException
)
208 OExternalLockGuard
aGuard( this );
209 return SVX_RESSTR( RID_SVXSTR_CHAR_SEL_DESC
);
211 // -----------------------------------------------------------------------------
212 Reference
< XAccessibleRelationSet
> SAL_CALL
SvxShowCharSetVirtualAcc::getAccessibleRelationSet( ) throw (RuntimeException
)
214 return Reference
< XAccessibleRelationSet
>();
216 // -----------------------------------------------------------------------------
217 Reference
< XAccessibleStateSet
> SAL_CALL
SvxShowCharSetVirtualAcc::getAccessibleStateSet( ) throw (RuntimeException
)
219 OExternalLockGuard
aGuard( this );
221 ::utl::AccessibleStateSetHelper
* pStateSet
= new ::utl::AccessibleStateSetHelper
;
226 pStateSet
->AddState( AccessibleStateType::FOCUSABLE
);
227 if ( mpParent
->HasFocus() )
228 pStateSet
->AddState( AccessibleStateType::FOCUSED
);
229 if ( mpParent
->IsActive() )
230 pStateSet
->AddState( AccessibleStateType::ACTIVE
);
231 if ( mpParent
->IsEnabled() )
233 pStateSet
->AddState( AccessibleStateType::ENABLED
);
234 pStateSet
->AddState( AccessibleStateType::SENSITIVE
);
236 if ( mpParent
->IsReallyVisible() )
237 pStateSet
->AddState( AccessibleStateType::VISIBLE
);
242 // -----------------------------------------------------------------------------
243 void SAL_CALL
SvxShowCharSetVirtualAcc::disposing()
245 OAccessibleContextHelper::disposing();
250 // -----------------------------------------------------------------------------
252 // - SvxShowCharSetItem -
255 SvxShowCharSetItem::SvxShowCharSetItem( SvxShowCharSet
& rParent
,SvxShowCharSetAcc
* _pParent
,USHORT _nPos
) :
262 // -----------------------------------------------------------------------
264 SvxShowCharSetItem::~SvxShowCharSetItem()
268 m_pItem
->ParentDestroyed();
273 // -----------------------------------------------------------------------
275 uno::Reference
< accessibility::XAccessible
> SvxShowCharSetItem::GetAccessible()
279 m_pItem
= new SvxShowCharSetItemAcc( this );
286 // -----------------------------------------------------------------------
288 void SvxShowCharSetItem::ClearAccessible()
299 // - SvxShowCharSetAcc -
302 SvxShowCharSetAcc::SvxShowCharSetAcc( SvxShowCharSetVirtualAcc
* _pParent
) : OAccessibleSelectionHelper(new VCLExternalSolarLock())
303 ,m_pParent( _pParent
)
305 osl_incrementInterlockedCount(&m_refCount
);
309 osl_decrementInterlockedCount(&m_refCount
);
312 // -----------------------------------------------------------------------------
314 SvxShowCharSetAcc::~SvxShowCharSetAcc()
317 delete getExternalLock();
319 // -----------------------------------------------------------------------------
320 void SAL_CALL
SvxShowCharSetAcc::disposing()
322 OAccessibleSelectionHelper::disposing();
323 ::std::vector
< Reference
< XAccessible
> >::iterator aIter
= m_aChildren
.begin();
324 ::std::vector
< Reference
< XAccessible
> >::iterator aEnd
= m_aChildren
.end();
325 for (;aIter
!= aEnd
; ++aIter
)
326 ::comphelper::disposeComponent(*aIter
);
332 // -----------------------------------------------------------------------------
333 IMPLEMENT_FORWARD_XINTERFACE2( SvxShowCharSetAcc
, OAccessibleSelectionHelper
, OAccessibleHelper_Base
)
334 IMPLEMENT_FORWARD_XTYPEPROVIDER2( SvxShowCharSetAcc
, OAccessibleSelectionHelper
, OAccessibleHelper_Base
)
335 // -----------------------------------------------------------------------
336 sal_Bool
SvxShowCharSetAcc::implIsSelected( sal_Int32 nAccessibleChildIndex
) throw (RuntimeException
)
338 return m_pParent
&& m_pParent
->getCharSetControl()->IsSelected(
339 sal::static_int_cast
<USHORT
>(nAccessibleChildIndex
));
341 // -----------------------------------------------------------------------------
342 // select the specified child => watch for special ChildIndexes (ACCESSIBLE_SELECTION_CHILD_xxx)
343 void SvxShowCharSetAcc::implSelect( sal_Int32 nAccessibleChildIndex
, sal_Bool bSelect
) throw (IndexOutOfBoundsException
, RuntimeException
)
348 m_pParent
->getCharSetControl()->SelectIndex(nAccessibleChildIndex
,sal_True
);
350 m_pParent
->getCharSetControl()->DeSelect();
353 // -----------------------------------------------------------------------------
354 ::com::sun::star::awt::Rectangle SAL_CALL
SvxShowCharSetAcc::implGetBounds( ) throw (RuntimeException
)
356 const Point
aOutPos( m_pParent
->getCharSetControl()->GetPosPixel() );
357 Size
aOutSize( m_pParent
->getCharSetControl()->GetOutputSizePixel());
358 if ( m_pParent
->getCharSetControl()->getScrollBar()->IsVisible() )
360 const Size aScrollBar
= m_pParent
->getCharSetControl()->getScrollBar()->GetOutputSizePixel();
361 aOutSize
.Width() -= aScrollBar
.Width();
362 aOutSize
.Height() -= aScrollBar
.Height();
367 aRet
.X
= aOutPos
.X();
368 aRet
.Y
= aOutPos
.Y();
369 aRet
.Width
= aOutSize
.Width();
370 aRet
.Height
= aOutSize
.Height();
374 // -----------------------------------------------------------------------------
375 sal_Int32 SAL_CALL
SvxShowCharSetAcc::getAccessibleChildCount()
376 throw (uno::RuntimeException
)
378 OExternalLockGuard
aGuard( this );
380 return m_pParent
->getCharSetControl()->getMaxCharCount();
383 // -----------------------------------------------------------------------------
385 uno::Reference
< accessibility::XAccessible
> SAL_CALL
SvxShowCharSetAcc::getAccessibleChild( sal_Int32 i
)
386 throw (lang::IndexOutOfBoundsException
, uno::RuntimeException
)
388 OExternalLockGuard
aGuard( this );
390 uno::Reference
< accessibility::XAccessible
> xRet
;
391 SvxShowCharSetItem
* pItem
= m_pParent
->getCharSetControl()->ImplGetItem( static_cast< USHORT
>( i
) );
395 pItem
->m_pParent
= this;
396 xRet
= pItem
->GetAccessible();
397 m_aChildren
.push_back(xRet
);
400 throw lang::IndexOutOfBoundsException();
405 // -----------------------------------------------------------------------------
407 uno::Reference
< accessibility::XAccessible
> SAL_CALL
SvxShowCharSetAcc::getAccessibleParent()
408 throw (uno::RuntimeException
)
410 OExternalLockGuard
aGuard( this );
415 // -----------------------------------------------------------------------------
417 sal_Int16 SAL_CALL
SvxShowCharSetAcc::getAccessibleRole()
418 throw (uno::RuntimeException
)
420 return accessibility::AccessibleRole::TABLE
;
423 // -----------------------------------------------------------------------------
425 ::rtl::OUString SAL_CALL
SvxShowCharSetAcc::getAccessibleDescription()
426 throw (uno::RuntimeException
)
428 OExternalLockGuard
aGuard( this );
429 return SVX_RESSTR( RID_SVXSTR_CHARACTER_SELECTION
);
432 // -----------------------------------------------------------------------------
434 ::rtl::OUString SAL_CALL
SvxShowCharSetAcc::getAccessibleName()
435 throw (uno::RuntimeException
)
437 OExternalLockGuard
aGuard( this );
439 return SVX_RESSTR( RID_SVXSTR_CHAR_SEL_DESC
);
442 // -----------------------------------------------------------------------------
444 uno::Reference
< accessibility::XAccessibleRelationSet
> SAL_CALL
SvxShowCharSetAcc::getAccessibleRelationSet()
445 throw (uno::RuntimeException
)
447 return uno::Reference
< accessibility::XAccessibleRelationSet
>();
450 // -----------------------------------------------------------------------------
452 uno::Reference
< accessibility::XAccessibleStateSet
> SAL_CALL
SvxShowCharSetAcc::getAccessibleStateSet()
453 throw (uno::RuntimeException
)
455 OExternalLockGuard
aGuard( this );
457 ::utl::AccessibleStateSetHelper
* pStateSet
= new ::utl::AccessibleStateSetHelper
;
459 if( m_pParent
->getCharSetControl() )
462 pStateSet
->AddState( AccessibleStateType::FOCUSABLE
);
463 if ( m_pParent
->getCharSetControl()->HasFocus() )
464 pStateSet
->AddState( AccessibleStateType::FOCUSED
);
465 if ( m_pParent
->getCharSetControl()->IsActive() )
466 pStateSet
->AddState( AccessibleStateType::ACTIVE
);
467 if ( m_pParent
->getCharSetControl()->IsEnabled() )
469 pStateSet
->AddState( AccessibleStateType::ENABLED
);
470 pStateSet
->AddState( AccessibleStateType::SENSITIVE
);
472 if ( m_pParent
->getCharSetControl()->IsReallyVisible() )
473 pStateSet
->AddState( AccessibleStateType::VISIBLE
);
475 pStateSet
->AddState( AccessibleStateType::MANAGES_DESCENDANTS
);
480 // -----------------------------------------------------------------------------
482 uno::Reference
< accessibility::XAccessible
> SAL_CALL
SvxShowCharSetAcc::getAccessibleAtPoint( const awt::Point
& aPoint
)
483 throw (uno::RuntimeException
)
485 OExternalLockGuard
aGuard( this );
488 uno::Reference
< accessibility::XAccessible
> xRet
;
489 const USHORT nItemId
= sal::static_int_cast
<USHORT
>(
490 m_pParent
->getCharSetControl()->PixelToMapIndex( Point( aPoint
.X
, aPoint
.Y
) ));
492 if( USHORT(-1) != nItemId
)
494 SvxShowCharSetItem
* pItem
= m_pParent
->getCharSetControl()->ImplGetItem( nItemId
);
495 xRet
= pItem
->GetAccessible();
500 // -----------------------------------------------------------------------------
501 // -----------------------------------------------------------------------------
503 void SAL_CALL
SvxShowCharSetAcc::grabFocus()
504 throw (uno::RuntimeException
)
506 OExternalLockGuard
aGuard( this );
508 m_pParent
->getCharSetControl()->GrabFocus();
511 // -----------------------------------------------------------------------------
513 uno::Any SAL_CALL
SvxShowCharSetAcc::getAccessibleKeyBinding()
514 throw (uno::RuntimeException
)
518 // -----------------------------------------------------------------------------
519 sal_Int32 SAL_CALL
SvxShowCharSetAcc::getAccessibleRowCount( ) throw (RuntimeException
)
521 return ((getAccessibleChildCount()-1) / COLUMN_COUNT
) + 1;
523 // -----------------------------------------------------------------------------
524 sal_Int32 SAL_CALL
SvxShowCharSetAcc::getAccessibleColumnCount( ) throw (RuntimeException
)
528 // -----------------------------------------------------------------------------
529 ::rtl::OUString SAL_CALL
SvxShowCharSetAcc::getAccessibleRowDescription( sal_Int32
/*nRow*/ ) throw (IndexOutOfBoundsException
, RuntimeException
)
531 return ::rtl::OUString();
533 // -----------------------------------------------------------------------------
534 ::rtl::OUString SAL_CALL
SvxShowCharSetAcc::getAccessibleColumnDescription( sal_Int32
/*nColumn*/ ) throw (IndexOutOfBoundsException
, RuntimeException
)
536 return ::rtl::OUString();
538 // -----------------------------------------------------------------------------
539 sal_Int32 SAL_CALL
SvxShowCharSetAcc::getAccessibleRowExtentAt( sal_Int32
/*nRow*/, sal_Int32
/*nColumn*/ ) throw (IndexOutOfBoundsException
, RuntimeException
)
543 // -----------------------------------------------------------------------------
544 sal_Int32 SAL_CALL
SvxShowCharSetAcc::getAccessibleColumnExtentAt( sal_Int32
/*nRow*/, sal_Int32
/*nColumn*/ ) throw (IndexOutOfBoundsException
, RuntimeException
)
548 // -----------------------------------------------------------------------------
549 Reference
< XAccessibleTable
> SAL_CALL
SvxShowCharSetAcc::getAccessibleRowHeaders( ) throw (RuntimeException
)
551 return Reference
< XAccessibleTable
>();
553 // -----------------------------------------------------------------------------
554 Reference
< XAccessibleTable
> SAL_CALL
SvxShowCharSetAcc::getAccessibleColumnHeaders( ) throw (RuntimeException
)
556 return Reference
< XAccessibleTable
>();
558 // -----------------------------------------------------------------------------
559 Sequence
< sal_Int32
> SAL_CALL
SvxShowCharSetAcc::getSelectedAccessibleRows( ) throw (RuntimeException
)
561 OExternalLockGuard
aGuard( this );
563 Sequence
< sal_Int32
> aSel(1);
564 aSel
[0] = m_pParent
->getCharSetControl()->GetRowPos(m_pParent
->getCharSetControl()->GetSelectIndexId());
567 // -----------------------------------------------------------------------------
568 Sequence
< sal_Int32
> SAL_CALL
SvxShowCharSetAcc::getSelectedAccessibleColumns( ) throw (RuntimeException
)
570 OExternalLockGuard
aGuard( this );
572 Sequence
< sal_Int32
> aSel(1);
573 aSel
[0] = m_pParent
->getCharSetControl()->GetColumnPos(m_pParent
->getCharSetControl()->GetSelectIndexId());
576 // -----------------------------------------------------------------------------
577 sal_Bool SAL_CALL
SvxShowCharSetAcc::isAccessibleRowSelected( sal_Int32 nRow
) throw (IndexOutOfBoundsException
, RuntimeException
)
579 OExternalLockGuard
aGuard( this );
581 return m_pParent
->getCharSetControl()->GetRowPos(m_pParent
->getCharSetControl()->GetSelectIndexId()) == nRow
;
583 // -----------------------------------------------------------------------------
584 sal_Bool SAL_CALL
SvxShowCharSetAcc::isAccessibleColumnSelected( sal_Int32 nColumn
) throw (IndexOutOfBoundsException
, RuntimeException
)
586 OExternalLockGuard
aGuard( this );
588 return m_pParent
->getCharSetControl()->GetColumnPos(m_pParent
->getCharSetControl()->GetSelectIndexId()) == nColumn
;
590 // -----------------------------------------------------------------------------
591 Reference
< XAccessible
> SAL_CALL
SvxShowCharSetAcc::getAccessibleCellAt( sal_Int32 nRow
, sal_Int32 nColumn
) throw (IndexOutOfBoundsException
, RuntimeException
)
593 OExternalLockGuard
aGuard( this );
595 ::svx::SvxShowCharSetItem
* pItem
= m_pParent
->getCharSetControl()->ImplGetItem(
596 sal::static_int_cast
<USHORT
>(getAccessibleIndex(nRow
,nColumn
) ));
598 throw IndexOutOfBoundsException();
599 return pItem
->GetAccessible();
601 // -----------------------------------------------------------------------------
602 Reference
< XAccessible
> SAL_CALL
SvxShowCharSetAcc::getAccessibleCaption( ) throw (RuntimeException
)
604 return Reference
< XAccessible
>();
606 // -----------------------------------------------------------------------------
607 Reference
< XAccessible
> SAL_CALL
SvxShowCharSetAcc::getAccessibleSummary( ) throw (RuntimeException
)
609 return Reference
< XAccessible
>();
611 // -----------------------------------------------------------------------------
612 sal_Bool SAL_CALL
SvxShowCharSetAcc::isAccessibleSelected( sal_Int32 nRow
, sal_Int32 nColumn
) throw (IndexOutOfBoundsException
, RuntimeException
)
614 OExternalLockGuard
aGuard( this );
616 return m_pParent
->getCharSetControl()->GetSelectIndexId() == getAccessibleIndex(nRow
,nColumn
);
618 // -----------------------------------------------------------------------------
619 sal_Int32 SAL_CALL
SvxShowCharSetAcc::getAccessibleIndex( sal_Int32 nRow
, sal_Int32 nColumn
) throw (IndexOutOfBoundsException
, RuntimeException
)
621 return (nRow
*COLUMN_COUNT
) + nColumn
;
623 // -----------------------------------------------------------------------------
624 sal_Int32 SAL_CALL
SvxShowCharSetAcc::getAccessibleRow( sal_Int32 nChildIndex
) throw (IndexOutOfBoundsException
, RuntimeException
)
626 OExternalLockGuard
aGuard( this );
628 return m_pParent
->getCharSetControl()->GetRowPos(sal::static_int_cast
<USHORT
>(nChildIndex
));
630 // -----------------------------------------------------------------------------
631 sal_Int32 SAL_CALL
SvxShowCharSetAcc::getAccessibleColumn( sal_Int32 nChildIndex
) throw (IndexOutOfBoundsException
, RuntimeException
)
633 OExternalLockGuard
aGuard( this );
635 return m_pParent
->getCharSetControl()->GetColumnPos(sal::static_int_cast
<USHORT
>(nChildIndex
));
637 // -----------------------------------------------------------------------------
639 // -----------------------------------------------------------------------------
641 // - SvxShowCharSetItemAcc -
644 SvxShowCharSetItemAcc::SvxShowCharSetItemAcc( SvxShowCharSetItem
* pParent
) : OAccessibleComponentHelper(new VCLExternalSolarLock())
647 OSL_ENSURE(pParent
,"NO parent supplied!");
648 osl_incrementInterlockedCount(&m_refCount
);
652 osl_decrementInterlockedCount(&m_refCount
);
655 // -----------------------------------------------------------------------------
657 SvxShowCharSetItemAcc::~SvxShowCharSetItemAcc()
660 delete getExternalLock();
662 // -----------------------------------------------------------------------------
663 IMPLEMENT_FORWARD_XINTERFACE2( SvxShowCharSetItemAcc
, OAccessibleComponentHelper
, OAccessibleHelper_Base_2
)
664 IMPLEMENT_FORWARD_XTYPEPROVIDER2( SvxShowCharSetItemAcc
, OAccessibleComponentHelper
, OAccessibleHelper_Base_2
)
665 // -----------------------------------------------------------------------------
667 void SvxShowCharSetItemAcc::ParentDestroyed()
669 const ::osl::MutexGuard
aGuard( GetMutex() );
673 // -----------------------------------------------------------------------------
675 sal_Int32 SAL_CALL
SvxShowCharSetItemAcc::getAccessibleChildCount()
676 throw (uno::RuntimeException
)
681 // -----------------------------------------------------------------------------
683 uno::Reference
< accessibility::XAccessible
> SAL_CALL
SvxShowCharSetItemAcc::getAccessibleChild( sal_Int32
/*i*/ )
684 throw (lang::IndexOutOfBoundsException
, uno::RuntimeException
)
686 throw lang::IndexOutOfBoundsException();
689 // -----------------------------------------------------------------------------
691 uno::Reference
< accessibility::XAccessible
> SAL_CALL
SvxShowCharSetItemAcc::getAccessibleParent()
692 throw (uno::RuntimeException
)
694 OExternalLockGuard
aGuard( this );
696 return mpParent
->m_pParent
;
699 // -----------------------------------------------------------------------------
701 sal_Int16 SAL_CALL
SvxShowCharSetItemAcc::getAccessibleRole()
702 throw (uno::RuntimeException
)
704 return accessibility::AccessibleRole::LABEL
;
707 // -----------------------------------------------------------------------------
709 ::rtl::OUString SAL_CALL
SvxShowCharSetItemAcc::getAccessibleDescription()
710 throw (uno::RuntimeException
)
712 OExternalLockGuard
aGuard( this );
714 String sDescription
= SVX_RESSTR( RID_SVXSTR_CHARACTER_CODE
);
716 sal_Unicode c
= mpParent
->maText
.GetChar(0);
717 char buf
[16] = "0x0000";
718 sal_Unicode c_Shifted
= c
;
719 for( int i
= 0; i
< 4; ++i
)
721 char h
= (char)(c_Shifted
& 0x0F);
722 buf
[5-i
] = (h
> 9) ? (h
- 10 + 'A') : (h
+ '0');
726 snprintf( buf
+6, 10, " (%d)", c
);
727 sDescription
.AppendAscii(buf
);
732 // -----------------------------------------------------------------------------
734 ::rtl::OUString SAL_CALL
SvxShowCharSetItemAcc::getAccessibleName()
735 throw (uno::RuntimeException
)
737 OExternalLockGuard
aGuard( this );
743 aRet
= mpParent
->maText
;
746 aRet
= getAccessibleDescription();
752 // -----------------------------------------------------------------------------
754 uno::Reference
< accessibility::XAccessibleRelationSet
> SAL_CALL
SvxShowCharSetItemAcc::getAccessibleRelationSet()
755 throw (uno::RuntimeException
)
757 return uno::Reference
< accessibility::XAccessibleRelationSet
>();
760 // -----------------------------------------------------------------------------
762 uno::Reference
< accessibility::XAccessibleStateSet
> SAL_CALL
SvxShowCharSetItemAcc::getAccessibleStateSet()
763 throw (uno::RuntimeException
)
765 OExternalLockGuard
aGuard( this );
768 ::utl::AccessibleStateSetHelper
* pStateSet
= new ::utl::AccessibleStateSetHelper
;
773 pStateSet
->AddState( accessibility::AccessibleStateType::SELECTABLE
);
774 pStateSet
->AddState( accessibility::AccessibleStateType::FOCUSABLE
);
777 if( mpParent
->mrParent
.GetSelectIndexId() == mpParent
->mnId
)
779 pStateSet
->AddState( accessibility::AccessibleStateType::SELECTED
);
780 pStateSet
->AddState( accessibility::AccessibleStateType::FOCUSED
);
782 if ( mpParent
->mnId
>= mpParent
->mrParent
.FirstInView() && mpParent
->mnId
<= mpParent
->mrParent
.LastInView() )
783 pStateSet
->AddState( AccessibleStateType::VISIBLE
);
784 pStateSet
->AddState( AccessibleStateType::TRANSIENT
);
790 // -----------------------------------------------------------------------------
791 void SAL_CALL
SvxShowCharSetItemAcc::grabFocus()
792 throw (uno::RuntimeException
)
797 // -----------------------------------------------------------------------------
799 uno::Any SAL_CALL
SvxShowCharSetItemAcc::getAccessibleKeyBinding()
800 throw (uno::RuntimeException
)
804 // -----------------------------------------------------------------------------
805 awt::Rectangle SAL_CALL
SvxShowCharSetItemAcc::implGetBounds( ) throw (RuntimeException
)
811 Rectangle
aRect( mpParent
->maRect
);
813 Rectangle
aParentRect( aOrigin
, mpParent
->mrParent
.GetOutputSizePixel() );
815 aRect
.Intersection( aParentRect
);
817 aRet
.X
= aRect
.Left();
818 aRet
.Y
= aRect
.Top();
819 aRet
.Width
= aRect
.GetWidth();
820 aRet
.Height
= aRect
.GetHeight();
825 // -----------------------------------------------------------------------------
826 uno::Reference
< accessibility::XAccessible
> SAL_CALL
SvxShowCharSetItemAcc::getAccessibleAtPoint( const awt::Point
& /*aPoint*/ )
827 throw (uno::RuntimeException
)
829 return uno::Reference
< accessibility::XAccessible
>();
831 // -----------------------------------------------------------------------------
832 sal_Int32 SAL_CALL
SvxShowCharSetVirtualAcc::getForeground( ) throw (RuntimeException
)
834 OExternalLockGuard
aGuard( this );
836 sal_Int32 nColor
= 0;
839 if ( mpParent
->IsControlForeground() )
840 nColor
= mpParent
->GetControlForeground().GetColor();
844 if ( mpParent
->IsControlFont() )
845 aFont
= mpParent
->GetControlFont();
847 aFont
= mpParent
->GetFont();
848 nColor
= aFont
.GetColor().GetColor();
854 // -----------------------------------------------------------------------------
855 sal_Int32 SAL_CALL
SvxShowCharSetVirtualAcc::getBackground( ) throw (RuntimeException
)
857 OExternalLockGuard
aGuard( this );
858 sal_Int32 nColor
= 0;
861 if ( mpParent
->IsControlBackground() )
862 nColor
= mpParent
->GetControlBackground().GetColor();
864 nColor
= mpParent
->GetBackground().GetColor().GetColor();
869 // -----------------------------------------------------------------------------
870 sal_Int32 SAL_CALL
SvxShowCharSetAcc::getForeground( ) throw (RuntimeException
)
872 OExternalLockGuard
aGuard( this );
874 sal_Int32 nColor
= 0;
876 nColor
= m_pParent
->getForeground();
879 // -----------------------------------------------------------------------------
880 sal_Int32 SAL_CALL
SvxShowCharSetAcc::getBackground( ) throw (RuntimeException
)
882 OExternalLockGuard
aGuard( this );
883 sal_Int32 nColor
= 0;
885 nColor
= m_pParent
->getBackground();
888 // -----------------------------------------------------------------------------
890 // -----------------------------------------------------------------------------
892 // -----------------------------------------------------------------------------