bump product version to 5.0.4.1
[LibreOffice.git] / svx / source / accessibility / charmapacc.cxx
blob69aff5d6feb8857f181b0bcd08dffcee659ab9af
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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>
22 #include <stdio.h>
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>
34 namespace svx
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())
46 ,mpParent( pParent )
47 ,m_pTable(NULL)
49 osl_atomic_increment(&m_refCount);
51 lateInit(this);
53 osl_atomic_decrement(&m_refCount);
58 SvxShowCharSetVirtualAcc::~SvxShowCharSetVirtualAcc()
60 ensureDisposed();
61 delete getExternalLock();
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
73 if ( m_pTable )
74 m_pTable->fireEvent(_nEventId,_rOldValue,_rNewValue);
77 sal_Int32 SAL_CALL SvxShowCharSetVirtualAcc::getAccessibleChildCount( ) throw (RuntimeException, std::exception)
79 OExternalLockGuard aGuard( this );
80 ensureAlive();
81 return ( mpParent->getScrollBar().IsVisible() ) ? 2 : 1;
84 uno::Reference< css::accessibility::XAccessible > SAL_CALL SvxShowCharSetVirtualAcc::getAccessibleAtPoint( const awt::Point& aPoint )
85 throw (uno::RuntimeException, std::exception)
87 OExternalLockGuard aGuard( this );
88 ensureAlive();
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 )
95 if ( !m_pTable )
96 m_pTable = new SvxShowCharSetAcc(this);
97 xRet = m_pTable;
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();
108 return xRet;
111 void SAL_CALL SvxShowCharSetVirtualAcc::grabFocus()
112 throw (uno::RuntimeException, std::exception)
114 OExternalLockGuard aGuard( this );
115 ensureAlive();
116 mpParent->GrabFocus();
119 Reference< XAccessible > SAL_CALL SvxShowCharSetVirtualAcc::getAccessibleChild( sal_Int32 i ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
121 OExternalLockGuard aGuard( this );
122 ensureAlive();
123 if ( mpParent->getScrollBar().IsVisible() && i == 0 )
124 return mpParent->getScrollBar().GetAccessible();
125 else if ( i == 1 )
127 if ( !m_xAcc.is() )
129 m_pTable = new SvxShowCharSetAcc(this);
130 m_xAcc = m_pTable;
133 else
134 throw IndexOutOfBoundsException();
135 return m_xAcc;
138 Reference< XAccessible > SAL_CALL SvxShowCharSetVirtualAcc::getAccessibleParent( ) throw (RuntimeException, std::exception)
140 OExternalLockGuard aGuard( this );
141 ensureAlive();
142 vcl::Window* pParent = mpParent->GetParent();
143 uno::Reference< css::accessibility::XAccessible > xRet;
145 if ( pParent )
146 xRet = pParent->GetAccessible();
148 return xRet;
151 ::com::sun::star::awt::Rectangle SvxShowCharSetVirtualAcc::implGetBounds( ) throw (RuntimeException)
153 ::com::sun::star::awt::Rectangle aBounds ( 0, 0, 0, 0 );
154 vcl::Window* pWindow = mpParent;
155 if ( pWindow )
157 Rectangle aRect = pWindow->GetWindowExtentsRelative( NULL );
158 aBounds = AWTRectangle( aRect );
159 vcl::Window* pParent = pWindow->GetAccessibleParentWindow();
160 if ( pParent )
162 Rectangle aParentRect = pParent->GetWindowExtentsRelative( NULL );
163 ::com::sun::star::awt::Point aParentScreenLoc = AWTPoint( aParentRect.TopLeft() );
164 aBounds.X -= aParentScreenLoc.X;
165 aBounds.Y -= aParentScreenLoc.Y;
168 return aBounds;
171 sal_Int16 SAL_CALL SvxShowCharSetVirtualAcc::getAccessibleRole( ) throw (RuntimeException, std::exception)
173 return css::accessibility::AccessibleRole::SCROLL_PANE;
176 OUString SAL_CALL SvxShowCharSetVirtualAcc::getAccessibleDescription( ) throw (RuntimeException, std::exception)
178 OExternalLockGuard aGuard( this );
179 return SVX_RESSTR( RID_SVXSTR_CHARACTER_SELECTION);
182 OUString SAL_CALL SvxShowCharSetVirtualAcc::getAccessibleName( ) throw (RuntimeException, std::exception)
184 OExternalLockGuard aGuard( this );
185 return SVX_RESSTR( RID_SVXSTR_CHAR_SEL_DESC);
188 Reference< XAccessibleRelationSet > SAL_CALL SvxShowCharSetVirtualAcc::getAccessibleRelationSet( ) throw (RuntimeException, std::exception)
190 return Reference< XAccessibleRelationSet >();
193 Reference< XAccessibleStateSet > SAL_CALL SvxShowCharSetVirtualAcc::getAccessibleStateSet( ) throw (RuntimeException, std::exception)
195 OExternalLockGuard aGuard( this );
197 ::utl::AccessibleStateSetHelper* pStateSet = new ::utl::AccessibleStateSetHelper;
199 if( mpParent )
201 // SELECTABLE
202 pStateSet->AddState( AccessibleStateType::FOCUSABLE );
203 if ( mpParent->HasFocus() )
204 pStateSet->AddState( AccessibleStateType::FOCUSED );
205 if ( mpParent->IsActive() )
206 pStateSet->AddState( AccessibleStateType::ACTIVE );
207 if ( mpParent->IsEnabled() )
209 pStateSet->AddState( AccessibleStateType::ENABLED );
210 pStateSet->AddState( AccessibleStateType::SENSITIVE );
212 if ( mpParent->IsReallyVisible() )
213 pStateSet->AddState( AccessibleStateType::VISIBLE );
216 return pStateSet;
219 void SAL_CALL SvxShowCharSetVirtualAcc::disposing()
221 OAccessibleContextHelper::disposing();
222 if ( m_pTable )
223 m_pTable->dispose();
224 m_pTable = NULL;
228 // - SvxShowCharSetItem -
231 SvxShowCharSetItem::SvxShowCharSetItem( SvxShowCharSet& rParent,SvxShowCharSetAcc* _pParent,sal_uInt16 _nPos ) :
232 mrParent( rParent )
233 ,mnId( _nPos )
234 ,m_pItem(NULL)
235 ,m_pParent(_pParent)
240 SvxShowCharSetItem::~SvxShowCharSetItem()
242 if ( m_xAcc.is() )
244 m_pItem->ParentDestroyed();
245 ClearAccessible();
251 uno::Reference< css::accessibility::XAccessible > SvxShowCharSetItem::GetAccessible()
253 if( !m_xAcc.is() )
255 m_pItem = new SvxShowCharSetItemAcc( this );
256 m_xAcc = m_pItem;
259 return m_xAcc;
264 void SvxShowCharSetItem::ClearAccessible()
266 if ( m_xAcc.is() )
268 m_pItem = NULL;
269 m_xAcc = NULL;
275 // - SvxShowCharSetAcc -
278 SvxShowCharSetAcc::SvxShowCharSetAcc( SvxShowCharSetVirtualAcc* _pParent ) : OAccessibleSelectionHelper(new VCLExternalSolarLock())
279 ,m_pParent( _pParent )
281 osl_atomic_increment(&m_refCount);
283 lateInit(this);
285 osl_atomic_decrement(&m_refCount);
290 SvxShowCharSetAcc::~SvxShowCharSetAcc()
292 ensureDisposed();
293 delete getExternalLock();
296 void SAL_CALL SvxShowCharSetAcc::disposing()
298 OAccessibleSelectionHelper::disposing();
299 ::std::vector< Reference< XAccessible > >::iterator aIter = m_aChildren.begin();
300 ::std::vector< Reference< XAccessible > >::iterator aEnd = m_aChildren.end();
301 for (;aIter != aEnd ; ++aIter)
302 ::comphelper::disposeComponent(*aIter);
304 m_aChildren.clear();
305 m_pParent = NULL;
309 IMPLEMENT_FORWARD_XINTERFACE2( SvxShowCharSetAcc, OAccessibleSelectionHelper, OAccessibleHelper_Base )
310 IMPLEMENT_FORWARD_XTYPEPROVIDER2( SvxShowCharSetAcc, OAccessibleSelectionHelper, OAccessibleHelper_Base )
312 bool SvxShowCharSetAcc::implIsSelected( sal_Int32 nAccessibleChildIndex ) throw (RuntimeException)
314 return m_pParent && m_pParent->getCharSetControl()->IsSelected(
315 sal::static_int_cast<sal_uInt16>(nAccessibleChildIndex));
318 // select the specified child => watch for special ChildIndexes (ACCESSIBLE_SELECTION_CHILD_xxx)
319 void SvxShowCharSetAcc::implSelect(sal_Int32 nAccessibleChildIndex, bool bSelect)
320 throw (IndexOutOfBoundsException, RuntimeException, std::exception)
322 if ( m_pParent )
324 if ( bSelect )
325 m_pParent->getCharSetControl()->SelectIndex(nAccessibleChildIndex, true);
326 else
327 m_pParent->getCharSetControl()->DeSelect();
331 ::com::sun::star::awt::Rectangle SvxShowCharSetAcc::implGetBounds( ) throw (RuntimeException)
333 const Point aOutPos;//( m_pParent->getCharSetControl()->GetPosPixel() );
334 Size aOutSize( m_pParent->getCharSetControl()->GetOutputSizePixel());
335 if ( m_pParent->getCharSetControl()->getScrollBar().IsVisible() )
337 const Size aScrollBar = m_pParent->getCharSetControl()->getScrollBar().GetOutputSizePixel();
338 aOutSize.Width() -= aScrollBar.Width();
341 awt::Rectangle aRet;
343 aRet.X = aOutPos.X();
344 aRet.Y = aOutPos.Y();
345 aRet.Width = aOutSize.Width();
346 aRet.Height = aOutSize.Height();
348 return aRet;
351 sal_Int32 SAL_CALL SvxShowCharSetAcc::getAccessibleChildCount()
352 throw (uno::RuntimeException, std::exception)
354 OExternalLockGuard aGuard( this );
355 ensureAlive();
356 return m_pParent->getCharSetControl()->getMaxCharCount();
361 uno::Reference< css::accessibility::XAccessible > SAL_CALL SvxShowCharSetAcc::getAccessibleChild( sal_Int32 i )
362 throw (lang::IndexOutOfBoundsException, uno::RuntimeException, std::exception)
364 OExternalLockGuard aGuard( this );
365 ensureAlive();
366 uno::Reference< css::accessibility::XAccessible > xRet;
367 SvxShowCharSetItem* pItem = m_pParent->getCharSetControl()->ImplGetItem( static_cast< sal_uInt16 >( i ) );
369 if( pItem )
371 pItem->m_pParent = this;
372 xRet = pItem->GetAccessible();
373 m_aChildren.push_back(xRet);
375 else
376 throw lang::IndexOutOfBoundsException();
378 return xRet;
383 uno::Reference< css::accessibility::XAccessible > SAL_CALL SvxShowCharSetAcc::getAccessibleParent()
384 throw (uno::RuntimeException, std::exception)
386 OExternalLockGuard aGuard( this );
387 ensureAlive();
388 return m_pParent;
393 sal_Int16 SAL_CALL SvxShowCharSetAcc::getAccessibleRole()
394 throw (uno::RuntimeException, std::exception)
396 return css::accessibility::AccessibleRole::TABLE;
401 OUString SAL_CALL SvxShowCharSetAcc::getAccessibleDescription()
402 throw (uno::RuntimeException, std::exception)
404 OExternalLockGuard aGuard( this );
405 return SVX_RESSTR( RID_SVXSTR_CHARACTER_SELECTION );
410 OUString SAL_CALL SvxShowCharSetAcc::getAccessibleName()
411 throw (uno::RuntimeException, std::exception)
413 OExternalLockGuard aGuard( this );
414 ensureAlive();
415 return SVX_RESSTR( RID_SVXSTR_CHAR_SEL_DESC );
420 uno::Reference< css::accessibility::XAccessibleRelationSet > SAL_CALL SvxShowCharSetAcc::getAccessibleRelationSet()
421 throw (uno::RuntimeException, std::exception)
423 return uno::Reference< css::accessibility::XAccessibleRelationSet >();
428 uno::Reference< css::accessibility::XAccessibleStateSet > SAL_CALL SvxShowCharSetAcc::getAccessibleStateSet()
429 throw (uno::RuntimeException, std::exception)
431 OExternalLockGuard aGuard( this );
433 ::utl::AccessibleStateSetHelper* pStateSet = new ::utl::AccessibleStateSetHelper;
435 if( m_pParent->getCharSetControl() )
437 // SELECTABLE
438 pStateSet->AddState( AccessibleStateType::FOCUSABLE );
439 if ( m_pParent->getCharSetControl()->HasFocus() )
440 pStateSet->AddState( AccessibleStateType::FOCUSED );
441 if ( m_pParent->getCharSetControl()->IsActive() )
442 pStateSet->AddState( AccessibleStateType::ACTIVE );
443 if ( m_pParent->getCharSetControl()->IsEnabled() )
445 pStateSet->AddState( AccessibleStateType::ENABLED );
446 pStateSet->AddState( AccessibleStateType::SENSITIVE );
448 if ( m_pParent->getCharSetControl()->IsReallyVisible() )
449 pStateSet->AddState( AccessibleStateType::VISIBLE );
451 pStateSet->AddState( AccessibleStateType::MANAGES_DESCENDANTS );
454 return pStateSet;
458 uno::Reference< css::accessibility::XAccessible > SAL_CALL SvxShowCharSetAcc::getAccessibleAtPoint( const awt::Point& aPoint )
459 throw (uno::RuntimeException, std::exception)
461 OExternalLockGuard aGuard( this );
462 ensureAlive();
464 uno::Reference< css::accessibility::XAccessible > xRet;
465 const sal_uInt16 nItemId = sal::static_int_cast<sal_uInt16>(
466 m_pParent->getCharSetControl()->PixelToMapIndex( Point( aPoint.X, aPoint.Y ) ));
468 if( sal_uInt16(-1) != nItemId )
470 SvxShowCharSetItem* pItem = m_pParent->getCharSetControl()->ImplGetItem( nItemId );
471 xRet = pItem->GetAccessible();
473 return xRet;
476 void SAL_CALL SvxShowCharSetAcc::grabFocus()
477 throw (uno::RuntimeException, std::exception)
479 OExternalLockGuard aGuard( this );
480 ensureAlive();
481 m_pParent->getCharSetControl()->GrabFocus();
484 sal_Int32 SAL_CALL SvxShowCharSetAcc::getAccessibleRowCount( ) throw (RuntimeException, std::exception)
486 return ((getAccessibleChildCount()-1) / COLUMN_COUNT) + 1;
489 sal_Int32 SAL_CALL SvxShowCharSetAcc::getAccessibleColumnCount( ) throw (RuntimeException, std::exception)
491 return COLUMN_COUNT;
494 OUString SAL_CALL SvxShowCharSetAcc::getAccessibleRowDescription( sal_Int32 /*nRow*/ ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
496 return OUString();
499 OUString SAL_CALL SvxShowCharSetAcc::getAccessibleColumnDescription( sal_Int32 /*nColumn*/ ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
501 return OUString();
504 sal_Int32 SAL_CALL SvxShowCharSetAcc::getAccessibleRowExtentAt( sal_Int32 /*nRow*/, sal_Int32 /*nColumn*/ ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
506 return 1;
509 sal_Int32 SAL_CALL SvxShowCharSetAcc::getAccessibleColumnExtentAt( sal_Int32 /*nRow*/, sal_Int32 /*nColumn*/ ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
511 return 1;
514 Reference< XAccessibleTable > SAL_CALL SvxShowCharSetAcc::getAccessibleRowHeaders( ) throw (RuntimeException, std::exception)
516 return Reference< XAccessibleTable >();
519 Reference< XAccessibleTable > SAL_CALL SvxShowCharSetAcc::getAccessibleColumnHeaders( ) throw (RuntimeException, std::exception)
521 return Reference< XAccessibleTable >();
524 Sequence< sal_Int32 > SAL_CALL SvxShowCharSetAcc::getSelectedAccessibleRows( ) throw (RuntimeException, std::exception)
526 OExternalLockGuard aGuard( this );
527 ensureAlive();
528 Sequence< sal_Int32 > aSel(1);
529 aSel[0] = SvxShowCharSet::GetRowPos(m_pParent->getCharSetControl()->GetSelectIndexId());
530 return aSel;
533 Sequence< sal_Int32 > SAL_CALL SvxShowCharSetAcc::getSelectedAccessibleColumns( ) throw (RuntimeException, std::exception)
535 OExternalLockGuard aGuard( this );
536 ensureAlive();
537 Sequence< sal_Int32 > aSel(1);
538 aSel[0] = SvxShowCharSet::GetColumnPos(m_pParent->getCharSetControl()->GetSelectIndexId());
539 return aSel;
542 sal_Bool SAL_CALL SvxShowCharSetAcc::isAccessibleRowSelected( sal_Int32 nRow ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
544 OExternalLockGuard aGuard( this );
545 ensureAlive();
546 return SvxShowCharSet::GetRowPos(m_pParent->getCharSetControl()->GetSelectIndexId()) == nRow;
549 sal_Bool SAL_CALL SvxShowCharSetAcc::isAccessibleColumnSelected( sal_Int32 nColumn ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
551 OExternalLockGuard aGuard( this );
552 ensureAlive();
553 return SvxShowCharSet::GetColumnPos(m_pParent->getCharSetControl()->GetSelectIndexId()) == nColumn;
556 Reference< XAccessible > SAL_CALL SvxShowCharSetAcc::getAccessibleCellAt( sal_Int32 nRow, sal_Int32 nColumn ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
558 OExternalLockGuard aGuard( this );
559 ensureAlive();
560 svx::SvxShowCharSetItem* pItem = m_pParent->getCharSetControl()->ImplGetItem(
561 sal::static_int_cast<sal_uInt16>(getAccessibleIndex(nRow,nColumn) ));
562 if ( !pItem )
563 throw IndexOutOfBoundsException();
564 return pItem->GetAccessible();
567 Reference< XAccessible > SAL_CALL SvxShowCharSetAcc::getAccessibleCaption( ) throw (RuntimeException, std::exception)
569 return Reference< XAccessible >();
572 Reference< XAccessible > SAL_CALL SvxShowCharSetAcc::getAccessibleSummary( ) throw (RuntimeException, std::exception)
574 return Reference< XAccessible >();
577 sal_Bool SAL_CALL SvxShowCharSetAcc::isAccessibleSelected( sal_Int32 nRow, sal_Int32 nColumn ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
579 OExternalLockGuard aGuard( this );
580 ensureAlive();
581 return m_pParent->getCharSetControl()->GetSelectIndexId() == getAccessibleIndex(nRow,nColumn);
584 sal_Int32 SAL_CALL SvxShowCharSetAcc::getAccessibleIndex( sal_Int32 nRow, sal_Int32 nColumn ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
586 return (nRow*COLUMN_COUNT) + nColumn;
589 sal_Int32 SAL_CALL SvxShowCharSetAcc::getAccessibleRow( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
591 OExternalLockGuard aGuard( this );
592 ensureAlive();
593 return SvxShowCharSet::GetRowPos(sal::static_int_cast<sal_uInt16>(nChildIndex));
596 sal_Int32 SAL_CALL SvxShowCharSetAcc::getAccessibleColumn( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
598 OExternalLockGuard aGuard( this );
599 ensureAlive();
600 return SvxShowCharSet::GetColumnPos(sal::static_int_cast<sal_uInt16>(nChildIndex));
606 // - SvxShowCharSetItemAcc -
609 SvxShowCharSetItemAcc::SvxShowCharSetItemAcc( SvxShowCharSetItem* pParent ) : OAccessibleComponentHelper(new VCLExternalSolarLock())
610 ,mpParent( pParent )
612 OSL_ENSURE(pParent,"NO parent supplied!");
613 osl_atomic_increment(&m_refCount);
614 { // #b6211265 #
615 lateInit(this);
617 osl_atomic_decrement(&m_refCount);
622 SvxShowCharSetItemAcc::~SvxShowCharSetItemAcc()
624 ensureDisposed();
625 delete getExternalLock();
628 IMPLEMENT_FORWARD_XINTERFACE2( SvxShowCharSetItemAcc, OAccessibleComponentHelper, OAccessibleHelper_Base_2 )
629 IMPLEMENT_FORWARD_XTYPEPROVIDER2( SvxShowCharSetItemAcc, OAccessibleComponentHelper, OAccessibleHelper_Base_2 )
632 void SvxShowCharSetItemAcc::ParentDestroyed()
634 const ::osl::MutexGuard aGuard( GetMutex() );
635 mpParent = NULL;
640 sal_Int32 SAL_CALL SvxShowCharSetItemAcc::getAccessibleChildCount()
641 throw (uno::RuntimeException, std::exception)
643 return 0;
648 uno::Reference< css::accessibility::XAccessible > SAL_CALL SvxShowCharSetItemAcc::getAccessibleChild( sal_Int32 /*i*/ )
649 throw (lang::IndexOutOfBoundsException, uno::RuntimeException, std::exception)
651 throw lang::IndexOutOfBoundsException();
656 uno::Reference< css::accessibility::XAccessible > SAL_CALL SvxShowCharSetItemAcc::getAccessibleParent()
657 throw (uno::RuntimeException, std::exception)
659 OExternalLockGuard aGuard( this );
660 ensureAlive();
661 return mpParent->m_pParent;
666 sal_Int16 SAL_CALL SvxShowCharSetItemAcc::getAccessibleRole()
667 throw (uno::RuntimeException, std::exception)
669 return css::accessibility::AccessibleRole::TABLE_CELL;
674 OUString SAL_CALL SvxShowCharSetItemAcc::getAccessibleDescription()
675 throw (uno::RuntimeException, std::exception)
677 OExternalLockGuard aGuard( this );
678 ensureAlive();
679 OUString sDescription = SVX_RESSTR( RID_SVXSTR_CHARACTER_CODE );
681 const OUString aCharStr( mpParent->maText);
682 sal_Int32 nStrIndex = 0;
683 const sal_UCS4 c = aCharStr.iterateCodePoints( &nStrIndex );
684 const int tmp_len = (c < 0x10000) ? 4 : 6;
685 char buf[16] = "0x0000";
686 sal_UCS4 c_Shifted = c;
687 for( int i = 0; i < tmp_len; ++i )
689 char h = (char)(c_Shifted & 0x0F);
690 buf[tmp_len+1-i] = (h > 9) ? (h - 10 + 'A') : (h + '0');
691 c_Shifted >>= 4;
693 if( c < 256 )
694 snprintf( buf+6, 10, " (%" SAL_PRIuUINT32 ")", c );
695 sDescription += " " + OUString(buf, strlen(buf), RTL_TEXTENCODING_ASCII_US);
697 return sDescription;
702 OUString SAL_CALL SvxShowCharSetItemAcc::getAccessibleName()
703 throw (uno::RuntimeException, std::exception)
705 OExternalLockGuard aGuard( this );
706 ensureAlive();
707 OUString aRet;
709 if( mpParent )
711 aRet = mpParent->maText;
713 if (aRet.isEmpty())
714 aRet = getAccessibleDescription();
717 return aRet;
722 uno::Reference< css::accessibility::XAccessibleRelationSet > SAL_CALL SvxShowCharSetItemAcc::getAccessibleRelationSet()
723 throw (uno::RuntimeException, std::exception)
725 return uno::Reference< css::accessibility::XAccessibleRelationSet >();
730 uno::Reference< css::accessibility::XAccessibleStateSet > SAL_CALL SvxShowCharSetItemAcc::getAccessibleStateSet()
731 throw (uno::RuntimeException, std::exception)
733 OExternalLockGuard aGuard( this );
734 ensureAlive();
736 ::utl::AccessibleStateSetHelper* pStateSet = new ::utl::AccessibleStateSetHelper;
738 if( mpParent )
740 if (mpParent->mrParent.IsEnabled())
742 pStateSet->AddState( css::accessibility::AccessibleStateType::ENABLED );
743 // SELECTABLE
744 pStateSet->AddState( css::accessibility::AccessibleStateType::SELECTABLE );
745 pStateSet->AddState( css::accessibility::AccessibleStateType::FOCUSABLE );
748 // SELECTED
749 if( mpParent->mrParent.GetSelectIndexId() == mpParent->mnId )
751 pStateSet->AddState( css::accessibility::AccessibleStateType::SELECTED );
752 pStateSet->AddState( css::accessibility::AccessibleStateType::FOCUSED );
754 if ( mpParent->mnId >= mpParent->mrParent.FirstInView() && mpParent->mnId <= mpParent->mrParent.LastInView() )
756 pStateSet->AddState( AccessibleStateType::VISIBLE );
757 pStateSet->AddState( AccessibleStateType::SHOWING );
759 pStateSet->AddState( AccessibleStateType::TRANSIENT );
762 return pStateSet;
765 void SAL_CALL SvxShowCharSetItemAcc::grabFocus()
766 throw (uno::RuntimeException, std::exception)
768 // nothing to do
771 awt::Rectangle SvxShowCharSetItemAcc::implGetBounds( ) throw (RuntimeException)
773 awt::Rectangle aRet;
775 if( mpParent )
777 Rectangle aRect( mpParent->maRect );
778 Point aOrigin;
779 Rectangle aParentRect( aOrigin, mpParent->mrParent.GetOutputSizePixel() );
781 aRect.Intersection( aParentRect );
783 aRet.X = aRect.Left();
784 aRet.Y = aRect.Top();
785 aRet.Width = aRect.GetWidth();
786 aRet.Height = aRect.GetHeight();
789 return aRet;
792 uno::Reference< css::accessibility::XAccessible > SAL_CALL SvxShowCharSetItemAcc::getAccessibleAtPoint( const awt::Point& /*aPoint*/ )
793 throw (uno::RuntimeException, std::exception)
795 return uno::Reference< css::accessibility::XAccessible >();
798 sal_Int32 SAL_CALL SvxShowCharSetVirtualAcc::getForeground( ) throw (RuntimeException, std::exception)
800 OExternalLockGuard aGuard( this );
802 sal_Int32 nColor = 0;
803 if ( mpParent )
805 if ( mpParent->IsControlForeground() )
806 nColor = mpParent->GetControlForeground().GetColor();
807 else
809 vcl::Font aFont;
810 if ( mpParent->IsControlFont() )
811 aFont = mpParent->GetControlFont();
812 else
813 aFont = mpParent->GetFont();
814 nColor = aFont.GetColor().GetColor();
818 return nColor;
821 sal_Int32 SAL_CALL SvxShowCharSetVirtualAcc::getBackground( ) throw (RuntimeException, std::exception)
823 OExternalLockGuard aGuard( this );
824 sal_Int32 nColor = 0;
825 if ( mpParent )
827 if ( mpParent->IsControlBackground() )
828 nColor = mpParent->GetControlBackground().GetColor();
829 else
830 nColor = mpParent->GetBackground().GetColor().GetColor();
833 return nColor;
836 sal_Int32 SAL_CALL SvxShowCharSetAcc::getForeground( ) throw (RuntimeException, std::exception)
838 OExternalLockGuard aGuard( this );
840 sal_Int32 nColor = 0;
841 if ( m_pParent )
842 nColor = m_pParent->getForeground();
843 return nColor;
846 sal_Int32 SAL_CALL SvxShowCharSetAcc::getBackground( ) throw (RuntimeException, std::exception)
848 OExternalLockGuard aGuard( this );
849 sal_Int32 nColor = 0;
850 if ( m_pParent )
851 nColor = m_pParent->getBackground();
852 return nColor;
861 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */