winhttp: Make strings in WINHTTP_PROXY_INFO non-const.
[wine/multimedia.git] / programs / wordpad / olecallback.c
blob8b279ada89dc94b8077266c1477145aa26682de3
1 /*
2 * Wordpad implementation - Richedit OLE callback implementation
4 * Copyright 2010 by Dylan Smith <dylan.ah.smith@gmail.com>
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 #define COBJMACROS
23 #include <windows.h>
24 #include <richedit.h>
25 #include <ole2.h>
26 #include <richole.h>
28 #include "wine/debug.h"
29 #include "wordpad.h"
31 WINE_DEFAULT_DEBUG_CHANNEL(wordpad);
33 struct IRichEditOleCallbackImpl {
34 const IRichEditOleCallbackVtbl *vtbl;
35 IStorage *stg;
36 int item_num;
39 struct IRichEditOleCallbackImpl olecallback;
41 static HRESULT STDMETHODCALLTYPE RichEditOleCallback_QueryInterface(
42 IRichEditOleCallback* This,
43 REFIID riid,
44 void **ppvObject)
46 WINE_TRACE("(%p, %s, %p)\n", This, wine_dbgstr_guid(riid), ppvObject);
47 if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IRichEditOleCallback))
49 *ppvObject = This;
50 return S_OK;
52 WINE_FIXME("Unknown interface: %s\n", wine_dbgstr_guid(riid));
53 return E_NOINTERFACE;
56 static ULONG STDMETHODCALLTYPE RichEditOleCallback_AddRef(
57 IRichEditOleCallback* This)
59 WINE_TRACE("(%p)\n", This);
60 /* singleton */
61 return 1;
64 static ULONG STDMETHODCALLTYPE RichEditOleCallback_Release(
65 IRichEditOleCallback* This)
67 WINE_TRACE("(%p)\n", This);
68 return 1;
71 /*** IRichEditOleCallback methods ***/
72 static HRESULT STDMETHODCALLTYPE RichEditOleCallback_GetNewStorage(
73 IRichEditOleCallback* This,
74 LPSTORAGE *lplpstg)
76 WCHAR name[32];
77 static const WCHAR template[] = {'R','E','O','L','E','_','%','u','\0'};
79 WINE_TRACE("(%p, %p)\n", This, lplpstg);
80 wsprintfW(name, template, olecallback.item_num++);
81 return IStorage_CreateStorage(olecallback.stg, name,
82 STGM_READWRITE | STGM_SHARE_EXCLUSIVE | STGM_CREATE,
83 0, 0, lplpstg);
86 static HRESULT STDMETHODCALLTYPE RichEditOleCallback_GetInPlaceContext(
87 IRichEditOleCallback* This,
88 LPOLEINPLACEFRAME *lplpFrame,
89 LPOLEINPLACEUIWINDOW *lplpDoc,
90 LPOLEINPLACEFRAMEINFO lpFrameInfo)
92 WINE_FIXME("(%p, %p, %p, %p) stub\n", This, lplpFrame, lplpDoc, lpFrameInfo);
93 return E_INVALIDARG;
96 static HRESULT STDMETHODCALLTYPE RichEditOleCallback_ShowContainerUI(
97 IRichEditOleCallback* This,
98 BOOL fShow)
100 WINE_TRACE("(%p, %d)\n", This, fShow);
101 return S_OK;
104 static HRESULT STDMETHODCALLTYPE RichEditOleCallback_QueryInsertObject(
105 IRichEditOleCallback* This,
106 LPCLSID lpclsid,
107 LPSTORAGE lpstg,
108 LONG cp)
110 WINE_TRACE("(%p, %p, %p, %d)\n", This, lpclsid, lpstg, cp);
111 return S_OK;
114 static HRESULT STDMETHODCALLTYPE RichEditOleCallback_DeleteObject(
115 IRichEditOleCallback* This,
116 LPOLEOBJECT lpoleobj)
118 WINE_TRACE("(%p, %p)\n", This, lpoleobj);
119 return S_OK;
122 static HRESULT STDMETHODCALLTYPE RichEditOleCallback_QueryAcceptData(
123 IRichEditOleCallback* This,
124 LPDATAOBJECT lpdataobj,
125 CLIPFORMAT *lpcfFormat,
126 DWORD reco,
127 BOOL fReally,
128 HGLOBAL hMetaPict)
130 WINE_TRACE("(%p, %p, %p, %x, %d, %p)\n",
131 This, lpdataobj, lpcfFormat, reco, fReally, hMetaPict);
132 return S_OK;
135 static HRESULT STDMETHODCALLTYPE RichEditOleCallback_ContextSensitiveHelp(
136 IRichEditOleCallback* This,
137 BOOL fEnterMode)
139 WINE_TRACE("(%p, %d)\n", This, fEnterMode);
140 return S_OK;
143 static HRESULT STDMETHODCALLTYPE RichEditOleCallback_GetClipboardData(
144 IRichEditOleCallback* This,
145 CHARRANGE *lpchrg,
146 DWORD reco,
147 LPDATAOBJECT *lplpdataobj)
149 WINE_TRACE("(%p, %p, %x, %p)\n", This, lpchrg, reco, lplpdataobj);
150 return E_NOTIMPL;
153 static HRESULT STDMETHODCALLTYPE RichEditOleCallback_GetDragDropEffect(
154 IRichEditOleCallback* This,
155 BOOL fDrag,
156 DWORD grfKeyState,
157 LPDWORD pdwEffect)
159 WINE_TRACE("(%p, %d, %x, %p)\n", This, fDrag, grfKeyState, pdwEffect);
160 if (pdwEffect)
161 *pdwEffect = DROPEFFECT_COPY;
162 return S_OK;
165 static HRESULT STDMETHODCALLTYPE RichEditOleCallback_GetContextMenu(
166 IRichEditOleCallback* This,
167 WORD seltype,
168 LPOLEOBJECT lpoleobj,
169 CHARRANGE *lpchrg,
170 HMENU *lphmenu)
172 HINSTANCE hInstance = GetModuleHandleW(0);
173 HMENU hPopupMenu = LoadMenuW(hInstance, MAKEINTRESOURCEW(IDM_POPUP));
175 WINE_TRACE("(%p, %x, %p, %p, %p)\n",
176 This, seltype, lpoleobj, lpchrg, lphmenu);
178 *lphmenu = GetSubMenu(hPopupMenu, 0);
179 return S_OK;
182 struct IRichEditOleCallbackVtbl olecallbackVtbl = {
183 RichEditOleCallback_QueryInterface,
184 RichEditOleCallback_AddRef,
185 RichEditOleCallback_Release,
186 RichEditOleCallback_GetNewStorage,
187 RichEditOleCallback_GetInPlaceContext,
188 RichEditOleCallback_ShowContainerUI,
189 RichEditOleCallback_QueryInsertObject,
190 RichEditOleCallback_DeleteObject,
191 RichEditOleCallback_QueryAcceptData,
192 RichEditOleCallback_ContextSensitiveHelp,
193 RichEditOleCallback_GetClipboardData,
194 RichEditOleCallback_GetDragDropEffect,
195 RichEditOleCallback_GetContextMenu
198 struct IRichEditOleCallbackImpl olecallback = {
199 &olecallbackVtbl, NULL, 0
202 HRESULT setup_richedit_olecallback(HWND hEditorWnd)
204 HRESULT hr = StgCreateDocfile(NULL,
205 STGM_READWRITE | STGM_SHARE_EXCLUSIVE | STGM_DELETEONRELEASE,
206 0, &olecallback.stg);
208 SendMessageW(hEditorWnd, EM_SETOLECALLBACK, 0, (LPARAM)&olecallback);
209 return hr;