2005-08-02 13:29:04 +02:00
|
|
|
/*
|
|
|
|
* DOM Document implementation
|
|
|
|
*
|
|
|
|
* Copyright 2005 Mike McCormack
|
2011-05-04 22:38:03 +02:00
|
|
|
* Copyright 2010-2011 Adam Martinson for CodeWeavers
|
2005-08-02 13:29:04 +02:00
|
|
|
*
|
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
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
2005-12-01 18:46:42 +01:00
|
|
|
#include <assert.h>
|
2011-02-24 13:11:53 +01:00
|
|
|
#ifdef HAVE_LIBXML2
|
|
|
|
# include <libxml/parser.h>
|
|
|
|
# include <libxml/xmlerror.h>
|
|
|
|
# include <libxml/xpathInternals.h>
|
|
|
|
# include <libxml/xmlsave.h>
|
|
|
|
# include <libxml/SAX2.h>
|
|
|
|
# include <libxml/parserInternals.h>
|
|
|
|
#endif
|
|
|
|
|
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"
|
2010-10-23 15:22:35 +02:00
|
|
|
#include "olectl.h"
|
2010-08-29 23:31:49 +02:00
|
|
|
#include "msxml6.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"
|
2005-08-02 13:29:04 +02:00
|
|
|
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
#include "msxml_private.h"
|
|
|
|
|
|
|
|
#ifdef HAVE_LIBXML2
|
|
|
|
|
2015-02-21 14:58:41 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(msxml);
|
|
|
|
|
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
|
|
|
|
|
2010-08-29 23:33:54 +02:00
|
|
|
static const WCHAR PropertySelectionLanguageW[] = {'S','e','l','e','c','t','i','o','n','L','a','n','g','u','a','g','e',0};
|
|
|
|
static const WCHAR PropertySelectionNamespacesW[] = {'S','e','l','e','c','t','i','o','n','N','a','m','e','s','p','a','c','e','s',0};
|
|
|
|
static const WCHAR PropertyProhibitDTDW[] = {'P','r','o','h','i','b','i','t','D','T','D',0};
|
2010-10-05 21:56:15 +02:00
|
|
|
static const WCHAR PropertyNewParserW[] = {'N','e','w','P','a','r','s','e','r',0};
|
2010-08-29 23:33:54 +02:00
|
|
|
static const WCHAR PropValueXPathW[] = {'X','P','a','t','h',0};
|
|
|
|
static const WCHAR PropValueXSLPatternW[] = {'X','S','L','P','a','t','t','e','r','n',0};
|
2011-03-11 01:32:32 +01:00
|
|
|
static const WCHAR PropertyResolveExternalsW[] = {'R','e','s','o','l','v','e','E','x','t','e','r','n','a','l','s',0};
|
2007-05-09 20:09:11 +02:00
|
|
|
|
2010-11-16 01:15:24 +01:00
|
|
|
/* Anything that passes the test_get_ownerDocument()
|
|
|
|
* tests can go here (data shared between all instances).
|
2010-09-28 02:59:51 +02:00
|
|
|
* We need to preserve this when reloading a document,
|
|
|
|
* and also need access to it from the libxml backend. */
|
2011-12-17 23:21:09 +01:00
|
|
|
typedef struct {
|
2010-11-24 20:53:47 +01:00
|
|
|
MSXML_VERSION version;
|
2010-11-03 22:13:45 +01:00
|
|
|
VARIANT_BOOL preserving;
|
2010-11-16 01:15:24 +01:00
|
|
|
IXMLDOMSchemaCollection2* schemaCache;
|
2010-09-28 02:59:51 +02:00
|
|
|
struct list selectNsList;
|
|
|
|
xmlChar const* selectNsStr;
|
|
|
|
LONG selectNsStr_len;
|
|
|
|
BOOL XPath;
|
2013-12-16 15:52:09 +01:00
|
|
|
WCHAR *url;
|
2010-09-28 02:59:51 +02:00
|
|
|
} domdoc_properties;
|
|
|
|
|
2010-10-23 15:22:35 +02:00
|
|
|
typedef struct ConnectionPoint ConnectionPoint;
|
|
|
|
typedef struct domdoc domdoc;
|
|
|
|
|
|
|
|
struct ConnectionPoint
|
|
|
|
{
|
2011-04-26 23:47:48 +02:00
|
|
|
IConnectionPoint IConnectionPoint_iface;
|
2010-10-23 15:22:35 +02:00
|
|
|
const IID *iid;
|
|
|
|
|
|
|
|
ConnectionPoint *next;
|
|
|
|
IConnectionPointContainer *container;
|
|
|
|
domdoc *doc;
|
2010-10-23 15:40:06 +02:00
|
|
|
|
|
|
|
union
|
|
|
|
{
|
|
|
|
IUnknown *unk;
|
|
|
|
IDispatch *disp;
|
|
|
|
IPropertyNotifySink *propnotif;
|
|
|
|
} *sinks;
|
|
|
|
DWORD sinks_size;
|
2010-10-23 15:22:35 +02:00
|
|
|
};
|
|
|
|
|
2011-02-19 15:09:58 +01:00
|
|
|
typedef enum {
|
|
|
|
EVENTID_READYSTATECHANGE = 0,
|
|
|
|
EVENTID_DATAAVAILABLE,
|
|
|
|
EVENTID_TRANSFORMNODE,
|
|
|
|
EVENTID_LAST
|
|
|
|
} eventid_t;
|
|
|
|
|
2010-10-23 15:22:35 +02:00
|
|
|
struct domdoc
|
2008-07-08 20:55:03 +02:00
|
|
|
{
|
2009-10-14 20:01:42 +02:00
|
|
|
xmlnode node;
|
2011-04-26 23:47:48 +02:00
|
|
|
IXMLDOMDocument3 IXMLDOMDocument3_iface;
|
|
|
|
IPersistStreamInit IPersistStreamInit_iface;
|
|
|
|
IObjectWithSite IObjectWithSite_iface;
|
|
|
|
IObjectSafety IObjectSafety_iface;
|
|
|
|
IConnectionPointContainer IConnectionPointContainer_iface;
|
2008-07-08 20:55:03 +02:00
|
|
|
LONG ref;
|
|
|
|
VARIANT_BOOL async;
|
|
|
|
VARIANT_BOOL validating;
|
|
|
|
VARIANT_BOOL resolving;
|
2010-09-28 02:59:51 +02:00
|
|
|
domdoc_properties* properties;
|
2008-07-08 20:55:03 +02:00
|
|
|
HRESULT error;
|
|
|
|
|
2013-11-04 11:17:12 +01:00
|
|
|
/* IObjectWithSite */
|
2008-07-08 20:55:03 +02:00
|
|
|
IUnknown *site;
|
|
|
|
|
|
|
|
/* IObjectSafety */
|
|
|
|
DWORD safeopt;
|
2010-10-23 15:22:35 +02:00
|
|
|
|
|
|
|
/* connection list */
|
|
|
|
ConnectionPoint *cp_list;
|
|
|
|
ConnectionPoint cp_domdocevents;
|
|
|
|
ConnectionPoint cp_propnotif;
|
|
|
|
ConnectionPoint cp_dispatch;
|
2011-02-19 15:09:58 +01:00
|
|
|
|
|
|
|
/* events */
|
|
|
|
IDispatch *events[EVENTID_LAST];
|
2012-01-24 08:40:56 +01:00
|
|
|
|
|
|
|
IXMLDOMSchemaCollection2 *namespaces;
|
2010-10-23 15:22:35 +02:00
|
|
|
};
|
|
|
|
|
2011-02-19 15:09:58 +01:00
|
|
|
static HRESULT set_doc_event(domdoc *doc, eventid_t eid, const VARIANT *v)
|
|
|
|
{
|
|
|
|
IDispatch *disp;
|
|
|
|
|
|
|
|
switch (V_VT(v))
|
|
|
|
{
|
|
|
|
case VT_UNKNOWN:
|
|
|
|
if (V_UNKNOWN(v))
|
|
|
|
IUnknown_QueryInterface(V_UNKNOWN(v), &IID_IDispatch, (void**)&disp);
|
|
|
|
else
|
|
|
|
disp = NULL;
|
|
|
|
break;
|
|
|
|
case VT_DISPATCH:
|
|
|
|
disp = V_DISPATCH(v);
|
|
|
|
if (disp) IDispatch_AddRef(disp);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return DISP_E_TYPEMISMATCH;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (doc->events[eid]) IDispatch_Release(doc->events[eid]);
|
|
|
|
doc->events[eid] = disp;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2010-10-23 15:22:35 +02:00
|
|
|
static inline ConnectionPoint *impl_from_IConnectionPoint(IConnectionPoint *iface)
|
|
|
|
{
|
2011-04-26 23:47:48 +02:00
|
|
|
return CONTAINING_RECORD(iface, ConnectionPoint, IConnectionPoint_iface);
|
2010-10-23 15:22:35 +02:00
|
|
|
}
|
2008-07-08 20:55:03 +02:00
|
|
|
|
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;
|
2010-09-28 02:59:51 +02:00
|
|
|
domdoc_properties* properties;
|
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;
|
|
|
|
|
2010-09-28 21:35:48 +02:00
|
|
|
typedef struct _select_ns_entry {
|
|
|
|
struct list entry;
|
|
|
|
xmlChar const* prefix;
|
|
|
|
xmlChar prefix_end;
|
|
|
|
xmlChar const* href;
|
|
|
|
xmlChar href_end;
|
|
|
|
} select_ns_entry;
|
|
|
|
|
2010-09-16 21:59:32 +02:00
|
|
|
static inline xmldoc_priv * priv_from_xmlDocPtr(const xmlDocPtr doc)
|
2008-10-11 23:59:12 +02:00
|
|
|
{
|
|
|
|
return doc->_private;
|
|
|
|
}
|
|
|
|
|
2010-09-28 02:59:51 +02:00
|
|
|
static inline domdoc_properties * properties_from_xmlDocPtr(xmlDocPtr doc)
|
2010-09-16 21:59:32 +02:00
|
|
|
{
|
2010-09-28 02:59:51 +02:00
|
|
|
return priv_from_xmlDocPtr(doc)->properties;
|
2010-09-16 21:59:32 +02:00
|
|
|
}
|
|
|
|
|
2010-09-30 22:06:01 +02:00
|
|
|
BOOL is_xpathmode(const xmlDocPtr doc)
|
2010-09-16 21:59:32 +02:00
|
|
|
{
|
2010-09-28 02:59:51 +02:00
|
|
|
return properties_from_xmlDocPtr(doc)->XPath;
|
2010-09-16 21:59:32 +02:00
|
|
|
}
|
|
|
|
|
2010-11-23 03:59:20 +01:00
|
|
|
void set_xpathmode(xmlDocPtr doc, BOOL xpath)
|
|
|
|
{
|
|
|
|
properties_from_xmlDocPtr(doc)->XPath = xpath;
|
|
|
|
}
|
|
|
|
|
2010-09-28 21:35:48 +02:00
|
|
|
int registerNamespaces(xmlXPathContextPtr ctxt)
|
|
|
|
{
|
|
|
|
int n = 0;
|
|
|
|
const select_ns_entry* ns = NULL;
|
2010-09-28 02:59:51 +02:00
|
|
|
const struct list* pNsList = &properties_from_xmlDocPtr(ctxt->doc)->selectNsList;
|
2010-09-28 21:35:48 +02:00
|
|
|
|
|
|
|
TRACE("(%p)\n", ctxt);
|
|
|
|
|
|
|
|
LIST_FOR_EACH_ENTRY( ns, pNsList, select_ns_entry, entry )
|
|
|
|
{
|
|
|
|
xmlXPathRegisterNs(ctxt, ns->prefix, ns->href);
|
|
|
|
++n;
|
|
|
|
}
|
|
|
|
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
|
2010-09-28 02:59:51 +02:00
|
|
|
static inline void clear_selectNsList(struct list* pNsList)
|
|
|
|
{
|
|
|
|
select_ns_entry *ns, *ns2;
|
|
|
|
LIST_FOR_EACH_ENTRY_SAFE( ns, ns2, pNsList, select_ns_entry, entry )
|
|
|
|
{
|
|
|
|
heap_free( ns );
|
|
|
|
}
|
|
|
|
list_init(pNsList);
|
|
|
|
}
|
|
|
|
|
2008-10-11 23:59:12 +02:00
|
|
|
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
|
|
|
|
2010-09-16 21:59:32 +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 );
|
2010-09-28 02:59:51 +02:00
|
|
|
priv->properties = NULL;
|
2008-10-11 23:59:19 +02:00
|
|
|
}
|
2008-10-11 23:59:12 +02:00
|
|
|
|
|
|
|
return priv;
|
|
|
|
}
|
|
|
|
|
2011-12-17 23:21:09 +01:00
|
|
|
static domdoc_properties *create_properties(MSXML_VERSION version)
|
2010-09-28 02:59:51 +02:00
|
|
|
{
|
|
|
|
domdoc_properties *properties = heap_alloc(sizeof(domdoc_properties));
|
|
|
|
|
2010-11-24 20:53:47 +01:00
|
|
|
list_init(&properties->selectNsList);
|
2010-11-03 22:13:45 +01:00
|
|
|
properties->preserving = VARIANT_FALSE;
|
2010-11-16 01:15:24 +01:00
|
|
|
properties->schemaCache = NULL;
|
2010-09-28 02:59:51 +02:00
|
|
|
properties->selectNsStr = heap_alloc_zero(sizeof(xmlChar));
|
|
|
|
properties->selectNsStr_len = 0;
|
|
|
|
|
|
|
|
/* properties that are dependent on object versions */
|
2011-08-24 14:00:16 +02:00
|
|
|
properties->version = version;
|
|
|
|
properties->XPath = (version == MSXML4 || version == MSXML6);
|
2010-09-28 02:59:51 +02:00
|
|
|
|
2013-12-16 15:52:09 +01:00
|
|
|
/* document url */
|
|
|
|
properties->url = NULL;
|
|
|
|
|
2010-09-28 02:59:51 +02:00
|
|
|
return properties;
|
|
|
|
}
|
|
|
|
|
|
|
|
static domdoc_properties* copy_properties(domdoc_properties const* properties)
|
|
|
|
{
|
|
|
|
domdoc_properties* pcopy = heap_alloc(sizeof(domdoc_properties));
|
|
|
|
select_ns_entry const* ns = NULL;
|
|
|
|
select_ns_entry* new_ns = NULL;
|
|
|
|
int len = (properties->selectNsStr_len+1)*sizeof(xmlChar);
|
|
|
|
ptrdiff_t offset;
|
|
|
|
|
|
|
|
if (pcopy)
|
|
|
|
{
|
2010-11-24 20:53:47 +01:00
|
|
|
pcopy->version = properties->version;
|
2010-11-03 22:13:45 +01:00
|
|
|
pcopy->preserving = properties->preserving;
|
2010-11-16 01:15:24 +01:00
|
|
|
pcopy->schemaCache = properties->schemaCache;
|
2010-11-30 17:41:19 +01:00
|
|
|
if (pcopy->schemaCache)
|
|
|
|
IXMLDOMSchemaCollection2_AddRef(pcopy->schemaCache);
|
2010-09-28 02:59:51 +02:00
|
|
|
pcopy->XPath = properties->XPath;
|
|
|
|
pcopy->selectNsStr_len = properties->selectNsStr_len;
|
|
|
|
list_init( &pcopy->selectNsList );
|
|
|
|
pcopy->selectNsStr = heap_alloc(len);
|
|
|
|
memcpy((xmlChar*)pcopy->selectNsStr, properties->selectNsStr, len);
|
|
|
|
offset = pcopy->selectNsStr - properties->selectNsStr;
|
|
|
|
|
|
|
|
LIST_FOR_EACH_ENTRY( ns, (&properties->selectNsList), select_ns_entry, entry )
|
|
|
|
{
|
|
|
|
new_ns = heap_alloc(sizeof(select_ns_entry));
|
|
|
|
memcpy(new_ns, ns, sizeof(select_ns_entry));
|
|
|
|
new_ns->href += offset;
|
|
|
|
new_ns->prefix += offset;
|
|
|
|
list_add_tail(&pcopy->selectNsList, &new_ns->entry);
|
|
|
|
}
|
|
|
|
|
2013-12-16 15:52:09 +01:00
|
|
|
if (properties->url)
|
|
|
|
{
|
|
|
|
int len = strlenW(properties->url);
|
|
|
|
|
|
|
|
pcopy->url = CoTaskMemAlloc((len+1)*sizeof(WCHAR));
|
|
|
|
memcpy(pcopy->url, properties->url, len*sizeof(WCHAR));
|
|
|
|
pcopy->url[len] = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
pcopy->url = NULL;
|
2010-09-28 02:59:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return pcopy;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void free_properties(domdoc_properties* properties)
|
|
|
|
{
|
|
|
|
if (properties)
|
|
|
|
{
|
2010-11-16 01:15:24 +01:00
|
|
|
if (properties->schemaCache)
|
|
|
|
IXMLDOMSchemaCollection2_Release(properties->schemaCache);
|
2010-09-28 02:59:51 +02:00
|
|
|
clear_selectNsList(&properties->selectNsList);
|
|
|
|
heap_free((xmlChar*)properties->selectNsStr);
|
2013-12-16 15:52:09 +01:00
|
|
|
CoTaskMemFree(properties->url);
|
2010-09-28 02:59:51 +02:00
|
|
|
heap_free(properties);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-01-24 08:40:56 +01:00
|
|
|
static void release_namespaces(domdoc *This)
|
|
|
|
{
|
|
|
|
if (This->namespaces)
|
|
|
|
{
|
|
|
|
IXMLDOMSchemaCollection2_Release(This->namespaces);
|
|
|
|
This->namespaces = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
{
|
2012-07-08 20:49:43 +02:00
|
|
|
static const xmlChar xmlA[] = "xml";
|
|
|
|
xmlNodePtr node, first_child;
|
2010-06-28 10:17:56 +02:00
|
|
|
|
|
|
|
assert(doc != NULL);
|
|
|
|
|
2012-07-08 20:49:43 +02:00
|
|
|
/* xml declaration node could be created automatically after parsing or added
|
|
|
|
to a tree later */
|
|
|
|
first_child = doc->children;
|
|
|
|
if (first_child && first_child->type == XML_PI_NODE && xmlStrEqual(first_child->name, xmlA))
|
2010-06-28 10:17:56 +02:00
|
|
|
{
|
2012-07-08 20:49:43 +02:00
|
|
|
node = first_child;
|
2010-06-28 10:17:56 +02:00
|
|
|
xmlUnlinkNode( node );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
node = NULL;
|
|
|
|
|
|
|
|
return node;
|
|
|
|
}
|
|
|
|
|
2010-11-03 22:13:45 +01:00
|
|
|
BOOL is_preserving_whitespace(xmlNodePtr node)
|
|
|
|
{
|
|
|
|
domdoc_properties* properties = NULL;
|
|
|
|
/* during parsing the xmlDoc._private stuff is not there */
|
|
|
|
if (priv_from_xmlDocPtr(node->doc))
|
|
|
|
properties = properties_from_xmlDocPtr(node->doc);
|
|
|
|
return ((properties && properties->preserving == VARIANT_TRUE) ||
|
|
|
|
xmlNodeGetSpacePreserve(node) == 1);
|
|
|
|
}
|
|
|
|
|
2010-09-30 16:49:10 +02:00
|
|
|
static inline BOOL strn_isspace(xmlChar const* str, int len)
|
|
|
|
{
|
|
|
|
for (; str && len > 0 && *str; ++str, --len)
|
|
|
|
if (!isspace(*str))
|
|
|
|
break;
|
|
|
|
|
|
|
|
return len == 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void sax_characters(void *ctx, const xmlChar *ch, int len)
|
|
|
|
{
|
2011-03-13 11:46:45 +01:00
|
|
|
xmlParserCtxtPtr ctxt;
|
|
|
|
const domdoc *This;
|
2010-09-30 16:49:10 +02:00
|
|
|
|
2011-03-13 11:46:45 +01:00
|
|
|
ctxt = (xmlParserCtxtPtr) ctx;
|
|
|
|
This = (const domdoc*) ctxt->_private;
|
2010-09-30 16:49:10 +02:00
|
|
|
|
2011-03-13 11:46:45 +01:00
|
|
|
if (ctxt->node)
|
|
|
|
{
|
2013-05-14 22:18:07 +02:00
|
|
|
xmlChar cur = *(ctxt->input->cur);
|
|
|
|
|
2013-05-05 13:44:06 +02:00
|
|
|
/* Characters are reported with multiple calls, for example each charref is reported with a separate
|
|
|
|
call and then parser appends it to a single text node or creates a new node if not created.
|
|
|
|
It's not possible to tell if it's ignorable data or not just looking at data itself cause it could be
|
2013-05-14 22:18:07 +02:00
|
|
|
space chars that separate charrefs or similar case. We only need to skip leading and trailing spaces,
|
2013-05-05 13:44:06 +02:00
|
|
|
or whole node if it has nothing but space chars, so to detect leading space node->last is checked that
|
|
|
|
contains text node pointer if already created, trailing spaces are detected directly looking at parser input
|
2013-05-14 22:18:07 +02:00
|
|
|
for next '<' opening bracket - similar logic is used by libxml2 itself. Basically 'cur' == '<' means the last
|
|
|
|
chunk of char data, in case it's not the last chunk we check for previously added node type and if it's not
|
|
|
|
a text node it's safe to ignore.
|
2013-05-05 13:44:06 +02:00
|
|
|
|
|
|
|
Note that during domdoc_loadXML() the xmlDocPtr->_private data is not available. */
|
2013-05-14 22:18:07 +02:00
|
|
|
|
2011-03-13 11:46:45 +01:00
|
|
|
if (!This->properties->preserving &&
|
|
|
|
!is_preserving_whitespace(ctxt->node) &&
|
2013-05-05 13:44:06 +02:00
|
|
|
strn_isspace(ch, len) &&
|
|
|
|
(!ctxt->node->last ||
|
2013-05-14 22:18:07 +02:00
|
|
|
((ctxt->node->last && (cur == '<' || ctxt->node->last->type != XML_TEXT_NODE))
|
|
|
|
)))
|
2011-03-13 11:46:45 +01:00
|
|
|
return;
|
|
|
|
}
|
2010-09-30 16:49:10 +02:00
|
|
|
|
2011-03-13 11:46:45 +01:00
|
|
|
xmlSAX2Characters(ctxt, ch, len);
|
2010-09-30 16:49:10 +02:00
|
|
|
}
|
|
|
|
|
2010-10-27 16:35:56 +02:00
|
|
|
static void LIBXML2_LOG_CALLBACK sax_error(void* ctx, char const* msg, ...)
|
|
|
|
{
|
|
|
|
va_list ap;
|
|
|
|
va_start(ap, msg);
|
|
|
|
LIBXML2_CALLBACK_ERR(doparse, msg, ap);
|
|
|
|
va_end(ap);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void LIBXML2_LOG_CALLBACK sax_warning(void* ctx, char const* msg, ...)
|
|
|
|
{
|
|
|
|
va_list ap;
|
|
|
|
va_start(ap, msg);
|
|
|
|
LIBXML2_CALLBACK_WARN(doparse, msg, ap);
|
|
|
|
va_end(ap);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void sax_serror(void* ctx, xmlErrorPtr err)
|
|
|
|
{
|
|
|
|
LIBXML2_CALLBACK_SERROR(doparse, err);
|
|
|
|
}
|
|
|
|
|
2011-05-20 17:05:05 +02:00
|
|
|
static xmlDocPtr doparse(domdoc* This, char const* ptr, int len, xmlCharEncoding encoding)
|
2008-07-08 20:55:10 +02:00
|
|
|
{
|
2010-10-21 00:00:21 +02:00
|
|
|
xmlDocPtr doc = NULL;
|
|
|
|
xmlParserCtxtPtr pctx;
|
2010-09-29 23:04:38 +02:00
|
|
|
static xmlSAXHandler sax_handler = {
|
|
|
|
xmlSAX2InternalSubset, /* internalSubset */
|
|
|
|
xmlSAX2IsStandalone, /* isStandalone */
|
|
|
|
xmlSAX2HasInternalSubset, /* hasInternalSubset */
|
|
|
|
xmlSAX2HasExternalSubset, /* hasExternalSubset */
|
|
|
|
xmlSAX2ResolveEntity, /* resolveEntity */
|
|
|
|
xmlSAX2GetEntity, /* getEntity */
|
|
|
|
xmlSAX2EntityDecl, /* entityDecl */
|
|
|
|
xmlSAX2NotationDecl, /* notationDecl */
|
|
|
|
xmlSAX2AttributeDecl, /* attributeDecl */
|
|
|
|
xmlSAX2ElementDecl, /* elementDecl */
|
|
|
|
xmlSAX2UnparsedEntityDecl, /* unparsedEntityDecl */
|
|
|
|
xmlSAX2SetDocumentLocator, /* setDocumentLocator */
|
|
|
|
xmlSAX2StartDocument, /* startDocument */
|
|
|
|
xmlSAX2EndDocument, /* endDocument */
|
|
|
|
xmlSAX2StartElement, /* startElement */
|
|
|
|
xmlSAX2EndElement, /* endElement */
|
|
|
|
xmlSAX2Reference, /* reference */
|
2010-09-30 16:49:10 +02:00
|
|
|
sax_characters, /* characters */
|
|
|
|
sax_characters, /* ignorableWhitespace */
|
2010-09-29 23:04:38 +02:00
|
|
|
xmlSAX2ProcessingInstruction, /* processingInstruction */
|
|
|
|
xmlSAX2Comment, /* comment */
|
2010-10-27 16:35:56 +02:00
|
|
|
sax_warning, /* warning */
|
|
|
|
sax_error, /* error */
|
|
|
|
sax_error, /* fatalError */
|
2010-09-29 23:04:38 +02:00
|
|
|
xmlSAX2GetParameterEntity, /* getParameterEntity */
|
|
|
|
xmlSAX2CDataBlock, /* cdataBlock */
|
|
|
|
xmlSAX2ExternalSubset, /* externalSubset */
|
|
|
|
0, /* initialized */
|
|
|
|
NULL, /* _private */
|
|
|
|
xmlSAX2StartElementNs, /* startElementNs */
|
|
|
|
xmlSAX2EndElementNs, /* endElementNs */
|
2010-10-27 16:35:56 +02:00
|
|
|
sax_serror /* serror */
|
2010-09-29 23:04:38 +02:00
|
|
|
};
|
2010-10-21 00:00:21 +02:00
|
|
|
|
|
|
|
pctx = xmlCreateMemoryParserCtxt(ptr, len);
|
|
|
|
if (!pctx)
|
|
|
|
{
|
|
|
|
ERR("Failed to create parser context\n");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2010-10-27 16:35:56 +02:00
|
|
|
if (pctx->sax) xmlFree(pctx->sax);
|
2010-10-21 00:00:21 +02:00
|
|
|
pctx->sax = &sax_handler;
|
2010-10-27 16:35:56 +02:00
|
|
|
pctx->_private = This;
|
2010-10-21 00:00:21 +02:00
|
|
|
pctx->recovery = 0;
|
2011-05-20 17:05:05 +02:00
|
|
|
|
|
|
|
if (encoding != XML_CHAR_ENCODING_NONE)
|
|
|
|
xmlSwitchEncoding(pctx, encoding);
|
|
|
|
|
2010-10-21 00:00:21 +02:00
|
|
|
xmlParseDocument(pctx);
|
2010-09-29 23:04:38 +02:00
|
|
|
|
2010-10-21 00:00:21 +02:00
|
|
|
if (pctx->wellFormed)
|
|
|
|
{
|
|
|
|
doc = pctx->myDoc;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
xmlFreeDoc(pctx->myDoc);
|
|
|
|
pctx->myDoc = NULL;
|
|
|
|
}
|
|
|
|
pctx->sax = NULL;
|
|
|
|
xmlFreeParserCtxt(pctx);
|
2010-09-29 23:04:38 +02:00
|
|
|
|
|
|
|
/* TODO: put this in one of the SAX callbacks */
|
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
|
|
|
}
|
|
|
|
|
2011-08-24 14:00:16 +02:00
|
|
|
void xmldoc_init(xmlDocPtr doc, MSXML_VERSION version)
|
2010-10-15 16:25:11 +02:00
|
|
|
{
|
|
|
|
doc->_private = create_priv();
|
2011-08-24 14:00:16 +02:00
|
|
|
priv_from_xmlDocPtr(doc)->properties = create_properties(version);
|
2010-10-15 16:25:11 +02:00
|
|
|
}
|
|
|
|
|
2013-02-24 21:30:22 +01:00
|
|
|
LONG xmldoc_add_refs(xmlDocPtr doc, LONG refs)
|
2005-11-18 16:05:26 +01:00
|
|
|
{
|
2013-02-24 21:30:22 +01:00
|
|
|
LONG ref = InterlockedExchangeAdd(&priv_from_xmlDocPtr(doc)->refs, refs) + 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;
|
|
|
|
}
|
|
|
|
|
2013-02-24 21:30:22 +01:00
|
|
|
LONG xmldoc_add_ref(xmlDocPtr doc)
|
|
|
|
{
|
|
|
|
return xmldoc_add_refs(doc, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
LONG xmldoc_release_refs(xmlDocPtr doc, LONG refs)
|
2005-11-18 16:05:26 +01:00
|
|
|
{
|
2008-10-11 23:59:12 +02:00
|
|
|
xmldoc_priv *priv = priv_from_xmlDocPtr(doc);
|
2013-02-24 21:30:22 +01:00
|
|
|
LONG ref = InterlockedExchangeAdd(&priv->refs, -refs) - refs;
|
2010-06-21 11:36:13 +02:00
|
|
|
TRACE("(%p)->(%d)\n", doc, ref);
|
2013-02-24 21:30:22 +01:00
|
|
|
|
|
|
|
if (ref < 0)
|
|
|
|
WARN("negative refcount, expect troubles\n");
|
|
|
|
|
|
|
|
if (ref == 0)
|
2005-11-18 16:05:26 +01:00
|
|
|
{
|
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-09-28 02:59:51 +02:00
|
|
|
free_properties(priv->properties);
|
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;
|
|
|
|
}
|
|
|
|
|
2013-02-24 21:30:22 +01:00
|
|
|
LONG xmldoc_release(xmlDocPtr doc)
|
|
|
|
{
|
|
|
|
return xmldoc_release_refs(doc, 1);
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2010-09-28 02:59:51 +02:00
|
|
|
static inline xmlDocPtr get_doc( domdoc *This )
|
2008-11-29 10:51:58 +01:00
|
|
|
{
|
2013-02-28 19:44:02 +01:00
|
|
|
return This->node.node->doc;
|
2010-09-28 02:59:51 +02:00
|
|
|
}
|
2008-11-29 10:51:58 +01:00
|
|
|
|
2010-09-28 02:59:51 +02:00
|
|
|
static HRESULT attach_xmldoc(domdoc *This, xmlDocPtr xml )
|
|
|
|
{
|
2012-01-24 08:40:56 +01:00
|
|
|
release_namespaces(This);
|
|
|
|
|
2010-09-28 02:59:51 +02:00
|
|
|
if(This->node.node)
|
|
|
|
{
|
|
|
|
priv_from_xmlDocPtr(get_doc(This))->properties = NULL;
|
|
|
|
if (xmldoc_release(get_doc(This)) != 0)
|
|
|
|
priv_from_xmlDocPtr(get_doc(This))->properties =
|
|
|
|
copy_properties(This->properties);
|
|
|
|
}
|
|
|
|
|
|
|
|
This->node.node = (xmlNodePtr) xml;
|
|
|
|
|
|
|
|
if(This->node.node)
|
|
|
|
{
|
|
|
|
xmldoc_add_ref(get_doc(This));
|
|
|
|
priv_from_xmlDocPtr(get_doc(This))->properties = This->properties;
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
2010-08-29 23:31:49 +02:00
|
|
|
static inline domdoc *impl_from_IXMLDOMDocument3( IXMLDOMDocument3 *iface )
|
2005-08-02 13:29:04 +02:00
|
|
|
{
|
2011-04-26 23:47:48 +02:00
|
|
|
return CONTAINING_RECORD(iface, domdoc, IXMLDOMDocument3_iface);
|
2005-08-02 13:29:04 +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
|
|
|
{
|
2011-04-26 23:47:48 +02:00
|
|
|
return CONTAINING_RECORD(iface, domdoc, IPersistStreamInit_iface);
|
2007-12-09 23:31:38 +01:00
|
|
|
}
|
|
|
|
|
2008-04-26 14:55:05 +02:00
|
|
|
static inline domdoc *impl_from_IObjectWithSite(IObjectWithSite *iface)
|
|
|
|
{
|
2011-04-26 23:47:48 +02:00
|
|
|
return CONTAINING_RECORD(iface, domdoc, IObjectWithSite_iface);
|
2008-04-26 14:55:05 +02:00
|
|
|
}
|
|
|
|
|
2008-04-29 12:52:00 +02:00
|
|
|
static inline domdoc *impl_from_IObjectSafety(IObjectSafety *iface)
|
|
|
|
{
|
2011-04-26 23:47:48 +02:00
|
|
|
return CONTAINING_RECORD(iface, domdoc, IObjectSafety_iface);
|
2008-04-29 12:52:00 +02:00
|
|
|
}
|
|
|
|
|
2010-10-23 13:55:42 +02:00
|
|
|
static inline domdoc *impl_from_IConnectionPointContainer(IConnectionPointContainer *iface)
|
|
|
|
{
|
2011-04-26 23:47:48 +02:00
|
|
|
return CONTAINING_RECORD(iface, domdoc, IConnectionPointContainer_iface);
|
2010-10-23 13:55:42 +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
|
|
|
*/
|
2012-01-24 09:02:35 +01:00
|
|
|
static HRESULT WINAPI PersistStreamInit_QueryInterface(
|
2010-06-28 19:34:00 +02:00
|
|
|
IPersistStreamInit *iface, REFIID riid, void **ppvObj)
|
2007-12-09 23:31:38 +01:00
|
|
|
{
|
2010-11-24 20:53:47 +01:00
|
|
|
domdoc* This = impl_from_IPersistStreamInit(iface);
|
2011-04-26 23:47:48 +02:00
|
|
|
return IXMLDOMDocument3_QueryInterface(&This->IXMLDOMDocument3_iface, riid, ppvObj);
|
2007-12-09 23:31:38 +01:00
|
|
|
}
|
|
|
|
|
2012-01-24 09:02:35 +01:00
|
|
|
static ULONG WINAPI PersistStreamInit_AddRef(
|
2010-06-28 19:16:43 +02:00
|
|
|
IPersistStreamInit *iface)
|
2007-12-09 23:31:38 +01:00
|
|
|
{
|
2010-11-24 20:53:47 +01:00
|
|
|
domdoc* This = impl_from_IPersistStreamInit(iface);
|
2011-04-26 23:47:48 +02:00
|
|
|
return IXMLDOMDocument3_AddRef(&This->IXMLDOMDocument3_iface);
|
2007-12-09 23:31:38 +01:00
|
|
|
}
|
|
|
|
|
2012-01-24 09:02:35 +01:00
|
|
|
static ULONG WINAPI PersistStreamInit_Release(
|
2010-06-28 19:16:43 +02:00
|
|
|
IPersistStreamInit *iface)
|
2007-12-09 23:31:38 +01:00
|
|
|
{
|
2010-11-24 20:53:47 +01:00
|
|
|
domdoc* This = impl_from_IPersistStreamInit(iface);
|
2011-04-26 23:47:48 +02:00
|
|
|
return IXMLDOMDocument3_Release(&This->IXMLDOMDocument3_iface);
|
2007-12-09 23:31:38 +01:00
|
|
|
}
|
|
|
|
|
2012-01-24 09:02:35 +01:00
|
|
|
static HRESULT WINAPI PersistStreamInit_GetClassID(
|
2010-06-28 19:16:43 +02:00
|
|
|
IPersistStreamInit *iface, CLSID *classid)
|
2007-12-09 23:31:38 +01:00
|
|
|
{
|
2010-11-24 20:53:47 +01:00
|
|
|
domdoc* This = impl_from_IPersistStreamInit(iface);
|
|
|
|
TRACE("(%p)->(%p)\n", This, classid);
|
2008-01-14 05:35:02 +01:00
|
|
|
|
|
|
|
if(!classid)
|
|
|
|
return E_POINTER;
|
|
|
|
|
2010-11-24 20:53:47 +01:00
|
|
|
*classid = *DOMDocument_version(This->properties->version);
|
2008-01-14 05:35:02 +01:00
|
|
|
|
|
|
|
return S_OK;
|
2007-12-09 23:31:38 +01:00
|
|
|
}
|
|
|
|
|
2012-01-24 09:02:35 +01:00
|
|
|
static HRESULT WINAPI PersistStreamInit_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;
|
|
|
|
}
|
|
|
|
|
2012-11-27 05:07:24 +01:00
|
|
|
static HRESULT domdoc_load_from_stream(domdoc *doc, ISequentialStream *stream)
|
2007-12-09 23:31:38 +01:00
|
|
|
{
|
|
|
|
DWORD read, written, len;
|
2012-11-27 05:07:24 +01:00
|
|
|
xmlDocPtr xmldoc = NULL;
|
2012-11-27 05:32:57 +01:00
|
|
|
IStream *hstream;
|
2012-11-27 05:07:24 +01:00
|
|
|
HGLOBAL hglobal;
|
2007-12-09 23:31:38 +01:00
|
|
|
BYTE buf[4096];
|
2012-11-27 05:07:24 +01:00
|
|
|
HRESULT hr;
|
2007-12-09 23:31:38 +01:00
|
|
|
char *ptr;
|
|
|
|
|
2012-11-27 05:32:57 +01:00
|
|
|
hstream = NULL;
|
|
|
|
hr = CreateStreamOnHGlobal(NULL, TRUE, &hstream);
|
2007-12-09 23:31:38 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
2012-11-27 05:07:24 +01:00
|
|
|
ISequentialStream_Read(stream, buf, sizeof(buf), &read);
|
2012-11-27 05:32:57 +01:00
|
|
|
hr = IStream_Write(hstream, buf, read, &written);
|
2007-12-09 23:31:38 +01:00
|
|
|
} while(SUCCEEDED(hr) && written != 0 && read != 0);
|
|
|
|
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
2012-11-27 05:07:24 +01:00
|
|
|
ERR("failed to copy stream 0x%08x\n", hr);
|
2012-11-27 05:32:57 +01:00
|
|
|
IStream_Release(hstream);
|
2007-12-09 23:31:38 +01:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2012-11-27 05:32:57 +01:00
|
|
|
hr = GetHGlobalFromStream(hstream, &hglobal);
|
2007-12-09 23:31:38 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
len = GlobalSize(hglobal);
|
|
|
|
ptr = GlobalLock(hglobal);
|
2012-11-27 05:07:24 +01:00
|
|
|
if (len)
|
|
|
|
xmldoc = doparse(doc, ptr, len, XML_CHAR_ENCODING_NONE);
|
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
|
|
|
|
2012-11-27 05:07:24 +01:00
|
|
|
return attach_xmldoc(doc, xmldoc);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI PersistStreamInit_Load(IPersistStreamInit *iface, IStream *stream)
|
|
|
|
{
|
|
|
|
domdoc *This = impl_from_IPersistStreamInit(iface);
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, stream);
|
|
|
|
|
|
|
|
if (!stream)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
return domdoc_load_from_stream(This, (ISequentialStream*)stream);
|
2007-12-09 23:31:38 +01:00
|
|
|
}
|
|
|
|
|
2012-01-24 09:02:35 +01:00
|
|
|
static HRESULT WINAPI PersistStreamInit_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
|
|
|
|
2011-04-26 23:47:48 +02:00
|
|
|
hr = IXMLDOMDocument3_get_xml(&This->IXMLDOMDocument3_iface, &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
|
|
|
}
|
|
|
|
|
2012-01-24 09:02:35 +01:00
|
|
|
static HRESULT WINAPI PersistStreamInit_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);
|
2012-12-11 11:31:29 +01:00
|
|
|
TRACE("(%p)->(%p)\n", This, pcbSize);
|
2007-12-09 23:31:38 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2012-01-24 09:02:35 +01:00
|
|
|
static HRESULT WINAPI PersistStreamInit_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 =
|
|
|
|
{
|
2012-01-24 09:02:35 +01:00
|
|
|
PersistStreamInit_QueryInterface,
|
|
|
|
PersistStreamInit_AddRef,
|
|
|
|
PersistStreamInit_Release,
|
|
|
|
PersistStreamInit_GetClassID,
|
|
|
|
PersistStreamInit_IsDirty,
|
|
|
|
PersistStreamInit_Load,
|
|
|
|
PersistStreamInit_Save,
|
|
|
|
PersistStreamInit_GetSizeMax,
|
|
|
|
PersistStreamInit_InitNew
|
2007-12-09 23:31:38 +01:00
|
|
|
};
|
|
|
|
|
2011-11-19 14:33:10 +01:00
|
|
|
/* IXMLDOMDocument3 interface */
|
2008-12-19 09:48:58 +01:00
|
|
|
|
2011-11-19 14:33:10 +01:00
|
|
|
static const tid_t domdoc_se_tids[] = {
|
|
|
|
IXMLDOMNode_tid,
|
|
|
|
IXMLDOMDocument_tid,
|
|
|
|
IXMLDOMDocument2_tid,
|
2011-11-19 15:00:24 +01:00
|
|
|
IXMLDOMDocument3_tid,
|
2013-05-07 13:07:28 +02:00
|
|
|
NULL_tid
|
2008-12-19 09:48:58 +01:00
|
|
|
};
|
|
|
|
|
2010-08-29 23:31:49 +02:00
|
|
|
static HRESULT WINAPI domdoc_QueryInterface( IXMLDOMDocument3 *iface, REFIID riid, void** ppvObject )
|
2005-08-02 13:29:04 +02:00
|
|
|
{
|
2010-08-29 23:31:49 +02:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument3( 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 ) ||
|
2010-09-04 17:56:08 +02:00
|
|
|
IsEqualGUID( riid, &IID_IXMLDOMNode ) ||
|
2007-02-26 13:49:12 +01:00
|
|
|
IsEqualGUID( riid, &IID_IXMLDOMDocument ) ||
|
2010-08-29 23:31:49 +02:00
|
|
|
IsEqualGUID( riid, &IID_IXMLDOMDocument2 )||
|
|
|
|
IsEqualGUID( riid, &IID_IXMLDOMDocument3 ))
|
2005-08-02 13:29:04 +02:00
|
|
|
{
|
|
|
|
*ppvObject = iface;
|
|
|
|
}
|
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
|
|
|
{
|
2011-04-26 23:47:48 +02:00
|
|
|
*ppvObject = &This->IPersistStreamInit_iface;
|
2007-12-09 23:31:38 +01:00
|
|
|
}
|
2008-04-26 14:55:05 +02:00
|
|
|
else if (IsEqualGUID(&IID_IObjectWithSite, riid))
|
|
|
|
{
|
2011-04-26 23:47:48 +02:00
|
|
|
*ppvObject = &This->IObjectWithSite_iface;
|
2008-04-26 14:55:05 +02:00
|
|
|
}
|
2010-02-19 11:46:16 +01:00
|
|
|
else if (IsEqualGUID(&IID_IObjectSafety, riid))
|
|
|
|
{
|
2011-04-26 23:47:48 +02:00
|
|
|
*ppvObject = &This->IObjectSafety_iface;
|
2010-02-19 11:46:16 +01:00
|
|
|
}
|
2008-12-19 09:48:58 +01:00
|
|
|
else if( IsEqualGUID( riid, &IID_ISupportErrorInfo ))
|
|
|
|
{
|
2011-11-19 14:33:10 +01:00
|
|
|
return node_create_supporterrorinfo(domdoc_se_tids, ppvObject);
|
2008-12-19 09:48:58 +01:00
|
|
|
}
|
2010-09-04 17:54:46 +02:00
|
|
|
else if(node_query_interface(&This->node, riid, ppvObject))
|
2008-09-03 02:23:10 +02:00
|
|
|
{
|
|
|
|
return *ppvObject ? S_OK : E_NOINTERFACE;
|
|
|
|
}
|
2010-10-23 13:55:42 +02:00
|
|
|
else if (IsEqualGUID( riid, &IID_IConnectionPointContainer ))
|
|
|
|
{
|
2011-04-26 23:47:48 +02:00
|
|
|
*ppvObject = &This->IConnectionPointContainer_iface;
|
2010-10-23 13:55:42 +02:00
|
|
|
}
|
2005-08-02 13:29:04 +02:00
|
|
|
else
|
2006-01-27 19:22:56 +01:00
|
|
|
{
|
2011-03-13 14:40:26 +01:00
|
|
|
TRACE("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;
|
|
|
|
}
|
|
|
|
|
2011-11-19 17:32:23 +01:00
|
|
|
static ULONG WINAPI domdoc_AddRef( IXMLDOMDocument3 *iface )
|
2005-08-02 13:29:04 +02:00
|
|
|
{
|
2010-08-29 23:31:49 +02:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument3( iface );
|
2010-11-07 22:01:50 +01:00
|
|
|
ULONG ref = InterlockedIncrement( &This->ref );
|
|
|
|
TRACE("(%p)->(%d)\n", This, ref );
|
|
|
|
return ref;
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
2011-11-19 17:32:23 +01:00
|
|
|
static ULONG WINAPI domdoc_Release( IXMLDOMDocument3 *iface )
|
2005-08-02 13:29:04 +02:00
|
|
|
{
|
2010-08-29 23:31:49 +02:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument3( iface );
|
2010-11-07 22:01:50 +01:00
|
|
|
LONG ref = InterlockedDecrement( &This->ref );
|
2005-08-02 13:29:04 +02:00
|
|
|
|
2010-11-07 22:01:50 +01:00
|
|
|
TRACE("(%p)->(%d)\n", This, ref );
|
2005-08-02 13:29:04 +02:00
|
|
|
|
|
|
|
if ( ref == 0 )
|
|
|
|
{
|
2011-02-19 15:09:58 +01:00
|
|
|
int eid;
|
|
|
|
|
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);
|
2011-02-19 15:09:58 +01:00
|
|
|
|
|
|
|
for (eid = 0; eid < EVENTID_LAST; eid++)
|
|
|
|
if (This->events[eid]) IDispatch_Release(This->events[eid]);
|
|
|
|
|
2012-01-24 08:40:56 +01:00
|
|
|
release_namespaces(This);
|
2010-11-07 22:01:50 +01:00
|
|
|
heap_free(This);
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
2010-08-29 23:31:49 +02:00
|
|
|
static HRESULT WINAPI domdoc_GetTypeInfoCount( IXMLDOMDocument3 *iface, UINT* pctinfo )
|
2005-08-02 13:29:04 +02:00
|
|
|
{
|
2010-08-29 23:31:49 +02:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument3( iface );
|
2011-11-19 17:32:23 +01:00
|
|
|
return IDispatchEx_GetTypeInfoCount(&This->node.dispex.IDispatchEx_iface, pctinfo);
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_GetTypeInfo(
|
2010-08-29 23:31:49 +02:00
|
|
|
IXMLDOMDocument3 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
UINT iTInfo, LCID lcid, ITypeInfo** ppTInfo )
|
|
|
|
{
|
2010-08-29 23:31:49 +02:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument3( iface );
|
2011-11-19 17:32:23 +01:00
|
|
|
return IDispatchEx_GetTypeInfo(&This->node.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_GetIDsOfNames(
|
2010-08-29 23:31:49 +02:00
|
|
|
IXMLDOMDocument3 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
REFIID riid,
|
|
|
|
LPOLESTR* rgszNames,
|
|
|
|
UINT cNames,
|
|
|
|
LCID lcid,
|
|
|
|
DISPID* rgDispId)
|
|
|
|
{
|
2010-08-29 23:31:49 +02:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument3( iface );
|
2011-11-19 17:32:23 +01:00
|
|
|
return IDispatchEx_GetIDsOfNames(&This->node.dispex.IDispatchEx_iface,
|
|
|
|
riid, rgszNames, cNames, lcid, rgDispId);
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_Invoke(
|
2010-08-29 23:31:49 +02:00
|
|
|
IXMLDOMDocument3 *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)
|
|
|
|
{
|
2010-08-29 23:31:49 +02:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument3( iface );
|
2011-11-19 17:32:23 +01:00
|
|
|
return IDispatchEx_Invoke(&This->node.dispex.IDispatchEx_iface,
|
|
|
|
dispIdMember, riid, lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_get_nodeName(
|
2010-08-29 23:31:49 +02:00
|
|
|
IXMLDOMDocument3 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
BSTR* name )
|
|
|
|
{
|
2010-08-29 23:31:49 +02:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument3( iface );
|
2010-09-04 17:56:25 +02:00
|
|
|
|
|
|
|
static const WCHAR documentW[] = {'#','d','o','c','u','m','e','n','t',0};
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, name);
|
|
|
|
|
|
|
|
return return_bstr(documentW, name);
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_get_nodeValue(
|
2010-08-29 23:31:49 +02:00
|
|
|
IXMLDOMDocument3 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
VARIANT* value )
|
|
|
|
{
|
2010-08-29 23:31:49 +02:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument3( iface );
|
2010-09-04 17:56:45 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, value);
|
|
|
|
|
|
|
|
if(!value)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
V_VT(value) = VT_NULL;
|
|
|
|
V_BSTR(value) = NULL; /* tests show that we should do this */
|
|
|
|
return S_FALSE;
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_put_nodeValue(
|
2010-08-29 23:31:49 +02:00
|
|
|
IXMLDOMDocument3 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
VARIANT value)
|
|
|
|
{
|
2010-08-29 23:31:49 +02:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument3( iface );
|
2012-01-29 10:40:22 +01:00
|
|
|
TRACE("(%p)->(%s)\n", This, debugstr_variant(&value));
|
2010-09-07 15:27:31 +02:00
|
|
|
return E_FAIL;
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_get_nodeType(
|
2010-08-29 23:31:49 +02:00
|
|
|
IXMLDOMDocument3 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
DOMNodeType* type )
|
|
|
|
{
|
2010-08-29 23:31:49 +02:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument3( iface );
|
2010-09-07 15:28:21 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, type);
|
|
|
|
|
|
|
|
*type = NODE_DOCUMENT;
|
|
|
|
return S_OK;
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_get_parentNode(
|
2010-08-29 23:31:49 +02:00
|
|
|
IXMLDOMDocument3 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
IXMLDOMNode** parent )
|
|
|
|
{
|
2010-08-29 23:31:49 +02:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument3( iface );
|
2010-09-07 15:28:21 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, parent);
|
|
|
|
|
|
|
|
return node_get_parent(&This->node, parent);
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_get_childNodes(
|
2010-08-29 23:31:49 +02:00
|
|
|
IXMLDOMDocument3 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
IXMLDOMNodeList** childList )
|
|
|
|
{
|
2010-08-29 23:31:49 +02:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument3( iface );
|
2010-09-08 15:12:02 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, childList);
|
|
|
|
|
|
|
|
return node_get_child_nodes(&This->node, childList);
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_get_firstChild(
|
2010-08-29 23:31:49 +02:00
|
|
|
IXMLDOMDocument3 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
IXMLDOMNode** firstChild )
|
|
|
|
{
|
2010-08-29 23:31:49 +02:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument3( iface );
|
2010-09-08 15:12:14 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, firstChild);
|
|
|
|
|
|
|
|
return node_get_first_child(&This->node, firstChild);
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_get_lastChild(
|
2010-08-29 23:31:49 +02:00
|
|
|
IXMLDOMDocument3 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
IXMLDOMNode** lastChild )
|
|
|
|
{
|
2010-08-29 23:31:49 +02:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument3( iface );
|
2010-09-08 15:12:14 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, lastChild);
|
|
|
|
|
2010-09-08 21:55:37 +02:00
|
|
|
return node_get_last_child(&This->node, lastChild);
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_get_previousSibling(
|
2010-08-29 23:31:49 +02:00
|
|
|
IXMLDOMDocument3 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
IXMLDOMNode** previousSibling )
|
|
|
|
{
|
2010-08-29 23:31:49 +02:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument3( iface );
|
2010-09-10 16:53:48 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, previousSibling);
|
|
|
|
|
|
|
|
return return_null_node(previousSibling);
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_get_nextSibling(
|
2010-08-29 23:31:49 +02:00
|
|
|
IXMLDOMDocument3 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
IXMLDOMNode** nextSibling )
|
|
|
|
{
|
2010-08-29 23:31:49 +02:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument3( iface );
|
2010-09-10 16:53:48 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, nextSibling);
|
|
|
|
|
|
|
|
return return_null_node(nextSibling);
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_get_attributes(
|
2010-08-29 23:31:49 +02:00
|
|
|
IXMLDOMDocument3 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
IXMLDOMNamedNodeMap** attributeMap )
|
|
|
|
{
|
2010-08-29 23:31:49 +02:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument3( iface );
|
2010-09-10 16:54:06 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, attributeMap);
|
|
|
|
|
|
|
|
return return_null_ptr((void**)attributeMap);
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_insertBefore(
|
2010-08-29 23:31:49 +02:00
|
|
|
IXMLDOMDocument3 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
IXMLDOMNode* newChild,
|
|
|
|
VARIANT refChild,
|
|
|
|
IXMLDOMNode** outNewChild )
|
|
|
|
{
|
2010-08-29 23:31:49 +02:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument3( iface );
|
2013-02-24 15:04:02 +01:00
|
|
|
DOMNodeType type;
|
|
|
|
HRESULT hr;
|
2010-09-10 16:55:14 +02:00
|
|
|
|
2012-01-29 10:40:22 +01:00
|
|
|
TRACE("(%p)->(%p %s %p)\n", This, newChild, debugstr_variant(&refChild), outNewChild);
|
2010-09-10 16:55:14 +02:00
|
|
|
|
2013-02-24 15:04:02 +01:00
|
|
|
hr = IXMLDOMNode_get_nodeType(newChild, &type);
|
|
|
|
if (hr != S_OK) return hr;
|
2005-08-02 13:29:04 +02:00
|
|
|
|
2013-02-24 15:04:02 +01:00
|
|
|
TRACE("new node type %d\n", type);
|
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case NODE_ATTRIBUTE:
|
|
|
|
case NODE_DOCUMENT:
|
|
|
|
case NODE_CDATA_SECTION:
|
|
|
|
if (outNewChild) *outNewChild = NULL;
|
|
|
|
return E_FAIL;
|
|
|
|
default:
|
|
|
|
return node_insert_before(&This->node, newChild, &refChild, outNewChild);
|
|
|
|
}
|
|
|
|
}
|
2005-08-02 13:29:04 +02:00
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_replaceChild(
|
2010-08-29 23:31:49 +02:00
|
|
|
IXMLDOMDocument3 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
IXMLDOMNode* newChild,
|
|
|
|
IXMLDOMNode* oldChild,
|
|
|
|
IXMLDOMNode** outOldChild)
|
|
|
|
{
|
2010-08-29 23:31:49 +02:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument3( iface );
|
2010-10-13 15:11:32 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p %p %p)\n", This, newChild, oldChild, outOldChild);
|
|
|
|
|
|
|
|
return node_replace_child(&This->node, newChild, oldChild, outOldChild);
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_removeChild(
|
2010-08-29 23:31:49 +02:00
|
|
|
IXMLDOMDocument3 *iface,
|
2011-02-23 12:28:44 +01:00
|
|
|
IXMLDOMNode *child,
|
|
|
|
IXMLDOMNode **oldChild)
|
2005-08-02 13:29:04 +02:00
|
|
|
{
|
2010-08-29 23:31:49 +02:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument3( iface );
|
2011-02-23 12:28:44 +01:00
|
|
|
TRACE("(%p)->(%p %p)\n", This, child, oldChild);
|
|
|
|
return node_remove_child(&This->node, child, oldChild);
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_appendChild(
|
2010-08-29 23:31:49 +02:00
|
|
|
IXMLDOMDocument3 *iface,
|
2011-02-23 12:32:16 +01:00
|
|
|
IXMLDOMNode *child,
|
|
|
|
IXMLDOMNode **outChild)
|
2005-08-02 13:29:04 +02:00
|
|
|
{
|
2010-08-29 23:31:49 +02:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument3( iface );
|
2011-02-23 12:32:16 +01:00
|
|
|
TRACE("(%p)->(%p %p)\n", This, child, outChild);
|
|
|
|
return node_append_child(&This->node, child, outChild);
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_hasChildNodes(
|
2010-08-29 23:31:49 +02:00
|
|
|
IXMLDOMDocument3 *iface,
|
2011-02-23 12:35:35 +01:00
|
|
|
VARIANT_BOOL *ret)
|
2005-08-02 13:29:04 +02:00
|
|
|
{
|
2010-08-29 23:31:49 +02:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument3( iface );
|
2011-02-23 12:35:35 +01:00
|
|
|
TRACE("(%p)->(%p)\n", This, ret);
|
|
|
|
return node_has_childnodes(&This->node, ret);
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_get_ownerDocument(
|
2010-08-29 23:31:49 +02:00
|
|
|
IXMLDOMDocument3 *iface,
|
2011-02-23 12:38:32 +01:00
|
|
|
IXMLDOMDocument **doc)
|
2005-08-02 13:29:04 +02:00
|
|
|
{
|
2010-08-29 23:31:49 +02:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument3( iface );
|
2011-02-23 12:38:32 +01:00
|
|
|
TRACE("(%p)->(%p)\n", This, doc);
|
|
|
|
return node_get_owner_doc(&This->node, doc);
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_cloneNode(
|
2010-08-29 23:31:49 +02:00
|
|
|
IXMLDOMDocument3 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
VARIANT_BOOL deep,
|
2010-10-31 09:50:58 +01:00
|
|
|
IXMLDOMNode** outNode)
|
2005-08-02 13:29:04 +02:00
|
|
|
{
|
2010-08-29 23:31:49 +02:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument3( iface );
|
2010-10-31 09:50:58 +01:00
|
|
|
TRACE("(%p)->(%d %p)\n", This, deep, outNode);
|
|
|
|
return node_clone( &This->node, deep, outNode );
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_get_nodeTypeString(
|
2010-08-29 23:31:49 +02:00
|
|
|
IXMLDOMDocument3 *iface,
|
2010-11-07 20:28:36 +01:00
|
|
|
BSTR *p)
|
2005-08-02 13:29:04 +02:00
|
|
|
{
|
2010-08-29 23:31:49 +02:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument3( iface );
|
2010-11-07 20:28:36 +01:00
|
|
|
static const WCHAR documentW[] = {'d','o','c','u','m','e','n','t',0};
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, p);
|
|
|
|
|
|
|
|
return return_bstr(documentW, p);
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_get_text(
|
2010-08-29 23:31:49 +02:00
|
|
|
IXMLDOMDocument3 *iface,
|
2011-02-23 12:40:43 +01:00
|
|
|
BSTR *p)
|
2005-08-02 13:29:04 +02:00
|
|
|
{
|
2010-08-29 23:31:49 +02:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument3( iface );
|
2011-02-23 12:40:43 +01:00
|
|
|
TRACE("(%p)->(%p)\n", This, p);
|
|
|
|
return node_get_text(&This->node, p);
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_put_text(
|
2010-08-29 23:31:49 +02:00
|
|
|
IXMLDOMDocument3 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
BSTR text )
|
|
|
|
{
|
2010-08-29 23:31:49 +02:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument3( iface );
|
2010-10-19 01:27:48 +02:00
|
|
|
TRACE("(%p)->(%s)\n", This, debugstr_w(text));
|
|
|
|
return E_FAIL;
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_get_specified(
|
2010-08-29 23:31:49 +02:00
|
|
|
IXMLDOMDocument3 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
VARIANT_BOOL* isSpecified )
|
|
|
|
{
|
2010-08-29 23:31:49 +02:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument3( iface );
|
2010-10-24 22:55:04 +02:00
|
|
|
FIXME("(%p)->(%p) stub!\n", This, isSpecified);
|
|
|
|
*isSpecified = VARIANT_TRUE;
|
|
|
|
return S_OK;
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_get_definition(
|
2010-08-29 23:31:49 +02:00
|
|
|
IXMLDOMDocument3 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
IXMLDOMNode** definitionNode )
|
|
|
|
{
|
2010-08-29 23:31:49 +02:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument3( iface );
|
2010-10-24 22:55:04 +02:00
|
|
|
FIXME("(%p)->(%p)\n", This, definitionNode);
|
|
|
|
return E_NOTIMPL;
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_get_nodeTypedValue(
|
2010-08-29 23:31:49 +02:00
|
|
|
IXMLDOMDocument3 *iface,
|
2011-03-06 22:39:13 +01:00
|
|
|
VARIANT* v )
|
2005-08-02 13:29:04 +02:00
|
|
|
{
|
2010-08-29 23:31:49 +02:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument3( iface );
|
2011-03-06 22:39:13 +01:00
|
|
|
TRACE("(%p)->(%p)\n", This, v);
|
|
|
|
return return_null_var(v);
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_put_nodeTypedValue(
|
2010-08-29 23:31:49 +02:00
|
|
|
IXMLDOMDocument3 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
VARIANT typedValue )
|
|
|
|
{
|
2010-08-29 23:31:49 +02:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument3( iface );
|
2010-12-30 13:07:50 +01:00
|
|
|
FIXME("(%p)->(%s)\n", This, debugstr_variant(&typedValue));
|
|
|
|
return E_NOTIMPL;
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_get_dataType(
|
2010-08-29 23:31:49 +02:00
|
|
|
IXMLDOMDocument3 *iface,
|
2010-10-19 01:13:30 +02:00
|
|
|
VARIANT* typename )
|
2005-08-02 13:29:04 +02:00
|
|
|
{
|
2010-08-29 23:31:49 +02:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument3( iface );
|
2010-10-19 01:13:30 +02:00
|
|
|
TRACE("(%p)->(%p)\n", This, typename);
|
|
|
|
return return_null_var( typename );
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_put_dataType(
|
2010-08-29 23:31:49 +02:00
|
|
|
IXMLDOMDocument3 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
BSTR dataTypeName )
|
|
|
|
{
|
2010-08-29 23:31:49 +02:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument3( iface );
|
2010-12-30 13:07:50 +01:00
|
|
|
|
|
|
|
FIXME("(%p)->(%s)\n", This, debugstr_w(dataTypeName));
|
|
|
|
|
|
|
|
if(!dataTypeName)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
return E_FAIL;
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
2010-11-11 21:08:33 +01:00
|
|
|
static int XMLCALL domdoc_get_xml_writecallback(void *ctx, const char *data, int len)
|
|
|
|
{
|
|
|
|
return xmlBufferAdd((xmlBufferPtr)ctx, (xmlChar*)data, len) == 0 ? len : 0;
|
|
|
|
}
|
2005-08-02 13:29:04 +02:00
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_get_xml(
|
2010-08-29 23:31:49 +02:00
|
|
|
IXMLDOMDocument3 *iface,
|
2010-10-29 16:27:09 +02:00
|
|
|
BSTR* p)
|
2005-08-02 13:29:04 +02:00
|
|
|
{
|
2010-08-29 23:31:49 +02:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument3( iface );
|
2010-11-06 20:07:11 +01:00
|
|
|
xmlSaveCtxtPtr ctxt;
|
|
|
|
xmlBufferPtr buf;
|
|
|
|
int options;
|
|
|
|
long ret;
|
2010-10-29 16:27:09 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, p);
|
|
|
|
|
2010-11-06 20:07:11 +01:00
|
|
|
if(!p)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
*p = NULL;
|
|
|
|
|
|
|
|
buf = xmlBufferCreate();
|
|
|
|
if(!buf)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
2011-05-04 22:38:03 +02:00
|
|
|
options = XML_SAVE_FORMAT | XML_SAVE_NO_DECL;
|
2010-11-11 21:08:33 +01:00
|
|
|
ctxt = xmlSaveToIO(domdoc_get_xml_writecallback, NULL, buf, "UTF-8", options);
|
|
|
|
|
2010-11-06 20:07:11 +01:00
|
|
|
if(!ctxt)
|
|
|
|
{
|
|
|
|
xmlBufferFree(buf);
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = xmlSaveDoc(ctxt, get_doc(This));
|
|
|
|
/* flushes on close */
|
|
|
|
xmlSaveClose(ctxt);
|
|
|
|
|
|
|
|
TRACE("%ld, len=%d\n", ret, xmlBufferLength(buf));
|
|
|
|
if(ret != -1 && xmlBufferLength(buf) > 0)
|
|
|
|
{
|
|
|
|
BSTR content;
|
|
|
|
|
|
|
|
content = bstr_from_xmlChar(xmlBufferContent(buf));
|
|
|
|
content = EnsureCorrectEOL(content);
|
|
|
|
|
|
|
|
*p = content;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*p = SysAllocStringLen(NULL, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
xmlBufferFree(buf);
|
|
|
|
|
|
|
|
return *p ? S_OK : E_OUTOFMEMORY;
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_transformNode(
|
2010-08-29 23:31:49 +02:00
|
|
|
IXMLDOMDocument3 *iface,
|
2011-02-23 13:03:42 +01:00
|
|
|
IXMLDOMNode *node,
|
|
|
|
BSTR *p)
|
2005-08-02 13:29:04 +02:00
|
|
|
{
|
2010-08-29 23:31:49 +02:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument3( iface );
|
2011-02-23 13:03:42 +01:00
|
|
|
TRACE("(%p)->(%p %p)\n", This, node, p);
|
|
|
|
return node_transform_node(&This->node, node, p);
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_selectNodes(
|
2010-08-29 23:31:49 +02:00
|
|
|
IXMLDOMDocument3 *iface,
|
2011-02-23 12:42:24 +01:00
|
|
|
BSTR p,
|
|
|
|
IXMLDOMNodeList **outList)
|
2005-08-02 13:29:04 +02:00
|
|
|
{
|
2010-08-29 23:31:49 +02:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument3( iface );
|
2011-02-23 12:42:24 +01:00
|
|
|
TRACE("(%p)->(%s %p)\n", This, debugstr_w(p), outList);
|
|
|
|
return node_select_nodes(&This->node, p, outList);
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_selectSingleNode(
|
2010-08-29 23:31:49 +02:00
|
|
|
IXMLDOMDocument3 *iface,
|
2011-02-23 12:44:20 +01:00
|
|
|
BSTR p,
|
|
|
|
IXMLDOMNode **outNode)
|
2005-08-02 13:29:04 +02:00
|
|
|
{
|
2010-08-29 23:31:49 +02:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument3( iface );
|
2011-02-23 12:44:20 +01:00
|
|
|
TRACE("(%p)->(%s %p)\n", This, debugstr_w(p), outNode);
|
|
|
|
return node_select_singlenode(&This->node, p, outNode);
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_get_parsed(
|
2010-08-29 23:31:49 +02:00
|
|
|
IXMLDOMDocument3 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
VARIANT_BOOL* isParsed )
|
|
|
|
{
|
2010-08-29 23:31:49 +02:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument3( iface );
|
2010-10-24 22:55:04 +02:00
|
|
|
FIXME("(%p)->(%p) stub!\n", This, isParsed);
|
|
|
|
*isParsed = VARIANT_TRUE;
|
|
|
|
return S_OK;
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_get_namespaceURI(
|
2010-08-29 23:31:49 +02:00
|
|
|
IXMLDOMDocument3 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
BSTR* namespaceURI )
|
|
|
|
{
|
2010-08-29 23:31:49 +02:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument3( iface );
|
2011-01-09 21:42:55 +01:00
|
|
|
TRACE("(%p)->(%p)\n", This, namespaceURI);
|
2011-11-27 20:36:32 +01:00
|
|
|
return return_null_bstr( namespaceURI );
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_get_prefix(
|
2010-08-29 23:31:49 +02:00
|
|
|
IXMLDOMDocument3 *iface,
|
2010-10-31 10:22:53 +01:00
|
|
|
BSTR* prefix )
|
2005-08-02 13:29:04 +02:00
|
|
|
{
|
2010-08-29 23:31:49 +02:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument3( iface );
|
2010-10-31 10:22:53 +01:00
|
|
|
TRACE("(%p)->(%p)\n", This, prefix);
|
|
|
|
return return_null_bstr( prefix );
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_get_baseName(
|
2010-08-29 23:31:49 +02:00
|
|
|
IXMLDOMDocument3 *iface,
|
2010-10-31 10:39:53 +01:00
|
|
|
BSTR* name )
|
2005-08-02 13:29:04 +02:00
|
|
|
{
|
2010-08-29 23:31:49 +02:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument3( iface );
|
2010-10-31 10:39:53 +01:00
|
|
|
TRACE("(%p)->(%p)\n", This, name);
|
|
|
|
return return_null_bstr( name );
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_transformNodeToObject(
|
2010-08-29 23:31:49 +02:00
|
|
|
IXMLDOMDocument3 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
IXMLDOMNode* stylesheet,
|
|
|
|
VARIANT outputObject)
|
|
|
|
{
|
2010-08-29 23:31:49 +02:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument3( iface );
|
2011-01-06 17:21:02 +01:00
|
|
|
FIXME("(%p)->(%p %s)\n", This, stylesheet, debugstr_variant(&outputObject));
|
|
|
|
return E_NOTIMPL;
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_get_doctype(
|
2010-08-29 23:31:49 +02:00
|
|
|
IXMLDOMDocument3 *iface,
|
2011-03-06 22:53:54 +01:00
|
|
|
IXMLDOMDocumentType** doctype )
|
2005-08-02 13:29:04 +02:00
|
|
|
{
|
2010-08-29 23:31:49 +02:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument3(iface);
|
2011-03-06 22:53:54 +01:00
|
|
|
IXMLDOMNode *node;
|
|
|
|
xmlDtdPtr dtd;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, doctype);
|
|
|
|
|
|
|
|
if (!doctype) return E_INVALIDARG;
|
|
|
|
|
|
|
|
*doctype = NULL;
|
|
|
|
|
|
|
|
dtd = xmlGetIntSubset(get_doc(This));
|
|
|
|
if (!dtd) return S_FALSE;
|
|
|
|
|
|
|
|
node = create_node((xmlNodePtr)dtd);
|
|
|
|
if (!node) return S_FALSE;
|
|
|
|
|
|
|
|
hr = IXMLDOMNode_QueryInterface(node, &IID_IXMLDOMDocumentType, (void**)doctype);
|
|
|
|
IXMLDOMNode_Release(node);
|
|
|
|
|
|
|
|
return hr;
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_get_implementation(
|
2010-08-29 23:31:49 +02:00
|
|
|
IXMLDOMDocument3 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
IXMLDOMImplementation** impl )
|
|
|
|
{
|
2010-08-29 23:31:49 +02:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument3(iface);
|
2010-02-17 07:40:40 +01:00
|
|
|
|
|
|
|
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(
|
2010-08-29 23:31:49 +02:00
|
|
|
IXMLDOMDocument3 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
IXMLDOMElement** DOMElement )
|
|
|
|
{
|
2010-08-29 23:31:49 +02:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument3( iface );
|
2005-12-01 18:46:42 +01:00
|
|
|
IXMLDOMNode *element_node;
|
2010-09-02 20:49:56 +02:00
|
|
|
xmlNodePtr root;
|
2005-12-01 18:46:42 +01:00
|
|
|
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
|
|
|
|
2010-09-02 20:49:56 +02:00
|
|
|
root = xmlDocGetRootElement( get_doc(This) );
|
2005-08-10 11:54:22 +02:00
|
|
|
if ( !root )
|
|
|
|
return S_FALSE;
|
|
|
|
|
2005-12-01 18:46:42 +01:00
|
|
|
element_node = create_node( root );
|
|
|
|
if(!element_node) return S_FALSE;
|
|
|
|
|
2010-09-02 20:49:56 +02:00
|
|
|
hr = IXMLDOMNode_QueryInterface(element_node, &IID_IXMLDOMElement, (void**)DOMElement);
|
2005-12-01 18:46:42 +01:00
|
|
|
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(
|
2010-08-29 23:31:49 +02:00
|
|
|
IXMLDOMDocument3 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
IXMLDOMElement* DOMElement )
|
|
|
|
{
|
2010-08-29 23:31:49 +02:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument3( iface );
|
2008-07-08 20:54:16 +02:00
|
|
|
IXMLDOMNode *elementNode;
|
2008-10-16 20:55:41 +02:00
|
|
|
xmlNodePtr oldRoot;
|
2013-02-26 07:46:33 +01:00
|
|
|
xmlDocPtr old_doc;
|
2008-07-08 20:54:16 +02:00
|
|
|
xmlnode *xmlNode;
|
2013-02-26 07:46:33 +01:00
|
|
|
int refcount = 0;
|
2008-07-08 20:54:16 +02:00
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, DOMElement);
|
|
|
|
|
|
|
|
hr = IXMLDOMElement_QueryInterface( DOMElement, &IID_IXMLDOMNode, (void**)&elementNode );
|
|
|
|
if(FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
2010-09-04 17:55:04 +02:00
|
|
|
xmlNode = get_node_obj( elementNode );
|
2011-03-03 23:03:15 +01:00
|
|
|
if(!xmlNode) return E_FAIL;
|
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);
|
|
|
|
|
2013-02-26 07:46:33 +01:00
|
|
|
old_doc = xmlNode->node->doc;
|
|
|
|
if (old_doc != get_doc(This))
|
|
|
|
refcount = xmlnode_get_inst_cnt(xmlNode);
|
|
|
|
|
|
|
|
/* old root is still orphaned by its document, update refcount from new root */
|
|
|
|
if (refcount) xmldoc_add_refs(get_doc(This), refcount);
|
2008-10-16 20:55:41 +02:00
|
|
|
oldRoot = xmlDocSetRootElement( get_doc(This), xmlNode->node);
|
2013-02-26 07:46:33 +01:00
|
|
|
if (refcount) xmldoc_release_refs(old_doc, refcount);
|
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(
|
2010-08-29 23:31:49 +02:00
|
|
|
IXMLDOMDocument3 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
BSTR tagname,
|
|
|
|
IXMLDOMElement** element )
|
|
|
|
{
|
2010-08-29 23:31:49 +02:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument3( 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-08-29 23:31:49 +02:00
|
|
|
hr = IXMLDOMDocument3_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(
|
2010-08-29 23:31:49 +02:00
|
|
|
IXMLDOMDocument3 *iface,
|
2010-02-12 01:59:14 +01:00
|
|
|
IXMLDOMDocumentFragment** frag )
|
2005-08-02 13:29:04 +02:00
|
|
|
{
|
2010-08-29 23:31:49 +02:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument3( 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-08-29 23:31:49 +02:00
|
|
|
hr = IXMLDOMDocument3_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(
|
2010-08-29 23:31:49 +02:00
|
|
|
IXMLDOMDocument3 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
BSTR data,
|
|
|
|
IXMLDOMText** text )
|
|
|
|
{
|
2010-08-29 23:31:49 +02:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument3( 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-08-29 23:31:49 +02:00
|
|
|
hr = IXMLDOMDocument3_createNode(iface, type, NULL, NULL, &node);
|
2010-02-12 19:44:27 +01:00
|
|
|
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(
|
2010-08-29 23:31:49 +02:00
|
|
|
IXMLDOMDocument3 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
BSTR data,
|
|
|
|
IXMLDOMComment** comment )
|
|
|
|
{
|
2010-08-29 23:31:49 +02:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument3( 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-08-29 23:31:49 +02:00
|
|
|
hr = IXMLDOMDocument3_createNode(iface, type, NULL, NULL, &node);
|
2010-02-12 19:26:50 +01:00
|
|
|
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(
|
2010-08-29 23:31:49 +02:00
|
|
|
IXMLDOMDocument3 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
BSTR data,
|
|
|
|
IXMLDOMCDATASection** cdata )
|
|
|
|
{
|
2010-08-29 23:31:49 +02:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument3( 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-08-29 23:31:49 +02:00
|
|
|
hr = IXMLDOMDocument3_createNode(iface, type, NULL, NULL, &node);
|
2010-02-12 19:58:17 +01:00
|
|
|
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(
|
2010-08-29 23:31:49 +02:00
|
|
|
IXMLDOMDocument3 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
BSTR target,
|
|
|
|
BSTR data,
|
|
|
|
IXMLDOMProcessingInstruction** pi )
|
|
|
|
{
|
2010-08-29 23:31:49 +02:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument3( 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-08-29 23:31:49 +02:00
|
|
|
hr = IXMLDOMDocument3_createNode(iface, type, target, NULL, &node);
|
2010-02-12 21:06:42 +01:00
|
|
|
if (hr == S_OK)
|
|
|
|
{
|
2010-09-04 17:56:08 +02:00
|
|
|
xmlnode *node_obj;
|
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 */
|
2010-09-04 17:56:08 +02:00
|
|
|
node_obj = get_node_obj(node);
|
2010-10-26 00:06:52 +02:00
|
|
|
hr = node_set_content(node_obj, data);
|
2010-02-12 21:06:42 +01:00
|
|
|
|
|
|
|
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(
|
2010-08-29 23:31:49 +02:00
|
|
|
IXMLDOMDocument3 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
BSTR name,
|
|
|
|
IXMLDOMAttribute** attribute )
|
|
|
|
{
|
2010-08-29 23:31:49 +02:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument3( 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-08-29 23:31:49 +02:00
|
|
|
hr = IXMLDOMDocument3_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(
|
2010-08-29 23:31:49 +02:00
|
|
|
IXMLDOMDocument3 *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
|
|
|
{
|
2010-08-29 23:31:49 +02:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument3( 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-08-29 23:31:49 +02:00
|
|
|
hr = IXMLDOMDocument3_createNode(iface, type, name, NULL, &node);
|
2010-02-12 21:24:40 +01:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2010-11-23 03:59:20 +01:00
|
|
|
xmlChar* tagName_to_XPath(const BSTR tagName)
|
|
|
|
{
|
|
|
|
xmlChar *query, *tmp;
|
2014-05-13 10:49:05 +02:00
|
|
|
static const xmlChar everything[] = "/descendant::node()";
|
2010-11-23 03:59:20 +01:00
|
|
|
static const xmlChar mod_pre[] = "*[local-name()='";
|
|
|
|
static const xmlChar mod_post[] = "']";
|
|
|
|
static const xmlChar prefix[] = "descendant::";
|
|
|
|
const WCHAR *tokBegin, *tokEnd;
|
|
|
|
int len;
|
|
|
|
|
2014-05-13 10:49:05 +02:00
|
|
|
/* Special case - empty tagname - means select all nodes,
|
|
|
|
except document itself. */
|
|
|
|
if (!*tagName)
|
|
|
|
return xmlStrdup(everything);
|
|
|
|
|
2010-11-23 03:59:20 +01:00
|
|
|
query = xmlStrdup(prefix);
|
|
|
|
|
|
|
|
tokBegin = tagName;
|
|
|
|
while (tokBegin && *tokBegin)
|
|
|
|
{
|
|
|
|
switch (*tokBegin)
|
|
|
|
{
|
|
|
|
case '/':
|
|
|
|
query = xmlStrcat(query, BAD_CAST "/");
|
|
|
|
++tokBegin;
|
|
|
|
break;
|
|
|
|
case '*':
|
|
|
|
query = xmlStrcat(query, BAD_CAST "*");
|
|
|
|
++tokBegin;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
query = xmlStrcat(query, mod_pre);
|
|
|
|
tokEnd = tokBegin;
|
|
|
|
while (*tokEnd && *tokEnd != '/')
|
|
|
|
++tokEnd;
|
|
|
|
len = WideCharToMultiByte(CP_UTF8, 0, tokBegin, tokEnd-tokBegin, NULL, 0, NULL, NULL);
|
|
|
|
tmp = xmlMalloc(len);
|
|
|
|
WideCharToMultiByte(CP_UTF8, 0, tokBegin, tokEnd-tokBegin, (char*)tmp, len, NULL, NULL);
|
|
|
|
query = xmlStrncat(query, tmp, len);
|
|
|
|
xmlFree(tmp);
|
|
|
|
tokBegin = tokEnd;
|
|
|
|
query = xmlStrcat(query, mod_post);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return query;
|
|
|
|
}
|
2005-08-02 13:29:04 +02:00
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_getElementsByTagName(
|
2010-08-29 23:31:49 +02:00
|
|
|
IXMLDOMDocument3 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
BSTR tagName,
|
|
|
|
IXMLDOMNodeList** resultList )
|
|
|
|
{
|
2010-08-29 23:31:49 +02:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument3( iface );
|
2010-11-23 03:59:20 +01:00
|
|
|
xmlChar *query;
|
2007-05-11 17:03:13 +02:00
|
|
|
HRESULT hr;
|
2010-11-23 03:59:20 +01:00
|
|
|
BOOL XPath;
|
2010-09-01 22:29:18 +02:00
|
|
|
|
2010-11-23 03:59:20 +01:00
|
|
|
TRACE("(%p)->(%s, %p)\n", This, debugstr_w(tagName), resultList);
|
2006-02-14 10:38:21 +01:00
|
|
|
|
2010-09-01 22:29:18 +02:00
|
|
|
if (!tagName || !resultList) return E_INVALIDARG;
|
|
|
|
|
2010-11-23 03:59:20 +01:00
|
|
|
XPath = This->properties->XPath;
|
|
|
|
This->properties->XPath = TRUE;
|
|
|
|
query = tagName_to_XPath(tagName);
|
2011-03-13 00:54:47 +01:00
|
|
|
hr = create_selection((xmlNodePtr)get_doc(This), query, resultList);
|
2010-11-23 03:59:20 +01:00
|
|
|
xmlFree(query);
|
|
|
|
This->properties->XPath = XPath;
|
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(
|
2010-08-29 23:31:49 +02:00
|
|
|
IXMLDOMDocument3 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
VARIANT Type,
|
|
|
|
BSTR name,
|
|
|
|
BSTR namespaceURI,
|
|
|
|
IXMLDOMNode** node )
|
|
|
|
{
|
2010-08-29 23:31:49 +02:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument3( iface );
|
2006-01-11 21:15:12 +01:00
|
|
|
DOMNodeType node_type;
|
2010-02-12 01:48:46 +01:00
|
|
|
xmlNodePtr xmlnode;
|
2010-09-14 06:55:40 +02:00
|
|
|
xmlChar *xml_name, *href;
|
2008-10-07 11:55:57 +02:00
|
|
|
HRESULT hr;
|
2006-01-11 21:15:12 +01:00
|
|
|
|
2012-01-29 10:40:22 +01:00
|
|
|
TRACE("(%p)->(%s %s %s %p)\n", This, debugstr_variant(&Type), 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;
|
|
|
|
|
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;
|
2011-10-08 18:51:38 +02:00
|
|
|
break;
|
2010-02-12 20:34:50 +01:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2006-01-11 21:15:12 +01:00
|
|
|
|
2011-03-10 20:15:09 +01:00
|
|
|
xml_name = xmlchar_from_wchar(name);
|
2010-09-14 06:55:40 +02:00
|
|
|
/* prevent empty href to be allocated */
|
2011-03-10 20:15:09 +01:00
|
|
|
href = namespaceURI ? xmlchar_from_wchar(namespaceURI) : NULL;
|
2005-08-02 13:29:04 +02:00
|
|
|
|
2006-01-11 21:15:12 +01:00
|
|
|
switch(node_type)
|
|
|
|
{
|
|
|
|
case NODE_ELEMENT:
|
2010-09-14 06:55:40 +02:00
|
|
|
{
|
|
|
|
xmlChar *local, *prefix;
|
|
|
|
|
|
|
|
local = xmlSplitQName2(xml_name, &prefix);
|
|
|
|
|
|
|
|
xmlnode = xmlNewDocNode(get_doc(This), NULL, local ? local : xml_name, NULL);
|
|
|
|
|
|
|
|
/* allow to create default namespace xmlns= */
|
|
|
|
if (local || (href && *href))
|
|
|
|
{
|
|
|
|
xmlNsPtr ns = xmlNewNs(xmlnode, href, prefix);
|
|
|
|
xmlSetNs(xmlnode, ns);
|
|
|
|
}
|
|
|
|
|
|
|
|
xmlFree(local);
|
|
|
|
xmlFree(prefix);
|
|
|
|
|
2006-01-11 21:15:12 +01:00
|
|
|
break;
|
2010-09-14 06:55:40 +02:00
|
|
|
}
|
2008-07-02 14:49:50 +02:00
|
|
|
case NODE_ATTRIBUTE:
|
2013-07-26 06:44:57 +02:00
|
|
|
{
|
|
|
|
xmlChar *local, *prefix;
|
|
|
|
|
|
|
|
local = xmlSplitQName2(xml_name, &prefix);
|
|
|
|
|
|
|
|
xmlnode = (xmlNodePtr)xmlNewDocProp(get_doc(This), local ? local : xml_name, NULL);
|
|
|
|
|
|
|
|
if (local || (href && *href))
|
|
|
|
{
|
|
|
|
/* we need a floating namespace here, it can't be created linked to attribute from
|
|
|
|
a start */
|
|
|
|
xmlNsPtr ns = xmlNewNs(NULL, href, prefix);
|
|
|
|
xmlSetNs(xmlnode, ns);
|
|
|
|
}
|
|
|
|
|
|
|
|
xmlFree(local);
|
|
|
|
xmlFree(prefix);
|
|
|
|
|
2008-07-02 14:49:50 +02:00
|
|
|
break;
|
2013-07-26 06:44:57 +02:00
|
|
|
}
|
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);
|
2010-09-14 06:55:40 +02:00
|
|
|
heap_free(href);
|
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(
|
2010-08-29 23:31:49 +02:00
|
|
|
IXMLDOMDocument3 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
BSTR idString,
|
|
|
|
IXMLDOMNode** node )
|
|
|
|
{
|
2010-08-29 23:31:49 +02:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument3(iface);
|
2010-02-17 07:40:40 +01:00
|
|
|
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
|
|
|
|
2011-05-20 17:05:05 +02:00
|
|
|
xmldoc = doparse(This, ptr, len, XML_CHAR_ENCODING_NONE);
|
2008-07-27 19:54:38 +02:00
|
|
|
if(xmldoc) {
|
2008-10-11 23:59:12 +02:00
|
|
|
xmldoc->_private = create_priv();
|
2010-09-28 02:59:51 +02:00
|
|
|
return attach_xmldoc(This, xmldoc);
|
2006-02-21 12:50:59 +01:00
|
|
|
}
|
|
|
|
|
2013-10-12 20:11:41 +02:00
|
|
|
return E_FAIL;
|
2008-07-27 19:54:38 +02:00
|
|
|
}
|
2008-07-08 20:55:03 +02:00
|
|
|
|
2012-03-12 20:41:45 +01:00
|
|
|
static HRESULT domdoc_load_moniker(domdoc *This, IMoniker *mon)
|
2008-07-27 19:54:38 +02:00
|
|
|
{
|
|
|
|
bsc_t *bsc;
|
|
|
|
HRESULT hr;
|
2008-07-08 20:55:03 +02:00
|
|
|
|
2012-03-12 10:56:59 +01:00
|
|
|
hr = bind_url(mon, domdoc_onDataAvailable, This, &bsc);
|
2008-07-27 19:54:38 +02:00
|
|
|
if(FAILED(hr))
|
|
|
|
return hr;
|
2006-02-21 12:50:59 +01:00
|
|
|
|
2013-10-12 20:11:41 +02:00
|
|
|
return detach_bsc(bsc);
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_load(
|
2010-08-29 23:31:49 +02:00
|
|
|
IXMLDOMDocument3 *iface,
|
2011-03-15 22:35:55 +01:00
|
|
|
VARIANT source,
|
2005-08-02 13:29:04 +02:00
|
|
|
VARIANT_BOOL* isSuccessful )
|
|
|
|
{
|
2010-08-29 23:31:49 +02:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument3( iface );
|
2005-08-02 13:29:04 +02:00
|
|
|
LPWSTR filename = NULL;
|
2006-06-27 11:54:40 +02:00
|
|
|
HRESULT hr = S_FALSE;
|
2008-07-08 20:55:10 +02:00
|
|
|
xmlDocPtr xmldoc;
|
2005-08-02 13:29:04 +02:00
|
|
|
|
2011-03-15 22:35:55 +01:00
|
|
|
TRACE("(%p)->(%s)\n", This, debugstr_variant(&source));
|
2005-08-10 11:54:22 +02:00
|
|
|
|
2011-05-20 17:05:38 +02:00
|
|
|
if (!isSuccessful)
|
|
|
|
return E_POINTER;
|
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
|
|
|
|
2011-03-15 22:35:55 +01:00
|
|
|
switch( V_VT(&source) )
|
2005-08-02 13:29:04 +02:00
|
|
|
{
|
|
|
|
case VT_BSTR:
|
2011-03-15 22:35:55 +01:00
|
|
|
filename = V_BSTR(&source);
|
|
|
|
break;
|
|
|
|
case VT_BSTR|VT_BYREF:
|
|
|
|
if (!V_BSTRREF(&source)) return E_INVALIDARG;
|
|
|
|
filename = *V_BSTRREF(&source);
|
2011-05-20 17:05:38 +02:00
|
|
|
break;
|
|
|
|
case VT_ARRAY|VT_UI1:
|
|
|
|
{
|
|
|
|
SAFEARRAY *psa = V_ARRAY(&source);
|
|
|
|
char *str;
|
|
|
|
LONG len;
|
|
|
|
UINT dim = SafeArrayGetDim(psa);
|
|
|
|
|
|
|
|
switch (dim)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
ERR("SAFEARRAY == NULL\n");
|
|
|
|
hr = This->error = E_INVALIDARG;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
/* Only takes UTF-8 strings.
|
|
|
|
* NOT NULL-terminated. */
|
|
|
|
SafeArrayAccessData(psa, (void**)&str);
|
|
|
|
SafeArrayGetUBound(psa, 1, &len);
|
|
|
|
|
|
|
|
if ((xmldoc = doparse(This, str, ++len, XML_CHAR_ENCODING_UTF8)))
|
|
|
|
{
|
|
|
|
hr = This->error = S_OK;
|
|
|
|
*isSuccessful = VARIANT_TRUE;
|
|
|
|
TRACE("parsed document %p\n", xmldoc);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
This->error = E_FAIL;
|
|
|
|
TRACE("failed to parse document\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
SafeArrayUnaccessData(psa);
|
|
|
|
|
|
|
|
if(xmldoc)
|
|
|
|
{
|
|
|
|
xmldoc->_private = create_priv();
|
|
|
|
return attach_xmldoc(This, xmldoc);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
FIXME("unhandled SAFEARRAY dim: %d\n", dim);
|
|
|
|
hr = This->error = E_NOTIMPL;
|
|
|
|
}
|
|
|
|
}
|
2007-12-09 23:31:38 +01:00
|
|
|
break;
|
|
|
|
case VT_UNKNOWN:
|
2012-11-27 05:29:06 +01:00
|
|
|
{
|
|
|
|
ISequentialStream *stream = NULL;
|
|
|
|
IXMLDOMDocument3 *newdoc = NULL;
|
|
|
|
|
2012-07-14 20:52:35 +02:00
|
|
|
if (!V_UNKNOWN(&source)) return E_INVALIDARG;
|
2012-11-27 05:29:06 +01:00
|
|
|
|
|
|
|
hr = IUnknown_QueryInterface(V_UNKNOWN(&source), &IID_IXMLDOMDocument3, (void**)&newdoc);
|
2007-12-09 23:31:38 +01:00
|
|
|
if(hr == S_OK)
|
|
|
|
{
|
2012-11-27 05:29:06 +01:00
|
|
|
if(newdoc)
|
2007-12-09 23:31:38 +01:00
|
|
|
{
|
2012-11-27 05:29:06 +01:00
|
|
|
domdoc *newDoc = impl_from_IXMLDOMDocument3( newdoc );
|
2012-01-23 15:36:35 +01:00
|
|
|
|
2007-12-09 23:31:38 +01:00
|
|
|
xmldoc = xmlCopyDoc(get_doc(newDoc), 1);
|
2012-01-23 15:36:35 +01:00
|
|
|
xmldoc->_private = create_priv();
|
2010-09-28 02:59:51 +02:00
|
|
|
hr = attach_xmldoc(This, 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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-11-27 05:29:06 +01:00
|
|
|
hr = IUnknown_QueryInterface(V_UNKNOWN(&source), &IID_IStream, (void**)&stream);
|
|
|
|
if (FAILED(hr))
|
|
|
|
hr = IUnknown_QueryInterface(V_UNKNOWN(&source), &IID_ISequentialStream, (void**)&stream);
|
|
|
|
|
|
|
|
if (hr == S_OK)
|
2007-12-09 23:31:38 +01:00
|
|
|
{
|
2012-11-27 05:29:06 +01:00
|
|
|
hr = domdoc_load_from_stream(This, stream);
|
|
|
|
if (hr == S_OK)
|
|
|
|
*isSuccessful = VARIANT_TRUE;
|
|
|
|
ISequentialStream_Release(stream);
|
|
|
|
return hr;
|
2007-12-09 23:31:38 +01:00
|
|
|
}
|
2012-11-27 05:29:06 +01:00
|
|
|
|
|
|
|
FIXME("unsupported IUnknown type (0x%08x) (%p)\n", hr, V_UNKNOWN(&source)->lpVtbl);
|
2007-12-09 23:31:38 +01:00
|
|
|
break;
|
2012-11-27 05:29:06 +01:00
|
|
|
}
|
|
|
|
default:
|
|
|
|
FIXME("VT type not supported (%d)\n", V_VT(&source));
|
2011-03-15 22:35:55 +01:00
|
|
|
}
|
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
|
|
|
{
|
2012-03-12 10:56:59 +01:00
|
|
|
IMoniker *mon;
|
|
|
|
|
2013-12-16 15:52:09 +01:00
|
|
|
CoTaskMemFree(This->properties->url);
|
|
|
|
This->properties->url = NULL;
|
2013-11-04 11:17:12 +01:00
|
|
|
|
2012-03-12 10:56:59 +01:00
|
|
|
hr = create_moniker_from_url( filename, &mon);
|
|
|
|
if ( SUCCEEDED(hr) )
|
|
|
|
{
|
2012-03-12 20:41:45 +01:00
|
|
|
hr = domdoc_load_moniker( This, mon );
|
2013-11-04 11:17:12 +01:00
|
|
|
if (hr == S_OK)
|
2013-12-16 15:52:09 +01:00
|
|
|
IMoniker_GetDisplayName(mon, NULL, NULL, &This->properties->url);
|
2012-03-12 10:56:59 +01:00
|
|
|
IMoniker_Release(mon);
|
|
|
|
}
|
2010-09-28 02:59:51 +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();
|
2010-09-28 02:59:51 +02:00
|
|
|
hr = attach_xmldoc(This, 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(
|
2010-08-29 23:31:49 +02:00
|
|
|
IXMLDOMDocument3 *iface,
|
2009-03-09 23:28:16 +01:00
|
|
|
LONG *value )
|
2005-08-02 13:29:04 +02:00
|
|
|
{
|
2010-08-29 23:31:49 +02:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument3(iface);
|
2010-10-01 00:01:44 +02:00
|
|
|
FIXME("stub! (%p)->(%p)\n", This, value);
|
|
|
|
|
|
|
|
if (!value)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
*value = READYSTATE_COMPLETE;
|
|
|
|
return S_OK;
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_get_parseError(
|
2010-08-29 23:31:49 +02:00
|
|
|
IXMLDOMDocument3 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
IXMLDOMParseError** errorObj )
|
|
|
|
{
|
2010-08-29 23:31:49 +02:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument3( iface );
|
2006-02-21 12:52:25 +01:00
|
|
|
static const WCHAR err[] = {'e','r','r','o','r',0};
|
2010-08-29 23:31:49 +02:00
|
|
|
BSTR error_string = NULL;
|
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(
|
2010-08-29 23:31:49 +02:00
|
|
|
IXMLDOMDocument3 *iface,
|
2013-11-04 11:17:12 +01:00
|
|
|
BSTR* url )
|
2005-08-02 13:29:04 +02:00
|
|
|
{
|
2010-08-29 23:31:49 +02:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument3(iface);
|
2013-11-04 11:17:12 +01:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, url);
|
|
|
|
|
|
|
|
if (!url)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2013-12-16 15:52:09 +01:00
|
|
|
if (This->properties->url)
|
2013-11-04 11:17:12 +01:00
|
|
|
{
|
2013-12-16 15:52:09 +01:00
|
|
|
*url = SysAllocString(This->properties->url);
|
2013-11-04 11:17:12 +01:00
|
|
|
if (!*url)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return return_null_bstr(url);
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_get_async(
|
2010-08-29 23:31:49 +02:00
|
|
|
IXMLDOMDocument3 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
VARIANT_BOOL* isAsync )
|
|
|
|
{
|
2010-08-29 23:31:49 +02:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument3( 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(
|
2010-08-29 23:31:49 +02:00
|
|
|
IXMLDOMDocument3 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
VARIANT_BOOL isAsync )
|
|
|
|
{
|
2010-08-29 23:31:49 +02:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument3( 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(
|
2010-08-29 23:31:49 +02:00
|
|
|
IXMLDOMDocument3 *iface )
|
2005-08-02 13:29:04 +02:00
|
|
|
{
|
2010-08-29 23:31:49 +02:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument3(iface);
|
2010-02-17 07:40:40 +01:00
|
|
|
FIXME("%p\n", This);
|
2005-08-02 13:29:04 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
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(
|
2010-08-29 23:31:49 +02:00
|
|
|
IXMLDOMDocument3 *iface,
|
2011-12-17 23:21:09 +01:00
|
|
|
BSTR data,
|
2005-08-02 13:29:04 +02:00
|
|
|
VARIANT_BOOL* isSuccessful )
|
|
|
|
{
|
2010-08-29 23:31:49 +02:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument3( iface );
|
2006-06-27 11:54:40 +02:00
|
|
|
xmlDocPtr xmldoc = NULL;
|
2010-08-29 23:33:54 +02:00
|
|
|
HRESULT hr = S_FALSE, hr2;
|
2005-08-11 12:32:36 +02:00
|
|
|
|
2011-12-17 23:21:09 +01:00
|
|
|
TRACE("(%p)->(%s %p)\n", This, debugstr_w(data), 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;
|
|
|
|
|
2011-12-17 23:21:09 +01:00
|
|
|
if (data)
|
2006-06-27 11:54:40 +02:00
|
|
|
{
|
2011-12-17 23:21:09 +01:00
|
|
|
WCHAR *ptr = data;
|
|
|
|
|
|
|
|
/* skip leading spaces if needed */
|
|
|
|
if (This->properties->version == MSXML_DEFAULT || This->properties->version == MSXML26)
|
2012-05-14 08:01:10 +02:00
|
|
|
while (*ptr && isspaceW(*ptr)) ptr++;
|
2011-12-17 23:21:09 +01:00
|
|
|
|
|
|
|
xmldoc = doparse(This, (char*)ptr, strlenW(ptr)*sizeof(WCHAR), XML_CHAR_ENCODING_UTF16LE);
|
2006-06-27 11:54:40 +02:00
|
|
|
if ( !xmldoc )
|
2010-10-21 00:00:21 +02:00
|
|
|
{
|
2006-06-27 11:54:40 +02:00
|
|
|
This->error = E_FAIL;
|
2010-10-21 00:00:21 +02:00
|
|
|
TRACE("failed to parse document\n");
|
|
|
|
}
|
2006-06-27 11:54:40 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
hr = This->error = S_OK;
|
|
|
|
*isSuccessful = VARIANT_TRUE;
|
2010-08-29 23:33:54 +02:00
|
|
|
TRACE("parsed document %p\n", xmldoc);
|
2006-06-27 11:54:40 +02:00
|
|
|
}
|
|
|
|
}
|
2006-02-21 12:52:25 +01:00
|
|
|
}
|
2012-01-24 08:40:56 +01:00
|
|
|
|
2006-06-27 11:54:40 +02:00
|
|
|
if(!xmldoc)
|
|
|
|
xmldoc = xmlNewDoc(NULL);
|
2008-10-11 23:59:12 +02:00
|
|
|
xmldoc->_private = create_priv();
|
2010-09-28 02:59:51 +02:00
|
|
|
hr2 = attach_xmldoc(This, 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-10-20 00:29:43 +02:00
|
|
|
static int XMLCALL domdoc_save_writecallback(void *ctx, const char *buffer, int len)
|
2010-02-05 14:25:02 +01:00
|
|
|
{
|
|
|
|
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
|
|
|
|
2010-10-20 00:29:43 +02:00
|
|
|
static int XMLCALL domdoc_stream_save_writecallback(void *ctx, const char *buffer, int len)
|
|
|
|
{
|
|
|
|
ULONG written = 0;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
hr = IStream_Write((IStream*)ctx, buffer, len, &written);
|
2012-07-07 10:13:08 +02:00
|
|
|
TRACE("0x%08x %p %d %u\n", hr, buffer, len, written);
|
2010-10-20 00:29:43 +02:00
|
|
|
if (hr != S_OK)
|
|
|
|
{
|
|
|
|
WARN("stream write error: 0x%08x\n", hr);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
else
|
2012-07-07 10:13:08 +02:00
|
|
|
return len;
|
2010-10-20 00:29:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static int XMLCALL domdoc_stream_save_closecallback(void *ctx)
|
|
|
|
{
|
|
|
|
IStream_Release((IStream*)ctx);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-08-02 13:29:04 +02:00
|
|
|
static HRESULT WINAPI domdoc_save(
|
2010-08-29 23:31:49 +02:00
|
|
|
IXMLDOMDocument3 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
VARIANT destination )
|
|
|
|
{
|
2010-08-29 23:31:49 +02:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument3( iface );
|
2010-10-20 00:29:43 +02:00
|
|
|
xmlSaveCtxtPtr ctx = NULL;
|
2010-06-28 10:17:56 +02:00
|
|
|
xmlNodePtr xmldecl;
|
2006-01-24 14:43:18 +01:00
|
|
|
HRESULT ret = S_OK;
|
|
|
|
|
2011-06-20 07:26:12 +02:00
|
|
|
TRACE("(%p)->(%s)\n", This, debugstr_variant(&destination));
|
2006-01-24 14:43:18 +01:00
|
|
|
|
2011-06-20 07:26:12 +02:00
|
|
|
switch (V_VT(&destination))
|
2006-01-24 14:43:18 +01:00
|
|
|
{
|
2011-06-20 07:26:12 +02:00
|
|
|
case VT_UNKNOWN:
|
2008-03-12 11:47:17 +01:00
|
|
|
{
|
2011-06-20 07:26:12 +02:00
|
|
|
IUnknown *pUnk = V_UNKNOWN(&destination);
|
2011-11-19 15:00:24 +01:00
|
|
|
IXMLDOMDocument3 *document;
|
2011-06-20 07:26:12 +02:00
|
|
|
IStream *stream;
|
2008-03-12 11:47:17 +01:00
|
|
|
|
2011-06-20 07:26:12 +02:00
|
|
|
ret = IUnknown_QueryInterface(pUnk, &IID_IXMLDOMDocument3, (void**)&document);
|
2008-03-12 11:47:17 +01:00
|
|
|
if(ret == S_OK)
|
|
|
|
{
|
2011-06-20 07:26:12 +02:00
|
|
|
VARIANT_BOOL success;
|
|
|
|
BSTR xml;
|
|
|
|
|
|
|
|
ret = IXMLDOMDocument3_get_xml(iface, &xml);
|
|
|
|
if(ret == S_OK)
|
|
|
|
{
|
|
|
|
ret = IXMLDOMDocument3_loadXML(document, xml, &success);
|
|
|
|
SysFreeString(xml);
|
|
|
|
}
|
|
|
|
|
|
|
|
IXMLDOMDocument3_Release(document);
|
|
|
|
return ret;
|
2008-03-12 11:47:17 +01:00
|
|
|
}
|
|
|
|
|
2011-06-20 07:26:12 +02:00
|
|
|
ret = IUnknown_QueryInterface(pUnk, &IID_IStream, (void**)&stream);
|
|
|
|
if(ret == S_OK)
|
|
|
|
{
|
2012-07-08 20:49:43 +02:00
|
|
|
int options = get_doc(This)->standalone == -1 ? XML_SAVE_NO_DECL : 0;
|
2011-06-20 07:26:12 +02:00
|
|
|
ctx = xmlSaveToIO(domdoc_stream_save_writecallback,
|
2012-07-08 20:49:43 +02:00
|
|
|
domdoc_stream_save_closecallback, stream, NULL, options);
|
2011-06-20 07:26:12 +02:00
|
|
|
|
|
|
|
if(!ctx)
|
|
|
|
{
|
|
|
|
IStream_Release(stream);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
}
|
2008-03-12 11:47:17 +01:00
|
|
|
}
|
2011-06-20 07:26:12 +02:00
|
|
|
break;
|
2008-03-12 11:47:17 +01:00
|
|
|
|
2011-06-20 07:26:12 +02:00
|
|
|
case VT_BSTR:
|
|
|
|
case VT_BSTR | VT_BYREF:
|
2010-10-20 00:29:43 +02:00
|
|
|
{
|
2012-07-08 20:51:52 +02:00
|
|
|
int options = get_doc(This)->standalone == -1 ? XML_SAVE_NO_DECL : 0;
|
|
|
|
|
2011-06-20 07:26:12 +02:00
|
|
|
/* save with file path */
|
|
|
|
HANDLE handle = CreateFileW( (V_VT(&destination) & VT_BYREF)? *V_BSTRREF(&destination) : 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 E_FAIL;
|
|
|
|
}
|
2008-08-13 08:06:22 +02:00
|
|
|
|
2011-06-20 07:26:12 +02:00
|
|
|
/* disable top XML declaration */
|
|
|
|
ctx = xmlSaveToIO(domdoc_save_writecallback, domdoc_save_closecallback,
|
2012-07-08 20:51:52 +02:00
|
|
|
handle, NULL, options);
|
2011-06-20 07:26:12 +02:00
|
|
|
if (!ctx)
|
2010-10-20 00:29:43 +02:00
|
|
|
{
|
2011-06-20 07:26:12 +02:00
|
|
|
CloseHandle(handle);
|
2010-10-20 00:29:43 +02:00
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
}
|
2011-06-20 07:26:12 +02:00
|
|
|
break;
|
2006-01-24 14:43:18 +01:00
|
|
|
|
2011-06-20 07:26:12 +02:00
|
|
|
default:
|
|
|
|
FIXME("Unhandled VARIANT: %s\n", debugstr_variant(&destination));
|
|
|
|
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-10-20 00:29:43 +02:00
|
|
|
/* will release resources through close callback */
|
2010-02-05 14:25:02 +01:00
|
|
|
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(
|
2010-08-29 23:31:49 +02:00
|
|
|
IXMLDOMDocument3 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
VARIANT_BOOL* isValidating )
|
|
|
|
{
|
2010-08-29 23:31:49 +02:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument3( iface );
|
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(
|
2010-08-29 23:31:49 +02:00
|
|
|
IXMLDOMDocument3 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
VARIANT_BOOL isValidating )
|
|
|
|
{
|
2010-08-29 23:31:49 +02:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument3( iface );
|
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(
|
2010-08-29 23:31:49 +02:00
|
|
|
IXMLDOMDocument3 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
VARIANT_BOOL* isResolving )
|
|
|
|
{
|
2010-08-29 23:31:49 +02:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument3( iface );
|
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(
|
2010-08-29 23:31:49 +02:00
|
|
|
IXMLDOMDocument3 *iface,
|
2007-02-18 19:37:18 +01:00
|
|
|
VARIANT_BOOL isResolving )
|
2005-08-02 13:29:04 +02:00
|
|
|
{
|
2010-08-29 23:31:49 +02:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument3( iface );
|
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(
|
2010-08-29 23:31:49 +02:00
|
|
|
IXMLDOMDocument3 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
VARIANT_BOOL* isPreserving )
|
|
|
|
{
|
2010-08-29 23:31:49 +02:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument3( iface );
|
2010-11-03 22:13:45 +01:00
|
|
|
TRACE("(%p)->(%p: %d)\n", This, isPreserving, This->properties->preserving);
|
|
|
|
*isPreserving = This->properties->preserving;
|
2007-02-18 19:37:18 +01:00
|
|
|
return S_OK;
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_put_preserveWhiteSpace(
|
2010-08-29 23:31:49 +02:00
|
|
|
IXMLDOMDocument3 *iface,
|
2005-08-02 13:29:04 +02:00
|
|
|
VARIANT_BOOL isPreserving )
|
|
|
|
{
|
2010-08-29 23:31:49 +02:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument3( iface );
|
2010-02-17 07:40:40 +01:00
|
|
|
TRACE("(%p)->(%d)\n", This, isPreserving);
|
2010-11-03 22:13:45 +01:00
|
|
|
This->properties->preserving = isPreserving;
|
2007-02-18 19:37:18 +01:00
|
|
|
return S_OK;
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-02-19 15:09:58 +01:00
|
|
|
static HRESULT WINAPI domdoc_put_onreadystatechange(
|
2010-08-29 23:31:49 +02:00
|
|
|
IXMLDOMDocument3 *iface,
|
2011-02-19 15:09:58 +01:00
|
|
|
VARIANT event )
|
2005-08-02 13:29:04 +02:00
|
|
|
{
|
2010-08-29 23:31:49 +02:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument3( iface );
|
2011-02-19 15:09:58 +01:00
|
|
|
|
|
|
|
TRACE("(%p)->(%s)\n", This, debugstr_variant(&event));
|
|
|
|
return set_doc_event(This, EVENTID_READYSTATECHANGE, &event);
|
2005-08-02 13:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-01-29 10:40:22 +01:00
|
|
|
static HRESULT WINAPI domdoc_put_onDataAvailable(IXMLDOMDocument3 *iface, VARIANT sink)
|
2005-08-02 13:29:04 +02:00
|
|
|
{
|
2010-08-29 23:31:49 +02:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument3( iface );
|
2012-01-29 10:40:22 +01:00
|
|
|
FIXME("(%p)->(%s): stub\n", This, debugstr_variant(&sink));
|
2005-08-02 13:29:04 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2012-01-29 10:40:22 +01:00
|
|
|
static HRESULT WINAPI domdoc_put_onTransformNode(IXMLDOMDocument3 *iface, VARIANT sink )
|
2005-08-02 13:29:04 +02:00
|
|
|
{
|
2010-08-29 23:31:49 +02:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument3( iface );
|
2012-01-29 10:40:22 +01:00
|
|
|
FIXME("(%p)->(%s): stub\n", This, debugstr_variant(&sink));
|
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(
|
2010-08-29 23:31:49 +02:00
|
|
|
IXMLDOMDocument3* iface,
|
2012-01-20 02:00:23 +01:00
|
|
|
IXMLDOMSchemaCollection** collection )
|
2007-02-26 13:49:12 +01:00
|
|
|
{
|
2010-08-29 23:31:49 +02:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument3( iface );
|
2012-01-24 08:40:56 +01:00
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
FIXME("(%p)->(%p): semi-stub\n", This, collection);
|
2012-01-20 02:00:23 +01:00
|
|
|
|
|
|
|
if (!collection) return E_POINTER;
|
|
|
|
|
2012-01-24 08:40:56 +01:00
|
|
|
if (!This->namespaces)
|
|
|
|
{
|
2014-01-09 12:57:58 +01:00
|
|
|
hr = SchemaCache_create(This->properties->version, (void**)&This->namespaces);
|
2012-01-24 08:40:56 +01:00
|
|
|
if (hr != S_OK) return hr;
|
|
|
|
|
|
|
|
hr = cache_from_doc_ns(This->namespaces, &This->node);
|
|
|
|
if (hr != S_OK)
|
|
|
|
release_namespaces(This);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (This->namespaces)
|
|
|
|
return IXMLDOMSchemaCollection2_QueryInterface(This->namespaces,
|
|
|
|
&IID_IXMLDOMSchemaCollection, (void**)collection);
|
|
|
|
|
|
|
|
return hr;
|
2007-02-26 13:49:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_get_schemas(
|
2010-08-29 23:31:49 +02:00
|
|
|
IXMLDOMDocument3* iface,
|
2012-07-01 20:27:17 +02:00
|
|
|
VARIANT* schema )
|
2007-02-26 13:49:12 +01:00
|
|
|
{
|
2010-08-29 23:31:49 +02:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument3( iface );
|
2010-11-16 01:15:24 +01:00
|
|
|
IXMLDOMSchemaCollection2* cur_schema = This->properties->schemaCache;
|
2012-07-01 20:27:17 +02:00
|
|
|
HRESULT hr = S_FALSE;
|
2007-02-27 16:11:13 +01:00
|
|
|
|
2012-07-01 20:27:17 +02:00
|
|
|
TRACE("(%p)->(%p)\n", This, schema);
|
2007-02-27 16:11:13 +01:00
|
|
|
|
2012-07-01 20:27:17 +02:00
|
|
|
V_VT(schema) = VT_NULL;
|
|
|
|
/* just to reset pointer part, cause that's what application is expected to use */
|
|
|
|
V_DISPATCH(schema) = NULL;
|
2007-02-27 16:11:13 +01:00
|
|
|
|
|
|
|
if(cur_schema)
|
|
|
|
{
|
2012-07-01 20:27:17 +02:00
|
|
|
hr = IXMLDOMSchemaCollection2_QueryInterface(cur_schema, &IID_IDispatch, (void**)&V_DISPATCH(schema));
|
2007-02-27 16:11:13 +01:00
|
|
|
if(SUCCEEDED(hr))
|
2012-07-01 20:27:17 +02:00
|
|
|
V_VT(schema) = VT_DISPATCH;
|
2007-02-27 16:11:13 +01:00
|
|
|
}
|
|
|
|
return hr;
|
2007-02-26 13:49:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_putref_schemas(
|
2010-08-29 23:31:49 +02:00
|
|
|
IXMLDOMDocument3* iface,
|
2012-01-29 10:40:22 +01:00
|
|
|
VARIANT schema)
|
2007-02-26 13:49:12 +01:00
|
|
|
{
|
2010-08-29 23:31:49 +02:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument3( iface );
|
2007-02-27 16:11:13 +01:00
|
|
|
HRESULT hr = E_FAIL;
|
2010-11-02 23:20:31 +01:00
|
|
|
IXMLDOMSchemaCollection2* new_schema = NULL;
|
2007-02-27 16:11:13 +01:00
|
|
|
|
2012-01-29 10:40:22 +01:00
|
|
|
FIXME("(%p)->(%s): semi-stub\n", This, debugstr_variant(&schema));
|
|
|
|
switch(V_VT(&schema))
|
2007-02-27 16:11:13 +01:00
|
|
|
{
|
|
|
|
case VT_UNKNOWN:
|
2012-07-01 20:27:17 +02:00
|
|
|
if (V_UNKNOWN(&schema))
|
|
|
|
{
|
|
|
|
hr = IUnknown_QueryInterface(V_UNKNOWN(&schema), &IID_IXMLDOMSchemaCollection, (void**)&new_schema);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
/* fallthrough */
|
2007-02-27 16:11:13 +01:00
|
|
|
case VT_DISPATCH:
|
2012-07-01 20:27:17 +02:00
|
|
|
if (V_DISPATCH(&schema))
|
|
|
|
{
|
|
|
|
hr = IDispatch_QueryInterface(V_DISPATCH(&schema), &IID_IXMLDOMSchemaCollection, (void**)&new_schema);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
/* fallthrough */
|
2007-02-27 16:11:13 +01:00
|
|
|
case VT_NULL:
|
|
|
|
case VT_EMPTY:
|
|
|
|
hr = S_OK;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2012-01-29 10:40:22 +01:00
|
|
|
WARN("Can't get schema from vt %x\n", V_VT(&schema));
|
2007-02-27 16:11:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if(SUCCEEDED(hr))
|
|
|
|
{
|
2010-11-16 01:15:24 +01:00
|
|
|
IXMLDOMSchemaCollection2* old_schema = InterlockedExchangePointer((void**)&This->properties->schemaCache, new_schema);
|
2010-11-02 23:20:31 +01:00
|
|
|
if(old_schema) IXMLDOMSchemaCollection2_Release(old_schema);
|
2007-02-27 16:11:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return hr;
|
2007-02-26 13:49:12 +01:00
|
|
|
}
|
|
|
|
|
2010-11-02 23:20:31 +01:00
|
|
|
static inline BOOL is_wellformed(xmlDocPtr doc)
|
|
|
|
{
|
|
|
|
#ifdef HAVE_XMLDOC_PROPERTIES
|
|
|
|
return doc->properties & XML_DOC_WELLFORMED;
|
|
|
|
#else
|
|
|
|
/* Not a full check, but catches the worst violations */
|
|
|
|
xmlNodePtr child;
|
|
|
|
int root = 0;
|
|
|
|
|
|
|
|
for (child = doc->children; child != NULL; child = child->next)
|
|
|
|
{
|
|
|
|
switch (child->type)
|
|
|
|
{
|
|
|
|
case XML_ELEMENT_NODE:
|
|
|
|
if (++root > 1)
|
|
|
|
return FALSE;
|
|
|
|
break;
|
|
|
|
case XML_TEXT_NODE:
|
|
|
|
case XML_CDATA_SECTION_NODE:
|
|
|
|
return FALSE;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return root == 1;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2010-10-27 16:35:56 +02:00
|
|
|
static void LIBXML2_LOG_CALLBACK validate_error(void* ctx, char const* msg, ...)
|
|
|
|
{
|
|
|
|
va_list ap;
|
|
|
|
va_start(ap, msg);
|
2010-11-02 23:20:31 +01:00
|
|
|
LIBXML2_CALLBACK_ERR(domdoc_validateNode, msg, ap);
|
2010-10-27 16:35:56 +02:00
|
|
|
va_end(ap);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void LIBXML2_LOG_CALLBACK validate_warning(void* ctx, char const* msg, ...)
|
|
|
|
{
|
|
|
|
va_list ap;
|
|
|
|
va_start(ap, msg);
|
2010-11-02 23:20:31 +01:00
|
|
|
LIBXML2_CALLBACK_WARN(domdoc_validateNode, msg, ap);
|
2010-10-27 16:35:56 +02:00
|
|
|
va_end(ap);
|
|
|
|
}
|
|
|
|
|
2010-11-02 23:20:31 +01:00
|
|
|
static HRESULT WINAPI domdoc_validateNode(
|
2010-08-29 23:31:49 +02:00
|
|
|
IXMLDOMDocument3* iface,
|
2010-11-02 23:20:31 +01:00
|
|
|
IXMLDOMNode* node,
|
2007-02-26 13:49:12 +01:00
|
|
|
IXMLDOMParseError** err)
|
|
|
|
{
|
2010-11-02 23:20:31 +01:00
|
|
|
domdoc* This = impl_from_IXMLDOMDocument3(iface);
|
|
|
|
LONG state, err_code = 0;
|
|
|
|
HRESULT hr = S_OK;
|
|
|
|
int validated = 0;
|
2010-10-01 21:31:21 +02:00
|
|
|
|
2010-11-02 23:20:31 +01:00
|
|
|
TRACE("(%p)->(%p, %p)\n", This, node, err);
|
2012-01-24 09:02:35 +01:00
|
|
|
IXMLDOMDocument3_get_readyState(iface, &state);
|
2010-10-01 21:31:21 +02:00
|
|
|
if (state != READYSTATE_COMPLETE)
|
|
|
|
{
|
|
|
|
if (err)
|
2010-11-02 23:20:31 +01:00
|
|
|
*err = create_parseError(err_code, NULL, NULL, NULL, 0, 0, 0);
|
2010-10-01 21:31:21 +02:00
|
|
|
return E_PENDING;
|
|
|
|
}
|
|
|
|
|
2010-11-02 23:20:31 +01:00
|
|
|
if (!node)
|
|
|
|
{
|
|
|
|
if (err)
|
|
|
|
*err = create_parseError(err_code, NULL, NULL, NULL, 0, 0, 0);
|
|
|
|
return E_POINTER;
|
|
|
|
}
|
2010-10-01 21:31:21 +02:00
|
|
|
|
2010-11-02 23:20:31 +01:00
|
|
|
if (!get_node_obj(node)->node || get_node_obj(node)->node->doc != get_doc(This))
|
2010-10-01 21:31:21 +02:00
|
|
|
{
|
|
|
|
if (err)
|
2010-11-02 23:20:31 +01:00
|
|
|
*err = create_parseError(err_code, NULL, NULL, NULL, 0, 0, 0);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!is_wellformed(get_doc(This)))
|
|
|
|
{
|
2010-12-03 15:02:20 +01:00
|
|
|
ERR("doc not well-formed\n");
|
2010-11-02 23:20:31 +01:00
|
|
|
if (err)
|
|
|
|
*err = create_parseError(E_XML_NOTWF, NULL, NULL, NULL, 0, 0, 0);
|
|
|
|
return S_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* DTD validation */
|
|
|
|
if (get_doc(This)->intSubset || get_doc(This)->extSubset)
|
|
|
|
{
|
|
|
|
xmlValidCtxtPtr vctx = xmlNewValidCtxt();
|
|
|
|
vctx->error = validate_error;
|
|
|
|
vctx->warning = validate_warning;
|
|
|
|
++validated;
|
|
|
|
|
|
|
|
if (!((node == (IXMLDOMNode*)iface)?
|
|
|
|
xmlValidateDocument(vctx, get_doc(This)) :
|
|
|
|
xmlValidateElement(vctx, get_doc(This), get_node_obj(node)->node)))
|
|
|
|
{
|
|
|
|
/* TODO: get a real error code here */
|
|
|
|
TRACE("DTD validation failed\n");
|
|
|
|
err_code = E_XML_INVALID;
|
|
|
|
hr = S_FALSE;
|
|
|
|
}
|
2010-10-01 21:31:21 +02:00
|
|
|
xmlFreeValidCtxt(vctx);
|
|
|
|
}
|
|
|
|
|
2010-11-02 23:20:31 +01:00
|
|
|
/* Schema validation */
|
2010-11-16 01:15:24 +01:00
|
|
|
if (hr == S_OK && This->properties->schemaCache != NULL)
|
2010-11-02 23:20:31 +01:00
|
|
|
{
|
|
|
|
|
2010-11-16 01:15:24 +01:00
|
|
|
hr = SchemaCache_validate_tree(This->properties->schemaCache, get_node_obj(node)->node);
|
2011-10-01 20:31:34 +02:00
|
|
|
if (SUCCEEDED(hr))
|
2010-11-02 23:20:31 +01:00
|
|
|
{
|
|
|
|
++validated;
|
|
|
|
/* TODO: get a real error code here */
|
2010-11-24 20:53:17 +01:00
|
|
|
if (hr == S_OK)
|
|
|
|
{
|
|
|
|
TRACE("schema validation succeeded\n");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ERR("schema validation failed\n");
|
2010-11-02 23:20:31 +01:00
|
|
|
err_code = E_XML_INVALID;
|
2010-11-24 20:53:17 +01:00
|
|
|
}
|
2010-11-02 23:20:31 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* not really OK, just didn't find a schema for the ns */
|
|
|
|
hr = S_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!validated)
|
|
|
|
{
|
2010-11-24 20:53:17 +01:00
|
|
|
ERR("no DTD or schema found\n");
|
2010-11-02 23:20:31 +01:00
|
|
|
err_code = E_XML_NODTD;
|
|
|
|
hr = S_FALSE;
|
|
|
|
}
|
|
|
|
|
2010-10-01 21:31:21 +02:00
|
|
|
if (err)
|
2010-11-02 23:20:31 +01:00
|
|
|
*err = create_parseError(err_code, NULL, NULL, NULL, 0, 0, 0);
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_validate(
|
|
|
|
IXMLDOMDocument3* iface,
|
|
|
|
IXMLDOMParseError** err)
|
|
|
|
{
|
|
|
|
domdoc *This = impl_from_IXMLDOMDocument3( iface );
|
|
|
|
TRACE("(%p)->(%p)\n", This, err);
|
2012-01-24 09:02:35 +01:00
|
|
|
return IXMLDOMDocument3_validateNode(iface, (IXMLDOMNode*)iface, err);
|
2007-02-26 13:49:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_setProperty(
|
2010-08-29 23:31:49 +02:00
|
|
|
IXMLDOMDocument3* iface,
|
2007-02-26 13:49:12 +01:00
|
|
|
BSTR p,
|
2012-01-29 10:40:22 +01:00
|
|
|
VARIANT value)
|
2007-02-26 13:49:12 +01:00
|
|
|
{
|
2010-08-29 23:31:49 +02:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument3( iface );
|
2007-05-09 20:09:11 +02:00
|
|
|
|
2012-01-29 10:40:22 +01:00
|
|
|
TRACE("(%p)->(%s %s)\n", This, debugstr_w(p), debugstr_variant(&value));
|
2010-02-17 07:40:40 +01:00
|
|
|
|
2010-08-29 23:33:54 +02:00
|
|
|
if (lstrcmpiW(p, PropertySelectionLanguageW) == 0)
|
2007-05-09 20:09:11 +02:00
|
|
|
{
|
|
|
|
VARIANT varStr;
|
|
|
|
HRESULT hr;
|
|
|
|
BSTR bstr;
|
|
|
|
|
|
|
|
V_VT(&varStr) = VT_EMPTY;
|
2012-01-29 10:40:22 +01:00
|
|
|
if (V_VT(&value) != VT_BSTR)
|
2007-05-09 20:09:11 +02:00
|
|
|
{
|
2012-01-29 10:40:22 +01:00
|
|
|
if (FAILED(hr = VariantChangeType(&varStr, &value, 0, VT_BSTR)))
|
2007-05-09 20:09:11 +02:00
|
|
|
return hr;
|
|
|
|
bstr = V_BSTR(&varStr);
|
|
|
|
}
|
|
|
|
else
|
2012-01-29 10:40:22 +01:00
|
|
|
bstr = V_BSTR(&value);
|
2007-05-09 20:09:11 +02:00
|
|
|
|
|
|
|
hr = S_OK;
|
2010-08-29 23:33:54 +02:00
|
|
|
if (lstrcmpiW(bstr, PropValueXPathW) == 0)
|
2010-09-28 02:59:51 +02:00
|
|
|
This->properties->XPath = TRUE;
|
2010-08-29 23:33:54 +02:00
|
|
|
else if (lstrcmpiW(bstr, PropValueXSLPatternW) == 0)
|
2010-09-28 02:59:51 +02:00
|
|
|
This->properties->XPath = FALSE;
|
2007-05-09 20:09:11 +02:00
|
|
|
else
|
|
|
|
hr = E_FAIL;
|
|
|
|
|
|
|
|
VariantClear(&varStr);
|
|
|
|
return hr;
|
|
|
|
}
|
2010-09-28 21:35:48 +02:00
|
|
|
else if (lstrcmpiW(p, PropertySelectionNamespacesW) == 0)
|
|
|
|
{
|
2012-01-12 21:31:22 +01:00
|
|
|
xmlChar *nsStr = (xmlChar*)This->properties->selectNsStr;
|
|
|
|
struct list *pNsList;
|
2010-09-28 21:35:48 +02:00
|
|
|
VARIANT varStr;
|
|
|
|
HRESULT hr;
|
|
|
|
BSTR bstr;
|
|
|
|
|
|
|
|
V_VT(&varStr) = VT_EMPTY;
|
2012-01-29 10:40:22 +01:00
|
|
|
if (V_VT(&value) != VT_BSTR)
|
2010-09-28 21:35:48 +02:00
|
|
|
{
|
2012-01-29 10:40:22 +01:00
|
|
|
if (FAILED(hr = VariantChangeType(&varStr, &value, 0, VT_BSTR)))
|
2010-09-28 21:35:48 +02:00
|
|
|
return hr;
|
|
|
|
bstr = V_BSTR(&varStr);
|
|
|
|
}
|
|
|
|
else
|
2012-01-29 10:40:22 +01:00
|
|
|
bstr = V_BSTR(&value);
|
2010-09-28 21:35:48 +02:00
|
|
|
|
|
|
|
hr = S_OK;
|
|
|
|
|
2010-09-28 02:59:51 +02:00
|
|
|
pNsList = &(This->properties->selectNsList);
|
2010-09-28 21:35:48 +02:00
|
|
|
clear_selectNsList(pNsList);
|
|
|
|
heap_free(nsStr);
|
2011-03-10 20:15:09 +01:00
|
|
|
nsStr = xmlchar_from_wchar(bstr);
|
2010-09-28 21:35:48 +02:00
|
|
|
|
2012-01-12 21:31:22 +01:00
|
|
|
TRACE("property value: \"%s\"\n", debugstr_w(bstr));
|
2010-09-28 21:35:48 +02:00
|
|
|
|
2010-09-28 02:59:51 +02:00
|
|
|
This->properties->selectNsStr = nsStr;
|
|
|
|
This->properties->selectNsStr_len = xmlStrlen(nsStr);
|
2010-09-28 21:35:48 +02:00
|
|
|
if (bstr && *bstr)
|
|
|
|
{
|
2012-01-12 21:31:22 +01:00
|
|
|
xmlChar *pTokBegin, *pTokEnd, *pTokInner;
|
|
|
|
select_ns_entry* ns_entry = NULL;
|
|
|
|
xmlXPathContextPtr ctx;
|
|
|
|
|
2010-09-28 21:35:48 +02:00
|
|
|
ctx = xmlXPathNewContext(This->node.node->doc);
|
|
|
|
pTokBegin = nsStr;
|
2012-01-12 21:31:22 +01:00
|
|
|
|
|
|
|
/* skip leading spaces */
|
|
|
|
while (*pTokBegin == ' ' || *pTokBegin == '\n' ||
|
|
|
|
*pTokBegin == '\t' || *pTokBegin == '\r')
|
|
|
|
++pTokBegin;
|
|
|
|
|
2010-09-28 21:35:48 +02:00
|
|
|
for (; *pTokBegin; pTokBegin = pTokEnd)
|
|
|
|
{
|
2012-01-12 21:31:22 +01:00
|
|
|
if (ns_entry)
|
|
|
|
memset(ns_entry, 0, sizeof(select_ns_entry));
|
2010-09-28 21:35:48 +02:00
|
|
|
else
|
2012-01-12 21:31:22 +01:00
|
|
|
ns_entry = heap_alloc_zero(sizeof(select_ns_entry));
|
2010-09-28 21:35:48 +02:00
|
|
|
|
|
|
|
while (*pTokBegin == ' ')
|
|
|
|
++pTokBegin;
|
|
|
|
pTokEnd = pTokBegin;
|
|
|
|
while (*pTokEnd != ' ' && *pTokEnd != 0)
|
|
|
|
++pTokEnd;
|
|
|
|
|
2012-07-19 08:24:43 +02:00
|
|
|
/* so it failed to advance which means we've got some trailing spaces */
|
|
|
|
if (pTokEnd == pTokBegin) break;
|
|
|
|
|
2010-09-28 21:35:48 +02:00
|
|
|
if (xmlStrncmp(pTokBegin, (xmlChar const*)"xmlns", 5) != 0)
|
|
|
|
{
|
|
|
|
hr = E_FAIL;
|
|
|
|
WARN("Syntax error in xmlns string: %s\n\tat token: %s\n",
|
2012-01-20 02:00:47 +01:00
|
|
|
debugstr_w(bstr), debugstr_an((const char*)pTokBegin, pTokEnd-pTokBegin));
|
2010-09-28 21:35:48 +02:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
pTokBegin += 5;
|
|
|
|
if (*pTokBegin == '=')
|
|
|
|
{
|
|
|
|
/*valid for XSLPattern?*/
|
|
|
|
FIXME("Setting default xmlns not supported - skipping.\n");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else if (*pTokBegin == ':')
|
|
|
|
{
|
2012-01-12 21:31:22 +01:00
|
|
|
ns_entry->prefix = ++pTokBegin;
|
2010-09-28 21:35:48 +02:00
|
|
|
for (pTokInner = pTokBegin; pTokInner != pTokEnd && *pTokInner != '='; ++pTokInner)
|
|
|
|
;
|
|
|
|
|
|
|
|
if (pTokInner == pTokEnd)
|
|
|
|
{
|
|
|
|
hr = E_FAIL;
|
|
|
|
WARN("Syntax error in xmlns string: %s\n\tat token: %s\n",
|
2012-01-20 02:00:47 +01:00
|
|
|
debugstr_w(bstr), debugstr_an((const char*)pTokBegin, pTokEnd-pTokBegin));
|
2010-09-28 21:35:48 +02:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2012-01-12 21:31:22 +01:00
|
|
|
ns_entry->prefix_end = *pTokInner;
|
2010-09-28 21:35:48 +02:00
|
|
|
*pTokInner = 0;
|
|
|
|
++pTokInner;
|
|
|
|
|
|
|
|
if (pTokEnd-pTokInner > 1 &&
|
|
|
|
((*pTokInner == '\'' && *(pTokEnd-1) == '\'') ||
|
|
|
|
(*pTokInner == '"' && *(pTokEnd-1) == '"')))
|
|
|
|
{
|
2012-01-12 21:31:22 +01:00
|
|
|
ns_entry->href = ++pTokInner;
|
|
|
|
ns_entry->href_end = *(pTokEnd-1);
|
2010-09-28 21:35:48 +02:00
|
|
|
*(pTokEnd-1) = 0;
|
2012-01-12 21:31:22 +01:00
|
|
|
list_add_tail(pNsList, &ns_entry->entry);
|
2010-09-28 21:35:48 +02:00
|
|
|
/*let libxml figure out if they're valid from here ;)*/
|
2012-01-12 21:31:22 +01:00
|
|
|
if (xmlXPathRegisterNs(ctx, ns_entry->prefix, ns_entry->href) != 0)
|
2010-09-28 21:35:48 +02:00
|
|
|
{
|
|
|
|
hr = E_FAIL;
|
|
|
|
}
|
2012-01-12 21:31:22 +01:00
|
|
|
ns_entry = NULL;
|
2010-09-28 21:35:48 +02:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
WARN("Syntax error in xmlns string: %s\n\tat token: %s\n",
|
2012-01-20 02:00:47 +01:00
|
|
|
debugstr_w(bstr), debugstr_an((const char*)pTokInner, pTokEnd-pTokInner));
|
2012-01-12 21:31:22 +01:00
|
|
|
list_add_tail(pNsList, &ns_entry->entry);
|
2010-09-28 21:35:48 +02:00
|
|
|
|
2012-01-12 21:31:22 +01:00
|
|
|
ns_entry = NULL;
|
2010-09-28 21:35:48 +02:00
|
|
|
hr = E_FAIL;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
hr = E_FAIL;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
2012-01-12 21:31:22 +01:00
|
|
|
heap_free(ns_entry);
|
2010-09-28 21:35:48 +02:00
|
|
|
xmlXPathFreeContext(ctx);
|
|
|
|
}
|
|
|
|
|
|
|
|
VariantClear(&varStr);
|
|
|
|
return hr;
|
|
|
|
}
|
2010-10-05 21:56:15 +02:00
|
|
|
else if (lstrcmpiW(p, PropertyProhibitDTDW) == 0 ||
|
2011-03-11 01:32:32 +01:00
|
|
|
lstrcmpiW(p, PropertyNewParserW) == 0 ||
|
|
|
|
lstrcmpiW(p, PropertyResolveExternalsW) == 0)
|
2010-07-27 15:32:51 +02:00
|
|
|
{
|
|
|
|
/* Ignore */
|
2013-05-31 04:59:32 +02:00
|
|
|
FIXME("Ignoring property %s, value %s\n", debugstr_w(p), debugstr_variant(&value));
|
2010-07-27 15:32:51 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
2007-05-09 20:09:11 +02:00
|
|
|
|
2012-01-20 02:00:47 +01:00
|
|
|
FIXME("Unknown property %s\n", debugstr_w(p));
|
2007-05-09 20:09:11 +02:00
|
|
|
return E_FAIL;
|
2007-02-26 13:49:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI domdoc_getProperty(
|
2010-08-29 23:31:49 +02:00
|
|
|
IXMLDOMDocument3* iface,
|
2007-02-26 13:49:12 +01:00
|
|
|
BSTR p,
|
|
|
|
VARIANT* var)
|
|
|
|
{
|
2010-08-29 23:31:49 +02:00
|
|
|
domdoc *This = impl_from_IXMLDOMDocument3( iface );
|
2007-05-09 20:09:11 +02:00
|
|
|
|
2012-03-21 23:37:36 +01:00
|
|
|
TRACE("(%p)->(%s)\n", This, debugstr_w(p));
|
2010-02-17 07:40:40 +01:00
|
|
|
|
2010-09-16 21:59:32 +02:00
|
|
|
if (!var)
|
2007-05-09 20:09:11 +02:00
|
|
|
return E_INVALIDARG;
|
2010-08-29 23:33:54 +02:00
|
|
|
|
|
|
|
if (lstrcmpiW(p, PropertySelectionLanguageW) == 0)
|
2007-05-09 20:09:11 +02:00
|
|
|
{
|
|
|
|
V_VT(var) = VT_BSTR;
|
2010-09-28 02:59:51 +02:00
|
|
|
V_BSTR(var) = This->properties->XPath ?
|
2010-09-16 21:59:32 +02:00
|
|
|
SysAllocString(PropValueXPathW) :
|
|
|
|
SysAllocString(PropValueXSLPatternW);
|
|
|
|
return V_BSTR(var) ? S_OK : E_OUTOFMEMORY;
|
2007-05-09 20:09:11 +02:00
|
|
|
}
|
2010-09-28 21:35:48 +02:00
|
|
|
else if (lstrcmpiW(p, PropertySelectionNamespacesW) == 0)
|
|
|
|
{
|
|
|
|
int lenA, lenW;
|
|
|
|
BSTR rebuiltStr, cur;
|
|
|
|
const xmlChar *nsStr;
|
|
|
|
struct list *pNsList;
|
|
|
|
select_ns_entry* pNsEntry;
|
|
|
|
|
|
|
|
V_VT(var) = VT_BSTR;
|
2010-09-28 02:59:51 +02:00
|
|
|
nsStr = This->properties->selectNsStr;
|
|
|
|
pNsList = &This->properties->selectNsList;
|
|
|
|
lenA = This->properties->selectNsStr_len;
|
2010-09-28 21:35:48 +02:00
|
|
|
lenW = MultiByteToWideChar(CP_UTF8, 0, (LPCSTR)nsStr, lenA+1, NULL, 0);
|
|
|
|
rebuiltStr = heap_alloc(lenW*sizeof(WCHAR));
|
|
|
|
MultiByteToWideChar(CP_UTF8, 0, (LPCSTR)nsStr, lenA+1, rebuiltStr, lenW);
|
|
|
|
cur = rebuiltStr;
|
|
|
|
/* this is fine because all of the chars that end tokens are ASCII*/
|
|
|
|
LIST_FOR_EACH_ENTRY(pNsEntry, pNsList, select_ns_entry, entry)
|
|
|
|
{
|
|
|
|
while (*cur != 0) ++cur;
|
|
|
|
if (pNsEntry->prefix_end)
|
|
|
|
{
|
|
|
|
*cur = pNsEntry->prefix_end;
|
|
|
|
while (*cur != 0) ++cur;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pNsEntry->href_end)
|
|
|
|
{
|
|
|
|
*cur = pNsEntry->href_end;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
V_BSTR(var) = SysAllocString(rebuiltStr);
|
|
|
|
heap_free(rebuiltStr);
|
|
|
|
return S_OK;
|
|
|
|
}
|
2007-05-09 20:09:11 +02:00
|
|
|
|
2012-01-20 02:00:47 +01:00
|
|
|
FIXME("Unknown property %s\n", debugstr_w(p));
|
2007-05-09 20:09:11 +02:00
|
|
|
return E_FAIL;
|
2007-02-26 13:49:12 +01:00
|
|
|
}
|
|
|
|
|
2010-08-29 23:31:49 +02:00
|
|
|
static HRESULT WINAPI domdoc_importNode(
|
|
|
|
IXMLDOMDocument3* iface,
|
|
|
|
IXMLDOMNode* node,
|
|
|
|
VARIANT_BOOL deep,
|
|
|
|
IXMLDOMNode** clone)
|
|
|
|
{
|
|
|
|
domdoc *This = impl_from_IXMLDOMDocument3( iface );
|
|
|
|
FIXME("(%p)->(%p %d %p): stub\n", This, node, deep, clone);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2011-11-19 15:00:24 +01:00
|
|
|
static const struct IXMLDOMDocument3Vtbl XMLDOMDocument3Vtbl =
|
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,
|
2011-02-19 15:09:58 +01:00
|
|
|
domdoc_put_onreadystatechange,
|
2005-08-02 13:29:04 +02:00
|
|
|
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,
|
2010-08-29 23:31:49 +02:00
|
|
|
domdoc_getProperty,
|
|
|
|
domdoc_validateNode,
|
|
|
|
domdoc_importNode
|
2005-08-02 13:29:04 +02:00
|
|
|
};
|
|
|
|
|
2010-10-23 13:55:42 +02:00
|
|
|
/* IConnectionPointContainer */
|
|
|
|
static HRESULT WINAPI ConnectionPointContainer_QueryInterface(IConnectionPointContainer *iface,
|
|
|
|
REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
domdoc *This = impl_from_IConnectionPointContainer(iface);
|
2011-04-26 23:47:48 +02:00
|
|
|
return IXMLDOMDocument3_QueryInterface(&This->IXMLDOMDocument3_iface, riid, ppv);
|
2010-10-23 13:55:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI ConnectionPointContainer_AddRef(IConnectionPointContainer *iface)
|
|
|
|
{
|
|
|
|
domdoc *This = impl_from_IConnectionPointContainer(iface);
|
2011-04-26 23:47:48 +02:00
|
|
|
return IXMLDOMDocument3_AddRef(&This->IXMLDOMDocument3_iface);
|
2010-10-23 13:55:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI ConnectionPointContainer_Release(IConnectionPointContainer *iface)
|
|
|
|
{
|
|
|
|
domdoc *This = impl_from_IConnectionPointContainer(iface);
|
2011-04-26 23:47:48 +02:00
|
|
|
return IXMLDOMDocument3_Release(&This->IXMLDOMDocument3_iface);
|
2010-10-23 13:55:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ConnectionPointContainer_EnumConnectionPoints(IConnectionPointContainer *iface,
|
|
|
|
IEnumConnectionPoints **ppEnum)
|
|
|
|
{
|
|
|
|
domdoc *This = impl_from_IConnectionPointContainer(iface);
|
|
|
|
FIXME("(%p)->(%p): stub\n", This, ppEnum);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ConnectionPointContainer_FindConnectionPoint(IConnectionPointContainer *iface,
|
2010-10-23 15:22:35 +02:00
|
|
|
REFIID riid, IConnectionPoint **cp)
|
2010-10-23 13:55:42 +02:00
|
|
|
{
|
|
|
|
domdoc *This = impl_from_IConnectionPointContainer(iface);
|
2010-10-23 15:22:35 +02:00
|
|
|
ConnectionPoint *iter;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), cp);
|
|
|
|
|
|
|
|
*cp = NULL;
|
|
|
|
|
|
|
|
for(iter = This->cp_list; iter; iter = iter->next)
|
|
|
|
{
|
|
|
|
if (IsEqualGUID(iter->iid, riid))
|
2011-04-26 23:47:48 +02:00
|
|
|
*cp = &iter->IConnectionPoint_iface;
|
2010-10-23 15:22:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (*cp)
|
|
|
|
{
|
|
|
|
IConnectionPoint_AddRef(*cp);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
FIXME("unsupported riid %s\n", debugstr_guid(riid));
|
|
|
|
return CONNECT_E_NOCONNECTION;
|
|
|
|
|
2010-10-23 13:55:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static const struct IConnectionPointContainerVtbl ConnectionPointContainerVtbl =
|
|
|
|
{
|
|
|
|
ConnectionPointContainer_QueryInterface,
|
|
|
|
ConnectionPointContainer_AddRef,
|
|
|
|
ConnectionPointContainer_Release,
|
|
|
|
ConnectionPointContainer_EnumConnectionPoints,
|
|
|
|
ConnectionPointContainer_FindConnectionPoint
|
|
|
|
};
|
|
|
|
|
2010-10-23 15:22:35 +02:00
|
|
|
/* IConnectionPoint */
|
|
|
|
static HRESULT WINAPI ConnectionPoint_QueryInterface(IConnectionPoint *iface,
|
|
|
|
REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
ConnectionPoint *This = impl_from_IConnectionPoint(iface);
|
|
|
|
|
|
|
|
TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv );
|
|
|
|
|
|
|
|
*ppv = NULL;
|
|
|
|
|
|
|
|
if (IsEqualGUID(&IID_IUnknown, riid) ||
|
|
|
|
IsEqualGUID(&IID_IConnectionPoint, riid))
|
|
|
|
{
|
|
|
|
*ppv = iface;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (*ppv)
|
|
|
|
{
|
|
|
|
IConnectionPoint_AddRef(iface);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
WARN("Unsupported interface %s\n", debugstr_guid(riid));
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI ConnectionPoint_AddRef(IConnectionPoint *iface)
|
|
|
|
{
|
|
|
|
ConnectionPoint *This = impl_from_IConnectionPoint(iface);
|
|
|
|
return IConnectionPointContainer_AddRef(This->container);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI ConnectionPoint_Release(IConnectionPoint *iface)
|
|
|
|
{
|
|
|
|
ConnectionPoint *This = impl_from_IConnectionPoint(iface);
|
|
|
|
return IConnectionPointContainer_Release(This->container);
|
|
|
|
}
|
|
|
|
|
2010-10-23 15:31:52 +02:00
|
|
|
static HRESULT WINAPI ConnectionPoint_GetConnectionInterface(IConnectionPoint *iface, IID *iid)
|
2010-10-23 15:22:35 +02:00
|
|
|
{
|
|
|
|
ConnectionPoint *This = impl_from_IConnectionPoint(iface);
|
2010-10-23 15:31:52 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, iid);
|
|
|
|
|
|
|
|
if (!iid) return E_POINTER;
|
|
|
|
|
|
|
|
*iid = *This->iid;
|
|
|
|
return S_OK;
|
2010-10-23 15:22:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ConnectionPoint_GetConnectionPointContainer(IConnectionPoint *iface,
|
2010-10-23 15:33:42 +02:00
|
|
|
IConnectionPointContainer **container)
|
2010-10-23 15:22:35 +02:00
|
|
|
{
|
|
|
|
ConnectionPoint *This = impl_from_IConnectionPoint(iface);
|
2010-10-23 15:33:42 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, container);
|
|
|
|
|
|
|
|
if (!container) return E_POINTER;
|
|
|
|
|
|
|
|
*container = This->container;
|
|
|
|
IConnectionPointContainer_AddRef(*container);
|
|
|
|
return S_OK;
|
2010-10-23 15:22:35 +02:00
|
|
|
}
|
|
|
|
|
2012-09-23 13:55:13 +02:00
|
|
|
static HRESULT WINAPI ConnectionPoint_Advise(IConnectionPoint *iface, IUnknown *unk_sink,
|
|
|
|
DWORD *cookie)
|
2010-10-23 15:22:35 +02:00
|
|
|
{
|
|
|
|
ConnectionPoint *This = impl_from_IConnectionPoint(iface);
|
2012-09-23 13:55:13 +02:00
|
|
|
IUnknown *sink;
|
|
|
|
HRESULT hr;
|
2013-02-19 23:24:44 +01:00
|
|
|
DWORD i;
|
2012-09-23 13:55:13 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p %p)\n", This, unk_sink, cookie);
|
|
|
|
|
|
|
|
hr = IUnknown_QueryInterface(unk_sink, This->iid, (void**)&sink);
|
|
|
|
if(FAILED(hr) && !IsEqualGUID(&IID_IPropertyNotifySink, This->iid))
|
|
|
|
hr = IUnknown_QueryInterface(unk_sink, &IID_IDispatch, (void**)&sink);
|
|
|
|
if(FAILED(hr))
|
|
|
|
return CONNECT_E_CANNOTCONNECT;
|
|
|
|
|
|
|
|
if(This->sinks)
|
|
|
|
{
|
|
|
|
for (i = 0; i < This->sinks_size; i++)
|
|
|
|
if (!This->sinks[i].unk)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (i == This->sinks_size)
|
|
|
|
This->sinks = heap_realloc(This->sinks,(++This->sinks_size)*sizeof(*This->sinks));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
This->sinks = heap_alloc(sizeof(*This->sinks));
|
|
|
|
This->sinks_size = 1;
|
|
|
|
i = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
This->sinks[i].unk = sink;
|
|
|
|
if (cookie)
|
|
|
|
*cookie = i+1;
|
|
|
|
|
|
|
|
return S_OK;
|
2010-10-23 15:22:35 +02:00
|
|
|
}
|
|
|
|
|
2010-10-23 15:40:06 +02:00
|
|
|
static HRESULT WINAPI ConnectionPoint_Unadvise(IConnectionPoint *iface, DWORD cookie)
|
2010-10-23 15:22:35 +02:00
|
|
|
{
|
|
|
|
ConnectionPoint *This = impl_from_IConnectionPoint(iface);
|
2010-10-23 15:40:06 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%d)\n", This, cookie);
|
|
|
|
|
|
|
|
if (cookie == 0 || cookie > This->sinks_size || !This->sinks[cookie-1].unk)
|
|
|
|
return CONNECT_E_NOCONNECTION;
|
|
|
|
|
|
|
|
IUnknown_Release(This->sinks[cookie-1].unk);
|
|
|
|
This->sinks[cookie-1].unk = NULL;
|
|
|
|
|
|
|
|
return S_OK;
|
2010-10-23 15:22:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ConnectionPoint_EnumConnections(IConnectionPoint *iface,
|
|
|
|
IEnumConnections **ppEnum)
|
|
|
|
{
|
|
|
|
ConnectionPoint *This = impl_from_IConnectionPoint(iface);
|
|
|
|
FIXME("(%p)->(%p): stub\n", This, ppEnum);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IConnectionPointVtbl ConnectionPointVtbl =
|
|
|
|
{
|
|
|
|
ConnectionPoint_QueryInterface,
|
|
|
|
ConnectionPoint_AddRef,
|
|
|
|
ConnectionPoint_Release,
|
|
|
|
ConnectionPoint_GetConnectionInterface,
|
|
|
|
ConnectionPoint_GetConnectionPointContainer,
|
|
|
|
ConnectionPoint_Advise,
|
|
|
|
ConnectionPoint_Unadvise,
|
|
|
|
ConnectionPoint_EnumConnections
|
|
|
|
};
|
|
|
|
|
2011-03-16 08:30:45 +01:00
|
|
|
static void ConnectionPoint_Init(ConnectionPoint *cp, struct domdoc *doc, REFIID riid)
|
2010-10-23 15:22:35 +02:00
|
|
|
{
|
2011-04-26 23:47:48 +02:00
|
|
|
cp->IConnectionPoint_iface.lpVtbl = &ConnectionPointVtbl;
|
2010-10-23 15:22:35 +02:00
|
|
|
cp->doc = doc;
|
|
|
|
cp->iid = riid;
|
2010-10-23 15:40:06 +02:00
|
|
|
cp->sinks = NULL;
|
|
|
|
cp->sinks_size = 0;
|
2010-10-23 15:22:35 +02:00
|
|
|
|
|
|
|
cp->next = doc->cp_list;
|
|
|
|
doc->cp_list = cp;
|
|
|
|
|
2011-04-26 23:47:48 +02:00
|
|
|
cp->container = &doc->IConnectionPointContainer_iface;
|
2010-10-23 15:22:35 +02:00
|
|
|
}
|
|
|
|
|
2010-10-23 15:47:30 +02:00
|
|
|
/* domdoc implementation of IObjectWithSite */
|
2008-04-26 14:55:05 +02:00
|
|
|
static HRESULT WINAPI
|
2010-10-23 15:47:30 +02:00
|
|
|
domdoc_ObjectWithSite_QueryInterface( IObjectWithSite* iface, REFIID riid, void** ppvObject )
|
2008-04-26 14:55:05 +02:00
|
|
|
{
|
|
|
|
domdoc *This = impl_from_IObjectWithSite(iface);
|
2011-04-26 23:47:48 +02:00
|
|
|
return IXMLDOMDocument3_QueryInterface(&This->IXMLDOMDocument3_iface, riid, ppvObject);
|
2008-04-26 14:55:05 +02:00
|
|
|
}
|
|
|
|
|
2010-10-23 15:47:30 +02:00
|
|
|
static ULONG WINAPI domdoc_ObjectWithSite_AddRef( IObjectWithSite* iface )
|
2008-04-26 14:55:05 +02:00
|
|
|
{
|
|
|
|
domdoc *This = impl_from_IObjectWithSite(iface);
|
2011-04-26 23:47:48 +02:00
|
|
|
return IXMLDOMDocument3_AddRef(&This->IXMLDOMDocument3_iface);
|
2008-04-26 14:55:05 +02:00
|
|
|
}
|
|
|
|
|
2010-10-23 15:47:30 +02:00
|
|
|
static ULONG WINAPI domdoc_ObjectWithSite_Release( IObjectWithSite* iface )
|
2008-04-26 14:55:05 +02:00
|
|
|
{
|
|
|
|
domdoc *This = impl_from_IObjectWithSite(iface);
|
2011-04-26 23:47:48 +02:00
|
|
|
return IXMLDOMDocument3_Release(&This->IXMLDOMDocument3_iface);
|
2008-04-26 14:55:05 +02:00
|
|
|
}
|
|
|
|
|
2010-10-23 15:47:30 +02:00
|
|
|
static HRESULT WINAPI domdoc_ObjectWithSite_GetSite( IObjectWithSite *iface, REFIID iid, void **ppvSite )
|
2008-04-26 14:55:05 +02:00
|
|
|
{
|
|
|
|
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 );
|
|
|
|
}
|
|
|
|
|
2010-10-23 15:47:30 +02:00
|
|
|
static HRESULT WINAPI domdoc_ObjectWithSite_SetSite( IObjectWithSite *iface, IUnknown *punk )
|
2008-04-26 14:55:05 +02:00
|
|
|
{
|
|
|
|
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 =
|
|
|
|
{
|
2010-10-23 15:47:30 +02:00
|
|
|
domdoc_ObjectWithSite_QueryInterface,
|
|
|
|
domdoc_ObjectWithSite_AddRef,
|
|
|
|
domdoc_ObjectWithSite_Release,
|
|
|
|
domdoc_ObjectWithSite_SetSite,
|
|
|
|
domdoc_ObjectWithSite_GetSite
|
2008-04-26 14:55:05 +02:00
|
|
|
};
|
|
|
|
|
2010-10-23 15:47:30 +02:00
|
|
|
static HRESULT WINAPI domdoc_Safety_QueryInterface(IObjectSafety *iface, REFIID riid, void **ppv)
|
2008-04-29 12:52:00 +02:00
|
|
|
{
|
|
|
|
domdoc *This = impl_from_IObjectSafety(iface);
|
2011-04-26 23:47:48 +02:00
|
|
|
return IXMLDOMDocument3_QueryInterface(&This->IXMLDOMDocument3_iface, riid, ppv);
|
2008-04-29 12:52:00 +02:00
|
|
|
}
|
|
|
|
|
2010-10-23 15:47:30 +02:00
|
|
|
static ULONG WINAPI domdoc_Safety_AddRef(IObjectSafety *iface)
|
2008-04-29 12:52:00 +02:00
|
|
|
{
|
|
|
|
domdoc *This = impl_from_IObjectSafety(iface);
|
2011-04-26 23:47:48 +02:00
|
|
|
return IXMLDOMDocument3_AddRef(&This->IXMLDOMDocument3_iface);
|
2008-04-29 12:52:00 +02:00
|
|
|
}
|
|
|
|
|
2010-10-23 15:47:30 +02:00
|
|
|
static ULONG WINAPI domdoc_Safety_Release(IObjectSafety *iface)
|
2008-04-29 12:52:00 +02:00
|
|
|
{
|
|
|
|
domdoc *This = impl_from_IObjectSafety(iface);
|
2011-04-26 23:47:48 +02:00
|
|
|
return IXMLDOMDocument3_Release(&This->IXMLDOMDocument3_iface);
|
2008-04-29 12:52:00 +02:00
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2010-10-23 15:47:30 +02:00
|
|
|
static HRESULT WINAPI domdoc_Safety_GetInterfaceSafetyOptions(IObjectSafety *iface, REFIID riid,
|
|
|
|
DWORD *supported, DWORD *enabled)
|
2008-04-29 12:52:00 +02:00
|
|
|
{
|
|
|
|
domdoc *This = impl_from_IObjectSafety(iface);
|
|
|
|
|
2010-10-23 15:47:30 +02:00
|
|
|
TRACE("(%p)->(%s %p %p)\n", This, debugstr_guid(riid), supported, enabled);
|
2008-04-29 12:52:00 +02:00
|
|
|
|
2010-10-23 15:47:30 +02:00
|
|
|
if(!supported || !enabled) return E_POINTER;
|
2008-04-29 12:52:00 +02:00
|
|
|
|
2010-10-23 15:47:30 +02:00
|
|
|
*supported = SAFETY_SUPPORTED_OPTIONS;
|
|
|
|
*enabled = This->safeopt;
|
2008-04-29 12:52:00 +02:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2010-10-23 15:47:30 +02:00
|
|
|
static HRESULT WINAPI domdoc_Safety_SetInterfaceSafetyOptions(IObjectSafety *iface, REFIID riid,
|
|
|
|
DWORD mask, DWORD enabled)
|
2008-04-29 12:52:00 +02:00
|
|
|
{
|
|
|
|
domdoc *This = impl_from_IObjectSafety(iface);
|
2010-10-23 15:47:30 +02:00
|
|
|
TRACE("(%p)->(%s %x %x)\n", This, debugstr_guid(riid), mask, enabled);
|
2008-04-29 12:52:00 +02:00
|
|
|
|
2010-10-23 15:47:30 +02:00
|
|
|
if ((mask & ~SAFETY_SUPPORTED_OPTIONS) != 0)
|
2010-02-28 22:24:47 +01:00
|
|
|
return E_FAIL;
|
|
|
|
|
2011-08-30 14:27:02 +02:00
|
|
|
This->safeopt = (This->safeopt & ~mask) | (mask & enabled);
|
|
|
|
|
2008-04-29 12:52:00 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2010-10-23 15:47:30 +02:00
|
|
|
#undef SAFETY_SUPPORTED_OPTIONS
|
|
|
|
|
2008-04-29 12:52:00 +02:00
|
|
|
static const IObjectSafetyVtbl domdocObjectSafetyVtbl = {
|
2010-10-23 15:47:30 +02:00
|
|
|
domdoc_Safety_QueryInterface,
|
|
|
|
domdoc_Safety_AddRef,
|
|
|
|
domdoc_Safety_Release,
|
|
|
|
domdoc_Safety_GetInterfaceSafetyOptions,
|
|
|
|
domdoc_Safety_SetInterfaceSafetyOptions
|
2008-04-29 12:52:00 +02:00
|
|
|
};
|
|
|
|
|
2008-09-03 02:23:10 +02:00
|
|
|
static const tid_t domdoc_iface_tids[] = {
|
2011-11-19 15:00:24 +01:00
|
|
|
IXMLDOMDocument3_tid,
|
2008-09-03 02:23:10 +02:00
|
|
|
0
|
|
|
|
};
|
2011-11-19 15:00:24 +01:00
|
|
|
|
2008-09-03 02:23:10 +02:00
|
|
|
static dispex_static_data_t domdoc_dispex = {
|
|
|
|
NULL,
|
2011-11-19 15:00:24 +01:00
|
|
|
IXMLDOMDocument3_tid,
|
2008-09-03 02:23:10 +02:00
|
|
|
NULL,
|
|
|
|
domdoc_iface_tids
|
|
|
|
};
|
|
|
|
|
2011-02-23 12:38:32 +01:00
|
|
|
HRESULT get_domdoc_from_xmldoc(xmlDocPtr xmldoc, IXMLDOMDocument3 **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;
|
|
|
|
|
2011-11-19 15:00:24 +01:00
|
|
|
doc->IXMLDOMDocument3_iface.lpVtbl = &XMLDOMDocument3Vtbl;
|
2011-04-26 23:47:48 +02:00
|
|
|
doc->IPersistStreamInit_iface.lpVtbl = &xmldoc_IPersistStreamInit_VTable;
|
|
|
|
doc->IObjectWithSite_iface.lpVtbl = &domdocObjectSite;
|
|
|
|
doc->IObjectSafety_iface.lpVtbl = &domdocObjectSafetyVtbl;
|
|
|
|
doc->IConnectionPointContainer_iface.lpVtbl = &ConnectionPointContainerVtbl;
|
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;
|
2010-09-28 02:59:51 +02:00
|
|
|
doc->properties = properties_from_xmlDocPtr(xmldoc);
|
2006-02-21 12:52:25 +01:00
|
|
|
doc->error = S_OK;
|
2008-04-26 14:55:05 +02:00
|
|
|
doc->site = NULL;
|
2008-04-29 12:52:00 +02:00
|
|
|
doc->safeopt = 0;
|
2010-10-23 15:22:35 +02:00
|
|
|
doc->cp_list = NULL;
|
2012-01-24 08:40:56 +01:00
|
|
|
doc->namespaces = NULL;
|
2011-02-19 15:09:58 +01:00
|
|
|
memset(doc->events, 0, sizeof(doc->events));
|
2010-10-23 15:22:35 +02:00
|
|
|
|
|
|
|
/* events connection points */
|
|
|
|
ConnectionPoint_Init(&doc->cp_dispatch, doc, &IID_IDispatch);
|
|
|
|
ConnectionPoint_Init(&doc->cp_propnotif, doc, &IID_IPropertyNotifySink);
|
|
|
|
ConnectionPoint_Init(&doc->cp_domdocevents, doc, &DIID_XMLDOMDocumentEvents);
|
2005-12-01 18:46:42 +01:00
|
|
|
|
2011-04-26 23:47:48 +02:00
|
|
|
init_xmlnode(&doc->node, (xmlNodePtr)xmldoc, (IXMLDOMNode*)&doc->IXMLDOMDocument3_iface,
|
|
|
|
&domdoc_dispex);
|
2005-12-01 18:46:42 +01:00
|
|
|
|
2011-04-26 23:47:48 +02:00
|
|
|
*document = &doc->IXMLDOMDocument3_iface;
|
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;
|
|
|
|
}
|
|
|
|
|
2014-01-09 12:57:58 +01:00
|
|
|
HRESULT DOMDocument_create(MSXML_VERSION version, void **ppObj)
|
2008-07-08 20:55:47 +02:00
|
|
|
{
|
|
|
|
xmlDocPtr xmldoc;
|
|
|
|
HRESULT hr;
|
|
|
|
|
2014-01-09 12:57:58 +01:00
|
|
|
TRACE("(%d, %p)\n", version, ppObj);
|
2008-07-08 20:55:47 +02:00
|
|
|
|
|
|
|
xmldoc = xmlNewDoc(NULL);
|
|
|
|
if(!xmldoc)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
2012-01-23 15:36:35 +01:00
|
|
|
xmldoc_init(xmldoc, version);
|
2008-07-08 20:55:47 +02:00
|
|
|
|
2011-02-23 12:38:32 +01:00
|
|
|
hr = get_domdoc_from_xmldoc(xmldoc, (IXMLDOMDocument3**)ppObj);
|
2008-07-08 20:55:47 +02:00
|
|
|
if(FAILED(hr))
|
2010-09-16 21:59:32 +02:00
|
|
|
{
|
2010-10-14 17:24:40 +02:00
|
|
|
free_properties(properties_from_xmlDocPtr(xmldoc));
|
|
|
|
heap_free(xmldoc->_private);
|
2008-07-08 20:55:47 +02:00
|
|
|
xmlFreeDoc(xmldoc);
|
2010-09-16 21:59:32 +02:00
|
|
|
return hr;
|
|
|
|
}
|
2008-07-08 20:55:47 +02:00
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2008-07-16 14:13:18 +02:00
|
|
|
IUnknown* create_domdoc( xmlNodePtr document )
|
|
|
|
{
|
2010-08-29 23:32:11 +02:00
|
|
|
void* pObj = NULL;
|
2008-07-16 14:13:18 +02:00
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("(%p)\n", document);
|
|
|
|
|
2011-02-23 12:38:32 +01:00
|
|
|
hr = get_domdoc_from_xmldoc((xmlDocPtr)document, (IXMLDOMDocument3**)&pObj);
|
2008-07-16 14:13:18 +02:00
|
|
|
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
|
|
|
|
|
2014-01-09 12:57:58 +01:00
|
|
|
HRESULT DOMDocument_create(MSXML_VERSION version, void **ppObj)
|
2005-08-02 13:29:04 +02:00
|
|
|
{
|
|
|
|
MESSAGE("This program tried to use a DOMDocument object, but\n"
|
|
|
|
"libxml2 support was not present at compile time.\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|