LCOV - code coverage report
Current view: top level - svx/source/accessibility - AccessibleFrameSelector.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 315 0.0 %
Date: 2012-08-25 Functions: 0 43 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 525 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include "AccessibleFrameSelector.hxx"
      30                 :            : #include <com/sun/star/awt/KeyEvent.hpp>
      31                 :            : #include <com/sun/star/awt/KeyModifier.hpp>
      32                 :            : #include <com/sun/star/awt/Key.hpp>
      33                 :            : #include <com/sun/star/accessibility/AccessibleStateType.hpp>
      34                 :            : #include <com/sun/star/accessibility/AccessibleRelationType.hpp>
      35                 :            : #include <com/sun/star/accessibility/AccessibleRole.hpp>
      36                 :            : #include <com/sun/star/accessibility/AccessibleEventId.hpp>
      37                 :            : #include <com/sun/star/awt/FocusChangeReason.hpp>
      38                 :            : #include <unotools/accessiblestatesethelper.hxx>
      39                 :            : #include <unotools/accessiblerelationsethelper.hxx>
      40                 :            : #include <osl/mutex.hxx>
      41                 :            : #include <vcl/svapp.hxx>
      42                 :            : #include <svx/frmsel.hxx>
      43                 :            : #include <svx/dialmgr.hxx>
      44                 :            : #include "editeng/unolingu.hxx"
      45                 :            : 
      46                 :            : #include <svx/dialogs.hrc>
      47                 :            : #include "frmsel.hrc"
      48                 :            : 
      49                 :            : #ifndef MNEMONIC_CHAR
      50                 :            : #define MNEMONIC_CHAR ((sal_Unicode)'~')
      51                 :            : #endif
      52                 :            : 
      53                 :            : namespace svx {
      54                 :            : namespace a11y {
      55                 :            : 
      56                 :            : using ::rtl::OUString;
      57                 :            : using ::com::sun::star::uno::Any;
      58                 :            : using ::com::sun::star::uno::UNO_QUERY;
      59                 :            : using ::com::sun::star::uno::Reference;
      60                 :            : using ::com::sun::star::uno::Sequence;
      61                 :            : using ::com::sun::star::uno::RuntimeException;
      62                 :            : using ::com::sun::star::uno::XInterface;
      63                 :            : using ::com::sun::star::lang::Locale;
      64                 :            : using ::com::sun::star::lang::EventObject;
      65                 :            : using ::com::sun::star::beans::XPropertyChangeListener;
      66                 :            : using ::com::sun::star::awt::XFocusListener;
      67                 :            : 
      68                 :            : using namespace ::com::sun::star::accessibility;
      69                 :            : 
      70                 :            : namespace AwtKey                    = ::com::sun::star::awt::Key;
      71                 :            : namespace AwtKeyModifier            = ::com::sun::star::awt::KeyModifier;
      72                 :            : namespace AwtFocusChangeReason      = ::com::sun::star::awt::FocusChangeReason;
      73                 :            : 
      74                 :            : typedef ::com::sun::star::awt::Point        AwtPoint;
      75                 :            : typedef ::com::sun::star::awt::Size         AwtSize;
      76                 :            : typedef ::com::sun::star::awt::Rectangle    AwtRectangle;
      77                 :            : typedef ::com::sun::star::awt::KeyEvent     AwtKeyEvent;
      78                 :            : typedef ::com::sun::star::awt::FocusEvent   AwtFocusEvent;
      79                 :            : 
      80                 :            : // ============================================================================
      81                 :            : 
      82                 :          0 : AccFrameSelector::AccFrameSelector( FrameSelector& rFrameSel, FrameBorderType eBorder ) :
      83         [ #  # ]:          0 :     Resource( SVX_RES( RID_SVXSTR_BORDER_CONTROL ) ),
      84                 :            :     mpFrameSel( &rFrameSel ),
      85                 :            :     meBorder( eBorder ),
      86                 :            :     maFocusListeners( maFocusMutex ),
      87                 :            :     maPropertyListeners( maPropertyMutex ),
      88         [ #  # ]:          0 :     maNames( SVX_RES( ARR_TEXTS ) ),
      89         [ #  # ]:          0 :     maDescriptions( SVX_RES(ARR_DESCRIPTIONS ) ),
      90 [ #  # ][ #  # ]:          0 :     mnClientId( 0 )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
      91                 :            : {
      92         [ #  # ]:          0 :     FreeResource();
      93                 :            : 
      94         [ #  # ]:          0 :     if ( mpFrameSel )
      95                 :            :     {
      96 [ #  # ][ #  # ]:          0 :         mpFrameSel->AddEventListener( LINK( this, AccFrameSelector, WindowEventListener ) );
      97                 :            :     }
      98                 :          0 : }
      99                 :            : 
     100                 :            : // ----------------------------------------------------------------------------
     101                 :            : 
     102 [ #  # ][ #  # ]:          0 : AccFrameSelector::~AccFrameSelector()
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     103                 :            : {
     104         [ #  # ]:          0 :     if ( mpFrameSel )
     105                 :            :     {
     106 [ #  # ][ #  # ]:          0 :         mpFrameSel->RemoveEventListener( LINK( this, AccFrameSelector, WindowEventListener ) );
     107                 :            :     }
     108         [ #  # ]:          0 : }
     109                 :            : 
     110                 :            : // ----------------------------------------------------------------------------
     111                 :            : 
     112                 :          0 : Reference< XAccessibleContext > AccFrameSelector::getAccessibleContext(  )
     113                 :            :     throw (RuntimeException)
     114                 :            : {
     115                 :          0 :     return this;
     116                 :            : }
     117                 :            : 
     118                 :            : // ----------------------------------------------------------------------------
     119                 :            : 
     120                 :          0 : sal_Int32 AccFrameSelector::getAccessibleChildCount(  ) throw (RuntimeException)
     121                 :            : {
     122         [ #  # ]:          0 :     SolarMutexGuard aGuard;
     123         [ #  # ]:          0 :     IsValid();
     124 [ #  # ][ #  # ]:          0 :     return (meBorder == FRAMEBORDER_NONE) ? mpFrameSel->GetEnabledBorderCount() : 0;
                 [ #  # ]
     125                 :            : }
     126                 :            : 
     127                 :            : // ----------------------------------------------------------------------------
     128                 :            : 
     129                 :          0 : Reference< XAccessible > AccFrameSelector::getAccessibleChild( sal_Int32 i )
     130                 :            :     throw (RuntimeException)
     131                 :            : {
     132         [ #  # ]:          0 :     SolarMutexGuard aGuard;
     133         [ #  # ]:          0 :     IsValid();
     134                 :          0 :     Reference< XAccessible > xRet;
     135         [ #  # ]:          0 :     if( meBorder == FRAMEBORDER_NONE )
     136 [ #  # ][ #  # ]:          0 :         xRet = mpFrameSel->GetChildAccessible( i );
     137         [ #  # ]:          0 :     if( !xRet.is() )
     138         [ #  # ]:          0 :         throw RuntimeException();
     139         [ #  # ]:          0 :     return xRet;
     140                 :            : }
     141                 :            : 
     142                 :            : // ----------------------------------------------------------------------------
     143                 :            : 
     144                 :          0 : Reference< XAccessible > AccFrameSelector::getAccessibleParent(  )
     145                 :            :     throw (RuntimeException)
     146                 :            : {
     147         [ #  # ]:          0 :     SolarMutexGuard aGuard;
     148         [ #  # ]:          0 :     IsValid();
     149                 :          0 :     Reference< XAccessible > xRet;
     150         [ #  # ]:          0 :     if(meBorder == FRAMEBORDER_NONE)
     151 [ #  # ][ #  # ]:          0 :         xRet = mpFrameSel->GetParent()->GetAccessible( sal_True );
                 [ #  # ]
     152                 :            :     else
     153 [ #  # ][ #  # ]:          0 :         xRet = mpFrameSel->CreateAccessible();
     154         [ #  # ]:          0 :     return xRet;
     155                 :            : }
     156                 :            : 
     157                 :            : // ----------------------------------------------------------------------------
     158                 :            : 
     159                 :          0 : sal_Int32 AccFrameSelector::getAccessibleIndexInParent(  )
     160                 :            :     throw (RuntimeException)
     161                 :            : {
     162         [ #  # ]:          0 :     SolarMutexGuard aGuard;
     163         [ #  # ]:          0 :     IsValid();
     164                 :            : 
     165                 :          0 :     sal_Int32 nIdx = 0;
     166         [ #  # ]:          0 :     if( meBorder == FRAMEBORDER_NONE )
     167                 :            :     {
     168         [ #  # ]:          0 :         Window* pTabPage = mpFrameSel->GetParent();
     169         [ #  # ]:          0 :         sal_Int32 nChildren = pTabPage->GetChildCount();
     170         [ #  # ]:          0 :         for( nIdx = 0; nIdx < nChildren; ++nIdx )
     171 [ #  # ][ #  # ]:          0 :             if( pTabPage->GetChild( static_cast< sal_uInt16 >( nIdx ) ) == mpFrameSel )
     172                 :          0 :                 break;
     173                 :            :     }
     174                 :            :     else
     175         [ #  # ]:          0 :         nIdx = mpFrameSel->GetEnabledBorderIndex( meBorder );
     176                 :            : 
     177         [ #  # ]:          0 :     if( nIdx < 0 )
     178         [ #  # ]:          0 :         throw RuntimeException();
     179         [ #  # ]:          0 :     return nIdx;
     180                 :            : }
     181                 :            : 
     182                 :            : // ----------------------------------------------------------------------------
     183                 :            : 
     184                 :          0 : sal_Int16 AccFrameSelector::getAccessibleRole(  ) throw (RuntimeException)
     185                 :            : {
     186                 :          0 :     return AccessibleRole::OPTION_PANE;
     187                 :            : }
     188                 :            : 
     189                 :            : // ----------------------------------------------------------------------------
     190                 :            : 
     191                 :          0 : OUString AccFrameSelector::getAccessibleDescription(  )
     192                 :            :     throw (RuntimeException)
     193                 :            : {
     194         [ #  # ]:          0 :     SolarMutexGuard aGuard;
     195         [ #  # ]:          0 :     IsValid();
     196 [ #  # ][ #  # ]:          0 :     return maDescriptions.GetString(meBorder);
     197                 :            : }
     198                 :            : 
     199                 :            : // ----------------------------------------------------------------------------
     200                 :            : 
     201                 :          0 : OUString AccFrameSelector::getAccessibleName(  )
     202                 :            :     throw (RuntimeException)
     203                 :            : {
     204         [ #  # ]:          0 :     SolarMutexGuard aGuard;
     205         [ #  # ]:          0 :     IsValid();
     206 [ #  # ][ #  # ]:          0 :     return maNames.GetString(meBorder);
     207                 :            : }
     208                 :            : 
     209                 :            : // ----------------------------------------------------------------------------
     210                 :            : 
     211                 :          0 : Reference< XAccessibleRelationSet > AccFrameSelector::getAccessibleRelationSet(  )
     212                 :            :     throw (RuntimeException)
     213                 :            : {
     214         [ #  # ]:          0 :     SolarMutexGuard aGuard;
     215         [ #  # ]:          0 :     IsValid();
     216                 :            :     utl::AccessibleRelationSetHelper* pHelper;
     217 [ #  # ][ #  # ]:          0 :     Reference< XAccessibleRelationSet > xRet = pHelper = new utl::AccessibleRelationSetHelper;
                 [ #  # ]
     218         [ #  # ]:          0 :     if(meBorder == FRAMEBORDER_NONE)
     219                 :            :     {
     220                 :            :         //add the label relation
     221         [ #  # ]:          0 :         Window* pPrev = mpFrameSel->GetWindow( WINDOW_PREV );
     222 [ #  # ][ #  # ]:          0 :         if(pPrev && WINDOW_FIXEDTEXT == pPrev->GetType())
         [ #  # ][ #  # ]
     223                 :            :         {
     224         [ #  # ]:          0 :             AccessibleRelation aLabelRelation;
     225                 :          0 :             aLabelRelation.RelationType = AccessibleRelationType::LABELED_BY;
     226         [ #  # ]:          0 :             aLabelRelation.TargetSet.realloc(1);
     227 [ #  # ][ #  # ]:          0 :             aLabelRelation.TargetSet.getArray()[0]  = pPrev->GetAccessible();
                 [ #  # ]
     228 [ #  # ][ #  # ]:          0 :             pHelper->AddRelation(aLabelRelation);
     229                 :            :         }
     230                 :            :     }
     231         [ #  # ]:          0 :     return xRet;
     232                 :            : }
     233                 :            : 
     234                 :            : // ----------------------------------------------------------------------------
     235                 :            : 
     236                 :          0 : Reference< XAccessibleStateSet > AccFrameSelector::getAccessibleStateSet(  )
     237                 :            :     throw (RuntimeException)
     238                 :            : {
     239         [ #  # ]:          0 :     SolarMutexGuard aGuard;
     240         [ #  # ]:          0 :     utl::AccessibleStateSetHelper* pStateSetHelper = new utl::AccessibleStateSetHelper;
     241 [ #  # ][ #  # ]:          0 :     Reference< XAccessibleStateSet > xRet = pStateSetHelper;
     242                 :            : 
     243         [ #  # ]:          0 :     if(!mpFrameSel)
     244         [ #  # ]:          0 :         pStateSetHelper->AddState(AccessibleStateType::DEFUNC);
     245                 :            :     else
     246                 :            :     {
     247                 :            :         const sal_Int16 aStandardStates[] =
     248                 :            :         {
     249                 :            :             AccessibleStateType::EDITABLE,
     250                 :            :             AccessibleStateType::FOCUSABLE,
     251                 :            :             AccessibleStateType::MULTI_SELECTABLE,
     252                 :            :             AccessibleStateType::SELECTABLE,
     253                 :            :             AccessibleStateType::SHOWING,
     254                 :            :             AccessibleStateType::VISIBLE,
     255                 :            :             AccessibleStateType::OPAQUE,
     256                 :          0 :             0};
     257                 :          0 :         sal_Int16 nState = 0;
     258         [ #  # ]:          0 :         while(aStandardStates[nState])
     259                 :            :         {
     260         [ #  # ]:          0 :             pStateSetHelper->AddState(aStandardStates[nState++]);
     261                 :            :         }
     262 [ #  # ][ #  # ]:          0 :         if(mpFrameSel->IsEnabled())
     263                 :            :         {
     264         [ #  # ]:          0 :             pStateSetHelper->AddState(AccessibleStateType::ENABLED);
     265         [ #  # ]:          0 :             pStateSetHelper->AddState(AccessibleStateType::SENSITIVE);
     266                 :            :         }
     267                 :            : 
     268                 :          0 :         sal_Bool bIsParent = meBorder == FRAMEBORDER_NONE;
     269 [ #  # ][ #  # ]:          0 :         if(mpFrameSel->HasFocus() &&
         [ #  # ][ #  # ]
                 [ #  # ]
     270         [ #  # ]:          0 :             (bIsParent || mpFrameSel->IsBorderSelected(meBorder)))
     271                 :            :         {
     272         [ #  # ]:          0 :             pStateSetHelper->AddState(AccessibleStateType::ACTIVE);
     273         [ #  # ]:          0 :             pStateSetHelper->AddState(AccessibleStateType::FOCUSED);
     274         [ #  # ]:          0 :             pStateSetHelper->AddState(AccessibleStateType::SELECTED);
     275                 :            :         }
     276                 :            :     }
     277         [ #  # ]:          0 :     return xRet;
     278                 :            : }
     279                 :            : 
     280                 :            : // ----------------------------------------------------------------------------
     281                 :            : 
     282                 :          0 : Locale AccFrameSelector::getLocale(  )
     283                 :            :     throw (IllegalAccessibleComponentStateException, RuntimeException)
     284                 :            : {
     285                 :          0 :     Locale aRet;
     286 [ #  # ][ #  # ]:          0 :     SvxLanguageToLocale( aRet, Application::GetSettings().GetUILanguage() );
                 [ #  # ]
     287                 :          0 :     return aRet;
     288                 :            : }
     289                 :            : 
     290                 :            : // ----------------------------------------------------------------------------
     291                 :            : 
     292                 :          0 : void AccFrameSelector::addPropertyChangeListener(
     293                 :            :     const Reference< XPropertyChangeListener >& xListener )
     294                 :            :         throw (RuntimeException)
     295                 :            : {
     296                 :          0 :     maPropertyListeners.addInterface( xListener );
     297                 :          0 : }
     298                 :            : 
     299                 :            : // ----------------------------------------------------------------------------
     300                 :            : 
     301                 :          0 : void AccFrameSelector::removePropertyChangeListener( const Reference< XPropertyChangeListener >& xListener )
     302                 :            :     throw (RuntimeException)
     303                 :            : {
     304                 :          0 :     maPropertyListeners.removeInterface( xListener );
     305                 :          0 : }
     306                 :            : 
     307                 :            : // ----------------------------------------------------------------------------
     308                 :            : 
     309                 :          0 : sal_Bool AccFrameSelector::containsPoint( const AwtPoint& aPt )
     310                 :            :     throw (RuntimeException)
     311                 :            : {
     312         [ #  # ]:          0 :     SolarMutexGuard aGuard;
     313         [ #  # ]:          0 :     IsValid();
     314                 :            :     //aPt is relative to the frame selector
     315 [ #  # ][ #  # ]:          0 :     return mpFrameSel->ContainsClickPoint( Point( aPt.X, aPt.Y ) );
     316                 :            : }
     317                 :            : 
     318                 :            : // ----------------------------------------------------------------------------
     319                 :            : 
     320                 :          0 : Reference< XAccessible > AccFrameSelector::getAccessibleAtPoint(
     321                 :            :     const AwtPoint& aPt )
     322                 :            :         throw (RuntimeException)
     323                 :            : {
     324         [ #  # ]:          0 :     SolarMutexGuard aGuard;
     325         [ #  # ]:          0 :     IsValid();
     326                 :            :     //aPt is relative to the frame selector
     327 [ #  # ][ #  # ]:          0 :     return mpFrameSel->GetChildAccessible( Point( aPt.X, aPt.Y ) );
     328                 :            : }
     329                 :            : 
     330                 :          0 : AwtRectangle AccFrameSelector::getBounds(  ) throw (RuntimeException)
     331                 :            : {
     332         [ #  # ]:          0 :     SolarMutexGuard aGuard;
     333         [ #  # ]:          0 :     IsValid();
     334                 :          0 :     Size aSz;
     335                 :          0 :     Point aPos;
     336         [ #  # ]:          0 :     switch(meBorder)
     337                 :            :     {
     338                 :            :         case FRAMEBORDER_NONE:
     339         [ #  # ]:          0 :             aSz = mpFrameSel->GetSizePixel();
     340         [ #  # ]:          0 :             aPos = mpFrameSel->GetPosPixel();
     341                 :            :         break;
     342                 :            :         default:
     343         [ #  # ]:          0 :             const Rectangle aSpot = mpFrameSel->GetClickBoundRect( meBorder );
     344                 :          0 :             aPos = aSpot.TopLeft();
     345         [ #  # ]:          0 :             aSz = aSpot.GetSize();
     346                 :            :     }
     347                 :          0 :     AwtRectangle aRet;
     348                 :          0 :     aRet.X = aPos.X();
     349                 :          0 :     aRet.Y = aPos.Y();
     350                 :          0 :     aRet.Width = aSz.Width();
     351                 :          0 :     aRet.Height = aSz.Height();
     352         [ #  # ]:          0 :     return aRet;
     353                 :            : }
     354                 :            : 
     355                 :            : // ----------------------------------------------------------------------------
     356                 :            : 
     357                 :          0 : AwtPoint AccFrameSelector::getLocation(  ) throw (RuntimeException)
     358                 :            : {
     359         [ #  # ]:          0 :     SolarMutexGuard aGuard;
     360         [ #  # ]:          0 :     IsValid();
     361                 :          0 :     Point aPos;
     362         [ #  # ]:          0 :     switch(meBorder)
     363                 :            :     {
     364                 :            :         case FRAMEBORDER_NONE:
     365         [ #  # ]:          0 :             aPos = mpFrameSel->GetPosPixel();
     366                 :            :         break;
     367                 :            :         default:
     368         [ #  # ]:          0 :             const Rectangle aSpot = mpFrameSel->GetClickBoundRect( meBorder );
     369                 :          0 :             aPos = aSpot.TopLeft();
     370                 :            :     }
     371                 :          0 :     AwtPoint aRet(aPos.X(), aPos.Y());
     372         [ #  # ]:          0 :     return aRet;
     373                 :            : }
     374                 :            : 
     375                 :            : // ----------------------------------------------------------------------------
     376                 :            : 
     377                 :          0 : AwtPoint AccFrameSelector::getLocationOnScreen(  ) throw (RuntimeException)
     378                 :            : {
     379         [ #  # ]:          0 :     SolarMutexGuard aGuard;
     380         [ #  # ]:          0 :     IsValid();
     381                 :          0 :     Point aPos;
     382         [ #  # ]:          0 :     switch(meBorder)
     383                 :            :     {
     384                 :            :         case FRAMEBORDER_NONE:
     385         [ #  # ]:          0 :             aPos = mpFrameSel->GetPosPixel();
     386                 :            :         break;
     387                 :            :         default:
     388         [ #  # ]:          0 :             const Rectangle aSpot = mpFrameSel->GetClickBoundRect( meBorder );
     389                 :          0 :             aPos = aSpot.TopLeft();
     390                 :            :     }
     391         [ #  # ]:          0 :     aPos = mpFrameSel->OutputToAbsoluteScreenPixel( aPos );
     392                 :          0 :     AwtPoint aRet(aPos.X(), aPos.Y());
     393         [ #  # ]:          0 :     return aRet;
     394                 :            : }
     395                 :            : 
     396                 :            : // ----------------------------------------------------------------------------
     397                 :            : 
     398                 :          0 : AwtSize AccFrameSelector::getSize(  ) throw (RuntimeException)
     399                 :            : {
     400         [ #  # ]:          0 :     SolarMutexGuard aGuard;
     401         [ #  # ]:          0 :     IsValid();
     402                 :          0 :     Size aSz;
     403         [ #  # ]:          0 :     switch(meBorder)
     404                 :            :     {
     405                 :            :         case FRAMEBORDER_NONE:
     406         [ #  # ]:          0 :             aSz = mpFrameSel->GetSizePixel();
     407                 :            :         break;
     408                 :            :         default:
     409         [ #  # ]:          0 :             const Rectangle aSpot = mpFrameSel->GetClickBoundRect( meBorder );
     410         [ #  # ]:          0 :             aSz = aSpot.GetSize();
     411                 :            :     }
     412                 :          0 :     AwtSize aRet(aSz.Width(), aSz.Height());
     413         [ #  # ]:          0 :     return aRet;
     414                 :            : }
     415                 :            : 
     416                 :            : // ----------------------------------------------------------------------------
     417                 :            : 
     418                 :          0 : sal_Bool AccFrameSelector::isShowing(  ) throw (RuntimeException)
     419                 :            : {
     420         [ #  # ]:          0 :     SolarMutexGuard aGuard;
     421         [ #  # ]:          0 :     IsValid();
     422         [ #  # ]:          0 :     return sal_True;
     423                 :            : }
     424                 :            : 
     425                 :            : // ----------------------------------------------------------------------------
     426                 :            : 
     427                 :          0 : sal_Bool AccFrameSelector::isVisible(  ) throw (RuntimeException)
     428                 :            : {
     429         [ #  # ]:          0 :     SolarMutexGuard aGuard;
     430         [ #  # ]:          0 :     IsValid();
     431         [ #  # ]:          0 :     return sal_True;
     432                 :            : }
     433                 :            : 
     434                 :            : // ----------------------------------------------------------------------------
     435                 :            : 
     436                 :          0 : sal_Bool AccFrameSelector::isFocusTraversable(  ) throw (RuntimeException)
     437                 :            : {
     438         [ #  # ]:          0 :     SolarMutexGuard aGuard;
     439         [ #  # ]:          0 :     IsValid();
     440         [ #  # ]:          0 :     return sal_True;
     441                 :            : }
     442                 :            : 
     443                 :            : // ----------------------------------------------------------------------------
     444                 :            : 
     445                 :          0 : void AccFrameSelector::addFocusListener( const Reference< XFocusListener >& xListener ) throw (RuntimeException)
     446                 :            : {
     447                 :          0 :     maFocusListeners.addInterface( xListener );
     448                 :          0 : }
     449                 :            : 
     450                 :            : // ----------------------------------------------------------------------------
     451                 :            : 
     452                 :          0 : void AccFrameSelector::removeFocusListener( const Reference< XFocusListener >& xListener ) throw (RuntimeException)
     453                 :            : {
     454                 :          0 :     maFocusListeners.removeInterface( xListener );
     455                 :          0 : }
     456                 :            : 
     457                 :            : // ----------------------------------------------------------------------------
     458                 :            : 
     459                 :          0 : void AccFrameSelector::grabFocus(  ) throw (RuntimeException)
     460                 :            : {
     461         [ #  # ]:          0 :     SolarMutexGuard aGuard;
     462         [ #  # ]:          0 :     IsValid();
     463 [ #  # ][ #  # ]:          0 :     mpFrameSel->GrabFocus();
     464                 :          0 : }
     465                 :            : 
     466                 :            : // ----------------------------------------------------------------------------
     467                 :            : 
     468                 :          0 : Any AccFrameSelector::getAccessibleKeyBinding(  ) throw (RuntimeException)
     469                 :            : {
     470                 :          0 :     Any aRet;
     471         [ #  # ]:          0 :     SolarMutexGuard aGuard;
     472         [ #  # ]:          0 :     IsValid();
     473                 :            :     utl::AccessibleRelationSetHelper* pHelper;
     474 [ #  # ][ #  # ]:          0 :     Reference< XAccessibleRelationSet > xRet = pHelper = new utl::AccessibleRelationSetHelper;
                 [ #  # ]
     475         [ #  # ]:          0 :     if(meBorder == FRAMEBORDER_NONE)
     476                 :            :     {
     477         [ #  # ]:          0 :         Window* pPrev = mpFrameSel->GetWindow( WINDOW_PREV );
     478 [ #  # ][ #  # ]:          0 :         if(pPrev && WINDOW_FIXEDTEXT == pPrev->GetType())
         [ #  # ][ #  # ]
     479                 :            :         {
     480         [ #  # ]:          0 :             String sText = pPrev->GetText();
     481         [ #  # ]:          0 :             xub_StrLen nFound = sText.Search( MNEMONIC_CHAR );
     482 [ #  # ][ #  # ]:          0 :             if(STRING_NOTFOUND != nFound && ++nFound < sText.Len())
                 [ #  # ]
     483                 :            :             {
     484         [ #  # ]:          0 :                 sText.ToUpperAscii();
     485                 :          0 :                 sal_Unicode cChar = sText.GetChar(nFound);
     486         [ #  # ]:          0 :                 AwtKeyEvent aEvent;
     487                 :            : 
     488                 :          0 :                 aEvent.KeyCode = 0;
     489                 :          0 :                 aEvent.KeyChar = cChar;
     490                 :          0 :                 aEvent.KeyFunc = 0;
     491 [ #  # ][ #  # ]:          0 :                 if(cChar >= 'A' && cChar <= 'Z')
     492                 :            :                 {
     493                 :          0 :                      aEvent.KeyCode = AwtKey::A + cChar - 'A';
     494                 :            :                 }
     495                 :          0 :                 aEvent.Modifiers = AwtKeyModifier::MOD2;
     496 [ #  # ][ #  # ]:          0 :                 aRet <<= aEvent;
     497         [ #  # ]:          0 :             }
     498                 :            :         }
     499                 :            :     }
     500         [ #  # ]:          0 :     return aRet;
     501                 :            : }
     502                 :            : 
     503                 :            : // ----------------------------------------------------------------------------
     504                 :            : 
     505                 :          0 : sal_Int32 AccFrameSelector::getForeground(  )
     506                 :            :         throw (RuntimeException)
     507                 :            : {
     508                 :          0 :     Any aRet;
     509         [ #  # ]:          0 :     SolarMutexGuard aGuard;
     510         [ #  # ]:          0 :     IsValid();
     511 [ #  # ][ #  # ]:          0 :     return mpFrameSel->GetControlForeground().GetColor();
     512                 :            : }
     513                 :            : 
     514                 :            : // ----------------------------------------------------------------------------
     515                 :            : 
     516                 :          0 : sal_Int32 AccFrameSelector::getBackground(  )
     517                 :            :         throw (RuntimeException)
     518                 :            : {
     519                 :          0 :     Any aRet;
     520         [ #  # ]:          0 :     SolarMutexGuard aGuard;
     521         [ #  # ]:          0 :     IsValid();
     522 [ #  # ][ #  # ]:          0 :     return mpFrameSel->GetControlBackground().GetColor();
     523                 :            : }
     524                 :            : 
     525                 :            : // ----------------------------------------------------------------------------
     526                 :            : 
     527                 :          0 : void AccFrameSelector::addEventListener( const Reference< XAccessibleEventListener >& xListener ) throw (RuntimeException)
     528                 :            : {
     529         [ #  # ]:          0 :     SolarMutexGuard aGuard;
     530                 :            : 
     531         [ #  # ]:          0 :     if ( xListener.is() )
     532                 :            :     {
     533         [ #  # ]:          0 :         if ( !mnClientId )
     534                 :            :         {
     535         [ #  # ]:          0 :             mnClientId = ::comphelper::AccessibleEventNotifier::registerClient();
     536                 :            :         }
     537         [ #  # ]:          0 :         ::comphelper::AccessibleEventNotifier::addEventListener( mnClientId, xListener );
     538         [ #  # ]:          0 :     }
     539                 :          0 : }
     540                 :            : 
     541                 :            : // ----------------------------------------------------------------------------
     542                 :            : 
     543                 :          0 : void AccFrameSelector::removeEventListener( const Reference< XAccessibleEventListener >& xListener ) throw (RuntimeException)
     544                 :            : {
     545         [ #  # ]:          0 :     SolarMutexGuard aGuard;
     546                 :            : 
     547 [ #  # ][ #  # ]:          0 :     if ( xListener.is() && mnClientId != 0 &&
         [ #  # ][ #  # ]
     548         [ #  # ]:          0 :          ::comphelper::AccessibleEventNotifier::removeEventListener( mnClientId, xListener ) == 0 )
     549                 :            :     {
     550                 :            :         // no listeners anymore
     551                 :            :         // -> revoke ourself. This may lead to the notifier thread dying (if we were the last client),
     552                 :            :         // and at least to us not firing any events anymore, in case somebody calls
     553                 :            :         // NotifyAccessibleEvent, again
     554                 :          0 :         ::comphelper::AccessibleEventNotifier::TClientId nId( mnClientId );
     555                 :          0 :         mnClientId = 0;
     556         [ #  # ]:          0 :         ::comphelper::AccessibleEventNotifier::revokeClient( nId );
     557         [ #  # ]:          0 :     }
     558                 :          0 : }
     559                 :            : 
     560                 :            : // ----------------------------------------------------------------------------
     561                 :            : 
     562                 :          0 : OUString AccFrameSelector::getImplementationName(  ) throw (RuntimeException)
     563                 :            : {
     564                 :          0 :     return OUString(RTL_CONSTASCII_USTRINGPARAM("AccFrameSelector"));
     565                 :            : }
     566                 :            : 
     567                 :            : // ----------------------------------------------------------------------------
     568                 :            : 
     569                 :            : const sal_Char sAccessible[]          = "Accessible";
     570                 :            : const sal_Char sAccessibleContext[]   = "AccessibleContext";
     571                 :            : const sal_Char sAccessibleComponent[] = "AccessibleComponent";
     572                 :            : 
     573                 :          0 : sal_Bool AccFrameSelector::supportsService( const OUString& rServiceName )
     574                 :            :     throw (RuntimeException)
     575                 :            : {
     576                 :          0 :     return  rServiceName.equalsAsciiL( sAccessible         , sizeof(sAccessible         )-1 ) ||
     577                 :          0 :             rServiceName.equalsAsciiL( sAccessibleContext  , sizeof(sAccessibleContext  )-1 ) ||
     578         [ #  # ]:          0 :             rServiceName.equalsAsciiL( sAccessibleComponent, sizeof(sAccessibleComponent)-1 );
           [ #  #  #  # ]
     579                 :            : }
     580                 :            : 
     581                 :            : // ----------------------------------------------------------------------------
     582                 :            : 
     583                 :          0 : Sequence< OUString > AccFrameSelector::getSupportedServiceNames(  )
     584                 :            :     throw (RuntimeException)
     585                 :            : {
     586                 :          0 :     Sequence< OUString > aRet(3);
     587         [ #  # ]:          0 :     OUString* pArray = aRet.getArray();
     588         [ #  # ]:          0 :     pArray[0] = OUString( RTL_CONSTASCII_USTRINGPARAM(sAccessible         ) );
     589         [ #  # ]:          0 :     pArray[1] = OUString( RTL_CONSTASCII_USTRINGPARAM(sAccessibleContext  ) );
     590         [ #  # ]:          0 :     pArray[2] = OUString( RTL_CONSTASCII_USTRINGPARAM(sAccessibleComponent) );
     591                 :          0 :     return aRet;
     592                 :            : }
     593                 :            : 
     594                 :            : // ----------------------------------------------------------------------------
     595                 :            : 
     596                 :          0 : void AccFrameSelector::IsValid() throw (RuntimeException)
     597                 :            : {
     598         [ #  # ]:          0 :     if(!mpFrameSel)
     599         [ #  # ]:          0 :         throw RuntimeException();
     600                 :          0 : }
     601                 :            : 
     602                 :            : // ----------------------------------------------------------------------------
     603                 :            : 
     604                 :          0 : void    AccFrameSelector::NotifyFocusListeners(sal_Bool bGetFocus)
     605                 :            : {
     606         [ #  # ]:          0 :     SolarMutexGuard aGuard;
     607         [ #  # ]:          0 :     AwtFocusEvent aEvent;
     608                 :          0 :     aEvent.FocusFlags = 0;
     609         [ #  # ]:          0 :     if(bGetFocus)
     610                 :            :     {
     611         [ #  # ]:          0 :         sal_uInt16 nFocusFlags = mpFrameSel->GetGetFocusFlags();
     612         [ #  # ]:          0 :         if(nFocusFlags&GETFOCUS_TAB)
     613                 :          0 :             aEvent.FocusFlags |= AwtFocusChangeReason::TAB;
     614         [ #  # ]:          0 :         if(nFocusFlags&GETFOCUS_CURSOR)
     615                 :          0 :             aEvent.FocusFlags |= AwtFocusChangeReason::CURSOR;
     616         [ #  # ]:          0 :         if(nFocusFlags&GETFOCUS_MNEMONIC)
     617                 :          0 :             aEvent.FocusFlags |= AwtFocusChangeReason::MNEMONIC;
     618         [ #  # ]:          0 :         if(nFocusFlags&GETFOCUS_FORWARD)
     619                 :          0 :             aEvent.FocusFlags |= AwtFocusChangeReason::FORWARD;
     620         [ #  # ]:          0 :         if(nFocusFlags&GETFOCUS_BACKWARD)
     621                 :          0 :             aEvent.FocusFlags |= AwtFocusChangeReason::BACKWARD;
     622         [ #  # ]:          0 :         if(nFocusFlags&GETFOCUS_AROUND)
     623                 :          0 :             aEvent.FocusFlags |= AwtFocusChangeReason::AROUND;
     624         [ #  # ]:          0 :         if(nFocusFlags&GETFOCUS_UNIQUEMNEMONIC)
     625                 :          0 :             aEvent.FocusFlags |= AwtFocusChangeReason::UNIQUEMNEMONIC;
     626                 :            :     }
     627                 :          0 :     aEvent.Temporary = sal_False;
     628                 :            : 
     629         [ #  # ]:          0 :     Reference < XAccessibleContext > xThis( this );
     630         [ #  # ]:          0 :     aEvent.Source = xThis;
     631                 :            : 
     632         [ #  # ]:          0 :     ::cppu::OInterfaceIteratorHelper aIter( maFocusListeners );
     633         [ #  # ]:          0 :     while( aIter.hasMoreElements() )
     634                 :            :     {
     635 [ #  # ][ #  # ]:          0 :         Reference < XFocusListener > xListener( aIter.next(), UNO_QUERY );
     636         [ #  # ]:          0 :         if(bGetFocus)
     637 [ #  # ][ #  # ]:          0 :             xListener->focusGained( aEvent );
     638                 :            :         else
     639 [ #  # ][ #  # ]:          0 :             xListener->focusLost( aEvent );
     640 [ #  # ][ #  # ]:          0 :     }
                 [ #  # ]
     641                 :          0 : }
     642                 :            : 
     643                 :            : // ----------------------------------------------------------------------------
     644                 :            : 
     645                 :          0 : IMPL_LINK( AccFrameSelector, WindowEventListener, VclSimpleEvent*, pEvent )
     646                 :            : {
     647         [ #  # ]:          0 :     VclWindowEvent* pWinEvent = dynamic_cast< VclWindowEvent* >( pEvent );
     648                 :            :     DBG_ASSERT( pWinEvent, "AccFrameSelector::WindowEventListener - unknown window event" );
     649         [ #  # ]:          0 :     if ( pWinEvent )
     650                 :            :     {
     651                 :          0 :         Window* pWindow = pWinEvent->GetWindow();
     652                 :            :         DBG_ASSERT( pWindow, "AccFrameSelector::WindowEventListener: no window!" );
     653 [ #  # ][ #  # ]:          0 :         if ( !pWindow->IsAccessibilityEventsSuppressed() || ( pWinEvent->GetId() == VCLEVENT_OBJECT_DYING ) )
                 [ #  # ]
     654                 :            :         {
     655                 :          0 :             ProcessWindowEvent( *pWinEvent );
     656                 :            :         }
     657                 :            :     }
     658                 :            : 
     659                 :          0 :     return 0;
     660                 :            : }
     661                 :            : 
     662                 :            : // ----------------------------------------------------------------------------
     663                 :            : 
     664                 :          0 : void AccFrameSelector::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
     665                 :            : {
     666      [ #  #  # ]:          0 :     switch ( rVclWindowEvent.GetId() )
     667                 :            :     {
     668                 :            :         case VCLEVENT_WINDOW_GETFOCUS:
     669                 :            :         {
     670         [ #  # ]:          0 :             if ( meBorder == FRAMEBORDER_NONE )
     671                 :            :             {
     672                 :          0 :                 Any aOldValue, aNewValue;
     673         [ #  # ]:          0 :                 aNewValue <<= AccessibleStateType::FOCUSED;
     674         [ #  # ]:          0 :                 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
     675                 :            :             }
     676                 :            :         }
     677                 :          0 :         break;
     678                 :            :         case VCLEVENT_WINDOW_LOSEFOCUS:
     679                 :            :         {
     680         [ #  # ]:          0 :             if ( meBorder == FRAMEBORDER_NONE )
     681                 :            :             {
     682                 :          0 :                 Any aOldValue, aNewValue;
     683         [ #  # ]:          0 :                 aOldValue <<= AccessibleStateType::FOCUSED;
     684         [ #  # ]:          0 :                 NotifyAccessibleEvent( AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
     685                 :            :             }
     686                 :            :         }
     687                 :          0 :         break;
     688                 :            :         default:
     689                 :            :         {
     690                 :            :         }
     691                 :          0 :         break;
     692                 :            :     }
     693                 :          0 : }
     694                 :            : 
     695                 :            : // ----------------------------------------------------------------------------
     696                 :            : 
     697                 :          0 : void AccFrameSelector::NotifyAccessibleEvent( const sal_Int16 _nEventId,
     698                 :            :     const Any& _rOldValue, const Any& _rNewValue )
     699                 :            : {
     700         [ #  # ]:          0 :     if ( mnClientId )
     701                 :            :     {
     702         [ #  # ]:          0 :         Reference< XInterface > xSource( *this );
     703         [ #  # ]:          0 :         AccessibleEventObject aEvent( xSource, _nEventId, _rNewValue, _rOldValue );
     704 [ #  # ][ #  # ]:          0 :         ::comphelper::AccessibleEventNotifier::addEvent( mnClientId, aEvent );
     705                 :            :     }
     706                 :          0 : }
     707                 :            : 
     708                 :            : // ----------------------------------------------------------------------------
     709                 :            : 
     710                 :          0 : void AccFrameSelector::Invalidate()
     711                 :            : {
     712                 :          0 :     mpFrameSel = 0;
     713         [ #  # ]:          0 :     EventObject aEvent;
     714         [ #  # ]:          0 :     Reference < XAccessibleContext > xThis( this );
     715         [ #  # ]:          0 :     aEvent.Source = xThis;
     716         [ #  # ]:          0 :     maFocusListeners.disposeAndClear( aEvent );
     717 [ #  # ][ #  # ]:          0 :     maPropertyListeners.disposeAndClear( aEvent );
     718                 :          0 : }
     719                 :            : 
     720                 :            : // ============================================================================
     721                 :            : 
     722                 :            : } // namespace a11y
     723                 :            : } // namespace svx
     724                 :            : 
     725                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10