Kaydet (Commit) 07ebec47 authored tarafından Stephan Bergmann's avatar Stephan Bergmann

rhbz#1247588: Hold UNO objects by css::uno::Reference

...instead of raw pointer and manual acquire/relase.  It is unclear to me why
the original code thought it was necessary (or merely "better") to hold by raw
pointer; but at least from the backtrace in rhbz#1247588, it seems plausible
that UNO method calls through such raw pointers could recursively call into
atk_object_wrapper_dispose and make the raw pointer stale.

Change-Id: Idc0a4f9e2f7ffe610261c1b7b98ce9c5e040db43
üst dd8fbd4c
...@@ -43,24 +43,22 @@ getAsConst( const OString& rString ) ...@@ -43,24 +43,22 @@ getAsConst( const OString& rString )
return aUgly[ nIdx ].getStr(); return aUgly[ nIdx ].getStr();
} }
static accessibility::XAccessibleAction* static css::uno::Reference<css::accessibility::XAccessibleAction>
getAction( AtkAction *action ) throw (uno::RuntimeException) getAction( AtkAction *action ) throw (uno::RuntimeException)
{ {
AtkObjectWrapper *pWrap = ATK_OBJECT_WRAPPER( action ); AtkObjectWrapper *pWrap = ATK_OBJECT_WRAPPER( action );
if( pWrap ) if( pWrap )
{ {
if( !pWrap->mpAction && pWrap->mpContext ) if( !pWrap->mpAction.is() )
{ {
uno::Any any = pWrap->mpContext->queryInterface( cppu::UnoType<accessibility::XAccessibleAction>::get() ); pWrap->mpAction.set(pWrap->mpContext, css::uno::UNO_QUERY);
pWrap->mpAction = static_cast< accessibility::XAccessibleAction * > (any.pReserved);
pWrap->mpAction->acquire();
} }
return pWrap->mpAction; return pWrap->mpAction;
} }
return NULL; return css::uno::Reference<css::accessibility::XAccessibleAction>();
} }
extern "C" { extern "C" {
...@@ -70,8 +68,9 @@ action_wrapper_do_action (AtkAction *action, ...@@ -70,8 +68,9 @@ action_wrapper_do_action (AtkAction *action,
gint i) gint i)
{ {
try { try {
accessibility::XAccessibleAction* pAction = getAction( action ); css::uno::Reference<css::accessibility::XAccessibleAction> pAction
if( pAction ) = getAction( action );
if( pAction.is() )
return pAction->doAccessibleAction( i ); return pAction->doAccessibleAction( i );
} }
catch(const uno::Exception&) { catch(const uno::Exception&) {
...@@ -85,8 +84,9 @@ static gint ...@@ -85,8 +84,9 @@ static gint
action_wrapper_get_n_actions (AtkAction *action) action_wrapper_get_n_actions (AtkAction *action)
{ {
try { try {
accessibility::XAccessibleAction* pAction = getAction( action ); css::uno::Reference<css::accessibility::XAccessibleAction> pAction
if( pAction ) = getAction( action );
if( pAction.is() )
return pAction->getAccessibleActionCount(); return pAction->getAccessibleActionCount();
} }
catch(const uno::Exception&) { catch(const uno::Exception&) {
...@@ -129,8 +129,9 @@ action_wrapper_get_name (AtkAction *action, ...@@ -129,8 +129,9 @@ action_wrapper_get_name (AtkAction *action,
} }
try { try {
accessibility::XAccessibleAction* pAction = getAction( action ); css::uno::Reference<css::accessibility::XAccessibleAction> pAction
if( pAction ) = getAction( action );
if( pAction.is() )
{ {
std::map< OUString, const gchar * >::iterator iter; std::map< OUString, const gchar * >::iterator iter;
...@@ -211,8 +212,9 @@ action_wrapper_get_keybinding (AtkAction *action, ...@@ -211,8 +212,9 @@ action_wrapper_get_keybinding (AtkAction *action,
gint i) gint i)
{ {
try { try {
accessibility::XAccessibleAction* pAction = getAction( action ); css::uno::Reference<css::accessibility::XAccessibleAction> pAction
if( pAction ) = getAction( action );
if( pAction.is() )
{ {
uno::Reference< accessibility::XAccessibleKeyBinding > xBinding( pAction->getAccessibleActionKeyBinding( i )); uno::Reference< accessibility::XAccessibleKeyBinding > xBinding( pAction->getAccessibleActionKeyBinding( i ));
......
...@@ -23,29 +23,27 @@ ...@@ -23,29 +23,27 @@
using namespace ::com::sun::star; using namespace ::com::sun::star;
static accessibility::XAccessibleComponent* 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 && pWrap->mpContext ) if( !pWrap->mpComponent.is() )
{ {
uno::Any any = pWrap->mpContext->queryInterface( cppu::UnoType<accessibility::XAccessibleComponent>::get() ); pWrap->mpComponent.set(pWrap->mpContext, css::uno::UNO_QUERY);
pWrap->mpComponent = static_cast< accessibility::XAccessibleComponent * > (any.pReserved);
pWrap->mpComponent->acquire();
} }
return pWrap->mpComponent; return pWrap->mpComponent;
} }
return NULL; return css::uno::Reference<css::accessibility::XAccessibleComponent>();
} }
/*****************************************************************************/ /*****************************************************************************/
static awt::Point static awt::Point
translatePoint( accessibility::XAccessibleComponent *pComponent, translatePoint( css::uno::Reference<accessibility::XAccessibleComponent> const & pComponent,
gint x, gint y, AtkCoordType t) gint x, gint y, AtkCoordType t)
{ {
awt::Point aOrigin( 0, 0 ); awt::Point aOrigin( 0, 0 );
...@@ -63,8 +61,9 @@ component_wrapper_grab_focus (AtkComponent *component) ...@@ -63,8 +61,9 @@ component_wrapper_grab_focus (AtkComponent *component)
{ {
try try
{ {
accessibility::XAccessibleComponent* pComponent = getComponent( component ); css::uno::Reference<css::accessibility::XAccessibleComponent> pComponent
if( pComponent ) = getComponent( component );
if( pComponent.is() )
{ {
pComponent->grabFocus(); pComponent->grabFocus();
return TRUE; return TRUE;
...@@ -88,8 +87,9 @@ component_wrapper_contains (AtkComponent *component, ...@@ -88,8 +87,9 @@ component_wrapper_contains (AtkComponent *component,
{ {
try try
{ {
accessibility::XAccessibleComponent* pComponent = getComponent( component ); css::uno::Reference<css::accessibility::XAccessibleComponent> pComponent
if( pComponent ) = getComponent( component );
if( pComponent.is() )
return pComponent->containsPoint( translatePoint( pComponent, x, y, coord_type ) ); return pComponent->containsPoint( translatePoint( pComponent, x, y, coord_type ) );
} }
catch( const uno::Exception & ) catch( const uno::Exception & )
...@@ -110,9 +110,10 @@ component_wrapper_ref_accessible_at_point (AtkComponent *component, ...@@ -110,9 +110,10 @@ component_wrapper_ref_accessible_at_point (AtkComponent *component,
{ {
try try
{ {
accessibility::XAccessibleComponent* pComponent = getComponent( component ); css::uno::Reference<css::accessibility::XAccessibleComponent> pComponent
= getComponent( component );
if( pComponent ) if( pComponent.is() )
{ {
uno::Reference< accessibility::XAccessible > xAccessible; uno::Reference< accessibility::XAccessible > xAccessible;
xAccessible = pComponent->getAccessibleAtPoint( xAccessible = pComponent->getAccessibleAtPoint(
...@@ -138,8 +139,9 @@ component_wrapper_get_position (AtkComponent *component, ...@@ -138,8 +139,9 @@ component_wrapper_get_position (AtkComponent *component,
{ {
try try
{ {
accessibility::XAccessibleComponent* pComponent = getComponent( component ); css::uno::Reference<css::accessibility::XAccessibleComponent> pComponent
if( pComponent ) = getComponent( component );
if( pComponent.is() )
{ {
awt::Point aPos; awt::Point aPos;
...@@ -167,8 +169,9 @@ component_wrapper_get_size (AtkComponent *component, ...@@ -167,8 +169,9 @@ component_wrapper_get_size (AtkComponent *component,
{ {
try try
{ {
accessibility::XAccessibleComponent* pComponent = getComponent( component ); css::uno::Reference<css::accessibility::XAccessibleComponent> pComponent
if( pComponent ) = getComponent( component );
if( pComponent.is() )
{ {
awt::Size aSize = pComponent->getSize(); awt::Size aSize = pComponent->getSize();
*width = aSize.Width; *width = aSize.Width;
......
...@@ -27,23 +27,21 @@ ...@@ -27,23 +27,21 @@
using namespace ::com::sun::star; using namespace ::com::sun::star;
static accessibility::XAccessibleEditableText* 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 && pWrap->mpContext ) if( !pWrap->mpEditableText.is() )
{ {
uno::Any any = pWrap->mpContext->queryInterface( cppu::UnoType<accessibility::XAccessibleEditableText>::get() ); pWrap->mpEditableText.set(pWrap->mpContext, css::uno::UNO_QUERY);
pWrap->mpEditableText = static_cast< accessibility::XAccessibleEditableText * > (any.pReserved);
pWrap->mpEditableText->acquire();
} }
return pWrap->mpEditableText; return pWrap->mpEditableText;
} }
return NULL; return css::uno::Reference<css::accessibility::XAccessibleEditableText>();
} }
/*****************************************************************************/ /*****************************************************************************/
...@@ -57,8 +55,9 @@ editable_text_wrapper_set_run_attributes( AtkEditableText *text, ...@@ -57,8 +55,9 @@ editable_text_wrapper_set_run_attributes( AtkEditableText *text,
gint nEndOffset) gint nEndOffset)
{ {
try { try {
accessibility::XAccessibleEditableText* pEditableText = getEditableText( text ); css::uno::Reference<css::accessibility::XAccessibleEditableText>
if( pEditableText ) pEditableText = getEditableText( text );
if( pEditableText.is() )
{ {
uno::Sequence< beans::PropertyValue > aAttributeList; uno::Sequence< beans::PropertyValue > aAttributeList;
...@@ -78,8 +77,9 @@ editable_text_wrapper_set_text_contents( AtkEditableText *text, ...@@ -78,8 +77,9 @@ editable_text_wrapper_set_text_contents( AtkEditableText *text,
const gchar *string ) const gchar *string )
{ {
try { try {
accessibility::XAccessibleEditableText* pEditableText = getEditableText( text ); css::uno::Reference<css::accessibility::XAccessibleEditableText>
if( pEditableText ) pEditableText = getEditableText( text );
if( pEditableText.is() )
{ {
OUString aString ( string, strlen(string), RTL_TEXTENCODING_UTF8 ); OUString aString ( string, strlen(string), RTL_TEXTENCODING_UTF8 );
pEditableText->setText( aString ); pEditableText->setText( aString );
...@@ -97,8 +97,9 @@ editable_text_wrapper_insert_text( AtkEditableText *text, ...@@ -97,8 +97,9 @@ editable_text_wrapper_insert_text( AtkEditableText *text,
gint *pos ) gint *pos )
{ {
try { try {
accessibility::XAccessibleEditableText* pEditableText = getEditableText( text ); css::uno::Reference<css::accessibility::XAccessibleEditableText>
if( pEditableText ) pEditableText = getEditableText( text );
if( pEditableText.is() )
{ {
OUString aString ( string, length, RTL_TEXTENCODING_UTF8 ); OUString aString ( string, length, RTL_TEXTENCODING_UTF8 );
if( pEditableText->insertText( aString, *pos ) ) if( pEditableText->insertText( aString, *pos ) )
...@@ -116,8 +117,9 @@ editable_text_wrapper_cut_text( AtkEditableText *text, ...@@ -116,8 +117,9 @@ editable_text_wrapper_cut_text( AtkEditableText *text,
gint end ) gint end )
{ {
try { try {
accessibility::XAccessibleEditableText* pEditableText = getEditableText( text ); css::uno::Reference<css::accessibility::XAccessibleEditableText>
if( pEditableText ) pEditableText = getEditableText( text );
if( pEditableText.is() )
pEditableText->cutText( start, end ); pEditableText->cutText( start, end );
} }
catch(const uno::Exception&) { catch(const uno::Exception&) {
...@@ -131,8 +133,9 @@ editable_text_wrapper_delete_text( AtkEditableText *text, ...@@ -131,8 +133,9 @@ editable_text_wrapper_delete_text( AtkEditableText *text,
gint end ) gint end )
{ {
try { try {
accessibility::XAccessibleEditableText* pEditableText = getEditableText( text ); css::uno::Reference<css::accessibility::XAccessibleEditableText>
if( pEditableText ) pEditableText = getEditableText( text );
if( pEditableText.is() )
pEditableText->deleteText( start, end ); pEditableText->deleteText( start, end );
} }
catch(const uno::Exception&) { catch(const uno::Exception&) {
...@@ -145,8 +148,9 @@ editable_text_wrapper_paste_text( AtkEditableText *text, ...@@ -145,8 +148,9 @@ editable_text_wrapper_paste_text( AtkEditableText *text,
gint pos ) gint pos )
{ {
try { try {
accessibility::XAccessibleEditableText* pEditableText = getEditableText( text ); css::uno::Reference<css::accessibility::XAccessibleEditableText>
if( pEditableText ) pEditableText = getEditableText( text );
if( pEditableText.is() )
pEditableText->pasteText( pos ); pEditableText->pasteText( pos );
} }
catch(const uno::Exception&) { catch(const uno::Exception&) {
...@@ -160,8 +164,9 @@ editable_text_wrapper_copy_text( AtkEditableText *text, ...@@ -160,8 +164,9 @@ editable_text_wrapper_copy_text( AtkEditableText *text,
gint end ) gint end )
{ {
try { try {
accessibility::XAccessibleEditableText* pEditableText = getEditableText( text ); css::uno::Reference<css::accessibility::XAccessibleEditableText>
if( pEditableText ) pEditableText = getEditableText( text );
if( pEditableText.is() )
pEditableText->copyText( start, end ); pEditableText->copyText( start, end );
} }
catch(const uno::Exception&) { catch(const uno::Exception&) {
......
...@@ -189,23 +189,21 @@ hyper_link_get_type() ...@@ -189,23 +189,21 @@ hyper_link_get_type()
// ---------------------- AtkHyperText ---------------------- // ---------------------- AtkHyperText ----------------------
static accessibility::XAccessibleHypertext* 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 && pWrap->mpContext ) if( !pWrap->mpHypertext.is() )
{ {
uno::Any any = pWrap->mpContext->queryInterface( cppu::UnoType<accessibility::XAccessibleHypertext>::get() ); pWrap->mpHypertext.set(pWrap->mpContext, css::uno::UNO_QUERY);
pWrap->mpHypertext = static_cast< accessibility::XAccessibleHypertext * > (any.pReserved);
pWrap->mpHypertext->acquire();
} }
return pWrap->mpHypertext; return pWrap->mpHypertext;
} }
return NULL; return css::uno::Reference<css::accessibility::XAccessibleHypertext>();
} }
static AtkHyperlink * static AtkHyperlink *
...@@ -213,8 +211,9 @@ hypertext_get_link( AtkHypertext *hypertext, ...@@ -213,8 +211,9 @@ hypertext_get_link( AtkHypertext *hypertext,
gint link_index) gint link_index)
{ {
try { try {
accessibility::XAccessibleHypertext* pHypertext = getHypertext( hypertext ); css::uno::Reference<css::accessibility::XAccessibleHypertext> pHypertext
if( pHypertext ) = getHypertext( hypertext );
if( pHypertext.is() )
{ {
HyperLink *pLink = static_cast<HyperLink *>(g_object_new( hyper_link_get_type(), NULL )); HyperLink *pLink = static_cast<HyperLink *>(g_object_new( hyper_link_get_type(), NULL ));
pLink->xLink = pHypertext->getHyperLink( link_index ); pLink->xLink = pHypertext->getHyperLink( link_index );
...@@ -236,8 +235,9 @@ static gint ...@@ -236,8 +235,9 @@ static gint
hypertext_get_n_links( AtkHypertext *hypertext ) hypertext_get_n_links( AtkHypertext *hypertext )
{ {
try { try {
accessibility::XAccessibleHypertext* pHypertext = getHypertext( hypertext ); css::uno::Reference<css::accessibility::XAccessibleHypertext> pHypertext
if( pHypertext ) = getHypertext( hypertext );
if( pHypertext.is() )
return pHypertext->getHyperLinkCount(); return pHypertext->getHyperLinkCount();
} }
catch(const uno::Exception&) { catch(const uno::Exception&) {
...@@ -252,8 +252,9 @@ hypertext_get_link_index( AtkHypertext *hypertext, ...@@ -252,8 +252,9 @@ hypertext_get_link_index( AtkHypertext *hypertext,
gint index) gint index)
{ {
try { try {
accessibility::XAccessibleHypertext* pHypertext = getHypertext( hypertext ); css::uno::Reference<css::accessibility::XAccessibleHypertext> pHypertext
if( pHypertext ) = getHypertext( hypertext );
if( pHypertext.is() )
return pHypertext->getHyperLinkIndex( index ); return pHypertext->getHyperLinkIndex( index );
} }
catch(const uno::Exception&) { catch(const uno::Exception&) {
......
...@@ -35,23 +35,21 @@ getAsConst( const OUString& rString ) ...@@ -35,23 +35,21 @@ getAsConst( const OUString& rString )
return aUgly[ nIdx ].getStr(); return aUgly[ nIdx ].getStr();
} }
static accessibility::XAccessibleImage* 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 && pWrap->mpContext ) if( !pWrap->mpImage.is() )
{ {
uno::Any any = pWrap->mpContext->queryInterface( cppu::UnoType<accessibility::XAccessibleImage>::get() ); pWrap->mpImage.set(pWrap->mpContext, css::uno::UNO_QUERY);
pWrap->mpImage = static_cast< accessibility::XAccessibleImage * > (any.pReserved);
pWrap->mpImage->acquire();
} }
return pWrap->mpImage; return pWrap->mpImage;
} }
return NULL; return css::uno::Reference<css::accessibility::XAccessibleImage>();
} }
extern "C" { extern "C" {
...@@ -60,8 +58,9 @@ static G_CONST_RETURN gchar * ...@@ -60,8 +58,9 @@ static G_CONST_RETURN gchar *
image_get_image_description( AtkImage *image ) image_get_image_description( AtkImage *image )
{ {
try { try {
accessibility::XAccessibleImage* pImage = getImage( image ); css::uno::Reference<css::accessibility::XAccessibleImage> pImage
if( pImage ) = getImage( image );
if( pImage.is() )
return getAsConst( pImage->getAccessibleImageDescription() ); return getAsConst( pImage->getAccessibleImageDescription() );
} }
catch(const uno::Exception&) { catch(const uno::Exception&) {
...@@ -96,8 +95,9 @@ image_get_image_size( AtkImage *image, ...@@ -96,8 +95,9 @@ image_get_image_size( AtkImage *image,
*width = 0; *width = 0;
*height = 0; *height = 0;
try { try {
accessibility::XAccessibleImage* pImage = getImage( image ); css::uno::Reference<css::accessibility::XAccessibleImage> pImage
if( pImage ) = getImage( image );
if( pImage.is() )
{ {
*width = pImage->getAccessibleImageWidth(); *width = pImage->getAccessibleImageWidth();
*height = pImage->getAccessibleImageHeight(); *height = pImage->getAccessibleImageHeight();
......
...@@ -117,7 +117,9 @@ static AtkObject *getObjFromAny( const uno::Any &rAny ) ...@@ -117,7 +117,9 @@ static AtkObject *getObjFromAny( const uno::Any &rAny )
/*****************************************************************************/ /*****************************************************************************/
// Updates the child list held to provide the old IndexInParent on children_changed::remove // Updates the child list held to provide the old IndexInParent on children_changed::remove
void AtkListener::updateChildList(accessibility::XAccessibleContext* pContext) void AtkListener::updateChildList(
css::uno::Reference<css::accessibility::XAccessibleContext> const &
pContext)
{ {
m_aChildList.clear(); m_aChildList.clear();
...@@ -156,7 +158,7 @@ void AtkListener::handleChildAdded( ...@@ -156,7 +158,7 @@ void AtkListener::handleChildAdded(
if( pChild ) if( pChild )
{ {
updateChildList(rxParent.get()); updateChildList(rxParent);
atk_object_wrapper_add_child( mpWrapper, pChild, atk_object_wrapper_add_child( mpWrapper, pChild,
atk_object_get_index_in_parent( pChild )); atk_object_get_index_in_parent( pChild ));
...@@ -195,7 +197,7 @@ void AtkListener::handleChildRemoved( ...@@ -195,7 +197,7 @@ void AtkListener::handleChildRemoved(
// for now. // for now.
if( nIndex >= 0 ) if( nIndex >= 0 )
{ {
updateChildList(rxParent.get()); updateChildList(rxParent);
AtkObject * pChild = atk_object_wrapper_ref( rxChild, false ); AtkObject * pChild = atk_object_wrapper_ref( rxChild, false );
if( pChild ) if( pChild )
...@@ -226,7 +228,7 @@ void AtkListener::handleInvalidateChildren( ...@@ -226,7 +228,7 @@ void AtkListener::handleInvalidateChildren(
} }
} }
updateChildList(rxParent.get()); updateChildList(rxParent);
// Send notifications for all new children // Send notifications for all new children
size_t nmax = m_aChildList.size(); size_t nmax = m_aChildList.size();
......
...@@ -49,7 +49,9 @@ private: ...@@ -49,7 +49,9 @@ private:
virtual ~AtkListener(); virtual ~AtkListener();
// Updates the child list held to provide the old IndexInParent on children_changed::remove // Updates the child list held to provide the old IndexInParent on children_changed::remove
void updateChildList(::com::sun::star::accessibility::XAccessibleContext* pContext); void updateChildList(
css::uno::Reference<css::accessibility::XAccessibleContext> const &
pContext);
// Process CHILD_EVENT notifications with a new child added // Process CHILD_EVENT notifications with a new child added
void handleChildAdded( void handleChildAdded(
......
...@@ -55,10 +55,12 @@ ooo_wrapper_registry_add(const Reference< XAccessible >& rxAccessible, AtkObject ...@@ -55,10 +55,12 @@ ooo_wrapper_registry_add(const Reference< XAccessible >& rxAccessible, AtkObject
/*****************************************************************************/ /*****************************************************************************/
void void
ooo_wrapper_registry_remove(XAccessible *pAccessible) ooo_wrapper_registry_remove(
css::uno::Reference<css::accessibility::XAccessible> const & pAccessible)
{ {
if( uno_to_gobject ) if( uno_to_gobject )
g_hash_table_remove( uno_to_gobject, static_cast<gpointer>(pAccessible) ); g_hash_table_remove(
uno_to_gobject, static_cast<gpointer>(pAccessible.get()) );
} }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -27,7 +27,8 @@ AtkObject * ooo_wrapper_registry_get(const ::com::sun::star::uno::Reference< ::c ...@@ -27,7 +27,8 @@ AtkObject * ooo_wrapper_registry_get(const ::com::sun::star::uno::Reference< ::c
void ooo_wrapper_registry_add(const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& rxAccessible, AtkObject *obj); void ooo_wrapper_registry_add(const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& rxAccessible, AtkObject *obj);
void ooo_wrapper_registry_remove(::com::sun::star::accessibility::XAccessible *pAccessible); void ooo_wrapper_registry_remove(
css::uno::Reference<css::accessibility::XAccessible> const & pAccessible);
#endif // __ATK_REGISTRY_HXX_ #endif // __ATK_REGISTRY_HXX_
......
...@@ -23,23 +23,21 @@ ...@@ -23,23 +23,21 @@
using namespace ::com::sun::star; using namespace ::com::sun::star;
static accessibility::XAccessibleSelection* 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 && pWrap->mpContext ) if( !pWrap->mpSelection.is() )
{ {
uno::Any any = pWrap->mpContext->queryInterface( cppu::UnoType<accessibility::XAccessibleSelection>::get() ); pWrap->mpSelection.set(pWrap->mpContext, css::uno::UNO_QUERY);
pWrap->mpSelection = static_cast< accessibility::XAccessibleSelection * > (any.pReserved);
pWrap->mpSelection->acquire();
} }
return pWrap->mpSelection; return pWrap->mpSelection;
} }
return NULL; return css::uno::Reference<css::accessibility::XAccessibleSelection>();
} }
extern "C" { extern "C" {
...@@ -49,8 +47,9 @@ selection_add_selection( AtkSelection *selection, ...@@ -49,8 +47,9 @@ selection_add_selection( AtkSelection *selection,
gint i ) gint i )
{ {
try { try {
accessibility::XAccessibleSelection* pSelection = getSelection( selection ); css::uno::Reference<css::accessibility::XAccessibleSelection> pSelection
if( pSelection ) = getSelection( selection );
if( pSelection.is() )
{ {
pSelection->selectAccessibleChild( i ); pSelection->selectAccessibleChild( i );
return TRUE; return TRUE;
...@@ -67,8 +66,9 @@ static gboolean ...@@ -67,8 +66,9 @@ static gboolean
selection_clear_selection( AtkSelection *selection ) selection_clear_selection( AtkSelection *selection )
{ {
try { try {
accessibility::XAccessibleSelection* pSelection = getSelection( selection ); css::uno::Reference<css::accessibility::XAccessibleSelection> pSelection
if( pSelection ) = getSelection( selection );
if( pSelection.is() )
{ {
pSelection->clearAccessibleSelection(); pSelection->clearAccessibleSelection();
return TRUE; return TRUE;
...@@ -86,8 +86,9 @@ selection_ref_selection( AtkSelection *selection, ...@@ -86,8 +86,9 @@ selection_ref_selection( AtkSelection *selection,
gint i ) gint i )
{ {
try { try {
accessibility::XAccessibleSelection* pSelection = getSelection( selection ); css::uno::Reference<css::accessibility::XAccessibleSelection> pSelection
if( pSelection ) = getSelection( selection );
if( pSelection.is() )
return atk_object_wrapper_ref( pSelection->getSelectedAccessibleChild( i ) ); return atk_object_wrapper_ref( pSelection->getSelectedAccessibleChild( i ) );
} }
catch(const uno::Exception&) { catch(const uno::Exception&) {
...@@ -101,8 +102,9 @@ static gint ...@@ -101,8 +102,9 @@ static gint
selection_get_selection_count( AtkSelection *selection) selection_get_selection_count( AtkSelection *selection)
{ {
try { try {
accessibility::XAccessibleSelection* pSelection = getSelection( selection ); css::uno::Reference<css::accessibility::XAccessibleSelection> pSelection
if( pSelection ) = getSelection( selection );
if( pSelection.is() )
return pSelection->getSelectedAccessibleChildCount(); return pSelection->getSelectedAccessibleChildCount();
} }
catch(const uno::Exception&) { catch(const uno::Exception&) {
...@@ -117,8 +119,9 @@ selection_is_child_selected( AtkSelection *selection, ...@@ -117,8 +119,9 @@ selection_is_child_selected( AtkSelection *selection,
gint i) gint i)
{ {
try { try {
accessibility::XAccessibleSelection* pSelection = getSelection( selection ); css::uno::Reference<css::accessibility::XAccessibleSelection> pSelection
if( pSelection ) = getSelection( selection );
if( pSelection.is() )
return pSelection->isAccessibleChildSelected( i ); return pSelection->isAccessibleChildSelected( i );
} }
catch(const uno::Exception&) { catch(const uno::Exception&) {
...@@ -133,8 +136,9 @@ selection_remove_selection( AtkSelection *selection, ...@@ -133,8 +136,9 @@ selection_remove_selection( AtkSelection *selection,
gint i ) gint i )
{ {
try { try {
accessibility::XAccessibleSelection* pSelection = getSelection( selection ); css::uno::Reference<css::accessibility::XAccessibleSelection> pSelection
if( pSelection ) = getSelection( selection );
if( pSelection.is() )
{ {
pSelection->deselectAccessibleChild( i ); pSelection->deselectAccessibleChild( i );
return TRUE; return TRUE;
...@@ -151,8 +155,9 @@ static gboolean ...@@ -151,8 +155,9 @@ static gboolean
selection_select_all_selection( AtkSelection *selection) selection_select_all_selection( AtkSelection *selection)
{ {
try { try {
accessibility::XAccessibleSelection* pSelection = getSelection( selection ); css::uno::Reference<css::accessibility::XAccessibleSelection> pSelection
if( pSelection ) = getSelection( selection );
if( pSelection.is() )
{ {
pSelection->selectAllAccessibleChildren(); pSelection->selectAllAccessibleChildren();
return TRUE; return TRUE;
......
...@@ -48,23 +48,21 @@ getAsConst( const OUString& rString ) ...@@ -48,23 +48,21 @@ getAsConst( const OUString& rString )
/*****************************************************************************/ /*****************************************************************************/
static accessibility::XAccessibleTable* 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 && pWrap->mpContext ) if( !pWrap->mpTable.is() )
{ {
uno::Any any = pWrap->mpContext->queryInterface( cppu::UnoType<accessibility::XAccessibleTable>::get() ); pWrap->mpTable.set(pWrap->mpContext, css::uno::UNO_QUERY);
pWrap->mpTable = static_cast< accessibility::XAccessibleTable * > (any.pReserved);
pWrap->mpTable->acquire();
} }
return pWrap->mpTable; return pWrap->mpTable;
} }
return NULL; return css::uno::Reference<css::accessibility::XAccessibleTable>();
} }
/*****************************************************************************/ /*****************************************************************************/
...@@ -77,8 +75,8 @@ table_wrapper_ref_at (AtkTable *table, ...@@ -77,8 +75,8 @@ table_wrapper_ref_at (AtkTable *table,
gint column) gint column)
{ {
try { try {
accessibility::XAccessibleTable* pTable = getTable( table ); css::uno::Reference<css::accessibility::XAccessibleTable> pTable = getTable( table );
if( pTable ) if( pTable.is() )
return atk_object_wrapper_conditional_ref( pTable->getAccessibleCellAt( row, column ) ); return atk_object_wrapper_conditional_ref( pTable->getAccessibleCellAt( row, column ) );
} }
...@@ -97,8 +95,9 @@ table_wrapper_get_index_at (AtkTable *table, ...@@ -97,8 +95,9 @@ table_wrapper_get_index_at (AtkTable *table,
gint column) gint column)
{ {
try { try {
accessibility::XAccessibleTable* pTable = getTable( table ); css::uno::Reference<css::accessibility::XAccessibleTable> pTable
if( pTable ) = getTable( table );
if( pTable.is() )
return pTable->getAccessibleIndex( row, column ); return pTable->getAccessibleIndex( row, column );
} }
catch(const uno::Exception&) { catch(const uno::Exception&) {
...@@ -115,8 +114,9 @@ table_wrapper_get_column_at_index (AtkTable *table, ...@@ -115,8 +114,9 @@ table_wrapper_get_column_at_index (AtkTable *table,
gint nIndex) gint nIndex)
{ {
try { try {
accessibility::XAccessibleTable* pTable = getTable( table ); css::uno::Reference<css::accessibility::XAccessibleTable> pTable
if( pTable ) = getTable( table );
if( pTable.is() )
return pTable->getAccessibleColumn( nIndex ); return pTable->getAccessibleColumn( nIndex );
} }
catch(const uno::Exception&) { catch(const uno::Exception&) {
...@@ -133,8 +133,9 @@ table_wrapper_get_row_at_index( AtkTable *table, ...@@ -133,8 +133,9 @@ table_wrapper_get_row_at_index( AtkTable *table,
gint nIndex ) gint nIndex )
{ {
try { try {
accessibility::XAccessibleTable* pTable = getTable( table ); css::uno::Reference<css::accessibility::XAccessibleTable> pTable
if( pTable ) = getTable( table );
if( pTable.is() )
return pTable->getAccessibleRow( nIndex ); return pTable->getAccessibleRow( nIndex );
} }
catch(const uno::Exception&) { catch(const uno::Exception&) {
...@@ -150,8 +151,9 @@ static gint ...@@ -150,8 +151,9 @@ static gint
table_wrapper_get_n_columns( AtkTable *table ) table_wrapper_get_n_columns( AtkTable *table )
{ {
try { try {
accessibility::XAccessibleTable* pTable = getTable( table ); css::uno::Reference<css::accessibility::XAccessibleTable> pTable
if( pTable ) = getTable( table );
if( pTable.is() )
return pTable->getAccessibleColumnCount(); return pTable->getAccessibleColumnCount();
} }
catch(const uno::Exception&) { catch(const uno::Exception&) {
...@@ -167,8 +169,9 @@ static gint ...@@ -167,8 +169,9 @@ static gint
table_wrapper_get_n_rows( AtkTable *table ) table_wrapper_get_n_rows( AtkTable *table )
{ {
try { try {
accessibility::XAccessibleTable* pTable = getTable( table ); css::uno::Reference<css::accessibility::XAccessibleTable> pTable
if( pTable ) = getTable( table );
if( pTable.is() )
return pTable->getAccessibleRowCount(); return pTable->getAccessibleRowCount();
} }
catch(const uno::Exception&) { catch(const uno::Exception&) {
...@@ -186,8 +189,9 @@ table_wrapper_get_column_extent_at( AtkTable *table, ...@@ -186,8 +189,9 @@ table_wrapper_get_column_extent_at( AtkTable *table,
gint column ) gint column )
{ {
try { try {
accessibility::XAccessibleTable* pTable = getTable( table ); css::uno::Reference<css::accessibility::XAccessibleTable> pTable
if( pTable ) = getTable( table );
if( pTable.is() )
return pTable->getAccessibleColumnExtentAt( row, column ); return pTable->getAccessibleColumnExtentAt( row, column );
} }
catch(const uno::Exception&) { catch(const uno::Exception&) {
...@@ -205,8 +209,9 @@ table_wrapper_get_row_extent_at( AtkTable *table, ...@@ -205,8 +209,9 @@ table_wrapper_get_row_extent_at( AtkTable *table,
gint column ) gint column )
{ {
try { try {
accessibility::XAccessibleTable* pTable = getTable( table ); css::uno::Reference<css::accessibility::XAccessibleTable> pTable
if( pTable ) = getTable( table );
if( pTable.is() )
return pTable->getAccessibleRowExtentAt( row, column ); return pTable->getAccessibleRowExtentAt( row, column );
} }
catch(const uno::Exception&) { catch(const uno::Exception&) {
...@@ -222,8 +227,9 @@ static AtkObject * ...@@ -222,8 +227,9 @@ static AtkObject *
table_wrapper_get_caption( AtkTable *table ) table_wrapper_get_caption( AtkTable *table )
{ {
try { try {
accessibility::XAccessibleTable* pTable = getTable( table ); css::uno::Reference<css::accessibility::XAccessibleTable> pTable
if( pTable ) = getTable( table );
if( pTable.is() )
return atk_object_wrapper_conditional_ref( pTable->getAccessibleCaption() ); return atk_object_wrapper_conditional_ref( pTable->getAccessibleCaption() );
} }
...@@ -241,8 +247,9 @@ table_wrapper_get_row_description( AtkTable *table, ...@@ -241,8 +247,9 @@ table_wrapper_get_row_description( AtkTable *table,
gint row ) gint row )
{ {
try { try {
accessibility::XAccessibleTable* pTable = getTable( table ); css::uno::Reference<css::accessibility::XAccessibleTable> pTable
if( pTable ) = getTable( table );
if( pTable.is() )
return getAsConst( pTable->getAccessibleRowDescription( row ) ); return getAsConst( pTable->getAccessibleRowDescription( row ) );
} }
catch(const uno::Exception&) { catch(const uno::Exception&) {
...@@ -259,8 +266,9 @@ table_wrapper_get_column_description( AtkTable *table, ...@@ -259,8 +266,9 @@ table_wrapper_get_column_description( AtkTable *table,
gint column ) gint column )
{ {
try { try {
accessibility::XAccessibleTable* pTable = getTable( table ); css::uno::Reference<css::accessibility::XAccessibleTable> pTable
if( pTable ) = getTable( table );
if( pTable.is() )
return getAsConst( pTable->getAccessibleColumnDescription( column ) ); return getAsConst( pTable->getAccessibleColumnDescription( column ) );
} }
catch(const uno::Exception&) { catch(const uno::Exception&) {
...@@ -277,8 +285,9 @@ table_wrapper_get_row_header( AtkTable *table, ...@@ -277,8 +285,9 @@ table_wrapper_get_row_header( AtkTable *table,
gint row ) gint row )
{ {
try { try {
accessibility::XAccessibleTable* pTable = getTable( table ); css::uno::Reference<css::accessibility::XAccessibleTable> pTable
if( pTable ) = getTable( table );
if( pTable.is() )
{ {
uno::Reference< accessibility::XAccessibleTable > xRowHeaders( pTable->getAccessibleRowHeaders() ); uno::Reference< accessibility::XAccessibleTable > xRowHeaders( pTable->getAccessibleRowHeaders() );
if( xRowHeaders.is() ) if( xRowHeaders.is() )
...@@ -299,9 +308,9 @@ table_wrapper_get_column_header( AtkTable *table, ...@@ -299,9 +308,9 @@ table_wrapper_get_column_header( AtkTable *table,
gint column ) gint column )
{ {
try { try {
accessibility::XAccessibleTable* pTable = getTable( table ); css::uno::Reference<css::accessibility::XAccessibleTable> pTable
= getTable( table );
if( pTable ) if( pTable.is() )
{ {
uno::Reference< accessibility::XAccessibleTable > xColumnHeaders( pTable->getAccessibleColumnHeaders() ); uno::Reference< accessibility::XAccessibleTable > xColumnHeaders( pTable->getAccessibleColumnHeaders() );
if( xColumnHeaders.is() ) if( xColumnHeaders.is() )
...@@ -321,8 +330,9 @@ static AtkObject * ...@@ -321,8 +330,9 @@ static AtkObject *
table_wrapper_get_summary( AtkTable *table ) table_wrapper_get_summary( AtkTable *table )
{ {
try { try {
accessibility::XAccessibleTable* pTable = getTable( table ); css::uno::Reference<css::accessibility::XAccessibleTable> pTable
if( pTable ) = getTable( table );
if( pTable.is() )
{ {
return atk_object_wrapper_conditional_ref( pTable->getAccessibleSummary() ); return atk_object_wrapper_conditional_ref( pTable->getAccessibleSummary() );
} }
...@@ -358,8 +368,9 @@ table_wrapper_get_selected_columns( AtkTable *table, ...@@ -358,8 +368,9 @@ table_wrapper_get_selected_columns( AtkTable *table,
{ {
*pSelected = NULL; *pSelected = NULL;
try { try {
accessibility::XAccessibleTable* pTable = getTable( table ); css::uno::Reference<css::accessibility::XAccessibleTable> pTable
if( pTable ) = getTable( table );
if( pTable.is() )
return convertToGIntArray( pTable->getSelectedAccessibleColumns(), pSelected ); return convertToGIntArray( pTable->getSelectedAccessibleColumns(), pSelected );
} }
catch(const uno::Exception&) { catch(const uno::Exception&) {
...@@ -377,8 +388,9 @@ table_wrapper_get_selected_rows( AtkTable *table, ...@@ -377,8 +388,9 @@ table_wrapper_get_selected_rows( AtkTable *table,
{ {
*pSelected = NULL; *pSelected = NULL;
try { try {
accessibility::XAccessibleTable* pTable = getTable( table ); css::uno::Reference<css::accessibility::XAccessibleTable> pTable
if( pTable ) = getTable( table );
if( pTable.is() )
return convertToGIntArray( pTable->getSelectedAccessibleRows(), pSelected ); return convertToGIntArray( pTable->getSelectedAccessibleRows(), pSelected );
} }
catch(const uno::Exception&) { catch(const uno::Exception&) {
...@@ -395,8 +407,9 @@ table_wrapper_is_column_selected( AtkTable *table, ...@@ -395,8 +407,9 @@ table_wrapper_is_column_selected( AtkTable *table,
gint column ) gint column )
{ {
try { try {
accessibility::XAccessibleTable* pTable = getTable( table ); css::uno::Reference<css::accessibility::XAccessibleTable> pTable
if( pTable ) = getTable( table );
if( pTable.is() )
return pTable->isAccessibleColumnSelected( column ); return pTable->isAccessibleColumnSelected( column );
} }
catch(const uno::Exception&) { catch(const uno::Exception&) {
...@@ -413,8 +426,9 @@ table_wrapper_is_row_selected( AtkTable *table, ...@@ -413,8 +426,9 @@ table_wrapper_is_row_selected( AtkTable *table,
gint row ) gint row )
{ {
try { try {
accessibility::XAccessibleTable* pTable = getTable( table ); css::uno::Reference<css::accessibility::XAccessibleTable> pTable
if( pTable ) = getTable( table );
if( pTable.is() )
return pTable->isAccessibleRowSelected( row ); return pTable->isAccessibleRowSelected( row );
} }
catch(const uno::Exception&) { catch(const uno::Exception&) {
...@@ -432,8 +446,9 @@ table_wrapper_is_selected( AtkTable *table, ...@@ -432,8 +446,9 @@ table_wrapper_is_selected( AtkTable *table,
gint column ) gint column )
{ {
try { try {
accessibility::XAccessibleTable* pTable = getTable( table ); css::uno::Reference<css::accessibility::XAccessibleTable> pTable
if( pTable ) = getTable( table );
if( pTable.is() )
return pTable->isAccessibleSelected( row, column ); return pTable->isAccessibleSelected( row, column );
} }
catch(const uno::Exception&) { catch(const uno::Exception&) {
......
This diff is collapsed.
...@@ -207,23 +207,21 @@ String2Float( uno::Any& rAny, const gchar * value ) ...@@ -207,23 +207,21 @@ String2Float( uno::Any& rAny, const gchar * value )
/*****************************************************************************/ /*****************************************************************************/
static accessibility::XAccessibleComponent* 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 && pWrap->mpContext ) if( !pWrap->mpComponent.is() )
{ {
uno::Any any = pWrap->mpContext->queryInterface( cppu::UnoType<accessibility::XAccessibleComponent>::get() ); pWrap->mpComponent.set(pWrap->mpContext, css::uno::UNO_QUERY);
pWrap->mpComponent = static_cast< accessibility::XAccessibleComponent * > (any.pReserved);
pWrap->mpComponent->acquire();
} }
return pWrap->mpComponent; return pWrap->mpComponent;
} }
return NULL; return css::uno::Reference<css::accessibility::XAccessibleComponent>();
} }
static gchar* static gchar*
...@@ -248,8 +246,9 @@ get_color_value(const uno::Sequence< beans::PropertyValue >& rAttributeList, ...@@ -248,8 +246,9 @@ get_color_value(const uno::Sequence< beans::PropertyValue >& rAttributeList,
{ {
try try
{ {
accessibility::XAccessibleComponent *pComponent = getComponent( text ); css::uno::Reference<css::accessibility::XAccessibleComponent>
if( pComponent ) pComponent = getComponent( text );
if( pComponent.is() )
{ {
switch( attr ) switch( attr )
{ {
......
...@@ -85,23 +85,17 @@ atk_wrapper_focus_idle_handler (gpointer data) ...@@ -85,23 +85,17 @@ 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 && wrapper_obj->mpContext ) if( wrapper_obj && !wrapper_obj->mpText.is() )
{ {
uno::Any any = wrapper_obj->mpContext->queryInterface( cppu::UnoType<accessibility::XAccessibleText>::get() ); wrapper_obj->mpText.set(wrapper_obj->mpContext, css::uno::UNO_QUERY);
if ( typelib_TypeClass_INTERFACE == any.pType->eTypeClass && if ( wrapper_obj->mpText.is() )
any.pReserved != 0 )
{ {
wrapper_obj->mpText = static_cast< accessibility::XAccessibleText * > (any.pReserved); gint caretPos = wrapper_obj->mpText->getCaretPosition();
if ( wrapper_obj->mpText != 0 )
if ( caretPos != -1 )
{ {
wrapper_obj->mpText->acquire(); atk_object_notify_state_change( atk_obj, ATK_STATE_FOCUSED, TRUE );
gint caretPos = wrapper_obj->mpText->getCaretPosition(); g_signal_emit_by_name( atk_obj, "text_caret_moved", caretPos );
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 );
}
} }
} }
} }
......
...@@ -25,23 +25,21 @@ ...@@ -25,23 +25,21 @@
using namespace ::com::sun::star; using namespace ::com::sun::star;
static accessibility::XAccessibleValue* 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 && pWrap->mpContext ) if( !pWrap->mpValue.is() )
{ {
uno::Any any = pWrap->mpContext->queryInterface( cppu::UnoType<accessibility::XAccessibleValue>::get() ); pWrap->mpValue.set(pWrap->mpContext, css::uno::UNO_QUERY);
pWrap->mpValue = static_cast< accessibility::XAccessibleValue * > (any.pReserved);
pWrap->mpValue->acquire();
} }
return pWrap->mpValue; return pWrap->mpValue;
} }
return NULL; return css::uno::Reference<css::accessibility::XAccessibleValue>();
} }
static void anyToGValue( uno::Any aAny, GValue *pValue ) static void anyToGValue( uno::Any aAny, GValue *pValue )
...@@ -62,8 +60,9 @@ value_wrapper_get_current_value( AtkValue *value, ...@@ -62,8 +60,9 @@ value_wrapper_get_current_value( AtkValue *value,
GValue *gval ) GValue *gval )
{ {
try { try {
accessibility::XAccessibleValue* pValue = getValue( value ); css::uno::Reference<css::accessibility::XAccessibleValue> pValue
if( pValue ) = getValue( value );
if( pValue.is() )
anyToGValue( pValue->getCurrentValue(), gval ); anyToGValue( pValue->getCurrentValue(), gval );
} }
catch(const uno::Exception&) { catch(const uno::Exception&) {
...@@ -76,8 +75,9 @@ value_wrapper_get_maximum_value( AtkValue *value, ...@@ -76,8 +75,9 @@ value_wrapper_get_maximum_value( AtkValue *value,
GValue *gval ) GValue *gval )
{ {
try { try {
accessibility::XAccessibleValue* pValue = getValue( value ); css::uno::Reference<css::accessibility::XAccessibleValue> pValue
if( pValue ) = getValue( value );
if( pValue.is() )
anyToGValue( pValue->getMaximumValue(), gval ); anyToGValue( pValue->getMaximumValue(), gval );
} }
catch(const uno::Exception&) { catch(const uno::Exception&) {
...@@ -90,8 +90,9 @@ value_wrapper_get_minimum_value( AtkValue *value, ...@@ -90,8 +90,9 @@ value_wrapper_get_minimum_value( AtkValue *value,
GValue *gval ) GValue *gval )
{ {
try { try {
accessibility::XAccessibleValue* pValue = getValue( value ); css::uno::Reference<css::accessibility::XAccessibleValue> pValue
if( pValue ) = getValue( value );
if( pValue.is() )
anyToGValue( pValue->getMinimumValue(), gval ); anyToGValue( pValue->getMinimumValue(), gval );
} }
catch(const uno::Exception&) { catch(const uno::Exception&) {
...@@ -104,8 +105,9 @@ value_wrapper_set_current_value( AtkValue *value, ...@@ -104,8 +105,9 @@ value_wrapper_set_current_value( AtkValue *value,
const GValue *gval ) const GValue *gval )
{ {
try { try {
accessibility::XAccessibleValue* pValue = getValue( value ); css::uno::Reference<css::accessibility::XAccessibleValue> pValue
if( pValue ) = getValue( value );
if( pValue.is() )
{ {
// FIXME - this needs expanding // FIXME - this needs expanding
double aDouble = g_value_get_double( gval ); double aDouble = g_value_get_double( gval );
......
...@@ -338,13 +338,12 @@ wrapper_get_name( AtkObject *atk_obj ) ...@@ -338,13 +338,12 @@ wrapper_get_name( AtkObject *atk_obj )
{ {
AtkObjectWrapper *obj = ATK_OBJECT_WRAPPER (atk_obj); AtkObjectWrapper *obj = ATK_OBJECT_WRAPPER (atk_obj);
if( obj->mpContext ) if( obj->mpContext.is() )
{ {
uno::Reference< accessibility::XAccessibleContext > xContext(obj->mpContext);
try { try {
OString aName = OString aName =
OUStringToOString( OUStringToOString(
xContext->getAccessibleName(), obj->mpContext->getAccessibleName(),
RTL_TEXTENCODING_UTF8); RTL_TEXTENCODING_UTF8);
int nCmp = atk_obj->name ? rtl_str_compare( atk_obj->name, aName.getStr() ) : -1; int nCmp = atk_obj->name ? rtl_str_compare( atk_obj->name, aName.getStr() ) : -1;
...@@ -370,13 +369,12 @@ wrapper_get_description( AtkObject *atk_obj ) ...@@ -370,13 +369,12 @@ wrapper_get_description( AtkObject *atk_obj )
{ {
AtkObjectWrapper *obj = ATK_OBJECT_WRAPPER (atk_obj); AtkObjectWrapper *obj = ATK_OBJECT_WRAPPER (atk_obj);
if( obj->mpContext ) if( obj->mpContext.is() )
{ {
uno::Reference< accessibility::XAccessibleContext > xContext(obj->mpContext);
try { try {
OString aDescription = OString aDescription =
OUStringToOString( OUStringToOString(
xContext->getAccessibleDescription(), obj->mpContext->getAccessibleDescription(),
RTL_TEXTENCODING_UTF8); RTL_TEXTENCODING_UTF8);
g_free(atk_obj->description); g_free(atk_obj->description);
...@@ -399,20 +397,16 @@ wrapper_get_attributes( AtkObject *atk_obj ) ...@@ -399,20 +397,16 @@ wrapper_get_attributes( AtkObject *atk_obj )
AtkObjectWrapper *obj = ATK_OBJECT_WRAPPER( atk_obj ); AtkObjectWrapper *obj = ATK_OBJECT_WRAPPER( atk_obj );
AtkAttributeSet *pSet = NULL; AtkAttributeSet *pSet = NULL;
if( obj->mpContext ) try
{ {
uno::Reference< accessibility::XAccessibleContext > xContext( obj->mpContext ); uno::Reference< accessibility::XAccessibleExtendedAttributes >
try xExtendedAttrs( obj->mpContext, uno::UNO_QUERY );
{ if( xExtendedAttrs.is() )
uno::Reference< accessibility::XAccessibleExtendedAttributes > xExtendedAttrs( xContext, pSet = attribute_set_new_from_extended_attributes( xExtendedAttrs );
uno::UNO_QUERY ); }
if( xExtendedAttrs.is() ) catch(const uno::Exception&)
pSet = attribute_set_new_from_extended_attributes( xExtendedAttrs ); {
} g_warning( "Exception in getAccessibleAttributes()" );
catch(const uno::Exception&)
{
g_warning( "Exception in getAccessibleAttributes()" );
}
} }
return pSet; return pSet;
...@@ -426,11 +420,10 @@ wrapper_get_n_children( AtkObject *atk_obj ) ...@@ -426,11 +420,10 @@ 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 ) if( obj->mpContext.is() )
{ {
uno::Reference< accessibility::XAccessibleContext > xContext(obj->mpContext);
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()" );
...@@ -456,12 +449,11 @@ wrapper_ref_child( AtkObject *atk_obj, ...@@ -456,12 +449,11 @@ wrapper_ref_child( AtkObject *atk_obj,
return obj->child_about_to_be_removed; return obj->child_about_to_be_removed;
} }
if( obj->mpContext ) if( obj->mpContext.is() )
{ {
uno::Reference< accessibility::XAccessibleContext > xContext(obj->mpContext);
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 );
} }
...@@ -481,11 +473,10 @@ wrapper_get_index_in_parent( AtkObject *atk_obj ) ...@@ -481,11 +473,10 @@ 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 ) if( obj->mpContext.is() )
{ {
uno::Reference< accessibility::XAccessibleContext > xContext(obj->mpContext);
try { try {
i = xContext->getAccessibleIndexInParent(); i = obj->mpContext->getAccessibleIndexInParent();
} }
catch(const uno::Exception&) { catch(const uno::Exception&) {
g_warning( "Exception in getAccessibleIndexInParent()" ); g_warning( "Exception in getAccessibleIndexInParent()" );
...@@ -502,12 +493,11 @@ wrapper_ref_relation_set( AtkObject *atk_obj ) ...@@ -502,12 +493,11 @@ 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 ) if( obj->mpContext.is() )
{ {
uno::Reference< accessibility::XAccessibleContext > xContext(obj->mpContext);
try { try {
uno::Reference< accessibility::XAccessibleRelationSet > xRelationSet( uno::Reference< accessibility::XAccessibleRelationSet > xRelationSet(
xContext->getAccessibleRelationSet() obj->mpContext->getAccessibleRelationSet()
); );
sal_Int32 nRelations = xRelationSet.is() ? xRelationSet->getRelationCount() : 0; sal_Int32 nRelations = xRelationSet.is() ? xRelationSet->getRelationCount() : 0;
...@@ -548,12 +538,11 @@ wrapper_ref_state_set( AtkObject *atk_obj ) ...@@ -548,12 +538,11 @@ 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 ) if( obj->mpContext.is() )
{ {
uno::Reference< accessibility::XAccessibleContext > xContext(obj->mpContext);
try { try {
uno::Reference< accessibility::XAccessibleStateSet > xStateSet( uno::Reference< accessibility::XAccessibleStateSet > xStateSet(
xContext->getAccessibleStateSet()); obj->mpContext->getAccessibleStateSet());
if( xStateSet.is() ) if( xStateSet.is() )
{ {
...@@ -595,11 +584,10 @@ atk_object_wrapper_finalize (GObject *obj) ...@@ -595,11 +584,10 @@ atk_object_wrapper_finalize (GObject *obj)
{ {
AtkObjectWrapper *pWrap = ATK_OBJECT_WRAPPER (obj); AtkObjectWrapper *pWrap = ATK_OBJECT_WRAPPER (obj);
if( pWrap->mpAccessible ) if( pWrap->mpAccessible.is() )
{ {
ooo_wrapper_registry_remove( pWrap->mpAccessible ); ooo_wrapper_registry_remove( pWrap->mpAccessible );
pWrap->mpAccessible->release(); pWrap->mpAccessible.clear();
pWrap->mpAccessible = NULL;
} }
atk_object_wrapper_dispose( pWrap ); atk_object_wrapper_dispose( pWrap );
...@@ -826,14 +814,12 @@ atk_object_wrapper_new( const ::com::sun::star::uno::Reference< ::com::sun::star ...@@ -826,14 +814,12 @@ atk_object_wrapper_new( const ::com::sun::star::uno::Reference< ::com::sun::star
gpointer obj = g_object_new( nType, NULL); gpointer obj = g_object_new( nType, NULL);
pWrap = ATK_OBJECT_WRAPPER( obj ); pWrap = ATK_OBJECT_WRAPPER( obj );
pWrap->mpAccessible = rxAccessible.get(); pWrap->mpAccessible = rxAccessible;
rxAccessible->acquire();
pWrap->index_of_child_about_to_be_removed = -1; pWrap->index_of_child_about_to_be_removed = -1;
pWrap->child_about_to_be_removed = NULL; pWrap->child_about_to_be_removed = NULL;
xContext->acquire(); pWrap->mpContext = xContext;
pWrap->mpContext = xContext.get();
AtkObject* atk_obj = ATK_OBJECT(pWrap); AtkObject* atk_obj = ATK_OBJECT(pWrap);
atk_obj->role = mapToAtkRole( xContext->getAccessibleRole() ); atk_obj->role = mapToAtkRole( xContext->getAccessibleRole() );
...@@ -915,23 +901,21 @@ void atk_object_wrapper_set_role(AtkObjectWrapper* wrapper, sal_Int16 role) ...@@ -915,23 +901,21 @@ void atk_object_wrapper_set_role(AtkObjectWrapper* wrapper, sal_Int16 role)
/*****************************************************************************/ /*****************************************************************************/
#define RELEASE(i) if( i ) { i->release(); i = NULL; }
void atk_object_wrapper_dispose(AtkObjectWrapper* wrapper) void atk_object_wrapper_dispose(AtkObjectWrapper* wrapper)
{ {
RELEASE( wrapper->mpContext ) wrapper->mpContext.clear();
RELEASE( wrapper->mpAction ) wrapper->mpAction.clear();
RELEASE( wrapper->mpComponent ) wrapper->mpComponent.clear();
RELEASE( wrapper->mpEditableText ) wrapper->mpEditableText.clear();
RELEASE( wrapper->mpHypertext ) wrapper->mpHypertext.clear();
RELEASE( wrapper->mpImage ) wrapper->mpImage.clear();
RELEASE( wrapper->mpSelection ) wrapper->mpSelection.clear();
RELEASE( wrapper->mpMultiLineText ) wrapper->mpMultiLineText.clear();
RELEASE( wrapper->mpTable ) wrapper->mpTable.clear();
RELEASE( wrapper->mpText ) wrapper->mpText.clear();
RELEASE( wrapper->mpTextMarkup ) wrapper->mpTextMarkup.clear();
RELEASE( wrapper->mpTextAttributes ) wrapper->mpTextAttributes.clear();
RELEASE( wrapper->mpValue ) wrapper->mpValue.clear();
} }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -47,20 +47,23 @@ struct _AtkObjectWrapper ...@@ -47,20 +47,23 @@ struct _AtkObjectWrapper
{ {
AtkObject aParent; AtkObject aParent;
::com::sun::star::accessibility::XAccessible *mpAccessible; css::uno::Reference<css::accessibility::XAccessible> mpAccessible;
::com::sun::star::accessibility::XAccessibleContext *mpContext; css::uno::Reference<css::accessibility::XAccessibleContext> mpContext;
::com::sun::star::accessibility::XAccessibleAction *mpAction; css::uno::Reference<css::accessibility::XAccessibleAction> mpAction;
::com::sun::star::accessibility::XAccessibleComponent *mpComponent; css::uno::Reference<css::accessibility::XAccessibleComponent> mpComponent;
::com::sun::star::accessibility::XAccessibleEditableText *mpEditableText; css::uno::Reference<css::accessibility::XAccessibleEditableText>
::com::sun::star::accessibility::XAccessibleHypertext *mpHypertext; mpEditableText;
::com::sun::star::accessibility::XAccessibleImage *mpImage; css::uno::Reference<css::accessibility::XAccessibleHypertext> mpHypertext;
::com::sun::star::accessibility::XAccessibleMultiLineText *mpMultiLineText; css::uno::Reference<css::accessibility::XAccessibleImage> mpImage;
::com::sun::star::accessibility::XAccessibleSelection *mpSelection; css::uno::Reference<css::accessibility::XAccessibleMultiLineText>
::com::sun::star::accessibility::XAccessibleTable *mpTable; mpMultiLineText;
::com::sun::star::accessibility::XAccessibleText *mpText; css::uno::Reference<css::accessibility::XAccessibleSelection> mpSelection;
::com::sun::star::accessibility::XAccessibleTextMarkup *mpTextMarkup; css::uno::Reference<css::accessibility::XAccessibleTable> mpTable;
::com::sun::star::accessibility::XAccessibleTextAttributes *mpTextAttributes; css::uno::Reference<css::accessibility::XAccessibleText> mpText;
::com::sun::star::accessibility::XAccessibleValue *mpValue; 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;
......
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