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

Generated by: LCOV version 1.11