Kaydet (Commit) 1e6515e6 authored tarafından Jacobo Aragunde Pérez's avatar Jacobo Aragunde Pérez

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
üst 119d9c33
...@@ -1211,6 +1211,37 @@ attribute_set_new_from_property_values( ...@@ -1211,6 +1211,37 @@ attribute_set_new_from_property_values(
return attribute_set; 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 ) AtkAttributeSet* attribute_set_prepend_misspelled( AtkAttributeSet* attribute_set )
{ {
if( ATK_TEXT_ATTR_INVALID == atk_text_attribute_misspelled ) if( ATK_TEXT_ATTR_INVALID == atk_text_attribute_misspelled )
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include <com/sun/star/uno/Sequence.hxx> #include <com/sun/star/uno/Sequence.hxx>
#include <com/sun/star/beans/PropertyValue.hpp> #include <com/sun/star/beans/PropertyValue.hpp>
#include <com/sun/star/accessibility/XAccessibleExtendedAttributes.hpp>
#include <atk/atk.h> #include <atk/atk.h>
...@@ -31,6 +32,10 @@ attribute_set_new_from_property_values( ...@@ -31,6 +32,10 @@ attribute_set_new_from_property_values(
bool run_attributes_only, bool run_attributes_only,
AtkText *text); AtkText *text);
AtkAttributeSet*
attribute_set_new_from_extended_attributes(
const css::uno::Reference< css::accessibility::XAccessibleExtendedAttributes >& rExtendedAttributes );
bool bool
attribute_set_map_to_property_values( attribute_set_map_to_property_values(
AtkAttributeSet* attribute_set, AtkAttributeSet* attribute_set,
......
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
#include <com/sun/star/accessibility/XAccessibleRelationSet.hpp> #include <com/sun/star/accessibility/XAccessibleRelationSet.hpp>
#include <com/sun/star/accessibility/XAccessibleTable.hpp> #include <com/sun/star/accessibility/XAccessibleTable.hpp>
#include <com/sun/star/accessibility/XAccessibleEditableText.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/XAccessibleImage.hpp>
#include <com/sun/star/accessibility/XAccessibleHyperlink.hpp> #include <com/sun/star/accessibility/XAccessibleHyperlink.hpp>
#include <com/sun/star/accessibility/XAccessibleHypertext.hpp> #include <com/sun/star/accessibility/XAccessibleHypertext.hpp>
...@@ -62,6 +63,7 @@ ...@@ -62,6 +63,7 @@
#include "atkwrapper.hxx" #include "atkwrapper.hxx"
#include "atkregistry.hxx" #include "atkregistry.hxx"
#include "atklistener.hxx" #include "atklistener.hxx"
#include "atktextattributes.hxx"
#ifdef ENABLE_TRACING #ifdef ENABLE_TRACING
#include <stdio.h> #include <stdio.h>
...@@ -395,6 +397,33 @@ wrapper_get_description( AtkObject *atk_obj ) ...@@ -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 static gint
wrapper_get_n_children( AtkObject *atk_obj ) wrapper_get_n_children( AtkObject *atk_obj )
{ {
...@@ -601,6 +630,7 @@ atk_object_wrapper_class_init (AtkObjectWrapperClass *klass) ...@@ -601,6 +630,7 @@ atk_object_wrapper_class_init (AtkObjectWrapperClass *klass)
// AtkObject methods // AtkObject methods
atk_class->get_name = wrapper_get_name; atk_class->get_name = wrapper_get_name;
atk_class->get_description = wrapper_get_description; 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->get_n_children = wrapper_get_n_children;
atk_class->ref_child = wrapper_ref_child; atk_class->ref_child = wrapper_ref_child;
atk_class->get_index_in_parent = wrapper_get_index_in_parent; atk_class->get_index_in_parent = wrapper_get_index_in_parent;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment