LCOV - code coverage report
Current view: top level - vcl/unx/gtk/a11y - atkselection.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 0 71 0.0 %
Date: 2014-11-03 Functions: 0 9 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             : #include "atkwrapper.hxx"
      21             : 
      22             : #include <com/sun/star/accessibility/XAccessibleSelection.hpp>
      23             : 
      24             : #include <stdio.h>
      25             : 
      26             : using namespace ::com::sun::star;
      27             : 
      28             : static accessibility::XAccessibleSelection*
      29           0 :     getSelection( AtkSelection *pSelection ) throw (uno::RuntimeException)
      30             : {
      31           0 :     AtkObjectWrapper *pWrap = ATK_OBJECT_WRAPPER( pSelection );
      32           0 :     if( pWrap )
      33             :     {
      34           0 :         if( !pWrap->mpSelection && pWrap->mpContext )
      35             :         {
      36           0 :             uno::Any any = pWrap->mpContext->queryInterface( cppu::UnoType<accessibility::XAccessibleSelection>::get() );
      37           0 :             pWrap->mpSelection = reinterpret_cast< accessibility::XAccessibleSelection * > (any.pReserved);
      38           0 :             pWrap->mpSelection->acquire();
      39             :         }
      40             : 
      41           0 :         return pWrap->mpSelection;
      42             :     }
      43             : 
      44           0 :     return NULL;
      45             : }
      46             : 
      47             : extern "C" {
      48             : 
      49             : static gboolean
      50           0 : selection_add_selection( AtkSelection *selection,
      51             :                          gint          i )
      52             : {
      53             :     try {
      54           0 :         accessibility::XAccessibleSelection* pSelection = getSelection( selection );
      55           0 :         if( pSelection )
      56             :         {
      57           0 :             pSelection->selectAccessibleChild( i );
      58           0 :             return TRUE;
      59             :         }
      60             :     }
      61           0 :     catch(const uno::Exception&) {
      62           0 :         g_warning( "Exception in selectAccessibleChild()" );
      63             :     }
      64             : 
      65           0 :     return FALSE;
      66             : }
      67             : 
      68             : static gboolean
      69           0 : selection_clear_selection( AtkSelection *selection )
      70             : {
      71             :     try {
      72           0 :         accessibility::XAccessibleSelection* pSelection = getSelection( selection );
      73           0 :         if( pSelection )
      74             :         {
      75           0 :             pSelection->clearAccessibleSelection();
      76           0 :             return TRUE;
      77             :         }
      78             :     }
      79           0 :     catch(const uno::Exception&) {
      80           0 :         g_warning( "Exception in selectAccessibleChild()" );
      81             :     }
      82             : 
      83           0 :     return FALSE;
      84             : }
      85             : 
      86             : static AtkObject*
      87           0 : selection_ref_selection( AtkSelection *selection,
      88             :                          gint          i )
      89             : {
      90             :     try {
      91           0 :         accessibility::XAccessibleSelection* pSelection = getSelection( selection );
      92           0 :         if( pSelection )
      93           0 :             return atk_object_wrapper_ref( pSelection->getSelectedAccessibleChild( i ) );
      94             :     }
      95           0 :     catch(const uno::Exception&) {
      96           0 :         g_warning( "Exception in getSelectedAccessibleChild()" );
      97             :     }
      98             : 
      99           0 :     return NULL;
     100             : }
     101             : 
     102             : static gint
     103           0 : selection_get_selection_count( AtkSelection   *selection)
     104             : {
     105             :     try {
     106           0 :         accessibility::XAccessibleSelection* pSelection = getSelection( selection );
     107           0 :         if( pSelection )
     108           0 :             return pSelection->getSelectedAccessibleChildCount();
     109             :     }
     110           0 :     catch(const uno::Exception&) {
     111           0 :         g_warning( "Exception in getSelectedAccessibleChildCount()" );
     112             :     }
     113             : 
     114           0 :     return -1;
     115             : }
     116             : 
     117             : static gboolean
     118           0 : selection_is_child_selected( AtkSelection   *selection,
     119             :                               gint           i)
     120             : {
     121             :     try {
     122           0 :         accessibility::XAccessibleSelection* pSelection = getSelection( selection );
     123           0 :         if( pSelection )
     124           0 :             return pSelection->isAccessibleChildSelected( i );
     125             :     }
     126           0 :     catch(const uno::Exception&) {
     127           0 :         g_warning( "Exception in getSelectedAccessibleChildCount()" );
     128             :     }
     129             : 
     130           0 :     return FALSE;
     131             : }
     132             : 
     133             : static gboolean
     134           0 : selection_remove_selection( AtkSelection *selection,
     135             :                             gint           i )
     136             : {
     137             :     try {
     138           0 :         accessibility::XAccessibleSelection* pSelection = getSelection( selection );
     139           0 :         if( pSelection )
     140             :         {
     141           0 :             pSelection->deselectAccessibleChild( i );
     142           0 :             return TRUE;
     143             :         }
     144             :     }
     145           0 :     catch(const uno::Exception&) {
     146           0 :         g_warning( "Exception in getSelectedAccessibleChildCount()" );
     147             :     }
     148             : 
     149           0 :     return FALSE;
     150             : }
     151             : 
     152             : static gboolean
     153           0 : selection_select_all_selection( AtkSelection   *selection)
     154             : {
     155             :     try {
     156           0 :         accessibility::XAccessibleSelection* pSelection = getSelection( selection );
     157           0 :         if( pSelection )
     158             :         {
     159           0 :             pSelection->selectAllAccessibleChildren();
     160           0 :             return TRUE;
     161             :         }
     162             :     }
     163           0 :     catch(const uno::Exception&) {
     164           0 :         g_warning( "Exception in getSelectedAccessibleChildCount()" );
     165             :     }
     166             : 
     167           0 :     return FALSE;
     168             : }
     169             : 
     170             : } // extern "C"
     171             : 
     172             : void
     173           0 : selectionIfaceInit( AtkSelectionIface *iface)
     174             : {
     175           0 :   g_return_if_fail (iface != NULL);
     176             : 
     177           0 :   iface->add_selection = selection_add_selection;
     178           0 :   iface->clear_selection = selection_clear_selection;
     179           0 :   iface->ref_selection = selection_ref_selection;
     180           0 :   iface->get_selection_count = selection_get_selection_count;
     181           0 :   iface->is_child_selected = selection_is_child_selected;
     182           0 :   iface->remove_selection = selection_remove_selection;
     183           0 :   iface->select_all_selection = selection_select_all_selection;
     184             : }
     185             : 
     186             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10