LCOV - code coverage report
Current view: top level - vcl/unx/gtk/a11y - atkhypertext.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 102 0.0 %
Date: 2014-04-14 Functions: 0 17 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/XAccessibleHypertext.hpp>
      23             : 
      24             : #include <stdio.h>
      25             : 
      26             : using namespace ::com::sun::star;
      27             : 
      28             : // ---------------------- AtkHyperlink ----------------------
      29             : 
      30             : typedef struct {
      31             :     AtkHyperlink atk_hyper_link;
      32             : 
      33             :     uno::Reference< accessibility::XAccessibleHyperlink > xLink;
      34             : } HyperLink;
      35             : 
      36             : static uno::Reference< accessibility::XAccessibleHyperlink >
      37           0 :     getHyperlink( AtkHyperlink *pHyperlink )
      38             : {
      39           0 :     HyperLink *pLink = (HyperLink *) pHyperlink;
      40           0 :     return pLink->xLink;
      41             : }
      42             : 
      43             : static GObjectClass *hyper_parent_class = NULL;
      44             : 
      45             : extern "C" {
      46             : 
      47             : static void
      48           0 : hyper_link_finalize (GObject *obj)
      49             : {
      50           0 :     HyperLink *hl = (HyperLink *) obj;
      51           0 :     hl->xLink.clear();
      52           0 :     hyper_parent_class->finalize (obj);
      53           0 : }
      54             : 
      55             : static gchar *
      56           0 : hyper_link_get_uri( AtkHyperlink *pLink,
      57             :                     gint          i )
      58             : {
      59             :     try {
      60           0 :         uno::Any aAny = getHyperlink( pLink )->getAccessibleActionObject( i );
      61           0 :         OUString aUri = aAny.get< OUString > ();
      62           0 :         return OUStringToGChar(aUri);
      63             :     }
      64           0 :     catch(const uno::Exception&) {
      65           0 :         g_warning( "Exception in hyper_link_get_uri" );
      66             :     }
      67           0 :     return NULL;
      68             : }
      69             : 
      70             : static AtkObject *
      71           0 : hyper_link_get_object( AtkHyperlink *pLink,
      72             :                        gint          i)
      73             : {
      74             :     try {
      75           0 :         uno::Any aAny = getHyperlink( pLink )->getAccessibleActionObject( i );
      76           0 :         uno::Reference< accessibility::XAccessible > xObj( aAny, uno::UNO_QUERY_THROW );
      77           0 :         return atk_object_wrapper_ref( xObj );
      78             :     }
      79           0 :     catch(const uno::Exception&) {
      80           0 :         g_warning( "Exception in hyper_link_get_object" );
      81             :     }
      82           0 :     return NULL;
      83             : }
      84             : static gint
      85           0 : hyper_link_get_end_index( AtkHyperlink *pLink )
      86             : {
      87             :     try {
      88           0 :         return getHyperlink( pLink )->getEndIndex();
      89             :     }
      90           0 :     catch(const uno::Exception&) {
      91             :     }
      92           0 :     return -1;
      93             : }
      94             : static gint
      95           0 : hyper_link_get_start_index( AtkHyperlink *pLink )
      96             : {
      97             :     try {
      98           0 :         return getHyperlink( pLink )->getStartIndex();
      99             :     }
     100           0 :     catch(const uno::Exception&) {
     101             :     }
     102           0 :     return -1;
     103             : }
     104             : static gboolean
     105           0 : hyper_link_is_valid( AtkHyperlink *pLink )
     106             : {
     107             :     try {
     108           0 :         return getHyperlink( pLink )->isValid();
     109             :     }
     110           0 :     catch(const uno::Exception&) {
     111             :     }
     112           0 :     return FALSE;
     113             : }
     114             : static gint
     115           0 : hyper_link_get_n_anchors( AtkHyperlink *pLink )
     116             : {
     117             :     try {
     118           0 :         return getHyperlink( pLink )->getAccessibleActionCount();
     119             :     }
     120           0 :     catch(const uno::Exception&) {
     121             :     }
     122           0 :     return 0;
     123             : }
     124             : 
     125             : static guint
     126           0 : hyper_link_link_state( AtkHyperlink * )
     127             : {
     128           0 :     g_warning( "FIXME: hyper_link_link_state unimplemented" );
     129           0 :     return 0;
     130             : }
     131             : static gboolean
     132           0 : hyper_link_is_selected_link( AtkHyperlink * )
     133             : {
     134           0 :     g_warning( "FIXME: hyper_link_is_selected_link unimplemented" );
     135           0 :     return FALSE;
     136             : }
     137             : 
     138             : static void
     139           0 : hyper_link_class_init (AtkHyperlinkClass *klass)
     140             : {
     141           0 :     GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
     142             : 
     143           0 :     gobject_class->finalize = hyper_link_finalize;
     144             : 
     145           0 :     hyper_parent_class = (GObjectClass *)g_type_class_peek_parent (klass);
     146             : 
     147           0 :     klass->get_uri = hyper_link_get_uri;
     148           0 :     klass->get_object = hyper_link_get_object;
     149           0 :     klass->get_end_index = hyper_link_get_end_index;
     150           0 :     klass->get_start_index = hyper_link_get_start_index;
     151           0 :     klass->is_valid = hyper_link_is_valid;
     152           0 :     klass->get_n_anchors = hyper_link_get_n_anchors;
     153           0 :     klass->link_state = hyper_link_link_state;
     154           0 :     klass->is_selected_link = hyper_link_is_selected_link;
     155           0 : }
     156             : 
     157             : static GType
     158           0 : hyper_link_get_type (void)
     159             : {
     160             :     static GType type = 0;
     161             : 
     162           0 :     if (!type) {
     163             :         static const GTypeInfo tinfo = {
     164             :             sizeof (AtkHyperlinkClass),
     165             :             NULL,               /* base init */
     166             :             NULL,               /* base finalize */
     167             :             (GClassInitFunc) hyper_link_class_init,
     168             :             NULL,               /* class finalize */
     169             :             NULL,               /* class data */
     170             :             sizeof (HyperLink), /* instance size */
     171             :             0,                  /* nb preallocs */
     172             :             NULL,               /* instance init */
     173             :             NULL                /* value table */
     174             :         };
     175             : 
     176             :         static const GInterfaceInfo atk_action_info = {
     177             :             (GInterfaceInitFunc) actionIfaceInit,
     178             :             (GInterfaceFinalizeFunc) NULL,
     179             :             NULL
     180             :         };
     181             : 
     182             :         type = g_type_register_static (ATK_TYPE_HYPERLINK,
     183             :                                        "OOoAtkObjHyperLink", &tinfo,
     184           0 :                                        (GTypeFlags)0);
     185             :         g_type_add_interface_static (type, ATK_TYPE_ACTION,
     186           0 :                                      &atk_action_info);
     187             :     }
     188             : 
     189           0 :     return type;
     190             : }
     191             : 
     192             : // ---------------------- AtkHyperText ----------------------
     193             : 
     194             : static accessibility::XAccessibleHypertext*
     195           0 :     getHypertext( AtkHypertext *pHypertext ) throw (uno::RuntimeException)
     196             : {
     197           0 :     AtkObjectWrapper *pWrap = ATK_OBJECT_WRAPPER( pHypertext );
     198           0 :     if( pWrap )
     199             :     {
     200           0 :         if( !pWrap->mpHypertext && pWrap->mpContext )
     201             :         {
     202           0 :             uno::Any any = pWrap->mpContext->queryInterface( cppu::UnoType<accessibility::XAccessibleHypertext>::get() );
     203           0 :             pWrap->mpHypertext = reinterpret_cast< accessibility::XAccessibleHypertext * > (any.pReserved);
     204           0 :             pWrap->mpHypertext->acquire();
     205             :         }
     206             : 
     207           0 :         return pWrap->mpHypertext;
     208             :     }
     209             : 
     210           0 :     return NULL;
     211             : }
     212             : 
     213             : static AtkHyperlink *
     214           0 : hypertext_get_link( AtkHypertext *hypertext,
     215             :                     gint          link_index)
     216             : {
     217             :     try {
     218           0 :         accessibility::XAccessibleHypertext* pHypertext = getHypertext( hypertext );
     219           0 :         if( pHypertext )
     220             :         {
     221           0 :             HyperLink *pLink = (HyperLink *)g_object_new( hyper_link_get_type(), NULL );
     222           0 :             pLink->xLink = pHypertext->getHyperLink( link_index );
     223           0 :             if( !pLink->xLink.is() ) {
     224           0 :                 g_object_unref( G_OBJECT( pLink ) );
     225           0 :                 pLink = NULL;
     226             :             }
     227           0 :             return ATK_HYPERLINK( pLink );
     228             :         }
     229             :     }
     230           0 :     catch(const uno::Exception&) {
     231           0 :         g_warning( "Exception in getHyperLink()" );
     232             :     }
     233             : 
     234           0 :     return NULL;
     235             : }
     236             : 
     237             : static gint
     238           0 : hypertext_get_n_links( AtkHypertext *hypertext )
     239             : {
     240             :     try {
     241           0 :         accessibility::XAccessibleHypertext* pHypertext = getHypertext( hypertext );
     242           0 :         if( pHypertext )
     243           0 :             return pHypertext->getHyperLinkCount();
     244             :     }
     245           0 :     catch(const uno::Exception&) {
     246           0 :         g_warning( "Exception in getHyperLinkCount()" );
     247             :     }
     248             : 
     249           0 :     return 0;
     250             : }
     251             : 
     252             : static gint
     253           0 : hypertext_get_link_index( AtkHypertext *hypertext,
     254             :                           gint          index)
     255             : {
     256             :     try {
     257           0 :         accessibility::XAccessibleHypertext* pHypertext = getHypertext( hypertext );
     258           0 :         if( pHypertext )
     259           0 :             return pHypertext->getHyperLinkIndex( index );
     260             :     }
     261           0 :     catch(const uno::Exception&) {
     262           0 :         g_warning( "Exception in getHyperLinkIndex()" );
     263             :     }
     264             : 
     265           0 :     return 0;
     266             : }
     267             : 
     268             : } // extern "C"
     269             : 
     270             : void
     271           0 : hypertextIfaceInit (AtkHypertextIface *iface)
     272             : {
     273           0 :   g_return_if_fail (iface != NULL);
     274             : 
     275           0 :   iface->get_link = hypertext_get_link;
     276           0 :   iface->get_n_links = hypertext_get_n_links;
     277           0 :   iface->get_link_index = hypertext_get_link_index;
     278             : }
     279             : 
     280             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10