LCOV - code coverage report
Current view: top level - vcl/unx/gtk/a11y - atkfactory.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 49 0.0 %
Date: 2014-04-14 Functions: 0 8 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 <unx/gtk/gtkframe.hxx>
      21             : #include <vcl/window.hxx>
      22             : #include "atkwrapper.hxx"
      23             : #include "atkfactory.hxx"
      24             : #include "atkregistry.hxx"
      25             : 
      26             : using namespace ::com::sun::star;
      27             : 
      28             : extern "C" {
      29             : 
      30             : /*
      31             :  *  Instances of this dummy object class are returned whenever we have to
      32             :  *  create an AtkObject, but can't touch the OOo object anymore since it
      33             :  *  is already disposed.
      34             :  */
      35             : 
      36             : static AtkStateSet *
      37           0 : noop_wrapper_ref_state_set( AtkObject * )
      38             : {
      39           0 :     AtkStateSet *state_set = atk_state_set_new();
      40           0 :     atk_state_set_add_state( state_set, ATK_STATE_DEFUNCT );
      41           0 :     return state_set;
      42             : }
      43             : 
      44             : static void
      45           0 : atk_noop_object_wrapper_class_init(AtkNoOpObjectClass *klass)
      46             : {
      47           0 :     AtkObjectClass *atk_class = ATK_OBJECT_CLASS( klass );
      48           0 :     atk_class->ref_state_set = noop_wrapper_ref_state_set;
      49           0 : }
      50             : 
      51             : static GType
      52           0 : atk_noop_object_wrapper_get_type(void)
      53             : {
      54             :     static GType type = 0;
      55             : 
      56           0 :     if (!type)
      57             :     {
      58             :         static const GTypeInfo typeInfo =
      59             :         {
      60             :             sizeof (AtkNoOpObjectClass),
      61             :             (GBaseInitFunc) NULL,
      62             :             (GBaseFinalizeFunc) NULL,
      63             :             (GClassInitFunc) atk_noop_object_wrapper_class_init,
      64             :             (GClassFinalizeFunc) NULL,
      65             :             NULL,
      66             :             sizeof (AtkObjectWrapper),
      67             :             0,
      68             :             (GInstanceInitFunc) NULL,
      69             :             NULL
      70             :         } ;
      71             : 
      72           0 :         type = g_type_register_static (ATK_TYPE_OBJECT, "OOoAtkNoOpObj", &typeInfo, (GTypeFlags)0) ;
      73             :   }
      74           0 :   return type;
      75             : }
      76             : 
      77             : AtkObject*
      78           0 : atk_noop_object_wrapper_new()
      79             : {
      80             :   AtkObject *accessible;
      81             : 
      82           0 :   accessible = (AtkObject *) g_object_new (atk_noop_object_wrapper_get_type(), NULL);
      83           0 :   g_return_val_if_fail (accessible != NULL, NULL);
      84             : 
      85           0 :   accessible->role = ATK_ROLE_INVALID;
      86           0 :   accessible->layer = ATK_LAYER_INVALID;
      87             : 
      88           0 :   return accessible;
      89             : }
      90             : 
      91             : /*
      92             :  * The wrapper factory
      93             :  */
      94             : 
      95             : static GType
      96           0 : wrapper_factory_get_accessible_type(void)
      97             : {
      98           0 :   return atk_object_wrapper_get_type();
      99             : }
     100             : 
     101             : static AtkObject*
     102           0 : wrapper_factory_create_accessible( GObject *obj )
     103             : {
     104           0 :     GtkWidget* parent_widget = gtk_widget_get_parent( GTK_WIDGET( obj ) );
     105             : 
     106             :     // gail_container_real_remove_gtk tries to re-instanciate an accessible
     107             :     // for a widget that is about to vanish ..
     108           0 :     if( ! parent_widget )
     109           0 :         return atk_noop_object_wrapper_new();
     110             : 
     111           0 :     GtkSalFrame* pFrame = GtkSalFrame::getFromWindow( GTK_WINDOW( parent_widget ) );
     112           0 :     g_return_val_if_fail( pFrame != NULL, NULL );
     113             : 
     114           0 :     Window* pFrameWindow = pFrame->GetWindow();
     115           0 :     if( pFrameWindow )
     116             :     {
     117           0 :         Window* pWindow = pFrameWindow;
     118             : 
     119             :         // skip accessible objects already exposed by the frame objects
     120           0 :         if( WINDOW_BORDERWINDOW == pWindow->GetType() )
     121           0 :             pWindow = pFrameWindow->GetAccessibleChildWindow(0);
     122             : 
     123           0 :         if( pWindow )
     124             :         {
     125           0 :              uno::Reference< accessibility::XAccessible > xAccessible = pWindow->GetAccessible(true);
     126           0 :             if( xAccessible.is() )
     127             :             {
     128           0 :                 AtkObject *accessible = ooo_wrapper_registry_get( xAccessible );
     129             : 
     130           0 :                 if( accessible )
     131           0 :                     g_object_ref( G_OBJECT(accessible) );
     132             :                 else
     133           0 :                     accessible = atk_object_wrapper_new( xAccessible, gtk_widget_get_accessible(parent_widget) );
     134             : 
     135           0 :                 return accessible;
     136           0 :             }
     137             :         }
     138             :     }
     139             : 
     140           0 :     return NULL;
     141             : }
     142             : 
     143             : static void
     144           0 : wrapper_factory_class_init( AtkObjectFactoryClass *klass )
     145             : {
     146           0 :   klass->create_accessible   = wrapper_factory_create_accessible;
     147           0 :   klass->get_accessible_type = wrapper_factory_get_accessible_type;
     148           0 : }
     149             : 
     150             : GType
     151           0 : wrapper_factory_get_type (void)
     152             : {
     153             :   static GType t = 0;
     154             : 
     155           0 :   if (!t) {
     156             :     static const GTypeInfo tinfo =
     157             :     {
     158             :       sizeof (AtkObjectFactoryClass),
     159             :       NULL, NULL, (GClassInitFunc) wrapper_factory_class_init,
     160             :       NULL, NULL, sizeof (AtkObjectFactory), 0, NULL, NULL
     161             :     };
     162             : 
     163             :     t = g_type_register_static (
     164             :         ATK_TYPE_OBJECT_FACTORY, "OOoAtkObjectWrapperFactory",
     165           0 :         &tinfo, (GTypeFlags) 0);
     166             :   }
     167             : 
     168           0 :   return t;
     169             : }
     170             : 
     171             : } // extern C
     172             : 
     173             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10