From b0b12f83d87d3561be05d956226d728f762135ef Mon Sep 17 00:00:00 2001 From: billh Date: Wed, 12 Jul 2006 14:13:04 +0000 Subject: [PATCH] Enhancements to Accessibility::Text, based on patches from Ariel Rios. Bug #326540. git-svn-id: http://svn.gnome.org/svn/at-spi/trunk@834 e2bd861d-eb25-0410-b326-f6ed22b6b98c --- ChangeLog | 22 +++++++++++ configure.in | 4 +- cspi/spi-private.h | 5 ++- cspi/spi.h | 8 ++++ cspi/spi_text.c | 90 ++++++++++++++++++++++++++++++++++++++++++++ idl/Accessibility_Text.idl | 68 ++++++++++++++++++++++++++++++++- libspi/text.c | 94 +++++++++++++++++++++++++++++++++++++++++++++- 7 files changed, 283 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index c6696c3..c05db52 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,25 @@ +2006-07-12 Bill Haneman modifications to patch from +2006-07-12 Ariel Rios + + * cspi/bonobo/cspi-bonobo.c: Remove warning adding + + * cspi/spi_text.c: + (AccessibleText_getAttributeRun,AccessibleText_getDefaultAttributes): + New bindings for new methods defined in idl and libspi. + + * cspi/spi.h: + (AccessibleText_getAttributeRun,AccessibleText_getDefaultAttributes): + Added prototype functions. + + * libspi/text.c: + (impl_getAttributeRun, impl_getDefaultAttributeSet): New method implementation + Bug #326520 + (spi_text_class_init): Added previous methods. + + * libspi/spi.h: + (impl_getAttributeRun, impl_getDefaultAttributeSet): Added prototypes + * libspi/spi-private.h: Corrections. + 2006-06-29 Bill Haneman Added Document interface (see bug #326520), diff --git a/configure.in b/configure.in index ea56073..9de8ade 100644 --- a/configure.in +++ b/configure.in @@ -2,7 +2,7 @@ AC_INIT(idl/Accessibility.idl) AT_SPI_MAJOR_VERSION=1 AT_SPI_MINOR_VERSION=7 -AT_SPI_MICRO_VERSION=8 +AT_SPI_MICRO_VERSION=9 AT_SPI_INTERFACE_AGE=0 AT_SPI_BINARY_AGE=0 AT_SPI_VERSION="$AT_SPI_MAJOR_VERSION.$AT_SPI_MINOR_VERSION.$AT_SPI_MICRO_VERSION" @@ -16,7 +16,7 @@ AC_SUBST(AT_SPI_BINARY_AGE) # libtool versioning LT_RELEASE=$AT_SPI_MAJOR_VERSION.$AT_SPI_MINOR_VERSION LT_CURRENT=10 -LT_REVISION=9 +LT_REVISION=10 LT_AGE=10 LT_VERSION_INFO='-version-info ${LT_CURRENT}:${LT_REVISION}:${LT_AGE}' AC_SUBST(LT_VERSION_INFO) diff --git a/cspi/spi-private.h b/cspi/spi-private.h index 16b9eb3..6fd19eb 100644 --- a/cspi/spi-private.h +++ b/cspi/spi-private.h @@ -81,9 +81,10 @@ SPIBoolean cspi_accessible_is_a (Accessible *accessible, const char *interface_name); AccessibleRole cspi_role_from_spi_role (Accessibility_Role role); void cspi_streams_close_all (void); -gboolean _cspi_exception_throw (CORBA_Environment *ev, char *desc_prefix); - +gboolean cspi_exception_throw (CORBA_Environment *ev, char *desc_prefix); +AccessibleAttributeSet + *cspi_attribute_set_from_sequence (const Accessibility_AttributeSet *seq); #define cspi_return_if_fail(val) \ if (!(val)) \ return diff --git a/cspi/spi.h b/cspi/spi.h index 9cd6efb..0eb4821 100644 --- a/cspi/spi.h +++ b/cspi/spi.h @@ -1077,6 +1077,14 @@ AccessibleText_setSelection (AccessibleText *obj, long int selectionNum, long int startOffset, long int endOffset); +AccessibleAttributeSet * +AccessibleText_getAttributeRun (AccessibleText *obj, + long int offset, + long int *startOffset, + long int *endOffset, + long int includeDefaults); +AccessibleAttributeSet * +AccessibleText_getDefaultAttributeSet (AccessibleText *obj); /* AccessibleValue Function Prototypes: */ diff --git a/cspi/spi_text.c b/cspi/spi_text.c index e8ce45d..b3ee577 100644 --- a/cspi/spi_text.c +++ b/cspi/spi_text.c @@ -912,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; +} diff --git a/idl/Accessibility_Text.idl b/idl/Accessibility_Text.idl index 9afb855..133594c 100644 --- a/idl/Accessibility_Text.idl +++ b/idl/Accessibility_Text.idl @@ -385,6 +385,72 @@ module Accessibility { in TEXT_CLIP_TYPE xClipType, in TEXT_CLIP_TYPE yClipType); + /** + * Query a particular text object for the text attributes defined at a given offset, + * obtaining the start and end of the "attribute run" over which these attributes are currently + * invariant. Text attributes are those presentational, typographic, or semantic attributes or + * qualitites which apply to a range of text specifyable by starting and ending offsets. + * Attributes relevant to localization should be provided in + * accordance with the w3c "Internationalization and Localization Markup Requirements", + * http://www.w3.org/TR/2005/WD-itsreq-20051122/ + * Other text attributes should choose their names and value semantics in accordance with relevant + * standards such as CSS level 2 (http://www.w3.org/TR/1998/REC-CSS2-19980512), + * XHTML 1.0 (http://www.w3.org/TR/2002/REC-xhtml1-20020801), and + * WICD (http://www.w3.org/TR/2005/WD-WICD-20051121/). Those attributes from the aforementioned + * specifications and recommendations which do not concern typographic, presentational, or + * semantic aspects of text should be exposed via the more general Accessible::getAttributes() API + * (if at all). + * + * For example, CSS attributes which should be exposed on text (either as default attributes, or + * as explicitly-set attributes when non-default values are specified in the content view) include + * the Font attributes (i.e. "css2:font-weight", "css2:font-style"), + * the "css2:color" and "css2:background-color" attributes, and "css2:text-decoration" attribute. + * + * If includeDefaults is TRUE, then this AttributeSet should include the default + * attributes as well as those which are explicitly assigned to the attribute run in question. + * startOffset and endOffset will be back-filled to indicate the start and end of the attribute run + * which contains 'offset' - an attribute run is a contiguous section of text whose attributes are + * homogeneous. + * @param offset the offset of the character whose attributes will be reported. + * @param startOffset backfilled with the starting offset of the character range over which all + * text attributes match those of \c offset, i.e. the start of the homogeneous + * attribute run including \c offset. + * @param endOffset backfilled with the offset of the first character past the character range over which all + * text attributes match those of \c offset, i.e. the character immediately after + * the homogeneous attribute run including \c offset. + * @param includeDefaults 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. See also Text::getDefaultAttributes. + * + * @note Clients seeking annotations or properties of a more general nature, which + * are not specific to the onscreen textual content of objects and cannot logically be applied + * to specific character offset ranges, + * should use Accessible::getAttributes instead. + * The attributes returned by Text::getAttributeRun (with or without 'default attributes'), + * are distinct from the properties/attributes returned by Accessible::getAttributes. + * + * @see Accessible::getAttributes + * + * @returns the AttributeSet defined at offset, optionally including the 'default' attributes. + * + * @since AT-SPI 1.7.0 + **/ + AttributeSet getAttributeRun (in long offset, + out long startOffset, + out long endOffset, + in boolean includeDefaults); + /** + * Return 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. + * + * @since AT-SPI 1.7.0 + **/ + AttributeSet getDefaultAttributeSet (); + /** \cond * unImplemented: * @@ -392,8 +458,6 @@ module Accessibility { */ void unImplemented (); void unImplemented2 (); - void unImplemented3 (); - void unImplemented4 (); /** \endcond **/ }; }; diff --git a/libspi/text.c b/libspi/text.c index eaaa17b..29a25b3 100644 --- a/libspi/text.c +++ b/libspi/text.c @@ -126,7 +126,7 @@ impl_getText (PortableServer_Servant servant, } -CORBA_string +static CORBA_string impl_getTextAfterOffset (PortableServer_Servant servant, const CORBA_long offset, const @@ -598,7 +598,7 @@ _spi_bounds_contain (SpiTextRect *clip, SpiTextRect *cbounds, return FALSE; } -Accessibility_Text_RangeList * +static Accessibility_Text_RangeList * impl_getBoundedRanges(PortableServer_Servant servant, const CORBA_long x, const CORBA_long y, @@ -671,6 +671,94 @@ impl_getBoundedRanges(PortableServer_Servant servant, } + +static Accessibility_AttributeSet * +impl_getAttributeRun (PortableServer_Servant servant, + const CORBA_long offset, + CORBA_long *startOffset, CORBA_long *endOffset, + const CORBA_boolean includeDefaults, + CORBA_Environment *ev){ + + AtkAttributeSet *attributes, *default_attributes = NULL; + gint intstart_offset, intend_offset; + Accessibility_AttributeSet *retval = NULL; + AtkText *text = get_text_from_servant (servant); + gint n_attributes = 0, total_attributes = 0, n_default_attributes = 0; + gint i, j; + + g_return_val_if_fail (text != NULL, NULL); + + attributes = atk_text_get_run_attributes (text, offset, + &intstart_offset, &intend_offset); + + if (attributes) total_attributes = n_attributes = g_slist_length (attributes); + if (includeDefaults) + { + default_attributes = atk_text_get_default_attributes (text); + if (default_attributes) + n_default_attributes = g_slist_length (default_attributes); + total_attributes += n_default_attributes; + } + + *startOffset = intstart_offset; + *endOffset = intend_offset; + + if (total_attributes) + { + retval = CORBA_sequence_CORBA_string__alloc (); + retval->_length = retval->_maximum = total_attributes; + retval->_buffer = CORBA_sequence_CORBA_string_allocbuf (total_attributes); + CORBA_sequence_set_release (retval, CORBA_TRUE); + + for (i = 0; i < n_attributes; ++i) + { + retval->_buffer[i] = CORBA_string_dup (g_slist_nth_data (attributes, i)); + } + + for (j = 0; j < n_default_attributes; ++i, ++j) + { + retval->_buffer[i] = CORBA_string_dup (g_slist_nth_data (default_attributes, j)); + } + + atk_attribute_set_free (attributes); + if (default_attributes) + atk_attribute_set_free (default_attributes); + } + return retval; +} + +static Accessibility_AttributeSet * +impl_getDefaultAttributeSet (PortableServer_Servant servant, + CORBA_Environment *ev){ + AtkAttributeSet *attributes; + Accessibility_AttributeSet *retval = NULL; + AtkText *text = get_text_from_servant (servant); + gint n_attributes = 0; + gint i; + + g_return_val_if_fail (text != NULL, NULL); + + attributes = atk_text_get_default_attributes (text); + + if (attributes) + { + n_attributes = g_slist_length (attributes); + + retval = CORBA_sequence_CORBA_string__alloc (); + retval->_length = retval->_maximum = n_attributes; + retval->_buffer = CORBA_sequence_CORBA_string_allocbuf (n_attributes); + CORBA_sequence_set_release (retval, CORBA_TRUE); + + for (i = 0; i < n_attributes; ++i) + { + retval->_buffer[i] = CORBA_string_dup (g_slist_nth_data (attributes, i)); + } + atk_attribute_set_free (attributes); + } + return retval; +} + + static void spi_text_class_init (SpiTextClass *klass) { @@ -698,6 +786,8 @@ spi_text_class_init (SpiTextClass *klass) epv->getRangeExtents = impl_getRangeExtents; epv->getBoundedRanges = impl_getBoundedRanges; epv->getAttributeValue = impl_getAttributeValue; + epv->getAttributeRun = impl_getAttributeRun; + epv->getDefaultAttributeSet = impl_getDefaultAttributeSet; } static void -- 2.7.4