1#Copyright (C) 2008 Codethink Ltd
2#Copyright (c) 2012 SUSE LINUX Products GmbH, Nuernberg, Germany.
3
4#This library is free software; you can redistribute it and/or
5#modify it under the terms of the GNU Lesser General Public
6#License version 2 as published by the Free Software Foundation.
7
8#This program is distributed in the hope that it will be useful,
9#but WITHOUT ANY WARRANTY; without even the implied warranty of
10#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11#GNU General Public License for more details.
12#You should have received a copy of the GNU Lesser General Public License
13#along with this program; if not, write to the Free Software
14#Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15
16from gi.repository import Atspi
17from pyatspi.utils import *
18from pyatspi.interface import *
19
20__all__ = [
21           "Hypertext",
22          ]
23
24#------------------------------------------------------------------------------
25
26class Hypertext(interface):
27        """
28        An interface used for objects which implement linking between
29        multiple resource or content locations, or multiple 'markers'
30        within a single document. A Hypertext instance is associated
31        with one or more Hyperlinks, which are associated with particular
32        offsets within the Hypertext's included content.
33        """
34
35        def getLink(self, index):
36                """
37                Get one of the Hyperlinks associated with this Hypertext object,
38                by index.
39                @param : linkIndex
40                an integer from 0 to getNLinks() - 1.
41                @return the Hyperlink in this Hypertext object.
42                """
43                return Atspi.Hypertext.get_link(self.obj, index)
44
45        def getLinkIndex(self, character_index):
46                """
47                Get the hyperlink index, if any, associated with a particular
48                character offset in the Hypertext object. For Hypertext implementors
49                without textual content, all hyperlinks are associated with character
50                offset '0'.
51                @return the index of the Hyperlink associated with character
52                offset characterIndex, or -1 if no Hyperlink is associated with
53                that character offset.
54                """
55                return Atspi.Hypertext.get_link_index(self.obj, character_index)
56
57        def getNLinks(self):
58                """
59                Query the hypertext object for the number of Hyperlinks it contains.
60                @return the number of Hyperlinks associated with this Hypertext
61                object, as a long integer.
62                """
63                return Atspi.Hypertext.get_n_links(self.obj)
64
65#END----------------------------------------------------------------------------
66