LCOV - code coverage report
Current view: top level - vcl/source/window - legacyaccessibility.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 75 96 78.1 %
Date: 2014-11-03 Functions: 7 7 100.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             : #include <tools/debug.hxx>
      21             : 
      22             : #include <svdata.hxx>
      23             : 
      24             : #include <dlgctrl.hxx>
      25             : #include <vcl/event.hxx>
      26             : #include <vcl/fixed.hxx>
      27             : #include <vcl/layout.hxx>
      28             : #include <vcl/svapp.hxx>
      29             : #include <vcl/tabpage.hxx>
      30             : #include <vcl/tabctrl.hxx>
      31             : #include <vcl/tabdlg.hxx>
      32             : #include <vcl/button.hxx>
      33             : #include <vcl/settings.hxx>
      34             : #include <vcl/unohelp.hxx>
      35             : 
      36             : #include <com/sun/star/i18n/XCharacterClassification.hpp>
      37             : 
      38             : using namespace ::com::sun::star;
      39             : 
      40             : 
      41           4 : static vcl::Window* ImplGetLabelFor( vcl::Window* pFrameWindow, WindowType nMyType, vcl::Window* pLabel, sal_Unicode nAccel )
      42             : {
      43           4 :     vcl::Window* pWindow = NULL;
      44             : 
      45           4 :     if( nMyType == WINDOW_FIXEDTEXT     ||
      46           0 :         nMyType == WINDOW_FIXEDLINE     ||
      47             :         nMyType == WINDOW_GROUPBOX )
      48             :     {
      49             :         // #i100833# MT 2010/02: Group box and fixed lines can also lable a fixed text.
      50             :         // See tools/options/print for example.
      51           4 :         bool bThisIsAGroupControl = (nMyType == WINDOW_GROUPBOX) || (nMyType == WINDOW_FIXEDLINE);
      52             :         // get index, form start and form end
      53           4 :         sal_uInt16 nIndex=0, nFormStart=0, nFormEnd=0;
      54             :         ::ImplFindDlgCtrlWindow( pFrameWindow,
      55             :                                            pLabel,
      56             :                                            nIndex,
      57             :                                            nFormStart,
      58           4 :                                            nFormEnd );
      59           4 :         if( nAccel )
      60             :         {
      61             :             // find the accelerated window
      62             :             pWindow = ::ImplFindAccelWindow( pFrameWindow,
      63             :                                              nIndex,
      64             :                                              nAccel,
      65             :                                              nFormStart,
      66             :                                              nFormEnd,
      67           0 :                                              false );
      68             :         }
      69             :         else
      70             :         {
      71             :             // find the next control; if that is a fixed text
      72             :             // fixed line or group box, then return NULL
      73           8 :             while( nIndex < nFormEnd )
      74             :             {
      75           0 :                 nIndex++;
      76             :                 vcl::Window* pSWindow = ::ImplGetChildWindow( pFrameWindow,
      77             :                                                  nIndex,
      78             :                                                  nIndex,
      79           0 :                                                  false );
      80           0 :                 if( pSWindow && isVisibleInLayout(pSWindow) && ! (pSWindow->GetStyle() & WB_NOLABEL) )
      81             :                 {
      82           0 :                     WindowType nType = pSWindow->GetType();
      83           0 :                     if( nType != WINDOW_FIXEDTEXT   &&
      84           0 :                         nType != WINDOW_FIXEDLINE   &&
      85             :                         nType != WINDOW_GROUPBOX )
      86             :                     {
      87           0 :                         pWindow = pSWindow;
      88             :                     }
      89           0 :                     else if( bThisIsAGroupControl && ( nType == WINDOW_FIXEDTEXT ) )
      90             :                     {
      91           0 :                         pWindow = pSWindow;
      92             :                     }
      93           0 :                     break;
      94             :                 }
      95             :             }
      96             :         }
      97             :     }
      98             : 
      99           4 :     return pWindow;
     100             : }
     101             : 
     102             : namespace vcl {
     103             : 
     104       18640 : Window* Window::getLegacyNonLayoutAccessibleRelationLabelFor() const
     105             : {
     106       18640 :     Window* pWindow = NULL;
     107       18640 :     Window* pFrameWindow = ImplGetFrameWindow();
     108             : 
     109       18640 :     WinBits nFrameStyle = pFrameWindow->GetStyle();
     110       18640 :     if( ! ( nFrameStyle & WB_DIALOGCONTROL )
     111           2 :         || ( nFrameStyle & WB_NODIALOGCONTROL )
     112             :         )
     113       18638 :         return NULL;
     114             : 
     115           2 :     if ( mpWindowImpl->mpRealParent )
     116           2 :         pWindow = mpWindowImpl->mpRealParent->GetParentLabelFor( this );
     117             : 
     118           2 :     if( pWindow )
     119           0 :         return pWindow;
     120             : 
     121           2 :     sal_Unicode nAccel = getAccel( GetText() );
     122             : 
     123           2 :     pWindow = ImplGetLabelFor( pFrameWindow, GetType(), const_cast<Window*>(this), nAccel );
     124           2 :     if( ! pWindow && mpWindowImpl->mpRealParent )
     125           2 :         pWindow = ImplGetLabelFor( mpWindowImpl->mpRealParent, GetType(), const_cast<Window*>(this), nAccel );
     126           2 :     return pWindow;
     127             : }
     128             : 
     129       12088 : static Window* ImplGetLabeledBy( Window* pFrameWindow, WindowType nMyType, Window* pLabeled )
     130             : {
     131       12088 :     Window* pWindow = NULL;
     132       12088 :     if ( (nMyType != WINDOW_GROUPBOX) && (nMyType != WINDOW_FIXEDLINE) )
     133             :     {
     134             :         // search for a control that labels this window
     135             :         // a label is considered the last fixed text, fixed line or group box
     136             :         // that comes before this control; with the exception of push buttons
     137             :         // which are labeled only if the fixed text, fixed line or group box
     138             :         // is directly before the control
     139             : 
     140             :         // get form start and form end and index of this control
     141             :         sal_uInt16 nIndex, nFormStart, nFormEnd;
     142             :         Window* pSWindow = ::ImplFindDlgCtrlWindow( pFrameWindow,
     143             :                                                     pLabeled,
     144             :                                                     nIndex,
     145             :                                                     nFormStart,
     146       12088 :                                                     nFormEnd );
     147       12088 :         if( pSWindow && nIndex != nFormStart )
     148             :         {
     149        1267 :             if( nMyType == WINDOW_PUSHBUTTON        ||
     150        1267 :                 nMyType == WINDOW_HELPBUTTON        ||
     151        1267 :                 nMyType == WINDOW_OKBUTTON      ||
     152             :                 nMyType == WINDOW_CANCELBUTTON )
     153             :             {
     154           0 :                 nFormStart = nIndex-1;
     155             :             }
     156        2778 :             for( sal_uInt16 nSearchIndex = nIndex-1; nSearchIndex >= nFormStart; nSearchIndex-- )
     157             :             {
     158        1389 :                 sal_uInt16 nFoundIndex = 0;
     159             :                 pSWindow = ::ImplGetChildWindow( pFrameWindow,
     160             :                                                  nSearchIndex,
     161             :                                                  nFoundIndex,
     162        1389 :                                                  false );
     163        1389 :                 if( pSWindow && isVisibleInLayout(pSWindow) && !(pSWindow->GetStyle() & WB_NOLABEL) )
     164             :                 {
     165        1389 :                     WindowType nType = pSWindow->GetType();
     166        1389 :                     if ( ( nType == WINDOW_FIXEDTEXT    ||
     167        1389 :                           nType == WINDOW_FIXEDLINE ||
     168             :                           nType == WINDOW_GROUPBOX ) )
     169             :                     {
     170             :                         // a fixed text can't be labeld by a fixed text.
     171           0 :                         if ( ( nMyType != WINDOW_FIXEDTEXT ) || ( nType != WINDOW_FIXEDTEXT ) )
     172           0 :                             pWindow = pSWindow;
     173        1267 :                         break;
     174             :                     }
     175             :                 }
     176        1389 :                 if( nFoundIndex > nSearchIndex || nSearchIndex == 0 )
     177             :                     break;
     178             :             }
     179             :         }
     180             :     }
     181       12088 :     return pWindow;
     182             : }
     183             : 
     184        6044 : Window* Window::getLegacyNonLayoutAccessibleRelationLabeledBy() const
     185             : {
     186        6044 :     Window* pWindow = NULL;
     187        6044 :     Window* pFrameWindow = ImplGetFrameWindow();
     188             : 
     189        6044 :     if ( mpWindowImpl->mpRealParent )
     190             :     {
     191        6044 :         pWindow = mpWindowImpl->mpRealParent->GetParentLabeledBy( this );
     192             : 
     193        6044 :         if( pWindow )
     194           0 :             return pWindow;
     195             :     }
     196             : 
     197             :     // #i62723#, #104191# checkboxes and radiobuttons are not supposed to have labels
     198        6044 :     if( GetType() == WINDOW_CHECKBOX || GetType() == WINDOW_RADIOBUTTON )
     199           0 :         return NULL;
     200             : 
     201             : //    if( ! ( GetType() == WINDOW_FIXEDTEXT     ||
     202             : //            GetType() == WINDOW_FIXEDLINE     ||
     203             : //            GetType() == WINDOW_GROUPBOX ) )
     204             :     // #i100833# MT 2010/02: Group box and fixed lines can also lable a fixed text.
     205             :     // See tools/options/print for example.
     206             : 
     207        6044 :     pWindow = ImplGetLabeledBy( pFrameWindow, GetType(), const_cast<Window*>(this) );
     208        6044 :     if( ! pWindow && mpWindowImpl->mpRealParent )
     209        6044 :         pWindow = ImplGetLabeledBy( mpWindowImpl->mpRealParent, GetType(), const_cast<Window*>(this) );
     210             : 
     211        6044 :     return pWindow;
     212             : }
     213             : 
     214          10 : Window* Window::getLegacyNonLayoutAccessibleRelationMemberOf() const
     215             : {
     216          10 :     Window* pWindow = NULL;
     217          10 :     Window* pFrameWindow = GetParent();
     218          10 :     if ( !pFrameWindow )
     219             :     {
     220           0 :         pFrameWindow = ImplGetFrameWindow();
     221             :     }
     222             :     // if( ! ( GetType() == WINDOW_FIXEDTEXT        ||
     223          20 :     if( !( GetType() == WINDOW_FIXEDLINE ||
     224          10 :         GetType() == WINDOW_GROUPBOX ) )
     225             :     {
     226             :         // search for a control that makes member of this window
     227             :         // it is considered the last fixed line or group box
     228             :         // that comes before this control; with the exception of push buttons
     229             :         // which are labeled only if the fixed line or group box
     230             :         // is directly before the control
     231             :         // get form start and form end and index of this control
     232             :         sal_uInt16 nIndex, nFormStart, nFormEnd;
     233             :         Window* pSWindow = ::ImplFindDlgCtrlWindow( pFrameWindow,
     234             :             const_cast<Window*>(this),
     235             :             nIndex,
     236             :             nFormStart,
     237          10 :             nFormEnd );
     238          10 :         if( pSWindow && nIndex != nFormStart )
     239             :         {
     240           6 :             if( GetType() == WINDOW_PUSHBUTTON      ||
     241           4 :                 GetType() == WINDOW_HELPBUTTON      ||
     242           6 :                 GetType() == WINDOW_OKBUTTON        ||
     243           2 :                 GetType() == WINDOW_CANCELBUTTON )
     244             :             {
     245           0 :                 nFormStart = nIndex-1;
     246             :             }
     247           8 :             for( sal_uInt16 nSearchIndex = nIndex-1; nSearchIndex >= nFormStart; nSearchIndex-- )
     248             :             {
     249           4 :                 sal_uInt16 nFoundIndex = 0;
     250             :                 pSWindow = ::ImplGetChildWindow( pFrameWindow,
     251             :                     nSearchIndex,
     252             :                     nFoundIndex,
     253           4 :                     false );
     254           8 :                 if( pSWindow && pSWindow->IsVisible() &&
     255           8 :                     ( pSWindow->GetType() == WINDOW_FIXEDLINE   ||
     256           4 :                     pSWindow->GetType() == WINDOW_GROUPBOX ) )
     257             :                 {
     258           0 :                     pWindow = pSWindow;
     259           2 :                     break;
     260             :                 }
     261           4 :                 if( nFoundIndex > nSearchIndex || nSearchIndex == 0 )
     262             :                     break;
     263             :             }
     264             :         }
     265             :     }
     266          10 :     return pWindow;
     267             : }
     268             : 
     269        1233 : } /* namespace vcl */
     270             : 
     271             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10