fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / svx / source / accessibility / charmapacc.cxx
blob772832918726686ae7028606fa889c71bce0354c
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;
42 // ----------------
43 // - SvxShowCharSetVirtualAcc -
44 // ----------------
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);
56 // -----------------------------------------------------------------------------
58 SvxShowCharSetVirtualAcc::~SvxShowCharSetVirtualAcc()
60 ensureDisposed();
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
73 if ( m_pTable )
74 m_pTable->fireEvent(_nEventId,_rOldValue,_rNewValue);
76 // -----------------------------------------------------------------------------
77 sal_Int32 SAL_CALL SvxShowCharSetVirtualAcc::getAccessibleChildCount( ) throw (RuntimeException)
79 OExternalLockGuard aGuard( this );
80 ensureAlive();
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 );
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;
110 // -----------------------------------------------------------------------------
111 uno::Any SAL_CALL SvxShowCharSetVirtualAcc::getAccessibleKeyBinding()
112 throw (uno::RuntimeException)
114 return uno::Any();
116 // -----------------------------------------------------------------------------
117 void SAL_CALL SvxShowCharSetVirtualAcc::grabFocus()
118 throw (uno::RuntimeException)
120 OExternalLockGuard aGuard( this );
121 ensureAlive();
122 mpParent->GrabFocus();
126 // -----------------------------------------------------------------------------
127 Reference< XAccessible > SAL_CALL SvxShowCharSetVirtualAcc::getAccessibleChild( sal_Int32 i ) throw (IndexOutOfBoundsException, RuntimeException)
129 OExternalLockGuard aGuard( this );
130 ensureAlive();
131 if ( mpParent->getScrollBar()->IsVisible() && i == 0 )
132 return mpParent->getScrollBar()->GetAccessible();
133 else if ( i == 1 )
135 if ( !m_xAcc.is() )
137 m_pTable = new SvxShowCharSetAcc(this);
138 m_xAcc = m_pTable;
141 else
142 throw IndexOutOfBoundsException();
143 return m_xAcc;
145 // -----------------------------------------------------------------------------
146 Reference< XAccessible > SAL_CALL SvxShowCharSetVirtualAcc::getAccessibleParent( ) throw (RuntimeException)
148 OExternalLockGuard aGuard( this );
149 ensureAlive();
150 Window* pParent = mpParent->GetParent();
151 uno::Reference< css::accessibility::XAccessible > xRet;
153 if ( pParent )
154 xRet = pParent->GetAccessible();
156 return xRet;
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();
170 awt::Rectangle aRet;
172 aRet.X = aOutPos.X();
173 aRet.Y = aOutPos.Y();
174 aRet.Width = aOutSize.Width();
175 aRet.Height = aOutSize.Height();
177 return aRet;
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;
208 if( mpParent )
210 // SELECTABLE
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 );
225 return pStateSet;
227 // -----------------------------------------------------------------------------
228 void SAL_CALL SvxShowCharSetVirtualAcc::disposing()
230 OAccessibleContextHelper::disposing();
231 if ( m_pTable )
232 m_pTable->dispose();
233 m_pTable = NULL;
235 // -----------------------------------------------------------------------------
236 // ----------------
237 // - SvxShowCharSetItem -
238 // ----------------
240 SvxShowCharSetItem::SvxShowCharSetItem( SvxShowCharSet& rParent,SvxShowCharSetAcc* _pParent,sal_uInt16 _nPos ) :
241 mrParent( rParent )
242 ,mnId( _nPos )
243 ,m_pItem(NULL)
244 ,m_pParent(_pParent)
247 // -----------------------------------------------------------------------
249 SvxShowCharSetItem::~SvxShowCharSetItem()
251 if ( m_xAcc.is() )
253 m_pItem->ParentDestroyed();
254 ClearAccessible();
258 // -----------------------------------------------------------------------
260 uno::Reference< css::accessibility::XAccessible > SvxShowCharSetItem::GetAccessible()
262 if( !m_xAcc.is() )
264 m_pItem = new SvxShowCharSetItemAcc( this );
265 m_xAcc = m_pItem;
268 return m_xAcc;
271 // -----------------------------------------------------------------------
273 void SvxShowCharSetItem::ClearAccessible()
275 if ( m_xAcc.is() )
277 m_pItem = NULL;
278 m_xAcc = NULL;
283 // ---------------
284 // - SvxShowCharSetAcc -
285 // ---------------
287 SvxShowCharSetAcc::SvxShowCharSetAcc( SvxShowCharSetVirtualAcc* _pParent ) : OAccessibleSelectionHelper(new VCLExternalSolarLock())
288 ,m_pParent( _pParent )
290 osl_atomic_increment(&m_refCount);
292 lateInit(this);
294 osl_atomic_decrement(&m_refCount);
297 // -----------------------------------------------------------------------------
299 SvxShowCharSetAcc::~SvxShowCharSetAcc()
301 ensureDisposed();
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);
313 m_aChildren.clear();
314 m_pParent = NULL;
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)
330 if ( m_pParent )
332 if ( bSelect )
333 m_pParent->getCharSetControl()->SelectIndex(nAccessibleChildIndex,sal_True);
334 else
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();
350 awt::Rectangle aRet;
352 aRet.X = aOutPos.X();
353 aRet.Y = aOutPos.Y();
354 aRet.Width = aOutSize.Width();
355 aRet.Height = aOutSize.Height();
357 return aRet;
359 // -----------------------------------------------------------------------------
360 sal_Int32 SAL_CALL SvxShowCharSetAcc::getAccessibleChildCount()
361 throw (uno::RuntimeException)
363 OExternalLockGuard aGuard( this );
364 ensureAlive();
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 );
374 ensureAlive();
375 uno::Reference< css::accessibility::XAccessible > xRet;
376 SvxShowCharSetItem* pItem = m_pParent->getCharSetControl()->ImplGetItem( static_cast< sal_uInt16 >( i ) );
378 if( pItem )
380 pItem->m_pParent = this;
381 xRet = pItem->GetAccessible();
382 m_aChildren.push_back(xRet);
384 else
385 throw lang::IndexOutOfBoundsException();
387 return xRet;
390 // -----------------------------------------------------------------------------
392 uno::Reference< css::accessibility::XAccessible > SAL_CALL SvxShowCharSetAcc::getAccessibleParent()
393 throw (uno::RuntimeException)
395 OExternalLockGuard aGuard( this );
396 ensureAlive();
397 return m_pParent;
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 );
423 ensureAlive();
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() )
446 // SELECTABLE
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 );
463 return pStateSet;
465 // -----------------------------------------------------------------------------
467 uno::Reference< css::accessibility::XAccessible > SAL_CALL SvxShowCharSetAcc::getAccessibleAtPoint( const awt::Point& aPoint )
468 throw (uno::RuntimeException)
470 OExternalLockGuard aGuard( this );
471 ensureAlive();
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();
482 return xRet;
485 // -----------------------------------------------------------------------------
486 // -----------------------------------------------------------------------------
488 void SAL_CALL SvxShowCharSetAcc::grabFocus()
489 throw (uno::RuntimeException)
491 OExternalLockGuard aGuard( this );
492 ensureAlive();
493 m_pParent->getCharSetControl()->GrabFocus();
496 // -----------------------------------------------------------------------------
498 uno::Any SAL_CALL SvxShowCharSetAcc::getAccessibleKeyBinding()
499 throw (uno::RuntimeException)
501 return uno::Any();
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)
511 return COLUMN_COUNT;
513 // -----------------------------------------------------------------------------
514 OUString SAL_CALL SvxShowCharSetAcc::getAccessibleRowDescription( sal_Int32 /*nRow*/ ) throw (IndexOutOfBoundsException, RuntimeException)
516 return OUString();
518 // -----------------------------------------------------------------------------
519 OUString SAL_CALL SvxShowCharSetAcc::getAccessibleColumnDescription( sal_Int32 /*nColumn*/ ) throw (IndexOutOfBoundsException, RuntimeException)
521 return OUString();
523 // -----------------------------------------------------------------------------
524 sal_Int32 SAL_CALL SvxShowCharSetAcc::getAccessibleRowExtentAt( sal_Int32 /*nRow*/, sal_Int32 /*nColumn*/ ) throw (IndexOutOfBoundsException, RuntimeException)
526 return 1;
528 // -----------------------------------------------------------------------------
529 sal_Int32 SAL_CALL SvxShowCharSetAcc::getAccessibleColumnExtentAt( sal_Int32 /*nRow*/, sal_Int32 /*nColumn*/ ) throw (IndexOutOfBoundsException, RuntimeException)
531 return 1;
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 );
547 ensureAlive();
548 Sequence< sal_Int32 > aSel(1);
549 aSel[0] = m_pParent->getCharSetControl()->GetRowPos(m_pParent->getCharSetControl()->GetSelectIndexId());
550 return aSel;
552 // -----------------------------------------------------------------------------
553 Sequence< sal_Int32 > SAL_CALL SvxShowCharSetAcc::getSelectedAccessibleColumns( ) throw (RuntimeException)
555 OExternalLockGuard aGuard( this );
556 ensureAlive();
557 Sequence< sal_Int32 > aSel(1);
558 aSel[0] = m_pParent->getCharSetControl()->GetColumnPos(m_pParent->getCharSetControl()->GetSelectIndexId());
559 return aSel;
561 // -----------------------------------------------------------------------------
562 sal_Bool SAL_CALL SvxShowCharSetAcc::isAccessibleRowSelected( sal_Int32 nRow ) throw (IndexOutOfBoundsException, RuntimeException)
564 OExternalLockGuard aGuard( this );
565 ensureAlive();
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 );
572 ensureAlive();
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 );
579 ensureAlive();
580 ::svx::SvxShowCharSetItem* pItem = m_pParent->getCharSetControl()->ImplGetItem(
581 sal::static_int_cast<sal_uInt16>(getAccessibleIndex(nRow,nColumn) ));
582 if ( !pItem )
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 );
600 ensureAlive();
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 );
612 ensureAlive();
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 );
619 ensureAlive();
620 return m_pParent->getCharSetControl()->GetColumnPos(sal::static_int_cast<sal_uInt16>(nChildIndex));
622 // -----------------------------------------------------------------------------
624 // -----------------------------------------------------------------------------
625 // ----------------
626 // - SvxShowCharSetItemAcc -
627 // ----------------
629 SvxShowCharSetItemAcc::SvxShowCharSetItemAcc( SvxShowCharSetItem* pParent ) : OAccessibleComponentHelper(new VCLExternalSolarLock())
630 ,mpParent( pParent )
632 OSL_ENSURE(pParent,"NO parent supplied!");
633 osl_atomic_increment(&m_refCount);
634 { // #b6211265 #
635 lateInit(this);
637 osl_atomic_decrement(&m_refCount);
640 // -----------------------------------------------------------------------------
642 SvxShowCharSetItemAcc::~SvxShowCharSetItemAcc()
644 ensureDisposed();
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() );
655 mpParent = NULL;
658 // -----------------------------------------------------------------------------
660 sal_Int32 SAL_CALL SvxShowCharSetItemAcc::getAccessibleChildCount()
661 throw (uno::RuntimeException)
663 return 0;
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 );
680 ensureAlive();
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 );
698 ensureAlive();
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');
708 c_Shifted >>= 4;
710 if( c < 256 )
711 snprintf( buf+6, 10, " (%d)", c );
712 sDescription.AppendAscii(buf);
714 return sDescription;
717 // -----------------------------------------------------------------------------
719 OUString SAL_CALL SvxShowCharSetItemAcc::getAccessibleName()
720 throw (uno::RuntimeException)
722 OExternalLockGuard aGuard( this );
723 ensureAlive();
724 OUString aRet;
726 if( mpParent )
728 aRet = mpParent->maText;
730 if (aRet.isEmpty())
731 aRet = getAccessibleDescription();
734 return aRet;
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 );
751 ensureAlive();
753 ::utl::AccessibleStateSetHelper* pStateSet = new ::utl::AccessibleStateSetHelper;
755 if( mpParent )
757 // SELECTABLE
758 pStateSet->AddState( css::accessibility::AccessibleStateType::SELECTABLE );
759 pStateSet->AddState( css::accessibility::AccessibleStateType::FOCUSABLE );
761 // SELECTED
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 );
772 return pStateSet;
775 // -----------------------------------------------------------------------------
776 void SAL_CALL SvxShowCharSetItemAcc::grabFocus()
777 throw (uno::RuntimeException)
779 // nothing to do
782 // -----------------------------------------------------------------------------
784 uno::Any SAL_CALL SvxShowCharSetItemAcc::getAccessibleKeyBinding()
785 throw (uno::RuntimeException)
787 return uno::Any();
789 // -----------------------------------------------------------------------------
790 awt::Rectangle SAL_CALL SvxShowCharSetItemAcc::implGetBounds( ) throw (RuntimeException)
792 awt::Rectangle aRet;
794 if( mpParent )
796 Rectangle aRect( mpParent->maRect );
797 Point aOrigin;
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();
808 return aRet;
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;
822 if ( mpParent )
824 if ( mpParent->IsControlForeground() )
825 nColor = mpParent->GetControlForeground().GetColor();
826 else
828 Font aFont;
829 if ( mpParent->IsControlFont() )
830 aFont = mpParent->GetControlFont();
831 else
832 aFont = mpParent->GetFont();
833 nColor = aFont.GetColor().GetColor();
837 return nColor;
839 // -----------------------------------------------------------------------------
840 sal_Int32 SAL_CALL SvxShowCharSetVirtualAcc::getBackground( ) throw (RuntimeException)
842 OExternalLockGuard aGuard( this );
843 sal_Int32 nColor = 0;
844 if ( mpParent )
846 if ( mpParent->IsControlBackground() )
847 nColor = mpParent->GetControlBackground().GetColor();
848 else
849 nColor = mpParent->GetBackground().GetColor().GetColor();
852 return nColor;
854 // -----------------------------------------------------------------------------
855 sal_Int32 SAL_CALL SvxShowCharSetAcc::getForeground( ) throw (RuntimeException)
857 OExternalLockGuard aGuard( this );
859 sal_Int32 nColor = 0;
860 if ( m_pParent )
861 nColor = m_pParent->getForeground();
862 return nColor;
864 // -----------------------------------------------------------------------------
865 sal_Int32 SAL_CALL SvxShowCharSetAcc::getBackground( ) throw (RuntimeException)
867 OExternalLockGuard aGuard( this );
868 sal_Int32 nColor = 0;
869 if ( m_pParent )
870 nColor = m_pParent->getBackground();
871 return nColor;
873 // -----------------------------------------------------------------------------
875 // -----------------------------------------------------------------------------
876 } // namespace svx
877 // -----------------------------------------------------------------------------
880 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */