ReactOS  0.4.12-dev-43-g63b00d8
olecallback.c
Go to the documentation of this file.
1 /*
2  * Wordpad implementation - Richedit OLE callback implementation
3  *
4  * Copyright 2010 by Dylan Smith <dylan.ah.smith@gmail.com>
5  *
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.
10  *
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.
15  *
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
19  */
20 
21 #define COBJMACROS
22 
23 #define WIN32_NO_STATUS
24 #define WIN32_LEAN_AND_MEAN
25 #include <windows.h>
26 #include <richedit.h>
27 #include <richole.h>
28 #include <wine/debug.h>
29 
30 #include "wordpad.h"
31 
33 
35  const IRichEditOleCallbackVtbl *vtbl;
37  int item_num;
38 };
39 
41 
44  REFIID riid,
45  void **ppvObject)
46 {
47  WINE_TRACE("(%p, %s, %p)\n", This, wine_dbgstr_guid(riid), ppvObject);
48  if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IRichEditOleCallback))
49  {
50  *ppvObject = This;
51  return S_OK;
52  }
53  WINE_FIXME("Unknown interface: %s\n", wine_dbgstr_guid(riid));
54  return E_NOINTERFACE;
55 }
56 
59 {
60  WINE_TRACE("(%p)\n", This);
61  /* singleton */
62  return 1;
63 }
64 
67 {
68  WINE_TRACE("(%p)\n", This);
69  return 1;
70 }
71 
72 /*** IRichEditOleCallback methods ***/
75  LPSTORAGE *lplpstg)
76 {
77  WCHAR name[32];
78  static const WCHAR template[] = {'R','E','O','L','E','_','%','u','\0'};
79 
80  WINE_TRACE("(%p, %p)\n", This, lplpstg);
81  wsprintfW(name, template, olecallback.item_num++);
82  return IStorage_CreateStorage(olecallback.stg, name,
84  0, 0, lplpstg);
85 }
86 
89  LPOLEINPLACEFRAME *lplpFrame,
90  LPOLEINPLACEUIWINDOW *lplpDoc,
91  LPOLEINPLACEFRAMEINFO lpFrameInfo)
92 {
93  WINE_FIXME("(%p, %p, %p, %p) stub\n", This, lplpFrame, lplpDoc, lpFrameInfo);
94  return E_INVALIDARG;
95 }
96 
99  BOOL fShow)
100 {
101  WINE_TRACE("(%p, %d)\n", This, fShow);
102  return S_OK;
103 }
104 
107  LPCLSID lpclsid,
108  LPSTORAGE lpstg,
109  LONG cp)
110 {
111  WINE_TRACE("(%p, %p, %p, %d)\n", This, lpclsid, lpstg, cp);
112  return S_OK;
113 }
114 
117  LPOLEOBJECT lpoleobj)
118 {
119  WINE_TRACE("(%p, %p)\n", This, lpoleobj);
120  return S_OK;
121 }
122 
125  LPDATAOBJECT lpdataobj,
126  CLIPFORMAT *lpcfFormat,
127  DWORD reco,
128  BOOL fReally,
129  HGLOBAL hMetaPict)
130 {
131  WINE_TRACE("(%p, %p, %p, %x, %d, %p)\n",
132  This, lpdataobj, lpcfFormat, reco, fReally, hMetaPict);
133  return S_OK;
134 }
135 
138  BOOL fEnterMode)
139 {
140  WINE_TRACE("(%p, %d)\n", This, fEnterMode);
141  return S_OK;
142 }
143 
146  CHARRANGE *lpchrg,
147  DWORD reco,
148  LPDATAOBJECT *lplpdataobj)
149 {
150  WINE_TRACE("(%p, %p, %x, %p)\n", This, lpchrg, reco, lplpdataobj);
151  return E_NOTIMPL;
152 }
153 
156  BOOL fDrag,
157  DWORD grfKeyState,
158  LPDWORD pdwEffect)
159 {
160  WINE_TRACE("(%p, %d, %x, %p)\n", This, fDrag, grfKeyState, pdwEffect);
161  if (pdwEffect)
162  *pdwEffect = DROPEFFECT_COPY;
163  return S_OK;
164 }
165 
168  WORD seltype,
169  LPOLEOBJECT lpoleobj,
170  CHARRANGE *lpchrg,
171  HMENU *lphmenu)
172 {
174  HMENU hPopupMenu = LoadMenuW(hInstance, MAKEINTRESOURCEW(IDM_POPUP));
175 
176  WINE_TRACE("(%p, %x, %p, %p, %p)\n",
177  This, seltype, lpoleobj, lpchrg, lphmenu);
178 
179  *lphmenu = GetSubMenu(hPopupMenu, 0);
180  return S_OK;
181 }
182 
183 struct IRichEditOleCallbackVtbl olecallbackVtbl = {
197 };
198 
200  &olecallbackVtbl, NULL, 0
201 };
202 
204 {
207  0, &olecallback.stg);
208 
209  SendMessageW(hEditorWnd, EM_SETOLECALLBACK, 0, (LPARAM)&olecallback);
210  return hr;
211 }
int WINAPIV wsprintfW(_Out_ LPWSTR, _In_ _Printf_format_string_ LPCWSTR,...)
interface IStorage * LPSTORAGE
Definition: objfwd.h:30
static HRESULT STDMETHODCALLTYPE RichEditOleCallback_ContextSensitiveHelp(IRichEditOleCallback *This, BOOL fEnterMode)
Definition: olecallback.c:136
static HRESULT STDMETHODCALLTYPE RichEditOleCallback_ShowContainerUI(IRichEditOleCallback *This, BOOL fShow)
Definition: olecallback.c:97
static HRESULT STDMETHODCALLTYPE RichEditOleCallback_GetClipboardData(IRichEditOleCallback *This, CHARRANGE *lpchrg, DWORD reco, LPDATAOBJECT *lplpdataobj)
Definition: olecallback.c:144
#define REFIID
Definition: guiddef.h:113
static HRESULT STDMETHODCALLTYPE RichEditOleCallback_GetNewStorage(IRichEditOleCallback *This, LPSTORAGE *lplpstg)
Definition: olecallback.c:73
#define E_NOINTERFACE
Definition: winerror.h:2364
#define STGM_SHARE_EXCLUSIVE
Definition: objbase.h:922
__wchar_t WCHAR
Definition: xmlstorage.h:180
REFIID riid
Definition: precomp.h:44
INT BOOL fShow
Definition: msvc.h:54
#define STGM_CREATE
Definition: objbase.h:925
const char * wine_dbgstr_guid(const GUID *guid)
#define WINE_TRACE
Definition: debug.h:353
static HWND hEditorWnd
Definition: wordpad.c:60
static HRESULT STDMETHODCALLTYPE RichEditOleCallback_GetDragDropEffect(IRichEditOleCallback *This, BOOL fDrag, DWORD grfKeyState, LPDWORD pdwEffect)
Definition: olecallback.c:154
HINSTANCE hInstance
Definition: charmap.c:20
static HRESULT STDMETHODCALLTYPE RichEditOleCallback_QueryInterface(IRichEditOleCallback *This, REFIID riid, void **ppvObject)
Definition: olecallback.c:42
long LONG
Definition: pedump.c:60
static HRESULT STDMETHODCALLTYPE RichEditOleCallback_QueryAcceptData(IRichEditOleCallback *This, LPDATAOBJECT lpdataobj, CLIPFORMAT *lpcfFormat, DWORD reco, BOOL fReally, HGLOBAL hMetaPict)
Definition: olecallback.c:123
LONG_PTR LPARAM
Definition: windef.h:208
static HRESULT STDMETHODCALLTYPE RichEditOleCallback_DeleteObject(IRichEditOleCallback *This, LPOLEOBJECT lpoleobj)
Definition: olecallback.c:115
static ULONG STDMETHODCALLTYPE RichEditOleCallback_AddRef(IRichEditOleCallback *This)
Definition: olecallback.c:57
#define E_INVALIDARG
Definition: ddrawi.h:101
smooth NULL
Definition: ftsmooth.c:416
#define STGM_DELETEONRELEASE
Definition: objbase.h:924
static HRESULT STDMETHODCALLTYPE RichEditOleCallback_GetInPlaceContext(IRichEditOleCallback *This, LPOLEINPLACEFRAME *lplpFrame, LPOLEINPLACEUIWINDOW *lplpDoc, LPOLEINPLACEFRAMEINFO lpFrameInfo)
Definition: olecallback.c:87
unsigned int BOOL
Definition: ntddk_ex.h:94
LONG HRESULT
Definition: typedefs.h:77
const GUID IID_IUnknown
static ULONG STDMETHODCALLTYPE RichEditOleCallback_Release(IRichEditOleCallback *This)
Definition: olecallback.c:65
struct IRichEditOleCallbackVtbl olecallbackVtbl
Definition: olecallback.c:183
#define STDMETHODCALLTYPE
Definition: bdasup.h:9
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned long DWORD
Definition: ntddk_ex.h:95
#define IDM_POPUP
Definition: wordpad.h:180
#define EM_SETOLECALLBACK
Definition: richedit.h:103
HRESULT WINAPI StgCreateDocfile(LPCOLESTR pwcsName, DWORD grfMode, DWORD reserved, IStorage **ppstgOpen)
Definition: storage32.c:8637
static HRESULT STDMETHODCALLTYPE RichEditOleCallback_QueryInsertObject(IRichEditOleCallback *This, LPCLSID lpclsid, LPSTORAGE lpstg, LONG cp)
Definition: olecallback.c:105
REFIID LPVOID * ppvObject
Definition: precomp.h:44
HMENU WINAPI GetSubMenu(_In_ HMENU, _In_ int)
interface IDataObject * LPDATAOBJECT
Definition: objfwd.h:21
const IRichEditOleCallbackVtbl * vtbl
Definition: olecallback.c:35
#define STGM_READWRITE
Definition: objbase.h:918
#define S_OK
Definition: intsafe.h:59
static HRESULT STDMETHODCALLTYPE RichEditOleCallback_GetContextMenu(IRichEditOleCallback *This, WORD seltype, LPOLEOBJECT lpoleobj, CHARRANGE *lpchrg, HMENU *lphmenu)
Definition: olecallback.c:166
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define E_NOTIMPL
Definition: ddrawi.h:99
POINT cp
Definition: magnifier.c:60
Definition: name.c:36
uint32_t * LPDWORD
Definition: typedefs.h:57
HMENU WINAPI LoadMenuW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
unsigned int ULONG
Definition: retypes.h:1
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:845
HRESULT setup_richedit_olecallback(HWND hEditorWnd)
Definition: olecallback.c:203
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60
struct IRichEditOleCallbackImpl olecallback
Definition: olecallback.c:40
WINE_DEFAULT_DEBUG_CHANNEL(wordpad)
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:90
#define WINE_FIXME
Definition: debug.h:365