wine/dlls/msxml3 tests/domdoc.c nodemap.c node ...

Alexandre Julliard julliard at wine.codeweavers.com
Thu Nov 3 06:04:52 CST 2005


ChangeSet ID:	21086
CVSROOT:	/opt/cvs-commit
Module name:	wine
Changes by:	julliard at winehq.org	2005/11/03 06:04:52

Modified files:
	dlls/msxml3/tests: domdoc.c 
	dlls/msxml3    : nodemap.c nodelist.c 

Log message:
	Stefan Huehner <stefan at huehner.org>
	Add indexed access to attributes (nodemap) and childNodes
	(nodelist), with some testcases.

Patch: http://cvs.winehq.org/patch.py?id=21086

Old revision  New revision  Changes     Path
 1.4           1.5           +33 -0      wine/dlls/msxml3/tests/domdoc.c
 1.6           1.7           +53 -4      wine/dlls/msxml3/nodemap.c
 1.3           1.4           +44 -4      wine/dlls/msxml3/nodelist.c

Index: wine/dlls/msxml3/tests/domdoc.c
diff -u -p wine/dlls/msxml3/tests/domdoc.c:1.4 wine/dlls/msxml3/tests/domdoc.c:1.5
--- wine/dlls/msxml3/tests/domdoc.c:1.4	3 Nov 2005 12: 4:52 -0000
+++ wine/dlls/msxml3/tests/domdoc.c	3 Nov 2005 12: 4:52 -0000
@@ -242,6 +242,7 @@ void test_domnode( void )
     VARIANT_BOOL b;
     BSTR str;
     VARIANT var;
+    long count;
 
     r = CoCreateInstance( &CLSID_DOMDocument, NULL, 
         CLSCTX_INPROC_SERVER, &IID_IXMLDOMDocument, (LPVOID*)&doc );
@@ -325,6 +326,38 @@ void test_domnode( void )
         r = IXMLDOMNamedNodeMap_getNamedItem( map, str, &node );
         ok( r == S_OK, "getNamedItem returned wrong code\n");
         ok( node != NULL, "should be attributes\n");
+        SysFreeString( str );
+
+	/* test indexed access of attributes */
+        r = IXMLDOMNamedNodeMap_get_length( map, &count );
+        ok ( r == S_OK, "get_length wrong code\n");
+        ok ( count == 1, "get_length != 1\n");
+
+        node = NULL;
+        r = IXMLDOMNamedNodeMap_get_item( map, -1, &node);
+        ok ( r == S_FALSE, "get_item (-1) wrong code\n");
+        ok ( node == NULL, "there is no node\n");
+
+        node = NULL;
+        r = IXMLDOMNamedNodeMap_get_item( map, 1, &node);
+        ok ( r == S_FALSE, "get_item (1) wrong code\n");
+        ok ( node == NULL, "there is no attribute\n");
+
+        node = NULL;
+        r = IXMLDOMNamedNodeMap_get_item( map, 0, &node);
+        ok ( r == S_OK, "get_item (0) wrong code\n");
+        ok ( node != NULL, "should be attribute\n");
+
+        r = IXMLDOMNode_get_nodeName( node, NULL );
+        ok ( r == E_INVALIDARG, "get_nodeName (NULL) wrong code");
+
+        /* content doesn't matter here */
+        str = SysAllocString( szNonExistentFile );
+        r = IXMLDOMNode_get_nodeName( node, &str );
+        ok ( r == S_OK, "get_nodeName wrong code\n");
+        ok ( str != NULL, "str is null\n");
+        ok( !lstrcmpW( str, szdl ), "incorrect node name\n");
+        SysFreeString( str );
     }
     else
         ok( FALSE, "no map\n");
Index: wine/dlls/msxml3/nodemap.c
diff -u -p wine/dlls/msxml3/nodemap.c:1.6 wine/dlls/msxml3/nodemap.c:1.7
--- wine/dlls/msxml3/nodemap.c:1.6	3 Nov 2005 12: 4:52 -0000
+++ wine/dlls/msxml3/nodemap.c	3 Nov 2005 12: 4:52 -0000
@@ -196,16 +196,65 @@ static HRESULT WINAPI xmlnodemap_get_ite
     long index,
     IXMLDOMNode** listItem)
 {
-    FIXME("\n");
-    return E_NOTIMPL;
+    xmlnodemap *This = impl_from_IXMLDOMNamedNodeMap( iface );
+    xmlNodePtr node;
+    xmlAttrPtr curr;
+    long attrIndex;
+
+    TRACE("%p %ld\n", This, index);
+
+    *listItem = NULL;
+
+    if (index < 0)
+        return S_FALSE;
+
+    node = xmlNodePtr_from_domnode( This->node, 0 );
+    curr = node->properties;
+
+    for (attrIndex = 0; attrIndex < index; attrIndex++) {
+        if (curr->next == NULL)
+            return S_FALSE;
+        else
+            curr = curr->next;
+    }
+    
+    *listItem = create_node( (xmlNodePtr) curr );
+
+    return S_OK;
 }
 
 static HRESULT WINAPI xmlnodemap_get_length(
     IXMLDOMNamedNodeMap *iface,
     long* listLength)
 {
-    FIXME("\n");
-    return E_NOTIMPL;
+    xmlNodePtr node;
+    xmlAttrPtr first;
+    xmlAttrPtr curr;
+    long attrCount;
+
+    xmlnodemap *This = impl_from_IXMLDOMNamedNodeMap( iface );
+
+    TRACE("%p\n", This);
+
+    node = xmlNodePtr_from_domnode( This->node, 0 );
+    if ( !node )
+        return E_FAIL;
+
+    first = node->properties;
+    if (first == NULL) {
+	*listLength = 0;
+	return S_OK;
+    }
+
+    curr = first;
+    attrCount = 1;
+    while (curr->next != NULL) {
+        attrCount++;
+        curr = curr->next;
+    }
+    *listLength = attrCount;
+ 
+    return S_OK;
 }
 
 static HRESULT WINAPI xmlnodemap_getQualifiedItem(
Index: wine/dlls/msxml3/nodelist.c
diff -u -p wine/dlls/msxml3/nodelist.c:1.3 wine/dlls/msxml3/nodelist.c:1.4
--- wine/dlls/msxml3/nodelist.c:1.3	3 Nov 2005 12: 4:52 -0000
+++ wine/dlls/msxml3/nodelist.c	3 Nov 2005 12: 4:52 -0000
@@ -251,16 +251,56 @@ static HRESULT WINAPI xmlnodelist_get_it
         long index,
         IXMLDOMNode** listItem)
 {
-    FIXME("\n");
-    return E_NOTIMPL;
+    xmlnodelist *This = impl_from_IXMLDOMNodeList( iface );
+    xmlNodePtr curr;
+    long nodeIndex = 0;
+
+    TRACE("%p %ld\n", This, index);
+ 
+    *listItem = NULL;
+
+    if (index < 0)
+        return S_FALSE;
+
+    curr = This->node;
+    
+    for (nodeIndex = 0; nodeIndex < index; nodeIndex++) {
+        if (curr->next == NULL)
+            return S_FALSE;
+        else
+            curr = curr->next;
+    }
+    
+    *listItem = create_node( curr );
+
+    return S_OK;
 }
 
 static HRESULT WINAPI xmlnodelist_get_length(
         IXMLDOMNodeList* iface,
         long* listLength)
 {
-    FIXME("\n");
-    return E_NOTIMPL;
+
+    xmlNodePtr curr;
+    long nodeCount = 0;
+
+    xmlnodelist *This = impl_from_IXMLDOMNodeList( iface );
+
+    TRACE("%p\n", This);
+
+    if (This->node == NULL) {
+        *listLength = 0;
+	return S_OK;
+    }
+        
+    curr = This->node;
+    nodeCount = 1;
+    while (curr->next != NULL) {
+        nodeCount++;
+        curr = curr->next;
+    }
+   *listLength = nodeCount;
+    return S_OK;
 }
 
 static HRESULT WINAPI xmlnodelist_nextNode(



More information about the wine-cvs mailing list