Changes to introspection generation to remove DOCTYPE and XML
[platform/core/uifw/at-spi2-atk.git] / cspi / spi_text.c
index 35e33c2..13a9be4 100644 (file)
@@ -57,9 +57,57 @@ get_accessible_text_boundary_type (AccessibleTextBoundaryType type)
       /* Fixme */
       return Accessibility_TEXT_BOUNDARY_CHAR;
       break;
+    default:
+      /* FIXME */
+      return Accessibility_TEXT_BOUNDARY_CHAR;
+    }
+}
+
+static Accessibility_TEXT_CLIP_TYPE
+get_accessible_text_clip_type (AccessibleTextClipType type)
+{
+  switch (type)
+    {
+    case SPI_TEXT_CLIP_NONE:
+      return Accessibility_TEXT_CLIP_NONE;
+      break;
+    case SPI_TEXT_CLIP_MIN:
+      return Accessibility_TEXT_CLIP_MIN;
+      break;
+    case SPI_TEXT_CLIP_MAX:      
+      return Accessibility_TEXT_CLIP_MAX;
+      break;
+    default:
+      return Accessibility_TEXT_CLIP_BOTH;
     }
 }
 
+static AccessibleTextRange **
+get_accessible_text_ranges_from_range_seq (Accessibility_Text_RangeList *range_seq)
+{
+  AccessibleTextRange **ranges = NULL;
+  AccessibleTextRange *array = NULL;
+  int i;
+  if (range_seq && range_seq->_length > 0) 
+    {
+      ranges = g_new0 (AccessibleTextRange *, range_seq->_length + 1);
+    }
+  array = g_new0 (AccessibleTextRange, range_seq->_length);
+  for (i = 0; i < range_seq->_length; i++) 
+    {
+      AccessibleTextRange *range;
+      range = &array[i];
+      range->start = range_seq->_buffer[i].startOffset;
+      range->end = range_seq->_buffer[i].endOffset;
+      range->contents = CORBA_string_dup (range_seq->_buffer[i].content);
+      ranges[i] = range;
+    }
+  ranges[i] = NULL; /* null-terminated list! */
+  CORBA_free (range_seq);
+
+  return ranges;
+}
+
 
 /**
  * AccessibleText_ref:
@@ -174,10 +222,14 @@ AccessibleText_getCaretOffset (AccessibleText *obj)
  *
  * Get the attributes applied to a range of text from an #AccessibleText
  *          object, and the bounds of the range.
+ *          The text attributes correspond to CSS attributes where possible,
+ *          keys and values are delimited from one another via ":", and
+ *          the delimiter between key/value pairs is ";". Thus 
+ *          "font-size:10;foreground-color:0,0,0" would be a valid
+ *          return string.
  *
  * Returns: a text string describing the attributes occurring within the
- *          attribute run containing @offset, encoded as UTF-8 and
- *          delimited by ':'
+ *          attribute run containing @offset, encoded as UTF-8.
  **/
 char *
 AccessibleText_getAttributes (AccessibleText *obj,
@@ -215,6 +267,47 @@ AccessibleText_getAttributes (AccessibleText *obj,
 }
 
 /**
+ * AccessibleText_getDefaultAttributes:
+ * @obj: a pointer to the #AccessibleText object to query.
+ *
+ * Get the default attributes applied to an #AccessibleText
+ *          object.
+ *          The text attributes correspond to CSS attributes where possible,
+ *          keys and values are delimited from one another via ":", and
+ *          the delimiter between key/value pairs is ";". Thus 
+ *          "font-size:10;foreground-color:0,0,0" would be a valid
+ *          return string.  The combination of this attribute set and
+ *          the attributes reported by #AccessibleText_getAttributes
+ *          describes the entire set of text attributes over a range.
+ *
+ * @Since: AT-SPI 1.4
+ *
+ * Returns: a text string describing the default attributes 
+ *          applied to a text object, (exclusive of explicitly-set
+ *          attributes), encoded as UTF-8.
+ **/
+char *
+AccessibleText_getDefaultAttributes (AccessibleText *obj)
+{
+  char *retval;        
+
+  if (obj == NULL)
+    {
+      return NULL;
+    }
+
+  retval = Accessibility_Text_getDefaultAttributes (CSPI_OBJREF (obj),
+                                                   cspi_ev ());
+
+  if (!cspi_check_ev ("getAttributes"))
+    {
+      retval = NULL;
+    }
+
+  return retval;
+}
+
+/**
  * AccessibleText_setCaretOffset:
  * @obj: a pointer to the #AccessibleText object on which to operate.
  * @newOffset: the offset to which the text caret is to be moved.
@@ -533,6 +626,137 @@ AccessibleText_getOffsetAtPoint (AccessibleText *obj,
 }
 
 /**
+ * AccessibleText_getRangeExtents:
+ * @obj: a pointer to the #AccessibleText object on which to operate.
+ * @startOffset: an integer indicating the offset of the first text character for
+ *        whom boundary information is requested.
+ * @endOffset: an integer indicating the offset of the text character 
+ *        after the last character for whom boundary information is requested.
+ * @x: a pointer to a long integer into which the nominal x coordinate
+ *     of the corresponding bounding box will be returned.
+ * @y:a pointer to a long integer into which the nominal y coordinate
+ *     of the corresponding bounding box will be returned.
+ * @width:a pointer to a long integer into which the width
+ *     of the corresponding bounding box will be returned.
+ * @height: a pointer to a long integer into which the height
+ *     of the corresponding bounding box will be returned.
+ * @type: an #AccessibleCoordType indicating the coordinate system to use
+ *        for the returned values.
+ *
+ * Get the bounding box for text within a range in an  #AccessibleText object.
+ *
+ * @Since: AT-SPI 1.2
+ **/
+void
+AccessibleText_getRangeExtents (AccessibleText *obj,
+                               long int startOffset,
+                               long int endOffset,
+                               long int *x,
+                               long int *y,
+                               long int *width,
+                               long int *height,
+                               AccessibleCoordType type)
+{
+  CORBA_long retX, retY, retWidth, retHeight;
+
+  if (obj == NULL)
+    {
+      *x = *y = -1;
+      *width = *height = -1;
+      return;
+    }
+
+  Accessibility_Text_getRangeExtents (CSPI_OBJREF (obj),
+                                     startOffset,
+                                     endOffset,
+                                     &retX,
+                                     &retY,
+                                     &retWidth,
+                                     &retHeight,
+                                     type, cspi_ev ());
+
+  if (!cspi_check_ev ("getRangeExtents"))
+    {
+      *x = *y = -1;
+      *width = *height = -1;
+    }
+  else
+    {
+      *x = retX;
+      *y = retY;
+      *width = retWidth;
+      *height = retHeight;
+    }
+}
+
+/**
+ * AccessibleText_getBoundedRanges:
+ * @obj: a pointer to the #AccessibleText object on which to operate.
+ * @x: the 'starting' x coordinate of the bounding box.
+ * @y: the 'starting' y coordinate of the bounding box.
+ * @width: the x extent of the bounding box.
+ * @height: the y extent of the bounding box.
+ * @type: an #AccessibleCoordType indicating the coordinate system to use
+ *        for the returned values.
+ * @clipTypeX: an #AccessibleTextClipType indicating how to treat characters that
+ *        intersect the bounding box's x extents.
+ * @clipTypeY: an #AccessibleTextClipType indicating how to treat characters that
+ *        intersect the bounding box's y extents.
+ *
+ * Get the ranges of text from an #AccessibleText object which lie within the
+ *          bounds defined by (@x, @y) and (@x+@width, @y+@height).  
+ *
+ * @Since: AT-SPI 1.2
+ *
+ * Returns: a null-terminated list of pointers to AccessibleTextRange structs 
+ *          detailing the bounded text.
+ **/
+AccessibleTextRange **
+AccessibleText_getBoundedRanges (AccessibleText *obj,
+                                long int x,
+                                long int y,
+                                long int width,
+                                long int height,
+                                AccessibleCoordType type,
+                                AccessibleTextClipType clipTypeX,
+                                AccessibleTextClipType clipTypeY)
+{
+  Accessibility_Text_RangeList *range_seq;
+
+  cspi_return_val_if_fail (obj != NULL, NULL);
+
+  range_seq =
+    Accessibility_Text_getBoundedRanges (CSPI_OBJREF (obj), 
+                                        x, y, width, height,
+                                        type, 
+                                        get_accessible_text_clip_type (clipTypeX), 
+                                        get_accessible_text_clip_type (clipTypeY),
+                                        cspi_ev ());
+
+  cspi_return_val_if_ev ("getBoundedRanges", NULL); 
+  return get_accessible_text_ranges_from_range_seq (range_seq);
+}
+
+/**
+ * AccessibleTextRange_freeRanges:
+ * @ranges: a pointer to an array of AccessibleTextRange structs.
+ *
+ * Free the memory used by a list of AccessibleTextRange structs.
+ * The argument passed in should be an array of pointers 
+ * AccessibleTextRange structs.  
+ *
+ * @Since: AT-SPI 1.2
+ **/
+void
+AccessibleTextRange_freeRanges (AccessibleTextRange **ranges)
+{
+  /* this was a contiguously allocated block, only free the first element */
+  g_free (ranges[0]); 
+  g_free (ranges);
+}
+
+/**
  * AccessibleText_getNSelections:
  * @obj: a pointer to the #AccessibleText object on which to operate.
  *
@@ -688,4 +912,94 @@ AccessibleText_setSelection (AccessibleText *obj,
 }
 
 
+/**
+ * AccessibleText_getAttributeRun:
+ * @obj: a pointer to the #AccessibleText object to query.
+ * @offset: a long integer indicating the offset from which the attribute
+ *        search is based.
+ * @startOffset: a #long indicating the start of the desired text range.
+ * @endOffset: a #long indicating the first character past the desired range.
+ * @includeDefaults: a #bool if False, the call should only return those 
+ *                 attributes which are explicitly set on the current attribute 
+ *                 run, omitting any attributes which are inherited from the 
+ *                 default values.
+ *
+ *  @Since: AT-SPI 1.7
+ *
+ * Returns: the AttributeSet defined at offset, optionally including the 'default' attributes.
+ **/
+
+AccessibleAttributeSet *
+AccessibleText_getAttributeRun (AccessibleText *obj,
+                               long int offset,
+                               long int *startOffset,
+                               long int *endOffset,
+                               long int includeDefaults){
+
+  CORBA_long retStartOffset, retEndOffset;
+  AccessibleAttributeSet *retval;
+  Accessibility_AttributeSet *attributes;
+
+  if (obj == NULL)
+  {
+       *startOffset = *endOffset = -1;
+       return NULL;
+  }
+
+  attributes = Accessibility_Text_getAttributeRun (CSPI_OBJREF (obj),
+                                              offset,
+                                              &retStartOffset,
+                                              &retEndOffset,
+                                              (includeDefaults)? TRUE : FALSE,
+                                              cspi_ev ());
+
+  if (!cspi_check_ev ("getAttributeRun"))
+    {
+      *startOffset = *endOffset = -1;
+      retval = NULL;
+    }
+  else 
+  {
+      *startOffset = retStartOffset;
+      *endOffset   = retEndOffset;
+  }
+
+  retval =  _cspi_attribute_set_from_sequence (attributes);
+
+  return retval;
+                                    
+}
+
+/**
+ * AccessibleText_getDefaultAttributeSet:
+ * @obj: a pointer to the #AccessibleText object to query.
+ *
+ *
+ *  @Since: AT-SPI 1.7
+ *
+ * Returns: an AttributeSet containing the text attributes 
+ * which apply to all text in the object by virtue of the
+ * default settings of the document, view, or user agent; e.g.
+ * those attributes which are implied rather than explicitly 
+ * applied to the text object. For instance, an object whose 
+ * entire text content has been explicitly marked as 'bold' 
+ * will report the 'bold' attribute via getAttributeRun(), 
+ * whereas an object whose text weight is inspecified may 
+ * report the default or implied text weight in the default AttributeSet.
+ *
+ **/
+
+AccessibleAttributeSet *
+AccessibleText_getDefaultAttributeSet (AccessibleText *obj){
+   AccessibleAttributeSet *retval;
+   Accessibility_AttributeSet *attributes;
+
+   cspi_return_val_if_fail (obj != NULL, NULL);
 
+  attributes = Accessibility_Text_getDefaultAttributeSet (CSPI_OBJREF (obj), cspi_ev ());
+  cspi_return_val_if_ev ("getDefaultAttributeSet", NULL);
+  
+  retval = _cspi_attribute_set_from_sequence (attributes);
+  retval = NULL;
+  return retval;
+}