X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=libspi%2Fhypertext.c;h=3aac466b5a3329df78c747d006dc0fef92883ca4;hb=68b558bcef701bc71b1b7e53f68935f9c632fcdb;hp=17d3b4de05f30800b3b311c152fcff7a7595e897;hpb=a0661d5d4128769f2544d24430c80dc440bfdbba;p=platform%2Fcore%2Fuifw%2Fat-spi2-atk.git diff --git a/libspi/hypertext.c b/libspi/hypertext.c index 17d3b4d..3aac466 100644 --- a/libspi/hypertext.c +++ b/libspi/hypertext.c @@ -2,7 +2,7 @@ * AT-SPI - Assistive Technology Service Provider Interface * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap) * - * Copyright 2001 Sun Microsystems Inc. + * Copyright 2001 Sun Microsystems Inc, Ximian Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -24,39 +24,45 @@ #include #include +#include #include #include -/* Static function declarations */ - -static GObjectClass *parent_class; - -static void -spi_hypertext_finalize (GObject *obj) -{ - parent_class->finalize (obj); -} - SpiHypertext * spi_hypertext_interface_new (AtkObject *obj) { SpiHypertext *new_hypertext = g_object_new (SPI_HYPERTEXT_TYPE, NULL); - (SPI_TEXT (new_hypertext))->atko = obj; - g_object_ref (obj); + + spi_text_construct (SPI_TEXT (new_hypertext), obj); + return new_hypertext; } +static AtkHypertext * +get_hypertext_from_servant (PortableServer_Servant servant) +{ + SpiBase *object = SPI_BASE (bonobo_object_from_servant (servant)); + + if (!object) + { + return NULL; + } + + return ATK_HYPERTEXT (object->atko); +} + static CORBA_long -impl_getNLinks (PortableServer_Servant _servant, - CORBA_Environment * ev) +impl_getNLinks (PortableServer_Servant servant, + CORBA_Environment *ev) { - SpiHypertext *hypertext = SPI_HYPERTEXT (bonobo_object_from_servant(_servant)); - return (CORBA_long) - atk_hypertext_get_n_links (ATK_HYPERTEXT ((SPI_TEXT (hypertext))->atko)); -} + AtkHypertext *hypertext = get_hypertext_from_servant (servant); + g_return_val_if_fail (hypertext != NULL, 0); + + return (CORBA_long) atk_hypertext_get_n_links (hypertext); +} static Accessibility_Hyperlink @@ -65,41 +71,39 @@ impl_getLink (PortableServer_Servant servant, CORBA_Environment *ev) { AtkHyperlink *link; - SpiHypertext *hypertext; Accessibility_Hyperlink rv; - - hypertext = SPI_HYPERTEXT (bonobo_object_from_servant (servant)); + AtkHypertext *hypertext = get_hypertext_from_servant (servant); - link = atk_hypertext_get_link ( - ATK_HYPERTEXT ((SPI_TEXT (hypertext))->atko), linkIndex); + g_return_val_if_fail (hypertext != NULL, CORBA_OBJECT_NIL); + + link = atk_hypertext_get_link (hypertext, linkIndex); + g_return_val_if_fail (link != NULL, CORBA_OBJECT_NIL); - rv = bonobo_object_corba_objref (BONOBO_OBJECT ( - spi_hyperlink_new (ATK_OBJECT (link)))); + rv = BONOBO_OBJREF (spi_hyperlink_new (ATK_OBJECT (link))); - return rv; + return CORBA_Object_duplicate (rv, ev); } - static CORBA_long -impl_getLinkIndex (PortableServer_Servant _servant, - const CORBA_long characterIndex, - CORBA_Environment * ev) +impl_getLinkIndex (PortableServer_Servant servant, + const CORBA_long characterIndex, + CORBA_Environment *ev) { - SpiHypertext *hypertext = SPI_HYPERTEXT(bonobo_object_from_servant(_servant)); + AtkHypertext *hypertext = get_hypertext_from_servant (servant); + + g_return_val_if_fail (hypertext != NULL, 0); + return (CORBA_long) - atk_hypertext_get_link_index (ATK_HYPERTEXT ((SPI_TEXT (hypertext))->atko), + atk_hypertext_get_link_index (hypertext, (gint) characterIndex); } + static void spi_hypertext_class_init (SpiHypertextClass *klass) { - GObjectClass * object_class = (GObjectClass *) klass; POA_Accessibility_Hypertext__epv *epv = &klass->epv; - parent_class = g_type_class_peek_parent (klass); - - object_class->finalize = spi_hypertext_finalize; /* Initialize epv table */ @@ -108,11 +112,13 @@ spi_hypertext_class_init (SpiHypertextClass *klass) epv->getLinkIndex = impl_getLinkIndex; } + static void spi_hypertext_init (SpiHypertext *hypertext) { } + BONOBO_TYPE_FUNC_FULL (SpiHypertext, Accessibility_Hypertext, BONOBO_TYPE_OBJECT,