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

Generated by: LCOV version 1.10