2005-08-02 13:29:04 +02:00
|
|
|
/*
|
|
|
|
* DOM Document implementation
|
|
|
|
*
|
|
|
|
* Copyright 2005 Mike McCormack
|
|
|
|
*
|
2005-11-08 13:46:43 +01:00
|
|
|
* This library is free software; you can redistribute it and/or
|
2005-08-02 13:29:04 +02:00
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
2005-11-08 13:46:43 +01:00
|
|
|
* This library is distributed in the hope that it will be useful,
|
2005-08-02 13:29:04 +02:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2005-08-02 13:29:04 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#define COBJMACROS
|
2008-07-14 09:51:38 +02:00
|
|
|
#define NONAMELESSUNION
|
2005-08-02 13:29:04 +02:00
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
2005-12-01 18:46:42 +01:00
|
|
|
#include <assert.h>
|
2005-08-02 13:29:04 +02:00
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winuser.h"
|
2005-08-10 11:54:22 +02:00
|
|
|
#include "winnls.h"
|
2005-08-02 13:29:04 +02:00
|
|
|
#include "ole2.h"
|
2005-11-08 20:59:36 +01:00
|
|
|
#include "msxml2.h"
|
2006-02-21 12:50:59 +01:00
|
|
|
#include "wininet.h"
|
|
|
|
#include "winreg.h"
|
|
|
|
#include "shlwapi.h"
|
2008-04-26 14:55:05 +02:00
|
|
|
#include "ocidl.h"
|
2008-04-29 12:52:00 +02:00
|
|
|
#include "objsafe.h"
|
2008-09-03 02:23:10 +02:00
|
|
|
#include "dispex.h"
|
2005-08-02 13:29:04 +02:00
|
|
|
|
|
|
|
#include "wine/debug.h"
|
2008-10-11 23:59:19 +02:00
|
|
|
#include "wine/list.h"
|
2005-08-02 13:29:04 +02:00
|
|
|
|
|
|
|
#include "msxml_private.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(msxml);
|
|
|
|
|
|
|
|
#ifdef HAVE_LIBXML2
|
|
|
|
|
2010-02-05 14:25:02 +01:00
|
|
|
#include <libxml/xmlsave.h>
|
|
|
|
|
2010-02-09 15:53:28 +01:00
|
|
|
/* not defined in older versions */
|
|
|
|
#define XML_SAVE_FORMAT 1
|
|
|
|
#define XML_SAVE_NO_DECL 2
|
|
|
|
#define XML_SAVE_NO_EMPTY 4
|
|
|
|
#define XML_SAVE_NO_XHTML 8
|
|
|
|
#define XML_SAVE_XHTML 16
|
|
|
|
#define XML_SAVE_AS_XML 32
|
|
|
|
#define XML_SAVE_AS_HTML 64
|
|
|
|
|
2007-05-09 20:09:11 +02:00
|
|
|
static const WCHAR SZ_PROPERTY_SELECTION_LANGUAGE[] = {'S','e','l','e','c','t','i','o','n','L','a','n','g','u','a','g','e',0};
|
2010-07-27 15:32:51 +02:00
|
|
|
static const WCHAR SZ_PROPERTY_PROHIBIT_DTD[] = {'P','r','o','h','i','b','i','t','D','T','D',0};
|
2007-05-09 20:09:11 +02:00
|
|
|
static const WCHAR SZ_VALUE_XPATH[] = {'X','P','a','t','h',0};
|
|
|
|
static const WCHAR SZ_VALUE_XSLPATTERN[] = {'X','S','L','P','a','t','t','e','r','n',0};
|
|
|
|
|
2008-07-08 20:55:03 +02:00
|
|
|
typedef struct _domdoc
|
|
|
|
{
|
2009-10-14 20:01:42 +02:00
|
|
|
xmlnode node;
|
2008-07-08 20:55:03 +02:00
|
|
|
const struct IXMLDOMDocument2Vtbl *lpVtbl;
|
2010-06-28 19:16:43 +02:00
|
|
|
const struct IPersistStreamInitVtbl *lpvtblIPersistStreamInit;
|
2008-07-08 20:55:03 +02:00
|
|
|
const struct IObjectWithSiteVtbl *lpvtblIObjectWithSite;
|
|
|
|
const struct IObjectSafetyVtbl *lpvtblIObjectSafety;
|
2008-12-19 09:48:58 +01:00
|
|
|
const struct ISupportErrorInfoVtbl *lpvtblISupportErrorInfo;
|
2008-07-08 20:55:03 +02:00
|
|
|
LONG ref;
|
|
|
|
VARIANT_BOOL async;
|
|
|
|
VARIANT_BOOL validating;
|
|
|
|
VARIANT_BOOL resolving;
|
|
|
|
VARIANT_BOOL preserving;
|
|
|
|
BOOL bUseXPath;
|
|
|
|
IXMLDOMSchemaCollection *schema;
|
|
|
|
bsc_t *bsc;
|
|
|
|
HRESULT error;
|
|
|
|
|
|
|
|
/* IPersistStream */
|
|
|
|
IStream *stream;
|
|
|
|
|
|
|
|
/* IObjectWithSite*/
|
|
|
|
IUnknown *site;
|
|
|
|
|
|
|
|
/* IObjectSafety */
|
|
|
|
DWORD safeopt;
|
|
|
|
} domdoc;
|
|
|
|
|
2008-10-11 23:59:19 +02:00
|
|
|
/*
|
|
|
|
In native windows, the whole lifetime management of XMLDOMNodes is
|
|
|
|
managed automatically using reference counts. Wine emulates that by
|
|
|
|
maintaining a reference count to the document that is increased for
|
|
|
|
each IXMLDOMNode pointer passed out for this document. If all these
|
|
|
|
pointers are gone, the document is unreachable and gets freed, that
|
|
|
|
is, all nodes in the tree of the document get freed.
|
|
|
|
|
|
|
|
You are able to create nodes that are associated to a document (in
|
|
|
|
fact, in msxml's XMLDOM model, all nodes are associated to a document),
|
|
|
|
but not in the tree of that document, for example using the createFoo
|
|
|
|
functions from IXMLDOMDocument. These nodes do not get cleaned up
|
|
|
|
by libxml, so we have to do it ourselves.
|
|
|
|
|
|
|
|
To catch these nodes, a list of "orphan nodes" is introduced.
|
|
|
|
It contains pointers to all roots of node trees that are
|
|
|
|
associated with the document without being part of the document
|
|
|
|
tree. All nodes with parent==NULL (except for the document root nodes)
|
|
|
|
should be in the orphan node list of their document. All orphan nodes
|
|
|
|
get freed together with the document itself.
|
|
|
|
*/
|
|
|
|
|
2008-10-11 23:59:12 +02:00
|
|
|
typedef struct _xmldoc_priv {
|
|
|
|
LONG refs;
|
2008-10-11 23:59:19 +02:00
|
|
|
struct list orphans;
|
2008-10-11 23:59:12 +02:00
|
|
|
} xmldoc_priv;
|
|
|
|
|
2008-10-11 23:59:19 +02:00
|
|
|
typedef struct _orphan_entry {
|
|
|
|
struct list entry;
|
|
|
|
xmlNode * node;
|
|
|
|
} orphan_entry;
|
|
|
|
|
2008-10-11 23:59:12 +02:00
|
|
|
static inline xmldoc_priv * priv_from_xmlDocPtr(xmlDocPtr doc)
|
|
|
|
{
|
|
|
|
return doc->_private;
|
|
|
|
}
|
|
|
|
|
|
|
|
static xmldoc_priv * create_priv(void)
|
|
|
|
{
|
|
|
|
xmldoc_priv *priv;
|
2010-02-03 20:47:53 +01:00
|
|
|
priv = heap_alloc( sizeof (*priv) );
|
2008-10-11 23:59:12 +02:00
|
|
|
|
|
|
|
if(priv)
|
2008-10-11 23:59:19 +02:00
|
|
|
{
|
2008-10-11 23:59:12 +02:00
|
|
|
priv->refs = 0;
|
2008-10-11 23:59:19 +02:00
|
|
|
list_init( &priv->orphans );
|
|
|
|
}
|
2008-10-11 23:59:12 +02:00
|
|
|
|
|
|
|
return priv;
|
|
|
|
}
|
|
|
|
|
2010-06-28 10:17:56 +02:00
|
|
|
/* links a "<?xml" node as a first child */
|
|
|
|
void xmldoc_link_xmldecl(xmlDocPtr doc, xmlNodePtr node)
|
|
|
|
{
|
|
|
|
assert(doc != NULL);
|
|
|
|
if (doc->standalone != -1) xmlAddPrevSibling( doc->children, node );
|
|
|
|
}
|
|
|
|
|
|
|
|
/* unlinks a first "<?xml" child if it was created */
|
|
|
|
xmlNodePtr xmldoc_unlink_xmldecl(xmlDocPtr doc)
|
|
|
|
{
|
|
|
|
xmlNodePtr node;
|
|
|
|
|
|
|
|
assert(doc != NULL);
|
|
|
|
|
|
|
|
if (doc->standalone != -1)
|
|
|
|
{
|
|
|
|
node = doc->children;
|
|
|
|
xmlUnlinkNode( node );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
node = NULL;
|
|
|
|
|
|
|
|
return node;
|
|
|
|
}
|
|
|
|
|
2010-06-20 11:47:39 +02:00
|
|
|
static xmlDocPtr doparse( char *ptr, int len, const char *encoding )
|
2008-07-08 20:55:10 +02:00
|
|
|
{
|
2010-06-28 10:17:56 +02:00
|
|
|
xmlDocPtr doc;
|
|
|
|
|
2008-07-08 20:55:10 +02:00
|
|
|
#ifdef HAVE_XMLREADMEMORY
|
|
|
|
/*
|
|
|
|
* use xmlReadMemory if possible so we can suppress
|
|
|
|
* writing errors to stderr
|
|
|
|
*/
|
2010-06-28 10:17:56 +02:00
|
|
|
doc = xmlReadMemory( ptr, len, NULL, encoding,
|
|
|
|
XML_PARSE_NOERROR | XML_PARSE_NOWARNING | XML_PARSE_NOBLANKS );
|
2008-07-08 20:55:10 +02:00
|
|
|
#else
|
2010-06-28 10:17:56 +02:00
|
|
|
doc = xmlParseMemory( ptr, len );
|
2008-07-08 20:55:10 +02:00
|
|
|
#endif
|
2010-06-28 10:17:56 +02:00
|
|
|
|
|
|
|
/* create first child as a <?xml...?> */
|
|
|
|
if (doc && doc->standalone != -1)
|
|
|
|
{
|
|
|
|
xmlNodePtr node;
|
|
|
|
char buff[30];
|
|
|
|
xmlChar *xmlbuff = (xmlChar*)buff;
|
|
|
|
|
|
|
|
node = xmlNewDocPI( doc, (xmlChar*)"xml", NULL );
|
|
|
|
|
|
|
|
/* version attribute can't be omitted */
|
|
|
|
sprintf(buff, "version=\"%s\"", doc->version ? (char*)doc->version : "1.0");
|
|
|
|
xmlNodeAddContent( node, xmlbuff );
|
|
|
|
|
|
|
|
if (doc->encoding)
|
|
|
|
{
|
|
|
|
sprintf(buff, " encoding=\"%s\"", doc->encoding);
|
|
|
|
xmlNodeAddContent( node, xmlbuff );
|
|
|
|
}
|
|
|
|
|
|
|
|
if (doc->standalone != -2)
|
|
|
|
{
|
|
|
|
sprintf(buff, " standalone=\"%s\"", doc->standalone == 0 ? "no" : "yes");
|
|
|
|
xmlNodeAddContent( node, xmlbuff );
|
|
|
|
}
|
|
|
|
|
|
|
|
xmldoc_link_xmldecl( doc, node );
|
|
|
|
}
|
|
|
|
|
|
|
|
return doc;
|
2008-07-08 20:55:10 +02:00
|
|
|
}
|
|
|
|
|
2005-11-18 16:05:26 +01:00
|
|
|
LONG xmldoc_add_ref(xmlDocPtr doc)
|
|
|
|
{
|
2008-10-11 23:59:12 +02:00
|
|
|
LONG ref = InterlockedIncrement(&priv_from_xmlDocPtr(doc)->refs);
|
2010-06-21 11:36:13 +02:00
|
|
|
TRACE("(%p)->(%d)\n", doc, ref);
|
2005-11-18 16:05:26 +01:00
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
LONG xmldoc_release(xmlDocPtr doc)
|
|
|
|
{
|
2008-10-11 23:59:12 +02:00
|
|
|
xmldoc_priv *priv = priv_from_xmlDocPtr(doc);
|
|
|
|
LONG ref = InterlockedDecrement(&priv->refs);
|
2010-06-21 11:36:13 +02:00
|
|
|
TRACE("(%p)->(%d)\n", doc, ref);
|
2005-11-18 16:05:26 +01:00
|
|
|
if(ref == 0)
|
|
|
|
{
|
2008-10-11 23:59:19 +02:00
|
|
|
orphan_entry *orphan, *orphan2;
|
2005-11-18 16:05:26 +01:00
|
|
|
TRACE("freeing docptr %p\n", doc);
|
2008-10-11 23:59:19 +02:00
|
|
|
|
|
|
|
LIST_FOR_EACH_ENTRY_SAFE( orphan, orphan2, &priv->orphans, orphan_entry, entry )
|
|
|
|
{
|
|
|
|
xmlFreeNode( orphan->node );
|
2010-02-03 20:47:53 +01:00
|
|
|
heap_free( orphan );
|
2008-10-11 23:59:19 +02:00
|
|
|
}
|
2010-02-03 20:47:53 +01:00
|
|
|
heap_free(doc->_private);
|
2008-10-11 23:59:12 +02:00
|
|
|
|
2005-11-18 16:05:26 +01:00
|
|
|
xmlFreeDoc(doc);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
2008-10-11 23:59:19 +02:00
|
|
|
HRESULT xmldoc_add_orphan(xmlDocPtr doc, xmlNodePtr node)
|
|
|
|
{
|
|
|
|
xmldoc_priv *priv = priv_from_xmlDocPtr(doc);
|
|
|
|
orphan_entry *entry;
|
|
|
|
|
2010-02-03 20:47:53 +01:00
|
|
|
entry = heap_alloc( sizeof (*entry) );
|
2008-10-11 23:59:19 +02:00
|
|
|
if(!entry)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
entry->node = node;
|
|
|
|
list_add_head( &priv->orphans, &entry->entry );
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT xmldoc_remove_orphan(xmlDocPtr doc, xmlNodePtr node)
|
|
|
|
{
|
|
|
|
xmldoc_priv *priv = priv_from_xmlDocPtr(doc);
|
|
|
|
orphan_entry *entry, *entry2;
|
|
|
|
|
|
|
|
LIST_FOR_EACH_ENTRY_SAFE( entry, entry2, &priv->orphans, orphan_entry, entry )
|
|
|
|
{
|
|
|
|
if( entry->node == node )
|
|
|
|
{
|
|
|
|
list_remove( &entry->entry );
|
2010-02-03 20:47:53 +01:00
|
|
|
heap_free( entry );
|
2008-10-11 23:59:19 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_FALSE;
|
|
|
|
}
|
|
|
|
|
2009-08-21 13:25:28 +02:00
|
|
|
static HRESULT attach_xmldoc( xmlnode *node, xmlDocPtr xml )
|
2008-11-29 10:51:58 +01:00
|
|
|
{
|
2009-08-21 13:25:28 +02:00
|
|
|
if(node->node)
|
|
|
|
xmldoc_release(node->node->doc);
|
2008-11-29 10:51:58 +01:00
|
|
|
|
2009-08-21 13:25:28 +02:00
|
|
|
node->node = (xmlNodePtr) xml;
|
|
|
|
if(node->node)
|
|
|
|
xmldoc_add_ref(node->node->doc);
|
2008-11-29 10:51:58 +01:00
|
|
|
|
2008-11-29 10:52:24 +01:00
|
|
|
return S_OK;
|
2008-11-29 10:51:58 +01:00
|
|
|
}
|
|
|
|
|
2007-02-26 13:49:12 +01:00
|
|
|
static inline domdoc *impl_from_IXMLDOMDocument2( IXMLDOMDocument2 *iface )
|
2005-08-02 13:29:04 +02:00
|
|
|
{
|
|
|
|
return (domdoc *)((char*)iface - FIELD_OFFSET(domdoc, lpVtbl));
|
|
|
|
}
|
|
|
|
|
2005-08-18 12:48:13 +02:00
|
|
|
static inline xmlDocPtr get_doc( domdoc *This )
|
|
|
|
{
|
2009-10-14 20:01:42 +02:00
|
|
|
return (xmlDocPtr)This->node.node;
|
2005-08-18 12:48:13 +02:00
|
|
|
}
|
|
|
|
|
2010-06-28 19:16:43 +02:00
|
|
|
static inline domdoc *impl_from_IPersistStreamInit(IPersistStreamInit *iface)
|
2007-12-09 23:31:38 +01:00
|
|
|
{
|
2010-06-28 19:16:43 +02:00
|
|
|
return (domdoc *)((char*)iface - FIELD_OFFSET(domdoc, lpvtblIPersistStreamInit));
|
2007-12-09 23:31:38 +01:00
|
|
|
}
|
|
|
|
|
2008-04-26 14:55:05 +02:00
|
|
|
static inline domdoc *impl_from_IObjectWithSite(IObjectWithSite *iface)
|
|
|
|
{
|
|
|
|
return (domdoc *)((char*)iface - FIELD_OFFSET(domdoc, lpvtblIObjectWithSite));
|
|
|
|
}
|
|
|
|
|
2008-04-29 12:52:00 +02:00
|
|
|
static inline domdoc *impl_from_IObjectSafety(IObjectSafety *iface)
|
|
|
|
{
|
|
|
|
return (domdoc *)((char*)iface - FIELD_OFFSET(domdoc, lpvtblIObjectSafety));
|
|
|
|
}
|
|
|
|
|
2008-12-19 09:48:58 +01:00
|
|
|
static inline domdoc *impl_from_ISupportErrorInfo(ISupportErrorInfo *iface)
|
|
|
|
{
|
|
|
|
return (domdoc *)((char*)iface - FIELD_OFFSET(domdoc, lpvtblISupportErrorInfo));
|
|
|
|
}
|
2008-04-29 12:52:00 +02:00
|
|
|
|
2007-12-09 23:31:38 +01:00
|
|
|
/************************************************************************
|
2010-06-28 19:34:00 +02:00
|
|
|
* domdoc implementation of IPersistStream.
|
2007-12-09 23:31:38 +01:00
|
|
|
*/
|
2010-06-28 19:34:00 +02:00
|
|
|
static HRESULT WINAPI domdoc_IPersistStreamInit_QueryInterface(
|
|
|
|
IPersistStreamInit *iface, REFIID riid, void **ppvObj)
|
2007-12-09 23:31:38 +01:00
|
|
|
{
|
2010-06-28 19:16:43 +02:00
|
|
|
domdoc *this = impl_from_IPersistStreamInit(iface);
|
2010-06-28 19:34:00 +02:00
|
|
|
return IXMLDOMDocument2_QueryInterface((IXMLDOMDocument2 *)this, riid, ppvObj);
|
2007-12-09 23:31:38 +01:00
|
|
|
}
|
|
|
|
|
2010-06-28 19:34:00 +02:00
|
|
|
static ULONG WINAPI domdoc_IPersistStreamInit_AddRef(
|
2010-06-28 19:16:43 +02:00
|
|
|
IPersistStreamInit *iface)
|
2007-12-09 23:31:38 +01:00
|
|
|
{
|
2010-06-28 19:16:43 +02:00
|
|
|
domdoc *this = impl_from_IPersistStreamInit(iface);
|
2010-06-28 19:34:00 +02:00
|
|
|
return IXMLDOMDocument2_AddRef((IXMLDOMDocument2 *)this);
|
2007-12-09 23:31:38 +01:00
|
|
|
}
|
|
|
|
|
2010-06-28 19:34:00 +02:00
|
|
|
static ULONG WINAPI domdoc_IPersistStreamInit_Release(
|
2010-06-28 19:16:43 +02:00
|
|
|
IPersistStreamInit *iface)
|
2007-12-09 23:31:38 +01:00
|
|
|
{
|
2010-06-28 19:16:43 +02:00
|
|
|
domdoc *this = impl_from_IPersistStreamInit(iface);
|
2010-06-28 19:34:00 +02:00
|
|
|
return IXMLDOMDocument2_Release((IXMLDOMDocument2 *)this);
|
2007-12-09 23:31:38 +01:00
|
|
|
}
|
|
|
|
|
2010-06-28 19:34:00 +02:00
|
|
|
static HRESULT WINAPI domdoc_IPersistStreamInit_GetClassID(
|
2010-06-28 19:16:43 +02:00
|
|
|
IPersistStreamInit *iface, CLSID *classid)
|
2007-12-09 23:31:38 +01:00
|
|
|
{
|
2008-01-14 05:35:02 +01:00
|
|
|
TRACE("(%p,%p): stub!\n", iface, classid);
|
|
|
|
|
|
|
|
if(!classid)
|
|
|
|
return E_POINTER;
|
|
|
|
|
|
|
|
*classid = CLSID_DOMDocument2;
|
|
|
|
|
|
|
|
return S_OK;
|
2007-12-09 23:31:38 +01:00
|
|
|
}
|
|
|
|
|
2010-06-28 19:34:00 +02:00
|
|
|
static HRESULT WINAPI domdoc_IPersistStreamInit_IsDirty(
|
2010-06-28 19:16:43 +02:00
|
|
|
IPersistStreamInit *iface)
|
2007-12-09 23:31:38 +01:00
|
|
|
{
|
2010-06-28 19:16:43 +02:00
|
|
|
domdoc *This = impl_from_IPersistStreamInit(iface);
|
2010-02-17 07:40:40 +01:00
|
|
|
FIXME("(%p): stub!\n", This);
|
2007-12-09 23:31:38 +01:00
|
|
|
return S_FALSE;
|
|
|
|
}
|
|
|
|
|
2010-06-28 19:34:00 +02:00
|
|
|
static HRESULT WINAPI domdoc_IPersistStreamInit_Load(
|
2010-06-28 19:16:43 +02:00
|
|
|
IPersistStreamInit *iface, LPSTREAM pStm)
|
2007-12-09 23:31:38 +01:00
|
|
|
{
|
2010-06-28 19:16:43 +02:00
|
|
|
domdoc *This = impl_from_IPersistStreamInit(iface);
|
2007-12-09 23:31:38 +01:00
|
|
|
HRESULT hr;
|
|
|
|
HGLOBAL hglobal;
|
|
|
|
DWORD read, written, len;
|
|
|
|
BYTE buf[4096];
|
|
|
|
char *ptr;
|
|
|
|
xmlDocPtr xmldoc = NULL;
|
|
|
|
|
2010-02-17 07:40:40 +01:00
|
|
|
TRACE("(%p)->(%p)\n", This, pStm);
|
2007-12-09 23:31:38 +01:00
|
|
|
|
|
|
|
if (!pStm)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
hr = CreateStreamOnHGlobal(NULL, TRUE, &This->stream);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
IStream_Read(pStm, buf, sizeof(buf), &read);
|
|
|
|
hr = IStream_Write(This->stream, buf, read, &written);
|
|
|
|
} while(SUCCEEDED(hr) && written != 0 && read != 0);
|
|
|
|
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
ERR("Failed to copy stream\n");
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = GetHGlobalFromStream(This->stream, &hglobal);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
len = GlobalSize(hglobal);
|
|
|
|
ptr = GlobalLock(hglobal);
|
|
|
|
if (len != 0)
|
2010-06-28 10:17:56 +02:00
|
|
|
xmldoc = doparse(ptr, len, NULL);
|
2007-12-09 23:31:38 +01:00
|
|
|
GlobalUnlock(hglobal);
|
|
|
|
|
|
|
|
if (!xmldoc)
|
|
|
|
{
|
|
|
|
ERR("Failed to parse xml\n");
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
2008-10-14 23:51:51 +02:00
|
|
|
xmldoc->_private = create_priv();
|
2007-12-09 23:31:38 +01:00
|
|
|
|
2009-10-14 20:01:42 +02:00
|
|
|
return attach_xmldoc( &This->node, xmldoc );
|
2007-12-09 23:31:38 +01:00
|
|
|
}
|
|
|
|
|
2010-06-28 19:34:00 +02:00
|
|
|
static HRESULT WINAPI domdoc_IPersistStreamInit_Save(
|
2010-07-18 15:18:13 +02:00
|
|
|
IPersistStreamInit *iface, IStream *stream, BOOL clr_dirty)
|
2007-12-09 23:31:38 +01:00
|
|
|
{
|
2010-06-28 19:16:43 +02:00
|
|
|
domdoc *This = impl_from_IPersistStreamInit(iface);
|
2009-01-22 10:21:45 +01:00
|
|
|
BSTR xmlString;
|
2010-07-18 15:18:13 +02:00
|
|
|
HRESULT hr;
|
2009-01-22 10:21:45 +01:00
|
|
|
|
2010-07-18 15:18:13 +02:00
|
|
|
TRACE("(%p)->(%p %d)\n", This, stream, clr_dirty);
|
2009-01-22 10:21:45 +01:00
|
|
|
|
2009-10-14 20:01:42 +02:00
|
|
|
hr = IXMLDOMNode_get_xml( IXMLDOMNode_from_impl(&This->node), &xmlString );
|
2009-01-22 10:21:45 +01:00
|
|
|
if(hr == S_OK)
|
|
|
|
{
|
2010-07-18 15:18:13 +02:00
|
|
|
DWORD len = SysStringLen(xmlString) * sizeof(WCHAR);
|
2009-01-22 10:21:45 +01:00
|
|
|
|
2010-07-18 15:18:13 +02:00
|
|
|
hr = IStream_Write( stream, xmlString, len, NULL );
|
2009-01-22 10:21:45 +01:00
|
|
|
SysFreeString(xmlString);
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("ret 0x%08x\n", hr);
|
|
|
|
|
|
|
|
return hr;
|
2007-12-09 23:31:38 +01:00
|
|
|
}
|
|
|
|
|
2010-06-28 19:34:00 +02:00
|
|
|
static HRESULT WINAPI domdoc_IPersistStreamInit_GetSizeMax(
|
2010-06-28 19:16:43 +02:00
|
|
|
IPersistStreamInit *iface, ULARGE_INTEGER *pcbSize)
|
2007-12-09 23:31:38 +01:00
|
|
|
{
|
2010-06-28 19:16:43 +02:00
|
|
|
domdoc *This = impl_from_IPersistStreamInit(iface);
|
2010-02-17 07:40:40 +01:00
|
|
|
TRACE("(%p)->(%p): stub!\n", This, pcbSize);
|
2007-12-09 23:31:38 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2010-06-28 19:34:00 +02:00
|
|
|
static HRESULT WINAPI domdoc_IPersistStreamInit_InitNew(
|
2010-06-28 19:16:43 +02:00
|
|
|
IPersistStreamInit *iface)
|
2007-12-09 23:31:38 +01:00
|
|
|
{
|
2010-06-28 19:16:43 +02:00
|
|
|
domdoc *This = impl_from_IPersistStreamInit(iface);
|
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IPersistStreamInitVtbl xmldoc_IPersistStreamInit_VTable =
|
|
|
|
{
|
2010-06-28 19:34:00 +02:00
|
|
|
domdoc_IPersistStreamInit_QueryInterface,
|
|
|
|
domdoc_IPersistStreamInit_AddRef,
|
|
|
|
domdoc_IPersistStreamInit_Release,
|
|
|
|
domdoc_IPersistStreamInit_GetClassID,
|
|
|
|
domdoc_IPersistStreamInit_IsDirty,
|
|
|
|
domdoc_IPersistStreamInit_Load,
|
|
|
|
domdoc_IPersistStreamInit_Save,
|
|
|
|
domdoc_IPersistStreamInit_GetSizeMax,
|
|
|
|
domdoc_IPersistStreamInit_InitNew
|
2007-12-09 23:31:38 +01:00
|
|
|
};
|
|
|
|
|
2008-12-19 09:48:58 +01:00
|
|
|
/* ISupportErrorInfo interface */
|
|
|
|
static HRESULT WINAPI support_error_QueryInterface(
|
|
|
|
ISupportErrorInfo *iface,
|
|
|
|
REFIID riid, void** ppvObj )
|
|
|
|
{
|
|
|
|
domdoc *This = impl_from_ISupportErrorInfo(iface);
|
2010-06-28 19:34:00 +02:00
|
|
|
return IXMLDOMDocument2_QueryInterface((IXMLDOMDocument2 *)This, riid, ppvObj);
|
2008-12-19 09:48:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI support_error_AddRef(
|
|
|
|
ISupportErrorInfo *iface )
|
|
|
|
{
|
|
|
|
domdoc *This = impl_from_ISupportErrorInfo(iface);
|
2010-06-28 19:34:00 +02:00
|
|
|
return IXMLDOMDocument2_AddRef((IXMLDOMDocument2 *)This);
|
2008-12-19 09:48:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI support_error_Release(
|
|
|
|
ISupportErrorInfo *iface )
|
|
|
|
{
|
|
|
|
domdoc *This = impl_from_ISupportErrorInfo(iface);
|
2010-06-28 19:34:00 +02:00
|
|
|
return IXMLDOMDocument2_Release((IXMLDOMDocument2 *)This);
|
2008-12-19 09:48:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI support_error_InterfaceSupportsErrorInfo(
|
|
|
|
ISupportErrorInfo *iface,
|
|
|
|
REFIID riid )
|
|
|
|
{
|
|
|
|
FIXME("(%p)->(%s)\n", iface, debugstr_guid(riid));
|
|
|
|
return S_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct ISupportErrorInfoVtbl support_error_vtbl =
|
|
|
|
{
|
|
|
|
support_error_QueryInterface,
|
|
|
|
support_error_AddRef,
|
|
|
|
support_error_Release,
|
|
|
|
support_error_InterfaceSupportsErrorInfo
|
|
|
|
};
|
|
|
|
|
|
|
|
/* IXMLDOMDocument2 interface */
|
2007-02-26 13:49:12 +01:00
|
|
|
static HRESULT WINAPI domdoc_QueryInterface( IXMLDOMDocument2 *iface, REFIID riid, void** ppvObject )
|
2005-08-02 13:29:04 +02:00
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2005-08-02 13:29:04 +02:00
|
|
|
|
2010-02-17 07:40:40 +01:00
|
|
|
TRACE("(%p)->(%s %p)\n", This, debugstr_guid( riid ), ppvObject );
|
2005-08-02 13:29:04 +02:00
|
|
|
|
2008-01-09 02:26:51 +01:00
|
|
|
*ppvObject = NULL;
|
|
|
|
|
2007-02-26 13:49:12 +01:00
|
|
|
if ( IsEqualGUID( riid, &IID_IUnknown ) ||
|
2008-01-22 03:19:13 +01:00
|
|
|
IsEqualGUID( riid, &IID_IDispatch ) ||
|
2007-02-26 13:49:12 +01:00
|
|
|
IsEqualGUID( riid, &IID_IXMLDOMDocument ) ||
|
|
|
|
IsEqualGUID( riid, &IID_IXMLDOMDocument2 ) )
|
2005-08-02 13:29:04 +02:00
|
|
|
{
|
|
|
|
*ppvObject = iface;
|
|
|
|
}
|
2008-01-22 03:19:13 +01:00
|
|
|
else if ( IsEqualGUID( riid, &IID_IXMLDOMNode ) )
|
2005-12-01 18:46:42 +01:00
|
|
|
{
|
2009-10-14 20:01:42 +02:00
|
|
|
*ppvObject = IXMLDOMNode_from_impl(&This->node);
|
2005-12-01 18:46:42 +01:00
|
|
|
}
|
2010-06-28 19:16:43 +02:00
|
|
|
else if (IsEqualGUID(&IID_IPersistStream, riid) ||
|
|
|
|
IsEqualGUID(&IID_IPersistStreamInit, riid))
|
2007-12-09 23:31:38 +01:00
|
|
|
{
|
2010-06-28 19:16:43 +02:00
|
|
|
*ppvObject = &(This->lpvtblIPersistStreamInit);
|
2007-12-09 23:31:38 +01:00
|
|
|
}
|
2008-04-26 14:55:05 +02:00
|
|
|
else if (IsEqualGUID(&IID_IObjectWithSite, riid))
|
|
|
|
{
|
2009-01-26 11:01:02 +01:00
|
|
|
*ppvObject = &(This->lpvtblIObjectWithSite);
|
2008-04-26 14:55:05 +02:00
|
|
|
}
|
2010-02-19 11:46:16 +01:00
|
|
|
else if (IsEqualGUID(&IID_IObjectSafety, riid))
|
|
|
|
{
|
|
|
|
*ppvObject = &(This->lpvtblIObjectSafety);
|
|
|
|
}
|
2008-12-19 09:48:58 +01:00
|
|
|
else if( IsEqualGUID( riid, &IID_ISupportErrorInfo ))
|
|
|
|
{
|
|
|
|
*ppvObject = &This->lpvtblISupportErrorInfo;
|
|
|
|
}
|
2009-10-14 20:01:42 +02:00
|
|
|
else if(dispex_query_interface(&This->node.dispex, riid, ppvObject))
|
2008-09-03 02:23:10 +02:00
|
|
|
{
|
|
|
|
return *ppvObject ? S_OK : E_NOINTERFACE;
|
|
|
|
}
|
2008-01-09 02:26:51 +01:00
|
|
|
else if(IsEqualGUID(&IID_IRunnableObject, riid))
|
|
|
|
{
|
|
|
|
TRACE("IID_IRunnableObject not supported returning NULL\n");
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
2005-08-02 13:29:04 +02:00
|
|
|
else
|
2006-01-27 19:22:56 +01:00
|
|
|
{
|
|
|
|
FIXME("interface %s not implemented\n", debugstr_guid(riid));
|
2005-08-02 13:29:04 +02:00
|
|
|
return E_NOINTERFACE;
|
2006-01-27 19:22:56 +01:00
|
|
|
}
|
2005-08-02 13:29:04 +02:00
|
|
|
|
2009-08-21 13:25:28 +02:00
|
|
|
IUnknown_AddRef((IUnknown*)*ppvObject);
|
2005-08-02 13:29:04 +02:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static ULONG WINAPI domdoc_AddRef(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface )
|
2005-08-02 13:29:04 +02:00
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2005-08-02 13:29:04 +02:00
|
|
|
TRACE("%p\n", This );
|
|
|
|
return InterlockedIncrement( &This->ref );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static ULONG WINAPI domdoc_Release(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface )
|
2005-08-02 13:29:04 +02:00
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2005-08-02 13:29:04 +02:00
|
|
|
LONG ref;
|
|
|
|
|
|
|
|
TRACE("%p\n", This );
|
|
|
|
|
|
|
|
ref = InterlockedDecrement( &This->ref );
|
|
|
|
if ( ref == 0 )
|
|
|
|
{
|
2008-07-27 19:54:38 +02:00
|
|
|
if(This->bsc)
|
|
|
|
detach_bsc(This->bsc);
|
2008-07-08 20:55:03 +02:00
|
|
|
|
2008-04-26 14:55:05 +02:00
|
|
|
if (This->site)
|
|
|
|
IUnknown_Release( This->site );
|
2009-10-14 20:01:42 +02:00
|
|
|
destroy_xmlnode(&This->node);
|
2007-02-27 16:11:13 +01:00
|
|
|
if(This->schema) IXMLDOMSchemaCollection_Release( This->schema );
|
2007-12-09 23:31:38 +01:00
|
|
|
if (This->stream) IStream_Release(This->stream);
|
2005-08-02 13:29:04 +02:00
|
|
|
HeapFree( GetProcessHeap(), 0, This );
|
|
|
|
}
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
2007-02-26 13:49:12 +01:00
|
|
|
static HRESULT WINAPI domdoc_GetTypeInfoCount( IXMLDOMDocument2 *iface, UINT* pctinfo )
|
2005-08-02 13:29:04 +02:00
|
|
|
{
|
2008-02-18 20:28:54 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, pctinfo);
|
|
|
|
|
|
|
|
*pctinfo = 1;
|
|
|
|
|
|
|
|
return S_OK;
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_GetTypeInfo(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
UINT iTInfo, LCID lcid, ITypeInfo** ppTInfo )
|
|
|
|
{
|
2008-02-18 20:28:54 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
|
|
|
|
|
|
|
|
hr = get_typeinfo(IXMLDOMDocument2_tid, ppTInfo);
|
|
|
|
|
|
|
|
return hr;
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_GetIDsOfNames(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
REFIID riid,
|
|
|
|
LPOLESTR* rgszNames,
|
|
|
|
UINT cNames,
|
|
|
|
LCID lcid,
|
|
|
|
DISPID* rgDispId)
|
|
|
|
{
|
2008-02-18 20:28:54 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
|
|
|
ITypeInfo *typeinfo;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
|
|
|
|
lcid, rgDispId);
|
|
|
|
|
|
|
|
if(!rgszNames || cNames == 0 || !rgDispId)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
hr = get_typeinfo(IXMLDOMDocument2_tid, &typeinfo);
|
|
|
|
if(SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
hr = ITypeInfo_GetIDsOfNames(typeinfo, rgszNames, cNames, rgDispId);
|
|
|
|
ITypeInfo_Release(typeinfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
return hr;
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_Invoke(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
DISPID dispIdMember,
|
|
|
|
REFIID riid,
|
|
|
|
LCID lcid,
|
|
|
|
WORD wFlags,
|
|
|
|
DISPPARAMS* pDispParams,
|
|
|
|
VARIANT* pVarResult,
|
|
|
|
EXCEPINFO* pExcepInfo,
|
|
|
|
UINT* puArgErr)
|
|
|
|
{
|
2008-02-18 20:28:54 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
|
|
|
ITypeInfo *typeinfo;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
|
|
|
|
lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
|
|
|
|
|
|
|
|
hr = get_typeinfo(IXMLDOMDocument2_tid, &typeinfo);
|
|
|
|
if(SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
hr = ITypeInfo_Invoke(typeinfo, &(This->lpVtbl), dispIdMember, wFlags, pDispParams,
|
|
|
|
pVarResult, pExcepInfo, puArgErr);
|
|
|
|
ITypeInfo_Release(typeinfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
return hr;
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_get_nodeName(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
BSTR* name )
|
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2009-10-14 20:01:42 +02:00
|
|
|
return IXMLDOMNode_get_nodeName( IXMLDOMNode_from_impl(&This->node), name );
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_get_nodeValue(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
VARIANT* value )
|
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2009-10-14 20:01:42 +02:00
|
|
|
return IXMLDOMNode_get_nodeValue( IXMLDOMNode_from_impl(&This->node), value );
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_put_nodeValue(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
VARIANT value)
|
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2009-10-14 20:01:42 +02:00
|
|
|
return IXMLDOMNode_put_nodeValue( IXMLDOMNode_from_impl(&This->node), value );
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_get_nodeType(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
DOMNodeType* type )
|
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2009-10-14 20:01:42 +02:00
|
|
|
return IXMLDOMNode_get_nodeType( IXMLDOMNode_from_impl(&This->node), type );
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_get_parentNode(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
IXMLDOMNode** parent )
|
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2009-10-14 20:01:42 +02:00
|
|
|
return IXMLDOMNode_get_parentNode( IXMLDOMNode_from_impl(&This->node), parent );
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_get_childNodes(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
IXMLDOMNodeList** childList )
|
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2009-10-14 20:01:42 +02:00
|
|
|
return IXMLDOMNode_get_childNodes( IXMLDOMNode_from_impl(&This->node), childList );
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_get_firstChild(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
IXMLDOMNode** firstChild )
|
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2009-10-14 20:01:42 +02:00
|
|
|
return IXMLDOMNode_get_firstChild( IXMLDOMNode_from_impl(&This->node), firstChild );
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_get_lastChild(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
IXMLDOMNode** lastChild )
|
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2009-10-14 20:01:42 +02:00
|
|
|
return IXMLDOMNode_get_lastChild( IXMLDOMNode_from_impl(&This->node), lastChild );
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_get_previousSibling(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
IXMLDOMNode** previousSibling )
|
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2009-10-14 20:01:42 +02:00
|
|
|
return IXMLDOMNode_get_previousSibling( IXMLDOMNode_from_impl(&This->node), previousSibling );
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_get_nextSibling(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
IXMLDOMNode** nextSibling )
|
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2009-10-14 20:01:42 +02:00
|
|
|
return IXMLDOMNode_get_nextSibling( IXMLDOMNode_from_impl(&This->node), nextSibling );
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_get_attributes(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
IXMLDOMNamedNodeMap** attributeMap )
|
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2009-10-14 20:01:42 +02:00
|
|
|
return IXMLDOMNode_get_attributes( IXMLDOMNode_from_impl(&This->node), attributeMap );
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_insertBefore(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
IXMLDOMNode* newChild,
|
|
|
|
VARIANT refChild,
|
|
|
|
IXMLDOMNode** outNewChild )
|
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2009-10-14 20:01:42 +02:00
|
|
|
return IXMLDOMNode_insertBefore( IXMLDOMNode_from_impl(&This->node), newChild, refChild, outNewChild );
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_replaceChild(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
IXMLDOMNode* newChild,
|
|
|
|
IXMLDOMNode* oldChild,
|
|
|
|
IXMLDOMNode** outOldChild)
|
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2009-10-14 20:01:42 +02:00
|
|
|
return IXMLDOMNode_replaceChild( IXMLDOMNode_from_impl(&This->node), newChild, oldChild, outOldChild );
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_removeChild(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
IXMLDOMNode* childNode,
|
|
|
|
IXMLDOMNode** oldChild)
|
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2009-10-14 20:01:42 +02:00
|
|
|
return IXMLDOMNode_removeChild( IXMLDOMNode_from_impl(&This->node), childNode, oldChild );
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_appendChild(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
IXMLDOMNode* newChild,
|
|
|
|
IXMLDOMNode** outNewChild)
|
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2009-10-14 20:01:42 +02:00
|
|
|
return IXMLDOMNode_appendChild( IXMLDOMNode_from_impl(&This->node), newChild, outNewChild );
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_hasChildNodes(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
VARIANT_BOOL* hasChild)
|
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2009-10-14 20:01:42 +02:00
|
|
|
return IXMLDOMNode_hasChildNodes( IXMLDOMNode_from_impl(&This->node), hasChild );
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_get_ownerDocument(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
IXMLDOMDocument** DOMDocument)
|
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2009-10-14 20:01:42 +02:00
|
|
|
return IXMLDOMNode_get_ownerDocument( IXMLDOMNode_from_impl(&This->node), DOMDocument );
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_cloneNode(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
VARIANT_BOOL deep,
|
|
|
|
IXMLDOMNode** cloneRoot)
|
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2009-10-14 20:01:42 +02:00
|
|
|
return IXMLDOMNode_cloneNode( IXMLDOMNode_from_impl(&This->node), deep, cloneRoot );
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_get_nodeTypeString(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
BSTR* nodeType )
|
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2009-10-14 20:01:42 +02:00
|
|
|
return IXMLDOMNode_get_nodeTypeString( IXMLDOMNode_from_impl(&This->node), nodeType );
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_get_text(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
BSTR* text )
|
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2009-10-14 20:01:42 +02:00
|
|
|
return IXMLDOMNode_get_text( IXMLDOMNode_from_impl(&This->node), text );
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_put_text(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
BSTR text )
|
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2009-10-14 20:01:42 +02:00
|
|
|
return IXMLDOMNode_put_text( IXMLDOMNode_from_impl(&This->node), text );
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_get_specified(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
VARIANT_BOOL* isSpecified )
|
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2009-10-14 20:01:42 +02:00
|
|
|
return IXMLDOMNode_get_specified( IXMLDOMNode_from_impl(&This->node), isSpecified );
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_get_definition(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
IXMLDOMNode** definitionNode )
|
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2009-10-14 20:01:42 +02:00
|
|
|
return IXMLDOMNode_get_definition( IXMLDOMNode_from_impl(&This->node), definitionNode );
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_get_nodeTypedValue(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
VARIANT* typedValue )
|
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2009-10-14 20:01:42 +02:00
|
|
|
return IXMLDOMNode_get_nodeTypedValue( IXMLDOMNode_from_impl(&This->node), typedValue );
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_put_nodeTypedValue(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
VARIANT typedValue )
|
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2009-10-14 20:01:42 +02:00
|
|
|
return IXMLDOMNode_put_nodeTypedValue( IXMLDOMNode_from_impl(&This->node), typedValue );
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_get_dataType(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
VARIANT* dataTypeName )
|
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2009-10-14 20:01:42 +02:00
|
|
|
return IXMLDOMNode_get_dataType( IXMLDOMNode_from_impl(&This->node), dataTypeName );
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_put_dataType(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
BSTR dataTypeName )
|
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2009-10-14 20:01:42 +02:00
|
|
|
return IXMLDOMNode_put_dataType( IXMLDOMNode_from_impl(&This->node), dataTypeName );
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_get_xml(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
BSTR* xmlString )
|
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2009-10-14 20:01:42 +02:00
|
|
|
return IXMLDOMNode_get_xml( IXMLDOMNode_from_impl(&This->node), xmlString );
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_transformNode(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
IXMLDOMNode* styleSheet,
|
|
|
|
BSTR* xmlString )
|
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2009-10-14 20:01:42 +02:00
|
|
|
return IXMLDOMNode_transformNode( IXMLDOMNode_from_impl(&This->node), styleSheet, xmlString );
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_selectNodes(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
BSTR queryString,
|
|
|
|
IXMLDOMNodeList** resultList )
|
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2009-10-14 20:01:42 +02:00
|
|
|
return IXMLDOMNode_selectNodes( IXMLDOMNode_from_impl(&This->node), queryString, resultList );
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_selectSingleNode(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
BSTR queryString,
|
|
|
|
IXMLDOMNode** resultNode )
|
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2009-10-14 20:01:42 +02:00
|
|
|
return IXMLDOMNode_selectSingleNode( IXMLDOMNode_from_impl(&This->node), queryString, resultNode );
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_get_parsed(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
VARIANT_BOOL* isParsed )
|
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2009-10-14 20:01:42 +02:00
|
|
|
return IXMLDOMNode_get_parsed( IXMLDOMNode_from_impl(&This->node), isParsed );
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_get_namespaceURI(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
BSTR* namespaceURI )
|
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2009-10-14 20:01:42 +02:00
|
|
|
return IXMLDOMNode_get_namespaceURI( IXMLDOMNode_from_impl(&This->node), namespaceURI );
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_get_prefix(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
BSTR* prefixString )
|
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2009-10-14 20:01:42 +02:00
|
|
|
return IXMLDOMNode_get_prefix( IXMLDOMNode_from_impl(&This->node), prefixString );
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_get_baseName(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
BSTR* nameString )
|
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2009-10-14 20:01:42 +02:00
|
|
|
return IXMLDOMNode_get_baseName( IXMLDOMNode_from_impl(&This->node), nameString );
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_transformNodeToObject(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
IXMLDOMNode* stylesheet,
|
|
|
|
VARIANT outputObject)
|
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2009-10-14 20:01:42 +02:00
|
|
|
return IXMLDOMNode_transformNodeToObject( IXMLDOMNode_from_impl(&This->node), stylesheet, outputObject );
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_get_doctype(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-11-08 20:59:36 +01:00
|
|
|
IXMLDOMDocumentType** documentType )
|
2005-08-02 13:29:04 +02:00
|
|
|
{
|
2010-02-17 07:40:40 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2(iface);
|
|
|
|
FIXME("(%p)\n", This);
|
2005-08-02 13:29:04 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_get_implementation(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
IXMLDOMImplementation** impl )
|
|
|
|
{
|
2010-02-17 07:40:40 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2(iface);
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, impl);
|
|
|
|
|
2008-01-18 10:33:03 +01:00
|
|
|
if(!impl)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
*impl = (IXMLDOMImplementation*)create_doc_Implementation();
|
|
|
|
|
|
|
|
return S_OK;
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_get_documentElement(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
IXMLDOMElement** DOMElement )
|
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2005-08-10 11:54:22 +02:00
|
|
|
xmlDocPtr xmldoc = NULL;
|
|
|
|
xmlNodePtr root = NULL;
|
2005-12-01 18:46:42 +01:00
|
|
|
IXMLDOMNode *element_node;
|
|
|
|
HRESULT hr;
|
2005-08-10 11:54:22 +02:00
|
|
|
|
2010-02-17 07:40:40 +01:00
|
|
|
TRACE("(%p)->(%p)\n", This, DOMElement);
|
2007-11-11 12:35:35 +01:00
|
|
|
|
|
|
|
if(!DOMElement)
|
|
|
|
return E_INVALIDARG;
|
2005-08-03 12:58:47 +02:00
|
|
|
|
2005-08-10 11:54:22 +02:00
|
|
|
*DOMElement = NULL;
|
2005-08-03 12:58:47 +02:00
|
|
|
|
2005-08-18 12:48:13 +02:00
|
|
|
xmldoc = get_doc( This );
|
2005-08-10 11:54:22 +02:00
|
|
|
|
|
|
|
root = xmlDocGetRootElement( xmldoc );
|
|
|
|
if ( !root )
|
|
|
|
return S_FALSE;
|
|
|
|
|
2005-12-01 18:46:42 +01:00
|
|
|
element_node = create_node( root );
|
|
|
|
if(!element_node) return S_FALSE;
|
|
|
|
|
|
|
|
hr = IXMLDOMNode_QueryInterface(element_node, &IID_IXMLDOMElement, (LPVOID*)DOMElement);
|
|
|
|
IXMLDOMNode_Release(element_node);
|
|
|
|
|
|
|
|
return hr;
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-07-08 20:54:16 +02:00
|
|
|
static HRESULT WINAPI domdoc_put_documentElement(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
IXMLDOMElement* DOMElement )
|
|
|
|
{
|
2008-07-08 20:54:16 +02:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
|
|
|
IXMLDOMNode *elementNode;
|
2008-10-16 20:55:41 +02:00
|
|
|
xmlNodePtr oldRoot;
|
2008-07-08 20:54:16 +02:00
|
|
|
xmlnode *xmlNode;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, DOMElement);
|
|
|
|
|
|
|
|
hr = IXMLDOMElement_QueryInterface( DOMElement, &IID_IXMLDOMNode, (void**)&elementNode );
|
|
|
|
if(FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
xmlNode = impl_from_IXMLDOMNode( elementNode );
|
2008-10-16 20:55:41 +02:00
|
|
|
|
|
|
|
if(!xmlNode->node->parent)
|
|
|
|
if(xmldoc_remove_orphan(xmlNode->node->doc, xmlNode->node) != S_OK)
|
|
|
|
WARN("%p is not an orphan of %p\n", xmlNode->node->doc, xmlNode->node);
|
|
|
|
|
|
|
|
oldRoot = xmlDocSetRootElement( get_doc(This), xmlNode->node);
|
2008-07-08 20:54:16 +02:00
|
|
|
IXMLDOMNode_Release( elementNode );
|
|
|
|
|
2008-10-16 20:55:41 +02:00
|
|
|
if(oldRoot)
|
|
|
|
xmldoc_add_orphan(oldRoot->doc, oldRoot);
|
|
|
|
|
2008-07-08 20:54:16 +02:00
|
|
|
return S_OK;
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_createElement(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
BSTR tagname,
|
|
|
|
IXMLDOMElement** element )
|
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2010-02-12 19:48:01 +01:00
|
|
|
IXMLDOMNode *node;
|
2010-02-12 04:44:59 +01:00
|
|
|
VARIANT type;
|
2010-02-12 19:48:01 +01:00
|
|
|
HRESULT hr;
|
2006-11-17 15:32:17 +01:00
|
|
|
|
2010-02-17 07:40:40 +01:00
|
|
|
TRACE("(%p)->(%s %p)\n", This, debugstr_w(tagname), element);
|
2010-02-11 22:06:51 +01:00
|
|
|
|
2010-02-12 04:44:59 +01:00
|
|
|
if (!element || !tagname) return E_INVALIDARG;
|
2006-11-17 15:32:17 +01:00
|
|
|
|
2010-02-12 04:44:59 +01:00
|
|
|
V_VT(&type) = VT_I1;
|
|
|
|
V_I1(&type) = NODE_ELEMENT;
|
2006-11-17 15:32:17 +01:00
|
|
|
|
2010-06-22 14:14:51 +02:00
|
|
|
hr = IXMLDOMDocument2_createNode(iface, type, tagname, NULL, &node);
|
2010-02-12 19:48:01 +01:00
|
|
|
if (hr == S_OK)
|
|
|
|
{
|
|
|
|
IXMLDOMNode_QueryInterface(node, &IID_IXMLDOMElement, (void**)element);
|
|
|
|
IXMLDOMNode_Release(node);
|
|
|
|
}
|
|
|
|
|
|
|
|
return hr;
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_createDocumentFragment(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2010-02-12 01:59:14 +01:00
|
|
|
IXMLDOMDocumentFragment** frag )
|
2005-08-02 13:29:04 +02:00
|
|
|
{
|
2008-01-19 13:23:49 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2010-02-12 19:30:16 +01:00
|
|
|
IXMLDOMNode *node;
|
2010-02-12 01:59:14 +01:00
|
|
|
VARIANT type;
|
2010-02-12 19:30:16 +01:00
|
|
|
HRESULT hr;
|
2008-01-19 13:23:49 +01:00
|
|
|
|
2010-02-12 01:59:14 +01:00
|
|
|
TRACE("(%p)->(%p)\n", This, frag);
|
2008-01-19 13:23:49 +01:00
|
|
|
|
2010-02-12 19:30:16 +01:00
|
|
|
if (!frag) return E_INVALIDARG;
|
|
|
|
|
|
|
|
*frag = NULL;
|
|
|
|
|
2010-02-12 01:59:14 +01:00
|
|
|
V_VT(&type) = VT_I1;
|
|
|
|
V_I1(&type) = NODE_DOCUMENT_FRAGMENT;
|
2010-02-12 19:30:16 +01:00
|
|
|
|
2010-06-22 14:14:51 +02:00
|
|
|
hr = IXMLDOMDocument2_createNode(iface, type, NULL, NULL, &node);
|
2010-02-12 19:30:16 +01:00
|
|
|
if (hr == S_OK)
|
|
|
|
{
|
|
|
|
IXMLDOMNode_QueryInterface(node, &IID_IXMLDOMDocumentFragment, (void**)frag);
|
|
|
|
IXMLDOMNode_Release(node);
|
|
|
|
}
|
|
|
|
|
|
|
|
return hr;
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_createTextNode(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
BSTR data,
|
|
|
|
IXMLDOMText** text )
|
|
|
|
{
|
2007-11-15 23:55:49 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2010-02-12 19:44:27 +01:00
|
|
|
IXMLDOMNode *node;
|
|
|
|
VARIANT type;
|
|
|
|
HRESULT hr;
|
2007-11-15 23:55:49 +01:00
|
|
|
|
2010-02-17 07:40:40 +01:00
|
|
|
TRACE("(%p)->(%s %p)\n", This, debugstr_w(data), text);
|
2007-11-15 23:55:49 +01:00
|
|
|
|
2010-02-12 19:44:27 +01:00
|
|
|
if (!text) return E_INVALIDARG;
|
2007-11-15 23:55:49 +01:00
|
|
|
|
|
|
|
*text = NULL;
|
|
|
|
|
2010-02-12 19:44:27 +01:00
|
|
|
V_VT(&type) = VT_I1;
|
|
|
|
V_I1(&type) = NODE_TEXT;
|
2007-11-15 23:55:49 +01:00
|
|
|
|
2010-02-12 19:44:27 +01:00
|
|
|
hr = IXMLDOMDocument2_createNode(iface, type, NULL, NULL, &node);
|
|
|
|
if (hr == S_OK)
|
|
|
|
{
|
|
|
|
IXMLDOMNode_QueryInterface(node, &IID_IXMLDOMText, (void**)text);
|
|
|
|
IXMLDOMNode_Release(node);
|
|
|
|
hr = IXMLDOMText_put_data(*text, data);
|
|
|
|
}
|
2007-11-15 23:55:49 +01:00
|
|
|
|
2010-02-12 19:44:27 +01:00
|
|
|
return hr;
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_createComment(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
BSTR data,
|
|
|
|
IXMLDOMComment** comment )
|
|
|
|
{
|
2008-01-03 23:08:35 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2010-02-12 19:26:50 +01:00
|
|
|
VARIANT type;
|
|
|
|
HRESULT hr;
|
|
|
|
IXMLDOMNode *node;
|
2008-01-03 23:08:35 +01:00
|
|
|
|
2010-02-17 07:40:40 +01:00
|
|
|
TRACE("(%p)->(%s %p)\n", This, debugstr_w(data), comment);
|
2008-01-03 23:08:35 +01:00
|
|
|
|
2010-02-12 19:26:50 +01:00
|
|
|
if (!comment) return E_INVALIDARG;
|
2008-01-03 23:08:35 +01:00
|
|
|
|
|
|
|
*comment = NULL;
|
|
|
|
|
2010-02-12 19:26:50 +01:00
|
|
|
V_VT(&type) = VT_I1;
|
|
|
|
V_I1(&type) = NODE_COMMENT;
|
2008-01-03 23:08:35 +01:00
|
|
|
|
2010-02-12 19:26:50 +01:00
|
|
|
hr = IXMLDOMDocument2_createNode(iface, type, NULL, NULL, &node);
|
|
|
|
if (hr == S_OK)
|
|
|
|
{
|
|
|
|
IXMLDOMNode_QueryInterface(node, &IID_IXMLDOMComment, (void**)comment);
|
|
|
|
IXMLDOMNode_Release(node);
|
|
|
|
hr = IXMLDOMComment_put_data(*comment, data);
|
|
|
|
}
|
2008-01-03 23:08:35 +01:00
|
|
|
|
2010-02-12 19:26:50 +01:00
|
|
|
return hr;
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_createCDATASection(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
BSTR data,
|
|
|
|
IXMLDOMCDATASection** cdata )
|
|
|
|
{
|
2008-01-14 03:25:13 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2010-02-12 19:58:17 +01:00
|
|
|
IXMLDOMNode *node;
|
|
|
|
VARIANT type;
|
|
|
|
HRESULT hr;
|
2008-01-14 03:25:13 +01:00
|
|
|
|
2010-02-17 07:40:40 +01:00
|
|
|
TRACE("(%p)->(%s %p)\n", This, debugstr_w(data), cdata);
|
2008-01-14 03:25:13 +01:00
|
|
|
|
2010-02-12 19:58:17 +01:00
|
|
|
if (!cdata) return E_INVALIDARG;
|
2008-01-14 03:25:13 +01:00
|
|
|
|
|
|
|
*cdata = NULL;
|
|
|
|
|
2010-02-12 19:58:17 +01:00
|
|
|
V_VT(&type) = VT_I1;
|
|
|
|
V_I1(&type) = NODE_CDATA_SECTION;
|
2008-01-14 03:25:13 +01:00
|
|
|
|
2010-02-12 19:58:17 +01:00
|
|
|
hr = IXMLDOMDocument2_createNode(iface, type, NULL, NULL, &node);
|
|
|
|
if (hr == S_OK)
|
|
|
|
{
|
|
|
|
IXMLDOMNode_QueryInterface(node, &IID_IXMLDOMCDATASection, (void**)cdata);
|
|
|
|
IXMLDOMNode_Release(node);
|
|
|
|
hr = IXMLDOMCDATASection_put_data(*cdata, data);
|
|
|
|
}
|
2008-01-14 03:25:13 +01:00
|
|
|
|
2010-02-12 19:58:17 +01:00
|
|
|
return hr;
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_createProcessingInstruction(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
BSTR target,
|
|
|
|
BSTR data,
|
|
|
|
IXMLDOMProcessingInstruction** pi )
|
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2010-02-12 21:06:42 +01:00
|
|
|
IXMLDOMNode *node;
|
|
|
|
VARIANT type;
|
|
|
|
HRESULT hr;
|
2006-11-17 00:17:00 +01:00
|
|
|
|
2010-02-17 07:40:40 +01:00
|
|
|
TRACE("(%p)->(%s %s %p)\n", This, debugstr_w(target), debugstr_w(data), pi);
|
2006-11-17 00:17:00 +01:00
|
|
|
|
2010-02-12 21:06:42 +01:00
|
|
|
if (!pi) return E_INVALIDARG;
|
2008-01-08 01:07:12 +01:00
|
|
|
|
2010-02-12 21:06:42 +01:00
|
|
|
*pi = NULL;
|
2008-01-08 01:07:12 +01:00
|
|
|
|
2010-02-12 21:06:42 +01:00
|
|
|
V_VT(&type) = VT_I1;
|
|
|
|
V_I1(&type) = NODE_PROCESSING_INSTRUCTION;
|
2006-11-17 00:17:00 +01:00
|
|
|
|
2010-02-12 21:06:42 +01:00
|
|
|
hr = IXMLDOMDocument2_createNode(iface, type, target, NULL, &node);
|
|
|
|
if (hr == S_OK)
|
|
|
|
{
|
|
|
|
VARIANT v_data;
|
2006-11-17 00:17:00 +01:00
|
|
|
|
2010-02-12 21:06:42 +01:00
|
|
|
/* this is to bypass check in ::put_data() that blocks "<?xml" PIs */
|
|
|
|
V_VT(&v_data) = VT_BSTR;
|
|
|
|
V_BSTR(&v_data) = data;
|
2006-11-17 00:17:00 +01:00
|
|
|
|
2010-02-12 21:06:42 +01:00
|
|
|
hr = IXMLDOMNode_put_nodeValue( node, v_data );
|
|
|
|
|
|
|
|
IXMLDOMNode_QueryInterface(node, &IID_IXMLDOMProcessingInstruction, (void**)pi);
|
|
|
|
IXMLDOMNode_Release(node);
|
|
|
|
}
|
|
|
|
|
|
|
|
return hr;
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_createAttribute(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
BSTR name,
|
|
|
|
IXMLDOMAttribute** attribute )
|
|
|
|
{
|
2008-01-03 23:11:27 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2010-02-12 20:34:50 +01:00
|
|
|
IXMLDOMNode *node;
|
|
|
|
VARIANT type;
|
|
|
|
HRESULT hr;
|
2008-01-03 23:11:27 +01:00
|
|
|
|
2010-02-17 07:40:40 +01:00
|
|
|
TRACE("(%p)->(%s %p)\n", This, debugstr_w(name), attribute);
|
2008-01-03 23:11:27 +01:00
|
|
|
|
2010-02-12 20:34:50 +01:00
|
|
|
if (!attribute || !name) return E_INVALIDARG;
|
2008-01-03 23:11:27 +01:00
|
|
|
|
2010-02-12 20:34:50 +01:00
|
|
|
V_VT(&type) = VT_I1;
|
|
|
|
V_I1(&type) = NODE_ATTRIBUTE;
|
2008-01-03 23:11:27 +01:00
|
|
|
|
2010-06-22 14:14:51 +02:00
|
|
|
hr = IXMLDOMDocument2_createNode(iface, type, name, NULL, &node);
|
2010-02-12 20:34:50 +01:00
|
|
|
if (hr == S_OK)
|
|
|
|
{
|
|
|
|
IXMLDOMNode_QueryInterface(node, &IID_IXMLDOMAttribute, (void**)attribute);
|
|
|
|
IXMLDOMNode_Release(node);
|
|
|
|
}
|
2008-01-03 23:11:27 +01:00
|
|
|
|
2010-02-12 20:34:50 +01:00
|
|
|
return hr;
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_createEntityReference(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
BSTR name,
|
2010-02-12 21:24:40 +01:00
|
|
|
IXMLDOMEntityReference** entityref )
|
2005-08-02 13:29:04 +02:00
|
|
|
{
|
2008-01-21 22:33:32 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2010-02-12 21:24:40 +01:00
|
|
|
IXMLDOMNode *node;
|
|
|
|
VARIANT type;
|
|
|
|
HRESULT hr;
|
2008-01-21 22:33:32 +01:00
|
|
|
|
2010-02-17 07:40:40 +01:00
|
|
|
TRACE("(%p)->(%s %p)\n", This, debugstr_w(name), entityref);
|
2008-01-21 22:33:32 +01:00
|
|
|
|
2010-02-12 21:24:40 +01:00
|
|
|
if (!entityref) return E_INVALIDARG;
|
2008-01-21 22:33:32 +01:00
|
|
|
|
2010-02-12 21:24:40 +01:00
|
|
|
*entityref = NULL;
|
2008-01-21 22:33:32 +01:00
|
|
|
|
2010-02-12 21:24:40 +01:00
|
|
|
V_VT(&type) = VT_I1;
|
|
|
|
V_I1(&type) = NODE_ENTITY_REFERENCE;
|
2008-01-21 22:33:32 +01:00
|
|
|
|
2010-02-12 21:24:40 +01:00
|
|
|
hr = IXMLDOMDocument2_createNode(iface, type, name, NULL, &node);
|
|
|
|
if (hr == S_OK)
|
|
|
|
{
|
|
|
|
IXMLDOMNode_QueryInterface(node, &IID_IXMLDOMEntityReference, (void**)entityref);
|
|
|
|
IXMLDOMNode_Release(node);
|
|
|
|
}
|
2008-01-21 22:33:32 +01:00
|
|
|
|
2010-02-12 21:24:40 +01:00
|
|
|
return hr;
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_getElementsByTagName(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
BSTR tagName,
|
|
|
|
IXMLDOMNodeList** resultList )
|
|
|
|
{
|
2010-01-16 22:17:36 +01:00
|
|
|
static const WCHAR xpathformat[] =
|
|
|
|
{ '/','/','*','[','l','o','c','a','l','-','n','a','m','e','(',')','=','\'','%','s','\'',']',0 };
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2007-05-11 17:03:13 +02:00
|
|
|
LPWSTR szPattern;
|
|
|
|
HRESULT hr;
|
2010-02-17 07:40:40 +01:00
|
|
|
TRACE("(%p)->(%s %p)\n", This, debugstr_w(tagName), resultList);
|
2006-02-14 10:38:21 +01:00
|
|
|
|
2010-01-16 22:17:36 +01:00
|
|
|
if (tagName[0] == '*' && tagName[1] == 0)
|
|
|
|
{
|
2010-02-03 20:47:53 +01:00
|
|
|
szPattern = heap_alloc(sizeof(WCHAR)*4);
|
2010-01-16 22:17:36 +01:00
|
|
|
szPattern[0] = szPattern[1] = '/';
|
|
|
|
szPattern[2] = '*';
|
|
|
|
szPattern[3] = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-02-03 20:47:53 +01:00
|
|
|
szPattern = heap_alloc(sizeof(WCHAR)*(20+lstrlenW(tagName)+1));
|
2010-01-16 22:17:36 +01:00
|
|
|
wsprintfW(szPattern, xpathformat, tagName);
|
|
|
|
}
|
2006-02-14 10:38:21 +01:00
|
|
|
|
2007-05-11 17:03:13 +02:00
|
|
|
hr = queryresult_create((xmlNodePtr)get_doc(This), szPattern, resultList);
|
2010-02-03 20:47:53 +01:00
|
|
|
heap_free(szPattern);
|
2007-05-11 17:03:13 +02:00
|
|
|
|
|
|
|
return hr;
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
2008-10-07 11:55:57 +02:00
|
|
|
static HRESULT get_node_type(VARIANT Type, DOMNodeType * type)
|
2006-01-11 21:15:12 +01:00
|
|
|
{
|
2008-10-07 11:55:57 +02:00
|
|
|
VARIANT tmp;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
VariantInit(&tmp);
|
|
|
|
hr = VariantChangeType(&tmp, &Type, 0, VT_I4);
|
|
|
|
if(FAILED(hr))
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
*type = V_I4(&tmp);
|
2006-01-11 21:15:12 +01:00
|
|
|
|
2008-10-07 11:55:57 +02:00
|
|
|
return S_OK;
|
2006-01-11 21:15:12 +01:00
|
|
|
}
|
2005-08-02 13:29:04 +02:00
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_createNode(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
VARIANT Type,
|
|
|
|
BSTR name,
|
|
|
|
BSTR namespaceURI,
|
|
|
|
IXMLDOMNode** node )
|
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2006-01-11 21:15:12 +01:00
|
|
|
DOMNodeType node_type;
|
2010-02-12 01:48:46 +01:00
|
|
|
xmlNodePtr xmlnode;
|
2006-01-11 21:15:12 +01:00
|
|
|
xmlChar *xml_name;
|
2008-10-07 11:55:57 +02:00
|
|
|
HRESULT hr;
|
2006-01-11 21:15:12 +01:00
|
|
|
|
2010-02-17 07:40:40 +01:00
|
|
|
TRACE("(%p)->(%s %s %p)\n", This, debugstr_w(name), debugstr_w(namespaceURI), node);
|
2006-01-11 21:15:12 +01:00
|
|
|
|
2010-02-11 22:06:51 +01:00
|
|
|
if(!node) return E_INVALIDARG;
|
|
|
|
|
2009-01-13 22:29:27 +01:00
|
|
|
if(namespaceURI && namespaceURI[0])
|
|
|
|
FIXME("nodes with namespaces currently not supported.\n");
|
|
|
|
|
2008-10-07 11:55:57 +02:00
|
|
|
hr = get_node_type(Type, &node_type);
|
2010-02-12 01:48:46 +01:00
|
|
|
if(FAILED(hr)) return hr;
|
2008-10-07 11:55:57 +02:00
|
|
|
|
2006-01-11 21:15:12 +01:00
|
|
|
TRACE("node_type %d\n", node_type);
|
2010-02-12 04:44:59 +01:00
|
|
|
|
2010-02-12 20:34:50 +01:00
|
|
|
/* exit earlier for types that need name */
|
|
|
|
switch(node_type)
|
|
|
|
{
|
|
|
|
case NODE_ELEMENT:
|
|
|
|
case NODE_ATTRIBUTE:
|
2010-02-12 21:24:40 +01:00
|
|
|
case NODE_ENTITY_REFERENCE:
|
2010-02-12 20:34:50 +01:00
|
|
|
case NODE_PROCESSING_INSTRUCTION:
|
2010-06-13 02:23:23 +02:00
|
|
|
if (!name || *name == 0) return E_FAIL;
|
2010-02-12 20:34:50 +01:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2006-01-11 21:15:12 +01:00
|
|
|
|
2009-01-26 11:01:02 +01:00
|
|
|
xml_name = xmlChar_from_wchar(name);
|
2005-08-02 13:29:04 +02:00
|
|
|
|
2006-01-11 21:15:12 +01:00
|
|
|
switch(node_type)
|
|
|
|
{
|
|
|
|
case NODE_ELEMENT:
|
|
|
|
xmlnode = xmlNewDocNode(get_doc(This), NULL, xml_name, NULL);
|
|
|
|
break;
|
2008-07-02 14:49:50 +02:00
|
|
|
case NODE_ATTRIBUTE:
|
2010-02-12 01:48:46 +01:00
|
|
|
xmlnode = (xmlNodePtr)xmlNewDocProp(get_doc(This), xml_name, NULL);
|
2008-07-02 14:49:50 +02:00
|
|
|
break;
|
2010-02-12 01:48:46 +01:00
|
|
|
case NODE_TEXT:
|
|
|
|
xmlnode = (xmlNodePtr)xmlNewDocText(get_doc(This), NULL);
|
|
|
|
break;
|
|
|
|
case NODE_CDATA_SECTION:
|
|
|
|
xmlnode = xmlNewCDataBlock(get_doc(This), NULL, 0);
|
|
|
|
break;
|
2010-02-12 21:24:40 +01:00
|
|
|
case NODE_ENTITY_REFERENCE:
|
|
|
|
xmlnode = xmlNewReference(get_doc(This), xml_name);
|
|
|
|
break;
|
2010-02-12 01:48:46 +01:00
|
|
|
case NODE_PROCESSING_INSTRUCTION:
|
|
|
|
#ifdef HAVE_XMLNEWDOCPI
|
|
|
|
xmlnode = xmlNewDocPI(get_doc(This), xml_name, NULL);
|
|
|
|
#else
|
|
|
|
FIXME("xmlNewDocPI() not supported, use libxml2 2.6.15 or greater\n");
|
|
|
|
xmlnode = NULL;
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
case NODE_COMMENT:
|
|
|
|
xmlnode = xmlNewDocComment(get_doc(This), NULL);
|
|
|
|
break;
|
|
|
|
case NODE_DOCUMENT_FRAGMENT:
|
|
|
|
xmlnode = xmlNewDocFragment(get_doc(This));
|
|
|
|
break;
|
|
|
|
/* unsupported types */
|
|
|
|
case NODE_DOCUMENT:
|
|
|
|
case NODE_DOCUMENT_TYPE:
|
|
|
|
case NODE_ENTITY:
|
|
|
|
case NODE_NOTATION:
|
|
|
|
heap_free(xml_name);
|
|
|
|
return E_INVALIDARG;
|
2006-01-11 21:15:12 +01:00
|
|
|
default:
|
|
|
|
FIXME("unhandled node type %d\n", node_type);
|
2010-02-12 01:48:46 +01:00
|
|
|
xmlnode = NULL;
|
2006-01-11 21:15:12 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2010-02-12 01:48:46 +01:00
|
|
|
*node = create_node(xmlnode);
|
2010-02-03 20:47:53 +01:00
|
|
|
heap_free(xml_name);
|
2006-01-11 21:15:12 +01:00
|
|
|
|
2010-02-12 01:48:46 +01:00
|
|
|
if(*node)
|
2008-10-11 23:59:25 +02:00
|
|
|
{
|
2010-02-12 01:48:46 +01:00
|
|
|
TRACE("created node (%d, %p, %p)\n", node_type, *node, xmlnode);
|
2008-10-11 23:59:25 +02:00
|
|
|
xmldoc_add_orphan(xmlnode->doc, xmlnode);
|
2006-01-11 21:15:12 +01:00
|
|
|
return S_OK;
|
2008-10-11 23:59:25 +02:00
|
|
|
}
|
2006-01-11 21:15:12 +01:00
|
|
|
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
2005-08-02 13:29:04 +02:00
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_nodeFromID(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
BSTR idString,
|
|
|
|
IXMLDOMNode** node )
|
|
|
|
{
|
2010-02-17 07:40:40 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2(iface);
|
|
|
|
FIXME("(%p)->(%s %p)\n", This, debugstr_w(idString), node);
|
2005-08-02 13:29:04 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2008-07-27 19:54:38 +02:00
|
|
|
static HRESULT domdoc_onDataAvailable(void *obj, char *ptr, DWORD len)
|
2005-08-12 12:35:17 +02:00
|
|
|
{
|
2008-07-27 19:54:38 +02:00
|
|
|
domdoc *This = obj;
|
|
|
|
xmlDocPtr xmldoc;
|
2006-02-21 12:50:59 +01:00
|
|
|
|
2010-06-20 11:47:39 +02:00
|
|
|
xmldoc = doparse( ptr, len, NULL );
|
2008-07-27 19:54:38 +02:00
|
|
|
if(xmldoc) {
|
2008-10-11 23:59:12 +02:00
|
|
|
xmldoc->_private = create_priv();
|
2009-10-14 20:01:42 +02:00
|
|
|
return attach_xmldoc(&This->node, xmldoc);
|
2006-02-21 12:50:59 +01:00
|
|
|
}
|
|
|
|
|
2008-07-27 19:54:38 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
2008-07-08 20:55:03 +02:00
|
|
|
|
2008-07-27 19:54:38 +02:00
|
|
|
static HRESULT doread( domdoc *This, LPWSTR filename )
|
|
|
|
{
|
|
|
|
bsc_t *bsc;
|
|
|
|
HRESULT hr;
|
2008-07-08 20:55:03 +02:00
|
|
|
|
2008-07-27 19:54:38 +02:00
|
|
|
hr = bind_url(filename, domdoc_onDataAvailable, This, &bsc);
|
|
|
|
if(FAILED(hr))
|
|
|
|
return hr;
|
2006-02-21 12:50:59 +01:00
|
|
|
|
2008-07-27 19:54:38 +02:00
|
|
|
if(This->bsc)
|
|
|
|
detach_bsc(This->bsc);
|
|
|
|
|
|
|
|
This->bsc = bsc;
|
|
|
|
return S_OK;
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_load(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
VARIANT xmlSource,
|
|
|
|
VARIANT_BOOL* isSuccessful )
|
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2005-08-02 13:29:04 +02:00
|
|
|
LPWSTR filename = NULL;
|
2006-06-27 11:54:40 +02:00
|
|
|
HRESULT hr = S_FALSE;
|
2007-12-09 23:31:38 +01:00
|
|
|
IXMLDOMDocument2 *pNewDoc = NULL;
|
|
|
|
IStream *pStream = NULL;
|
2008-07-08 20:55:10 +02:00
|
|
|
xmlDocPtr xmldoc;
|
2005-08-02 13:29:04 +02:00
|
|
|
|
2010-02-17 07:40:40 +01:00
|
|
|
TRACE("(%p)->type %d\n", This, V_VT(&xmlSource) );
|
2005-08-10 11:54:22 +02:00
|
|
|
|
2005-12-01 18:46:42 +01:00
|
|
|
*isSuccessful = VARIANT_FALSE;
|
|
|
|
|
2009-10-14 20:01:42 +02:00
|
|
|
assert( &This->node );
|
2005-12-01 18:46:42 +01:00
|
|
|
|
2005-08-02 13:29:04 +02:00
|
|
|
switch( V_VT(&xmlSource) )
|
|
|
|
{
|
|
|
|
case VT_BSTR:
|
|
|
|
filename = V_BSTR(&xmlSource);
|
2007-12-09 23:31:38 +01:00
|
|
|
break;
|
|
|
|
case VT_UNKNOWN:
|
|
|
|
hr = IUnknown_QueryInterface(V_UNKNOWN(&xmlSource), &IID_IXMLDOMDocument2, (void**)&pNewDoc);
|
|
|
|
if(hr == S_OK)
|
|
|
|
{
|
|
|
|
if(pNewDoc)
|
|
|
|
{
|
|
|
|
domdoc *newDoc = impl_from_IXMLDOMDocument2( pNewDoc );
|
|
|
|
xmldoc = xmlCopyDoc(get_doc(newDoc), 1);
|
2009-10-14 20:01:42 +02:00
|
|
|
hr = attach_xmldoc(&This->node, xmldoc);
|
2007-12-09 23:31:38 +01:00
|
|
|
|
2008-11-29 10:52:24 +01:00
|
|
|
if(SUCCEEDED(hr))
|
|
|
|
*isSuccessful = VARIANT_TRUE;
|
2007-12-09 23:31:38 +01:00
|
|
|
|
2008-11-29 10:52:24 +01:00
|
|
|
return hr;
|
2007-12-09 23:31:38 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
hr = IUnknown_QueryInterface(V_UNKNOWN(&xmlSource), &IID_IStream, (void**)&pStream);
|
|
|
|
if(hr == S_OK)
|
|
|
|
{
|
|
|
|
IPersistStream *pDocStream;
|
|
|
|
hr = IUnknown_QueryInterface(iface, &IID_IPersistStream, (void**)&pDocStream);
|
|
|
|
if(hr == S_OK)
|
|
|
|
{
|
2010-06-28 19:16:43 +02:00
|
|
|
hr = IPersistStream_Load(pDocStream, pStream);
|
2007-12-09 23:31:38 +01:00
|
|
|
IStream_Release(pStream);
|
|
|
|
if(hr == S_OK)
|
|
|
|
{
|
|
|
|
*isSuccessful = VARIANT_TRUE;
|
|
|
|
|
2010-06-28 10:17:56 +02:00
|
|
|
TRACE("Using IStream to load Document\n");
|
2007-12-09 23:31:38 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ERR("xmldoc_IPersistStream_Load failed (%d)\n", hr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ERR("QueryInterface IID_IPersistStream failed (%d)\n", hr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* ISequentialStream */
|
|
|
|
FIXME("Unknown type not supported (%d) (%p)(%p)\n", hr, pNewDoc, V_UNKNOWN(&xmlSource)->lpVtbl);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
FIXME("VT type not supported (%d)\n", V_VT(&xmlSource));
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("filename (%s)\n", debugstr_w(filename));
|
2005-08-02 13:29:04 +02:00
|
|
|
|
2006-06-27 11:54:40 +02:00
|
|
|
if ( filename )
|
2006-02-21 12:52:25 +01:00
|
|
|
{
|
2008-07-08 20:55:10 +02:00
|
|
|
hr = doread( This, filename );
|
2006-06-27 11:54:40 +02:00
|
|
|
|
2008-07-08 20:55:10 +02:00
|
|
|
if ( FAILED(hr) )
|
2006-06-27 11:54:40 +02:00
|
|
|
This->error = E_FAIL;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
hr = This->error = S_OK;
|
|
|
|
*isSuccessful = VARIANT_TRUE;
|
|
|
|
}
|
2006-02-21 12:52:25 +01:00
|
|
|
}
|
2005-08-02 13:29:04 +02:00
|
|
|
|
2008-07-08 20:55:10 +02:00
|
|
|
if(!filename || FAILED(hr)) {
|
2006-06-27 11:54:40 +02:00
|
|
|
xmldoc = xmlNewDoc(NULL);
|
2008-10-11 23:59:12 +02:00
|
|
|
xmldoc->_private = create_priv();
|
2009-10-14 20:01:42 +02:00
|
|
|
hr = attach_xmldoc(&This->node, xmldoc);
|
2008-11-29 10:52:24 +01:00
|
|
|
if(SUCCEEDED(hr))
|
|
|
|
hr = S_FALSE;
|
2008-07-08 20:55:10 +02:00
|
|
|
}
|
2005-08-02 13:29:04 +02:00
|
|
|
|
2007-12-09 23:31:38 +01:00
|
|
|
TRACE("ret (%d)\n", hr);
|
|
|
|
|
2006-06-27 11:54:40 +02:00
|
|
|
return hr;
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_get_readyState(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2009-03-09 23:28:16 +01:00
|
|
|
LONG *value )
|
2005-08-02 13:29:04 +02:00
|
|
|
{
|
2010-02-17 07:40:40 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2(iface);
|
|
|
|
FIXME("(%p)->(%p)\n", This, value);
|
2005-08-02 13:29:04 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_get_parseError(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
IXMLDOMParseError** errorObj )
|
|
|
|
{
|
2006-02-21 12:52:25 +01:00
|
|
|
BSTR error_string = NULL;
|
|
|
|
static const WCHAR err[] = {'e','r','r','o','r',0};
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2006-02-21 12:52:25 +01:00
|
|
|
|
2005-11-08 14:10:49 +01:00
|
|
|
FIXME("(%p)->(%p): creating a dummy parseError\n", iface, errorObj);
|
2006-02-21 12:52:25 +01:00
|
|
|
|
|
|
|
if(This->error)
|
|
|
|
error_string = SysAllocString(err);
|
|
|
|
|
|
|
|
*errorObj = create_parseError(This->error, NULL, error_string, NULL, 0, 0, 0);
|
2005-11-08 14:10:49 +01:00
|
|
|
if(!*errorObj) return E_OUTOFMEMORY;
|
|
|
|
return S_OK;
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_get_url(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
BSTR* urlString )
|
|
|
|
{
|
2010-02-17 07:40:40 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2(iface);
|
|
|
|
FIXME("(%p)->(%p)\n", This, urlString);
|
2005-08-02 13:29:04 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_get_async(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
VARIANT_BOOL* isAsync )
|
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2005-08-02 13:29:04 +02:00
|
|
|
|
2010-02-17 07:40:40 +01:00
|
|
|
TRACE("(%p)->(%p: %d)\n", This, isAsync, This->async);
|
2005-08-02 13:29:04 +02:00
|
|
|
*isAsync = This->async;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_put_async(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
VARIANT_BOOL isAsync )
|
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2005-08-02 13:29:04 +02:00
|
|
|
|
2010-02-17 07:40:40 +01:00
|
|
|
TRACE("(%p)->(%d)\n", This, isAsync);
|
2005-08-02 13:29:04 +02:00
|
|
|
This->async = isAsync;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_abort(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface )
|
2005-08-02 13:29:04 +02:00
|
|
|
{
|
2010-02-17 07:40:40 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2(iface);
|
|
|
|
FIXME("%p\n", This);
|
2005-08-02 13:29:04 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-08-02 13:28:36 +02:00
|
|
|
static BOOL bstr_to_utf8( BSTR bstr, char **pstr, int *plen )
|
2005-08-11 12:32:36 +02:00
|
|
|
{
|
2010-03-15 00:16:02 +01:00
|
|
|
UINT len;
|
2005-08-11 12:32:36 +02:00
|
|
|
LPSTR str;
|
|
|
|
|
2010-03-15 00:16:02 +01:00
|
|
|
len = WideCharToMultiByte( CP_UTF8, 0, bstr, -1, NULL, 0, NULL, NULL );
|
2010-02-03 20:47:53 +01:00
|
|
|
str = heap_alloc( len );
|
2005-08-11 12:32:36 +02:00
|
|
|
if ( !str )
|
|
|
|
return FALSE;
|
2010-03-15 00:16:02 +01:00
|
|
|
WideCharToMultiByte( CP_UTF8, 0, bstr, -1, str, len, NULL, NULL );
|
2005-08-11 12:32:36 +02:00
|
|
|
*plen = len;
|
|
|
|
*pstr = str;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2010-03-15 00:16:02 +01:00
|
|
|
/* don't rely on data to be in BSTR format, treat it as WCHAR string */
|
2005-08-02 13:29:04 +02:00
|
|
|
static HRESULT WINAPI domdoc_loadXML(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
BSTR bstrXML,
|
|
|
|
VARIANT_BOOL* isSuccessful )
|
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2006-06-27 11:54:40 +02:00
|
|
|
xmlDocPtr xmldoc = NULL;
|
2005-08-11 12:32:36 +02:00
|
|
|
char *str;
|
|
|
|
int len;
|
2008-11-29 10:52:24 +01:00
|
|
|
HRESULT hr = S_FALSE, hr2;
|
2005-08-11 12:32:36 +02:00
|
|
|
|
2010-02-17 07:40:40 +01:00
|
|
|
TRACE("(%p)->(%s %p)\n", This, debugstr_w( bstrXML ), isSuccessful );
|
2005-08-11 12:32:36 +02:00
|
|
|
|
2009-10-14 20:01:42 +02:00
|
|
|
assert ( &This->node );
|
2005-12-01 18:46:42 +01:00
|
|
|
|
2006-06-27 11:54:40 +02:00
|
|
|
if ( isSuccessful )
|
2006-02-21 12:52:25 +01:00
|
|
|
{
|
2006-06-27 11:54:40 +02:00
|
|
|
*isSuccessful = VARIANT_FALSE;
|
|
|
|
|
2010-06-20 11:47:39 +02:00
|
|
|
if ( bstrXML && bstr_to_utf8( bstrXML, &str, &len ) )
|
2006-06-27 11:54:40 +02:00
|
|
|
{
|
2010-06-20 11:47:39 +02:00
|
|
|
xmldoc = doparse( str, len, "UTF-8" );
|
2010-02-03 20:47:53 +01:00
|
|
|
heap_free( str );
|
2006-06-27 11:54:40 +02:00
|
|
|
if ( !xmldoc )
|
|
|
|
This->error = E_FAIL;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
hr = This->error = S_OK;
|
|
|
|
*isSuccessful = VARIANT_TRUE;
|
|
|
|
}
|
|
|
|
}
|
2006-02-21 12:52:25 +01:00
|
|
|
}
|
2006-06-27 11:54:40 +02:00
|
|
|
if(!xmldoc)
|
|
|
|
xmldoc = xmlNewDoc(NULL);
|
2005-08-11 12:32:36 +02:00
|
|
|
|
2008-10-11 23:59:12 +02:00
|
|
|
xmldoc->_private = create_priv();
|
2009-10-14 20:01:42 +02:00
|
|
|
hr2 = attach_xmldoc( &This->node, xmldoc );
|
2008-11-29 10:52:24 +01:00
|
|
|
if( FAILED(hr2) )
|
|
|
|
hr = hr2;
|
2005-12-01 18:46:42 +01:00
|
|
|
|
2006-06-27 11:54:40 +02:00
|
|
|
return hr;
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
2010-02-05 14:25:02 +01:00
|
|
|
static int XMLCALL domdoc_save_writecallback(void *ctx, const char *buffer,
|
|
|
|
int len)
|
|
|
|
{
|
|
|
|
DWORD written = -1;
|
|
|
|
|
|
|
|
if(!WriteFile(ctx, buffer, len, &written, NULL))
|
|
|
|
{
|
|
|
|
WARN("write error\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return written;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int XMLCALL domdoc_save_closecallback(void *ctx)
|
|
|
|
{
|
|
|
|
return CloseHandle(ctx) ? 0 : -1;
|
|
|
|
}
|
2005-08-02 13:29:04 +02:00
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_save(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
VARIANT destination )
|
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2006-01-24 14:43:18 +01:00
|
|
|
HANDLE handle;
|
2010-02-05 14:25:02 +01:00
|
|
|
xmlSaveCtxtPtr ctx;
|
2010-06-28 10:17:56 +02:00
|
|
|
xmlNodePtr xmldecl;
|
2006-01-24 14:43:18 +01:00
|
|
|
HRESULT ret = S_OK;
|
|
|
|
|
2008-08-13 08:06:22 +02:00
|
|
|
TRACE("(%p)->(var(vt %d, %s))\n", This, V_VT(&destination),
|
2006-01-24 14:43:18 +01:00
|
|
|
V_VT(&destination) == VT_BSTR ? debugstr_w(V_BSTR(&destination)) : NULL);
|
|
|
|
|
2008-03-12 11:47:17 +01:00
|
|
|
if(V_VT(&destination) != VT_BSTR && V_VT(&destination) != VT_UNKNOWN)
|
2006-01-24 14:43:18 +01:00
|
|
|
{
|
2008-03-12 11:47:17 +01:00
|
|
|
FIXME("Unhandled vt %d\n", V_VT(&destination));
|
2006-01-24 14:43:18 +01:00
|
|
|
return S_FALSE;
|
|
|
|
}
|
|
|
|
|
2008-03-12 11:47:17 +01:00
|
|
|
if(V_VT(&destination) == VT_UNKNOWN)
|
|
|
|
{
|
|
|
|
IUnknown *pUnk = V_UNKNOWN(&destination);
|
2010-06-22 14:14:51 +02:00
|
|
|
IXMLDOMDocument2 *pDocument;
|
2008-03-12 11:47:17 +01:00
|
|
|
|
2010-06-22 14:14:51 +02:00
|
|
|
ret = IUnknown_QueryInterface(pUnk, &IID_IXMLDOMDocument2, (void**)&pDocument);
|
2008-03-12 11:47:17 +01:00
|
|
|
if(ret == S_OK)
|
|
|
|
{
|
|
|
|
BSTR bXML;
|
|
|
|
VARIANT_BOOL bSuccessful;
|
|
|
|
|
2010-06-22 14:14:51 +02:00
|
|
|
ret = IXMLDOMDocument2_get_xml(iface, &bXML);
|
2008-03-12 11:47:17 +01:00
|
|
|
if(ret == S_OK)
|
|
|
|
{
|
2010-06-22 14:14:51 +02:00
|
|
|
ret = IXMLDOMDocument2_loadXML(pDocument, bXML, &bSuccessful);
|
2008-03-12 11:47:17 +01:00
|
|
|
|
|
|
|
SysFreeString(bXML);
|
|
|
|
}
|
|
|
|
|
2010-06-22 14:14:51 +02:00
|
|
|
IXMLDOMDocument2_Release(pDocument);
|
2008-03-12 11:47:17 +01:00
|
|
|
}
|
|
|
|
|
2008-09-01 17:01:47 +02:00
|
|
|
TRACE("ret %d\n", ret);
|
2008-08-13 08:06:22 +02:00
|
|
|
|
2008-03-12 11:47:17 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2006-01-24 14:43:18 +01:00
|
|
|
handle = CreateFileW( V_BSTR(&destination), GENERIC_WRITE, 0,
|
|
|
|
NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL );
|
|
|
|
if( handle == INVALID_HANDLE_VALUE )
|
|
|
|
{
|
|
|
|
WARN("failed to create file\n");
|
|
|
|
return S_FALSE;
|
|
|
|
}
|
|
|
|
|
2010-02-05 14:25:02 +01:00
|
|
|
/* disable top XML declaration */
|
|
|
|
ctx = xmlSaveToIO(domdoc_save_writecallback, domdoc_save_closecallback,
|
|
|
|
handle, NULL, XML_SAVE_NO_DECL);
|
|
|
|
if (!ctx)
|
2006-01-24 14:43:18 +01:00
|
|
|
{
|
2010-02-05 14:25:02 +01:00
|
|
|
CloseHandle(handle);
|
|
|
|
return S_FALSE;
|
2006-01-24 14:43:18 +01:00
|
|
|
}
|
|
|
|
|
2010-06-28 10:17:56 +02:00
|
|
|
xmldecl = xmldoc_unlink_xmldecl(get_doc(This));
|
2010-02-05 14:25:02 +01:00
|
|
|
if (xmlSaveDoc(ctx, get_doc(This)) == -1) ret = S_FALSE;
|
2010-06-28 10:17:56 +02:00
|
|
|
xmldoc_link_xmldecl(get_doc(This), xmldecl);
|
|
|
|
|
2010-02-05 14:25:02 +01:00
|
|
|
/* will close file through close callback */
|
|
|
|
xmlSaveClose(ctx);
|
|
|
|
|
2006-01-24 14:43:18 +01:00
|
|
|
return ret;
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_get_validateOnParse(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
VARIANT_BOOL* isValidating )
|
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2007-02-18 19:37:18 +01:00
|
|
|
|
2010-02-17 07:40:40 +01:00
|
|
|
TRACE("(%p)->(%p: %d)\n", This, isValidating, This->validating);
|
2007-02-18 19:37:18 +01:00
|
|
|
*isValidating = This->validating;
|
|
|
|
return S_OK;
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_put_validateOnParse(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
VARIANT_BOOL isValidating )
|
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2007-02-18 19:37:18 +01:00
|
|
|
|
2010-02-17 07:40:40 +01:00
|
|
|
TRACE("(%p)->(%d)\n", This, isValidating);
|
2007-02-18 19:37:18 +01:00
|
|
|
This->validating = isValidating;
|
|
|
|
return S_OK;
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_get_resolveExternals(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
VARIANT_BOOL* isResolving )
|
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2007-02-18 19:37:18 +01:00
|
|
|
|
2010-02-17 07:40:40 +01:00
|
|
|
TRACE("(%p)->(%p: %d)\n", This, isResolving, This->resolving);
|
2007-02-18 19:37:18 +01:00
|
|
|
*isResolving = This->resolving;
|
|
|
|
return S_OK;
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_put_resolveExternals(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2007-02-18 19:37:18 +01:00
|
|
|
VARIANT_BOOL isResolving )
|
2005-08-02 13:29:04 +02:00
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2007-02-18 19:37:18 +01:00
|
|
|
|
2010-02-17 07:40:40 +01:00
|
|
|
TRACE("(%p)->(%d)\n", This, isResolving);
|
2007-02-18 19:37:18 +01:00
|
|
|
This->resolving = isResolving;
|
|
|
|
return S_OK;
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_get_preserveWhiteSpace(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
VARIANT_BOOL* isPreserving )
|
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2007-02-18 19:37:18 +01:00
|
|
|
|
2010-02-17 07:40:40 +01:00
|
|
|
TRACE("(%p)->(%p: %d)\n", This, isPreserving, This->preserving);
|
2007-02-18 19:37:18 +01:00
|
|
|
*isPreserving = This->preserving;
|
|
|
|
return S_OK;
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_put_preserveWhiteSpace(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
VARIANT_BOOL isPreserving )
|
|
|
|
{
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
2007-02-18 19:37:18 +01:00
|
|
|
|
2010-02-17 07:40:40 +01:00
|
|
|
TRACE("(%p)->(%d)\n", This, isPreserving);
|
2007-02-18 19:37:18 +01:00
|
|
|
This->preserving = isPreserving;
|
|
|
|
return S_OK;
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_put_onReadyStateChange(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
VARIANT readyStateChangeSink )
|
|
|
|
{
|
2010-02-17 07:40:40 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
|
|
|
FIXME("%p\n", This);
|
2005-08-02 13:29:04 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_put_onDataAvailable(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
VARIANT onDataAvailableSink )
|
|
|
|
{
|
2010-02-17 07:40:40 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
|
|
|
FIXME("%p\n", This);
|
2005-08-02 13:29:04 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_put_onTransformNode(
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMDocument2 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
VARIANT onTransformNodeSink )
|
|
|
|
{
|
2010-02-17 07:40:40 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
|
|
|
FIXME("%p\n", This);
|
2005-08-02 13:29:04 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2007-02-26 13:49:12 +01:00
|
|
|
static HRESULT WINAPI domdoc_get_namespaces(
|
2007-02-27 16:11:13 +01:00
|
|
|
IXMLDOMDocument2* iface,
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMSchemaCollection** schemaCollection )
|
|
|
|
{
|
2010-02-17 07:40:40 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
|
|
|
FIXME("(%p)->(%p)\n", This, schemaCollection);
|
2007-02-26 13:49:12 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_get_schemas(
|
2007-02-27 16:11:13 +01:00
|
|
|
IXMLDOMDocument2* iface,
|
2007-02-26 13:49:12 +01:00
|
|
|
VARIANT* var1 )
|
|
|
|
{
|
2007-02-27 16:11:13 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
|
|
|
HRESULT hr = S_FALSE;
|
|
|
|
IXMLDOMSchemaCollection *cur_schema = This->schema;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, var1);
|
|
|
|
|
|
|
|
VariantInit(var1); /* Test shows we don't call VariantClear here */
|
|
|
|
V_VT(var1) = VT_NULL;
|
|
|
|
|
|
|
|
if(cur_schema)
|
|
|
|
{
|
|
|
|
hr = IXMLDOMSchemaCollection_QueryInterface(cur_schema, &IID_IDispatch, (void**)&V_DISPATCH(var1));
|
|
|
|
if(SUCCEEDED(hr))
|
|
|
|
V_VT(var1) = VT_DISPATCH;
|
|
|
|
}
|
|
|
|
return hr;
|
2007-02-26 13:49:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_putref_schemas(
|
2007-02-27 16:11:13 +01:00
|
|
|
IXMLDOMDocument2* iface,
|
2007-02-26 13:49:12 +01:00
|
|
|
VARIANT var1)
|
|
|
|
{
|
2007-02-27 16:11:13 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
|
|
|
HRESULT hr = E_FAIL;
|
|
|
|
IXMLDOMSchemaCollection *new_schema = NULL;
|
|
|
|
|
|
|
|
FIXME("(%p): semi-stub\n", This);
|
|
|
|
switch(V_VT(&var1))
|
|
|
|
{
|
|
|
|
case VT_UNKNOWN:
|
|
|
|
hr = IUnknown_QueryInterface(V_UNKNOWN(&var1), &IID_IXMLDOMSchemaCollection, (void**)&new_schema);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VT_DISPATCH:
|
|
|
|
hr = IDispatch_QueryInterface(V_DISPATCH(&var1), &IID_IXMLDOMSchemaCollection, (void**)&new_schema);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VT_NULL:
|
|
|
|
case VT_EMPTY:
|
|
|
|
hr = S_OK;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
WARN("Can't get schema from vt %x\n", V_VT(&var1));
|
|
|
|
}
|
|
|
|
|
|
|
|
if(SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
IXMLDOMSchemaCollection *old_schema = InterlockedExchangePointer((void**)&This->schema, new_schema);
|
|
|
|
if(old_schema) IXMLDOMSchemaCollection_Release(old_schema);
|
|
|
|
}
|
|
|
|
|
|
|
|
return hr;
|
2007-02-26 13:49:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_validate(
|
2007-02-27 16:11:13 +01:00
|
|
|
IXMLDOMDocument2* iface,
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMParseError** err)
|
|
|
|
{
|
2010-02-17 07:40:40 +01:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
|
|
|
FIXME("(%p)->(%p)\n", This, err);
|
2007-02-26 13:49:12 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_setProperty(
|
2007-02-27 16:11:13 +01:00
|
|
|
IXMLDOMDocument2* iface,
|
2007-02-26 13:49:12 +01:00
|
|
|
BSTR p,
|
|
|
|
VARIANT var)
|
|
|
|
{
|
2007-05-09 20:09:11 +02:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
|
|
|
|
2010-02-17 07:40:40 +01:00
|
|
|
TRACE("(%p)->(%s)\n", This, debugstr_w(p));
|
|
|
|
|
2007-05-09 20:09:11 +02:00
|
|
|
if (lstrcmpiW(p, SZ_PROPERTY_SELECTION_LANGUAGE) == 0)
|
|
|
|
{
|
|
|
|
VARIANT varStr;
|
|
|
|
HRESULT hr;
|
|
|
|
BSTR bstr;
|
|
|
|
|
|
|
|
V_VT(&varStr) = VT_EMPTY;
|
|
|
|
if (V_VT(&var) != VT_BSTR)
|
|
|
|
{
|
|
|
|
if (FAILED(hr = VariantChangeType(&varStr, &var, 0, VT_BSTR)))
|
|
|
|
return hr;
|
|
|
|
bstr = V_BSTR(&varStr);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
bstr = V_BSTR(&var);
|
|
|
|
|
|
|
|
hr = S_OK;
|
|
|
|
if (lstrcmpiW(bstr, SZ_VALUE_XPATH) == 0)
|
|
|
|
This->bUseXPath = TRUE;
|
|
|
|
else if (lstrcmpiW(bstr, SZ_VALUE_XSLPATTERN) == 0)
|
|
|
|
This->bUseXPath = FALSE;
|
|
|
|
else
|
|
|
|
hr = E_FAIL;
|
|
|
|
|
|
|
|
VariantClear(&varStr);
|
|
|
|
return hr;
|
|
|
|
}
|
2010-07-27 15:32:51 +02:00
|
|
|
else if (lstrcmpiW(p, SZ_PROPERTY_PROHIBIT_DTD) == 0)
|
|
|
|
{
|
|
|
|
/* Ignore */
|
|
|
|
FIXME("Ignoring property ProhibitDTD, value %d\n", V_BOOL(&var));
|
|
|
|
return S_OK;
|
|
|
|
}
|
2007-05-09 20:09:11 +02:00
|
|
|
|
|
|
|
FIXME("Unknown property %s\n", wine_dbgstr_w(p));
|
|
|
|
return E_FAIL;
|
2007-02-26 13:49:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_getProperty(
|
2007-02-27 16:11:13 +01:00
|
|
|
IXMLDOMDocument2* iface,
|
2007-02-26 13:49:12 +01:00
|
|
|
BSTR p,
|
|
|
|
VARIANT* var)
|
|
|
|
{
|
2007-05-09 20:09:11 +02:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument2( iface );
|
|
|
|
|
2010-02-17 07:40:40 +01:00
|
|
|
TRACE("(%p)->(%p)\n", This, debugstr_w(p));
|
|
|
|
|
2007-05-09 20:09:11 +02:00
|
|
|
if (var == NULL)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
if (lstrcmpiW(p, SZ_PROPERTY_SELECTION_LANGUAGE) == 0)
|
|
|
|
{
|
|
|
|
V_VT(var) = VT_BSTR;
|
|
|
|
if (This->bUseXPath)
|
|
|
|
V_BSTR(var) = SysAllocString(SZ_VALUE_XPATH);
|
|
|
|
else
|
|
|
|
V_BSTR(var) = SysAllocString(SZ_VALUE_XSLPATTERN);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
FIXME("Unknown property %s\n", wine_dbgstr_w(p));
|
|
|
|
return E_FAIL;
|
2007-02-26 13:49:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static const struct IXMLDOMDocument2Vtbl domdoc_vtbl =
|
2005-08-02 13:29:04 +02:00
|
|
|
{
|
|
|
|
domdoc_QueryInterface,
|
|
|
|
domdoc_AddRef,
|
|
|
|
domdoc_Release,
|
|
|
|
domdoc_GetTypeInfoCount,
|
|
|
|
domdoc_GetTypeInfo,
|
|
|
|
domdoc_GetIDsOfNames,
|
|
|
|
domdoc_Invoke,
|
|
|
|
domdoc_get_nodeName,
|
|
|
|
domdoc_get_nodeValue,
|
|
|
|
domdoc_put_nodeValue,
|
|
|
|
domdoc_get_nodeType,
|
|
|
|
domdoc_get_parentNode,
|
|
|
|
domdoc_get_childNodes,
|
|
|
|
domdoc_get_firstChild,
|
|
|
|
domdoc_get_lastChild,
|
|
|
|
domdoc_get_previousSibling,
|
|
|
|
domdoc_get_nextSibling,
|
|
|
|
domdoc_get_attributes,
|
|
|
|
domdoc_insertBefore,
|
|
|
|
domdoc_replaceChild,
|
|
|
|
domdoc_removeChild,
|
|
|
|
domdoc_appendChild,
|
|
|
|
domdoc_hasChildNodes,
|
|
|
|
domdoc_get_ownerDocument,
|
|
|
|
domdoc_cloneNode,
|
|
|
|
domdoc_get_nodeTypeString,
|
|
|
|
domdoc_get_text,
|
|
|
|
domdoc_put_text,
|
|
|
|
domdoc_get_specified,
|
|
|
|
domdoc_get_definition,
|
|
|
|
domdoc_get_nodeTypedValue,
|
|
|
|
domdoc_put_nodeTypedValue,
|
|
|
|
domdoc_get_dataType,
|
|
|
|
domdoc_put_dataType,
|
|
|
|
domdoc_get_xml,
|
|
|
|
domdoc_transformNode,
|
|
|
|
domdoc_selectNodes,
|
|
|
|
domdoc_selectSingleNode,
|
|
|
|
domdoc_get_parsed,
|
|
|
|
domdoc_get_namespaceURI,
|
|
|
|
domdoc_get_prefix,
|
|
|
|
domdoc_get_baseName,
|
|
|
|
domdoc_transformNodeToObject,
|
|
|
|
domdoc_get_doctype,
|
|
|
|
domdoc_get_implementation,
|
|
|
|
domdoc_get_documentElement,
|
2008-07-08 20:54:16 +02:00
|
|
|
domdoc_put_documentElement,
|
2005-08-02 13:29:04 +02:00
|
|
|
domdoc_createElement,
|
|
|
|
domdoc_createDocumentFragment,
|
|
|
|
domdoc_createTextNode,
|
|
|
|
domdoc_createComment,
|
|
|
|
domdoc_createCDATASection,
|
|
|
|
domdoc_createProcessingInstruction,
|
|
|
|
domdoc_createAttribute,
|
|
|
|
domdoc_createEntityReference,
|
|
|
|
domdoc_getElementsByTagName,
|
|
|
|
domdoc_createNode,
|
|
|
|
domdoc_nodeFromID,
|
|
|
|
domdoc_load,
|
|
|
|
domdoc_get_readyState,
|
|
|
|
domdoc_get_parseError,
|
|
|
|
domdoc_get_url,
|
|
|
|
domdoc_get_async,
|
|
|
|
domdoc_put_async,
|
|
|
|
domdoc_abort,
|
|
|
|
domdoc_loadXML,
|
|
|
|
domdoc_save,
|
|
|
|
domdoc_get_validateOnParse,
|
|
|
|
domdoc_put_validateOnParse,
|
|
|
|
domdoc_get_resolveExternals,
|
|
|
|
domdoc_put_resolveExternals,
|
|
|
|
domdoc_get_preserveWhiteSpace,
|
|
|
|
domdoc_put_preserveWhiteSpace,
|
|
|
|
domdoc_put_onReadyStateChange,
|
|
|
|
domdoc_put_onDataAvailable,
|
|
|
|
domdoc_put_onTransformNode,
|
2007-02-26 13:49:12 +01:00
|
|
|
domdoc_get_namespaces,
|
|
|
|
domdoc_get_schemas,
|
|
|
|
domdoc_putref_schemas,
|
|
|
|
domdoc_validate,
|
|
|
|
domdoc_setProperty,
|
|
|
|
domdoc_getProperty
|
2005-08-02 13:29:04 +02:00
|
|
|
};
|
|
|
|
|
2008-04-26 14:55:05 +02:00
|
|
|
/* xmldoc implementation of IObjectWithSite */
|
|
|
|
static HRESULT WINAPI
|
|
|
|
xmldoc_ObjectWithSite_QueryInterface( IObjectWithSite* iface, REFIID riid, void** ppvObject )
|
|
|
|
{
|
|
|
|
domdoc *This = impl_from_IObjectWithSite(iface);
|
|
|
|
return IXMLDocument_QueryInterface( (IXMLDocument *)This, riid, ppvObject );
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI
|
|
|
|
xmldoc_ObjectWithSite_AddRef( IObjectWithSite* iface )
|
|
|
|
{
|
|
|
|
domdoc *This = impl_from_IObjectWithSite(iface);
|
|
|
|
return IXMLDocument_AddRef((IXMLDocument *)This);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI
|
|
|
|
xmldoc_ObjectWithSite_Release( IObjectWithSite* iface )
|
|
|
|
{
|
|
|
|
domdoc *This = impl_from_IObjectWithSite(iface);
|
|
|
|
return IXMLDocument_Release((IXMLDocument *)This);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
xmldoc_GetSite( IObjectWithSite *iface, REFIID iid, void ** ppvSite )
|
|
|
|
{
|
|
|
|
domdoc *This = impl_from_IObjectWithSite(iface);
|
|
|
|
|
2010-02-17 07:40:40 +01:00
|
|
|
TRACE("(%p)->(%s %p)\n", This, debugstr_guid( iid ), ppvSite );
|
2008-04-26 14:55:05 +02:00
|
|
|
|
|
|
|
if ( !This->site )
|
|
|
|
return E_FAIL;
|
|
|
|
|
|
|
|
return IUnknown_QueryInterface( This->site, iid, ppvSite );
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI
|
|
|
|
xmldoc_SetSite( IObjectWithSite *iface, IUnknown *punk )
|
|
|
|
{
|
|
|
|
domdoc *This = impl_from_IObjectWithSite(iface);
|
|
|
|
|
2010-02-17 07:40:40 +01:00
|
|
|
TRACE("(%p)->(%p)\n", iface, punk);
|
2008-04-26 14:55:05 +02:00
|
|
|
|
|
|
|
if(!punk)
|
|
|
|
{
|
|
|
|
if(This->site)
|
|
|
|
{
|
|
|
|
IUnknown_Release( This->site );
|
|
|
|
This->site = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2010-05-20 01:15:22 +02:00
|
|
|
IUnknown_AddRef( punk );
|
2008-04-26 14:55:05 +02:00
|
|
|
|
|
|
|
if(This->site)
|
|
|
|
IUnknown_Release( This->site );
|
|
|
|
|
|
|
|
This->site = punk;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IObjectWithSiteVtbl domdocObjectSite =
|
|
|
|
{
|
|
|
|
xmldoc_ObjectWithSite_QueryInterface,
|
|
|
|
xmldoc_ObjectWithSite_AddRef,
|
|
|
|
xmldoc_ObjectWithSite_Release,
|
|
|
|
xmldoc_SetSite,
|
|
|
|
xmldoc_GetSite,
|
|
|
|
};
|
|
|
|
|
2008-04-29 12:52:00 +02:00
|
|
|
static HRESULT WINAPI xmldoc_Safety_QueryInterface(IObjectSafety *iface, REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
domdoc *This = impl_from_IObjectSafety(iface);
|
|
|
|
return IXMLDocument_QueryInterface( (IXMLDocument *)This, riid, ppv );
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI xmldoc_Safety_AddRef(IObjectSafety *iface)
|
|
|
|
{
|
|
|
|
domdoc *This = impl_from_IObjectSafety(iface);
|
|
|
|
return IXMLDocument_AddRef((IXMLDocument *)This);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI xmldoc_Safety_Release(IObjectSafety *iface)
|
|
|
|
{
|
|
|
|
domdoc *This = impl_from_IObjectSafety(iface);
|
|
|
|
return IXMLDocument_Release((IXMLDocument *)This);
|
|
|
|
}
|
|
|
|
|
2010-02-28 22:24:47 +01:00
|
|
|
#define SAFETY_SUPPORTED_OPTIONS (INTERFACESAFE_FOR_UNTRUSTED_CALLER|INTERFACESAFE_FOR_UNTRUSTED_DATA|INTERFACE_USES_SECURITY_MANAGER)
|
2008-04-29 12:52:00 +02:00
|
|
|
|
|
|
|
static HRESULT WINAPI xmldoc_Safety_GetInterfaceSafetyOptions(IObjectSafety *iface, REFIID riid,
|
|
|
|
DWORD *pdwSupportedOptions, DWORD *pdwEnabledOptions)
|
|
|
|
{
|
|
|
|
domdoc *This = impl_from_IObjectSafety(iface);
|
|
|
|
|
|
|
|
TRACE("(%p)->(%s %p %p)\n", This, debugstr_guid(riid), pdwSupportedOptions, pdwEnabledOptions);
|
|
|
|
|
|
|
|
if(!pdwSupportedOptions || !pdwEnabledOptions)
|
|
|
|
return E_POINTER;
|
|
|
|
|
2010-02-19 11:46:16 +01:00
|
|
|
*pdwSupportedOptions = SAFETY_SUPPORTED_OPTIONS;
|
2008-04-29 12:52:00 +02:00
|
|
|
*pdwEnabledOptions = This->safeopt;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI xmldoc_Safety_SetInterfaceSafetyOptions(IObjectSafety *iface, REFIID riid,
|
|
|
|
DWORD dwOptionSetMask, DWORD dwEnabledOptions)
|
|
|
|
{
|
|
|
|
domdoc *This = impl_from_IObjectSafety(iface);
|
|
|
|
TRACE("(%p)->(%s %x %x)\n", This, debugstr_guid(riid), dwOptionSetMask, dwEnabledOptions);
|
|
|
|
|
2010-02-28 22:24:47 +01:00
|
|
|
if ((dwOptionSetMask & ~SAFETY_SUPPORTED_OPTIONS) != 0)
|
|
|
|
return E_FAIL;
|
|
|
|
|
2010-02-19 11:46:16 +01:00
|
|
|
This->safeopt = dwEnabledOptions & dwOptionSetMask & SAFETY_SUPPORTED_OPTIONS;
|
2008-04-29 12:52:00 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IObjectSafetyVtbl domdocObjectSafetyVtbl = {
|
|
|
|
xmldoc_Safety_QueryInterface,
|
|
|
|
xmldoc_Safety_AddRef,
|
|
|
|
xmldoc_Safety_Release,
|
|
|
|
xmldoc_Safety_GetInterfaceSafetyOptions,
|
|
|
|
xmldoc_Safety_SetInterfaceSafetyOptions
|
|
|
|
};
|
|
|
|
|
2008-09-03 02:23:10 +02:00
|
|
|
|
|
|
|
static const tid_t domdoc_iface_tids[] = {
|
|
|
|
IXMLDOMNode_tid,
|
|
|
|
IXMLDOMDocument_tid,
|
|
|
|
IXMLDOMDocument2_tid,
|
|
|
|
0
|
|
|
|
};
|
|
|
|
static dispex_static_data_t domdoc_dispex = {
|
|
|
|
NULL,
|
|
|
|
IXMLDOMDocument2_tid,
|
|
|
|
NULL,
|
|
|
|
domdoc_iface_tids
|
|
|
|
};
|
|
|
|
|
2008-07-08 20:55:47 +02:00
|
|
|
HRESULT DOMDocument_create_from_xmldoc(xmlDocPtr xmldoc, IXMLDOMDocument2 **document)
|
2005-08-02 13:29:04 +02:00
|
|
|
{
|
|
|
|
domdoc *doc;
|
|
|
|
|
2010-02-03 20:47:53 +01:00
|
|
|
doc = heap_alloc( sizeof (*doc) );
|
2005-08-02 13:29:04 +02:00
|
|
|
if( !doc )
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
doc->lpVtbl = &domdoc_vtbl;
|
2010-06-28 19:16:43 +02:00
|
|
|
doc->lpvtblIPersistStreamInit = &xmldoc_IPersistStreamInit_VTable;
|
2008-04-26 14:55:05 +02:00
|
|
|
doc->lpvtblIObjectWithSite = &domdocObjectSite;
|
2008-04-29 12:52:00 +02:00
|
|
|
doc->lpvtblIObjectSafety = &domdocObjectSafetyVtbl;
|
2008-12-19 09:48:58 +01:00
|
|
|
doc->lpvtblISupportErrorInfo = &support_error_vtbl;
|
2005-08-02 13:29:04 +02:00
|
|
|
doc->ref = 1;
|
2009-01-21 11:58:31 +01:00
|
|
|
doc->async = VARIANT_TRUE;
|
2007-02-18 19:37:18 +01:00
|
|
|
doc->validating = 0;
|
|
|
|
doc->resolving = 0;
|
|
|
|
doc->preserving = 0;
|
2007-05-09 20:09:11 +02:00
|
|
|
doc->bUseXPath = FALSE;
|
2006-02-21 12:52:25 +01:00
|
|
|
doc->error = S_OK;
|
2007-02-27 16:11:13 +01:00
|
|
|
doc->schema = NULL;
|
2007-12-09 23:31:38 +01:00
|
|
|
doc->stream = NULL;
|
2008-04-26 14:55:05 +02:00
|
|
|
doc->site = NULL;
|
2008-04-29 12:52:00 +02:00
|
|
|
doc->safeopt = 0;
|
2008-07-08 20:55:03 +02:00
|
|
|
doc->bsc = NULL;
|
2005-12-01 18:46:42 +01:00
|
|
|
|
2009-10-14 20:01:42 +02:00
|
|
|
init_xmlnode(&doc->node, (xmlNodePtr)xmldoc, (IUnknown*)&doc->lpVtbl, &domdoc_dispex);
|
2005-12-01 18:46:42 +01:00
|
|
|
|
2008-07-08 20:55:47 +02:00
|
|
|
*document = (IXMLDOMDocument2*)&doc->lpVtbl;
|
2005-08-02 13:29:04 +02:00
|
|
|
|
2008-07-08 20:55:47 +02:00
|
|
|
TRACE("returning iface %p\n", *document);
|
2005-08-02 13:29:04 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2008-07-08 20:55:47 +02:00
|
|
|
HRESULT DOMDocument_create(IUnknown *pUnkOuter, LPVOID *ppObj)
|
|
|
|
{
|
|
|
|
xmlDocPtr xmldoc;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("(%p,%p)\n", pUnkOuter, ppObj);
|
|
|
|
|
|
|
|
xmldoc = xmlNewDoc(NULL);
|
|
|
|
if(!xmldoc)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
2008-10-11 23:59:12 +02:00
|
|
|
xmldoc->_private = create_priv();
|
2008-07-08 20:55:47 +02:00
|
|
|
|
|
|
|
hr = DOMDocument_create_from_xmldoc(xmldoc, (IXMLDOMDocument2**)ppObj);
|
|
|
|
if(FAILED(hr))
|
|
|
|
xmlFreeDoc(xmldoc);
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2008-07-16 14:13:18 +02:00
|
|
|
IUnknown* create_domdoc( xmlNodePtr document )
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
LPVOID pObj = NULL;
|
|
|
|
|
|
|
|
TRACE("(%p)\n", document);
|
|
|
|
|
|
|
|
hr = DOMDocument_create_from_xmldoc((xmlDocPtr)document, (IXMLDOMDocument2**)&pObj);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return NULL;
|
|
|
|
|
2009-01-26 11:01:02 +01:00
|
|
|
return pObj;
|
2008-07-16 14:13:18 +02:00
|
|
|
}
|
|
|
|
|
2005-08-02 13:29:04 +02:00
|
|
|
#else
|
|
|
|
|
|
|
|
HRESULT DOMDocument_create(IUnknown *pUnkOuter, LPVOID *ppObj)
|
|
|
|
{
|
|
|
|
MESSAGE("This program tried to use a DOMDocument object, but\n"
|
|
|
|
"libxml2 support was not present at compile time.\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|