[Libreoffice-commits] core.git: vcl/unx

Kohei Yoshida kohei.yoshida at collabora.com
Wed Mar 1 00:07:55 UTC 2017


 vcl/unx/gtk/a11y/atkaction.cxx         |   11 -
 vcl/unx/gtk/a11y/atkcomponent.cxx      |   11 -
 vcl/unx/gtk/a11y/atkeditabletext.cxx   |   11 -
 vcl/unx/gtk/a11y/atkhypertext.cxx      |   11 -
 vcl/unx/gtk/a11y/atkimage.cxx          |   11 -
 vcl/unx/gtk/a11y/atklistener.cxx       |   20 --
 vcl/unx/gtk/a11y/atklistener.hxx       |    2 
 vcl/unx/gtk/a11y/atkselection.cxx      |   11 -
 vcl/unx/gtk/a11y/atktable.cxx          |   11 -
 vcl/unx/gtk/a11y/atktext.cxx           |   44 +++--
 vcl/unx/gtk/a11y/atktextattributes.cxx |   11 -
 vcl/unx/gtk/a11y/atkutil.cxx           |   25 +--
 vcl/unx/gtk/a11y/atkvalue.cxx          |   11 -
 vcl/unx/gtk/a11y/atkwrapper.cxx        |  266 +++++++++++++++------------------
 vcl/unx/gtk/a11y/atkwrapper.hxx        |   34 +++-
 15 files changed, 258 insertions(+), 232 deletions(-)

New commits:
commit 10077a06d8f6d08f276f99024528ee31a57390a9
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Tue Feb 28 17:52:10 2017 -0500

    Revert my fix for tdf#71409, to hopefully fix tdf#104381.
    
    This reverts commit 87e040fd0f04307534920d0765af6d5878794a98.
    This reverts commit a0ef7474521413c8967559a635e6fdc0d88f1df6.
    
    Conflicts:
    	vcl/unx/gtk/a11y/atkutil.cxx
    
    Change-Id: Ib3a799e27b2495ebd1e7723f1cb5babf0dfbc702
    Reviewed-on: https://gerrit.libreoffice.org/34730
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Kohei Yoshida <libreoffice at kohei.us>

diff --git a/vcl/unx/gtk/a11y/atkaction.cxx b/vcl/unx/gtk/a11y/atkaction.cxx
index faadc40..98a85e9 100644
--- a/vcl/unx/gtk/a11y/atkaction.cxx
+++ b/vcl/unx/gtk/a11y/atkaction.cxx
@@ -49,11 +49,14 @@ static css::uno::Reference<css::accessibility::XAccessibleAction>
 {
     AtkObjectWrapper *pWrap = ATK_OBJECT_WRAPPER( action );
 
-    if (pWrap)
+    if( pWrap )
     {
-        uno::Reference<accessibility::XAccessibleAction> xAction(
-            pWrap->mpContext.get(), uno::UNO_QUERY);
-        return xAction;
+        if( !pWrap->mpAction.is() )
+        {
+            pWrap->mpAction.set(pWrap->mpContext, css::uno::UNO_QUERY);
+        }
+
+        return pWrap->mpAction;
     }
 
     return css::uno::Reference<css::accessibility::XAccessibleAction>();
diff --git a/vcl/unx/gtk/a11y/atkcomponent.cxx b/vcl/unx/gtk/a11y/atkcomponent.cxx
index 54e664b..a56aebe 100644
--- a/vcl/unx/gtk/a11y/atkcomponent.cxx
+++ b/vcl/unx/gtk/a11y/atkcomponent.cxx
@@ -28,11 +28,14 @@ static css::uno::Reference<css::accessibility::XAccessibleComponent>
     getComponent( AtkComponent *pComponent )
 {
     AtkObjectWrapper *pWrap = ATK_OBJECT_WRAPPER( pComponent );
-    if (pWrap)
+    if( pWrap )
     {
-        uno::Reference<accessibility::XAccessibleComponent> xComp(
-            pWrap->mpContext.get(), uno::UNO_QUERY);
-        return xComp;
+        if( !pWrap->mpComponent.is() )
+        {
+            pWrap->mpComponent.set(pWrap->mpContext, css::uno::UNO_QUERY);
+        }
+
+        return pWrap->mpComponent;
     }
 
     return css::uno::Reference<css::accessibility::XAccessibleComponent>();
diff --git a/vcl/unx/gtk/a11y/atkeditabletext.cxx b/vcl/unx/gtk/a11y/atkeditabletext.cxx
index 070ee28..49d3eb9 100644
--- a/vcl/unx/gtk/a11y/atkeditabletext.cxx
+++ b/vcl/unx/gtk/a11y/atkeditabletext.cxx
@@ -32,11 +32,14 @@ static css::uno::Reference<css::accessibility::XAccessibleEditableText>
     getEditableText( AtkEditableText *pEditableText )
 {
     AtkObjectWrapper *pWrap = ATK_OBJECT_WRAPPER( pEditableText );
-    if (pWrap)
+    if( pWrap )
     {
-        uno::Reference<accessibility::XAccessibleEditableText> xET(
-            pWrap->mpContext.get(), uno::UNO_QUERY);
-        return xET;
+        if( !pWrap->mpEditableText.is() )
+        {
+            pWrap->mpEditableText.set(pWrap->mpContext, css::uno::UNO_QUERY);
+        }
+
+        return pWrap->mpEditableText;
     }
 
     return css::uno::Reference<css::accessibility::XAccessibleEditableText>();
diff --git a/vcl/unx/gtk/a11y/atkhypertext.cxx b/vcl/unx/gtk/a11y/atkhypertext.cxx
index 356262f..637842b 100644
--- a/vcl/unx/gtk/a11y/atkhypertext.cxx
+++ b/vcl/unx/gtk/a11y/atkhypertext.cxx
@@ -194,11 +194,14 @@ static css::uno::Reference<css::accessibility::XAccessibleHypertext>
     getHypertext( AtkHypertext *pHypertext )
 {
     AtkObjectWrapper *pWrap = ATK_OBJECT_WRAPPER( pHypertext );
-    if (pWrap)
+    if( pWrap )
     {
-        uno::Reference<accessibility::XAccessibleHypertext> xAH(
-            pWrap->mpContext.get(), uno::UNO_QUERY);
-        return xAH;
+        if( !pWrap->mpHypertext.is() )
+        {
+            pWrap->mpHypertext.set(pWrap->mpContext, css::uno::UNO_QUERY);
+        }
+
+        return pWrap->mpHypertext;
     }
 
     return css::uno::Reference<css::accessibility::XAccessibleHypertext>();
diff --git a/vcl/unx/gtk/a11y/atkimage.cxx b/vcl/unx/gtk/a11y/atkimage.cxx
index 404871f..1c9bc2c 100644
--- a/vcl/unx/gtk/a11y/atkimage.cxx
+++ b/vcl/unx/gtk/a11y/atkimage.cxx
@@ -40,11 +40,14 @@ static css::uno::Reference<css::accessibility::XAccessibleImage>
     getImage( AtkImage *pImage )
 {
     AtkObjectWrapper *pWrap = ATK_OBJECT_WRAPPER( pImage );
-    if (pWrap)
+    if( pWrap )
     {
-        uno::Reference<accessibility::XAccessibleImage> xAI(
-            pWrap->mpContext.get(), uno::UNO_QUERY);
-        return xAI;
+        if( !pWrap->mpImage.is() )
+        {
+            pWrap->mpImage.set(pWrap->mpContext, css::uno::UNO_QUERY);
+        }
+
+        return pWrap->mpImage;
     }
 
     return css::uno::Reference<css::accessibility::XAccessibleImage>();
diff --git a/vcl/unx/gtk/a11y/atklistener.cxx b/vcl/unx/gtk/a11y/atklistener.cxx
index b0e25d6..7edc337 100644
--- a/vcl/unx/gtk/a11y/atklistener.cxx
+++ b/vcl/unx/gtk/a11y/atklistener.cxx
@@ -129,9 +129,6 @@ void AtkListener::updateChildList(
     css::uno::Reference<css::accessibility::XAccessibleContext> const &
         pContext)
 {
-    if (!pContext.is())
-        return;
-
      m_aChildList.clear();
 
      uno::Reference< accessibility::XAccessibleStateSet > xStateSet = pContext->getAccessibleStateSet();
@@ -266,19 +263,6 @@ void AtkListener::handleInvalidateChildren(
     }
 }
 
-void AtkListener::stopListening()
-{
-    uno::Reference<accessibility::XAccessibleEventBroadcaster> xBroadcaster(
-        mpWrapper->mpContext.get(), uno::UNO_QUERY);
-
-    if (xBroadcaster.is())
-    {
-        uno::Reference<accessibility::XAccessibleEventListener> xListener(this);
-        if (xListener.is())
-            xBroadcaster->removeAccessibleEventListener(xListener);
-    }
-}
-
 /*****************************************************************************/
 
 static uno::Reference< accessibility::XAccessibleContext >
@@ -489,10 +473,6 @@ void AtkListener::notifyEvent( const accessibility::AccessibleEventObject& aEven
             gboolean bState = eNewState != ATK_STATE_INVALID;
             AtkStateType eRealState = bState ? eNewState : eOldState;
 
-            if (eOldState == ATK_STATE_FOCUSED)
-                // Stop listening to object going out-of-focus.
-                stopListening();
-
             atk_object_notify_state_change( atk_obj, eRealState, bState );
             break;
         }
diff --git a/vcl/unx/gtk/a11y/atklistener.hxx b/vcl/unx/gtk/a11y/atklistener.hxx
index 39d5075..82baf1e 100644
--- a/vcl/unx/gtk/a11y/atklistener.hxx
+++ b/vcl/unx/gtk/a11y/atklistener.hxx
@@ -64,8 +64,6 @@ private:
     // Process INVALIDATE_ALL_CHILDREN notification
     void handleInvalidateChildren(
         const css::uno::Reference< css::accessibility::XAccessibleContext >& rxParent);
-
-    void stopListening();
 };
 
 #endif // INCLUDED_VCL_UNX_GTK_A11Y_ATKLISTENER_HXX
diff --git a/vcl/unx/gtk/a11y/atkselection.cxx b/vcl/unx/gtk/a11y/atkselection.cxx
index b6d2a71..1d9772b 100644
--- a/vcl/unx/gtk/a11y/atkselection.cxx
+++ b/vcl/unx/gtk/a11y/atkselection.cxx
@@ -28,11 +28,14 @@ static css::uno::Reference<css::accessibility::XAccessibleSelection>
     getSelection( AtkSelection *pSelection )
 {
     AtkObjectWrapper *pWrap = ATK_OBJECT_WRAPPER( pSelection );
-    if (pWrap)
+    if( pWrap )
     {
-        uno::Reference<accessibility::XAccessibleSelection> xAS(
-            pWrap->mpContext.get(), uno::UNO_QUERY);
-        return xAS;
+        if( !pWrap->mpSelection.is() )
+        {
+            pWrap->mpSelection.set(pWrap->mpContext, css::uno::UNO_QUERY);
+        }
+
+        return pWrap->mpSelection;
     }
 
     return css::uno::Reference<css::accessibility::XAccessibleSelection>();
diff --git a/vcl/unx/gtk/a11y/atktable.cxx b/vcl/unx/gtk/a11y/atktable.cxx
index a39110a..f5a5324 100644
--- a/vcl/unx/gtk/a11y/atktable.cxx
+++ b/vcl/unx/gtk/a11y/atktable.cxx
@@ -53,11 +53,14 @@ static css::uno::Reference<css::accessibility::XAccessibleTable>
     getTable( AtkTable *pTable )
 {
     AtkObjectWrapper *pWrap = ATK_OBJECT_WRAPPER( pTable );
-    if (pWrap)
+    if( pWrap )
     {
-        uno::Reference<accessibility::XAccessibleTable> xAT(
-            pWrap->mpContext.get(), uno::UNO_QUERY);
-        return xAT;
+        if( !pWrap->mpTable.is() )
+        {
+            pWrap->mpTable.set(pWrap->mpContext, css::uno::UNO_QUERY);
+        }
+
+        return pWrap->mpTable;
     }
 
     return css::uno::Reference<css::accessibility::XAccessibleTable>();
diff --git a/vcl/unx/gtk/a11y/atktext.cxx b/vcl/unx/gtk/a11y/atktext.cxx
index 6dc3ca3..202236b 100644
--- a/vcl/unx/gtk/a11y/atktext.cxx
+++ b/vcl/unx/gtk/a11y/atktext.cxx
@@ -138,11 +138,14 @@ static css::uno::Reference<css::accessibility::XAccessibleText>
     getText( AtkText *pText )
 {
     AtkObjectWrapper *pWrap = ATK_OBJECT_WRAPPER( pText );
-    if (pWrap)
+    if( pWrap )
     {
-        uno::Reference<accessibility::XAccessibleText> xAT(
-            pWrap->mpContext.get(), uno::UNO_QUERY);
-        return xAT;
+        if( !pWrap->mpText.is() )
+        {
+            pWrap->mpText.set(pWrap->mpContext, css::uno::UNO_QUERY);
+        }
+
+        return pWrap->mpText;
     }
 
     return css::uno::Reference<css::accessibility::XAccessibleText>();
@@ -155,11 +158,14 @@ static css::uno::Reference<css::accessibility::XAccessibleTextMarkup>
     getTextMarkup( AtkText *pText )
 {
     AtkObjectWrapper *pWrap = ATK_OBJECT_WRAPPER( pText );
-    if (pWrap)
+    if( pWrap )
     {
-        uno::Reference<accessibility::XAccessibleTextMarkup> xATM(
-            pWrap->mpContext.get(), uno::UNO_QUERY);
-        return xATM;
+        if( !pWrap->mpTextMarkup.is() )
+        {
+            pWrap->mpTextMarkup.set(pWrap->mpContext, css::uno::UNO_QUERY);
+        }
+
+        return pWrap->mpTextMarkup;
     }
 
     return css::uno::Reference<css::accessibility::XAccessibleTextMarkup>();
@@ -172,11 +178,14 @@ static css::uno::Reference<css::accessibility::XAccessibleTextAttributes>
     getTextAttributes( AtkText *pText )
 {
     AtkObjectWrapper *pWrap = ATK_OBJECT_WRAPPER( pText );
-    if (pWrap)
+    if( pWrap )
     {
-        uno::Reference<accessibility::XAccessibleTextAttributes> xATA(
-            pWrap->mpContext.get(), uno::UNO_QUERY);
-        return xATA;
+        if( !pWrap->mpTextAttributes.is() )
+        {
+            pWrap->mpTextAttributes.set(pWrap->mpContext, css::uno::UNO_QUERY);
+        }
+
+        return pWrap->mpTextAttributes;
     }
 
     return css::uno::Reference<css::accessibility::XAccessibleTextAttributes>();
@@ -189,11 +198,14 @@ static css::uno::Reference<css::accessibility::XAccessibleMultiLineText>
     getMultiLineText( AtkText *pText )
 {
     AtkObjectWrapper *pWrap = ATK_OBJECT_WRAPPER( pText );
-    if (pWrap)
+    if( pWrap )
     {
-        uno::Reference<accessibility::XAccessibleMultiLineText> xAML(
-            pWrap->mpContext.get(), uno::UNO_QUERY);
-        return xAML;
+        if( !pWrap->mpMultiLineText.is() )
+        {
+            pWrap->mpMultiLineText.set(pWrap->mpContext, css::uno::UNO_QUERY);
+        }
+
+        return pWrap->mpMultiLineText;
     }
 
     return css::uno::Reference<css::accessibility::XAccessibleMultiLineText>();
diff --git a/vcl/unx/gtk/a11y/atktextattributes.cxx b/vcl/unx/gtk/a11y/atktextattributes.cxx
index da78072..bf4ae6f 100644
--- a/vcl/unx/gtk/a11y/atktextattributes.cxx
+++ b/vcl/unx/gtk/a11y/atktextattributes.cxx
@@ -212,11 +212,14 @@ static css::uno::Reference<css::accessibility::XAccessibleComponent>
     getComponent( AtkText *pText )
 {
     AtkObjectWrapper *pWrap = ATK_OBJECT_WRAPPER( pText );
-    if (pWrap)
+    if( pWrap )
     {
-        uno::Reference<accessibility::XAccessibleComponent> xAC(
-            pWrap->mpContext.get(), uno::UNO_QUERY);
-        return xAC;
+        if( !pWrap->mpComponent.is() )
+        {
+            pWrap->mpComponent.set(pWrap->mpContext, css::uno::UNO_QUERY);
+        }
+
+        return pWrap->mpComponent;
     }
 
     return css::uno::Reference<css::accessibility::XAccessibleComponent>();
diff --git a/vcl/unx/gtk/a11y/atkutil.cxx b/vcl/unx/gtk/a11y/atkutil.cxx
index 0f21a61..ad2e79b 100644
--- a/vcl/unx/gtk/a11y/atkutil.cxx
+++ b/vcl/unx/gtk/a11y/atkutil.cxx
@@ -87,24 +87,17 @@ atk_wrapper_focus_idle_handler (gpointer data)
             // also emit state-changed:focused event under the same condition.
             {
                 AtkObjectWrapper* wrapper_obj = ATK_OBJECT_WRAPPER (atk_obj);
-
-                if (wrapper_obj)
+                if( wrapper_obj && !wrapper_obj->mpText.is() )
                 {
-                    uno::Reference<accessibility::XAccessibleText> xText(
-                        wrapper_obj->mpContext.get(), uno::UNO_QUERY);
-
-                    if (xText.is())
+                    wrapper_obj->mpText.set(wrapper_obj->mpContext, css::uno::UNO_QUERY);
+                    if ( wrapper_obj->mpText.is() )
                     {
-                        try {
-                            gint caretPos = xText->getCaretPosition();
-
-                            if ( caretPos != -1 )
-                            {
-                                atk_object_notify_state_change( atk_obj, ATK_STATE_FOCUSED, TRUE );
-                                g_signal_emit_by_name( atk_obj, "text_caret_moved", caretPos );
-                            }
-                        } catch (const uno::Exception& e) {
-                            SAL_INFO("vcl.a11y", "exception: " << e.Message);
+                        gint caretPos = wrapper_obj->mpText->getCaretPosition();
+
+                        if ( caretPos != -1 )
+                        {
+                            atk_object_notify_state_change( atk_obj, ATK_STATE_FOCUSED, TRUE );
+                            g_signal_emit_by_name( atk_obj, "text_caret_moved", caretPos );
                         }
                     }
                 }
diff --git a/vcl/unx/gtk/a11y/atkvalue.cxx b/vcl/unx/gtk/a11y/atkvalue.cxx
index 6c80e37..f5e45d3 100644
--- a/vcl/unx/gtk/a11y/atkvalue.cxx
+++ b/vcl/unx/gtk/a11y/atkvalue.cxx
@@ -30,11 +30,14 @@ static css::uno::Reference<css::accessibility::XAccessibleValue>
     getValue( AtkValue *pValue )
 {
     AtkObjectWrapper *pWrap = ATK_OBJECT_WRAPPER( pValue );
-    if (pWrap)
+    if( pWrap )
     {
-        uno::Reference<accessibility::XAccessibleValue> xAV(
-            pWrap->mpContext.get(), uno::UNO_QUERY);
-        return xAV;
+        if( !pWrap->mpValue.is() )
+        {
+            pWrap->mpValue.set(pWrap->mpContext, css::uno::UNO_QUERY);
+        }
+
+        return pWrap->mpValue;
     }
 
     return css::uno::Reference<css::accessibility::XAccessibleValue>();
diff --git a/vcl/unx/gtk/a11y/atkwrapper.cxx b/vcl/unx/gtk/a11y/atkwrapper.cxx
index e9f3156..52f9218 100644
--- a/vcl/unx/gtk/a11y/atkwrapper.cxx
+++ b/vcl/unx/gtk/a11y/atkwrapper.cxx
@@ -335,31 +335,25 @@ wrapper_get_name( AtkObject *atk_obj )
 {
     AtkObjectWrapper *obj = ATK_OBJECT_WRAPPER (atk_obj);
 
-    if (obj)
+    if( obj->mpContext.is() )
     {
-        uno::Reference<accessibility::XAccessibleContext> xContext(
-            obj->mpContext.get(), uno::UNO_QUERY);
-
-        if (xContext.is())
-        {
-            try {
-                OString aName =
-                    OUStringToOString(
-                        xContext->getAccessibleName(),
-                        RTL_TEXTENCODING_UTF8);
-
-                int nCmp = atk_obj->name ? rtl_str_compare( atk_obj->name, aName.getStr() ) : -1;
-                if( nCmp != 0 )
-                {
-                    if( atk_obj->name )
-                        g_free(atk_obj->name);
-                    atk_obj->name = g_strdup(aName.getStr());
-                }
-            }
-            catch(const uno::Exception&) {
-                g_warning( "Exception in getAccessibleName()" );
+        try {
+            OString aName =
+                OUStringToOString(
+                    obj->mpContext->getAccessibleName(),
+                    RTL_TEXTENCODING_UTF8);
+
+            int nCmp = atk_obj->name ? rtl_str_compare( atk_obj->name, aName.getStr() ) : -1;
+            if( nCmp != 0 )
+            {
+                if( atk_obj->name )
+                    g_free(atk_obj->name);
+                atk_obj->name = g_strdup(aName.getStr());
             }
         }
+        catch(const uno::Exception&) {
+            g_warning( "Exception in getAccessibleName()" );
+        }
     }
 
     return ATK_OBJECT_CLASS (parent_class)->get_name(atk_obj);
@@ -372,23 +366,19 @@ wrapper_get_description( AtkObject *atk_obj )
 {
     AtkObjectWrapper *obj = ATK_OBJECT_WRAPPER (atk_obj);
 
-    if (obj)
+    if( obj->mpContext.is() )
     {
-        uno::Reference<accessibility::XAccessibleContext> xContext(obj->mpContext.get(), uno::UNO_QUERY);
-        if (xContext.is())
-        {
-            try {
-                OString aDescription =
-                    OUStringToOString(
-                        xContext->getAccessibleDescription(),
-                        RTL_TEXTENCODING_UTF8);
-
-                g_free(atk_obj->description);
-                atk_obj->description = g_strdup(aDescription.getStr());
-            }
-            catch(const uno::Exception&) {
-                g_warning( "Exception in getAccessibleDescription()" );
-            }
+        try {
+            OString aDescription =
+                OUStringToOString(
+                    obj->mpContext->getAccessibleDescription(),
+                    RTL_TEXTENCODING_UTF8);
+
+            g_free(atk_obj->description);
+            atk_obj->description = g_strdup(aDescription.getStr());
+        }
+        catch(const uno::Exception&) {
+            g_warning( "Exception in getAccessibleDescription()" );
         }
     }
 
@@ -407,7 +397,7 @@ wrapper_get_attributes( AtkObject *atk_obj )
     try
     {
         uno::Reference< accessibility::XAccessibleExtendedAttributes >
-            xExtendedAttrs(obj->mpContext.get(), uno::UNO_QUERY);
+            xExtendedAttrs( obj->mpContext, uno::UNO_QUERY );
         if( xExtendedAttrs.is() )
             pSet = attribute_set_new_from_extended_attributes( xExtendedAttrs );
     }
@@ -427,20 +417,14 @@ wrapper_get_n_children( AtkObject *atk_obj )
     AtkObjectWrapper *obj = ATK_OBJECT_WRAPPER (atk_obj);
     gint n = 0;
 
-    if (!obj)
-        return n;
-
-    uno::Reference<accessibility::XAccessibleContext> xContext(obj->mpContext.get(), uno::UNO_QUERY);
-    if (!xContext.is())
-        return n;
-
-    try
-    {
-        n = xContext->getAccessibleChildCount();
-    }
-    catch(const uno::Exception&)
+    if( obj->mpContext.is() )
     {
-        OSL_FAIL("Exception in getAccessibleChildCount()" );
+        try {
+            n = obj->mpContext->getAccessibleChildCount();
+        }
+        catch(const uno::Exception&) {
+            OSL_FAIL("Exception in getAccessibleChildCount()" );
+        }
     }
 
     return n;
@@ -462,22 +446,17 @@ wrapper_ref_child( AtkObject *atk_obj,
         return obj->child_about_to_be_removed;
     }
 
-    if (!obj)
-        return child;
-
-    uno::Reference<accessibility::XAccessibleContext> xContext(obj->mpContext.get(), uno::UNO_QUERY);
-    if (!xContext.is())
-        return child;
-
-    try
+    if( obj->mpContext.is() )
     {
-        uno::Reference< accessibility::XAccessible > xAccessible =
-            xContext->getAccessibleChild( i );
+        try {
+            uno::Reference< accessibility::XAccessible > xAccessible =
+                obj->mpContext->getAccessibleChild( i );
 
-        child = atk_object_wrapper_ref( xAccessible );
-    }
-    catch(const uno::Exception&) {
-        OSL_FAIL("Exception in getAccessibleChild");
+            child = atk_object_wrapper_ref( xAccessible );
+        }
+        catch(const uno::Exception&) {
+            OSL_FAIL("Exception in getAccessibleChild");
+        }
     }
 
     return child;
@@ -491,17 +470,13 @@ wrapper_get_index_in_parent( AtkObject *atk_obj )
     AtkObjectWrapper *obj = ATK_OBJECT_WRAPPER (atk_obj);
     gint i = -1;
 
-    if (obj)
+    if( obj->mpContext.is() )
     {
-        uno::Reference<accessibility::XAccessibleContext> xContext(obj->mpContext.get(), uno::UNO_QUERY);
-        if (xContext.is())
-        {
-            try {
-                i = xContext->getAccessibleIndexInParent();
-            }
-            catch(const uno::Exception&) {
-                g_warning( "Exception in getAccessibleIndexInParent()" );
-            }
+        try {
+            i = obj->mpContext->getAccessibleIndexInParent();
+        }
+        catch(const uno::Exception&) {
+            g_warning( "Exception in getAccessibleIndexInParent()" );
         }
     }
     return i;
@@ -515,44 +490,40 @@ wrapper_ref_relation_set( AtkObject *atk_obj )
     AtkObjectWrapper *obj = ATK_OBJECT_WRAPPER (atk_obj);
     AtkRelationSet *pSet = atk_relation_set_new();
 
-    if (obj)
+    if( obj->mpContext.is() )
     {
-        uno::Reference<accessibility::XAccessibleContext> xContext(obj->mpContext.get(), uno::UNO_QUERY);
-        if (xContext.is())
-        {
-            try {
-                uno::Reference< accessibility::XAccessibleRelationSet > xRelationSet(
-                        xContext->getAccessibleRelationSet()
-                );
+        try {
+            uno::Reference< accessibility::XAccessibleRelationSet > xRelationSet(
+                    obj->mpContext->getAccessibleRelationSet()
+            );
+
+            sal_Int32 nRelations = xRelationSet.is() ? xRelationSet->getRelationCount() : 0;
+            for( sal_Int32 n = 0; n < nRelations; n++ )
+            {
+                accessibility::AccessibleRelation aRelation = xRelationSet->getRelation( n );
+                sal_uInt32 nTargetCount = aRelation.TargetSet.getLength();
+
+                std::vector<AtkObject*> aTargets;
 
-                sal_Int32 nRelations = xRelationSet.is() ? xRelationSet->getRelationCount() : 0;
-                for( sal_Int32 n = 0; n < nRelations; n++ )
+                for (sal_uInt32 i = 0; i < nTargetCount; ++i)
                 {
-                    accessibility::AccessibleRelation aRelation = xRelationSet->getRelation( n );
-                    sal_uInt32 nTargetCount = aRelation.TargetSet.getLength();
-
-                    std::vector<AtkObject*> aTargets;
-
-                    for (sal_uInt32 i = 0; i < nTargetCount; ++i)
-                    {
-                        uno::Reference< accessibility::XAccessible > xAccessible(
-                                aRelation.TargetSet[i], uno::UNO_QUERY );
-                        aTargets.push_back(atk_object_wrapper_ref(xAccessible));
-                    }
-
-                    AtkRelation *pRel =
-                        atk_relation_new(
-                            aTargets.data(), nTargetCount,
-                            mapRelationType( aRelation.RelationType )
-                        );
-                    atk_relation_set_add( pSet, pRel );
-                    g_object_unref( G_OBJECT( pRel ) );
+                    uno::Reference< accessibility::XAccessible > xAccessible(
+                            aRelation.TargetSet[i], uno::UNO_QUERY );
+                    aTargets.push_back(atk_object_wrapper_ref(xAccessible));
                 }
+
+                AtkRelation *pRel =
+                    atk_relation_new(
+                        aTargets.data(), nTargetCount,
+                        mapRelationType( aRelation.RelationType )
+                    );
+                atk_relation_set_add( pSet, pRel );
+                g_object_unref( G_OBJECT( pRel ) );
             }
-            catch(const uno::Exception &) {
-                g_object_unref( G_OBJECT( pSet ) );
-                pSet = nullptr;
-            }
+        }
+        catch(const uno::Exception &) {
+            g_object_unref( G_OBJECT( pSet ) );
+            pSet = nullptr;
         }
     }
 
@@ -565,43 +536,37 @@ wrapper_ref_state_set( AtkObject *atk_obj )
     AtkObjectWrapper *obj = ATK_OBJECT_WRAPPER (atk_obj);
     AtkStateSet *pSet = atk_state_set_new();
 
-    if (obj)
+    if( obj->mpContext.is() )
     {
-        uno::Reference<accessibility::XAccessibleContext> xContext(obj->mpContext.get(), uno::UNO_QUERY);
-        if (xContext.is())
-        {
-            try
+        try {
+            uno::Reference< accessibility::XAccessibleStateSet > xStateSet(
+                obj->mpContext->getAccessibleStateSet());
+
+            if( xStateSet.is() )
             {
-                uno::Reference< accessibility::XAccessibleStateSet > xStateSet(
-                    xContext->getAccessibleStateSet());
+                uno::Sequence< sal_Int16 > aStates = xStateSet->getStates();
 
-                if( xStateSet.is() )
+                for( sal_Int32 n = 0; n < aStates.getLength(); n++ )
                 {
-                    uno::Sequence< sal_Int16 > aStates = xStateSet->getStates();
-
-                    for( sal_Int32 n = 0; n < aStates.getLength(); n++ )
-                    {
-                        // ATK_STATE_LAST_DEFINED is used to check if the state
-                        // is unmapped, do not report it to Atk
-                        if ( mapAtkState( aStates[n] ) != ATK_STATE_LAST_DEFINED )
-                            atk_state_set_add_state( pSet, mapAtkState( aStates[n] ) );
-                    }
-
-                    // We need to emulate FOCUS state for menus, menu-items etc.
-                    if( atk_obj == atk_get_focus_object() )
-                        atk_state_set_add_state( pSet, ATK_STATE_FOCUSED );
+                    // ATK_STATE_LAST_DEFINED is used to check if the state
+                    // is unmapped, do not report it to Atk
+                    if ( mapAtkState( aStates[n] ) != ATK_STATE_LAST_DEFINED )
+                        atk_state_set_add_state( pSet, mapAtkState( aStates[n] ) );
+                }
+
+                // We need to emulate FOCUS state for menus, menu-items etc.
+                if( atk_obj == atk_get_focus_object() )
+                    atk_state_set_add_state( pSet, ATK_STATE_FOCUSED );
 /* FIXME - should we do this ?
-                    else
-                        atk_state_set_remove_state( pSet, ATK_STATE_FOCUSED );
+                else
+                    atk_state_set_remove_state( pSet, ATK_STATE_FOCUSED );
 */
-                }
             }
+        }
 
-            catch(const uno::Exception &)
-            {
-                g_warning( "Exception in wrapper_ref_state_set" );
-                atk_state_set_add_state( pSet, ATK_STATE_DEFUNCT );
-            }
+        catch(const uno::Exception &) {
+            g_warning( "Exception in wrapper_ref_state_set" );
+            atk_state_set_add_state( pSet, ATK_STATE_DEFUNCT );
         }
     }
     else
@@ -651,9 +616,18 @@ atk_object_wrapper_class_init (AtkObjectWrapperClass *klass)
 }
 
 static void
-atk_object_wrapper_init (AtkObjectWrapper* wrapper, AtkObjectWrapperClass*)
+atk_object_wrapper_init (AtkObjectWrapper      *wrapper,
+                         AtkObjectWrapperClass*)
 {
-    wrapper->mpContext = nullptr;
+   wrapper->mpAction = nullptr;
+   wrapper->mpComponent = nullptr;
+   wrapper->mpEditableText = nullptr;
+   wrapper->mpHypertext = nullptr;
+   wrapper->mpImage = nullptr;
+   wrapper->mpSelection = nullptr;
+   wrapper->mpTable = nullptr;
+   wrapper->mpText = nullptr;
+   wrapper->mpValue = nullptr;
 }
 
 } // extern "C"
@@ -931,6 +905,18 @@ void atk_object_wrapper_set_role(AtkObjectWrapper* wrapper, sal_Int16 role)
 void atk_object_wrapper_dispose(AtkObjectWrapper* wrapper)
 {
     wrapper->mpContext.clear();
+    wrapper->mpAction.clear();
+    wrapper->mpComponent.clear();
+    wrapper->mpEditableText.clear();
+    wrapper->mpHypertext.clear();
+    wrapper->mpImage.clear();
+    wrapper->mpSelection.clear();
+    wrapper->mpMultiLineText.clear();
+    wrapper->mpTable.clear();
+    wrapper->mpText.clear();
+    wrapper->mpTextMarkup.clear();
+    wrapper->mpTextAttributes.clear();
+    wrapper->mpValue.clear();
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/gtk/a11y/atkwrapper.hxx b/vcl/unx/gtk/a11y/atkwrapper.hxx
index 87ff3b4..e8ab83b 100644
--- a/vcl/unx/gtk/a11y/atkwrapper.hxx
+++ b/vcl/unx/gtk/a11y/atkwrapper.hxx
@@ -22,19 +22,49 @@
 
 #include <atk/atk.h>
 #include <com/sun/star/accessibility/XAccessible.hpp>
-#include <cppuhelper/weakref.hxx>
 
 extern "C" {
 
+namespace com { namespace sun { namespace star { namespace accessibility {
+    class XAccessibleAction;
+    class XAccessibleComponent;
+    class XAccessibleEditableText;
+    class XAccessibleHypertext;
+    class XAccessibleImage;
+    class XAccessibleMultiLineText;
+    class XAccessibleSelection;
+    class XAccessibleTable;
+    class XAccessibleText;
+    class XAccessibleTextMarkup;
+    class XAccessibleTextAttributes;
+    class XAccessibleValue;
+} } } }
+
 struct AtkObjectWrapper
 {
     AtkObject aParent;
 
     css::uno::Reference<css::accessibility::XAccessible> mpAccessible;
-    css::uno::WeakReference<css::accessibility::XAccessibleContext> mpContext;
+    css::uno::Reference<css::accessibility::XAccessibleContext> mpContext;
+    css::uno::Reference<css::accessibility::XAccessibleAction> mpAction;
+    css::uno::Reference<css::accessibility::XAccessibleComponent> mpComponent;
+    css::uno::Reference<css::accessibility::XAccessibleEditableText>
+        mpEditableText;
+    css::uno::Reference<css::accessibility::XAccessibleHypertext> mpHypertext;
+    css::uno::Reference<css::accessibility::XAccessibleImage> mpImage;
+    css::uno::Reference<css::accessibility::XAccessibleMultiLineText>
+        mpMultiLineText;
+    css::uno::Reference<css::accessibility::XAccessibleSelection> mpSelection;
+    css::uno::Reference<css::accessibility::XAccessibleTable> mpTable;
+    css::uno::Reference<css::accessibility::XAccessibleText> mpText;
+    css::uno::Reference<css::accessibility::XAccessibleTextMarkup> mpTextMarkup;
+    css::uno::Reference<css::accessibility::XAccessibleTextAttributes>
+        mpTextAttributes;
+    css::uno::Reference<css::accessibility::XAccessibleValue> mpValue;
 
     AtkObject *child_about_to_be_removed;
     gint       index_of_child_about_to_be_removed;
+//    OString * m_pKeyBindings
 };
 
 struct AtkObjectWrapperClass


More information about the Libreoffice-commits mailing list