summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacobo Aragunde Pérez <jaragunde@igalia.com>2015-02-03 16:48:01 +0100
committerJacobo Aragunde Pérez <jaragunde@igalia.com>2015-02-05 14:06:34 +0100
commit1e6515e64cb4a40071e09d5df000a94f96311ea1 (patch)
tree5a7b91ddd1d8ca6abeefdb8784ff3ae24231b613
parent119d9c33b03790d52d57a27854064ec554a5777c (diff)
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
-rw-r--r--vcl/unx/gtk/a11y/atktextattributes.cxx31
-rw-r--r--vcl/unx/gtk/a11y/atktextattributes.hxx5
-rw-r--r--vcl/unx/gtk/a11y/atkwrapper.cxx30
3 files changed, 66 insertions, 0 deletions
diff --git a/vcl/unx/gtk/a11y/atktextattributes.cxx b/vcl/unx/gtk/a11y/atktextattributes.cxx
index a7487c0f6e98..7855a69ea72a 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 11bcffe1d665..cc78e1a836ef 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 6d972ffba7ab..80f347888f68 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;