LCOV - code coverage report
Current view: top level - svtools/source/brwbox - editbrowsebox2.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 1 80 1.2 %
Date: 2015-06-13 12:38:46 Functions: 2 13 15.4 %
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 <svtools/editbrowsebox.hxx>
      21             : #include <com/sun/star/accessibility/XAccessible.hpp>
      22             : #include <com/sun/star/accessibility/AccessibleEventId.hpp>
      23             : #include "editbrowseboximpl.hxx"
      24             : #include <comphelper/types.hxx>
      25             : #include <toolkit/helper/vclunohelper.hxx>
      26             : #include "svtaccessiblefactory.hxx"
      27             : 
      28             : namespace svt
      29             : {
      30             :     using namespace com::sun::star::accessibility;
      31             :     using namespace com::sun::star::uno;
      32             :     using namespace ::com::sun::star::accessibility::AccessibleEventId;
      33             : 
      34             : 
      35           0 : Reference< XAccessible > EditBrowseBox::CreateAccessibleCheckBoxCell(long _nRow, sal_uInt16 _nColumnPos,const TriState& eState)
      36             : {
      37           0 :     Reference< XAccessible > xAccessible( GetAccessible() );
      38           0 :     Reference< XAccessibleContext > xAccContext;
      39           0 :     if ( xAccessible.is() )
      40           0 :         xAccContext = xAccessible->getAccessibleContext();
      41             : 
      42           0 :     Reference< XAccessible > xReturn;
      43           0 :     if ( xAccContext.is() )
      44             :     {
      45           0 :         xReturn = getAccessibleFactory().createAccessibleCheckBoxCell(
      46           0 :             xAccContext->getAccessibleChild( ::svt::BBINDEX_TABLE ),
      47             :             *this,
      48             :             NULL,
      49             :             _nRow,
      50             :             _nColumnPos,
      51             :             eState,
      52             :             true
      53           0 :         );
      54             :     }
      55           0 :     return xReturn;
      56             : }
      57             : 
      58           0 : Reference< XAccessible > EditBrowseBox::CreateAccessibleCell( sal_Int32 _nRow, sal_uInt16 _nColumnPos )
      59             : {
      60           0 :     return BrowseBox::CreateAccessibleCell( _nRow, _nColumnPos );
      61             : }
      62             : 
      63           0 : sal_Int32 EditBrowseBox::GetAccessibleControlCount() const
      64             : {
      65           0 :     return IsEditing() ? 1 : 0;
      66             : }
      67             : 
      68           0 : void EditBrowseBox::implCreateActiveAccessible( )
      69             : {
      70             :     DBG_ASSERT( IsEditing(), "EditBrowseBox::implCreateActiveAccessible: not to be called if we're not editing currently!" );
      71             :     DBG_ASSERT( !m_aImpl->m_xActiveCell.is(), "EditBrowseBox::implCreateActiveAccessible: not to be called if the old one is still alive!" );
      72             : 
      73           0 :     if ( !m_aImpl->m_xActiveCell.is() && IsEditing() )
      74             :     {
      75           0 :          Reference< XAccessible > xCont = aController->GetWindow().GetAccessible();
      76           0 :          Reference< XAccessible > xMy = GetAccessible();
      77           0 :          if ( xMy.is() && xCont.is() )
      78             :           {
      79           0 :              m_aImpl->m_xActiveCell = getAccessibleFactory().createEditBrowseBoxTableCellAccess(
      80             :                  xMy,                                                       // parent accessible
      81             :                  xCont,                                                     // control accessible
      82           0 :                  VCLUnoHelper::GetInterface( &aController->GetWindow() ),   // focus window (for notifications)
      83             :                  *this,                                                     // the browse box
      84           0 :                  GetCurRow(),
      85           0 :                  GetColumnPos( GetCurColumnId() )
      86           0 :              );
      87             : 
      88           0 :              commitBrowseBoxEvent( CHILD, makeAny( m_aImpl->m_xActiveCell ), Any() );
      89           0 :           }
      90             :     }
      91           0 : }
      92             : 
      93             : 
      94           0 : Reference< XAccessible > EditBrowseBox::CreateAccessibleControl( sal_Int32
      95             : #ifdef DBG_UTIL
      96             : _nIndex
      97             : #endif
      98             : )
      99             : {
     100             :     DBG_ASSERT( 0 == _nIndex, "EditBrowseBox::CreateAccessibleControl: invalid index!" );
     101             : 
     102           0 :     if ( isAccessibleAlive() )
     103             :     {
     104           0 :         if ( !m_aImpl->m_xActiveCell.is() )
     105           0 :             implCreateActiveAccessible();
     106             :     }
     107             : 
     108           0 :     return m_aImpl->m_xActiveCell;
     109             : }
     110             : 
     111           0 : Reference<XAccessible > EditBrowseBox::CreateAccessibleRowHeader( sal_Int32 _nRow )
     112             : {
     113           0 :     return BrowseBox::CreateAccessibleRowHeader( _nRow );
     114             : }
     115             : 
     116           0 : void EditBrowseBoxImpl::clearActiveCell()
     117             : {
     118             :     try
     119             :     {
     120           0 :         ::comphelper::disposeComponent(m_xActiveCell);
     121             :     }
     122           0 :     catch(const Exception&)
     123             :     {
     124             :         OSL_FAIL( "EditBrowseBoxImpl::clearActiveCell: caught an exception while disposing the AccessibleCell!" );
     125             :     }
     126             : 
     127           0 :     m_xActiveCell = NULL;
     128           0 : }
     129             : 
     130           0 : void EditBrowseBox::GrabTableFocus()
     131             : {
     132           0 :     if ( aController.Is() )
     133           0 :         aController->GetWindow().GrabFocus();
     134           0 : }
     135             : 
     136           0 : void EditBrowseBox::DetermineFocus( const GetFocusFlags _nGetFocusFlags )
     137             : {
     138           0 :     bool bFocus = false;
     139           0 :     for (vcl::Window* pWindow = Application::GetFocusWindow();
     140           0 :          pWindow && !bFocus;
     141             :          pWindow = pWindow->GetParent())
     142           0 :          bFocus = pWindow == this;
     143             : 
     144           0 :     if (bFocus != bHasFocus)
     145             :     {
     146           0 :         bHasFocus = bFocus;
     147             : 
     148           0 :         if ( GetBrowserFlags( ) & EditBrowseBoxFlags::SMART_TAB_TRAVEL )
     149             :         {
     150           0 :             if  (   bHasFocus                           // we got the focus
     151           0 :                 &&  ( _nGetFocusFlags & GetFocusFlags::Tab )  // using the TAB key
     152             :                 )
     153             :             {
     154           0 :                 long nRows = GetRowCount();
     155           0 :                 sal_uInt16 nCols = ColCount();
     156             : 
     157           0 :                 if ( ( nRows > 0 ) && ( nCols > 0 ) )
     158             :                 {
     159           0 :                     if ( _nGetFocusFlags & GetFocusFlags::Forward )
     160             :                     {
     161           0 :                         if ( GetColumnId( 0 ) != HandleColumnId )
     162             :                         {
     163           0 :                             GoToRowColumnId( 0, GetColumnId( 0 ) );
     164             :                         }
     165             :                         else
     166             :                         {   // the first column is the handle column -> not focussable
     167           0 :                             if ( nCols > 1 )
     168           0 :                                 GoToRowColumnId( 0, GetColumnId( 1 ) );
     169             :                         }
     170             :                     }
     171           0 :                     else if ( _nGetFocusFlags & GetFocusFlags::Backward )
     172             :                     {
     173           0 :                         GoToRowColumnId( nRows - 1, GetColumnId( nCols -1 ) );
     174             :                     }
     175             :                 }
     176             :             }
     177             :         }
     178             :     }
     179           0 : }
     180             : 
     181           0 : Rectangle EditBrowseBox::GetFieldCharacterBounds(sal_Int32 _nRow,sal_Int32 _nColumnPos,sal_Int32 _nIndex)
     182             : {
     183           0 :     Rectangle aRect;
     184           0 :     if ( SeekRow(_nRow) )
     185             :     {
     186             :         CellController* pController = GetController(
     187           0 :             _nRow, GetColumnId( sal::static_int_cast< sal_uInt16 >(_nColumnPos) ) );
     188           0 :         if ( pController )
     189           0 :             aRect = pController->GetWindow().GetCharacterBounds(_nIndex);
     190             :     }
     191           0 :     return aRect;
     192             : }
     193             : 
     194           0 : sal_Int32 EditBrowseBox::GetFieldIndexAtPoint(sal_Int32 _nRow,sal_Int32 _nColumnPos,const Point& _rPoint)
     195             : {
     196           0 :     sal_Int32 nRet = -1;
     197           0 :     if ( SeekRow(_nRow) )
     198             :     {
     199             :         CellController* pController = GetController(
     200           0 :             _nRow, GetColumnId( sal::static_int_cast< sal_uInt16 >(_nColumnPos) ) );
     201           0 :         if ( pController )
     202           0 :             nRet = pController->GetWindow().GetIndexForPoint(_rPoint);
     203             :     }
     204           0 :     return nRet;
     205             : }
     206             : 
     207             : 
     208         798 : } // namespace svt
     209             : 
     210             : 
     211             : 
     212             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11