Kaydet (Commit) a0ef7474 authored tarafından Kohei Yoshida's avatar Kohei Yoshida Kaydeden (comit) Kohei Yoshida

tdf#71409: Use weak reference to avoid potential circular references.

AtkListener shouldn't be holding a reference back to the context /
broadcaster it listens to, as the latter also holds a reference to
the former.

Change-Id: Ie75cc4667f614752db710c20acbb83b93783654f
Reviewed-on: https://gerrit.libreoffice.org/31063Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarKohei Yoshida <libreoffice@kohei.us>
üst e010834d
...@@ -48,14 +48,11 @@ static css::uno::Reference<css::accessibility::XAccessibleAction> ...@@ -48,14 +48,11 @@ static css::uno::Reference<css::accessibility::XAccessibleAction>
{ {
AtkObjectWrapper *pWrap = ATK_OBJECT_WRAPPER( action ); AtkObjectWrapper *pWrap = ATK_OBJECT_WRAPPER( action );
if( pWrap ) if (pWrap)
{ {
if( !pWrap->mpAction.is() ) uno::Reference<accessibility::XAccessibleAction> xAction(
{ pWrap->mpContext.get(), uno::UNO_QUERY);
pWrap->mpAction.set(pWrap->mpContext, css::uno::UNO_QUERY); return xAction;
}
return pWrap->mpAction;
} }
return css::uno::Reference<css::accessibility::XAccessibleAction>(); return css::uno::Reference<css::accessibility::XAccessibleAction>();
......
...@@ -27,14 +27,11 @@ static css::uno::Reference<css::accessibility::XAccessibleComponent> ...@@ -27,14 +27,11 @@ static css::uno::Reference<css::accessibility::XAccessibleComponent>
getComponent( AtkComponent *pComponent ) throw (uno::RuntimeException) getComponent( AtkComponent *pComponent ) throw (uno::RuntimeException)
{ {
AtkObjectWrapper *pWrap = ATK_OBJECT_WRAPPER( pComponent ); AtkObjectWrapper *pWrap = ATK_OBJECT_WRAPPER( pComponent );
if( pWrap ) if (pWrap)
{ {
if( !pWrap->mpComponent.is() ) uno::Reference<accessibility::XAccessibleComponent> xComp(
{ pWrap->mpContext.get(), uno::UNO_QUERY);
pWrap->mpComponent.set(pWrap->mpContext, css::uno::UNO_QUERY); return xComp;
}
return pWrap->mpComponent;
} }
return css::uno::Reference<css::accessibility::XAccessibleComponent>(); return css::uno::Reference<css::accessibility::XAccessibleComponent>();
......
...@@ -31,14 +31,11 @@ static css::uno::Reference<css::accessibility::XAccessibleEditableText> ...@@ -31,14 +31,11 @@ static css::uno::Reference<css::accessibility::XAccessibleEditableText>
getEditableText( AtkEditableText *pEditableText ) throw (uno::RuntimeException) getEditableText( AtkEditableText *pEditableText ) throw (uno::RuntimeException)
{ {
AtkObjectWrapper *pWrap = ATK_OBJECT_WRAPPER( pEditableText ); AtkObjectWrapper *pWrap = ATK_OBJECT_WRAPPER( pEditableText );
if( pWrap ) if (pWrap)
{ {
if( !pWrap->mpEditableText.is() ) uno::Reference<accessibility::XAccessibleEditableText> xET(
{ pWrap->mpContext.get(), uno::UNO_QUERY);
pWrap->mpEditableText.set(pWrap->mpContext, css::uno::UNO_QUERY); return xET;
}
return pWrap->mpEditableText;
} }
return css::uno::Reference<css::accessibility::XAccessibleEditableText>(); return css::uno::Reference<css::accessibility::XAccessibleEditableText>();
......
...@@ -193,14 +193,11 @@ static css::uno::Reference<css::accessibility::XAccessibleHypertext> ...@@ -193,14 +193,11 @@ static css::uno::Reference<css::accessibility::XAccessibleHypertext>
getHypertext( AtkHypertext *pHypertext ) throw (uno::RuntimeException) getHypertext( AtkHypertext *pHypertext ) throw (uno::RuntimeException)
{ {
AtkObjectWrapper *pWrap = ATK_OBJECT_WRAPPER( pHypertext ); AtkObjectWrapper *pWrap = ATK_OBJECT_WRAPPER( pHypertext );
if( pWrap ) if (pWrap)
{ {
if( !pWrap->mpHypertext.is() ) uno::Reference<accessibility::XAccessibleHypertext> xAH(
{ pWrap->mpContext.get(), uno::UNO_QUERY);
pWrap->mpHypertext.set(pWrap->mpContext, css::uno::UNO_QUERY); return xAH;
}
return pWrap->mpHypertext;
} }
return css::uno::Reference<css::accessibility::XAccessibleHypertext>(); return css::uno::Reference<css::accessibility::XAccessibleHypertext>();
......
...@@ -39,14 +39,11 @@ static css::uno::Reference<css::accessibility::XAccessibleImage> ...@@ -39,14 +39,11 @@ static css::uno::Reference<css::accessibility::XAccessibleImage>
getImage( AtkImage *pImage ) throw (uno::RuntimeException) getImage( AtkImage *pImage ) throw (uno::RuntimeException)
{ {
AtkObjectWrapper *pWrap = ATK_OBJECT_WRAPPER( pImage ); AtkObjectWrapper *pWrap = ATK_OBJECT_WRAPPER( pImage );
if( pWrap ) if (pWrap)
{ {
if( !pWrap->mpImage.is() ) uno::Reference<accessibility::XAccessibleImage> xAI(
{ pWrap->mpContext.get(), uno::UNO_QUERY);
pWrap->mpImage.set(pWrap->mpContext, css::uno::UNO_QUERY); return xAI;
}
return pWrap->mpImage;
} }
return css::uno::Reference<css::accessibility::XAccessibleImage>(); return css::uno::Reference<css::accessibility::XAccessibleImage>();
......
...@@ -27,14 +27,11 @@ static css::uno::Reference<css::accessibility::XAccessibleSelection> ...@@ -27,14 +27,11 @@ static css::uno::Reference<css::accessibility::XAccessibleSelection>
getSelection( AtkSelection *pSelection ) throw (uno::RuntimeException) getSelection( AtkSelection *pSelection ) throw (uno::RuntimeException)
{ {
AtkObjectWrapper *pWrap = ATK_OBJECT_WRAPPER( pSelection ); AtkObjectWrapper *pWrap = ATK_OBJECT_WRAPPER( pSelection );
if( pWrap ) if (pWrap)
{ {
if( !pWrap->mpSelection.is() ) uno::Reference<accessibility::XAccessibleSelection> xAS(
{ pWrap->mpContext.get(), uno::UNO_QUERY);
pWrap->mpSelection.set(pWrap->mpContext, css::uno::UNO_QUERY); return xAS;
}
return pWrap->mpSelection;
} }
return css::uno::Reference<css::accessibility::XAccessibleSelection>(); return css::uno::Reference<css::accessibility::XAccessibleSelection>();
......
...@@ -52,14 +52,11 @@ static css::uno::Reference<css::accessibility::XAccessibleTable> ...@@ -52,14 +52,11 @@ static css::uno::Reference<css::accessibility::XAccessibleTable>
getTable( AtkTable *pTable ) throw (uno::RuntimeException) getTable( AtkTable *pTable ) throw (uno::RuntimeException)
{ {
AtkObjectWrapper *pWrap = ATK_OBJECT_WRAPPER( pTable ); AtkObjectWrapper *pWrap = ATK_OBJECT_WRAPPER( pTable );
if( pWrap ) if (pWrap)
{ {
if( !pWrap->mpTable.is() ) uno::Reference<accessibility::XAccessibleTable> xAT(
{ pWrap->mpContext.get(), uno::UNO_QUERY);
pWrap->mpTable.set(pWrap->mpContext, css::uno::UNO_QUERY); return xAT;
}
return pWrap->mpTable;
} }
return css::uno::Reference<css::accessibility::XAccessibleTable>(); return css::uno::Reference<css::accessibility::XAccessibleTable>();
......
...@@ -137,14 +137,11 @@ static css::uno::Reference<css::accessibility::XAccessibleText> ...@@ -137,14 +137,11 @@ static css::uno::Reference<css::accessibility::XAccessibleText>
getText( AtkText *pText ) throw (uno::RuntimeException) getText( AtkText *pText ) throw (uno::RuntimeException)
{ {
AtkObjectWrapper *pWrap = ATK_OBJECT_WRAPPER( pText ); AtkObjectWrapper *pWrap = ATK_OBJECT_WRAPPER( pText );
if( pWrap ) if (pWrap)
{ {
if( !pWrap->mpText.is() ) uno::Reference<accessibility::XAccessibleText> xAT(
{ pWrap->mpContext.get(), uno::UNO_QUERY);
pWrap->mpText.set(pWrap->mpContext, css::uno::UNO_QUERY); return xAT;
}
return pWrap->mpText;
} }
return css::uno::Reference<css::accessibility::XAccessibleText>(); return css::uno::Reference<css::accessibility::XAccessibleText>();
...@@ -156,14 +153,11 @@ static css::uno::Reference<css::accessibility::XAccessibleTextMarkup> ...@@ -156,14 +153,11 @@ static css::uno::Reference<css::accessibility::XAccessibleTextMarkup>
getTextMarkup( AtkText *pText ) throw (uno::RuntimeException) getTextMarkup( AtkText *pText ) throw (uno::RuntimeException)
{ {
AtkObjectWrapper *pWrap = ATK_OBJECT_WRAPPER( pText ); AtkObjectWrapper *pWrap = ATK_OBJECT_WRAPPER( pText );
if( pWrap ) if (pWrap)
{ {
if( !pWrap->mpTextMarkup.is() ) uno::Reference<accessibility::XAccessibleTextMarkup> xATM(
{ pWrap->mpContext.get(), uno::UNO_QUERY);
pWrap->mpTextMarkup.set(pWrap->mpContext, css::uno::UNO_QUERY); return xATM;
}
return pWrap->mpTextMarkup;
} }
return css::uno::Reference<css::accessibility::XAccessibleTextMarkup>(); return css::uno::Reference<css::accessibility::XAccessibleTextMarkup>();
...@@ -175,14 +169,11 @@ static css::uno::Reference<css::accessibility::XAccessibleTextAttributes> ...@@ -175,14 +169,11 @@ static css::uno::Reference<css::accessibility::XAccessibleTextAttributes>
getTextAttributes( AtkText *pText ) throw (uno::RuntimeException) getTextAttributes( AtkText *pText ) throw (uno::RuntimeException)
{ {
AtkObjectWrapper *pWrap = ATK_OBJECT_WRAPPER( pText ); AtkObjectWrapper *pWrap = ATK_OBJECT_WRAPPER( pText );
if( pWrap ) if (pWrap)
{ {
if( !pWrap->mpTextAttributes.is() ) uno::Reference<accessibility::XAccessibleTextAttributes> xATA(
{ pWrap->mpContext.get(), uno::UNO_QUERY);
pWrap->mpTextAttributes.set(pWrap->mpContext, css::uno::UNO_QUERY); return xATA;
}
return pWrap->mpTextAttributes;
} }
return css::uno::Reference<css::accessibility::XAccessibleTextAttributes>(); return css::uno::Reference<css::accessibility::XAccessibleTextAttributes>();
...@@ -194,14 +185,11 @@ static css::uno::Reference<css::accessibility::XAccessibleMultiLineText> ...@@ -194,14 +185,11 @@ static css::uno::Reference<css::accessibility::XAccessibleMultiLineText>
getMultiLineText( AtkText *pText ) throw (uno::RuntimeException) getMultiLineText( AtkText *pText ) throw (uno::RuntimeException)
{ {
AtkObjectWrapper *pWrap = ATK_OBJECT_WRAPPER( pText ); AtkObjectWrapper *pWrap = ATK_OBJECT_WRAPPER( pText );
if( pWrap ) if (pWrap)
{ {
if( !pWrap->mpMultiLineText.is() ) uno::Reference<accessibility::XAccessibleMultiLineText> xAML(
{ pWrap->mpContext.get(), uno::UNO_QUERY);
pWrap->mpMultiLineText.set(pWrap->mpContext, css::uno::UNO_QUERY); return xAML;
}
return pWrap->mpMultiLineText;
} }
return css::uno::Reference<css::accessibility::XAccessibleMultiLineText>(); return css::uno::Reference<css::accessibility::XAccessibleMultiLineText>();
......
...@@ -211,14 +211,11 @@ static css::uno::Reference<css::accessibility::XAccessibleComponent> ...@@ -211,14 +211,11 @@ static css::uno::Reference<css::accessibility::XAccessibleComponent>
getComponent( AtkText *pText ) throw (uno::RuntimeException) getComponent( AtkText *pText ) throw (uno::RuntimeException)
{ {
AtkObjectWrapper *pWrap = ATK_OBJECT_WRAPPER( pText ); AtkObjectWrapper *pWrap = ATK_OBJECT_WRAPPER( pText );
if( pWrap ) if (pWrap)
{ {
if( !pWrap->mpComponent.is() ) uno::Reference<accessibility::XAccessibleComponent> xAC(
{ pWrap->mpContext.get(), uno::UNO_QUERY);
pWrap->mpComponent.set(pWrap->mpContext, css::uno::UNO_QUERY); return xAC;
}
return pWrap->mpComponent;
} }
return css::uno::Reference<css::accessibility::XAccessibleComponent>(); return css::uno::Reference<css::accessibility::XAccessibleComponent>();
......
...@@ -86,12 +86,15 @@ atk_wrapper_focus_idle_handler (gpointer data) ...@@ -86,12 +86,15 @@ atk_wrapper_focus_idle_handler (gpointer data)
// also emit state-changed:focused event under the same condition. // also emit state-changed:focused event under the same condition.
{ {
AtkObjectWrapper* wrapper_obj = ATK_OBJECT_WRAPPER (atk_obj); AtkObjectWrapper* wrapper_obj = ATK_OBJECT_WRAPPER (atk_obj);
if( wrapper_obj && !wrapper_obj->mpText.is() )
if (wrapper_obj)
{ {
wrapper_obj->mpText.set(wrapper_obj->mpContext, css::uno::UNO_QUERY); uno::Reference<accessibility::XAccessibleText> xText(
if ( wrapper_obj->mpText.is() ) wrapper_obj->mpContext.get(), uno::UNO_QUERY);
if (xText.is())
{ {
gint caretPos = wrapper_obj->mpText->getCaretPosition(); gint caretPos = xText->getCaretPosition();
if ( caretPos != -1 ) if ( caretPos != -1 )
{ {
......
...@@ -29,14 +29,11 @@ static css::uno::Reference<css::accessibility::XAccessibleValue> ...@@ -29,14 +29,11 @@ static css::uno::Reference<css::accessibility::XAccessibleValue>
getValue( AtkValue *pValue ) throw (uno::RuntimeException) getValue( AtkValue *pValue ) throw (uno::RuntimeException)
{ {
AtkObjectWrapper *pWrap = ATK_OBJECT_WRAPPER( pValue ); AtkObjectWrapper *pWrap = ATK_OBJECT_WRAPPER( pValue );
if( pWrap ) if (pWrap)
{ {
if( !pWrap->mpValue.is() ) uno::Reference<accessibility::XAccessibleValue> xAV(
{ pWrap->mpContext.get(), uno::UNO_QUERY);
pWrap->mpValue.set(pWrap->mpContext, css::uno::UNO_QUERY); return xAV;
}
return pWrap->mpValue;
} }
return css::uno::Reference<css::accessibility::XAccessibleValue>(); return css::uno::Reference<css::accessibility::XAccessibleValue>();
......
...@@ -335,24 +335,30 @@ wrapper_get_name( AtkObject *atk_obj ) ...@@ -335,24 +335,30 @@ wrapper_get_name( AtkObject *atk_obj )
{ {
AtkObjectWrapper *obj = ATK_OBJECT_WRAPPER (atk_obj); AtkObjectWrapper *obj = ATK_OBJECT_WRAPPER (atk_obj);
if( obj->mpContext.is() ) if (obj)
{ {
try { uno::Reference<accessibility::XAccessibleContext> xContext(
OString aName = obj->mpContext.get(), uno::UNO_QUERY);
OUStringToOString(
obj->mpContext->getAccessibleName(), if (xContext.is())
RTL_TEXTENCODING_UTF8); {
try {
int nCmp = atk_obj->name ? rtl_str_compare( atk_obj->name, aName.getStr() ) : -1; OString aName =
if( nCmp != 0 ) OUStringToOString(
{ xContext->getAccessibleName(),
if( atk_obj->name ) RTL_TEXTENCODING_UTF8);
g_free(atk_obj->name);
atk_obj->name = g_strdup(aName.getStr()); 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()" );
} }
}
catch(const uno::Exception&) {
g_warning( "Exception in getAccessibleName()" );
} }
} }
...@@ -366,19 +372,23 @@ wrapper_get_description( AtkObject *atk_obj ) ...@@ -366,19 +372,23 @@ wrapper_get_description( AtkObject *atk_obj )
{ {
AtkObjectWrapper *obj = ATK_OBJECT_WRAPPER (atk_obj); AtkObjectWrapper *obj = ATK_OBJECT_WRAPPER (atk_obj);
if( obj->mpContext.is() ) if (obj)
{ {
try { uno::Reference<accessibility::XAccessibleContext> xContext(obj->mpContext.get(), uno::UNO_QUERY);
OString aDescription = if (xContext.is())
OUStringToOString( {
obj->mpContext->getAccessibleDescription(), try {
RTL_TEXTENCODING_UTF8); OString aDescription =
OUStringToOString(
g_free(atk_obj->description); xContext->getAccessibleDescription(),
atk_obj->description = g_strdup(aDescription.getStr()); RTL_TEXTENCODING_UTF8);
}
catch(const uno::Exception&) { g_free(atk_obj->description);
g_warning( "Exception in getAccessibleDescription()" ); atk_obj->description = g_strdup(aDescription.getStr());
}
catch(const uno::Exception&) {
g_warning( "Exception in getAccessibleDescription()" );
}
} }
} }
...@@ -397,7 +407,7 @@ wrapper_get_attributes( AtkObject *atk_obj ) ...@@ -397,7 +407,7 @@ wrapper_get_attributes( AtkObject *atk_obj )
try try
{ {
uno::Reference< accessibility::XAccessibleExtendedAttributes > uno::Reference< accessibility::XAccessibleExtendedAttributes >
xExtendedAttrs( obj->mpContext, uno::UNO_QUERY ); xExtendedAttrs(obj->mpContext.get(), uno::UNO_QUERY);
if( xExtendedAttrs.is() ) if( xExtendedAttrs.is() )
pSet = attribute_set_new_from_extended_attributes( xExtendedAttrs ); pSet = attribute_set_new_from_extended_attributes( xExtendedAttrs );
} }
...@@ -417,14 +427,20 @@ wrapper_get_n_children( AtkObject *atk_obj ) ...@@ -417,14 +427,20 @@ wrapper_get_n_children( AtkObject *atk_obj )
AtkObjectWrapper *obj = ATK_OBJECT_WRAPPER (atk_obj); AtkObjectWrapper *obj = ATK_OBJECT_WRAPPER (atk_obj);
gint n = 0; gint n = 0;
if( obj->mpContext.is() ) if (!obj)
return n;
uno::Reference<accessibility::XAccessibleContext> xContext(obj->mpContext.get(), uno::UNO_QUERY);
if (!xContext.is())
return n;
try
{ {
try { n = xContext->getAccessibleChildCount();
n = obj->mpContext->getAccessibleChildCount(); }
} catch(const uno::Exception&)
catch(const uno::Exception&) { {
OSL_FAIL("Exception in getAccessibleChildCount()" ); OSL_FAIL("Exception in getAccessibleChildCount()" );
}
} }
return n; return n;
...@@ -446,17 +462,22 @@ wrapper_ref_child( AtkObject *atk_obj, ...@@ -446,17 +462,22 @@ wrapper_ref_child( AtkObject *atk_obj,
return obj->child_about_to_be_removed; return obj->child_about_to_be_removed;
} }
if( obj->mpContext.is() ) if (!obj)
return child;
uno::Reference<accessibility::XAccessibleContext> xContext(obj->mpContext.get(), uno::UNO_QUERY);
if (!xContext.is())
return child;
try
{ {
try { uno::Reference< accessibility::XAccessible > xAccessible =
uno::Reference< accessibility::XAccessible > xAccessible = xContext->getAccessibleChild( i );
obj->mpContext->getAccessibleChild( i );
child = atk_object_wrapper_ref( xAccessible ); child = atk_object_wrapper_ref( xAccessible );
} }
catch(const uno::Exception&) { catch(const uno::Exception&) {
OSL_FAIL("Exception in getAccessibleChild"); OSL_FAIL("Exception in getAccessibleChild");
}
} }
return child; return child;
...@@ -470,13 +491,17 @@ wrapper_get_index_in_parent( AtkObject *atk_obj ) ...@@ -470,13 +491,17 @@ wrapper_get_index_in_parent( AtkObject *atk_obj )
AtkObjectWrapper *obj = ATK_OBJECT_WRAPPER (atk_obj); AtkObjectWrapper *obj = ATK_OBJECT_WRAPPER (atk_obj);
gint i = -1; gint i = -1;
if( obj->mpContext.is() ) if (obj)
{ {
try { uno::Reference<accessibility::XAccessibleContext> xContext(obj->mpContext.get(), uno::UNO_QUERY);
i = obj->mpContext->getAccessibleIndexInParent(); if (xContext.is())
} {
catch(const uno::Exception&) { try {
g_warning( "Exception in getAccessibleIndexInParent()" ); i = xContext->getAccessibleIndexInParent();
}
catch(const uno::Exception&) {
g_warning( "Exception in getAccessibleIndexInParent()" );
}
} }
} }
return i; return i;
...@@ -490,40 +515,44 @@ wrapper_ref_relation_set( AtkObject *atk_obj ) ...@@ -490,40 +515,44 @@ wrapper_ref_relation_set( AtkObject *atk_obj )
AtkObjectWrapper *obj = ATK_OBJECT_WRAPPER (atk_obj); AtkObjectWrapper *obj = ATK_OBJECT_WRAPPER (atk_obj);
AtkRelationSet *pSet = atk_relation_set_new(); AtkRelationSet *pSet = atk_relation_set_new();
if( obj->mpContext.is() ) if (obj)
{ {
try { uno::Reference<accessibility::XAccessibleContext> xContext(obj->mpContext.get(), uno::UNO_QUERY);
uno::Reference< accessibility::XAccessibleRelationSet > xRelationSet( if (xContext.is())
obj->mpContext->getAccessibleRelationSet() {
); try {
uno::Reference< accessibility::XAccessibleRelationSet > xRelationSet(
sal_Int32 nRelations = xRelationSet.is() ? xRelationSet->getRelationCount() : 0; xContext->getAccessibleRelationSet()
for( sal_Int32 n = 0; n < nRelations; n++ ) );
{
accessibility::AccessibleRelation aRelation = xRelationSet->getRelation( n );
sal_uInt32 nTargetCount = aRelation.TargetSet.getLength();
std::vector<AtkObject*> aTargets;
for (sal_uInt32 i = 0; i < nTargetCount; ++i) sal_Int32 nRelations = xRelationSet.is() ? xRelationSet->getRelationCount() : 0;
for( sal_Int32 n = 0; n < nRelations; n++ )
{ {
uno::Reference< accessibility::XAccessible > xAccessible( accessibility::AccessibleRelation aRelation = xRelationSet->getRelation( n );
aRelation.TargetSet[i], uno::UNO_QUERY ); sal_uInt32 nTargetCount = aRelation.TargetSet.getLength();
aTargets.push_back(atk_object_wrapper_ref(xAccessible));
std::vector<AtkObject*> 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 ) );
} }
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 &) {
catch(const uno::Exception &) { g_object_unref( G_OBJECT( pSet ) );
g_object_unref( G_OBJECT( pSet ) ); pSet = nullptr;
pSet = nullptr; }
} }
} }
...@@ -536,37 +565,43 @@ wrapper_ref_state_set( AtkObject *atk_obj ) ...@@ -536,37 +565,43 @@ wrapper_ref_state_set( AtkObject *atk_obj )
AtkObjectWrapper *obj = ATK_OBJECT_WRAPPER (atk_obj); AtkObjectWrapper *obj = ATK_OBJECT_WRAPPER (atk_obj);
AtkStateSet *pSet = atk_state_set_new(); AtkStateSet *pSet = atk_state_set_new();
if( obj->mpContext.is() ) if (obj)
{ {
try { uno::Reference<accessibility::XAccessibleContext> xContext(obj->mpContext.get(), uno::UNO_QUERY);
uno::Reference< accessibility::XAccessibleStateSet > xStateSet( if (xContext.is())
obj->mpContext->getAccessibleStateSet()); {
try
if( xStateSet.is() )
{ {
uno::Sequence< sal_Int16 > aStates = xStateSet->getStates(); uno::Reference< accessibility::XAccessibleStateSet > xStateSet(
xContext->getAccessibleStateSet());
for( sal_Int32 n = 0; n < aStates.getLength(); n++ ) if( xStateSet.is() )
{ {
// ATK_STATE_LAST_DEFINED is used to check if the state uno::Sequence< sal_Int16 > aStates = xStateSet->getStates();
// is unmapped, do not report it to Atk
if ( mapAtkState( aStates[n] ) != ATK_STATE_LAST_DEFINED ) for( sal_Int32 n = 0; n < aStates.getLength(); n++ )
atk_state_set_add_state( pSet, mapAtkState( aStates[n] ) ); {
} // ATK_STATE_LAST_DEFINED is used to check if the state
// is unmapped, do not report it to Atk
// We need to emulate FOCUS state for menus, menu-items etc. if ( mapAtkState( aStates[n] ) != ATK_STATE_LAST_DEFINED )
if( atk_obj == atk_get_focus_object() ) atk_state_set_add_state( pSet, mapAtkState( aStates[n] ) );
atk_state_set_add_state( pSet, ATK_STATE_FOCUSED ); }
// 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 ? /* FIXME - should we do this ?
else else
atk_state_set_remove_state( pSet, ATK_STATE_FOCUSED ); atk_state_set_remove_state( pSet, ATK_STATE_FOCUSED );
*/ */
}
} }
}
catch(const uno::Exception &) { catch(const uno::Exception &)
g_warning( "Exception in wrapper_ref_state_set" ); {
atk_state_set_add_state( pSet, ATK_STATE_DEFUNCT ); g_warning( "Exception in wrapper_ref_state_set" );
atk_state_set_add_state( pSet, ATK_STATE_DEFUNCT );
}
} }
} }
else else
...@@ -616,18 +651,9 @@ atk_object_wrapper_class_init (AtkObjectWrapperClass *klass) ...@@ -616,18 +651,9 @@ atk_object_wrapper_class_init (AtkObjectWrapperClass *klass)
} }
static void static void
atk_object_wrapper_init (AtkObjectWrapper *wrapper, atk_object_wrapper_init (AtkObjectWrapper* wrapper, AtkObjectWrapperClass*)
AtkObjectWrapperClass*)
{ {
wrapper->mpAction = nullptr; wrapper->mpContext = 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" } // extern "C"
...@@ -905,18 +931,6 @@ void atk_object_wrapper_set_role(AtkObjectWrapper* wrapper, sal_Int16 role) ...@@ -905,18 +931,6 @@ void atk_object_wrapper_set_role(AtkObjectWrapper* wrapper, sal_Int16 role)
void atk_object_wrapper_dispose(AtkObjectWrapper* wrapper) void atk_object_wrapper_dispose(AtkObjectWrapper* wrapper)
{ {
wrapper->mpContext.clear(); 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: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -22,49 +22,19 @@ ...@@ -22,49 +22,19 @@
#include <atk/atk.h> #include <atk/atk.h>
#include <com/sun/star/accessibility/XAccessible.hpp> #include <com/sun/star/accessibility/XAccessible.hpp>
#include <cppuhelper/weakref.hxx>
extern "C" { 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 struct AtkObjectWrapper
{ {
AtkObject aParent; AtkObject aParent;
css::uno::Reference<css::accessibility::XAccessible> mpAccessible; css::uno::Reference<css::accessibility::XAccessible> mpAccessible;
css::uno::Reference<css::accessibility::XAccessibleContext> mpContext; css::uno::WeakReference<css::accessibility::XAccessibleContext> mpContext;
css::uno::Reference<css::accessibility::XAccessibleAction> mpAction;
css::uno::Reference<css::accessibility::XAccessibleComponent> mpComponent;
css::uno::Reference<css::accessibility::XAccessibleEditableText>
mpEditableText;
css::uno::Reference<css::accessibility::XAccessibleHypertext> mpHypertext;
css::uno::Reference<css::accessibility::XAccessibleImage> mpImage;
css::uno::Reference<css::accessibility::XAccessibleMultiLineText>
mpMultiLineText;
css::uno::Reference<css::accessibility::XAccessibleSelection> mpSelection;
css::uno::Reference<css::accessibility::XAccessibleTable> mpTable;
css::uno::Reference<css::accessibility::XAccessibleText> mpText;
css::uno::Reference<css::accessibility::XAccessibleTextMarkup> mpTextMarkup;
css::uno::Reference<css::accessibility::XAccessibleTextAttributes>
mpTextAttributes;
css::uno::Reference<css::accessibility::XAccessibleValue> mpValue;
AtkObject *child_about_to_be_removed; AtkObject *child_about_to_be_removed;
gint index_of_child_about_to_be_removed; gint index_of_child_about_to_be_removed;
// OString * m_pKeyBindings
}; };
struct AtkObjectWrapperClass struct AtkObjectWrapperClass
......
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