1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: atkfactory.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_vcl.hxx"
34 #include <plugins/gtk/gtkframe.hxx>
35 #include <vcl/window.hxx>
36 #include "atkwrapper.hxx"
37 #include "atkfactory.hxx"
38 #include "atkregistry.hxx"
40 using namespace ::com::sun::star
;
45 * Instances of this dummy object class are returned whenever we have to
46 * create an AtkObject, but can't touch the OOo object anymore since it
47 * is already disposed.
51 noop_wrapper_ref_state_set( AtkObject
* )
53 AtkStateSet
*state_set
= atk_state_set_new();
54 atk_state_set_add_state( state_set
, ATK_STATE_DEFUNCT
);
59 atk_noop_object_wrapper_class_init(AtkNoOpObjectClass
*klass
)
61 AtkObjectClass
*atk_class
= ATK_OBJECT_CLASS( klass
);
62 atk_class
->ref_state_set
= noop_wrapper_ref_state_set
;
66 atk_noop_object_wrapper_get_type(void)
68 static GType type
= 0;
72 static const GTypeInfo typeInfo
=
74 sizeof (AtkNoOpObjectClass
),
76 (GBaseFinalizeFunc
) NULL
,
77 (GClassInitFunc
) atk_noop_object_wrapper_class_init
,
78 (GClassFinalizeFunc
) NULL
,
80 sizeof (AtkObjectWrapper
),
82 (GInstanceInitFunc
) NULL
,
86 type
= g_type_register_static (ATK_TYPE_OBJECT
, "OOoAtkNoOpObj", &typeInfo
, (GTypeFlags
)0) ;
92 atk_noop_object_wrapper_new()
94 AtkObject
*accessible
;
96 accessible
= (AtkObject
*) g_object_new (atk_noop_object_wrapper_get_type(), NULL
);
97 g_return_val_if_fail (accessible
!= NULL
, NULL
);
99 accessible
->role
= ATK_ROLE_INVALID
;
100 accessible
->layer
= ATK_LAYER_INVALID
;
106 * The wrapper factory
110 wrapper_factory_get_accessible_type(void)
112 return atk_object_wrapper_get_type();
116 wrapper_factory_create_accessible( GObject
*obj
)
118 GtkWidget
* parent_widget
= gtk_widget_get_parent( GTK_WIDGET( obj
) );
120 // gail_container_real_remove_gtk tries to re-instanciate an accessible
121 // for a widget that is about to vanish ..
122 if( ! parent_widget
)
123 return atk_noop_object_wrapper_new();
125 GtkSalFrame
* pFrame
= GtkSalFrame::getFromWindow( GTK_WINDOW( parent_widget
) );
126 g_return_val_if_fail( pFrame
!= NULL
, NULL
);
128 Window
* pFrameWindow
= pFrame
->GetWindow();
131 Window
* pWindow
= pFrameWindow
;
133 // skip accessible objects already exposed by the frame objects
134 if( WINDOW_BORDERWINDOW
== pWindow
->GetType() )
135 pWindow
= pFrameWindow
->GetAccessibleChildWindow(0);
139 uno::Reference
< accessibility::XAccessible
> xAccessible
= pWindow
->GetAccessible(true);
140 if( xAccessible
.is() )
142 AtkObject
*accessible
= ooo_wrapper_registry_get( xAccessible
);
145 g_object_ref( G_OBJECT(accessible
) );
147 accessible
= atk_object_wrapper_new( xAccessible
, gtk_widget_get_accessible(parent_widget
) );
158 wrapper_factory_class_init( AtkObjectFactoryClass
*klass
)
160 klass
->create_accessible
= wrapper_factory_create_accessible
;
161 klass
->get_accessible_type
= wrapper_factory_get_accessible_type
;
165 wrapper_factory_get_type (void)
170 static const GTypeInfo tinfo
=
172 sizeof (AtkObjectFactoryClass
),
173 NULL
, NULL
, (GClassInitFunc
) wrapper_factory_class_init
,
174 NULL
, NULL
, sizeof (AtkObjectFactory
), 0, NULL
, NULL
177 t
= g_type_register_static (
178 ATK_TYPE_OBJECT_FACTORY
, "OOoAtkObjectWrapperFactory",
179 &tinfo
, (GTypeFlags
) 0);