Fixed bug #517761, Collection match rules not working for attributes.
[platform/core/uifw/at-spi2-atk.git] / libspi / accessible.c
index ff7e4b5..ad7084f 100644 (file)
@@ -130,6 +130,10 @@ spi_init_role_lookup_table (Accessibility_Role *role_table)
   role_table [ATK_ROLE_HEADING] =             Accessibility_ROLE_HEADING;
   role_table [ATK_ROLE_PAGE] =                Accessibility_ROLE_PAGE;
   role_table [ATK_ROLE_SECTION] =             Accessibility_ROLE_SECTION;
+  role_table [ATK_ROLE_FORM] =                Accessibility_ROLE_FORM;
+  role_table [ATK_ROLE_REDUNDANT_OBJECT] =    Accessibility_ROLE_REDUNDANT_OBJECT;
+  role_table [ATK_ROLE_LINK] =                Accessibility_ROLE_LINK;
+  role_table [ATK_ROLE_INPUT_METHOD_WINDOW] = Accessibility_ROLE_INPUT_METHOD_WINDOW;
   return TRUE;
 }
 
@@ -330,9 +334,11 @@ impl_accessibility_accessible_get_state (PortableServer_Servant servant,
   atk_set = atk_object_ref_state_set (object);
   
   set = spi_state_set_new (atk_set);
-  retval = bonobo_object_dup_ref (
+  retval = CORBA_Object_duplicate (
                                  BONOBO_OBJREF(set),
-                                 ev);
+                                 NULL);
+
+  g_object_unref (atk_set);
 
   return retval;
 }
@@ -345,7 +351,7 @@ impl_accessibility_accessible_get_relation_set (PortableServer_Servant servant,
                                                CORBA_Environment     *ev)
 {
   Accessibility_RelationSet *retval;
-  gint n_relations;
+  gint n_relations = 0;
   gint i;
   AtkRelationSet *relation_set;
   AtkObject      *object = get_atkobject_from_servant (servant);
@@ -354,7 +360,8 @@ impl_accessibility_accessible_get_relation_set (PortableServer_Servant servant,
 
   relation_set = atk_object_ref_relation_set (object);
 
-  n_relations = atk_relation_set_get_n_relations (relation_set);
+  if (relation_set)
+    n_relations = atk_relation_set_get_n_relations (relation_set);
 
   retval = CORBA_sequence_Accessibility_Relation__alloc ();
   retval->_length = retval->_maximum = n_relations;
@@ -364,10 +371,10 @@ impl_accessibility_accessible_get_relation_set (PortableServer_Servant servant,
   for (i = 0; i < n_relations; ++i)
     {
       retval->_buffer[i] =
-        bonobo_object_dup_ref (
+        CORBA_Object_duplicate (
           BONOBO_OBJREF (
             spi_relation_new (atk_relation_set_get_relation (relation_set, i))),
-         ev);
+         NULL);
     }
   
   return retval;
@@ -448,7 +455,8 @@ impl_accessibility_accessible_get_attributes (PortableServer_Servant servant,
                                               CORBA_Environment     *ev)
 {
     Accessibility_AttributeSet *retval;
-    GSList *attributes;
+    AtkAttributeSet *attributes = NULL;
+    AtkAttribute *attr = NULL;
     gint n_attributes = 0;
     gint i;
     
@@ -456,9 +464,9 @@ impl_accessibility_accessible_get_attributes (PortableServer_Servant servant,
     
     g_return_val_if_fail (object != NULL, NULL);
     attributes = atk_object_get_attributes (object);
-    
-    bonobo_return_val_if_fail (attributes != NULL, NULL, ev);
-    n_attributes = g_slist_length (attributes);
+
+    if (attributes)
+      n_attributes = g_slist_length (attributes);
     
     retval = CORBA_sequence_CORBA_string__alloc ();
     retval->_length = retval->_maximum = n_attributes;
@@ -467,8 +475,11 @@ impl_accessibility_accessible_get_attributes (PortableServer_Servant servant,
     
     for (i = 0; i < n_attributes; ++i)
     {
-       retval->_buffer[i] = CORBA_string_dup (g_slist_nth_data (attributes, i));
+       attr = g_slist_nth_data (attributes, i);
+       retval->_buffer[i] = CORBA_string_dup (g_strconcat (attr->name, ":", attr->value, NULL));
     }
+
+    atk_attribute_set_free (attributes);
     
   return retval;
 }
@@ -614,6 +625,33 @@ spi_accessible_construct (GType type, AtkObject *o)
                                     BONOBO_OBJECT (spi_value_interface_new (o)));
       }
 
+    if (ATK_IS_STREAMABLE_CONTENT (o))
+      {
+        bonobo_object_add_interface (bonobo_object (retval),
+                                    BONOBO_OBJECT (spi_streamable_interface_new (o)));
+      }
+    if (ATK_IS_DOCUMENT (o)) /* We add collection interface to document */
+      {
+
+          
+        SpiDocument *doc = spi_document_interface_new (o);
+        bonobo_object_add_interface (BONOBO_OBJECT (doc), 
+                                     BONOBO_OBJECT (spi_collection_interface_new (o)));
+
+        bonobo_object_add_interface (bonobo_object (retval),
+                                       BONOBO_OBJECT (doc));
+      }
+    if (ATK_IS_HYPERLINK_IMPL (o))
+      {
+         /* !!! the cast below is used instead of the ATK_HYPERLINK macro, since 
+          the object 'o' is not really a hyperlink, but is in fact an AtkHyperlinkImpl.
+          Ouch.  This works since it gets cast back to GObject, but it's nasty and needs
+          to be cleaned up.
+         */
+       bonobo_object_add_interface (bonobo_object (retval),
+                                    BONOBO_OBJECT (spi_hyperlink_new ((AtkHyperlink*)o)));
+      }
+
     return retval;
 }