LCOV - code coverage report
Current view: top level - libreoffice/svx/source/accessibility - charmapacc.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 405 0.0 %
Date: 2012-12-17 Functions: 0 93 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       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/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      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 .
      18             :  */
      19             : 
      20             : 
      21             : #define _SVX_CHARMAP_CXX_
      22             : #include <unotools/accessiblestatesethelper.hxx>
      23             : #include <vcl/svapp.hxx>
      24             : #include <stdio.h>
      25             : #include <svx/charmap.hxx>
      26             : #include "charmapacc.hxx"
      27             : #include <com/sun/star/accessibility/AccessibleRole.hpp>
      28             : #include <com/sun/star/accessibility/AccessibleStateType.hpp>
      29             : #include <toolkit/helper/externallock.hxx>
      30             : #include <toolkit/helper/convert.hxx>
      31             : #include <osl/interlck.h>
      32             : #include <svx/dialmgr.hxx>
      33             : #include "accessibility.hrc"
      34             : #include <comphelper/types.hxx>
      35             : 
      36             : namespace svx
      37             : {
      38             :     using namespace comphelper;
      39             :     using namespace ::com::sun::star;
      40             :     using namespace ::com::sun::star::uno;
      41             :     using namespace ::com::sun::star::lang;
      42             :     using namespace ::com::sun::star::accessibility;
      43             : 
      44             : // ----------------
      45             : // - SvxShowCharSetVirtualAcc -
      46             : // ----------------
      47           0 : SvxShowCharSetVirtualAcc::SvxShowCharSetVirtualAcc( SvxShowCharSet* pParent ) : OAccessibleComponentHelper(new VCLExternalSolarLock())
      48             : ,mpParent( pParent )
      49           0 : ,m_pTable(NULL)
      50             : {
      51           0 :     osl_atomic_increment(&m_refCount);
      52             :     {
      53           0 :         lateInit(this);
      54             :     }
      55           0 :     osl_atomic_decrement(&m_refCount);
      56           0 : }
      57             : 
      58             : // -----------------------------------------------------------------------------
      59             : 
      60           0 : SvxShowCharSetVirtualAcc::~SvxShowCharSetVirtualAcc()
      61             : {
      62           0 :     ensureDisposed();
      63           0 :     delete getExternalLock();
      64           0 : }
      65             : // -----------------------------------------------------------------------------
      66           0 : IMPLEMENT_FORWARD_XINTERFACE2( SvxShowCharSetVirtualAcc, OAccessibleComponentHelper, OAccessibleHelper_Base_2 )
      67           0 : IMPLEMENT_FORWARD_XTYPEPROVIDER2( SvxShowCharSetVirtualAcc, OAccessibleComponentHelper, OAccessibleHelper_Base_2 )
      68             : 
      69           0 : void SAL_CALL SvxShowCharSetVirtualAcc::fireEvent(
      70             :                     const sal_Int16 _nEventId,
      71             :                     const ::com::sun::star::uno::Any& _rOldValue,
      72             :                     const ::com::sun::star::uno::Any& _rNewValue
      73             :                 )
      74             : {
      75           0 :     if ( m_pTable )
      76           0 :         m_pTable->fireEvent(_nEventId,_rOldValue,_rNewValue);
      77           0 : }
      78             : // -----------------------------------------------------------------------------
      79           0 : sal_Int32 SAL_CALL SvxShowCharSetVirtualAcc::getAccessibleChildCount(  ) throw (RuntimeException)
      80             : {
      81           0 :     OExternalLockGuard aGuard( this );
      82           0 :     ensureAlive();
      83           0 :     return ( mpParent->getScrollBar()->IsVisible() ) ? 2 : 1;
      84             : }
      85             : // -----------------------------------------------------------------------------
      86           0 : uno::Reference< css::accessibility::XAccessible > SAL_CALL SvxShowCharSetVirtualAcc::getAccessibleAtPoint( const awt::Point& aPoint )
      87             :     throw (uno::RuntimeException)
      88             : {
      89           0 :     OExternalLockGuard aGuard( this );
      90           0 :     ensureAlive();
      91             : 
      92           0 :     uno::Reference< css::accessibility::XAccessible >    xRet;
      93           0 :     const sal_uInt16 nItemId = sal::static_int_cast<sal_uInt16>(mpParent->PixelToMapIndex( Point( aPoint.X, aPoint.Y ) ));
      94             : 
      95           0 :     if( sal_uInt16(-1) != nItemId )
      96             :     {
      97           0 :         if ( !m_pTable )
      98           0 :             m_pTable = new SvxShowCharSetAcc(this);
      99           0 :         xRet = m_pTable;
     100             :     }
     101           0 :     else if ( mpParent->getScrollBar()->IsVisible() )
     102             :     {
     103           0 :         const Point aOutPos( mpParent->getScrollBar()->GetPosPixel() );
     104           0 :         const Size  aScrollBar = mpParent->getScrollBar()->GetOutputSizePixel();
     105           0 :         Rectangle aRect(aOutPos,aScrollBar);
     106             : 
     107           0 :         if ( aRect.IsInside(VCLPoint(aPoint)) )
     108           0 :             xRet = mpParent->getScrollBar()->GetAccessible();
     109             :     }
     110           0 :     return xRet;
     111             : }
     112             : // -----------------------------------------------------------------------------
     113           0 : uno::Any SAL_CALL SvxShowCharSetVirtualAcc::getAccessibleKeyBinding()
     114             :     throw (uno::RuntimeException)
     115             : {
     116           0 :     return uno::Any();
     117             : }
     118             : // -----------------------------------------------------------------------------
     119           0 : void SAL_CALL SvxShowCharSetVirtualAcc::grabFocus()
     120             :     throw (uno::RuntimeException)
     121             : {
     122           0 :     OExternalLockGuard aGuard( this );
     123           0 :     ensureAlive();
     124           0 :     mpParent->GrabFocus();
     125           0 : }
     126             : 
     127             : 
     128             : // -----------------------------------------------------------------------------
     129           0 : Reference< XAccessible > SAL_CALL SvxShowCharSetVirtualAcc::getAccessibleChild( sal_Int32 i ) throw (IndexOutOfBoundsException, RuntimeException)
     130             : {
     131           0 :     OExternalLockGuard aGuard( this );
     132           0 :     ensureAlive();
     133           0 :     if ( mpParent->getScrollBar()->IsVisible() && i == 0 )
     134           0 :         return mpParent->getScrollBar()->GetAccessible();
     135           0 :     else if ( i == 1 )
     136             :     {
     137           0 :         if ( !m_xAcc.is() )
     138             :         {
     139           0 :             m_pTable = new SvxShowCharSetAcc(this);
     140           0 :             m_xAcc = m_pTable;
     141             :         }
     142             :     }
     143             :     else
     144           0 :         throw IndexOutOfBoundsException();
     145           0 :     return m_xAcc;
     146             : }
     147             : // -----------------------------------------------------------------------------
     148           0 : Reference< XAccessible > SAL_CALL SvxShowCharSetVirtualAcc::getAccessibleParent(  ) throw (RuntimeException)
     149             : {
     150           0 :     OExternalLockGuard aGuard( this );
     151           0 :     ensureAlive();
     152           0 :     Window*                                         pParent = mpParent->GetParent();
     153           0 :     uno::Reference< css::accessibility::XAccessible >    xRet;
     154             : 
     155           0 :     if ( pParent )
     156           0 :         xRet = pParent->GetAccessible();
     157             : 
     158           0 :     return xRet;
     159             : }
     160             : // -----------------------------------------------------------------------------
     161           0 : ::com::sun::star::awt::Rectangle SAL_CALL SvxShowCharSetVirtualAcc::implGetBounds(  ) throw (RuntimeException)
     162             : {
     163           0 :     const Point   aOutPos( mpParent->GetPosPixel() );
     164           0 :     Size          aOutSize( mpParent->GetOutputSizePixel() );
     165           0 :     if ( mpParent->getScrollBar()->IsVisible() )
     166             :     {
     167           0 :         const Size aScrollBar = mpParent->getScrollBar()->GetOutputSizePixel();
     168           0 :         aOutSize.Width() -= aScrollBar.Width();
     169           0 :         aOutSize.Height() -= aScrollBar.Height();
     170             :     }
     171             : 
     172           0 :     awt::Rectangle aRet;
     173             : 
     174           0 :     aRet.X = aOutPos.X();
     175           0 :     aRet.Y = aOutPos.Y();
     176           0 :     aRet.Width = aOutSize.Width();
     177           0 :     aRet.Height = aOutSize.Height();
     178             : 
     179           0 :     return aRet;
     180             : }
     181             : // -----------------------------------------------------------------------------
     182           0 : sal_Int16 SAL_CALL SvxShowCharSetVirtualAcc::getAccessibleRole(  ) throw (RuntimeException)
     183             : {
     184           0 :     return css::accessibility::AccessibleRole::SCROLL_PANE;
     185             : }
     186             : // -----------------------------------------------------------------------------
     187           0 : ::rtl::OUString SAL_CALL SvxShowCharSetVirtualAcc::getAccessibleDescription(  ) throw (RuntimeException)
     188             : {
     189           0 :     OExternalLockGuard aGuard( this );
     190           0 :     return SVX_RESSTR( RID_SVXSTR_CHARACTER_SELECTION);
     191             : }
     192             : // -----------------------------------------------------------------------------
     193           0 : ::rtl::OUString SAL_CALL SvxShowCharSetVirtualAcc::getAccessibleName(  ) throw (RuntimeException)
     194             : {
     195           0 :     OExternalLockGuard aGuard( this );
     196           0 :     return SVX_RESSTR( RID_SVXSTR_CHAR_SEL_DESC);
     197             : }
     198             : // -----------------------------------------------------------------------------
     199           0 : Reference< XAccessibleRelationSet > SAL_CALL SvxShowCharSetVirtualAcc::getAccessibleRelationSet(  ) throw (RuntimeException)
     200             : {
     201           0 :     return Reference< XAccessibleRelationSet >();
     202             : }
     203             : // -----------------------------------------------------------------------------
     204           0 : Reference< XAccessibleStateSet > SAL_CALL SvxShowCharSetVirtualAcc::getAccessibleStateSet(  ) throw (RuntimeException)
     205             : {
     206           0 :     OExternalLockGuard aGuard( this );
     207             : 
     208           0 :     ::utl::AccessibleStateSetHelper*    pStateSet = new ::utl::AccessibleStateSetHelper;
     209             : 
     210           0 :     if( mpParent )
     211             :     {
     212             :         // SELECTABLE
     213           0 :         pStateSet->AddState( AccessibleStateType::FOCUSABLE );
     214           0 :         if ( mpParent->HasFocus() )
     215           0 :             pStateSet->AddState( AccessibleStateType::FOCUSED );
     216           0 :         if ( mpParent->IsActive() )
     217           0 :             pStateSet->AddState( AccessibleStateType::ACTIVE );
     218           0 :         if ( mpParent->IsEnabled() )
     219             :         {
     220           0 :             pStateSet->AddState( AccessibleStateType::ENABLED );
     221           0 :             pStateSet->AddState( AccessibleStateType::SENSITIVE );
     222             :         }
     223           0 :         if ( mpParent->IsReallyVisible() )
     224           0 :             pStateSet->AddState( AccessibleStateType::VISIBLE );
     225             :     }
     226             : 
     227           0 :     return pStateSet;
     228             : }
     229             : // -----------------------------------------------------------------------------
     230           0 : void SAL_CALL SvxShowCharSetVirtualAcc::disposing()
     231             : {
     232           0 :     OAccessibleContextHelper::disposing();
     233           0 :     if ( m_pTable )
     234           0 :         m_pTable->dispose();
     235           0 :     m_pTable = NULL;
     236           0 : }
     237             : // -----------------------------------------------------------------------------
     238             : // ----------------
     239             : // - SvxShowCharSetItem -
     240             : // ----------------
     241             : 
     242           0 : SvxShowCharSetItem::SvxShowCharSetItem( SvxShowCharSet& rParent,SvxShowCharSetAcc*  _pParent,sal_uInt16 _nPos ) :
     243             :     mrParent( rParent )
     244             :     ,mnId( _nPos )
     245             :     ,m_pItem(NULL)
     246           0 :     ,m_pParent(_pParent)
     247             : {
     248           0 : }
     249             : // -----------------------------------------------------------------------
     250             : 
     251           0 : SvxShowCharSetItem::~SvxShowCharSetItem()
     252             : {
     253           0 :     if ( m_xAcc.is() )
     254             :     {
     255           0 :         m_pItem->ParentDestroyed();
     256           0 :         ClearAccessible();
     257             :     }
     258           0 : }
     259             : 
     260             : // -----------------------------------------------------------------------
     261             : 
     262           0 : uno::Reference< css::accessibility::XAccessible > SvxShowCharSetItem::GetAccessible()
     263             : {
     264           0 :     if( !m_xAcc.is() )
     265             :     {
     266           0 :         m_pItem = new SvxShowCharSetItemAcc( this );
     267           0 :         m_xAcc = m_pItem;
     268             :     }
     269             : 
     270           0 :     return m_xAcc;
     271             : }
     272             : 
     273             : // -----------------------------------------------------------------------
     274             : 
     275           0 : void SvxShowCharSetItem::ClearAccessible()
     276             : {
     277           0 :     if ( m_xAcc.is() )
     278             :     {
     279           0 :         m_pItem = NULL;
     280           0 :         m_xAcc  = NULL;
     281             :     }
     282           0 : }
     283             : 
     284             : 
     285             : // ---------------
     286             : // - SvxShowCharSetAcc -
     287             : // ---------------
     288             : 
     289           0 : SvxShowCharSetAcc::SvxShowCharSetAcc( SvxShowCharSetVirtualAcc* _pParent ) : OAccessibleSelectionHelper(new VCLExternalSolarLock())
     290           0 :   ,m_pParent( _pParent )
     291             : {
     292           0 :     osl_atomic_increment(&m_refCount);
     293             :     {
     294           0 :         lateInit(this);
     295             :     }
     296           0 :     osl_atomic_decrement(&m_refCount);
     297           0 : }
     298             : 
     299             : // -----------------------------------------------------------------------------
     300             : 
     301           0 : SvxShowCharSetAcc::~SvxShowCharSetAcc()
     302             : {
     303           0 :     ensureDisposed();
     304           0 :     delete getExternalLock();
     305           0 : }
     306             : // -----------------------------------------------------------------------------
     307           0 : void SAL_CALL SvxShowCharSetAcc::disposing()
     308             : {
     309           0 :     OAccessibleSelectionHelper::disposing();
     310           0 :     ::std::vector< Reference< XAccessible > >::iterator aIter = m_aChildren.begin();
     311           0 :     ::std::vector< Reference< XAccessible > >::iterator aEnd  = m_aChildren.end();
     312           0 :     for (;aIter != aEnd ; ++aIter)
     313           0 :         ::comphelper::disposeComponent(*aIter);
     314             : 
     315           0 :     m_aChildren.clear();
     316           0 :     m_pParent = NULL;
     317           0 : }
     318             : 
     319             : // -----------------------------------------------------------------------------
     320           0 : IMPLEMENT_FORWARD_XINTERFACE2( SvxShowCharSetAcc, OAccessibleSelectionHelper, OAccessibleHelper_Base )
     321           0 : IMPLEMENT_FORWARD_XTYPEPROVIDER2( SvxShowCharSetAcc, OAccessibleSelectionHelper, OAccessibleHelper_Base )
     322             : // -----------------------------------------------------------------------
     323           0 : sal_Bool SvxShowCharSetAcc::implIsSelected( sal_Int32 nAccessibleChildIndex ) throw (RuntimeException)
     324             : {
     325             :     return m_pParent && m_pParent->getCharSetControl()->IsSelected(
     326           0 :         sal::static_int_cast<sal_uInt16>(nAccessibleChildIndex));
     327             : }
     328             : // -----------------------------------------------------------------------------
     329             :         // select the specified child => watch for special ChildIndexes (ACCESSIBLE_SELECTION_CHILD_xxx)
     330           0 : void SvxShowCharSetAcc::implSelect( sal_Int32 nAccessibleChildIndex, sal_Bool bSelect ) throw (IndexOutOfBoundsException, RuntimeException)
     331             : {
     332           0 :     if ( m_pParent )
     333             :     {
     334           0 :         if ( bSelect )
     335           0 :             m_pParent->getCharSetControl()->SelectIndex(nAccessibleChildIndex,sal_True);
     336             :         else
     337           0 :             m_pParent->getCharSetControl()->DeSelect();
     338             :     }
     339           0 : }
     340             : // -----------------------------------------------------------------------------
     341           0 : ::com::sun::star::awt::Rectangle SAL_CALL SvxShowCharSetAcc::implGetBounds(  ) throw (RuntimeException)
     342             : {
     343           0 :     const Point   aOutPos( m_pParent->getCharSetControl()->GetPosPixel() );
     344           0 :     Size          aOutSize( m_pParent->getCharSetControl()->GetOutputSizePixel());
     345           0 :     if ( m_pParent->getCharSetControl()->getScrollBar()->IsVisible() )
     346             :     {
     347           0 :         const Size aScrollBar = m_pParent->getCharSetControl()->getScrollBar()->GetOutputSizePixel();
     348           0 :         aOutSize.Width() -= aScrollBar.Width();
     349           0 :         aOutSize.Height() -= aScrollBar.Height();
     350             :     }
     351             : 
     352           0 :     awt::Rectangle aRet;
     353             : 
     354           0 :     aRet.X = aOutPos.X();
     355           0 :     aRet.Y = aOutPos.Y();
     356           0 :     aRet.Width = aOutSize.Width();
     357           0 :     aRet.Height = aOutSize.Height();
     358             : 
     359           0 :     return aRet;
     360             : }
     361             : // -----------------------------------------------------------------------------
     362           0 : sal_Int32 SAL_CALL SvxShowCharSetAcc::getAccessibleChildCount()
     363             :     throw (uno::RuntimeException)
     364             : {
     365           0 :     OExternalLockGuard aGuard( this );
     366           0 :     ensureAlive();
     367           0 :     return m_pParent->getCharSetControl()->getMaxCharCount();
     368             : }
     369             : 
     370             : // -----------------------------------------------------------------------------
     371             : 
     372           0 : uno::Reference< css::accessibility::XAccessible > SAL_CALL SvxShowCharSetAcc::getAccessibleChild( sal_Int32 i )
     373             :     throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
     374             : {
     375           0 :     OExternalLockGuard aGuard( this );
     376           0 :     ensureAlive();
     377           0 :     uno::Reference< css::accessibility::XAccessible >    xRet;
     378           0 :     SvxShowCharSetItem* pItem = m_pParent->getCharSetControl()->ImplGetItem( static_cast< sal_uInt16 >( i ) );
     379             : 
     380           0 :     if( pItem )
     381             :     {
     382           0 :         pItem->m_pParent = this;
     383           0 :         xRet = pItem->GetAccessible();
     384           0 :         m_aChildren.push_back(xRet);
     385             :     }
     386             :     else
     387           0 :         throw lang::IndexOutOfBoundsException();
     388             : 
     389           0 :     return xRet;
     390             : }
     391             : 
     392             : // -----------------------------------------------------------------------------
     393             : 
     394           0 : uno::Reference< css::accessibility::XAccessible > SAL_CALL SvxShowCharSetAcc::getAccessibleParent()
     395             :     throw (uno::RuntimeException)
     396             : {
     397           0 :     OExternalLockGuard aGuard( this );
     398           0 :     ensureAlive();
     399           0 :     return m_pParent;
     400             : }
     401             : 
     402             : // -----------------------------------------------------------------------------
     403             : 
     404           0 : sal_Int16 SAL_CALL SvxShowCharSetAcc::getAccessibleRole()
     405             :     throw (uno::RuntimeException)
     406             : {
     407           0 :     return css::accessibility::AccessibleRole::TABLE;
     408             : }
     409             : 
     410             : // -----------------------------------------------------------------------------
     411             : 
     412           0 : ::rtl::OUString SAL_CALL SvxShowCharSetAcc::getAccessibleDescription()
     413             :     throw (uno::RuntimeException)
     414             : {
     415           0 :     OExternalLockGuard aGuard( this );
     416           0 :     return SVX_RESSTR( RID_SVXSTR_CHARACTER_SELECTION );
     417             : }
     418             : 
     419             : // -----------------------------------------------------------------------------
     420             : 
     421           0 : ::rtl::OUString SAL_CALL SvxShowCharSetAcc::getAccessibleName()
     422             :     throw (uno::RuntimeException)
     423             : {
     424           0 :     OExternalLockGuard aGuard( this );
     425           0 :     ensureAlive();
     426           0 :     return SVX_RESSTR( RID_SVXSTR_CHAR_SEL_DESC );
     427             : }
     428             : 
     429             : // -----------------------------------------------------------------------------
     430             : 
     431           0 : uno::Reference< css::accessibility::XAccessibleRelationSet > SAL_CALL SvxShowCharSetAcc::getAccessibleRelationSet()
     432             :     throw (uno::RuntimeException)
     433             : {
     434           0 :     return uno::Reference< css::accessibility::XAccessibleRelationSet >();
     435             : }
     436             : 
     437             : // -----------------------------------------------------------------------------
     438             : 
     439           0 : uno::Reference< css::accessibility::XAccessibleStateSet > SAL_CALL SvxShowCharSetAcc::getAccessibleStateSet()
     440             :     throw (uno::RuntimeException)
     441             : {
     442           0 :     OExternalLockGuard aGuard( this );
     443             : 
     444           0 :     ::utl::AccessibleStateSetHelper*    pStateSet = new ::utl::AccessibleStateSetHelper;
     445             : 
     446           0 :     if( m_pParent->getCharSetControl() )
     447             :     {
     448             :         // SELECTABLE
     449           0 :         pStateSet->AddState( AccessibleStateType::FOCUSABLE );
     450           0 :         if ( m_pParent->getCharSetControl()->HasFocus() )
     451           0 :             pStateSet->AddState( AccessibleStateType::FOCUSED );
     452           0 :         if ( m_pParent->getCharSetControl()->IsActive() )
     453           0 :             pStateSet->AddState( AccessibleStateType::ACTIVE );
     454           0 :         if ( m_pParent->getCharSetControl()->IsEnabled() )
     455             :         {
     456           0 :             pStateSet->AddState( AccessibleStateType::ENABLED );
     457           0 :             pStateSet->AddState( AccessibleStateType::SENSITIVE );
     458             :         }
     459           0 :         if ( m_pParent->getCharSetControl()->IsReallyVisible() )
     460           0 :             pStateSet->AddState( AccessibleStateType::VISIBLE );
     461             : 
     462           0 :         pStateSet->AddState( AccessibleStateType::MANAGES_DESCENDANTS );
     463             :     }
     464             : 
     465           0 :     return pStateSet;
     466             : }
     467             : // -----------------------------------------------------------------------------
     468             : 
     469           0 : uno::Reference< css::accessibility::XAccessible > SAL_CALL SvxShowCharSetAcc::getAccessibleAtPoint( const awt::Point& aPoint )
     470             :     throw (uno::RuntimeException)
     471             : {
     472           0 :     OExternalLockGuard aGuard( this );
     473           0 :     ensureAlive();
     474             : 
     475           0 :     uno::Reference< css::accessibility::XAccessible >    xRet;
     476             :     const sal_uInt16 nItemId = sal::static_int_cast<sal_uInt16>(
     477           0 :         m_pParent->getCharSetControl()->PixelToMapIndex( Point( aPoint.X, aPoint.Y ) ));
     478             : 
     479           0 :     if( sal_uInt16(-1) != nItemId )
     480             :     {
     481           0 :         SvxShowCharSetItem* pItem = m_pParent->getCharSetControl()->ImplGetItem( nItemId );
     482           0 :         xRet = pItem->GetAccessible();
     483             :     }
     484           0 :     return xRet;
     485             : }
     486             : 
     487             : // -----------------------------------------------------------------------------
     488             : // -----------------------------------------------------------------------------
     489             : 
     490           0 : void SAL_CALL SvxShowCharSetAcc::grabFocus()
     491             :     throw (uno::RuntimeException)
     492             : {
     493           0 :     OExternalLockGuard aGuard( this );
     494           0 :     ensureAlive();
     495           0 :     m_pParent->getCharSetControl()->GrabFocus();
     496           0 : }
     497             : 
     498             : // -----------------------------------------------------------------------------
     499             : 
     500           0 : uno::Any SAL_CALL SvxShowCharSetAcc::getAccessibleKeyBinding()
     501             :     throw (uno::RuntimeException)
     502             : {
     503           0 :     return uno::Any();
     504             : }
     505             : // -----------------------------------------------------------------------------
     506           0 : sal_Int32 SAL_CALL SvxShowCharSetAcc::getAccessibleRowCount(  ) throw (RuntimeException)
     507             : {
     508           0 :     return ((getAccessibleChildCount()-1) / COLUMN_COUNT) + 1;
     509             : }
     510             : // -----------------------------------------------------------------------------
     511           0 : sal_Int32 SAL_CALL SvxShowCharSetAcc::getAccessibleColumnCount(  ) throw (RuntimeException)
     512             : {
     513           0 :     return COLUMN_COUNT;
     514             : }
     515             : // -----------------------------------------------------------------------------
     516           0 : ::rtl::OUString SAL_CALL SvxShowCharSetAcc::getAccessibleRowDescription( sal_Int32 /*nRow*/ ) throw (IndexOutOfBoundsException, RuntimeException)
     517             : {
     518           0 :     return ::rtl::OUString();
     519             : }
     520             : // -----------------------------------------------------------------------------
     521           0 : ::rtl::OUString SAL_CALL SvxShowCharSetAcc::getAccessibleColumnDescription( sal_Int32 /*nColumn*/ ) throw (IndexOutOfBoundsException, RuntimeException)
     522             : {
     523           0 :     return ::rtl::OUString();
     524             : }
     525             : // -----------------------------------------------------------------------------
     526           0 : sal_Int32 SAL_CALL SvxShowCharSetAcc::getAccessibleRowExtentAt( sal_Int32 /*nRow*/, sal_Int32 /*nColumn*/ ) throw (IndexOutOfBoundsException, RuntimeException)
     527             : {
     528           0 :     return 1;
     529             : }
     530             : // -----------------------------------------------------------------------------
     531           0 : sal_Int32 SAL_CALL SvxShowCharSetAcc::getAccessibleColumnExtentAt( sal_Int32 /*nRow*/, sal_Int32 /*nColumn*/ ) throw (IndexOutOfBoundsException, RuntimeException)
     532             : {
     533           0 :     return 1;
     534             : }
     535             : // -----------------------------------------------------------------------------
     536           0 : Reference< XAccessibleTable > SAL_CALL SvxShowCharSetAcc::getAccessibleRowHeaders(  ) throw (RuntimeException)
     537             : {
     538           0 :     return Reference< XAccessibleTable >();
     539             : }
     540             : // -----------------------------------------------------------------------------
     541           0 : Reference< XAccessibleTable > SAL_CALL SvxShowCharSetAcc::getAccessibleColumnHeaders(  ) throw (RuntimeException)
     542             : {
     543           0 :     return Reference< XAccessibleTable >();
     544             : }
     545             : // -----------------------------------------------------------------------------
     546           0 : Sequence< sal_Int32 > SAL_CALL SvxShowCharSetAcc::getSelectedAccessibleRows(  ) throw (RuntimeException)
     547             : {
     548           0 :     OExternalLockGuard aGuard( this );
     549           0 :     ensureAlive();
     550           0 :     Sequence< sal_Int32 > aSel(1);
     551           0 :     aSel[0] = m_pParent->getCharSetControl()->GetRowPos(m_pParent->getCharSetControl()->GetSelectIndexId());
     552           0 :     return aSel;
     553             : }
     554             : // -----------------------------------------------------------------------------
     555           0 : Sequence< sal_Int32 > SAL_CALL SvxShowCharSetAcc::getSelectedAccessibleColumns(  ) throw (RuntimeException)
     556             : {
     557           0 :     OExternalLockGuard aGuard( this );
     558           0 :     ensureAlive();
     559           0 :     Sequence< sal_Int32 > aSel(1);
     560           0 :     aSel[0] = m_pParent->getCharSetControl()->GetColumnPos(m_pParent->getCharSetControl()->GetSelectIndexId());
     561           0 :     return aSel;
     562             : }
     563             : // -----------------------------------------------------------------------------
     564           0 : sal_Bool SAL_CALL SvxShowCharSetAcc::isAccessibleRowSelected( sal_Int32 nRow ) throw (IndexOutOfBoundsException, RuntimeException)
     565             : {
     566           0 :     OExternalLockGuard aGuard( this );
     567           0 :     ensureAlive();
     568           0 :     return m_pParent->getCharSetControl()->GetRowPos(m_pParent->getCharSetControl()->GetSelectIndexId()) == nRow;
     569             : }
     570             : // -----------------------------------------------------------------------------
     571           0 : sal_Bool SAL_CALL SvxShowCharSetAcc::isAccessibleColumnSelected( sal_Int32 nColumn ) throw (IndexOutOfBoundsException, RuntimeException)
     572             : {
     573           0 :     OExternalLockGuard aGuard( this );
     574           0 :     ensureAlive();
     575           0 :     return m_pParent->getCharSetControl()->GetColumnPos(m_pParent->getCharSetControl()->GetSelectIndexId()) == nColumn;
     576             : }
     577             : // -----------------------------------------------------------------------------
     578           0 : Reference< XAccessible > SAL_CALL SvxShowCharSetAcc::getAccessibleCellAt( sal_Int32 nRow, sal_Int32 nColumn ) throw (IndexOutOfBoundsException, RuntimeException)
     579             : {
     580           0 :     OExternalLockGuard aGuard( this );
     581           0 :     ensureAlive();
     582             :     ::svx::SvxShowCharSetItem* pItem = m_pParent->getCharSetControl()->ImplGetItem(
     583           0 :         sal::static_int_cast<sal_uInt16>(getAccessibleIndex(nRow,nColumn) ));
     584           0 :     if ( !pItem  )
     585           0 :         throw IndexOutOfBoundsException();
     586           0 :     return pItem->GetAccessible();
     587             : }
     588             : // -----------------------------------------------------------------------------
     589           0 : Reference< XAccessible > SAL_CALL SvxShowCharSetAcc::getAccessibleCaption(  ) throw (RuntimeException)
     590             : {
     591           0 :     return Reference< XAccessible >();
     592             : }
     593             : // -----------------------------------------------------------------------------
     594           0 : Reference< XAccessible > SAL_CALL SvxShowCharSetAcc::getAccessibleSummary(  ) throw (RuntimeException)
     595             : {
     596           0 :     return Reference< XAccessible >();
     597             : }
     598             : // -----------------------------------------------------------------------------
     599           0 : sal_Bool SAL_CALL SvxShowCharSetAcc::isAccessibleSelected( sal_Int32 nRow, sal_Int32 nColumn ) throw (IndexOutOfBoundsException, RuntimeException)
     600             : {
     601           0 :     OExternalLockGuard aGuard( this );
     602           0 :     ensureAlive();
     603           0 :     return m_pParent->getCharSetControl()->GetSelectIndexId() == getAccessibleIndex(nRow,nColumn);
     604             : }
     605             : // -----------------------------------------------------------------------------
     606           0 : sal_Int32 SAL_CALL SvxShowCharSetAcc::getAccessibleIndex( sal_Int32 nRow, sal_Int32 nColumn ) throw (IndexOutOfBoundsException, RuntimeException)
     607             : {
     608           0 :     return (nRow*COLUMN_COUNT) + nColumn;
     609             : }
     610             : // -----------------------------------------------------------------------------
     611           0 : sal_Int32 SAL_CALL SvxShowCharSetAcc::getAccessibleRow( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException)
     612             : {
     613           0 :     OExternalLockGuard aGuard( this );
     614           0 :     ensureAlive();
     615           0 :     return m_pParent->getCharSetControl()->GetRowPos(sal::static_int_cast<sal_uInt16>(nChildIndex));
     616             : }
     617             : // -----------------------------------------------------------------------------
     618           0 : sal_Int32 SAL_CALL SvxShowCharSetAcc::getAccessibleColumn( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException)
     619             : {
     620           0 :     OExternalLockGuard aGuard( this );
     621           0 :     ensureAlive();
     622           0 :     return m_pParent->getCharSetControl()->GetColumnPos(sal::static_int_cast<sal_uInt16>(nChildIndex));
     623             : }
     624             : // -----------------------------------------------------------------------------
     625             : 
     626             : // -----------------------------------------------------------------------------
     627             : // ----------------
     628             : // - SvxShowCharSetItemAcc -
     629             : // ----------------
     630             : 
     631           0 : SvxShowCharSetItemAcc::SvxShowCharSetItemAcc( SvxShowCharSetItem* pParent ) : OAccessibleComponentHelper(new VCLExternalSolarLock())
     632           0 : ,mpParent( pParent )
     633             : {
     634             :     OSL_ENSURE(pParent,"NO parent supplied!");
     635           0 :     osl_atomic_increment(&m_refCount);
     636             :     { // #b6211265 #
     637           0 :         lateInit(this);
     638             :     }
     639           0 :     osl_atomic_decrement(&m_refCount);
     640           0 : }
     641             : 
     642             : // -----------------------------------------------------------------------------
     643             : 
     644           0 : SvxShowCharSetItemAcc::~SvxShowCharSetItemAcc()
     645             : {
     646           0 :     ensureDisposed();
     647           0 :     delete getExternalLock();
     648           0 : }
     649             : // -----------------------------------------------------------------------------
     650           0 : IMPLEMENT_FORWARD_XINTERFACE2( SvxShowCharSetItemAcc, OAccessibleComponentHelper, OAccessibleHelper_Base_2 )
     651           0 : IMPLEMENT_FORWARD_XTYPEPROVIDER2( SvxShowCharSetItemAcc, OAccessibleComponentHelper, OAccessibleHelper_Base_2 )
     652             : // -----------------------------------------------------------------------------
     653             : 
     654           0 : void SvxShowCharSetItemAcc::ParentDestroyed()
     655             : {
     656           0 :     const ::osl::MutexGuard aGuard( GetMutex() );
     657           0 :     mpParent = NULL;
     658           0 : }
     659             : 
     660             : // -----------------------------------------------------------------------------
     661             : 
     662           0 : sal_Int32 SAL_CALL SvxShowCharSetItemAcc::getAccessibleChildCount()
     663             :     throw (uno::RuntimeException)
     664             : {
     665           0 :     return 0;
     666             : }
     667             : 
     668             : // -----------------------------------------------------------------------------
     669             : 
     670           0 : uno::Reference< css::accessibility::XAccessible > SAL_CALL SvxShowCharSetItemAcc::getAccessibleChild( sal_Int32 /*i*/ )
     671             :     throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
     672             : {
     673           0 :     throw lang::IndexOutOfBoundsException();
     674             : }
     675             : 
     676             : // -----------------------------------------------------------------------------
     677             : 
     678           0 : uno::Reference< css::accessibility::XAccessible > SAL_CALL SvxShowCharSetItemAcc::getAccessibleParent()
     679             :     throw (uno::RuntimeException)
     680             : {
     681           0 :     OExternalLockGuard aGuard( this );
     682           0 :     ensureAlive();
     683           0 :     return mpParent->m_pParent;
     684             : }
     685             : 
     686             : // -----------------------------------------------------------------------------
     687             : 
     688           0 : sal_Int16 SAL_CALL SvxShowCharSetItemAcc::getAccessibleRole()
     689             :     throw (uno::RuntimeException)
     690             : {
     691           0 :     return css::accessibility::AccessibleRole::LABEL;
     692             : }
     693             : 
     694             : // -----------------------------------------------------------------------------
     695             : 
     696           0 : ::rtl::OUString SAL_CALL SvxShowCharSetItemAcc::getAccessibleDescription()
     697             :     throw (uno::RuntimeException)
     698             : {
     699           0 :     OExternalLockGuard aGuard( this );
     700           0 :     ensureAlive();
     701           0 :     String sDescription = SVX_RESSTR( RID_SVXSTR_CHARACTER_CODE );
     702             : 
     703           0 :     sal_Unicode c = mpParent->maText.GetChar(0);
     704           0 :     char buf[16] = "0x0000";
     705           0 :     sal_Unicode c_Shifted = c;
     706           0 :     for( int i = 0; i < 4; ++i )
     707             :     {
     708           0 :         char h = (char)(c_Shifted & 0x0F);
     709           0 :         buf[5-i] = (h > 9) ? (h - 10 + 'A') : (h + '0');
     710           0 :         c_Shifted >>= 4;
     711             :     }
     712           0 :     if( c < 256 )
     713           0 :         snprintf( buf+6, 10, " (%d)", c );
     714           0 :     sDescription.AppendAscii(buf);
     715             : 
     716           0 :     return sDescription;
     717             : }
     718             : 
     719             : // -----------------------------------------------------------------------------
     720             : 
     721           0 : ::rtl::OUString SAL_CALL SvxShowCharSetItemAcc::getAccessibleName()
     722             :     throw (uno::RuntimeException)
     723             : {
     724           0 :     OExternalLockGuard aGuard( this );
     725           0 :     ensureAlive();
     726           0 :     String aRet;
     727             : 
     728           0 :     if( mpParent )
     729             :     {
     730           0 :         aRet = mpParent->maText;
     731             : 
     732           0 :         if( !aRet.Len() )
     733           0 :             aRet = getAccessibleDescription();
     734             :     }
     735             : 
     736           0 :     return aRet;
     737             : }
     738             : 
     739             : // -----------------------------------------------------------------------------
     740             : 
     741           0 : uno::Reference< css::accessibility::XAccessibleRelationSet > SAL_CALL SvxShowCharSetItemAcc::getAccessibleRelationSet()
     742             :     throw (uno::RuntimeException)
     743             : {
     744           0 :     return uno::Reference< css::accessibility::XAccessibleRelationSet >();
     745             : }
     746             : 
     747             : // -----------------------------------------------------------------------------
     748             : 
     749           0 : uno::Reference< css::accessibility::XAccessibleStateSet > SAL_CALL SvxShowCharSetItemAcc::getAccessibleStateSet()
     750             :     throw (uno::RuntimeException)
     751             : {
     752           0 :     OExternalLockGuard aGuard( this );
     753           0 :     ensureAlive();
     754             : 
     755           0 :     ::utl::AccessibleStateSetHelper*    pStateSet = new ::utl::AccessibleStateSetHelper;
     756             : 
     757           0 :     if( mpParent )
     758             :     {
     759             :         // SELECTABLE
     760           0 :         pStateSet->AddState( css::accessibility::AccessibleStateType::SELECTABLE );
     761           0 :         pStateSet->AddState( css::accessibility::AccessibleStateType::FOCUSABLE );
     762             : 
     763             :         // SELECTED
     764           0 :         if( mpParent->mrParent.GetSelectIndexId() == mpParent->mnId )
     765             :         {
     766           0 :             pStateSet->AddState( css::accessibility::AccessibleStateType::SELECTED );
     767           0 :                pStateSet->AddState( css::accessibility::AccessibleStateType::FOCUSED );
     768             :         }
     769           0 :         if ( mpParent->mnId >= mpParent->mrParent.FirstInView() && mpParent->mnId <= mpParent->mrParent.LastInView() )
     770           0 :             pStateSet->AddState( AccessibleStateType::VISIBLE );
     771           0 :         pStateSet->AddState( AccessibleStateType::TRANSIENT );
     772             :     }
     773             : 
     774           0 :     return pStateSet;
     775             : }
     776             : 
     777             : // -----------------------------------------------------------------------------
     778           0 : void SAL_CALL SvxShowCharSetItemAcc::grabFocus()
     779             :     throw (uno::RuntimeException)
     780             : {
     781             :     // nothing to do
     782           0 : }
     783             : 
     784             : // -----------------------------------------------------------------------------
     785             : 
     786           0 : uno::Any SAL_CALL SvxShowCharSetItemAcc::getAccessibleKeyBinding()
     787             :     throw (uno::RuntimeException)
     788             : {
     789           0 :     return uno::Any();
     790             : }
     791             : // -----------------------------------------------------------------------------
     792           0 : awt::Rectangle SAL_CALL SvxShowCharSetItemAcc::implGetBounds(  ) throw (RuntimeException)
     793             : {
     794           0 :     awt::Rectangle      aRet;
     795             : 
     796           0 :     if( mpParent )
     797             :     {
     798           0 :         Rectangle   aRect( mpParent->maRect );
     799           0 :         Point       aOrigin;
     800           0 :         Rectangle   aParentRect( aOrigin, mpParent->mrParent.GetOutputSizePixel() );
     801             : 
     802           0 :         aRect.Intersection( aParentRect );
     803             : 
     804           0 :         aRet.X = aRect.Left();
     805           0 :         aRet.Y = aRect.Top();
     806           0 :         aRet.Width = aRect.GetWidth();
     807           0 :         aRet.Height = aRect.GetHeight();
     808             :     }
     809             : 
     810           0 :     return aRet;
     811             : }
     812             : // -----------------------------------------------------------------------------
     813           0 : uno::Reference< css::accessibility::XAccessible > SAL_CALL SvxShowCharSetItemAcc::getAccessibleAtPoint( const awt::Point& /*aPoint*/ )
     814             :     throw (uno::RuntimeException)
     815             : {
     816           0 :     return uno::Reference< css::accessibility::XAccessible >();
     817             : }
     818             : // -----------------------------------------------------------------------------
     819           0 : sal_Int32 SAL_CALL SvxShowCharSetVirtualAcc::getForeground(  ) throw (RuntimeException)
     820             : {
     821           0 :     OExternalLockGuard aGuard( this );
     822             : 
     823           0 :     sal_Int32 nColor = 0;
     824           0 :     if ( mpParent )
     825             :     {
     826           0 :         if ( mpParent->IsControlForeground() )
     827           0 :             nColor = mpParent->GetControlForeground().GetColor();
     828             :         else
     829             :         {
     830           0 :             Font aFont;
     831           0 :             if ( mpParent->IsControlFont() )
     832           0 :                 aFont = mpParent->GetControlFont();
     833             :             else
     834           0 :                 aFont = mpParent->GetFont();
     835           0 :             nColor = aFont.GetColor().GetColor();
     836             :         }
     837             :     }
     838             : 
     839           0 :     return nColor;
     840             : }
     841             : // -----------------------------------------------------------------------------
     842           0 : sal_Int32 SAL_CALL SvxShowCharSetVirtualAcc::getBackground(  ) throw (RuntimeException)
     843             : {
     844           0 :     OExternalLockGuard aGuard( this  );
     845           0 :     sal_Int32 nColor = 0;
     846           0 :     if ( mpParent )
     847             :     {
     848           0 :         if ( mpParent->IsControlBackground() )
     849           0 :             nColor = mpParent->GetControlBackground().GetColor();
     850             :         else
     851           0 :             nColor = mpParent->GetBackground().GetColor().GetColor();
     852             :     }
     853             : 
     854           0 :     return nColor;
     855             : }
     856             : // -----------------------------------------------------------------------------
     857           0 : sal_Int32 SAL_CALL SvxShowCharSetAcc::getForeground(  ) throw (RuntimeException)
     858             : {
     859           0 :     OExternalLockGuard aGuard( this );
     860             : 
     861           0 :     sal_Int32 nColor = 0;
     862           0 :     if ( m_pParent )
     863           0 :         nColor = m_pParent->getForeground();
     864           0 :     return nColor;
     865             : }
     866             : // -----------------------------------------------------------------------------
     867           0 : sal_Int32 SAL_CALL SvxShowCharSetAcc::getBackground(  ) throw (RuntimeException)
     868             : {
     869           0 :     OExternalLockGuard aGuard( this  );
     870           0 :     sal_Int32 nColor = 0;
     871           0 :     if ( m_pParent )
     872           0 :         nColor = m_pParent->getBackground();
     873           0 :     return nColor;
     874             : }
     875             : // -----------------------------------------------------------------------------
     876             : 
     877             : // -----------------------------------------------------------------------------
     878             : } // namespace svx
     879             : // -----------------------------------------------------------------------------
     880             : 
     881             : 
     882             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10