From 524a817195dbe147f632f9af533c155c2a731eb6 Mon Sep 17 00:00:00 2001 From: Alistair Leslie-Hughes Date: Thu, 29 Sep 2011 14:30:30 +1000 Subject: [PATCH] msxml3: Implement IXMLParser Get/Set Flags. --- .gitignore | 1 + dlls/msxml3/tests/Makefile.in | 2 + dlls/msxml3/tests/xmlparser.c | 23 +- dlls/msxml3/tests/xmlparser.idl | 381 ++++++++++++++++++++++++++++++++ dlls/msxml3/tests/xmlview.c | 3 +- dlls/msxml3/xmlparser.c | 13 +- 6 files changed, 410 insertions(+), 13 deletions(-) create mode 100644 dlls/msxml3/tests/xmlparser.idl diff --git a/.gitignore b/.gitignore index f1215319bd..c70b20a5f0 100644 --- a/.gitignore +++ b/.gitignore @@ -80,6 +80,7 @@ dlls/msi/sql.tab.c dlls/msi/sql.tab.h dlls/mstask/mstask_local.h dlls/mstask/mstask_local_i.c +dlls/msxml3/tests/xmlparser.h dlls/msxml3/xmlparser.h dlls/msxml3/xslpattern.tab.c dlls/msxml3/xslpattern.tab.h diff --git a/dlls/msxml3/tests/Makefile.in b/dlls/msxml3/tests/Makefile.in index 05c4f50707..a2765a7fd4 100644 --- a/dlls/msxml3/tests/Makefile.in +++ b/dlls/msxml3/tests/Makefile.in @@ -9,6 +9,8 @@ C_SRCS = \ xmlparser.c \ xmlview.c +IDL_H_SRCS = xmlparser.idl + RC_SRCS = rsrc.rc @MAKE_TEST_RULES@ diff --git a/dlls/msxml3/tests/xmlparser.c b/dlls/msxml3/tests/xmlparser.c index ec83a81c7e..4bf80bbee9 100644 --- a/dlls/msxml3/tests/xmlparser.c +++ b/dlls/msxml3/tests/xmlparser.c @@ -25,17 +25,14 @@ #include "windows.h" #include "ole2.h" -#include "initguid.h" - +#include "xmlparser.h" #include "wine/test.h" -DEFINE_GUID(IID_IXMLParser, 0xd242361e, 0x51a0, 0x11d2, 0x9c,0xaf, 0x00,0x60,0xb0,0xec,0x3d,0x39); -DEFINE_GUID(CLSID_XMLParser30, 0xf5078f31, 0xc551, 0x11d3, 0x89,0xb9, 0x00,0x00,0xf8,0x1f,0xe2,0x21); - static void create_test(void) { HRESULT hr; - IUnknown *parser; + IXMLParser *parser; + DWORD flags; hr = CoCreateInstance(&CLSID_XMLParser30, NULL, CLSCTX_INPROC_SERVER, &IID_IXMLParser, (void**)&parser); if (FAILED(hr)) @@ -44,7 +41,19 @@ static void create_test(void) return; } - IUnknown_Release(parser); + flags = IXMLParser_GetFlags(parser); + ok(flags == 0, "Expected 0 got %d\n", flags); + + hr = IXMLParser_SetFlags(parser, XMLFLAG_SAX); + ok(hr == S_OK, "Expected S_OK got 0x%08x\n", hr); + + flags = IXMLParser_GetFlags(parser); + ok(flags == XMLFLAG_SAX, "Expected 0 got %d\n", flags); + + hr = IXMLParser_SetFlags(parser, 0); + ok(hr == S_OK, "Expected S_OK got 0x%08x\n", hr); + + IXMLParser_Release(parser); } START_TEST(xmlparser) diff --git a/dlls/msxml3/tests/xmlparser.idl b/dlls/msxml3/tests/xmlparser.idl new file mode 100644 index 0000000000..a0ce97efd7 --- /dev/null +++ b/dlls/msxml3/tests/xmlparser.idl @@ -0,0 +1,381 @@ +/* + * Copyright (C) 2011 Alistair Leslie-Hughes + * + * This library is free software; you can redistribute it and/or + * 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. + * + * This library is distributed in the hope that it will be useful, + * 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 + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +import "unknwn.idl"; +import "objidl.idl"; +import "oaidl.idl"; + +interface IXMLNodeSource; +interface IXMLParser; +interface IXMLNodeFactory; +interface IMoniker; + +typedef enum +{ + XML_ELEMENT = 1, + XML_ATTRIBUTE, + XML_PI, + XML_XMLDECL, + XML_DOCTYPE, + XML_DTDATTRIBUTE, + XML_ENTITYDECL, + XML_ELEMENTDECL, + XML_ATTLISTDECL, + XML_NOTATION, + XML_GROUP, + XML_INCLUDESECT, + XML_PCDATA, + XML_CDATA, + XML_IGNORESECT, + XML_COMMENT, + XML_ENTITYREF, + XML_WHITESPACE, + XML_NAME, + XML_NMTOKEN, + XML_STRING, + XML_PEREF, + XML_MODEL, + XML_ATTDEF, + XML_ATTTYPE, + XML_ATTPRESENCE, + XML_DTDSUBSET, + XML_LASTNODETYPE +} XML_NODE_TYPE; + +typedef enum +{ + XML_VERSION = XML_LASTNODETYPE, + XML_ENCODING, + XML_STANDALONE, + XML_NS, + XML_XMLSPACE, + XML_XMLLANG, + XML_SYSTEM, + XML_PUBLIC, + XML_NDATA, + XML_AT_CDATA, + XML_AT_ID, + XML_AT_IDREF, + XML_AT_IDREFS, + XML_AT_ENTITY, + XML_AT_ENTITIES, + XML_AT_NMTOKEN, + XML_AT_NMTOKENS, + XML_AT_NOTATION, + XML_AT_REQUIRED, + XML_AT_IMPLIED, + XML_AT_FIXED, + XML_PENTITYDECL, + XML_EMPTY, + XML_ANY, + XML_MIXED, + XML_SEQUENCE, + XML_CHOICE, + XML_STAR, + XML_PLUS, + XML_QUESTIONMARK, + XML_LASTSUBNODETYPE +} +XML_NODE_SUBTYPE; + +typedef enum +{ + XML_E_PARSEERRORBASE = 0xC00CE500L, + + XML_E_ENDOFINPUT = XML_E_PARSEERRORBASE, + XML_E_MISSINGEQUALS = 0xC00CE501, + XML_E_MISSINGQUOTE = 0xC00CE502, + XML_E_COMMENTSYNTAX = 0xC00CE503, + XML_E_BADSTARTNAMECHAR = 0xC00CE504, + XML_E_BADNAMECHAR = 0xC00CE505, + XML_E_BADCHARINSTRING = 0xC00CE506, + XML_E_XMLDECLSYNTAX = 0xC00CE507, + XML_E_BADCHARDATA = 0xC00CE508, + XML_E_MISSINGWHITESPACE = 0xC00CE509, + XML_E_EXPECTINGTAGEND = 0xC00CE50A, + XML_E_BADCHARINDTD = 0xC00CE50B, + XML_E_BADCHARINDECL = 0xC00CE50C, + XML_E_MISSINGSEMICOLON = 0xC00CE50D, + XML_E_BADCHARINENTREF = 0xC00CE50E, + XML_E_UNBALANCEDPAREN = 0xC00CE50F, + XML_E_EXPECTINGOPENBRACKET = 0xC00CE510, + XML_E_BADENDCONDSECT = 0xC00CE511, + XML_E_INTERNALERROR = 0xC00CE512, + XML_E_UNEXPECTED_WHITESPACE = 0xC00CE513, + XML_E_INCOMPLETE_ENCODING = 0xC00CE514, + XML_E_BADCHARINMIXEDMODEL = 0xC00CE515, + XML_E_MISSING_STAR = 0xC00CE516, + XML_E_BADCHARINMODEL = 0xC00CE517, + XML_E_MISSING_PAREN = 0xC00CE518, + XML_E_BADCHARINENUMERATION = 0xC00CE519, + XML_E_PIDECLSYNTAX = 0xC00CE51A, + XML_E_EXPECTINGCLOSEQUOTE = 0xC00CE51B, + XML_E_MULTIPLE_COLONS = 0xC00CE51C, + XML_E_INVALID_DECIMAL = 0xC00CE51D, + XML_E_INVALID_HEXIDECIMAL = 0xC00CE51E, + XML_E_INVALID_UNICODE = 0xC00CE51F, + XML_E_WHITESPACEORQUESTIONMARK = 0xC00CE520, + XML_E_ENDOFPE = 0xC00CE521, + + XML_E_TOKEN_ERROR = XML_E_PARSEERRORBASE + 0x50, + XML_E_SUSPENDED = 0xC00CE550, + XML_E_STOPPED = 0xC00CE551, + XML_E_UNEXPECTEDENDTAG = 0xC00CE552, + XML_E_UNCLOSEDTAG = 0xC00CE553, + XML_E_DUPLICATEATTRIBUTE = 0xC00CE554, + XML_E_MULTIPLEROOTS = 0xC00CE555, + XML_E_INVALIDATROOTLEVEL = 0xC00CE556, + XML_E_BADXMLDECL = 0xC00CE557, + XML_E_MISSINGROOT = 0xC00CE558, + XML_E_UNEXPECTEDEOF = 0xC00CE559, + XML_E_BADPEREFINSUBSET = 0xC00CE55A, + XML_E_PE_NESTING = 0xC00CE55B, + XML_E_INVALID_CDATACLOSINGTAG = 0xC00CE55C, + XML_E_UNCLOSEDPI = 0xC00CE55D, + XML_E_UNCLOSEDSTARTTAG = 0xC00CE55E, + XML_E_UNCLOSEDENDTAG = 0xC00CE55F, + XML_E_UNCLOSEDSTRING = 0xC00CE560, + XML_E_UNCLOSEDCOMMENT = 0xC00CE561, + XML_E_UNCLOSEDDECL = 0xC00CE562, + XML_E_UNCLOSEDMARKUPDECL = 0xC00CE563, + XML_E_UNCLOSEDCDATA = 0xC00CE564, + XML_E_BADDECLNAME = 0xC00CE565, + XML_E_BADEXTERNALID = 0xC00CE566, + XML_E_BADELEMENTINDTD = 0xC00CE567, + XML_E_RESERVEDNAMESPACE = 0xC00CE568, + XML_E_EXPECTING_VERSION = 0xC00CE569, + XML_E_EXPECTING_ENCODING = 0xC00CE56A, + XML_E_EXPECTING_NAME = 0xC00CE56B, + XML_E_UNEXPECTED_ATTRIBUTE = 0xC00CE56C, + XML_E_ENDTAGMISMATCH = 0xC00CE56D, + XML_E_INVALIDENCODING = 0xC00CE56E, + XML_E_INVALIDSWITCH = 0xC00CE56F, + XML_E_EXPECTING_NDATA = 0xC00CE570, + XML_E_INVALID_MODEL = 0xC00CE571, + XML_E_INVALID_TYPE = 0xC00CE572, + XML_E_INVALIDXMLSPACE = 0xC00CE573, + XML_E_MULTI_ATTR_VALUE = 0xC00CE574, + XML_E_INVALID_PRESENCE = 0xC00CE575, + XML_E_BADXMLCASE = 0xC00CE576, + XML_E_CONDSECTINSUBSET = 0xC00CE577, + XML_E_CDATAINVALID = 0xC00CE578, + XML_E_INVALID_STANDALONE = 0xC00CE579, + XML_E_UNEXPECTED_STANDALONE = 0xC00CE57A, + XML_E_DOCTYPE_IN_DTD = 0xC00CE57B, + XML_E_MISSING_ENTITY = 0xC00CE57C, + XML_E_ENTITYREF_INNAME = 0xC00CE57D, + XML_E_DOCTYPE_OUTSIDE_PROLOG = 0xC00CE57E, + XML_E_INVALID_VERSION = 0xC00CE57F, + XML_E_DTDELEMENT_OUTSIDE_DTD = 0xC00CE580, + XML_E_DUPLICATEDOCTYPE = 0xC00CE581, + XML_E_RESOURCE = 0xC00CE582, + XML_E_MISSINGNAME = 0xC00CE583, + XML_E_LASTERROR = 0xC00CE584 +} XML_ERROR_CODE; + +typedef enum +{ + XMLPARSER_IDLE, + XMLPARSER_WAITING, + XMLPARSER_BUSY, + XMLPARSER_ERROR, + XMLPARSER_STOPPED, + XMLPARSER_SUSPENDED +} XML_PARSER_STATE; + +typedef enum +{ + XMLFLAG_FLOATINGAMP = 0x00000001, + XMLFLAG_SHORTENDTAGS = 0x00000002, + XMLFLAG_CASEINSENSITIVE = 0x00000004, + XMLFLAG_NONAMESPACES = 0x00000008, + XMLFLAG_NOWHITESPACE = 0x00000010, + XMLFLAG_IE4QUIRKS = 0x00000020, + XMLFLAG_NODTDNODES = 0x00000040, + XMLFLAG_IE4COMPATIBILITY = 0x000000FF, + XMLFLAG_IE5COMPATIBILITY = 0x00000100, + XMLFLAG_SAX = 0x00000200, + XMLFLAG_NORMALIZELB = 0x00000400, + XMLFLAG_IGNOREENCODING = 0x00000800, + XMLFLAG_USEWINHTTP = 0x00001000, + XMLFLAG_RUNBUFFERONLY = 0x00002000, + XMLFLAG_PROHIBIT_DTD = 0x00008000 +} XML_PARSER_FLAGS; + + +typedef enum +{ + XMLNF_STARTDOCUMENT, + XMLNF_STARTDTD, + XMLNF_ENDDTD, + XMLNF_STARTDTDSUBSET, + XMLNF_ENDDTDSUBSET, + XMLNF_ENDPROLOG, + XMLNF_STARTENTITY, + XMLNF_ENDENTITY, + XMLNF_ENDDOCUMENT, + XMLNF_DATAAVAILABLE, + XMLNF_LASTEVENT = XMLNF_DATAAVAILABLE +} XML_NODEFACTORY_EVENT; + +typedef struct _XML_NODE_INFO +{ + DWORD dwSize; + DWORD dwType; + DWORD dwSubType; + BOOL fTerminal; + const WCHAR* pwcText; + ULONG ulLen; + ULONG ulNsPrefixLen; + PVOID pNode; + PVOID pReserved; +} XML_NODE_INFO; + +[ + uuid(d242361c-51a0-11d2-9caf-0060b0ec3d39), + helpstring("Microsoft XML Parser 1.0"), + lcid(0x0000), + version(1.0) +] +library XMLPSR +{ +importlib("stdole32.tlb"); +importlib("stdole2.tlb"); + +[ + local, + object, + pointer_default(unique), + helpstring("IXMLNodeFactory Interface"), + uuid(d242361f-51a0-11d2-9caf-0060b0ec3d39) +] +interface IXMLNodeFactory : IUnknown +{ + HRESULT NotifyEvent([in] IXMLNodeSource* pSource,[in] XML_NODEFACTORY_EVENT iEvt); + HRESULT BeginChildren([in] IXMLNodeSource* pSource, [in] XML_NODE_INFO* pNodeInfo); + HRESULT EndChildren([in] IXMLNodeSource* pSource, [in] BOOL fEmpty, [in] XML_NODE_INFO* pNodeInfo); + HRESULT Error([in] IXMLNodeSource* pSource,[in] HRESULT hrErrorCode, + [in] USHORT cNumRecs, [in] XML_NODE_INFO** ppNodeInfo); + HRESULT CreateNode([in] IXMLNodeSource* pSource, [in] PVOID pNodeParent, [in] USHORT cNumRecs, + [in] XML_NODE_INFO** ppNodeInfo); +}; + +[ + local, + object, + pointer_default(unique), + uuid(d242361d-51a0-11d2-9caf-0060b0ec3d39) +] +interface IXMLNodeSource : IUnknown +{ + HRESULT SetFactory([in] IXMLNodeFactory* pNodeFactory); + HRESULT GetFactory([out] IXMLNodeFactory** ppNodeFactory); + HRESULT Abort([in] BSTR bstrErrorInfo); + ULONG GetLineNumber(); + ULONG GetLinePosition(); + ULONG GetAbsolutePosition(); + HRESULT GetLineBuffer([out] const WCHAR** ppBuf,[out] ULONG* Len, [out] ULONG* StartPos); + HRESULT GetLastError(); + HRESULT GetErrorInfo([out] BSTR* pErrorInfo); + ULONG GetFlags(); + HRESULT GetURL([out] const WCHAR** ppBuf); +}; + +[ + local, + object, + pointer_default(unique), + helpstring("IXMLParser Interface"), + uuid(d242361e-51a0-11d2-9caf-0060b0ec3d39) +] +interface IXMLParser : IXMLNodeSource +{ + HRESULT SetURL([in] const WCHAR* pszBaseUrl,[in] const WCHAR* pszRelativeUrl,[in] BOOL fAsync); + HRESULT Load([in] BOOL fFullyAvailable, [in] IMoniker *pimkName, [in] LPBC pibc, [in] DWORD grfMode); + HRESULT SetInput([in] IUnknown *pStm); + HRESULT PushData([in] const char* pData, [in] ULONG ulChars, [in] BOOL fLastBuffer); + HRESULT LoadDTD([in] const WCHAR* pszBaseUrl, [in] const WCHAR* pszRelativeUrl); + HRESULT LoadEntity([in] const WCHAR* pszBaseUrl, [in] const WCHAR* pszRelativeUrl, [in] BOOL fpe); + HRESULT ParseEntity([in] const WCHAR* pwcText, [in] ULONG ulLen, [in] BOOL fpe); + HRESULT ExpandEntity([in] const WCHAR* pwcText, [in] ULONG ulLen); + HRESULT SetRoot([in] PVOID pRoot); + HRESULT GetRoot([in] PVOID* ppRoot); + HRESULT Run([in] long lChars); + HRESULT GetParserState(); + HRESULT Suspend(); + HRESULT Reset(); + HRESULT SetFlags([in] ULONG iFlags); + HRESULT SetSecureBaseURL([in] const WCHAR* pszBaseUrl); + HRESULT GetSecureBaseURL([out] const WCHAR** ppwcBuf); +}; + +} + +[ + helpstring("XML Parser"), + uuid(f5078f19-c551-11d3-89b9-0000f81fe221), + threading(both), + progid("Msxml2.XMLParser"), + vi_progid("Msxml2.XMLParser"), + version(3.0) +] +coclass XMLParser +{ + [default] interface IXMLParser; +}; + +[ + helpstring("XML Parser 2.6"), + uuid(f5078f20-c551-11d3-89b9-0000f81fe221), + threading(both), + progid("Msxml2.XMLParser.2.6"), + vi_progid("Msxml2.XMLParser"), + version(2.6) +] +coclass XMLParser26 +{ + [default] interface IXMLParser; +}; + +[ + helpstring("XML Parser 3.0"), + uuid(f5078f31-c551-11d3-89b9-0000f81fe221), + threading(both), + progid("Msxml2.XMLParser.3.0"), + vi_progid("Msxml2.XMLParser"), + version(3.0) +] +coclass XMLParser30 +{ + [default] interface IXMLParser; +}; + +[ + helpstring("XML Document"), + threading(apartment), + uuid(48123bc4-99d9-11d1-a6b3-00c04fd91555), + progid("xmlfile"), + version(1.0) +] +coclass XMLView +{ + interface IPersistMoniker; + interface IPersistHistory; + interface IOleCommandTarget; + interface IOleObject; +} diff --git a/dlls/msxml3/tests/xmlview.c b/dlls/msxml3/tests/xmlview.c index b238d69aa5..eb660e4d76 100644 --- a/dlls/msxml3/tests/xmlview.c +++ b/dlls/msxml3/tests/xmlview.c @@ -29,11 +29,10 @@ #include "perhist.h" #include "docobj.h" #include "urlmon.h" +#include "xmlparser.h" #include "wine/test.h" -DEFINE_GUID(CLSID_XMLView, 0x48123bc4, 0x99d9, 0x11d1, 0xa6,0xb3, 0x00,0xc0,0x4f,0xd9,0x15,0x55); - HRESULT (WINAPI *pCreateURLMoniker)(IMoniker*, LPCWSTR, IMoniker**); static const char xmlview_html[] = diff --git a/dlls/msxml3/xmlparser.c b/dlls/msxml3/xmlparser.c index 2b3026dfc9..c51b674876 100644 --- a/dlls/msxml3/xmlparser.c +++ b/dlls/msxml3/xmlparser.c @@ -47,6 +47,8 @@ typedef struct _xmlparser { IXMLParser IXMLParser_iface; LONG ref; + + int flags; } xmlparser; static inline xmlparser *impl_from_IXMLParser( IXMLParser *iface ) @@ -186,9 +188,9 @@ static ULONG WINAPI xmlparser_GetFlags(IXMLParser *iface) { xmlparser *This = impl_from_IXMLParser( iface ); - FIXME("(%p)\n", This); + TRACE("(%p)\n", This); - return 0; + return This->flags; } static HRESULT WINAPI xmlparser_GetURL(IXMLParser *iface, const WCHAR **ppBuf) @@ -338,9 +340,11 @@ static HRESULT WINAPI xmlparser_SetFlags(IXMLParser *iface, ULONG flags) { xmlparser *This = impl_from_IXMLParser( iface ); - FIXME("(%p %d)\n", This, flags); + TRACE("(%p %d)\n", This, flags); - return E_NOTIMPL; + This->flags = flags; + + return S_OK; } static HRESULT WINAPI xmlparser_SetSecureBaseURL(IXMLParser *iface, const WCHAR *baseUrl) @@ -411,6 +415,7 @@ HRESULT XMLParser_create(IUnknown* pUnkOuter, void**ppObj) return E_OUTOFMEMORY; This->IXMLParser_iface.lpVtbl = &xmlparser_vtbl; + This->flags = 0; This->ref = 1; *ppObj = &This->IXMLParser_iface;