From 6f36ee01ab3d7934880bfd8b5d337288dcbf62c7 Mon Sep 17 00:00:00 2001 From: Kohei Yoshida Date: Tue, 28 Feb 2017 17:52:10 -0500 Subject: Revert my fix for tdf#71409, to hopefully fix tdf#104381. This reverts commit 87e040fd0f04307534920d0765af6d5878794a98. This reverts commit a0ef7474521413c8967559a635e6fdc0d88f1df6. Conflicts: vcl/unx/gtk/a11y/atkutil.cxx Change-Id: Ib3a799e27b2495ebd1e7723f1cb5babf0dfbc702 Reviewed-on: https://gerrit.libreoffice.org/34730 Tested-by: Jenkins Reviewed-by: Kohei Yoshida (cherry picked from commit 10077a06d8f6d08f276f99024528ee31a57390a9) Reviewed-on: https://gerrit.libreoffice.org/34732 Reviewed-by: Michael Meeks Tested-by: Michael Meeks --- vcl/unx/gtk/a11y/atkaction.cxx | 11 +- vcl/unx/gtk/a11y/atkcomponent.cxx | 11 +- vcl/unx/gtk/a11y/atkeditabletext.cxx | 11 +- vcl/unx/gtk/a11y/atkhypertext.cxx | 11 +- vcl/unx/gtk/a11y/atkimage.cxx | 11 +- vcl/unx/gtk/a11y/atklistener.cxx | 20 --- vcl/unx/gtk/a11y/atklistener.hxx | 2 - vcl/unx/gtk/a11y/atkselection.cxx | 11 +- vcl/unx/gtk/a11y/atktable.cxx | 11 +- vcl/unx/gtk/a11y/atktext.cxx | 44 ++++-- vcl/unx/gtk/a11y/atktextattributes.cxx | 11 +- vcl/unx/gtk/a11y/atkutil.cxx | 25 ++-- vcl/unx/gtk/a11y/atkvalue.cxx | 11 +- vcl/unx/gtk/a11y/atkwrapper.cxx | 266 ++++++++++++++++----------------- vcl/unx/gtk/a11y/atkwrapper.hxx | 34 ++++- 15 files changed, 258 insertions(+), 232 deletions(-) diff --git a/vcl/unx/gtk/a11y/atkaction.cxx b/vcl/unx/gtk/a11y/atkaction.cxx index ef3c2ba4e9f1..c9e3ec776f6a 100644 --- a/vcl/unx/gtk/a11y/atkaction.cxx +++ b/vcl/unx/gtk/a11y/atkaction.cxx @@ -48,11 +48,14 @@ static css::uno::Reference { AtkObjectWrapper *pWrap = ATK_OBJECT_WRAPPER( action ); - if (pWrap) + if( pWrap ) { - uno::Reference xAction( - pWrap->mpContext.get(), uno::UNO_QUERY); - return xAction; + if( !pWrap->mpAction.is() ) + { + pWrap->mpAction.set(pWrap->mpContext, css::uno::UNO_QUERY); + } + + return pWrap->mpAction; } return css::uno::Reference(); diff --git a/vcl/unx/gtk/a11y/atkcomponent.cxx b/vcl/unx/gtk/a11y/atkcomponent.cxx index 60600b2e9ff0..cbc4b8e38b27 100644 --- a/vcl/unx/gtk/a11y/atkcomponent.cxx +++ b/vcl/unx/gtk/a11y/atkcomponent.cxx @@ -27,11 +27,14 @@ static css::uno::Reference getComponent( AtkComponent *pComponent ) throw (uno::RuntimeException) { AtkObjectWrapper *pWrap = ATK_OBJECT_WRAPPER( pComponent ); - if (pWrap) + if( pWrap ) { - uno::Reference xComp( - pWrap->mpContext.get(), uno::UNO_QUERY); - return xComp; + if( !pWrap->mpComponent.is() ) + { + pWrap->mpComponent.set(pWrap->mpContext, css::uno::UNO_QUERY); + } + + return pWrap->mpComponent; } return css::uno::Reference(); diff --git a/vcl/unx/gtk/a11y/atkeditabletext.cxx b/vcl/unx/gtk/a11y/atkeditabletext.cxx index ee984bdeb7b6..f601f137dd04 100644 --- a/vcl/unx/gtk/a11y/atkeditabletext.cxx +++ b/vcl/unx/gtk/a11y/atkeditabletext.cxx @@ -31,11 +31,14 @@ static css::uno::Reference getEditableText( AtkEditableText *pEditableText ) throw (uno::RuntimeException) { AtkObjectWrapper *pWrap = ATK_OBJECT_WRAPPER( pEditableText ); - if (pWrap) + if( pWrap ) { - uno::Reference xET( - pWrap->mpContext.get(), uno::UNO_QUERY); - return xET; + if( !pWrap->mpEditableText.is() ) + { + pWrap->mpEditableText.set(pWrap->mpContext, css::uno::UNO_QUERY); + } + + return pWrap->mpEditableText; } return css::uno::Reference(); diff --git a/vcl/unx/gtk/a11y/atkhypertext.cxx b/vcl/unx/gtk/a11y/atkhypertext.cxx index 4c28babf9ee2..ff952558d50d 100644 --- a/vcl/unx/gtk/a11y/atkhypertext.cxx +++ b/vcl/unx/gtk/a11y/atkhypertext.cxx @@ -193,11 +193,14 @@ static css::uno::Reference getHypertext( AtkHypertext *pHypertext ) throw (uno::RuntimeException) { AtkObjectWrapper *pWrap = ATK_OBJECT_WRAPPER( pHypertext ); - if (pWrap) + if( pWrap ) { - uno::Reference xAH( - pWrap->mpContext.get(), uno::UNO_QUERY); - return xAH; + if( !pWrap->mpHypertext.is() ) + { + pWrap->mpHypertext.set(pWrap->mpContext, css::uno::UNO_QUERY); + } + + return pWrap->mpHypertext; } return css::uno::Reference(); diff --git a/vcl/unx/gtk/a11y/atkimage.cxx b/vcl/unx/gtk/a11y/atkimage.cxx index 873cddddbcd2..c1652a4ee582 100644 --- a/vcl/unx/gtk/a11y/atkimage.cxx +++ b/vcl/unx/gtk/a11y/atkimage.cxx @@ -39,11 +39,14 @@ static css::uno::Reference getImage( AtkImage *pImage ) throw (uno::RuntimeException) { AtkObjectWrapper *pWrap = ATK_OBJECT_WRAPPER( pImage ); - if (pWrap) + if( pWrap ) { - uno::Reference xAI( - pWrap->mpContext.get(), uno::UNO_QUERY); - return xAI; + if( !pWrap->mpImage.is() ) + { + pWrap->mpImage.set(pWrap->mpContext, css::uno::UNO_QUERY); + } + + return pWrap->mpImage; } return css::uno::Reference(); diff --git a/vcl/unx/gtk/a11y/atklistener.cxx b/vcl/unx/gtk/a11y/atklistener.cxx index 39930b274fda..5cc6083fc288 100644 --- a/vcl/unx/gtk/a11y/atklistener.cxx +++ b/vcl/unx/gtk/a11y/atklistener.cxx @@ -121,9 +121,6 @@ void AtkListener::updateChildList( css::uno::Reference const & pContext) { - if (!pContext.is()) - return; - m_aChildList.clear(); uno::Reference< accessibility::XAccessibleStateSet > xStateSet = pContext->getAccessibleStateSet(); @@ -258,19 +255,6 @@ void AtkListener::handleInvalidateChildren( } } -void AtkListener::stopListening() -{ - uno::Reference xBroadcaster( - mpWrapper->mpContext.get(), uno::UNO_QUERY); - - if (xBroadcaster.is()) - { - uno::Reference xListener(this); - if (xListener.is()) - xBroadcaster->removeAccessibleEventListener(xListener); - } -} - /*****************************************************************************/ static uno::Reference< accessibility::XAccessibleContext > @@ -362,10 +346,6 @@ void AtkListener::notifyEvent( const accessibility::AccessibleEventObject& aEven gboolean bState = eNewState != ATK_STATE_INVALID; AtkStateType eRealState = bState ? eNewState : eOldState; - if (eOldState == ATK_STATE_FOCUSED) - // Stop listening to object going out-of-focus. - stopListening(); - atk_object_notify_state_change( atk_obj, eRealState, bState ); break; } diff --git a/vcl/unx/gtk/a11y/atklistener.hxx b/vcl/unx/gtk/a11y/atklistener.hxx index fccf03181c37..39dbe5db9446 100644 --- a/vcl/unx/gtk/a11y/atklistener.hxx +++ b/vcl/unx/gtk/a11y/atklistener.hxx @@ -66,8 +66,6 @@ private: // Process INVALIDATE_ALL_CHILDREN notification void handleInvalidateChildren( const css::uno::Reference< css::accessibility::XAccessibleContext >& rxParent); - - void stopListening(); }; #endif // INCLUDED_VCL_UNX_GTK_A11Y_ATKLISTENER_HXX diff --git a/vcl/unx/gtk/a11y/atkselection.cxx b/vcl/unx/gtk/a11y/atkselection.cxx index 62dd4289fab7..eb3b2fcef167 100644 --- a/vcl/unx/gtk/a11y/atkselection.cxx +++ b/vcl/unx/gtk/a11y/atkselection.cxx @@ -27,11 +27,14 @@ static css::uno::Reference getSelection( AtkSelection *pSelection ) throw (uno::RuntimeException) { AtkObjectWrapper *pWrap = ATK_OBJECT_WRAPPER( pSelection ); - if (pWrap) + if( pWrap ) { - uno::Reference xAS( - pWrap->mpContext.get(), uno::UNO_QUERY); - return xAS; + if( !pWrap->mpSelection.is() ) + { + pWrap->mpSelection.set(pWrap->mpContext, css::uno::UNO_QUERY); + } + + return pWrap->mpSelection; } return css::uno::Reference(); diff --git a/vcl/unx/gtk/a11y/atktable.cxx b/vcl/unx/gtk/a11y/atktable.cxx index 75dd5a11dbde..a3423f6084d4 100644 --- a/vcl/unx/gtk/a11y/atktable.cxx +++ b/vcl/unx/gtk/a11y/atktable.cxx @@ -52,11 +52,14 @@ static css::uno::Reference getTable( AtkTable *pTable ) throw (uno::RuntimeException) { AtkObjectWrapper *pWrap = ATK_OBJECT_WRAPPER( pTable ); - if (pWrap) + if( pWrap ) { - uno::Reference xAT( - pWrap->mpContext.get(), uno::UNO_QUERY); - return xAT; + if( !pWrap->mpTable.is() ) + { + pWrap->mpTable.set(pWrap->mpContext, css::uno::UNO_QUERY); + } + + return pWrap->mpTable; } return css::uno::Reference(); diff --git a/vcl/unx/gtk/a11y/atktext.cxx b/vcl/unx/gtk/a11y/atktext.cxx index fbfd0fb41e11..425b3358f1b7 100644 --- a/vcl/unx/gtk/a11y/atktext.cxx +++ b/vcl/unx/gtk/a11y/atktext.cxx @@ -137,11 +137,14 @@ static css::uno::Reference getText( AtkText *pText ) throw (uno::RuntimeException) { AtkObjectWrapper *pWrap = ATK_OBJECT_WRAPPER( pText ); - if (pWrap) + if( pWrap ) { - uno::Reference xAT( - pWrap->mpContext.get(), uno::UNO_QUERY); - return xAT; + if( !pWrap->mpText.is() ) + { + pWrap->mpText.set(pWrap->mpContext, css::uno::UNO_QUERY); + } + + return pWrap->mpText; } return css::uno::Reference(); @@ -153,11 +156,14 @@ static css::uno::Reference getTextMarkup( AtkText *pText ) throw (uno::RuntimeException) { AtkObjectWrapper *pWrap = ATK_OBJECT_WRAPPER( pText ); - if (pWrap) + if( pWrap ) { - uno::Reference xATM( - pWrap->mpContext.get(), uno::UNO_QUERY); - return xATM; + if( !pWrap->mpTextMarkup.is() ) + { + pWrap->mpTextMarkup.set(pWrap->mpContext, css::uno::UNO_QUERY); + } + + return pWrap->mpTextMarkup; } return css::uno::Reference(); @@ -169,11 +175,14 @@ static css::uno::Reference getTextAttributes( AtkText *pText ) throw (uno::RuntimeException) { AtkObjectWrapper *pWrap = ATK_OBJECT_WRAPPER( pText ); - if (pWrap) + if( pWrap ) { - uno::Reference xATA( - pWrap->mpContext.get(), uno::UNO_QUERY); - return xATA; + if( !pWrap->mpTextAttributes.is() ) + { + pWrap->mpTextAttributes.set(pWrap->mpContext, css::uno::UNO_QUERY); + } + + return pWrap->mpTextAttributes; } return css::uno::Reference(); @@ -185,11 +194,14 @@ static css::uno::Reference getMultiLineText( AtkText *pText ) throw (uno::RuntimeException) { AtkObjectWrapper *pWrap = ATK_OBJECT_WRAPPER( pText ); - if (pWrap) + if( pWrap ) { - uno::Reference xAML( - pWrap->mpContext.get(), uno::UNO_QUERY); - return xAML; + if( !pWrap->mpMultiLineText.is() ) + { + pWrap->mpMultiLineText.set(pWrap->mpContext, css::uno::UNO_QUERY); + } + + return pWrap->mpMultiLineText; } return css::uno::Reference(); diff --git a/vcl/unx/gtk/a11y/atktextattributes.cxx b/vcl/unx/gtk/a11y/atktextattributes.cxx index 51c961892f6c..a9e26caef3d5 100644 --- a/vcl/unx/gtk/a11y/atktextattributes.cxx +++ b/vcl/unx/gtk/a11y/atktextattributes.cxx @@ -211,11 +211,14 @@ static css::uno::Reference getComponent( AtkText *pText ) throw (uno::RuntimeException) { AtkObjectWrapper *pWrap = ATK_OBJECT_WRAPPER( pText ); - if (pWrap) + if( pWrap ) { - uno::Reference xAC( - pWrap->mpContext.get(), uno::UNO_QUERY); - return xAC; + if( !pWrap->mpComponent.is() ) + { + pWrap->mpComponent.set(pWrap->mpContext, css::uno::UNO_QUERY); + } + + return pWrap->mpComponent; } return css::uno::Reference(); diff --git a/vcl/unx/gtk/a11y/atkutil.cxx b/vcl/unx/gtk/a11y/atkutil.cxx index bf809734f561..708417722788 100644 --- a/vcl/unx/gtk/a11y/atkutil.cxx +++ b/vcl/unx/gtk/a11y/atkutil.cxx @@ -86,24 +86,17 @@ atk_wrapper_focus_idle_handler (gpointer data) // also emit state-changed:focused event under the same condition. { AtkObjectWrapper* wrapper_obj = ATK_OBJECT_WRAPPER (atk_obj); - - if (wrapper_obj) + if( wrapper_obj && !wrapper_obj->mpText.is() ) { - uno::Reference xText( - wrapper_obj->mpContext.get(), uno::UNO_QUERY); - - if (xText.is()) + wrapper_obj->mpText.set(wrapper_obj->mpContext, css::uno::UNO_QUERY); + if ( wrapper_obj->mpText.is() ) { - try { - gint caretPos = xText->getCaretPosition(); - - if ( caretPos != -1 ) - { - atk_object_notify_state_change( atk_obj, ATK_STATE_FOCUSED, TRUE ); - g_signal_emit_by_name( atk_obj, "text_caret_moved", caretPos ); - } - } catch (const uno::Exception& e) { - SAL_INFO("vcl.a11y", "exception: " << e.Message); + gint caretPos = wrapper_obj->mpText->getCaretPosition(); + + if ( caretPos != -1 ) + { + atk_object_notify_state_change( atk_obj, ATK_STATE_FOCUSED, TRUE ); + g_signal_emit_by_name( atk_obj, "text_caret_moved", caretPos ); } } } diff --git a/vcl/unx/gtk/a11y/atkvalue.cxx b/vcl/unx/gtk/a11y/atkvalue.cxx index def434be6e75..7babb6bf7d29 100644 --- a/vcl/unx/gtk/a11y/atkvalue.cxx +++ b/vcl/unx/gtk/a11y/atkvalue.cxx @@ -29,11 +29,14 @@ static css::uno::Reference getValue( AtkValue *pValue ) throw (uno::RuntimeException) { AtkObjectWrapper *pWrap = ATK_OBJECT_WRAPPER( pValue ); - if (pWrap) + if( pWrap ) { - uno::Reference xAV( - pWrap->mpContext.get(), uno::UNO_QUERY); - return xAV; + if( !pWrap->mpValue.is() ) + { + pWrap->mpValue.set(pWrap->mpContext, css::uno::UNO_QUERY); + } + + return pWrap->mpValue; } return css::uno::Reference(); diff --git a/vcl/unx/gtk/a11y/atkwrapper.cxx b/vcl/unx/gtk/a11y/atkwrapper.cxx index e9f31562b65c..52f92186c846 100644 --- a/vcl/unx/gtk/a11y/atkwrapper.cxx +++ b/vcl/unx/gtk/a11y/atkwrapper.cxx @@ -335,31 +335,25 @@ wrapper_get_name( AtkObject *atk_obj ) { AtkObjectWrapper *obj = ATK_OBJECT_WRAPPER (atk_obj); - if (obj) + if( obj->mpContext.is() ) { - uno::Reference xContext( - obj->mpContext.get(), uno::UNO_QUERY); - - if (xContext.is()) - { - try { - OString aName = - OUStringToOString( - xContext->getAccessibleName(), - RTL_TEXTENCODING_UTF8); - - int nCmp = atk_obj->name ? rtl_str_compare( atk_obj->name, aName.getStr() ) : -1; - if( nCmp != 0 ) - { - if( atk_obj->name ) - g_free(atk_obj->name); - atk_obj->name = g_strdup(aName.getStr()); - } - } - catch(const uno::Exception&) { - g_warning( "Exception in getAccessibleName()" ); + try { + OString aName = + OUStringToOString( + obj->mpContext->getAccessibleName(), + RTL_TEXTENCODING_UTF8); + + int nCmp = atk_obj->name ? rtl_str_compare( atk_obj->name, aName.getStr() ) : -1; + if( nCmp != 0 ) + { + if( atk_obj->name ) + g_free(atk_obj->name); + atk_obj->name = g_strdup(aName.getStr()); } } + catch(const uno::Exception&) { + g_warning( "Exception in getAccessibleName()" ); + } } return ATK_OBJECT_CLASS (parent_class)->get_name(atk_obj); @@ -372,23 +366,19 @@ wrapper_get_description( AtkObject *atk_obj ) { AtkObjectWrapper *obj = ATK_OBJECT_WRAPPER (atk_obj); - if (obj) + if( obj->mpContext.is() ) { - uno::Reference xContext(obj->mpContext.get(), uno::UNO_QUERY); - if (xContext.is()) - { - try { - OString aDescription = - OUStringToOString( - xContext->getAccessibleDescription(), - RTL_TEXTENCODING_UTF8); - - g_free(atk_obj->description); - atk_obj->description = g_strdup(aDescription.getStr()); - } - catch(const uno::Exception&) { - g_warning( "Exception in getAccessibleDescription()" ); - } + try { + OString aDescription = + OUStringToOString( + obj->mpContext->getAccessibleDescription(), + RTL_TEXTENCODING_UTF8); + + g_free(atk_obj->description); + atk_obj->description = g_strdup(aDescription.getStr()); + } + catch(const uno::Exception&) { + g_warning( "Exception in getAccessibleDescription()" ); } } @@ -407,7 +397,7 @@ wrapper_get_attributes( AtkObject *atk_obj ) try { uno::Reference< accessibility::XAccessibleExtendedAttributes > - xExtendedAttrs(obj->mpContext.get(), uno::UNO_QUERY); + xExtendedAttrs( obj->mpContext, uno::UNO_QUERY ); if( xExtendedAttrs.is() ) pSet = attribute_set_new_from_extended_attributes( xExtendedAttrs ); } @@ -427,20 +417,14 @@ wrapper_get_n_children( AtkObject *atk_obj ) AtkObjectWrapper *obj = ATK_OBJECT_WRAPPER (atk_obj); gint n = 0; - if (!obj) - return n; - - uno::Reference xContext(obj->mpContext.get(), uno::UNO_QUERY); - if (!xContext.is()) - return n; - - try - { - n = xContext->getAccessibleChildCount(); - } - catch(const uno::Exception&) + if( obj->mpContext.is() ) { - OSL_FAIL("Exception in getAccessibleChildCount()" ); + try { + n = obj->mpContext->getAccessibleChildCount(); + } + catch(const uno::Exception&) { + OSL_FAIL("Exception in getAccessibleChildCount()" ); + } } return n; @@ -462,22 +446,17 @@ wrapper_ref_child( AtkObject *atk_obj, return obj->child_about_to_be_removed; } - if (!obj) - return child; - - uno::Reference xContext(obj->mpContext.get(), uno::UNO_QUERY); - if (!xContext.is()) - return child; - - try + if( obj->mpContext.is() ) { - uno::Reference< accessibility::XAccessible > xAccessible = - xContext->getAccessibleChild( i ); + try { + uno::Reference< accessibility::XAccessible > xAccessible = + obj->mpContext->getAccessibleChild( i ); - child = atk_object_wrapper_ref( xAccessible ); - } - catch(const uno::Exception&) { - OSL_FAIL("Exception in getAccessibleChild"); + child = atk_object_wrapper_ref( xAccessible ); + } + catch(const uno::Exception&) { + OSL_FAIL("Exception in getAccessibleChild"); + } } return child; @@ -491,17 +470,13 @@ wrapper_get_index_in_parent( AtkObject *atk_obj ) AtkObjectWrapper *obj = ATK_OBJECT_WRAPPER (atk_obj); gint i = -1; - if (obj) + if( obj->mpContext.is() ) { - uno::Reference xContext(obj->mpContext.get(), uno::UNO_QUERY); - if (xContext.is()) - { - try { - i = xContext->getAccessibleIndexInParent(); - } - catch(const uno::Exception&) { - g_warning( "Exception in getAccessibleIndexInParent()" ); - } + try { + i = obj->mpContext->getAccessibleIndexInParent(); + } + catch(const uno::Exception&) { + g_warning( "Exception in getAccessibleIndexInParent()" ); } } return i; @@ -515,44 +490,40 @@ wrapper_ref_relation_set( AtkObject *atk_obj ) AtkObjectWrapper *obj = ATK_OBJECT_WRAPPER (atk_obj); AtkRelationSet *pSet = atk_relation_set_new(); - if (obj) + if( obj->mpContext.is() ) { - uno::Reference xContext(obj->mpContext.get(), uno::UNO_QUERY); - if (xContext.is()) - { - try { - uno::Reference< accessibility::XAccessibleRelationSet > xRelationSet( - xContext->getAccessibleRelationSet() - ); + try { + uno::Reference< accessibility::XAccessibleRelationSet > xRelationSet( + obj->mpContext->getAccessibleRelationSet() + ); + + 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; - sal_Int32 nRelations = xRelationSet.is() ? xRelationSet->getRelationCount() : 0; - for( sal_Int32 n = 0; n < nRelations; n++ ) + for (sal_uInt32 i = 0; i < nTargetCount; ++i) { - 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 ) ); + 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 ) ); } - catch(const uno::Exception &) { - g_object_unref( G_OBJECT( pSet ) ); - pSet = nullptr; - } + } + catch(const uno::Exception &) { + g_object_unref( G_OBJECT( pSet ) ); + pSet = nullptr; } } @@ -565,43 +536,37 @@ wrapper_ref_state_set( AtkObject *atk_obj ) AtkObjectWrapper *obj = ATK_OBJECT_WRAPPER (atk_obj); AtkStateSet *pSet = atk_state_set_new(); - if (obj) + if( obj->mpContext.is() ) { - uno::Reference xContext(obj->mpContext.get(), uno::UNO_QUERY); - if (xContext.is()) - { - try + try { + uno::Reference< accessibility::XAccessibleStateSet > xStateSet( + obj->mpContext->getAccessibleStateSet()); + + if( xStateSet.is() ) { - uno::Reference< accessibility::XAccessibleStateSet > xStateSet( - xContext->getAccessibleStateSet()); + uno::Sequence< sal_Int16 > aStates = xStateSet->getStates(); - if( xStateSet.is() ) + for( sal_Int32 n = 0; n < aStates.getLength(); n++ ) { - uno::Sequence< sal_Int16 > aStates = xStateSet->getStates(); - - for( sal_Int32 n = 0; n < aStates.getLength(); n++ ) - { - // ATK_STATE_LAST_DEFINED is used to check if the state - // is unmapped, do not report it to Atk - if ( mapAtkState( aStates[n] ) != ATK_STATE_LAST_DEFINED ) - atk_state_set_add_state( pSet, mapAtkState( aStates[n] ) ); - } - - // We need to emulate FOCUS state for menus, menu-items etc. - if( atk_obj == atk_get_focus_object() ) - atk_state_set_add_state( pSet, ATK_STATE_FOCUSED ); + // ATK_STATE_LAST_DEFINED is used to check if the state + // is unmapped, do not report it to Atk + if ( mapAtkState( aStates[n] ) != ATK_STATE_LAST_DEFINED ) + atk_state_set_add_state( pSet, mapAtkState( aStates[n] ) ); + } + + // We need to emulate FOCUS state for menus, menu-items etc. + if( atk_obj == atk_get_focus_object() ) + atk_state_set_add_state( pSet, ATK_STATE_FOCUSED ); /* FIXME - should we do this ? - else - atk_state_set_remove_state( pSet, ATK_STATE_FOCUSED ); + else + atk_state_set_remove_state( pSet, ATK_STATE_FOCUSED ); */ - } } + } - catch(const uno::Exception &) - { - g_warning( "Exception in wrapper_ref_state_set" ); - atk_state_set_add_state( pSet, ATK_STATE_DEFUNCT ); - } + catch(const uno::Exception &) { + g_warning( "Exception in wrapper_ref_state_set" ); + atk_state_set_add_state( pSet, ATK_STATE_DEFUNCT ); } } else @@ -651,9 +616,18 @@ atk_object_wrapper_class_init (AtkObjectWrapperClass *klass) } static void -atk_object_wrapper_init (AtkObjectWrapper* wrapper, AtkObjectWrapperClass*) +atk_object_wrapper_init (AtkObjectWrapper *wrapper, + AtkObjectWrapperClass*) { - wrapper->mpContext = nullptr; + wrapper->mpAction = nullptr; + wrapper->mpComponent = nullptr; + wrapper->mpEditableText = nullptr; + wrapper->mpHypertext = nullptr; + wrapper->mpImage = nullptr; + wrapper->mpSelection = nullptr; + wrapper->mpTable = nullptr; + wrapper->mpText = nullptr; + wrapper->mpValue = nullptr; } } // extern "C" @@ -931,6 +905,18 @@ void atk_object_wrapper_set_role(AtkObjectWrapper* wrapper, sal_Int16 role) void atk_object_wrapper_dispose(AtkObjectWrapper* wrapper) { wrapper->mpContext.clear(); + wrapper->mpAction.clear(); + wrapper->mpComponent.clear(); + wrapper->mpEditableText.clear(); + wrapper->mpHypertext.clear(); + wrapper->mpImage.clear(); + wrapper->mpSelection.clear(); + wrapper->mpMultiLineText.clear(); + wrapper->mpTable.clear(); + wrapper->mpText.clear(); + wrapper->mpTextMarkup.clear(); + wrapper->mpTextAttributes.clear(); + wrapper->mpValue.clear(); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/unx/gtk/a11y/atkwrapper.hxx b/vcl/unx/gtk/a11y/atkwrapper.hxx index 87ff3b49cb2c..e8ab83b5c778 100644 --- a/vcl/unx/gtk/a11y/atkwrapper.hxx +++ b/vcl/unx/gtk/a11y/atkwrapper.hxx @@ -22,19 +22,49 @@ #include #include -#include extern "C" { +namespace com { namespace sun { namespace star { namespace accessibility { + class XAccessibleAction; + class XAccessibleComponent; + class XAccessibleEditableText; + class XAccessibleHypertext; + class XAccessibleImage; + class XAccessibleMultiLineText; + class XAccessibleSelection; + class XAccessibleTable; + class XAccessibleText; + class XAccessibleTextMarkup; + class XAccessibleTextAttributes; + class XAccessibleValue; +} } } } + struct AtkObjectWrapper { AtkObject aParent; css::uno::Reference mpAccessible; - css::uno::WeakReference mpContext; + css::uno::Reference mpContext; + css::uno::Reference mpAction; + css::uno::Reference mpComponent; + css::uno::Reference + mpEditableText; + css::uno::Reference mpHypertext; + css::uno::Reference mpImage; + css::uno::Reference + mpMultiLineText; + css::uno::Reference mpSelection; + css::uno::Reference mpTable; + css::uno::Reference mpText; + css::uno::Reference mpTextMarkup; + css::uno::Reference + mpTextAttributes; + css::uno::Reference mpValue; AtkObject *child_about_to_be_removed; gint index_of_child_about_to_be_removed; +// OString * m_pKeyBindings }; struct AtkObjectWrapperClass -- cgit v1.2.3