source: trunk/third/at-spi/cspi/spi_text.c @ 18688

Revision 18688, 24.8 KB checked in by ghudson, 21 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r18687, which included commits to RCS files with non-trunk default branches.
Line 
1/*
2 * AT-SPI - Assistive Technology Service Provider Interface
3 * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
4 *
5 * Copyright 2001, 2002 Sun Microsystems Inc.,
6 * Copyright 2001, 2002 Ximian, Inc.
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16 * Library General Public License for more details.
17 *
18 * You should have received a copy of the GNU Library General Public
19 * License along with this library; if not, write to the
20 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 * Boston, MA 02111-1307, USA.
22 */
23
24#include <cspi/spi-private.h>
25
26static Accessibility_TEXT_BOUNDARY_TYPE
27get_accessible_text_boundary_type (AccessibleTextBoundaryType type)
28{
29  switch (type)
30    {
31    case SPI_TEXT_BOUNDARY_CHAR:
32      return Accessibility_TEXT_BOUNDARY_CHAR;
33      break;
34    case SPI_TEXT_BOUNDARY_CURSOR_POS:
35      /* FixME */
36      return Accessibility_TEXT_BOUNDARY_CHAR;
37      break;
38    case SPI_TEXT_BOUNDARY_WORD_START:
39      return Accessibility_TEXT_BOUNDARY_WORD_START;
40      break;
41    case SPI_TEXT_BOUNDARY_WORD_END:
42      return Accessibility_TEXT_BOUNDARY_WORD_END;
43      break;
44    case SPI_TEXT_BOUNDARY_SENTENCE_START:
45      return Accessibility_TEXT_BOUNDARY_SENTENCE_START;
46      break;
47    case SPI_TEXT_BOUNDARY_SENTENCE_END:
48      return Accessibility_TEXT_BOUNDARY_SENTENCE_END;
49      break;
50    case SPI_TEXT_BOUNDARY_LINE_START:
51      return Accessibility_TEXT_BOUNDARY_LINE_START;
52      break;
53    case SPI_TEXT_BOUNDARY_LINE_END:
54      return Accessibility_TEXT_BOUNDARY_LINE_END;
55      break;
56    case SPI_TEXT_BOUNDARY_ATTRIBUTE_RANGE:
57      /* Fixme */
58      return Accessibility_TEXT_BOUNDARY_CHAR;
59      break;
60    }
61  /* FIXME */
62  return Accessibility_TEXT_BOUNDARY_CHAR;
63}
64
65static Accessibility_TEXT_CLIP_TYPE
66get_accessible_text_clip_type (AccessibleTextClipType type)
67{
68  switch (type)
69    {
70    case SPI_TEXT_CLIP_NONE:
71      return Accessibility_TEXT_CLIP_NONE;
72      break;
73    case SPI_TEXT_CLIP_MIN:
74      return Accessibility_TEXT_CLIP_MIN;
75      break;
76    case SPI_TEXT_CLIP_MAX:
77      return Accessibility_TEXT_CLIP_MAX;
78      break;
79    }
80  return Accessibility_TEXT_CLIP_BOTH;
81}
82
83static AccessibleTextRange **
84get_accessible_text_ranges_from_range_seq (Accessibility_Text_RangeList *range_seq)
85{
86  AccessibleTextRange **ranges = NULL;
87  AccessibleTextRange *array = NULL;
88  int i;
89  if (range_seq && range_seq->_length > 0)
90    {
91      ranges = g_new0 (AccessibleTextRange *, range_seq->_length + 1);
92    }
93  array = g_new0 (AccessibleTextRange, range_seq->_length);
94  for (i = 0; i < range_seq->_length; i++)
95    {
96      AccessibleTextRange *range;
97      range = &array[i];
98      range->start = range_seq->_buffer[i].startOffset;
99      range->end = range_seq->_buffer[i].endOffset;
100      range->contents = CORBA_string_dup (range_seq->_buffer[i].content);
101      ranges[i] = range;
102    }
103  ranges[i] = NULL; /* null-terminated list! */
104  CORBA_free (range_seq);
105
106  return ranges;
107}
108
109
110/**
111 * AccessibleText_ref:
112 * @obj: a pointer to the #AccessibleText object on which to operate.
113 *
114 * Increment the reference count for an #AccessibleText object.
115 **/
116void
117AccessibleText_ref (AccessibleText *obj)
118{
119  cspi_object_ref (obj);
120}
121
122/**
123 * AccessibleText_unref:
124 * @obj: a pointer to the #Accessible object on which to operate.
125 *
126 * Decrement the reference count for an #AccessibleText object.
127 **/
128void
129AccessibleText_unref (AccessibleText *obj)
130{
131  cspi_object_unref (obj);
132}
133
134/**
135 * AccessibleText_getCharacterCount:
136 * @obj: a pointer to the #AccessibleText object to query.
137 *
138 * Get the character count of an #AccessibleText object.
139 *
140 * Returns: a long integer indicating the total number of
141 *              characters in the #AccessibleText object.
142 **/
143long
144AccessibleText_getCharacterCount (AccessibleText *obj)
145{
146  long retval;
147
148  cspi_return_val_if_fail (obj != NULL, -1);
149
150  retval = Accessibility_Text__get_characterCount (CSPI_OBJREF (obj), cspi_ev ());
151
152  cspi_return_val_if_ev ("getCharacterCount", -1);
153
154  return retval;
155}
156
157/**
158 * AccessibleText_getText:
159 * @obj: a pointer to the #AccessibleText object to query.
160 * @startOffset: a #long indicating the start of the desired text range.
161 * @endOffset: a #long indicating the first character past the desired range.
162 *
163 * Get a range of text from an #AccessibleText object.  The number of bytes
164 *          in the returned string may exceed endOffset-startOffset, since
165 *          UTF-8 is a variable-width encoding.
166 *
167 * Returns: a text string containing characters from @startOffset
168 *          to @endOffset-1, inclusive, encoded as UTF-8.
169 **/
170char *
171AccessibleText_getText (AccessibleText *obj,
172                        long int startOffset,
173                        long int endOffset)
174{
175  char *retval;
176
177  cspi_return_val_if_fail (obj != NULL, NULL);
178
179  retval =
180    Accessibility_Text_getText (CSPI_OBJREF (obj),
181                                startOffset,
182                                endOffset,
183                                cspi_ev ());
184
185  cspi_return_val_if_ev ("getText", NULL);
186
187  return retval;
188}
189
190/**
191 * AccessibleText_getCaretOffset:
192 * @obj: a pointer to the #AccessibleText object to query.
193 *
194 * Get the current offset of the text caret in an #AccessibleText object.
195 *
196 * Returns: a long integer indicating the current position of the text caret.
197 **/
198long
199AccessibleText_getCaretOffset (AccessibleText *obj)
200{
201  long retval;
202
203  cspi_return_val_if_fail (obj != NULL, -1);
204
205  retval =
206    Accessibility_Text__get_caretOffset (CSPI_OBJREF (obj), cspi_ev ());
207
208  cspi_return_val_if_ev ("getCaretOffset", -1);
209
210  return retval;
211}
212
213/**
214 * AccessibleText_getAttributes:
215 * @obj: a pointer to the #AccessibleText object to query.
216 * @offset: a long integer indicating the offset from which the attribute
217 *        search is based.
218 * @startOffset: a #long indicating the start of the desired text range.
219 * @endOffset: a #long indicating the first character past the desired range.
220 *
221 * Get the attributes applied to a range of text from an #AccessibleText
222 *          object, and the bounds of the range.
223 *          The text attributes correspond to CSS attributes where possible,
224 *          keys and values are delimited from one another via ":", and
225 *          the delimiter between key/value pairs is ";". Thus
226 *          "font-size:10;foreground-color:0,0,0" would be a valid
227 *          return string.
228 *
229 * Returns: a text string describing the attributes occurring within the
230 *          attribute run containing @offset, encoded as UTF-8.
231 **/
232char *
233AccessibleText_getAttributes (AccessibleText *obj,
234                              long int offset,
235                              long int *startOffset,
236                              long int *endOffset)
237{
238  CORBA_long retStartOffset, retEndOffset;
239  char *retval;
240
241  if (obj == NULL)
242    {
243      *startOffset = *endOffset = -1;
244      return NULL;
245    }
246
247  retval = Accessibility_Text_getAttributes (CSPI_OBJREF (obj),
248                                      offset,
249                                      &retStartOffset,
250                                      &retEndOffset,
251                                      cspi_ev ());
252
253  if (!cspi_check_ev ("getAttributes"))
254    {
255      *startOffset = *endOffset = -1;
256      retval = NULL;
257    }
258  else
259    {
260      *startOffset = retStartOffset;
261      *endOffset   = retEndOffset;
262    }
263
264  return retval;
265}
266
267/**
268 * AccessibleText_setCaretOffset:
269 * @obj: a pointer to the #AccessibleText object on which to operate.
270 * @newOffset: the offset to which the text caret is to be moved.
271 *
272 * Set the text caret position for an #AccessibleText object.
273 *
274 * Returns: #TRUE if successful, #FALSE otherwise.
275 **/
276SPIBoolean
277AccessibleText_setCaretOffset (AccessibleText *obj,
278                               long int newOffset)
279{
280  SPIBoolean retval;
281
282  cspi_return_val_if_fail (obj != NULL, FALSE);
283
284  retval =
285    Accessibility_Text_setCaretOffset (CSPI_OBJREF (obj),
286                                       newOffset, cspi_ev ());
287
288  cspi_return_val_if_ev ("setCaretOffset", FALSE);
289
290  return retval;
291}
292
293/**
294 * AccessibleText_getTextBeforeOffset:
295 * @obj: a pointer to the #AccessibleText object on which to operate.
296 * @offset: a long integer indicating the offset from which the delimiter
297 *        search is based.
298 * @type: an #AccessibleTextBoundaryType indicating whether the desired
299 *       text string is a word, sentence, line, or attribute run.
300 * @startOffset: a pointer to a long integer which is assigned the
301 *       starting offset of the returned string, relative to the
302 *       original #AccessibleText.
303 * @endOffset: a pointer to a long integer which is assigned the
304 *       ending offset of the returned string, relative to the original
305 *       #AccessibleText.
306 *
307 * Get delimited text from an #AccessibleText object which precedes a given
308 *          text offset.
309 *
310 * Returns: a UTF-8 string representing the delimited text, both of whose
311 *          delimiting boundaries are before the current offset, or
312 *          an empty string if no such text exists.
313 **/
314char *
315AccessibleText_getTextBeforeOffset (AccessibleText *obj,
316                                    long int offset,
317                                    AccessibleTextBoundaryType type,
318                                    long int *startOffset,
319                                    long int *endOffset)
320{
321  char *retval;
322  CORBA_long retStartOffset, retEndOffset;
323
324  if (obj == NULL)
325    {
326      *startOffset = *endOffset = -1;
327      return NULL;
328    }
329
330  retval = Accessibility_Text_getTextBeforeOffset (CSPI_OBJREF (obj),
331                                           offset,
332                        get_accessible_text_boundary_type (type),
333                                           &retStartOffset, &retEndOffset,
334                                           cspi_ev ());
335  if (!cspi_check_ev ("getTextBeforeOffset"))
336    {
337      *startOffset = *endOffset = -1;
338      retval = NULL;
339    }
340  else
341    {
342      *startOffset = retStartOffset;
343      *endOffset = retEndOffset;
344    }
345  return retval;
346}
347
348/**
349 * AccessibleText_getTextAtOffset:
350 * @obj: a pointer to the #AccessibleText object on which to operate.
351 * @offset: a long integer indicating the offset from which the delimiter
352 *        search is based.
353 * @type: an #AccessibleTextBoundaryType indicating whether the desired
354 *       text string is a word, sentence, line, or attribute run.
355 * @startOffset: a pointer to a long integer which is assigned the
356 *       starting offset of the returned string, relative to the
357 *       original #AccessibleText.
358 * @endOffset: a pointer to a long integer which is assigned the
359 *       ending offset of the returned string, relative to the original
360 *       #AccessibleText.
361 *
362 * Get delimited text from an #AccessibleText object which includes a given
363 *          text offset.
364 *
365 * Returns: a UTF-8 string representing the delimited text, whose
366 *          delimiting boundaries bracket the current offset, or
367 *          an empty string if no such text exists.
368 **/
369char *
370AccessibleText_getTextAtOffset (AccessibleText *obj,
371                                long int offset,
372                                AccessibleTextBoundaryType type,
373                                long int *startOffset, long int *endOffset)
374{
375  CORBA_long corbaStartOffset;
376  CORBA_long corbaEndOffset;
377  char      *retval;
378
379  if (obj == NULL)
380    {
381      *startOffset = *endOffset = -1;
382      return NULL;
383    }
384
385  retval = Accessibility_Text_getTextAtOffset (CSPI_OBJREF (obj),
386                                               offset,
387                          get_accessible_text_boundary_type (type),
388                                               &corbaStartOffset,
389                                               &corbaEndOffset,
390                                               cspi_ev ());
391
392  if (!cspi_check_ev ("getTextAtOffset"))
393    {
394      *startOffset = *endOffset = -1;
395      retval = NULL;
396    }
397  else
398    {
399      *startOffset = corbaStartOffset;
400      *endOffset   = corbaEndOffset;
401    }
402  return retval;
403}
404
405/**
406 * AccessibleText_getTextAfterOffset:
407 * @obj: a pointer to the #AccessibleText object on which to operate.
408 * @offset: a long integer indicating the offset from which the delimiter
409 *        search is based.
410 * @type: an #AccessibleTextBoundaryType indicating whether the desired
411 *       text string is a word, sentence, line, or attribute run.
412 * @startOffset: a pointer to a long integer which is assigned the
413 *       starting offset of the returned string, relative to the
414 *       original #AccessibleText.
415 * @endOffset: a pointer to a long integer which is assigned the
416 *       ending offset of the returned string, relative to the original
417 *       #AccessibleText.
418 *
419 * Get delimited text from an #AccessibleText object which follows a given
420 *          text offset.
421 *
422 * Returns: a UTF-8 string representing the delimited text, both of whose
423 *          delimiting boundaries are after or inclusive of the current
424 *          offset, or an empty string if no such text exists.
425 **/
426char *
427AccessibleText_getTextAfterOffset (AccessibleText *obj,
428                                   long int offset,
429                                   AccessibleTextBoundaryType type,
430                                   long int *startOffset, long int *endOffset)
431{
432  char *retval;
433  CORBA_long retStartOffset, retEndOffset;
434
435  if (obj == NULL)
436    {
437      *startOffset = *endOffset = -1;
438      return NULL;
439    }
440
441  retval = Accessibility_Text_getTextAfterOffset (CSPI_OBJREF (obj),
442                                           offset,
443                             get_accessible_text_boundary_type (type),
444                                           &retStartOffset, &retEndOffset,
445                                           cspi_ev ());
446
447  if (!cspi_check_ev ("getTextAfterOffset"))
448    {
449      *startOffset = *endOffset = -1;
450      retval = NULL;
451    }
452  else
453    {
454      *startOffset = retStartOffset;
455      *endOffset   = retEndOffset;
456    }
457  return retval;
458}
459
460/**
461 * AccessibleText_getCharacterAtOffset:
462 * @obj: a pointer to the #AccessibleText object on which to operate.
463 * @offset: a long integer indicating the text offset where the desired
464 *          character is located.
465 *
466 * Get the character at a given offset for an #AccessibleText object.
467 *
468 * Returns: an #unsigned long integer which represents the
469 *        UCS-4 unicode code point of the given character, or
470 *        0xFFFFFFFF if the character in question cannot be represented
471 *        in the UCS-4 encoding.
472 **/
473unsigned long
474AccessibleText_getCharacterAtOffset (AccessibleText *obj,
475                                     long int offset)
476{
477  long retval;
478
479  cspi_return_val_if_fail (obj != NULL, -1);
480
481  retval =
482    Accessibility_Text_getCharacterAtOffset (CSPI_OBJREF (obj),
483                                             offset,
484                                             cspi_ev ());
485
486  cspi_return_val_if_ev ("getCharacterAtOffset", -1);
487
488  return retval;
489}
490
491/**
492 * AccessibleText_getCharacterExtents:
493 * @obj: a pointer to the #AccessibleText object on which to operate.
494 * @offset: an integer indicating the offset of the text character for
495 *        whom boundary information is requested.
496 * @x: a pointer to a long integer into which the nominal x coordinate
497 *     of the corresponding glyph will be returned.
498 * @y:a pointer to a long integer into which the nominal y coordinate
499 *     of the corresponding glyph will be returned.
500 * @width:a pointer to a long integer into which the width
501 *     of the corresponding glyph will be returned.
502 * @height: a pointer to a long integer into which the height
503 *     of the corresponding glyph will be returned.
504 * @type: an #AccessibleCoordType indicating the coordinate system to use
505 *        for the returned values.
506 *
507 * Get the bounding box containing the glyph representing
508 *        the character at a particular text offset.
509 **/
510void
511AccessibleText_getCharacterExtents (AccessibleText *obj,
512                                    long int offset,
513                                    long int *x,
514                                    long int *y,
515                                    long int *width,
516                                    long int *height,
517                                    AccessibleCoordType type)
518{
519  CORBA_long retX, retY, retWidth, retHeight;
520
521  if (obj == NULL)
522    {
523      *x = *y = -1;
524      *width = *height = -1;
525      return;
526    }
527
528  Accessibility_Text_getCharacterExtents (CSPI_OBJREF (obj),
529                                          offset,
530                                          &retX,
531                                          &retY,
532                                          &retWidth,
533                                          &retHeight,
534                                          type, cspi_ev ());
535
536  if (!cspi_check_ev ("getCharacterExtents"))
537    {
538      *x = *y = -1;
539      *width = *height = -1;
540    }
541  else
542    {
543      *x = retX;
544      *y = retY;
545      *width = retWidth;
546      *height = retHeight;
547    }
548}
549
550/**
551 * AccessibleText_getOffsetAtPoint:
552 * @obj: a pointer to the #AccessibleText object on which to operate.
553 * @x: the x coordinate of the point to be queried.
554 * @y: the y coordinate of the point to be queried.
555 * @type: an #AccessibleCoordType indicating the coordinate system in which
556 *       the values should be returned.
557 *
558 * Get the bounding box for a glyph at a certain #AccessibleText offset.
559 *
560 * Returns: the offset (as a long integer) at the point (@x, @y)
561 *       in the specified coordinate system.
562 *
563 **/
564long
565AccessibleText_getOffsetAtPoint (AccessibleText *obj,
566                                 long int x,
567                                 long int y,
568                                 AccessibleCoordType type)
569{
570  long retval;
571
572  cspi_return_val_if_fail (obj != NULL, -1);
573
574  retval =
575    Accessibility_Text_getOffsetAtPoint (CSPI_OBJREF (obj),
576                                         x,
577                                         y,
578                                         type, cspi_ev ());
579
580  cspi_return_val_if_ev ("getOffsetAtPoint", -1);
581
582  return retval;
583}
584
585/**
586 * AccessibleText_getRangeExtents:
587 * @obj: a pointer to the #AccessibleText object on which to operate.
588 * @startOffset: an integer indicating the offset of the first text character for
589 *        whom boundary information is requested.
590 * @endOffset: an integer indicating the offset of the text character
591 *        after the last character for whom boundary information is requested.
592 * @x: a pointer to a long integer into which the nominal x coordinate
593 *     of the corresponding bounding box will be returned.
594 * @y:a pointer to a long integer into which the nominal y coordinate
595 *     of the corresponding bounding box will be returned.
596 * @width:a pointer to a long integer into which the width
597 *     of the corresponding bounding box will be returned.
598 * @height: a pointer to a long integer into which the height
599 *     of the corresponding bounding box will be returned.
600 * @type: an #AccessibleCoordType indicating the coordinate system to use
601 *        for the returned values.
602 *
603 * Get the bounding box for text within a range in an  #AccessibleText object.
604 *
605 * Returns: the bounding-box extents of the specified text range,
606 *       in the specified coordinate system.
607 *
608 **/
609void
610AccessibleText_getRangeExtents (AccessibleText *obj,
611                                long int startOffset,
612                                long int endOffset,
613                                long int *x,
614                                long int *y,
615                                long int *width,
616                                long int *height,
617                                AccessibleCoordType type)
618{
619  CORBA_long retX, retY, retWidth, retHeight;
620
621  if (obj == NULL)
622    {
623      *x = *y = -1;
624      *width = *height = -1;
625      return;
626    }
627
628  Accessibility_Text_getRangeExtents (CSPI_OBJREF (obj),
629                                      startOffset,
630                                      endOffset,
631                                      &retX,
632                                      &retY,
633                                      &retWidth,
634                                      &retHeight,
635                                      type, cspi_ev ());
636
637  if (!cspi_check_ev ("getRangeExtents"))
638    {
639      *x = *y = -1;
640      *width = *height = -1;
641    }
642  else
643    {
644      *x = retX;
645      *y = retY;
646      *width = retWidth;
647      *height = retHeight;
648    }
649}
650
651/**
652 * AccessibleText_getBoundedRanges:
653 * @obj: a pointer to the #AccessibleText object on which to operate.
654 * @x: the 'starting' x coordinate of the bounding box.
655 * @y: the 'starting' y coordinate of the bounding box.
656 * @width: the x extent of the bounding box.
657 * @height: the y extent of the bounding box.
658 * @type: an #AccessibleCoordType indicating the coordinate system to use
659 *        for the returned values.
660 * @clipTypeX: an #AccessibleTextClipType indicating how to treat characters that
661 *        intersect the bounding box's x extents.
662 * @clipTypeY: an #AccessibleTextClipType indicating how to treat characters that
663 *        intersect the bounding box's y extents.
664 *
665 * Get the ranges of text from an #AccessibleText object which lie within the
666 *          bounds defined by (@x, @y) and (@x+@width, @y+@height). 
667 *
668 * Returns: a null-terminated list of pointers to AccessibleTextRange structs
669 *          detailing the bounded text.
670 **/
671AccessibleTextRange **
672AccessibleText_getBoundedRanges (AccessibleText *obj,
673                                 long int x,
674                                 long int y,
675                                 long int width,
676                                 long int height,
677                                 AccessibleCoordType type,
678                                 AccessibleTextClipType clipTypeX,
679                                 AccessibleTextClipType clipTypeY)
680{
681  Accessibility_Text_RangeList *range_seq;
682
683  cspi_return_val_if_fail (obj != NULL, NULL);
684
685  range_seq =
686    Accessibility_Text_getBoundedRanges (CSPI_OBJREF (obj),
687                                         x, y, width, height,
688                                         type,
689                                         get_accessible_text_clip_type (clipTypeX),
690                                         get_accessible_text_clip_type (clipTypeY),
691                                         cspi_ev ());
692
693  cspi_return_val_if_ev ("getBoundedRanges", NULL);
694 
695  return get_accessible_text_ranges_from_range_seq (range_seq);
696}
697
698/**
699 * AccessibleTextRange_freeRanges:
700 * @ranges: a pointer to an array of AccessibleTextRange structs.
701 *
702 * Free the memory used by a list of AccessibleTextRange structs.
703 * The argument passed in should be an array of pointers
704 * AccessibleTextRange structs. 
705 **/
706void
707AccessibleTextRange_freeRanges (AccessibleTextRange **ranges)
708{
709  /* this was a contiguously allocated block, only free the first element */
710  g_free (ranges[0]);
711  g_free (ranges);
712}
713
714/**
715 * AccessibleText_getNSelections:
716 * @obj: a pointer to the #AccessibleText object on which to operate.
717 *
718 * Get the number of active non-contiguous selections for an
719 *          #AccessibleText object.
720 *
721 * Returns: a long integer indicating the current
722 *          number of non-contiguous text selections active
723 *          within an #AccessibleText object.
724 **/
725long
726AccessibleText_getNSelections (AccessibleText *obj)
727{
728  long retval;
729
730  cspi_return_val_if_fail (obj != NULL, -1);
731
732  retval =
733    Accessibility_Text_getNSelections (CSPI_OBJREF (obj), cspi_ev ());
734
735  cspi_return_val_if_ev ("getNSelections", -1);
736
737  return retval;
738}
739
740/**
741 * AccessibleText_getSelection:
742 * @obj: a pointer to the #AccessibleText object on which to operate.
743 * @selectionNum: an integer indicating which selection to query.
744 * @startOffset: a pointer to a long integer into which the start offset
745 *           of the selection will be returned.
746 * @endOffset: a pointer to a long integer into which the start offset
747 *           of the selection will be returned.
748 *
749 * Get the bounds of the @selectionNum-th active text selection for an
750 *         #AccessibleText object.
751 **/
752void
753AccessibleText_getSelection (AccessibleText *obj,
754                             long int selectionNum,
755                             long int *startOffset,
756                             long int *endOffset)
757{
758  CORBA_long retStartOffset, retEndOffset;
759
760  if (obj == NULL)
761    {
762      *endOffset = *startOffset = -1;
763      return;
764    }
765
766  Accessibility_Text_getSelection (CSPI_OBJREF (obj),
767                                   selectionNum,
768                                   &retStartOffset, &retEndOffset,
769                                   cspi_ev ());
770
771  if (!cspi_check_ev ("getSelection"))
772    {
773      *startOffset = *endOffset = -1;
774    }
775  else
776    {
777      *startOffset = retStartOffset;
778      *endOffset   = retEndOffset;
779    }
780}
781
782/**
783 * AccessibleText_addSelection:
784 * @obj: a pointer to the #AccessibleText object on which to operate.
785 * @startOffset: the starting offset of the desired new selection.
786 * @endOffset: the offset of the first character after the new selection.
787 *
788 * Select some text (add a text selection) in an #AccessibleText object.
789 *
790 * Returns: #TRUE if successful, #FALSE otherwise.
791 **/
792SPIBoolean
793AccessibleText_addSelection (AccessibleText *obj,
794                             long int startOffset, long int endOffset)
795{
796  SPIBoolean retval;
797
798  cspi_return_val_if_fail (obj != NULL, FALSE);
799
800  retval =
801    Accessibility_Text_addSelection (
802      CSPI_OBJREF (obj), startOffset,
803      endOffset, cspi_ev ());
804
805  cspi_return_val_if_ev ("addSelection", FALSE);
806
807  return retval;
808}
809
810/**
811 * AccessibleText_removeSelection:
812 * @obj: a pointer to the #AccessibleText object on which to operate.
813 * @selectionNum: an integer indicating which (possibly of several)
814 *         text selection to remove.
815 *
816 * De-select a text selection.
817 *
818 * Returns: #TRUE if successful, #FALSE otherwise.
819 **/
820SPIBoolean
821AccessibleText_removeSelection (AccessibleText *obj,
822                                long int selectionNum)
823{
824  SPIBoolean retval;
825
826  cspi_return_val_if_fail (obj != NULL, FALSE);
827
828  retval =
829    Accessibility_Text_removeSelection (
830      CSPI_OBJREF (obj), selectionNum, cspi_ev ());
831
832  cspi_return_val_if_ev ("removeSelection", FALSE);
833
834  return retval;
835}
836
837/**
838 * AccessibleText_setSelection:
839 * @obj: a pointer to the #AccessibleText object on which to operate.
840 * @selectionNum: a zero-offset index indicating which text selection to modify.
841 * @startOffset: a long int, the new starting offset for the selection.
842 * @endOffset: a long int, the desired new offset of the first character
843 *             after the selection.
844 *
845 * Change the bounds of an existing #AccessibleText text selection.
846 *
847 * Returns: #TRUE if successful, #FALSE otherwise.
848 **/
849SPIBoolean
850AccessibleText_setSelection (AccessibleText *obj,
851                             long int selectionNum,
852                             long int startOffset,
853                             long int endOffset)
854{
855  SPIBoolean retval;
856
857  cspi_return_val_if_fail (obj != NULL, FALSE);
858
859  retval = Accessibility_Text_setSelection (CSPI_OBJREF (obj),
860                                   selectionNum,
861                                   startOffset,
862                                   endOffset, cspi_ev ());
863
864  cspi_return_val_if_ev ("setSelection", FALSE);
865
866  return retval;
867}
868
869
870
Note: See TracBrowser for help on using the repository browser.