LCOV - code coverage report
Current view: top level - vcl/unx/gtk/a11y - atkselection.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 71 0.0 %
Date: 2012-08-25 Functions: 0 9 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

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

Generated by: LCOV version 1.10