gdi32: Add some additional tests for negative axes extents.
[wine/wine-gecko.git] / dlls / hlink / browse_ctx.c
blob2496f9a61b1ce353d290ff8b05c51431edc0afa3
1 /*
2 * Implementation of hyperlinking (hlink.dll)
4 * Copyright 2005 Aric Stewart for CodeWeavers
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include "hlink_private.h"
23 #include "wine/debug.h"
25 WINE_DEFAULT_DEBUG_CHANNEL(hlink);
27 static const IHlinkBrowseContextVtbl hlvt;
29 typedef struct
31 IHlinkBrowseContext IHlinkBrowseContext_iface;
32 LONG ref;
33 HLBWINFO* BrowseWindowInfo;
34 IHlink* CurrentPage;
35 } HlinkBCImpl;
37 static inline HlinkBCImpl *impl_from_IHlinkBrowseContext(IHlinkBrowseContext *iface)
39 return CONTAINING_RECORD(iface, HlinkBCImpl, IHlinkBrowseContext_iface);
43 HRESULT WINAPI HLinkBrowseContext_Constructor(IUnknown *pUnkOuter, REFIID riid,
44 LPVOID *ppv)
46 HlinkBCImpl * hl;
48 TRACE("unkOut=%p riid=%s\n", pUnkOuter, debugstr_guid(riid));
49 *ppv = NULL;
51 if (pUnkOuter)
52 return CLASS_E_NOAGGREGATION;
54 hl = heap_alloc_zero(sizeof(HlinkBCImpl));
55 if (!hl)
56 return E_OUTOFMEMORY;
58 hl->ref = 1;
59 hl->IHlinkBrowseContext_iface.lpVtbl = &hlvt;
61 *ppv = hl;
62 return S_OK;
65 static HRESULT WINAPI IHlinkBC_fnQueryInterface( IHlinkBrowseContext *iface,
66 REFIID riid, LPVOID* ppvObj)
68 HlinkBCImpl *This = impl_from_IHlinkBrowseContext(iface);
69 TRACE ("(%p)->(%s,%p)\n", This, debugstr_guid (riid), ppvObj);
71 if (IsEqualIID(riid, &IID_IUnknown) ||
72 IsEqualIID(riid, &IID_IHlinkBrowseContext))
73 *ppvObj = This;
75 if (*ppvObj)
77 IUnknown_AddRef((IUnknown*)(*ppvObj));
78 return S_OK;
80 return E_NOINTERFACE;
83 static ULONG WINAPI IHlinkBC_fnAddRef (IHlinkBrowseContext* iface)
85 HlinkBCImpl *This = impl_from_IHlinkBrowseContext(iface);
86 ULONG refCount = InterlockedIncrement(&This->ref);
88 TRACE("(%p)->(count=%u)\n", This, refCount - 1);
90 return refCount;
93 static ULONG WINAPI IHlinkBC_fnRelease (IHlinkBrowseContext* iface)
95 HlinkBCImpl *This = impl_from_IHlinkBrowseContext(iface);
96 ULONG refCount = InterlockedDecrement(&This->ref);
98 TRACE("(%p)->(count=%u)\n", This, refCount + 1);
99 if (refCount)
100 return refCount;
102 TRACE("-- destroying IHlinkBrowseContext (%p)\n", This);
103 heap_free(This->BrowseWindowInfo);
104 if (This->CurrentPage)
105 IHlink_Release(This->CurrentPage);
106 heap_free(This);
107 return 0;
110 static HRESULT WINAPI IHlinkBC_Register(IHlinkBrowseContext* iface,
111 DWORD dwReserved, IUnknown *piunk, IMoniker *pimk, DWORD *pdwRegister)
113 static const WCHAR szIdent[] = {'W','I','N','E','H','L','I','N','K',0};
114 HlinkBCImpl *This = impl_from_IHlinkBrowseContext(iface);
115 IMoniker *mon;
116 IMoniker *composite;
117 IRunningObjectTable *ROT;
119 FIXME("(%p)->(%i %p %p %p)\n", This, dwReserved, piunk, pimk, pdwRegister);
121 CreateItemMoniker(NULL, szIdent, &mon);
122 CreateGenericComposite(mon, pimk, &composite);
124 GetRunningObjectTable(0, &ROT);
125 IRunningObjectTable_Register(ROT, 0, piunk, composite, pdwRegister);
127 IRunningObjectTable_Release(ROT);
128 IMoniker_Release(composite);
129 IMoniker_Release(mon);
131 return S_OK;
134 static HRESULT WINAPI IHlinkBC_GetObject(IHlinkBrowseContext* face,
135 IMoniker *pimk, BOOL fBindifRootRegistered, IUnknown **ppiunk)
137 FIXME("\n");
138 return E_NOTIMPL;
141 static HRESULT WINAPI IHlinkBC_Revoke(IHlinkBrowseContext* iface,
142 DWORD dwRegister)
144 HRESULT r = S_OK;
145 IRunningObjectTable *ROT;
146 HlinkBCImpl *This = impl_from_IHlinkBrowseContext(iface);
148 FIXME("(%p)->(%i)\n", This, dwRegister);
150 GetRunningObjectTable(0, &ROT);
151 r = IRunningObjectTable_Revoke(ROT, dwRegister);
152 IRunningObjectTable_Release(ROT);
154 return r;
157 static HRESULT WINAPI IHlinkBC_SetBrowseWindowInfo(IHlinkBrowseContext* iface,
158 HLBWINFO *phlbwi)
160 HlinkBCImpl *This = impl_from_IHlinkBrowseContext(iface);
161 TRACE("(%p)->(%p)\n", This, phlbwi);
163 if(!phlbwi)
164 return E_INVALIDARG;
166 heap_free(This->BrowseWindowInfo);
167 This->BrowseWindowInfo = heap_alloc(phlbwi->cbSize);
168 memcpy(This->BrowseWindowInfo, phlbwi, phlbwi->cbSize);
170 return S_OK;
173 static HRESULT WINAPI IHlinkBC_GetBrowseWindowInfo(IHlinkBrowseContext* iface,
174 HLBWINFO *phlbwi)
176 HlinkBCImpl *This = impl_from_IHlinkBrowseContext(iface);
177 TRACE("(%p)->(%p)\n", This, phlbwi);
179 if(!phlbwi)
180 return E_INVALIDARG;
182 if(!This->BrowseWindowInfo)
183 phlbwi->cbSize = 0;
184 else
185 memcpy(phlbwi, This->BrowseWindowInfo, This->BrowseWindowInfo->cbSize);
187 return S_OK;
190 static HRESULT WINAPI IHlinkBC_SetInitialHlink(IHlinkBrowseContext* iface,
191 IMoniker *pimkTarget, LPCWSTR pwzLocation, LPCWSTR pwzFriendlyName)
193 HlinkBCImpl *This = impl_from_IHlinkBrowseContext(iface);
195 FIXME("(%p)->(%p %s %s)\n", This, pimkTarget,
196 debugstr_w(pwzLocation), debugstr_w(pwzFriendlyName));
198 if (This->CurrentPage)
199 IHlink_Release(This->CurrentPage);
201 HlinkCreateFromMoniker(pimkTarget, pwzLocation, pwzFriendlyName, NULL,
202 0, NULL, &IID_IHlink, (LPVOID*) &This->CurrentPage);
204 return S_OK;
207 static HRESULT WINAPI IHlinkBC_OnNavigateHlink(IHlinkBrowseContext *iface,
208 DWORD grfHLNF, IMoniker* pmkTarget, LPCWSTR pwzLocation, LPCWSTR
209 pwzFriendlyName, ULONG *puHLID)
211 HlinkBCImpl *This = impl_from_IHlinkBrowseContext(iface);
213 FIXME("(%p)->(%i %p %s %s %p)\n", This, grfHLNF, pmkTarget,
214 debugstr_w(pwzLocation), debugstr_w(pwzFriendlyName), puHLID);
216 return S_OK;
219 static HRESULT WINAPI IHlinkBC_UpdateHlink(IHlinkBrowseContext* iface,
220 ULONG uHLID, IMoniker* pimkTarget, LPCWSTR pwzLocation,
221 LPCWSTR pwzFriendlyName)
223 FIXME("\n");
224 return E_NOTIMPL;
227 static HRESULT WINAPI IHlinkBC_EnumNavigationStack( IHlinkBrowseContext *iface,
228 DWORD dwReserved, DWORD grfHLFNAMEF, IEnumHLITEM** ppienumhlitem)
230 FIXME("\n");
231 return E_NOTIMPL;
234 static HRESULT WINAPI IHlinkBC_QueryHlink( IHlinkBrowseContext* iface,
235 DWORD grfHLONG, ULONG uHLID)
237 FIXME("\n");
238 return E_NOTIMPL;
241 static HRESULT WINAPI IHlinkBC_GetHlink( IHlinkBrowseContext* iface,
242 ULONG uHLID, IHlink** ppihl)
244 HlinkBCImpl *This = impl_from_IHlinkBrowseContext(iface);
246 TRACE("(%p)->(%x %p)\n", This, uHLID, ppihl);
248 if(uHLID != HLID_CURRENT) {
249 FIXME("Only HLID_CURRENT implemented, given: %x\n", uHLID);
250 return E_NOTIMPL;
253 *ppihl = This->CurrentPage;
254 IHlink_AddRef(*ppihl);
256 return S_OK;
259 static HRESULT WINAPI IHlinkBC_SetCurrentHlink( IHlinkBrowseContext* iface,
260 ULONG uHLID)
262 FIXME("\n");
263 return E_NOTIMPL;
266 static HRESULT WINAPI IHlinkBC_Clone( IHlinkBrowseContext* iface,
267 IUnknown* piunkOuter, REFIID riid, IUnknown** ppiunkOjb)
269 FIXME("\n");
270 return E_NOTIMPL;
273 static HRESULT WINAPI IHlinkBC_Close(IHlinkBrowseContext* iface,
274 DWORD reserverd)
276 FIXME("\n");
277 return E_NOTIMPL;
280 static const IHlinkBrowseContextVtbl hlvt =
282 IHlinkBC_fnQueryInterface,
283 IHlinkBC_fnAddRef,
284 IHlinkBC_fnRelease,
285 IHlinkBC_Register,
286 IHlinkBC_GetObject,
287 IHlinkBC_Revoke,
288 IHlinkBC_SetBrowseWindowInfo,
289 IHlinkBC_GetBrowseWindowInfo,
290 IHlinkBC_SetInitialHlink,
291 IHlinkBC_OnNavigateHlink,
292 IHlinkBC_UpdateHlink,
293 IHlinkBC_EnumNavigationStack,
294 IHlinkBC_QueryHlink,
295 IHlinkBC_GetHlink,
296 IHlinkBC_SetCurrentHlink,
297 IHlinkBC_Clone,
298 IHlinkBC_Close