update dev300-m58
[ooovba.git] / svx / source / accessibility / charmapacc.cxx
blobfac109fc9cff98d9931d40d3183f9dac0f13de3f
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: charmapacc.cxx,v $
10 * $Revision: 1.15 $
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>
37 #include <stdio.h>
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>
49 namespace svx
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;
57 // ----------------
58 // - SvxShowCharSetVirtualAcc -
59 // ----------------
60 SvxShowCharSetVirtualAcc::SvxShowCharSetVirtualAcc( SvxShowCharSet* pParent ) : OAccessibleComponentHelper(new VCLExternalSolarLock())
61 ,mpParent( pParent )
62 ,m_pTable(NULL)
64 osl_incrementInterlockedCount(&m_refCount);
65 { // #b6211265 #
66 lateInit(this);
68 osl_decrementInterlockedCount(&m_refCount);
71 // -----------------------------------------------------------------------------
73 SvxShowCharSetVirtualAcc::~SvxShowCharSetVirtualAcc()
75 ensureDisposed();
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
88 if ( m_pTable )
89 m_pTable->fireEvent(_nEventId,_rOldValue,_rNewValue);
91 // -----------------------------------------------------------------------------
92 sal_Int32 SAL_CALL SvxShowCharSetVirtualAcc::getAccessibleChildCount( ) throw (RuntimeException)
94 OExternalLockGuard aGuard( this );
95 ensureAlive();
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 );
103 ensureAlive();
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 )
110 if ( !m_pTable )
111 m_pTable = new SvxShowCharSetAcc(this);
112 xRet = m_pTable;
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();
123 return xRet;
125 // -----------------------------------------------------------------------------
126 uno::Any SAL_CALL SvxShowCharSetVirtualAcc::getAccessibleKeyBinding()
127 throw (uno::RuntimeException)
129 return uno::Any();
131 // -----------------------------------------------------------------------------
132 void SAL_CALL SvxShowCharSetVirtualAcc::grabFocus()
133 throw (uno::RuntimeException)
135 OExternalLockGuard aGuard( this );
136 ensureAlive();
137 mpParent->GrabFocus();
141 // -----------------------------------------------------------------------------
142 Reference< XAccessible > SAL_CALL SvxShowCharSetVirtualAcc::getAccessibleChild( sal_Int32 i ) throw (IndexOutOfBoundsException, RuntimeException)
144 OExternalLockGuard aGuard( this );
145 ensureAlive();
146 if ( mpParent->getScrollBar()->IsVisible() && i == 0 )
147 return mpParent->getScrollBar()->GetAccessible();
148 else if ( i == 1 )
150 if ( !m_xAcc.is() )
152 m_pTable = new SvxShowCharSetAcc(this);
153 m_xAcc = m_pTable;
156 else
157 throw IndexOutOfBoundsException();
158 return m_xAcc;
160 // -----------------------------------------------------------------------------
161 Reference< XAccessible > SAL_CALL SvxShowCharSetVirtualAcc::getAccessibleParent( ) throw (RuntimeException)
163 OExternalLockGuard aGuard( this );
164 ensureAlive();
165 Window* pParent = mpParent->GetParent();
166 uno::Reference< accessibility::XAccessible > xRet;
168 if ( pParent )
169 xRet = pParent->GetAccessible();
171 return xRet;
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();
185 awt::Rectangle aRet;
187 aRet.X = aOutPos.X();
188 aRet.Y = aOutPos.Y();
189 aRet.Width = aOutSize.Width();
190 aRet.Height = aOutSize.Height();
192 return aRet;
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;
223 if( mpParent )
225 // SELECTABLE
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 );
240 return pStateSet;
242 // -----------------------------------------------------------------------------
243 void SAL_CALL SvxShowCharSetVirtualAcc::disposing()
245 OAccessibleContextHelper::disposing();
246 if ( m_pTable )
247 m_pTable->dispose();
248 m_pTable = NULL;
250 // -----------------------------------------------------------------------------
251 // ----------------
252 // - SvxShowCharSetItem -
253 // ----------------
255 SvxShowCharSetItem::SvxShowCharSetItem( SvxShowCharSet& rParent,SvxShowCharSetAcc* _pParent,USHORT _nPos ) :
256 mrParent( rParent )
257 ,mnId( _nPos )
258 ,m_pItem(NULL)
259 ,m_pParent(_pParent)
262 // -----------------------------------------------------------------------
264 SvxShowCharSetItem::~SvxShowCharSetItem()
266 if ( m_xAcc.is() )
268 m_pItem->ParentDestroyed();
269 ClearAccessible();
273 // -----------------------------------------------------------------------
275 uno::Reference< accessibility::XAccessible > SvxShowCharSetItem::GetAccessible()
277 if( !m_xAcc.is() )
279 m_pItem = new SvxShowCharSetItemAcc( this );
280 m_xAcc = m_pItem;
283 return m_xAcc;
286 // -----------------------------------------------------------------------
288 void SvxShowCharSetItem::ClearAccessible()
290 if ( m_xAcc.is() )
292 m_pItem = NULL;
293 m_xAcc = NULL;
298 // ---------------
299 // - SvxShowCharSetAcc -
300 // ---------------
302 SvxShowCharSetAcc::SvxShowCharSetAcc( SvxShowCharSetVirtualAcc* _pParent ) : OAccessibleSelectionHelper(new VCLExternalSolarLock())
303 ,m_pParent( _pParent )
305 osl_incrementInterlockedCount(&m_refCount);
306 { // #b6211265 #
307 lateInit(this);
309 osl_decrementInterlockedCount(&m_refCount);
312 // -----------------------------------------------------------------------------
314 SvxShowCharSetAcc::~SvxShowCharSetAcc()
316 ensureDisposed();
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);
328 m_aChildren.clear();
329 m_pParent = NULL;
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)
345 if ( m_pParent )
347 if ( bSelect )
348 m_pParent->getCharSetControl()->SelectIndex(nAccessibleChildIndex,sal_True);
349 else
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();
365 awt::Rectangle aRet;
367 aRet.X = aOutPos.X();
368 aRet.Y = aOutPos.Y();
369 aRet.Width = aOutSize.Width();
370 aRet.Height = aOutSize.Height();
372 return aRet;
374 // -----------------------------------------------------------------------------
375 sal_Int32 SAL_CALL SvxShowCharSetAcc::getAccessibleChildCount()
376 throw (uno::RuntimeException)
378 OExternalLockGuard aGuard( this );
379 ensureAlive();
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 );
389 ensureAlive();
390 uno::Reference< accessibility::XAccessible > xRet;
391 SvxShowCharSetItem* pItem = m_pParent->getCharSetControl()->ImplGetItem( static_cast< USHORT >( i ) );
393 if( pItem )
395 pItem->m_pParent = this;
396 xRet = pItem->GetAccessible();
397 m_aChildren.push_back(xRet);
399 else
400 throw lang::IndexOutOfBoundsException();
402 return xRet;
405 // -----------------------------------------------------------------------------
407 uno::Reference< accessibility::XAccessible > SAL_CALL SvxShowCharSetAcc::getAccessibleParent()
408 throw (uno::RuntimeException)
410 OExternalLockGuard aGuard( this );
411 ensureAlive();
412 return m_pParent;
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 );
438 ensureAlive();
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() )
461 // SELECTABLE
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 );
478 return pStateSet;
480 // -----------------------------------------------------------------------------
482 uno::Reference< accessibility::XAccessible > SAL_CALL SvxShowCharSetAcc::getAccessibleAtPoint( const awt::Point& aPoint )
483 throw (uno::RuntimeException)
485 OExternalLockGuard aGuard( this );
486 ensureAlive();
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();
497 return xRet;
500 // -----------------------------------------------------------------------------
501 // -----------------------------------------------------------------------------
503 void SAL_CALL SvxShowCharSetAcc::grabFocus()
504 throw (uno::RuntimeException)
506 OExternalLockGuard aGuard( this );
507 ensureAlive();
508 m_pParent->getCharSetControl()->GrabFocus();
511 // -----------------------------------------------------------------------------
513 uno::Any SAL_CALL SvxShowCharSetAcc::getAccessibleKeyBinding()
514 throw (uno::RuntimeException)
516 return uno::Any();
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)
526 return COLUMN_COUNT;
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)
541 return 1;
543 // -----------------------------------------------------------------------------
544 sal_Int32 SAL_CALL SvxShowCharSetAcc::getAccessibleColumnExtentAt( sal_Int32 /*nRow*/, sal_Int32 /*nColumn*/ ) throw (IndexOutOfBoundsException, RuntimeException)
546 return 1;
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 );
562 ensureAlive();
563 Sequence< sal_Int32 > aSel(1);
564 aSel[0] = m_pParent->getCharSetControl()->GetRowPos(m_pParent->getCharSetControl()->GetSelectIndexId());
565 return aSel;
567 // -----------------------------------------------------------------------------
568 Sequence< sal_Int32 > SAL_CALL SvxShowCharSetAcc::getSelectedAccessibleColumns( ) throw (RuntimeException)
570 OExternalLockGuard aGuard( this );
571 ensureAlive();
572 Sequence< sal_Int32 > aSel(1);
573 aSel[0] = m_pParent->getCharSetControl()->GetColumnPos(m_pParent->getCharSetControl()->GetSelectIndexId());
574 return aSel;
576 // -----------------------------------------------------------------------------
577 sal_Bool SAL_CALL SvxShowCharSetAcc::isAccessibleRowSelected( sal_Int32 nRow ) throw (IndexOutOfBoundsException, RuntimeException)
579 OExternalLockGuard aGuard( this );
580 ensureAlive();
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 );
587 ensureAlive();
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 );
594 ensureAlive();
595 ::svx::SvxShowCharSetItem* pItem = m_pParent->getCharSetControl()->ImplGetItem(
596 sal::static_int_cast<USHORT>(getAccessibleIndex(nRow,nColumn) ));
597 if ( !pItem )
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 );
615 ensureAlive();
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 );
627 ensureAlive();
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 );
634 ensureAlive();
635 return m_pParent->getCharSetControl()->GetColumnPos(sal::static_int_cast<USHORT>(nChildIndex));
637 // -----------------------------------------------------------------------------
639 // -----------------------------------------------------------------------------
640 // ----------------
641 // - SvxShowCharSetItemAcc -
642 // ----------------
644 SvxShowCharSetItemAcc::SvxShowCharSetItemAcc( SvxShowCharSetItem* pParent ) : OAccessibleComponentHelper(new VCLExternalSolarLock())
645 ,mpParent( pParent )
647 OSL_ENSURE(pParent,"NO parent supplied!");
648 osl_incrementInterlockedCount(&m_refCount);
649 { // #b6211265 #
650 lateInit(this);
652 osl_decrementInterlockedCount(&m_refCount);
655 // -----------------------------------------------------------------------------
657 SvxShowCharSetItemAcc::~SvxShowCharSetItemAcc()
659 ensureDisposed();
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() );
670 mpParent = NULL;
673 // -----------------------------------------------------------------------------
675 sal_Int32 SAL_CALL SvxShowCharSetItemAcc::getAccessibleChildCount()
676 throw (uno::RuntimeException)
678 return 0;
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 );
695 ensureAlive();
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 );
713 ensureAlive();
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');
723 c_Shifted >>= 4;
725 if( c < 256 )
726 snprintf( buf+6, 10, " (%d)", c );
727 sDescription.AppendAscii(buf);
729 return sDescription;
732 // -----------------------------------------------------------------------------
734 ::rtl::OUString SAL_CALL SvxShowCharSetItemAcc::getAccessibleName()
735 throw (uno::RuntimeException)
737 OExternalLockGuard aGuard( this );
738 ensureAlive();
739 String aRet;
741 if( mpParent )
743 aRet = mpParent->maText;
745 if( !aRet.Len() )
746 aRet = getAccessibleDescription();
749 return aRet;
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 );
766 ensureAlive();
768 ::utl::AccessibleStateSetHelper* pStateSet = new ::utl::AccessibleStateSetHelper;
770 if( mpParent )
772 // SELECTABLE
773 pStateSet->AddState( accessibility::AccessibleStateType::SELECTABLE );
774 pStateSet->AddState( accessibility::AccessibleStateType::FOCUSABLE );
776 // SELECTED
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 );
787 return pStateSet;
790 // -----------------------------------------------------------------------------
791 void SAL_CALL SvxShowCharSetItemAcc::grabFocus()
792 throw (uno::RuntimeException)
794 // nothing to do
797 // -----------------------------------------------------------------------------
799 uno::Any SAL_CALL SvxShowCharSetItemAcc::getAccessibleKeyBinding()
800 throw (uno::RuntimeException)
802 return uno::Any();
804 // -----------------------------------------------------------------------------
805 awt::Rectangle SAL_CALL SvxShowCharSetItemAcc::implGetBounds( ) throw (RuntimeException)
807 awt::Rectangle aRet;
809 if( mpParent )
811 Rectangle aRect( mpParent->maRect );
812 Point aOrigin;
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();
823 return aRet;
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;
837 if ( mpParent )
839 if ( mpParent->IsControlForeground() )
840 nColor = mpParent->GetControlForeground().GetColor();
841 else
843 Font aFont;
844 if ( mpParent->IsControlFont() )
845 aFont = mpParent->GetControlFont();
846 else
847 aFont = mpParent->GetFont();
848 nColor = aFont.GetColor().GetColor();
852 return nColor;
854 // -----------------------------------------------------------------------------
855 sal_Int32 SAL_CALL SvxShowCharSetVirtualAcc::getBackground( ) throw (RuntimeException)
857 OExternalLockGuard aGuard( this );
858 sal_Int32 nColor = 0;
859 if ( mpParent )
861 if ( mpParent->IsControlBackground() )
862 nColor = mpParent->GetControlBackground().GetColor();
863 else
864 nColor = mpParent->GetBackground().GetColor().GetColor();
867 return nColor;
869 // -----------------------------------------------------------------------------
870 sal_Int32 SAL_CALL SvxShowCharSetAcc::getForeground( ) throw (RuntimeException)
872 OExternalLockGuard aGuard( this );
874 sal_Int32 nColor = 0;
875 if ( m_pParent )
876 nColor = m_pParent->getForeground();
877 return nColor;
879 // -----------------------------------------------------------------------------
880 sal_Int32 SAL_CALL SvxShowCharSetAcc::getBackground( ) throw (RuntimeException)
882 OExternalLockGuard aGuard( this );
883 sal_Int32 nColor = 0;
884 if ( m_pParent )
885 nColor = m_pParent->getBackground();
886 return nColor;
888 // -----------------------------------------------------------------------------
890 // -----------------------------------------------------------------------------
891 } // namespace svx
892 // -----------------------------------------------------------------------------