Nikolay Sivov : msxml3: Implement setting attributes properties with IMXAttributes.

Alexandre Julliard julliard at winehq.org
Tue Jul 30 14:14:22 CDT 2013


Module: wine
Branch: master
Commit: ccf04d644ba27accd3463075041b0f83f7cd704c
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=ccf04d644ba27accd3463075041b0f83f7cd704c

Author: Nikolay Sivov <nsivov at codeweavers.com>
Date:   Tue Jul 30 15:08:03 2013 +0400

msxml3: Implement setting attributes properties with IMXAttributes.

---

 dlls/msxml3/mxwriter.c |   63 +++++++++++++++++++++++++++++++++++++----------
 1 files changed, 49 insertions(+), 14 deletions(-)

diff --git a/dlls/msxml3/mxwriter.c b/dlls/msxml3/mxwriter.c
index 03c1b67..dd4e629 100644
--- a/dlls/msxml3/mxwriter.c
+++ b/dlls/msxml3/mxwriter.c
@@ -1888,14 +1888,20 @@ static HRESULT WINAPI MXAttributes_clear(IMXAttributes *iface)
     return S_OK;
 }
 
+static mxattribute *get_attribute_byindex(mxattributes *attrs, int index)
+{
+    if (index < 0 || index >= attrs->length) return NULL;
+    return &attrs->attr[index];
+}
+
 static HRESULT WINAPI MXAttributes_removeAttribute(IMXAttributes *iface, int index)
 {
     mxattributes *This = impl_from_IMXAttributes( iface );
-    mxattribute *src, *dst;
+    mxattribute *dst;
 
     TRACE("(%p)->(%d)\n", This, index);
 
-    if (index < 0 || index >= This->length) return E_INVALIDARG;
+    if (!(dst = get_attribute_byindex(This, index))) return E_INVALIDARG;
 
     /* no need to remove last attribute, just make it inaccessible */
     if (index + 1 == This->length)
@@ -1904,10 +1910,7 @@ static HRESULT WINAPI MXAttributes_removeAttribute(IMXAttributes *iface, int ind
         return S_OK;
     }
 
-    dst = &This->attr[index];
-    src = &This->attr[index+1];
-
-    memmove(dst, src, (This->length-index-1)*sizeof(*dst));
+    memmove(dst, dst + 1, (This->length-index-1)*sizeof(*dst));
     This->length--;
 
     return S_OK;
@@ -1933,29 +1936,61 @@ static HRESULT WINAPI MXAttributes_setLocalName(IMXAttributes *iface, int index,
     BSTR localName)
 {
     mxattributes *This = impl_from_IMXAttributes( iface );
-    FIXME("(%p)->(%d %s): stub\n", This, index, debugstr_w(localName));
-    return E_NOTIMPL;
+    mxattribute *attr;
+
+    TRACE("(%p)->(%d %s)\n", This, index, debugstr_w(localName));
+
+    if (!(attr = get_attribute_byindex(This, index))) return E_INVALIDARG;
+
+    SysFreeString(attr->local);
+    attr->local = SysAllocString(localName);
+
+    return S_OK;
 }
 
 static HRESULT WINAPI MXAttributes_setQName(IMXAttributes *iface, int index, BSTR QName)
 {
     mxattributes *This = impl_from_IMXAttributes( iface );
-    FIXME("(%p)->(%d %s): stub\n", This, index, debugstr_w(QName));
-    return E_NOTIMPL;
+    mxattribute *attr;
+
+    TRACE("(%p)->(%d %s)\n", This, index, debugstr_w(QName));
+
+    if (!(attr = get_attribute_byindex(This, index))) return E_INVALIDARG;
+
+    SysFreeString(attr->qname);
+    attr->qname = SysAllocString(QName);
+
+    return S_OK;
 }
 
 static HRESULT WINAPI MXAttributes_setURI(IMXAttributes *iface, int index, BSTR uri)
 {
     mxattributes *This = impl_from_IMXAttributes( iface );
-    FIXME("(%p)->(%d %s): stub\n", This, index, debugstr_w(uri));
-    return E_NOTIMPL;
+    mxattribute *attr;
+
+    TRACE("(%p)->(%d %s)\n", This, index, debugstr_w(uri));
+
+    if (!(attr = get_attribute_byindex(This, index))) return E_INVALIDARG;
+
+    SysFreeString(attr->uri);
+    attr->uri = SysAllocString(uri);
+
+    return S_OK;
 }
 
 static HRESULT WINAPI MXAttributes_setValue(IMXAttributes *iface, int index, BSTR value)
 {
     mxattributes *This = impl_from_IMXAttributes( iface );
-    FIXME("(%p)->(%d %s): stub\n", This, index, debugstr_w(value));
-    return E_NOTIMPL;
+    mxattribute *attr;
+
+    TRACE("(%p)->(%d %s)\n", This, index, debugstr_w(value));
+
+    if (!(attr = get_attribute_byindex(This, index))) return E_INVALIDARG;
+
+    SysFreeString(attr->value);
+    attr->value = SysAllocString(value);
+
+    return S_OK;
 }
 
 static const IMXAttributesVtbl MXAttributesVtbl = {




More information about the wine-cvs mailing list