forked from NASAWorldWind/WorldWindJava
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHTMLMoniker.h
More file actions
141 lines (107 loc) · 4.32 KB
/
HTMLMoniker.h
File metadata and controls
141 lines (107 loc) · 4.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
/*
* Copyright (C) 2012 United States Government as represented by the Administrator of the
* National Aeronautics and Space Administration.
* All Rights Reserved.
*/
#include "stdafx.h"
#ifndef HTML_MONIKER_H
#define HTML_MONIKER_H
// The SHCreateMemStream function has existed since Windows 2000, but was only added to the header files
// in Windows Vista. To use this function in Windows 2000 and Windows XP, we need to explicitly load it
// from the DLL. SHCreateMemStream creates a COM stream object from an array of bytes in local memory.
// For more information see: http://msdn.microsoft.com/en-us/library/bb773831%28VS.85%29.aspx
typedef IStream* (__stdcall *fnSHCreateMemStream)(const BYTE *pInit, UINT cbInit);
class HTMLMoniker : public IMoniker
{
private:
HTMLMoniker();
public:
/** Create a new instance of the HTMLMoniker. */
static HRESULT CreateInstance(HTMLMoniker **pMoniker)
{
HRESULT hr = E_OUTOFMEMORY;
*pMoniker = new HTMLMoniker();
if (*pMoniker != NULL)
{
(*pMoniker)->AddRef();
hr = S_OK;
}
return hr;
}
/** Destroy the moniker. */
virtual ~HTMLMoniker();
/**
* Set the HTML content from a buffer in memory.
*
* @param buffer Buffer containing HTML data. The data can be encoded in any
* encoding that the web browser control can parse.
* @param bufferSize Size of the buffer in bytes.
*
* @return HRESULT indicating success or failure.
*/
HRESULT SetHTML(BYTE *buffer, UINT bufferSize);
/**
* Set the content base URL.
*
* @param baseUrl New base URL. Does not need to be NULL terminated.
* @param baseUrlLen String length (in wchars) of the base URL.
*/
HRESULT SetBaseURL(const wchar_t *baseUrl, size_t baseUrlLen);
/** Determine if the base URL for this content is the default base URL (about:blank). */
BOOL IsDefaultBaseUrl() const;
public:
// IMoniker
STDMETHODIMP BindToStorage(IBindCtx *pbc, IMoniker *pmkToLeft, REFIID riid, void **ppvObj);
STDMETHODIMP GetDisplayName(IBindCtx *pbc, IMoniker *pmkToLeft, LPOLESTR *ppszDisplayName);
STDMETHODIMP BindToObject(IBindCtx *pbc, IMoniker *pmkToLeft, REFIID riidResult, void **ppvResult)
{ return E_NOTIMPL; }
STDMETHODIMP Reduce(IBindCtx *pbc, DWORD dwReduceHowFar, IMoniker **ppmkToLeft, IMoniker **ppmkReduced)
{ return E_NOTIMPL; }
STDMETHODIMP ComposeWith(IMoniker *pmkRight, BOOL fOnlyIfNotGeneric, IMoniker **ppmkComposite)
{ return E_NOTIMPL; }
STDMETHODIMP Enum(BOOL fForward, IEnumMoniker **ppenumMoniker)
{ return E_NOTIMPL; }
STDMETHODIMP IsEqual(IMoniker *pmkOtherMoniker)
{ return E_NOTIMPL; }
STDMETHODIMP Hash(DWORD *pdwHash)
{ return E_NOTIMPL; }
STDMETHODIMP IsRunning(IBindCtx *pbc, IMoniker *pmkToLeft, IMoniker *pmkNewlyRunning)
{ return E_NOTIMPL; }
STDMETHODIMP GetTimeOfLastChange(IBindCtx *pbc, IMoniker *pmkToLeft, FILETIME *pFileTime)
{ return E_NOTIMPL; }
STDMETHODIMP Inverse(IMoniker **ppmk)
{ return E_NOTIMPL; }
STDMETHODIMP CommonPrefixWith(IMoniker *pmkOther, IMoniker **ppmkPrefix)
{ return E_NOTIMPL; }
STDMETHODIMP RelativePathTo(IMoniker *pmkOther, IMoniker **ppmkRelPath)
{ return E_NOTIMPL; }
STDMETHODIMP ParseDisplayName(IBindCtx *pbc, IMoniker *pmkToLeft,LPOLESTR pszDisplayName,
ULONG *pchEaten, IMoniker **ppmkOut)
{ return E_NOTIMPL; }
STDMETHODIMP IsSystemMoniker(DWORD *pdwMksys)
{
if (!pdwMksys)
return E_POINTER;
*pdwMksys = MKSYS_NONE;
return S_OK;
}
// IPersistStream methods
STDMETHODIMP Save(IStream *pStm, BOOL fClearDirty) { return E_NOTIMPL; }
STDMETHODIMP IsDirty() { return E_NOTIMPL; }
STDMETHODIMP Load(IStream *pStm) { return E_NOTIMPL; }
STDMETHODIMP GetSizeMax(ULARGE_INTEGER *pcbSize) { return E_NOTIMPL; }
// IPersist
STDMETHODIMP GetClassID(CLSID *pClassID) { return E_NOTIMPL; }
// IUnknown
STDMETHODIMP QueryInterface(REFIID riid, void **ppvObject);
virtual ULONG STDMETHODCALLTYPE AddRef(void);
virtual ULONG STDMETHODCALLTYPE Release(void);
private:
BYTE *htmlBuffer;
wchar_t *baseUrl;
IStream *htmlStream;
int refCount;
HMODULE libShlWapi;
fnSHCreateMemStream SHCreateMemStream;
};
#endif