From 0ed7e590746db719f15b97a5d9cfca9b1ad3c773 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= Date: Sat, 23 Mar 2019 14:23:44 +0000 Subject: [PATCH] factor out the adding to an atk relation set code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ie81cfaab1fac15648fc8ba89391bdedd5c1e6c90 Reviewed-on: https://gerrit.libreoffice.org/69590 Tested-by: Jenkins Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- vcl/unx/gtk/a11y/atkwrapper.cxx | 43 ++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/vcl/unx/gtk/a11y/atkwrapper.cxx b/vcl/unx/gtk/a11y/atkwrapper.cxx index 875d5a26fb9f..2aa1e50bc6c7 100644 --- a/vcl/unx/gtk/a11y/atkwrapper.cxx +++ b/vcl/unx/gtk/a11y/atkwrapper.cxx @@ -496,6 +496,29 @@ wrapper_get_index_in_parent( AtkObject *atk_obj ) /*****************************************************************************/ +static void +relation_set_add(AtkRelationSet *pSet, const accessibility::AccessibleRelation& rRelation) +{ + sal_uInt32 nTargetCount = rRelation.TargetSet.getLength(); + + std::vector aTargets; + + for (sal_uInt32 i = 0; i < nTargetCount; ++i) + { + uno::Reference< accessibility::XAccessible > xAccessible( + rRelation.TargetSet[i], uno::UNO_QUERY ); + aTargets.push_back(atk_object_wrapper_ref(xAccessible)); + } + + AtkRelation *pRel = + atk_relation_new( + aTargets.data(), nTargetCount, + mapRelationType( rRelation.RelationType ) + ); + atk_relation_set_add( pSet, pRel ); + g_object_unref( G_OBJECT( pRel ) ); +} + static AtkRelationSet * wrapper_ref_relation_set( AtkObject *atk_obj ) { @@ -517,25 +540,7 @@ wrapper_ref_relation_set( AtkObject *atk_obj ) sal_Int32 nRelations = xRelationSet.is() ? xRelationSet->getRelationCount() : 0; for( sal_Int32 n = 0; n < nRelations; n++ ) { - accessibility::AccessibleRelation aRelation = xRelationSet->getRelation( n ); - sal_uInt32 nTargetCount = aRelation.TargetSet.getLength(); - - std::vector aTargets; - - for (sal_uInt32 i = 0; i < nTargetCount; ++i) - { - uno::Reference< accessibility::XAccessible > xAccessible( - aRelation.TargetSet[i], uno::UNO_QUERY ); - aTargets.push_back(atk_object_wrapper_ref(xAccessible)); - } - - AtkRelation *pRel = - atk_relation_new( - aTargets.data(), nTargetCount, - mapRelationType( aRelation.RelationType ) - ); - atk_relation_set_add( pSet, pRel ); - g_object_unref( G_OBJECT( pRel ) ); + relation_set_add(pSet, xRelationSet->getRelation(n)); } } catch(const uno::Exception &) { -- 2.18.1