ReactOS 0.4.16-dev-297-gc569aee
xmlview.c File Reference
#include <stdio.h>
#include <assert.h>
#include "windows.h"
#include "ole2.h"
#include "mshtml.h"
#include "mshtmdid.h"
#include "initguid.h"
#include "perhist.h"
#include "docobj.h"
#include "urlmon.h"
#include "xmlparser.h"
#include "wine/test.h"
Include dependency graph for xmlview.c:

Go to the source code of this file.

Macros

#define COBJMACROS
 
#define CONST_VTABLE
 

Functions

 HRESULT (WINAPI *pCreateURLMoniker)(IMoniker *
 
static int html_src_compare (LPCWSTR strw, const char *stra)
 
static HRESULT WINAPI HTMLEvents_QueryInterface (IDispatch *iface, REFIID riid, void **ppv)
 
static ULONG WINAPI HTMLEvents_AddRef (IDispatch *iface)
 
static ULONG WINAPI HTMLEvents_Release (IDispatch *iface)
 
static HRESULT WINAPI HTMLEvents_GetTypeInfoCount (IDispatch *iface, UINT *pctinfo)
 
static HRESULT WINAPI HTMLEvents_GetTypeInfo (IDispatch *iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
 
static HRESULT WINAPI HTMLEvents_GetIDsOfNames (IDispatch *iface, REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
 
static HRESULT WINAPI HTMLEvents_Invoke (IDispatch *iface, DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
 
static void test_QueryInterface (void)
 
static void test_Load (void)
 
 START_TEST (xmlview)
 

Variables

 LPCWSTR
 
IMoniker **static const char xmlview_html []
 
IHTMLDocument2 * html_doc
 
BOOL loaded
 
static const IDispatchVtbl HTMLEventsVtbl
 
static IDispatch HTMLEvents = { &HTMLEventsVtbl }
 

Macro Definition Documentation

◆ COBJMACROS

#define COBJMACROS

Definition at line 18 of file xmlview.c.

◆ CONST_VTABLE

#define CONST_VTABLE

Definition at line 19 of file xmlview.c.

Function Documentation

◆ HRESULT()

HRESULT ( WINAPI pCreateURLMoniker)

◆ html_src_compare()

static int html_src_compare ( LPCWSTR  strw,
const char stra 
)
static

Definition at line 56 of file xmlview.c.

57{
58 char buf[2048], *p1;
59 const char *p2;
60
61 WideCharToMultiByte(CP_ACP, 0, strw, -1, buf, sizeof(buf), NULL, NULL);
62
63 p1 = buf;
64 p2 = stra;
65 while(1) {
66 while(*p1=='\r' || *p1=='\n' || *p1=='\"') p1++;
67 while(*p2=='\r' || *p2=='\n') p2++;
68
69 if(!*p1 || !*p2 || tolower(*p1)!=tolower(*p2))
70 break;
71
72 p1++;
73 p2++;
74 }
75
76 return *p1 != *p2;
77}
int tolower(int c)
Definition: utclib.c:902
#define NULL
Definition: types.h:112
#define CP_ACP
Definition: compat.h:109
#define WideCharToMultiByte
Definition: compat.h:111
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
static const char * strw(LPCWSTR x)
Definition: actctx.c:49

Referenced by test_Load().

◆ HTMLEvents_AddRef()

static ULONG WINAPI HTMLEvents_AddRef ( IDispatch iface)
static

Definition at line 90 of file xmlview.c.

91{
92 return 2;
93}

◆ HTMLEvents_GetIDsOfNames()

static HRESULT WINAPI HTMLEvents_GetIDsOfNames ( IDispatch iface,
REFIID  riid,
LPOLESTR rgszNames,
UINT  cNames,
LCID  lcid,
DISPID rgDispId 
)
static

Definition at line 113 of file xmlview.c.

115{
116 ok(0, "unexpected call\n");
117 return E_NOTIMPL;
118}
#define ok(value,...)
Definition: atltest.h:57
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ HTMLEvents_GetTypeInfo()

static HRESULT WINAPI HTMLEvents_GetTypeInfo ( IDispatch iface,
UINT  iTInfo,
LCID  lcid,
ITypeInfo **  ppTInfo 
)
static

Definition at line 106 of file xmlview.c.

108{
109 ok(0, "unexpected call\n");
110 return E_NOTIMPL;
111}

◆ HTMLEvents_GetTypeInfoCount()

static HRESULT WINAPI HTMLEvents_GetTypeInfoCount ( IDispatch iface,
UINT pctinfo 
)
static

Definition at line 100 of file xmlview.c.

101{
102 ok(0, "unexpected call\n");
103 return E_NOTIMPL;
104}

◆ HTMLEvents_Invoke()

static HRESULT WINAPI HTMLEvents_Invoke ( IDispatch iface,
DISPID  dispIdMember,
REFIID  riid,
LCID  lcid,
WORD  wFlags,
DISPPARAMS *  pDispParams,
VARIANT pVarResult,
EXCEPINFO *  pExcepInfo,
UINT puArgErr 
)
static

Definition at line 120 of file xmlview.c.

123{
125 static const WCHAR completeW[] = {'c','o','m','p','l','e','t','e',0};
126 HRESULT hr;
127 BSTR state;
128
129 hr = IHTMLDocument2_get_readyState(html_doc, &state);
130 ok(hr == S_OK, "got 0x%08x\n", hr);
131 if(!memcmp(state, completeW, sizeof(completeW)))
132 loaded = TRUE;
134 }
135
136 return S_OK;
137}
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
static int state
Definition: maze.c:121
#define TRUE
Definition: types.h:120
OLECHAR * BSTR
Definition: compat.h:2293
#define S_OK
Definition: intsafe.h:52
BOOL loaded
Definition: xmlview.c:54
IHTMLDocument2 * html_doc
Definition: xmlview.c:53
#define DISPID_HTMLDOCUMENTEVENTS2_ONREADYSTATECHANGE
Definition: mshtmdid.h:910
void WINAPI DECLSPEC_HOTPATCH SysFreeString(BSTR str)
Definition: oleaut.c:271
HRESULT hr
Definition: shlfolder.c:183
__wchar_t WCHAR
Definition: xmlstorage.h:180

◆ HTMLEvents_QueryInterface()

static HRESULT WINAPI HTMLEvents_QueryInterface ( IDispatch iface,
REFIID  riid,
void **  ppv 
)
static

Definition at line 79 of file xmlview.c.

80{
82 *ppv = iface;
83 return S_OK;
84 }
85
86 ok(0, "Unexpected call\n");
87 return E_NOINTERFACE;
88}
const GUID IID_IUnknown
REFIID riid
Definition: atlbase.h:39
REFIID LPVOID * ppv
Definition: atlbase.h:39
const GUID IID_IDispatch
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define E_NOINTERFACE
Definition: winerror.h:2364

◆ HTMLEvents_Release()

static ULONG WINAPI HTMLEvents_Release ( IDispatch iface)
static

Definition at line 95 of file xmlview.c.

96{
97 return 1;
98}

◆ START_TEST()

START_TEST ( xmlview  )

Definition at line 264 of file xmlview.c.

265{
266 HMODULE urlmon = LoadLibraryA("urlmon.dll");
267 pCreateURLMoniker = (void*)GetProcAddress(urlmon, "CreateURLMoniker");
268
271 test_Load();
273}
#define GetProcAddress(x, y)
Definition: compat.h:753
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
Definition: compobj.c:1964
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:2067
static void test_QueryInterface(void)
Definition: xmlview.c:151
static void test_Load(void)
Definition: xmlview.c:192

◆ test_Load()

static void test_Load ( void  )
static

Definition at line 192 of file xmlview.c.

193{
194 static const WCHAR xmlview_xmlW[] = {'/','x','m','l','/','x','m','l','v','i','e','w','.','x','m','l',0};
195 static const WCHAR res[] = {'r','e','s',':','/','/',0};
196
197 WCHAR buf[1024];
198 IPersistMoniker *pers_mon;
201 IMoniker *mon;
202 IBindCtx *bctx;
203 IHTMLElement *elem;
205 MSG msg;
206 BSTR source;
207
208 lstrcpyW(buf, res);
210 lstrcatW(buf, xmlview_xmlW);
211
212 if(!pCreateURLMoniker) {
213 win_skip("CreateURLMoniker not available\n");
214 return;
215 }
216
217 hres = CoCreateInstance(&CLSID_XMLView, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
218 &IID_IPersistMoniker, (void**)&pers_mon);
219 if(FAILED(hres)) {
220 win_skip("Failed to create XMLView instance\n");
221 return;
222 }
223 ok(hres == S_OK, "CoCreateInstance returned %x, expected S_OK\n", hres);
224
225 hres = IPersistMoniker_QueryInterface(pers_mon, &IID_IHTMLDocument2, (void**)&html_doc);
226 ok(hres == S_OK, "QueryInterface(HTMLDocument2) returned %x, expected S_OK\n", hres);
227 hres = IPersistMoniker_QueryInterface(pers_mon, &IID_IConnectionPointContainer, (void**)&cpc);
228 ok(hres == S_OK, "QueryInterface(IConnectionPointContainer) returned %x, expected S_OK\n", hres);
229 hres = IConnectionPointContainer_FindConnectionPoint(cpc, &IID_IDispatch, &cp);
230 ok(hres == S_OK, "FindConnectionPoint returned %x, expected S_OK\n", hres);
231 hres = IConnectionPoint_Advise(cp, (IUnknown*)&HTMLEvents, NULL);
232 ok(hres == S_OK, "Advise returned %x, expected S_OK\n", hres);
233 IConnectionPoint_Release(cp);
234 IConnectionPointContainer_Release(cpc);
235
236 hres = CreateBindCtx(0, &bctx);
237 ok(hres == S_OK, "CreateBindCtx returned %x, expected S_OK\n", hres);
238 hres = pCreateURLMoniker(NULL, buf, &mon);
239 ok(hres == S_OK, "CreateUrlMoniker returned %x, expected S_OK\n", hres);
240 loaded = FALSE;
241 hres = IPersistMoniker_Load(pers_mon, TRUE, mon, bctx, 0);
242 ok(hres == S_OK, "Load returned %x, expected S_OK\n", hres);
243 IBindCtx_Release(bctx);
244 IMoniker_Release(mon);
245
246 while(!loaded && GetMessageA(&msg, NULL, 0, 0)) {
249 }
250
251 hres = IHTMLDocument2_get_body(html_doc, &elem);
252 ok(hres == S_OK, "get_body returned %x, expected S_OK\n", hres);
253 hres = IHTMLElement_get_outerHTML(elem, &source);
254 ok(hres == S_OK, "get_outerHTML returned %x, expected S_OK\n", hres);
255 ok(!html_src_compare(source, xmlview_html), "Incorrect HTML source: %s\n", wine_dbgstr_w(source));
256 IHTMLElement_Release(elem);
258
259 IHTMLDocument2_Release(html_doc);
260 html_doc = NULL;
261 IPersistMoniker_Release(pers_mon);
262}
#define msg(x)
Definition: auth_time.c:54
#define ARRAY_SIZE(A)
Definition: main.h:20
#define FALSE
Definition: types.h:117
#define lstrcpyW
Definition: compat.h:749
#define lstrlenW
Definition: compat.h:750
DWORD WINAPI GetModuleFileNameW(HINSTANCE hModule, LPWSTR lpFilename, DWORD nSize)
Definition: loader.c:600
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3325
GLuint res
Definition: glext.h:9613
#define FAILED(hr)
Definition: intsafe.h:51
#define wine_dbgstr_w
Definition: kernel32.h:34
LPWSTR WINAPI lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:274
POINT cp
Definition: magnifier.c:59
HRESULT hres
Definition: protocol.c:465
static size_t elem
Definition: string.c:68
IMoniker **static const char xmlview_html[]
Definition: xmlview.c:38
static int html_src_compare(LPCWSTR strw, const char *stra)
Definition: xmlview.c:56
static IDispatch HTMLEvents
Definition: xmlview.c:149
HRESULT WINAPI CreateBindCtx(DWORD reserved, LPBC *ppbc)
Definition: bindctx.c:556
const GUID IID_IConnectionPointContainer
#define win_skip
Definition: test.h:163
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
LRESULT WINAPI DispatchMessageA(_In_ const MSG *)
BOOL WINAPI TranslateMessage(_In_ const MSG *)
BOOL WINAPI GetMessageA(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT)

Referenced by START_TEST(), and test_Persist().

◆ test_QueryInterface()

static void test_QueryInterface ( void  )
static

Definition at line 151 of file xmlview.c.

152{
153 IUnknown *xmlview, *unk;
154 IHTMLDocument *htmldoc;
156
157 hres = CoCreateInstance(&CLSID_XMLView, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
158 &IID_IUnknown, (void**)&xmlview);
159 if(FAILED(hres)) {
160 win_skip("Failed to create XMLView instance\n");
161 return;
162 }
163 ok(hres == S_OK, "CoCreateInstance returned %x, expected S_OK\n", hres);
164
165 hres = IUnknown_QueryInterface(xmlview, &IID_IPersistMoniker, (void**)&unk);
166 ok(hres == S_OK, "QueryInterface(IID_IPersistMoniker) returned %x, expected S_OK\n", hres);
167 IUnknown_Release(unk);
168
169 hres = IUnknown_QueryInterface(xmlview, &IID_IPersistHistory, (void**)&unk);
170 ok(hres == S_OK, "QueryInterface(IID_IPersistHistory) returned %x, expected S_OK\n", hres);
171 IUnknown_Release(unk);
172
173 hres = IUnknown_QueryInterface(xmlview, &IID_IOleCommandTarget, (void**)&unk);
174 ok(hres == S_OK, "QueryInterface(IID_IOleCommandTarget) returned %x, expected S_OK\n", hres);
175 IUnknown_Release(unk);
176
177 hres = IUnknown_QueryInterface(xmlview, &IID_IOleObject, (void**)&unk);
178 ok(hres == S_OK, "QueryInterface(IID_IOleObject) returned %x, expected S_OK\n", hres);
179 IUnknown_Release(unk);
180
181 hres = IUnknown_QueryInterface(xmlview, &IID_IHTMLDocument, (void**)&htmldoc);
182 ok(hres == S_OK, "QueryInterface(IID_IHTMLDocument) returned %x, expected S_OK\n", hres);
183 hres = IHTMLDocument_QueryInterface(htmldoc, &IID_IUnknown, (void**)&unk);
184 ok(hres == S_OK, "QueryInterface(IID_IUnknown) returned %x, expected S_OK\n", hres);
185 ok(unk == xmlview, "Aggregation is not working as expected\n");
186 IUnknown_Release(unk);
187 IHTMLDocument_Release(htmldoc);
188
189 IUnknown_Release(xmlview);
190}
const GUID IID_IOleObject

Referenced by START_TEST().

Variable Documentation

◆ html_doc

IHTMLDocument2* html_doc

◆ HTMLEvents

IDispatch HTMLEvents = { &HTMLEventsVtbl }
static

Definition at line 149 of file xmlview.c.

Referenced by test_Load().

◆ HTMLEventsVtbl

const IDispatchVtbl HTMLEventsVtbl
static
Initial value:
= {
}
static HRESULT WINAPI HTMLEvents_GetTypeInfoCount(IDispatch *iface, UINT *pctinfo)
Definition: xmlview.c:100
static ULONG WINAPI HTMLEvents_AddRef(IDispatch *iface)
Definition: xmlview.c:90
static HRESULT WINAPI HTMLEvents_GetTypeInfo(IDispatch *iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
Definition: xmlview.c:106
static HRESULT WINAPI HTMLEvents_Invoke(IDispatch *iface, DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
Definition: xmlview.c:120
static HRESULT WINAPI HTMLEvents_GetIDsOfNames(IDispatch *iface, REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
Definition: xmlview.c:113
static ULONG WINAPI HTMLEvents_Release(IDispatch *iface)
Definition: xmlview.c:95
static HRESULT WINAPI HTMLEvents_QueryInterface(IDispatch *iface, REFIID riid, void **ppv)
Definition: xmlview.c:79

Definition at line 139 of file xmlview.c.

◆ loaded

◆ LPCWSTR

Definition at line 36 of file xmlview.c.

◆ xmlview_html

IMoniker** static const char xmlview_html[]
static
Initial value:
=
"\r\n"
"<BODY><H2>Generated HTML</H2>\r\n"
"<TABLE>\r\n"
"<TBODY>\r\n"
"<TR bgColor=green>\r\n"
"<TH>Title</TH>\r\n"
"<TH>Value</TH></TR>\r\n"
"<TR>\r\n"
"<TD>title1</TD>\r\n"
"<TD>value1</TD></TR>\r\n"
"<TR>\r\n"
"<TD>title2</TD>\r\n"
"<TD>value2</TD></TR></TBODY></TABLE></BODY>"

Definition at line 38 of file xmlview.c.

Referenced by test_Load().