From 07ebec47da4a096aaab53bf6a90bb219ce29bfbf Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Thu, 13 Aug 2015 16:58:58 +0200 Subject: 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 --- vcl/unx/gtk/a11y/atkaction.cxx | 30 +++--- vcl/unx/gtk/a11y/atkcomponent.cxx | 37 ++++---- vcl/unx/gtk/a11y/atkeditabletext.cxx | 45 +++++---- vcl/unx/gtk/a11y/atkhypertext.cxx | 25 ++--- vcl/unx/gtk/a11y/atkimage.cxx | 20 ++-- vcl/unx/gtk/a11y/atklistener.cxx | 10 +- vcl/unx/gtk/a11y/atklistener.hxx | 4 +- vcl/unx/gtk/a11y/atkregistry.cxx | 6 +- vcl/unx/gtk/a11y/atkregistry.hxx | 3 +- vcl/unx/gtk/a11y/atkselection.cxx | 45 +++++---- vcl/unx/gtk/a11y/atktable.cxx | 105 ++++++++++++--------- vcl/unx/gtk/a11y/atktext.cxx | 162 ++++++++++++++++----------------- vcl/unx/gtk/a11y/atktextattributes.cxx | 15 ++- vcl/unx/gtk/a11y/atkutil.cxx | 22 ++--- vcl/unx/gtk/a11y/atkvalue.cxx | 30 +++--- vcl/unx/gtk/a11y/atkwrapper.cxx | 96 ++++++++----------- vcl/unx/gtk/a11y/atkwrapper.hxx | 31 ++++--- 17 files changed, 348 insertions(+), 338 deletions(-) diff --git a/vcl/unx/gtk/a11y/atkaction.cxx b/vcl/unx/gtk/a11y/atkaction.cxx index 41c6e36d5be6..71ada32ec8c9 100644 --- a/vcl/unx/gtk/a11y/atkaction.cxx +++ b/vcl/unx/gtk/a11y/atkaction.cxx @@ -43,24 +43,22 @@ getAsConst( const OString& rString ) return aUgly[ nIdx ].getStr(); } -static accessibility::XAccessibleAction* +static css::uno::Reference getAction( AtkAction *action ) throw (uno::RuntimeException) { AtkObjectWrapper *pWrap = ATK_OBJECT_WRAPPER( action ); if( pWrap ) { - if( !pWrap->mpAction && pWrap->mpContext ) + if( !pWrap->mpAction.is() ) { - uno::Any any = pWrap->mpContext->queryInterface( cppu::UnoType::get() ); - pWrap->mpAction = static_cast< accessibility::XAccessibleAction * > (any.pReserved); - pWrap->mpAction->acquire(); + pWrap->mpAction.set(pWrap->mpContext, css::uno::UNO_QUERY); } return pWrap->mpAction; } - return NULL; + return css::uno::Reference(); } extern "C" { @@ -70,8 +68,9 @@ action_wrapper_do_action (AtkAction *action, gint i) { try { - accessibility::XAccessibleAction* pAction = getAction( action ); - if( pAction ) + css::uno::Reference pAction + = getAction( action ); + if( pAction.is() ) return pAction->doAccessibleAction( i ); } catch(const uno::Exception&) { @@ -85,8 +84,9 @@ static gint action_wrapper_get_n_actions (AtkAction *action) { try { - accessibility::XAccessibleAction* pAction = getAction( action ); - if( pAction ) + css::uno::Reference pAction + = getAction( action ); + if( pAction.is() ) return pAction->getAccessibleActionCount(); } catch(const uno::Exception&) { @@ -129,8 +129,9 @@ action_wrapper_get_name (AtkAction *action, } try { - accessibility::XAccessibleAction* pAction = getAction( action ); - if( pAction ) + css::uno::Reference pAction + = getAction( action ); + if( pAction.is() ) { std::map< OUString, const gchar * >::iterator iter; @@ -211,8 +212,9 @@ action_wrapper_get_keybinding (AtkAction *action, gint i) { try { - accessibility::XAccessibleAction* pAction = getAction( action ); - if( pAction ) + css::uno::Reference pAction + = getAction( action ); + if( pAction.is() ) { uno::Reference< accessibility::XAccessibleKeyBinding > xBinding( pAction->getAccessibleActionKeyBinding( i )); diff --git a/vcl/unx/gtk/a11y/atkcomponent.cxx b/vcl/unx/gtk/a11y/atkcomponent.cxx index fe8afec2c3fe..2afdca099d19 100644 --- a/vcl/unx/gtk/a11y/atkcomponent.cxx +++ b/vcl/unx/gtk/a11y/atkcomponent.cxx @@ -23,29 +23,27 @@ using namespace ::com::sun::star; -static accessibility::XAccessibleComponent* +static css::uno::Reference getComponent( AtkComponent *pComponent ) throw (uno::RuntimeException) { AtkObjectWrapper *pWrap = ATK_OBJECT_WRAPPER( pComponent ); if( pWrap ) { - if( !pWrap->mpComponent && pWrap->mpContext ) + if( !pWrap->mpComponent.is() ) { - uno::Any any = pWrap->mpContext->queryInterface( cppu::UnoType::get() ); - pWrap->mpComponent = static_cast< accessibility::XAccessibleComponent * > (any.pReserved); - pWrap->mpComponent->acquire(); + pWrap->mpComponent.set(pWrap->mpContext, css::uno::UNO_QUERY); } return pWrap->mpComponent; } - return NULL; + return css::uno::Reference(); } /*****************************************************************************/ static awt::Point -translatePoint( accessibility::XAccessibleComponent *pComponent, +translatePoint( css::uno::Reference const & pComponent, gint x, gint y, AtkCoordType t) { awt::Point aOrigin( 0, 0 ); @@ -63,8 +61,9 @@ component_wrapper_grab_focus (AtkComponent *component) { try { - accessibility::XAccessibleComponent* pComponent = getComponent( component ); - if( pComponent ) + css::uno::Reference pComponent + = getComponent( component ); + if( pComponent.is() ) { pComponent->grabFocus(); return TRUE; @@ -88,8 +87,9 @@ component_wrapper_contains (AtkComponent *component, { try { - accessibility::XAccessibleComponent* pComponent = getComponent( component ); - if( pComponent ) + css::uno::Reference pComponent + = getComponent( component ); + if( pComponent.is() ) return pComponent->containsPoint( translatePoint( pComponent, x, y, coord_type ) ); } catch( const uno::Exception & ) @@ -110,9 +110,10 @@ component_wrapper_ref_accessible_at_point (AtkComponent *component, { try { - accessibility::XAccessibleComponent* pComponent = getComponent( component ); + css::uno::Reference pComponent + = getComponent( component ); - if( pComponent ) + if( pComponent.is() ) { uno::Reference< accessibility::XAccessible > xAccessible; xAccessible = pComponent->getAccessibleAtPoint( @@ -138,8 +139,9 @@ component_wrapper_get_position (AtkComponent *component, { try { - accessibility::XAccessibleComponent* pComponent = getComponent( component ); - if( pComponent ) + css::uno::Reference pComponent + = getComponent( component ); + if( pComponent.is() ) { awt::Point aPos; @@ -167,8 +169,9 @@ component_wrapper_get_size (AtkComponent *component, { try { - accessibility::XAccessibleComponent* pComponent = getComponent( component ); - if( pComponent ) + css::uno::Reference pComponent + = getComponent( component ); + if( pComponent.is() ) { awt::Size aSize = pComponent->getSize(); *width = aSize.Width; diff --git a/vcl/unx/gtk/a11y/atkeditabletext.cxx b/vcl/unx/gtk/a11y/atkeditabletext.cxx index 82aebc76436c..cc058b5b1019 100644 --- a/vcl/unx/gtk/a11y/atkeditabletext.cxx +++ b/vcl/unx/gtk/a11y/atkeditabletext.cxx @@ -27,23 +27,21 @@ using namespace ::com::sun::star; -static accessibility::XAccessibleEditableText* +static css::uno::Reference getEditableText( AtkEditableText *pEditableText ) throw (uno::RuntimeException) { AtkObjectWrapper *pWrap = ATK_OBJECT_WRAPPER( pEditableText ); if( pWrap ) { - if( !pWrap->mpEditableText && pWrap->mpContext ) + if( !pWrap->mpEditableText.is() ) { - uno::Any any = pWrap->mpContext->queryInterface( cppu::UnoType::get() ); - pWrap->mpEditableText = static_cast< accessibility::XAccessibleEditableText * > (any.pReserved); - pWrap->mpEditableText->acquire(); + pWrap->mpEditableText.set(pWrap->mpContext, css::uno::UNO_QUERY); } return pWrap->mpEditableText; } - return NULL; + return css::uno::Reference(); } /*****************************************************************************/ @@ -57,8 +55,9 @@ editable_text_wrapper_set_run_attributes( AtkEditableText *text, gint nEndOffset) { try { - accessibility::XAccessibleEditableText* pEditableText = getEditableText( text ); - if( pEditableText ) + css::uno::Reference + pEditableText = getEditableText( text ); + if( pEditableText.is() ) { uno::Sequence< beans::PropertyValue > aAttributeList; @@ -78,8 +77,9 @@ editable_text_wrapper_set_text_contents( AtkEditableText *text, const gchar *string ) { try { - accessibility::XAccessibleEditableText* pEditableText = getEditableText( text ); - if( pEditableText ) + css::uno::Reference + pEditableText = getEditableText( text ); + if( pEditableText.is() ) { OUString aString ( string, strlen(string), RTL_TEXTENCODING_UTF8 ); pEditableText->setText( aString ); @@ -97,8 +97,9 @@ editable_text_wrapper_insert_text( AtkEditableText *text, gint *pos ) { try { - accessibility::XAccessibleEditableText* pEditableText = getEditableText( text ); - if( pEditableText ) + css::uno::Reference + pEditableText = getEditableText( text ); + if( pEditableText.is() ) { OUString aString ( string, length, RTL_TEXTENCODING_UTF8 ); if( pEditableText->insertText( aString, *pos ) ) @@ -116,8 +117,9 @@ editable_text_wrapper_cut_text( AtkEditableText *text, gint end ) { try { - accessibility::XAccessibleEditableText* pEditableText = getEditableText( text ); - if( pEditableText ) + css::uno::Reference + pEditableText = getEditableText( text ); + if( pEditableText.is() ) pEditableText->cutText( start, end ); } catch(const uno::Exception&) { @@ -131,8 +133,9 @@ editable_text_wrapper_delete_text( AtkEditableText *text, gint end ) { try { - accessibility::XAccessibleEditableText* pEditableText = getEditableText( text ); - if( pEditableText ) + css::uno::Reference + pEditableText = getEditableText( text ); + if( pEditableText.is() ) pEditableText->deleteText( start, end ); } catch(const uno::Exception&) { @@ -145,8 +148,9 @@ editable_text_wrapper_paste_text( AtkEditableText *text, gint pos ) { try { - accessibility::XAccessibleEditableText* pEditableText = getEditableText( text ); - if( pEditableText ) + css::uno::Reference + pEditableText = getEditableText( text ); + if( pEditableText.is() ) pEditableText->pasteText( pos ); } catch(const uno::Exception&) { @@ -160,8 +164,9 @@ editable_text_wrapper_copy_text( AtkEditableText *text, gint end ) { try { - accessibility::XAccessibleEditableText* pEditableText = getEditableText( text ); - if( pEditableText ) + css::uno::Reference + pEditableText = getEditableText( text ); + if( pEditableText.is() ) pEditableText->copyText( start, end ); } catch(const uno::Exception&) { diff --git a/vcl/unx/gtk/a11y/atkhypertext.cxx b/vcl/unx/gtk/a11y/atkhypertext.cxx index 47872486a55a..aebb11a19f68 100644 --- a/vcl/unx/gtk/a11y/atkhypertext.cxx +++ b/vcl/unx/gtk/a11y/atkhypertext.cxx @@ -189,23 +189,21 @@ hyper_link_get_type() // ---------------------- AtkHyperText ---------------------- -static accessibility::XAccessibleHypertext* +static css::uno::Reference getHypertext( AtkHypertext *pHypertext ) throw (uno::RuntimeException) { AtkObjectWrapper *pWrap = ATK_OBJECT_WRAPPER( pHypertext ); if( pWrap ) { - if( !pWrap->mpHypertext && pWrap->mpContext ) + if( !pWrap->mpHypertext.is() ) { - uno::Any any = pWrap->mpContext->queryInterface( cppu::UnoType::get() ); - pWrap->mpHypertext = static_cast< accessibility::XAccessibleHypertext * > (any.pReserved); - pWrap->mpHypertext->acquire(); + pWrap->mpHypertext.set(pWrap->mpContext, css::uno::UNO_QUERY); } return pWrap->mpHypertext; } - return NULL; + return css::uno::Reference(); } static AtkHyperlink * @@ -213,8 +211,9 @@ hypertext_get_link( AtkHypertext *hypertext, gint link_index) { try { - accessibility::XAccessibleHypertext* pHypertext = getHypertext( hypertext ); - if( pHypertext ) + css::uno::Reference pHypertext + = getHypertext( hypertext ); + if( pHypertext.is() ) { HyperLink *pLink = static_cast(g_object_new( hyper_link_get_type(), NULL )); pLink->xLink = pHypertext->getHyperLink( link_index ); @@ -236,8 +235,9 @@ static gint hypertext_get_n_links( AtkHypertext *hypertext ) { try { - accessibility::XAccessibleHypertext* pHypertext = getHypertext( hypertext ); - if( pHypertext ) + css::uno::Reference pHypertext + = getHypertext( hypertext ); + if( pHypertext.is() ) return pHypertext->getHyperLinkCount(); } catch(const uno::Exception&) { @@ -252,8 +252,9 @@ hypertext_get_link_index( AtkHypertext *hypertext, gint index) { try { - accessibility::XAccessibleHypertext* pHypertext = getHypertext( hypertext ); - if( pHypertext ) + css::uno::Reference pHypertext + = getHypertext( hypertext ); + if( pHypertext.is() ) return pHypertext->getHyperLinkIndex( index ); } catch(const uno::Exception&) { diff --git a/vcl/unx/gtk/a11y/atkimage.cxx b/vcl/unx/gtk/a11y/atkimage.cxx index 2f6759fc4e0a..c6f6e75f1ece 100644 --- a/vcl/unx/gtk/a11y/atkimage.cxx +++ b/vcl/unx/gtk/a11y/atkimage.cxx @@ -35,23 +35,21 @@ getAsConst( const OUString& rString ) return aUgly[ nIdx ].getStr(); } -static accessibility::XAccessibleImage* +static css::uno::Reference getImage( AtkImage *pImage ) throw (uno::RuntimeException) { AtkObjectWrapper *pWrap = ATK_OBJECT_WRAPPER( pImage ); if( pWrap ) { - if( !pWrap->mpImage && pWrap->mpContext ) + if( !pWrap->mpImage.is() ) { - uno::Any any = pWrap->mpContext->queryInterface( cppu::UnoType::get() ); - pWrap->mpImage = static_cast< accessibility::XAccessibleImage * > (any.pReserved); - pWrap->mpImage->acquire(); + pWrap->mpImage.set(pWrap->mpContext, css::uno::UNO_QUERY); } return pWrap->mpImage; } - return NULL; + return css::uno::Reference(); } extern "C" { @@ -60,8 +58,9 @@ static G_CONST_RETURN gchar * image_get_image_description( AtkImage *image ) { try { - accessibility::XAccessibleImage* pImage = getImage( image ); - if( pImage ) + css::uno::Reference pImage + = getImage( image ); + if( pImage.is() ) return getAsConst( pImage->getAccessibleImageDescription() ); } catch(const uno::Exception&) { @@ -96,8 +95,9 @@ image_get_image_size( AtkImage *image, *width = 0; *height = 0; try { - accessibility::XAccessibleImage* pImage = getImage( image ); - if( pImage ) + css::uno::Reference pImage + = getImage( image ); + if( pImage.is() ) { *width = pImage->getAccessibleImageWidth(); *height = pImage->getAccessibleImageHeight(); diff --git a/vcl/unx/gtk/a11y/atklistener.cxx b/vcl/unx/gtk/a11y/atklistener.cxx index 9b4b0a88b712..753a7c2be3f9 100644 --- a/vcl/unx/gtk/a11y/atklistener.cxx +++ b/vcl/unx/gtk/a11y/atklistener.cxx @@ -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 -void AtkListener::updateChildList(accessibility::XAccessibleContext* pContext) +void AtkListener::updateChildList( + css::uno::Reference const & + pContext) { m_aChildList.clear(); @@ -156,7 +158,7 @@ void AtkListener::handleChildAdded( if( pChild ) { - updateChildList(rxParent.get()); + updateChildList(rxParent); atk_object_wrapper_add_child( mpWrapper, pChild, atk_object_get_index_in_parent( pChild )); @@ -195,7 +197,7 @@ void AtkListener::handleChildRemoved( // for now. if( nIndex >= 0 ) { - updateChildList(rxParent.get()); + updateChildList(rxParent); AtkObject * pChild = atk_object_wrapper_ref( rxChild, false ); if( pChild ) @@ -226,7 +228,7 @@ void AtkListener::handleInvalidateChildren( } } - updateChildList(rxParent.get()); + updateChildList(rxParent); // Send notifications for all new children size_t nmax = m_aChildList.size(); diff --git a/vcl/unx/gtk/a11y/atklistener.hxx b/vcl/unx/gtk/a11y/atklistener.hxx index 804769f2834c..e47f6222fe06 100644 --- a/vcl/unx/gtk/a11y/atklistener.hxx +++ b/vcl/unx/gtk/a11y/atklistener.hxx @@ -49,7 +49,9 @@ private: virtual ~AtkListener(); // 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 const & + pContext); // Process CHILD_EVENT notifications with a new child added void handleChildAdded( diff --git a/vcl/unx/gtk/a11y/atkregistry.cxx b/vcl/unx/gtk/a11y/atkregistry.cxx index ee34ee1209c5..5fdae5cbd2fb 100644 --- a/vcl/unx/gtk/a11y/atkregistry.cxx +++ b/vcl/unx/gtk/a11y/atkregistry.cxx @@ -55,10 +55,12 @@ ooo_wrapper_registry_add(const Reference< XAccessible >& rxAccessible, AtkObject /*****************************************************************************/ void -ooo_wrapper_registry_remove(XAccessible *pAccessible) +ooo_wrapper_registry_remove( + css::uno::Reference const & pAccessible) { if( uno_to_gobject ) - g_hash_table_remove( uno_to_gobject, static_cast(pAccessible) ); + g_hash_table_remove( + uno_to_gobject, static_cast(pAccessible.get()) ); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/unx/gtk/a11y/atkregistry.hxx b/vcl/unx/gtk/a11y/atkregistry.hxx index c5f70a8528e9..b25e449df474 100644 --- a/vcl/unx/gtk/a11y/atkregistry.hxx +++ b/vcl/unx/gtk/a11y/atkregistry.hxx @@ -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_remove(::com::sun::star::accessibility::XAccessible *pAccessible); +void ooo_wrapper_registry_remove( + css::uno::Reference const & pAccessible); #endif // __ATK_REGISTRY_HXX_ diff --git a/vcl/unx/gtk/a11y/atkselection.cxx b/vcl/unx/gtk/a11y/atkselection.cxx index 50bd94fa69ca..3c75865c6689 100644 --- a/vcl/unx/gtk/a11y/atkselection.cxx +++ b/vcl/unx/gtk/a11y/atkselection.cxx @@ -23,23 +23,21 @@ using namespace ::com::sun::star; -static accessibility::XAccessibleSelection* +static css::uno::Reference getSelection( AtkSelection *pSelection ) throw (uno::RuntimeException) { AtkObjectWrapper *pWrap = ATK_OBJECT_WRAPPER( pSelection ); if( pWrap ) { - if( !pWrap->mpSelection && pWrap->mpContext ) + if( !pWrap->mpSelection.is() ) { - uno::Any any = pWrap->mpContext->queryInterface( cppu::UnoType::get() ); - pWrap->mpSelection = static_cast< accessibility::XAccessibleSelection * > (any.pReserved); - pWrap->mpSelection->acquire(); + pWrap->mpSelection.set(pWrap->mpContext, css::uno::UNO_QUERY); } return pWrap->mpSelection; } - return NULL; + return css::uno::Reference(); } extern "C" { @@ -49,8 +47,9 @@ selection_add_selection( AtkSelection *selection, gint i ) { try { - accessibility::XAccessibleSelection* pSelection = getSelection( selection ); - if( pSelection ) + css::uno::Reference pSelection + = getSelection( selection ); + if( pSelection.is() ) { pSelection->selectAccessibleChild( i ); return TRUE; @@ -67,8 +66,9 @@ static gboolean selection_clear_selection( AtkSelection *selection ) { try { - accessibility::XAccessibleSelection* pSelection = getSelection( selection ); - if( pSelection ) + css::uno::Reference pSelection + = getSelection( selection ); + if( pSelection.is() ) { pSelection->clearAccessibleSelection(); return TRUE; @@ -86,8 +86,9 @@ selection_ref_selection( AtkSelection *selection, gint i ) { try { - accessibility::XAccessibleSelection* pSelection = getSelection( selection ); - if( pSelection ) + css::uno::Reference pSelection + = getSelection( selection ); + if( pSelection.is() ) return atk_object_wrapper_ref( pSelection->getSelectedAccessibleChild( i ) ); } catch(const uno::Exception&) { @@ -101,8 +102,9 @@ static gint selection_get_selection_count( AtkSelection *selection) { try { - accessibility::XAccessibleSelection* pSelection = getSelection( selection ); - if( pSelection ) + css::uno::Reference pSelection + = getSelection( selection ); + if( pSelection.is() ) return pSelection->getSelectedAccessibleChildCount(); } catch(const uno::Exception&) { @@ -117,8 +119,9 @@ selection_is_child_selected( AtkSelection *selection, gint i) { try { - accessibility::XAccessibleSelection* pSelection = getSelection( selection ); - if( pSelection ) + css::uno::Reference pSelection + = getSelection( selection ); + if( pSelection.is() ) return pSelection->isAccessibleChildSelected( i ); } catch(const uno::Exception&) { @@ -133,8 +136,9 @@ selection_remove_selection( AtkSelection *selection, gint i ) { try { - accessibility::XAccessibleSelection* pSelection = getSelection( selection ); - if( pSelection ) + css::uno::Reference pSelection + = getSelection( selection ); + if( pSelection.is() ) { pSelection->deselectAccessibleChild( i ); return TRUE; @@ -151,8 +155,9 @@ static gboolean selection_select_all_selection( AtkSelection *selection) { try { - accessibility::XAccessibleSelection* pSelection = getSelection( selection ); - if( pSelection ) + css::uno::Reference pSelection + = getSelection( selection ); + if( pSelection.is() ) { pSelection->selectAllAccessibleChildren(); return TRUE; diff --git a/vcl/unx/gtk/a11y/atktable.cxx b/vcl/unx/gtk/a11y/atktable.cxx index 9696b6bdb3cb..f4e975264652 100644 --- a/vcl/unx/gtk/a11y/atktable.cxx +++ b/vcl/unx/gtk/a11y/atktable.cxx @@ -48,23 +48,21 @@ getAsConst( const OUString& rString ) /*****************************************************************************/ -static accessibility::XAccessibleTable* +static css::uno::Reference getTable( AtkTable *pTable ) throw (uno::RuntimeException) { AtkObjectWrapper *pWrap = ATK_OBJECT_WRAPPER( pTable ); if( pWrap ) { - if( !pWrap->mpTable && pWrap->mpContext ) + if( !pWrap->mpTable.is() ) { - uno::Any any = pWrap->mpContext->queryInterface( cppu::UnoType::get() ); - pWrap->mpTable = static_cast< accessibility::XAccessibleTable * > (any.pReserved); - pWrap->mpTable->acquire(); + pWrap->mpTable.set(pWrap->mpContext, css::uno::UNO_QUERY); } return pWrap->mpTable; } - return NULL; + return css::uno::Reference(); } /*****************************************************************************/ @@ -77,8 +75,8 @@ table_wrapper_ref_at (AtkTable *table, gint column) { try { - accessibility::XAccessibleTable* pTable = getTable( table ); - if( pTable ) + css::uno::Reference pTable = getTable( table ); + if( pTable.is() ) return atk_object_wrapper_conditional_ref( pTable->getAccessibleCellAt( row, column ) ); } @@ -97,8 +95,9 @@ table_wrapper_get_index_at (AtkTable *table, gint column) { try { - accessibility::XAccessibleTable* pTable = getTable( table ); - if( pTable ) + css::uno::Reference pTable + = getTable( table ); + if( pTable.is() ) return pTable->getAccessibleIndex( row, column ); } catch(const uno::Exception&) { @@ -115,8 +114,9 @@ table_wrapper_get_column_at_index (AtkTable *table, gint nIndex) { try { - accessibility::XAccessibleTable* pTable = getTable( table ); - if( pTable ) + css::uno::Reference pTable + = getTable( table ); + if( pTable.is() ) return pTable->getAccessibleColumn( nIndex ); } catch(const uno::Exception&) { @@ -133,8 +133,9 @@ table_wrapper_get_row_at_index( AtkTable *table, gint nIndex ) { try { - accessibility::XAccessibleTable* pTable = getTable( table ); - if( pTable ) + css::uno::Reference pTable + = getTable( table ); + if( pTable.is() ) return pTable->getAccessibleRow( nIndex ); } catch(const uno::Exception&) { @@ -150,8 +151,9 @@ static gint table_wrapper_get_n_columns( AtkTable *table ) { try { - accessibility::XAccessibleTable* pTable = getTable( table ); - if( pTable ) + css::uno::Reference pTable + = getTable( table ); + if( pTable.is() ) return pTable->getAccessibleColumnCount(); } catch(const uno::Exception&) { @@ -167,8 +169,9 @@ static gint table_wrapper_get_n_rows( AtkTable *table ) { try { - accessibility::XAccessibleTable* pTable = getTable( table ); - if( pTable ) + css::uno::Reference pTable + = getTable( table ); + if( pTable.is() ) return pTable->getAccessibleRowCount(); } catch(const uno::Exception&) { @@ -186,8 +189,9 @@ table_wrapper_get_column_extent_at( AtkTable *table, gint column ) { try { - accessibility::XAccessibleTable* pTable = getTable( table ); - if( pTable ) + css::uno::Reference pTable + = getTable( table ); + if( pTable.is() ) return pTable->getAccessibleColumnExtentAt( row, column ); } catch(const uno::Exception&) { @@ -205,8 +209,9 @@ table_wrapper_get_row_extent_at( AtkTable *table, gint column ) { try { - accessibility::XAccessibleTable* pTable = getTable( table ); - if( pTable ) + css::uno::Reference pTable + = getTable( table ); + if( pTable.is() ) return pTable->getAccessibleRowExtentAt( row, column ); } catch(const uno::Exception&) { @@ -222,8 +227,9 @@ static AtkObject * table_wrapper_get_caption( AtkTable *table ) { try { - accessibility::XAccessibleTable* pTable = getTable( table ); - if( pTable ) + css::uno::Reference pTable + = getTable( table ); + if( pTable.is() ) return atk_object_wrapper_conditional_ref( pTable->getAccessibleCaption() ); } @@ -241,8 +247,9 @@ table_wrapper_get_row_description( AtkTable *table, gint row ) { try { - accessibility::XAccessibleTable* pTable = getTable( table ); - if( pTable ) + css::uno::Reference pTable + = getTable( table ); + if( pTable.is() ) return getAsConst( pTable->getAccessibleRowDescription( row ) ); } catch(const uno::Exception&) { @@ -259,8 +266,9 @@ table_wrapper_get_column_description( AtkTable *table, gint column ) { try { - accessibility::XAccessibleTable* pTable = getTable( table ); - if( pTable ) + css::uno::Reference pTable + = getTable( table ); + if( pTable.is() ) return getAsConst( pTable->getAccessibleColumnDescription( column ) ); } catch(const uno::Exception&) { @@ -277,8 +285,9 @@ table_wrapper_get_row_header( AtkTable *table, gint row ) { try { - accessibility::XAccessibleTable* pTable = getTable( table ); - if( pTable ) + css::uno::Reference pTable + = getTable( table ); + if( pTable.is() ) { uno::Reference< accessibility::XAccessibleTable > xRowHeaders( pTable->getAccessibleRowHeaders() ); if( xRowHeaders.is() ) @@ -299,9 +308,9 @@ table_wrapper_get_column_header( AtkTable *table, gint column ) { try { - accessibility::XAccessibleTable* pTable = getTable( table ); - - if( pTable ) + css::uno::Reference pTable + = getTable( table ); + if( pTable.is() ) { uno::Reference< accessibility::XAccessibleTable > xColumnHeaders( pTable->getAccessibleColumnHeaders() ); if( xColumnHeaders.is() ) @@ -321,8 +330,9 @@ static AtkObject * table_wrapper_get_summary( AtkTable *table ) { try { - accessibility::XAccessibleTable* pTable = getTable( table ); - if( pTable ) + css::uno::Reference pTable + = getTable( table ); + if( pTable.is() ) { return atk_object_wrapper_conditional_ref( pTable->getAccessibleSummary() ); } @@ -358,8 +368,9 @@ table_wrapper_get_selected_columns( AtkTable *table, { *pSelected = NULL; try { - accessibility::XAccessibleTable* pTable = getTable( table ); - if( pTable ) + css::uno::Reference pTable + = getTable( table ); + if( pTable.is() ) return convertToGIntArray( pTable->getSelectedAccessibleColumns(), pSelected ); } catch(const uno::Exception&) { @@ -377,8 +388,9 @@ table_wrapper_get_selected_rows( AtkTable *table, { *pSelected = NULL; try { - accessibility::XAccessibleTable* pTable = getTable( table ); - if( pTable ) + css::uno::Reference pTable + = getTable( table ); + if( pTable.is() ) return convertToGIntArray( pTable->getSelectedAccessibleRows(), pSelected ); } catch(const uno::Exception&) { @@ -395,8 +407,9 @@ table_wrapper_is_column_selected( AtkTable *table, gint column ) { try { - accessibility::XAccessibleTable* pTable = getTable( table ); - if( pTable ) + css::uno::Reference pTable + = getTable( table ); + if( pTable.is() ) return pTable->isAccessibleColumnSelected( column ); } catch(const uno::Exception&) { @@ -413,8 +426,9 @@ table_wrapper_is_row_selected( AtkTable *table, gint row ) { try { - accessibility::XAccessibleTable* pTable = getTable( table ); - if( pTable ) + css::uno::Reference pTable + = getTable( table ); + if( pTable.is() ) return pTable->isAccessibleRowSelected( row ); } catch(const uno::Exception&) { @@ -432,8 +446,9 @@ table_wrapper_is_selected( AtkTable *table, gint column ) { try { - accessibility::XAccessibleTable* pTable = getTable( table ); - if( pTable ) + css::uno::Reference pTable + = getTable( table ); + if( pTable.is() ) return pTable->isAccessibleSelected( row, column ); } catch(const uno::Exception&) { diff --git a/vcl/unx/gtk/a11y/atktext.cxx b/vcl/unx/gtk/a11y/atktext.cxx index c944e11bffa5..7ae5ff4b3ffc 100644 --- a/vcl/unx/gtk/a11y/atktext.cxx +++ b/vcl/unx/gtk/a11y/atktext.cxx @@ -57,7 +57,7 @@ text_type_from_boundary(AtkTextBoundary boundary_type) /*****************************************************************************/ static gchar * -adjust_boundaries( accessibility::XAccessibleText* pText, +adjust_boundaries( css::uno::Reference const & pText, accessibility::TextSegment& rTextSegment, AtkTextBoundary boundary_type, gint * start_offset, gint * end_offset ) @@ -133,108 +133,78 @@ adjust_boundaries( accessibility::XAccessibleText* pText, /*****************************************************************************/ -static accessibility::XAccessibleText* +static css::uno::Reference getText( AtkText *pText ) throw (uno::RuntimeException) { AtkObjectWrapper *pWrap = ATK_OBJECT_WRAPPER( pText ); if( pWrap ) { - if( !pWrap->mpText && pWrap->mpContext ) + if( !pWrap->mpText.is() ) { - uno::Any any = pWrap->mpContext->queryInterface( cppu::UnoType::get() ); - pWrap->mpText = static_cast< accessibility::XAccessibleText * > (any.pReserved); - pWrap->mpText->acquire(); + pWrap->mpText.set(pWrap->mpContext, css::uno::UNO_QUERY); } return pWrap->mpText; } - return NULL; + return css::uno::Reference(); } /*****************************************************************************/ -static accessibility::XAccessibleTextMarkup* +static css::uno::Reference getTextMarkup( AtkText *pText ) throw (uno::RuntimeException) { AtkObjectWrapper *pWrap = ATK_OBJECT_WRAPPER( pText ); if( pWrap ) { - if( !pWrap->mpTextMarkup && pWrap->mpContext ) + if( !pWrap->mpTextMarkup.is() ) { - uno::Any any = pWrap->mpContext->queryInterface( cppu::UnoType::get() ); - /* Since this not a dedicated interface in Atk and thus has not - * been queried during wrapper initialization, we need to check - * the return value here. - */ - if( typelib_TypeClass_INTERFACE == any.pType->eTypeClass ) - { - pWrap->mpTextMarkup = static_cast< accessibility::XAccessibleTextMarkup * > (any.pReserved); - if( pWrap->mpTextMarkup ) - pWrap->mpTextMarkup->acquire(); - } + pWrap->mpTextMarkup.set(pWrap->mpContext, css::uno::UNO_QUERY); } return pWrap->mpTextMarkup; } - return NULL; + return css::uno::Reference(); } /*****************************************************************************/ -static accessibility::XAccessibleTextAttributes* +static css::uno::Reference getTextAttributes( AtkText *pText ) throw (uno::RuntimeException) { AtkObjectWrapper *pWrap = ATK_OBJECT_WRAPPER( pText ); if( pWrap ) { - if( !pWrap->mpTextAttributes && pWrap->mpContext ) + if( !pWrap->mpTextAttributes.is() ) { - uno::Any any = pWrap->mpContext->queryInterface( cppu::UnoType::get() ); - /* Since this not a dedicated interface in Atk and thus has not - * been queried during wrapper initialization, we need to check - * the return value here. - */ - if( typelib_TypeClass_INTERFACE == any.pType->eTypeClass ) - { - pWrap->mpTextAttributes = static_cast< accessibility::XAccessibleTextAttributes * > (any.pReserved); - pWrap->mpTextAttributes->acquire(); - } + pWrap->mpTextAttributes.set(pWrap->mpContext, css::uno::UNO_QUERY); } return pWrap->mpTextAttributes; } - return NULL; + return css::uno::Reference(); } /*****************************************************************************/ -static accessibility::XAccessibleMultiLineText* +static css::uno::Reference getMultiLineText( AtkText *pText ) throw (uno::RuntimeException) { AtkObjectWrapper *pWrap = ATK_OBJECT_WRAPPER( pText ); if( pWrap ) { - if( !pWrap->mpMultiLineText && pWrap->mpContext ) + if( !pWrap->mpMultiLineText.is() ) { - uno::Any any = pWrap->mpContext->queryInterface( cppu::UnoType::get() ); - /* Since this not a dedicated interface in Atk and thus has not - * been queried during wrapper initialization, we need to check - * the return value here. - */ - if( typelib_TypeClass_INTERFACE == any.pType->eTypeClass ) - { - pWrap->mpMultiLineText = static_cast< accessibility::XAccessibleMultiLineText * > (any.pReserved); - pWrap->mpMultiLineText->acquire(); - } + pWrap->mpMultiLineText.set(pWrap->mpContext, css::uno::UNO_QUERY); } return pWrap->mpMultiLineText; } - return NULL; + return css::uno::Reference(); } /*****************************************************************************/ @@ -269,8 +239,9 @@ text_wrapper_get_text (AtkText *text, } try { - accessibility::XAccessibleText* pText = getText( text ); - if( pText ) + css::uno::Reference pText + = getText( text ); + if( pText.is() ) { OUString aText; sal_Int32 n = pText->getCharacterCount(); @@ -298,8 +269,9 @@ text_wrapper_get_text_after_offset (AtkText *text, gint *end_offset) { try { - accessibility::XAccessibleText* pText = getText( text ); - if( pText ) + css::uno::Reference pText + = getText( text ); + if( pText.is() ) { accessibility::TextSegment aTextSegment = pText->getTextBehindIndex(offset, text_type_from_boundary(boundary_type)); return adjust_boundaries(pText, aTextSegment, boundary_type, start_offset, end_offset); @@ -320,8 +292,9 @@ text_wrapper_get_text_at_offset (AtkText *text, gint *end_offset) { try { - accessibility::XAccessibleText* pText = getText( text ); - if( pText ) + css::uno::Reference pText + = getText( text ); + if( pText.is() ) { /* If the user presses the 'End' key, the caret will be placed behind the last character, * which is the same index as the first character of the next line. In atk the magic offset @@ -333,8 +306,10 @@ text_wrapper_get_text_at_offset (AtkText *text, ATK_TEXT_BOUNDARY_LINE_END == boundary_type) ) { - accessibility::XAccessibleMultiLineText* pMultiLineText = getMultiLineText( text ); - if( pMultiLineText ) + css::uno::Reference< + css::accessibility::XAccessibleMultiLineText> pMultiLineText + = getMultiLineText( text ); + if( pMultiLineText.is() ) { accessibility::TextSegment aTextSegment = pMultiLineText->getTextAtLineWithCaret(); return adjust_boundaries(pText, aTextSegment, boundary_type, start_offset, end_offset); @@ -379,8 +354,9 @@ text_wrapper_get_text_before_offset (AtkText *text, gint *end_offset) { try { - accessibility::XAccessibleText* pText = getText( text ); - if( pText ) + css::uno::Reference pText + = getText( text ); + if( pText.is() ) { accessibility::TextSegment aTextSegment = pText->getTextBeforeIndex(offset, text_type_from_boundary(boundary_type)); return adjust_boundaries(pText, aTextSegment, boundary_type, start_offset, end_offset); @@ -399,8 +375,9 @@ text_wrapper_get_caret_offset (AtkText *text) gint offset = -1; try { - accessibility::XAccessibleText* pText = getText( text ); - if( pText ) + css::uno::Reference pText + = getText( text ); + if( pText.is() ) offset = pText->getCaretPosition(); } catch(const uno::Exception&) { @@ -415,8 +392,9 @@ text_wrapper_set_caret_offset (AtkText *text, gint offset) { try { - accessibility::XAccessibleText* pText = getText( text ); - if( pText ) + css::uno::Reference pText + = getText( text ); + if( pText.is() ) return pText->setCaretPosition( offset ); } catch(const uno::Exception&) { @@ -428,7 +406,7 @@ text_wrapper_set_caret_offset (AtkText *text, // #i92232# AtkAttributeSet* -handle_text_markup_as_run_attribute( accessibility::XAccessibleTextMarkup* pTextMarkup, +handle_text_markup_as_run_attribute( css::uno::Reference const & pTextMarkup, const gint nTextMarkupType, const gint offset, AtkAttributeSet* pSet, @@ -514,9 +492,11 @@ text_wrapper_get_run_attributes( AtkText *text, try { bool bOffsetsAreValid = false; - accessibility::XAccessibleText* pText = getText( text ); - accessibility::XAccessibleTextAttributes* pTextAttributes = getTextAttributes( text ); - if( pText && pTextAttributes ) + css::uno::Reference pText + = getText( text ); + css::uno::Reference + pTextAttributes = getTextAttributes( text ); + if( pText.is() && pTextAttributes.is() ) { uno::Sequence< beans::PropertyValue > aAttributeList = pTextAttributes->getRunAttributes( offset, uno::Sequence< OUString > () ); @@ -540,11 +520,12 @@ text_wrapper_get_run_attributes( AtkText *text, // #i92232# // - add special handling for tracked changes and refactor the // corresponding code for handling misspelled text. - accessibility::XAccessibleTextMarkup* pTextMarkup = getTextMarkup( text ); - if( pTextMarkup ) + css::uno::Reference + pTextMarkup = getTextMarkup( text ); + if( pTextMarkup.is() ) { // Get attribute run here if it hasn't been done before - if (!bOffsetsAreValid && pText) + if (!bOffsetsAreValid && pText.is()) { accessibility::TextSegment aAttributeTextSegment = pText->getTextAtIndex(offset, accessibility::AccessibleTextType::ATTRIBUTE_RUN); @@ -593,8 +574,9 @@ text_wrapper_get_default_attributes( AtkText *text ) AtkAttributeSet *pSet = NULL; try { - accessibility::XAccessibleTextAttributes* pTextAttributes = getTextAttributes( text ); - if( pTextAttributes ) + css::uno::Reference + pTextAttributes = getTextAttributes( text ); + if( pTextAttributes.is() ) { uno::Sequence< beans::PropertyValue > aAttributeList = pTextAttributes->getDefaultAttributes( uno::Sequence< OUString > () ); @@ -628,8 +610,9 @@ text_wrapper_get_character_extents( AtkText *text, AtkCoordType coords ) { try { - accessibility::XAccessibleText* pText = getText( text ); - if( pText ) + css::uno::Reference pText + = getText( text ); + if( pText.is() ) { *x = *y = *width = *height = 0; awt::Rectangle aRect = pText->getCharacterBounds( offset ); @@ -662,8 +645,9 @@ text_wrapper_get_character_count (AtkText *text) gint rv = 0; try { - accessibility::XAccessibleText* pText = getText( text ); - if( pText ) + css::uno::Reference pText + = getText( text ); + if( pText.is() ) rv = pText->getCharacterCount(); } catch(const uno::Exception&) { @@ -680,8 +664,9 @@ text_wrapper_get_offset_at_point (AtkText *text, AtkCoordType coords) { try { - accessibility::XAccessibleText* pText = getText( text ); - if( pText ) + css::uno::Reference pText + = getText( text ); + if( pText.is() ) { gint origin_x = 0; gint origin_y = 0; @@ -712,8 +697,9 @@ text_wrapper_get_n_selections (AtkText *text) gint rv = 0; try { - accessibility::XAccessibleText* pText = getText( text ); - if( pText ) + css::uno::Reference pText + = getText( text ); + if( pText.is() ) rv = ( pText->getSelectionEnd() > pText->getSelectionStart() ) ? 1 : 0; } catch(const uno::Exception&) { @@ -732,8 +718,9 @@ text_wrapper_get_selection (AtkText *text, g_return_val_if_fail( selection_num == 0, FALSE ); try { - accessibility::XAccessibleText* pText = getText( text ); - if( pText ) + css::uno::Reference pText + = getText( text ); + if( pText.is() ) { *start_offset = pText->getSelectionStart(); *end_offset = pText->getSelectionEnd(); @@ -757,8 +744,9 @@ text_wrapper_add_selection (AtkText *text, // existing adjacent selection ? try { - accessibility::XAccessibleText* pText = getText( text ); - if( pText ) + css::uno::Reference pText + = getText( text ); + if( pText.is() ) return pText->setSelection( start_offset, end_offset ); // ? } catch(const uno::Exception&) { @@ -775,8 +763,9 @@ text_wrapper_remove_selection (AtkText *text, g_return_val_if_fail( selection_num == 0, FALSE ); try { - accessibility::XAccessibleText* pText = getText( text ); - if( pText ) + css::uno::Reference pText + = getText( text ); + if( pText.is() ) return pText->setSelection( 0, 0 ); // ? } catch(const uno::Exception&) { @@ -795,8 +784,9 @@ text_wrapper_set_selection (AtkText *text, g_return_val_if_fail( selection_num == 0, FALSE ); try { - accessibility::XAccessibleText* pText = getText( text ); - if( pText ) + css::uno::Reference pText + = getText( text ); + if( pText.is() ) return pText->setSelection( start_offset, end_offset ); } catch(const uno::Exception&) { diff --git a/vcl/unx/gtk/a11y/atktextattributes.cxx b/vcl/unx/gtk/a11y/atktextattributes.cxx index 484336773906..734200568eae 100644 --- a/vcl/unx/gtk/a11y/atktextattributes.cxx +++ b/vcl/unx/gtk/a11y/atktextattributes.cxx @@ -207,23 +207,21 @@ String2Float( uno::Any& rAny, const gchar * value ) /*****************************************************************************/ -static accessibility::XAccessibleComponent* +static css::uno::Reference getComponent( AtkText *pText ) throw (uno::RuntimeException) { AtkObjectWrapper *pWrap = ATK_OBJECT_WRAPPER( pText ); if( pWrap ) { - if( !pWrap->mpComponent && pWrap->mpContext ) + if( !pWrap->mpComponent.is() ) { - uno::Any any = pWrap->mpContext->queryInterface( cppu::UnoType::get() ); - pWrap->mpComponent = static_cast< accessibility::XAccessibleComponent * > (any.pReserved); - pWrap->mpComponent->acquire(); + pWrap->mpComponent.set(pWrap->mpContext, css::uno::UNO_QUERY); } return pWrap->mpComponent; } - return NULL; + return css::uno::Reference(); } static gchar* @@ -248,8 +246,9 @@ get_color_value(const uno::Sequence< beans::PropertyValue >& rAttributeList, { try { - accessibility::XAccessibleComponent *pComponent = getComponent( text ); - if( pComponent ) + css::uno::Reference + pComponent = getComponent( text ); + if( pComponent.is() ) { switch( attr ) { diff --git a/vcl/unx/gtk/a11y/atkutil.cxx b/vcl/unx/gtk/a11y/atkutil.cxx index c2e8ffb28b32..57556ac73173 100644 --- a/vcl/unx/gtk/a11y/atkutil.cxx +++ b/vcl/unx/gtk/a11y/atkutil.cxx @@ -85,23 +85,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 && !wrapper_obj->mpText && wrapper_obj->mpContext ) + if( wrapper_obj && !wrapper_obj->mpText.is() ) { - uno::Any any = wrapper_obj->mpContext->queryInterface( cppu::UnoType::get() ); - if ( typelib_TypeClass_INTERFACE == any.pType->eTypeClass && - any.pReserved != 0 ) + wrapper_obj->mpText.set(wrapper_obj->mpContext, css::uno::UNO_QUERY); + if ( wrapper_obj->mpText.is() ) { - wrapper_obj->mpText = static_cast< accessibility::XAccessibleText * > (any.pReserved); - if ( wrapper_obj->mpText != 0 ) + gint caretPos = wrapper_obj->mpText->getCaretPosition(); + + if ( caretPos != -1 ) { - wrapper_obj->mpText->acquire(); - 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 ); - } + 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 a81f6cd03e47..1fa6d3bfc099 100644 --- a/vcl/unx/gtk/a11y/atkvalue.cxx +++ b/vcl/unx/gtk/a11y/atkvalue.cxx @@ -25,23 +25,21 @@ using namespace ::com::sun::star; -static accessibility::XAccessibleValue* +static css::uno::Reference getValue( AtkValue *pValue ) throw (uno::RuntimeException) { AtkObjectWrapper *pWrap = ATK_OBJECT_WRAPPER( pValue ); if( pWrap ) { - if( !pWrap->mpValue && pWrap->mpContext ) + if( !pWrap->mpValue.is() ) { - uno::Any any = pWrap->mpContext->queryInterface( cppu::UnoType::get() ); - pWrap->mpValue = static_cast< accessibility::XAccessibleValue * > (any.pReserved); - pWrap->mpValue->acquire(); + pWrap->mpValue.set(pWrap->mpContext, css::uno::UNO_QUERY); } return pWrap->mpValue; } - return NULL; + return css::uno::Reference(); } static void anyToGValue( uno::Any aAny, GValue *pValue ) @@ -62,8 +60,9 @@ value_wrapper_get_current_value( AtkValue *value, GValue *gval ) { try { - accessibility::XAccessibleValue* pValue = getValue( value ); - if( pValue ) + css::uno::Reference pValue + = getValue( value ); + if( pValue.is() ) anyToGValue( pValue->getCurrentValue(), gval ); } catch(const uno::Exception&) { @@ -76,8 +75,9 @@ value_wrapper_get_maximum_value( AtkValue *value, GValue *gval ) { try { - accessibility::XAccessibleValue* pValue = getValue( value ); - if( pValue ) + css::uno::Reference pValue + = getValue( value ); + if( pValue.is() ) anyToGValue( pValue->getMaximumValue(), gval ); } catch(const uno::Exception&) { @@ -90,8 +90,9 @@ value_wrapper_get_minimum_value( AtkValue *value, GValue *gval ) { try { - accessibility::XAccessibleValue* pValue = getValue( value ); - if( pValue ) + css::uno::Reference pValue + = getValue( value ); + if( pValue.is() ) anyToGValue( pValue->getMinimumValue(), gval ); } catch(const uno::Exception&) { @@ -104,8 +105,9 @@ value_wrapper_set_current_value( AtkValue *value, const GValue *gval ) { try { - accessibility::XAccessibleValue* pValue = getValue( value ); - if( pValue ) + css::uno::Reference pValue + = getValue( value ); + if( pValue.is() ) { // FIXME - this needs expanding double aDouble = g_value_get_double( gval ); diff --git a/vcl/unx/gtk/a11y/atkwrapper.cxx b/vcl/unx/gtk/a11y/atkwrapper.cxx index efb3dd89d683..ef04c5862b0f 100644 --- a/vcl/unx/gtk/a11y/atkwrapper.cxx +++ b/vcl/unx/gtk/a11y/atkwrapper.cxx @@ -338,13 +338,12 @@ wrapper_get_name( AtkObject *atk_obj ) { AtkObjectWrapper *obj = ATK_OBJECT_WRAPPER (atk_obj); - if( obj->mpContext ) + if( obj->mpContext.is() ) { - uno::Reference< accessibility::XAccessibleContext > xContext(obj->mpContext); try { OString aName = OUStringToOString( - xContext->getAccessibleName(), + obj->mpContext->getAccessibleName(), RTL_TEXTENCODING_UTF8); int nCmp = atk_obj->name ? rtl_str_compare( atk_obj->name, aName.getStr() ) : -1; @@ -370,13 +369,12 @@ wrapper_get_description( AtkObject *atk_obj ) { AtkObjectWrapper *obj = ATK_OBJECT_WRAPPER (atk_obj); - if( obj->mpContext ) + if( obj->mpContext.is() ) { - uno::Reference< accessibility::XAccessibleContext > xContext(obj->mpContext); try { OString aDescription = OUStringToOString( - xContext->getAccessibleDescription(), + obj->mpContext->getAccessibleDescription(), RTL_TEXTENCODING_UTF8); g_free(atk_obj->description); @@ -399,20 +397,16 @@ wrapper_get_attributes( AtkObject *atk_obj ) AtkObjectWrapper *obj = ATK_OBJECT_WRAPPER( atk_obj ); AtkAttributeSet *pSet = NULL; - if( obj->mpContext ) + try { - uno::Reference< accessibility::XAccessibleContext > xContext( obj->mpContext ); - try - { - uno::Reference< accessibility::XAccessibleExtendedAttributes > xExtendedAttrs( xContext, - uno::UNO_QUERY ); - if( xExtendedAttrs.is() ) - pSet = attribute_set_new_from_extended_attributes( xExtendedAttrs ); - } - catch(const uno::Exception&) - { - g_warning( "Exception in getAccessibleAttributes()" ); - } + uno::Reference< accessibility::XAccessibleExtendedAttributes > + xExtendedAttrs( obj->mpContext, uno::UNO_QUERY ); + if( xExtendedAttrs.is() ) + pSet = attribute_set_new_from_extended_attributes( xExtendedAttrs ); + } + catch(const uno::Exception&) + { + g_warning( "Exception in getAccessibleAttributes()" ); } return pSet; @@ -426,11 +420,10 @@ wrapper_get_n_children( AtkObject *atk_obj ) AtkObjectWrapper *obj = ATK_OBJECT_WRAPPER (atk_obj); gint n = 0; - if( obj->mpContext ) + if( obj->mpContext.is() ) { - uno::Reference< accessibility::XAccessibleContext > xContext(obj->mpContext); try { - n = xContext->getAccessibleChildCount(); + n = obj->mpContext->getAccessibleChildCount(); } catch(const uno::Exception&) { OSL_FAIL("Exception in getAccessibleChildCount()" ); @@ -456,12 +449,11 @@ wrapper_ref_child( AtkObject *atk_obj, return obj->child_about_to_be_removed; } - if( obj->mpContext ) + if( obj->mpContext.is() ) { - uno::Reference< accessibility::XAccessibleContext > xContext(obj->mpContext); try { uno::Reference< accessibility::XAccessible > xAccessible = - xContext->getAccessibleChild( i ); + obj->mpContext->getAccessibleChild( i ); child = atk_object_wrapper_ref( xAccessible ); } @@ -481,11 +473,10 @@ wrapper_get_index_in_parent( AtkObject *atk_obj ) AtkObjectWrapper *obj = ATK_OBJECT_WRAPPER (atk_obj); gint i = -1; - if( obj->mpContext ) + if( obj->mpContext.is() ) { - uno::Reference< accessibility::XAccessibleContext > xContext(obj->mpContext); try { - i = xContext->getAccessibleIndexInParent(); + i = obj->mpContext->getAccessibleIndexInParent(); } catch(const uno::Exception&) { g_warning( "Exception in getAccessibleIndexInParent()" ); @@ -502,12 +493,11 @@ wrapper_ref_relation_set( AtkObject *atk_obj ) AtkObjectWrapper *obj = ATK_OBJECT_WRAPPER (atk_obj); AtkRelationSet *pSet = atk_relation_set_new(); - if( obj->mpContext ) + if( obj->mpContext.is() ) { - uno::Reference< accessibility::XAccessibleContext > xContext(obj->mpContext); try { uno::Reference< accessibility::XAccessibleRelationSet > xRelationSet( - xContext->getAccessibleRelationSet() + obj->mpContext->getAccessibleRelationSet() ); sal_Int32 nRelations = xRelationSet.is() ? xRelationSet->getRelationCount() : 0; @@ -548,12 +538,11 @@ wrapper_ref_state_set( AtkObject *atk_obj ) AtkObjectWrapper *obj = ATK_OBJECT_WRAPPER (atk_obj); AtkStateSet *pSet = atk_state_set_new(); - if( obj->mpContext ) + if( obj->mpContext.is() ) { - uno::Reference< accessibility::XAccessibleContext > xContext(obj->mpContext); try { uno::Reference< accessibility::XAccessibleStateSet > xStateSet( - xContext->getAccessibleStateSet()); + obj->mpContext->getAccessibleStateSet()); if( xStateSet.is() ) { @@ -595,11 +584,10 @@ atk_object_wrapper_finalize (GObject *obj) { AtkObjectWrapper *pWrap = ATK_OBJECT_WRAPPER (obj); - if( pWrap->mpAccessible ) + if( pWrap->mpAccessible.is() ) { ooo_wrapper_registry_remove( pWrap->mpAccessible ); - pWrap->mpAccessible->release(); - pWrap->mpAccessible = NULL; + pWrap->mpAccessible.clear(); } atk_object_wrapper_dispose( pWrap ); @@ -826,14 +814,12 @@ atk_object_wrapper_new( const ::com::sun::star::uno::Reference< ::com::sun::star gpointer obj = g_object_new( nType, NULL); pWrap = ATK_OBJECT_WRAPPER( obj ); - pWrap->mpAccessible = rxAccessible.get(); - rxAccessible->acquire(); + pWrap->mpAccessible = rxAccessible; pWrap->index_of_child_about_to_be_removed = -1; pWrap->child_about_to_be_removed = NULL; - xContext->acquire(); - pWrap->mpContext = xContext.get(); + pWrap->mpContext = xContext; AtkObject* atk_obj = ATK_OBJECT(pWrap); atk_obj->role = mapToAtkRole( xContext->getAccessibleRole() ); @@ -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) { - RELEASE( wrapper->mpContext ) - RELEASE( wrapper->mpAction ) - RELEASE( wrapper->mpComponent ) - RELEASE( wrapper->mpEditableText ) - RELEASE( wrapper->mpHypertext ) - RELEASE( wrapper->mpImage ) - RELEASE( wrapper->mpSelection ) - RELEASE( wrapper->mpMultiLineText ) - RELEASE( wrapper->mpTable ) - RELEASE( wrapper->mpText ) - RELEASE( wrapper->mpTextMarkup ) - RELEASE( wrapper->mpTextAttributes ) - RELEASE( wrapper->mpValue ) + 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 95625ad4bca8..5662625a3493 100644 --- a/vcl/unx/gtk/a11y/atkwrapper.hxx +++ b/vcl/unx/gtk/a11y/atkwrapper.hxx @@ -47,20 +47,23 @@ struct _AtkObjectWrapper { AtkObject aParent; - ::com::sun::star::accessibility::XAccessible *mpAccessible; - ::com::sun::star::accessibility::XAccessibleContext *mpContext; - ::com::sun::star::accessibility::XAccessibleAction *mpAction; - ::com::sun::star::accessibility::XAccessibleComponent *mpComponent; - ::com::sun::star::accessibility::XAccessibleEditableText *mpEditableText; - ::com::sun::star::accessibility::XAccessibleHypertext *mpHypertext; - ::com::sun::star::accessibility::XAccessibleImage *mpImage; - ::com::sun::star::accessibility::XAccessibleMultiLineText *mpMultiLineText; - ::com::sun::star::accessibility::XAccessibleSelection *mpSelection; - ::com::sun::star::accessibility::XAccessibleTable *mpTable; - ::com::sun::star::accessibility::XAccessibleText *mpText; - ::com::sun::star::accessibility::XAccessibleTextMarkup *mpTextMarkup; - ::com::sun::star::accessibility::XAccessibleTextAttributes *mpTextAttributes; - ::com::sun::star::accessibility::XAccessibleValue *mpValue; + css::uno::Reference mpAccessible; + 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; -- cgit