vcl/unx/gtk/a11y/atktextattributes.cxx | 31 +++++++++++++++++++++++++++++++ vcl/unx/gtk/a11y/atktextattributes.hxx | 5 +++++ vcl/unx/gtk/a11y/atkwrapper.cxx | 30 ++++++++++++++++++++++++++++++ 3 files changed, 66 insertions(+)
New commits: commit 89446eb5ae51b2004fb86f7af5be58754ece8fb3 Author: Jacobo Aragunde Pérez <jaragu...@igalia.com> Date: Tue Feb 3 16:48:01 2015 +0100 tdf#84102: Expose XAccessibleExtendedAttributes through ATK Those attributes contain a lot of interesting properties, among them the heading level which fixes this bug. Change-Id: I634ef404123cb1b2831563b9b186db4b7e9e7d8b (cherry picked from commit 1e6515e64cb4a40071e09d5df000a94f96311ea1) Reviewed-on: https://gerrit.libreoffice.org/14807 Reviewed-by: Caolán McNamara <caol...@redhat.com> Tested-by: Caolán McNamara <caol...@redhat.com> diff --git a/vcl/unx/gtk/a11y/atktextattributes.cxx b/vcl/unx/gtk/a11y/atktextattributes.cxx index fe2f0d5..bc286d0 100644 --- a/vcl/unx/gtk/a11y/atktextattributes.cxx +++ b/vcl/unx/gtk/a11y/atktextattributes.cxx @@ -1211,6 +1211,37 @@ attribute_set_new_from_property_values( return attribute_set; } +AtkAttributeSet* +attribute_set_new_from_extended_attributes( + const css::uno::Reference< css::accessibility::XAccessibleExtendedAttributes >& rExtendedAttributes ) +{ + AtkAttributeSet *pSet = NULL; + + // extended attributes is a string of colon-separated pairs of property and value, + // with pairs separated by semicolons. Example: "heading-level:2;weight:bold;" + uno::Any anyVal = rExtendedAttributes->getExtendedAttributes(); + OUString sExtendedAttrs; + anyVal >>= sExtendedAttrs; + sal_Int32 nIndex = 0; + do + { + OUString sProperty = sExtendedAttrs.getToken( 0, ';', nIndex ); + + sal_Int32 nColonPos = 0; + OString sPropertyName = OUStringToOString( sProperty.getToken( 0, ':', nColonPos ), + RTL_TEXTENCODING_UTF8 ); + OString sPropertyValue = OUStringToOString( sProperty.getToken( 0, ':', nColonPos ), + RTL_TEXTENCODING_UTF8 ); + + pSet = attribute_set_prepend( pSet, + atk_text_attribute_register( sPropertyName.getStr() ), + g_strdup_printf( sPropertyValue.getStr() ) ); + } + while ( nIndex >= 0 && nIndex < sExtendedAttrs.getLength() ); + + return pSet; +} + AtkAttributeSet* attribute_set_prepend_misspelled( AtkAttributeSet* attribute_set ) { if( ATK_TEXT_ATTR_INVALID == atk_text_attribute_misspelled ) diff --git a/vcl/unx/gtk/a11y/atktextattributes.hxx b/vcl/unx/gtk/a11y/atktextattributes.hxx index 11bcffe..cc78e1a 100644 --- a/vcl/unx/gtk/a11y/atktextattributes.hxx +++ b/vcl/unx/gtk/a11y/atktextattributes.hxx @@ -22,6 +22,7 @@ #include <com/sun/star/uno/Sequence.hxx> #include <com/sun/star/beans/PropertyValue.hpp> +#include <com/sun/star/accessibility/XAccessibleExtendedAttributes.hpp> #include <atk/atk.h> @@ -31,6 +32,10 @@ attribute_set_new_from_property_values( bool run_attributes_only, AtkText *text); +AtkAttributeSet* +attribute_set_new_from_extended_attributes( + const css::uno::Reference< css::accessibility::XAccessibleExtendedAttributes >& rExtendedAttributes ); + bool attribute_set_map_to_property_values( AtkAttributeSet* attribute_set, diff --git a/vcl/unx/gtk/a11y/atkwrapper.cxx b/vcl/unx/gtk/a11y/atkwrapper.cxx index 688ce62..f19c7e8 100644 --- a/vcl/unx/gtk/a11y/atkwrapper.cxx +++ b/vcl/unx/gtk/a11y/atkwrapper.cxx @@ -38,6 +38,7 @@ #include <com/sun/star/accessibility/XAccessibleRelationSet.hpp> #include <com/sun/star/accessibility/XAccessibleTable.hpp> #include <com/sun/star/accessibility/XAccessibleEditableText.hpp> +#include <com/sun/star/accessibility/XAccessibleExtendedAttributes.hpp> #include <com/sun/star/accessibility/XAccessibleImage.hpp> #include <com/sun/star/accessibility/XAccessibleHyperlink.hpp> #include <com/sun/star/accessibility/XAccessibleHypertext.hpp> @@ -62,6 +63,7 @@ #include "atkwrapper.hxx" #include "atkregistry.hxx" #include "atklistener.hxx" +#include "atktextattributes.hxx" #ifdef ENABLE_TRACING #include <stdio.h> @@ -395,6 +397,33 @@ wrapper_get_description( AtkObject *atk_obj ) /*****************************************************************************/ +static AtkAttributeSet * +wrapper_get_attributes( AtkObject *atk_obj ) +{ + AtkObjectWrapper *obj = ATK_OBJECT_WRAPPER( atk_obj ); + AtkAttributeSet *pSet = NULL; + + if( obj->mpContext ) + { + uno::Reference< accessibility::XAccessibleContext > xContext( obj->mpContext ); + try + { + uno::Reference< accessibility::XAccessibleExtendedAttributes > xExtendedAttrs( xContext, + uno::UNO_QUERY ); + if( xExtendedAttrs.is() ) + pSet = attribute_set_new_from_extended_attributes( xExtendedAttrs ); + } + catch(const uno::Exception&) + { + g_warning( "Exception in getAccessibleAttributes()" ); + } + } + + return pSet; +} + +/*****************************************************************************/ + static gint wrapper_get_n_children( AtkObject *atk_obj ) { @@ -601,6 +630,7 @@ atk_object_wrapper_class_init (AtkObjectWrapperClass *klass) // AtkObject methods atk_class->get_name = wrapper_get_name; atk_class->get_description = wrapper_get_description; + atk_class->get_attributes = wrapper_get_attributes; atk_class->get_n_children = wrapper_get_n_children; atk_class->ref_child = wrapper_ref_child; atk_class->get_index_in_parent = wrapper_get_index_in_parent;
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits