Fixed bug 85980.
[platform/core/uifw/at-spi2-atk.git] / cspi / spi_hyperlink.c
1 /*
2  * AT-SPI - Assistive Technology Service Provider Interface
3  * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
4  *
5  * Copyright 2001 Sun Microsystems Inc.
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Library General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Library General Public License for more details.
16  *
17  * You should have received a copy of the GNU Library General Public
18  * License along with this library; if not, write to the
19  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20  * Boston, MA 02111-1307, USA.
21  */
22
23 #include <cspi/spi-private.h>
24
25 /**
26  * AccessibleHyperlink_ref:
27  * @obj: a pointer to the #AccessibleHyperlink object on which to operate.
28  *
29  * Increment the reference count for an #AccessibleHyperlink object.
30  **/
31 void
32 AccessibleHyperlink_ref (AccessibleHyperlink *obj)
33 {
34   cspi_object_ref (obj);
35 }
36
37 /**
38  * AccessibleHyperlink_unref:
39  * @obj: a pointer to the #AccessibleHyperlink object on which to operate.
40  *
41  * Decrement the reference count for an #AccessibleHyperlink object.
42  **/
43 void
44 AccessibleHyperlink_unref (AccessibleHyperlink *obj)
45 {
46   cspi_object_ref (obj);
47 }
48
49 /**
50  * AccessibleHyperlink_getNAnchors:
51  * @obj: a pointer to the #AccessibleHyperlink object on which to operate.
52  *
53  * Get the total number of anchors which an #AccessibleHyperlink implementor has.
54  *       Though typical hyperlinks have only one anchor, client-side image maps and
55  *       other hypertext objects may potentially activate or refer to multiple
56  *       URIs.  For each anchor there is a corresponding URI and object.
57  * @see AccessibleHyperlink_getURI() and AccessibleHyperlink_getObject().
58  *
59  * Returns: a #long indicating the number of anchors in this hyperlink.
60  **/
61 long
62 AccessibleHyperlink_getNAnchors (AccessibleHyperlink *obj)
63 {
64   long retval;
65
66   cspi_return_val_if_fail (obj != NULL, -1);
67
68   retval =
69     Accessibility_Hyperlink__get_nAnchors (CSPI_OBJREF (obj), cspi_ev ());
70
71   cspi_return_val_if_ev ("getNAnchors", -1);
72
73   return retval;
74 }
75
76 /**
77  * AccessibleHyperlink_getURI:
78  * @obj: a pointer to the #AccessibleHyperlink implementor on which to operate.
79  * @i: a (zero-index) long integer indicating which hyperlink anchor to query.
80  *
81  * Get the URI associated with a particular hyperlink anchor.  
82  *
83  * Returns: a UTF-8 string giving the URI of the @ith hyperlink anchor.
84  **/
85 char *
86 AccessibleHyperlink_getURI (AccessibleHyperlink *obj,
87                             long int             i)
88 {
89   char *retval;
90
91   cspi_return_val_if_fail (obj != NULL, NULL);
92
93   retval =
94     Accessibility_Hyperlink_getURI (CSPI_OBJREF (obj),
95                                     i, cspi_ev ());
96
97   cspi_return_val_if_ev ("getURI", NULL);
98
99   return retval;
100 }
101
102 /**
103  * AccessibleHyperlink_getObject:
104  * @obj: a pointer to the #AccessibleHyperlink implementor on which to operate.
105  * @i: a (zero-index) long integer indicating which hyperlink anchor to query.
106  *
107  * Get the object associated with a particular hyperlink anchor, as an #Accessible. 
108  *
109  * Returns: an #Accessible that represents the object associated with the @ith anchor
110  *        of the specified #AccessibleHyperlink.
111  **/
112 Accessible*
113 AccessibleHyperlink_getObject (AccessibleHyperlink *obj,
114                                long int             i)
115 {
116   cspi_return_val_if_fail (obj != NULL, NULL);
117
118   return cspi_object_add (
119     Accessibility_Hyperlink_getObject (CSPI_OBJREF (obj),
120                                        i, cspi_ev ()));
121 }
122
123 /**
124  * AccessibleHyperlink_getIndexRange:
125  * @obj: a pointer to the #AccessibleHyperlink implementor on which to operate.
126  * @startIndex: a pointer to a long integer into which the starting
127  *       offset of the text associated with this #AccessibleHyperlink is returned.
128  * @endIndex: a pointer to a long integer into which the offset of the first character
129  *       after the text associated with this #AccessibleHyperlink is returned.
130  *
131  *
132  * Get the starting and ending character offsets of the text range associated with
133  *       a #AccessibleHyperlink, in its originating #AccessibleHypertext.
134  **/
135 void
136 AccessibleHyperlink_getIndexRange (AccessibleHyperlink *obj,
137                                    long int *startIndex,
138                                    long int *endIndex)
139 {
140   CORBA_long si, ei;
141
142   cspi_return_if_fail (obj != NULL);
143
144 si = Accessibility_Hyperlink__get_startIndex (CSPI_OBJREF (obj), cspi_ev ());
145  cspi_return_if_ev ("startIndex");
146  ei = Accessibility_Hyperlink__get_endIndex (CSPI_OBJREF (obj), cspi_ev ());
147
148  cspi_return_if_ev ("endIndex");
149  *startIndex = si;
150  *endIndex = ei; 
151 }
152
153 /**
154  * AccessibleHyperlink_isValid:
155  * @obj: a pointer to the #AccessibleHyperlink on which to operate.
156  *
157  * Tell whether an #AccessibleHyperlink object is still valid with respect to its
158  *          originating hypertext object.
159  *
160  * Returns: #TRUE of the specified #AccessibleHyperlink is still valid with respect
161  *          to its originating #AccessibleHypertext object, #FALSE otherwise.
162  **/
163 SPIBoolean
164 AccessibleHyperlink_isValid (AccessibleHyperlink *obj)
165 {
166   SPIBoolean retval;
167
168   cspi_return_val_if_fail (obj != NULL, FALSE);
169
170   retval =
171     Accessibility_Hyperlink_isValid (CSPI_OBJREF (obj), cspi_ev ());
172
173   cspi_return_val_if_ev ("isValid", FALSE);
174
175   return retval;
176 }
177
178