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

Generated by: LCOV version 1.11