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
28 #include "wine/debug.h"
31 WINE_DEFAULT_DEBUG_CHANNEL(wordpad
);
33 struct IRichEditOleCallbackImpl
{
34 IRichEditOleCallback IRichEditOleCallback_iface
;
39 struct IRichEditOleCallbackImpl olecallback
;
41 static HRESULT STDMETHODCALLTYPE
RichEditOleCallback_QueryInterface(
42 IRichEditOleCallback
* This
,
46 WINE_TRACE("(%p, %s, %p)\n", This
, wine_dbgstr_guid(riid
), ppvObject
);
47 if (IsEqualIID(riid
, &IID_IUnknown
) || IsEqualIID(riid
, &IID_IRichEditOleCallback
))
52 WINE_FIXME("Unknown interface: %s\n", wine_dbgstr_guid(riid
));
56 static ULONG STDMETHODCALLTYPE
RichEditOleCallback_AddRef(
57 IRichEditOleCallback
* This
)
59 WINE_TRACE("(%p)\n", This
);
64 static ULONG STDMETHODCALLTYPE
RichEditOleCallback_Release(
65 IRichEditOleCallback
* This
)
67 WINE_TRACE("(%p)\n", This
);
71 /*** IRichEditOleCallback methods ***/
72 static HRESULT STDMETHODCALLTYPE
RichEditOleCallback_GetNewStorage(
73 IRichEditOleCallback
* This
,
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
,
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
);
96 static HRESULT STDMETHODCALLTYPE
RichEditOleCallback_ShowContainerUI(
97 IRichEditOleCallback
* This
,
100 WINE_TRACE("(%p, %d)\n", This
, fShow
);
104 static HRESULT STDMETHODCALLTYPE
RichEditOleCallback_QueryInsertObject(
105 IRichEditOleCallback
* This
,
110 WINE_TRACE("(%p, %p, %p, %d)\n", This
, lpclsid
, lpstg
, cp
);
114 static HRESULT STDMETHODCALLTYPE
RichEditOleCallback_DeleteObject(
115 IRichEditOleCallback
* This
,
116 LPOLEOBJECT lpoleobj
)
118 WINE_TRACE("(%p, %p)\n", This
, lpoleobj
);
122 static HRESULT STDMETHODCALLTYPE
RichEditOleCallback_QueryAcceptData(
123 IRichEditOleCallback
* This
,
124 LPDATAOBJECT lpdataobj
,
125 CLIPFORMAT
*lpcfFormat
,
130 WINE_TRACE("(%p, %p, %p, %x, %d, %p)\n",
131 This
, lpdataobj
, lpcfFormat
, reco
, fReally
, hMetaPict
);
135 static HRESULT STDMETHODCALLTYPE
RichEditOleCallback_ContextSensitiveHelp(
136 IRichEditOleCallback
* This
,
139 WINE_TRACE("(%p, %d)\n", This
, fEnterMode
);
143 static HRESULT STDMETHODCALLTYPE
RichEditOleCallback_GetClipboardData(
144 IRichEditOleCallback
* This
,
147 LPDATAOBJECT
*lplpdataobj
)
149 WINE_TRACE("(%p, %p, %x, %p)\n", This
, lpchrg
, reco
, lplpdataobj
);
153 static HRESULT STDMETHODCALLTYPE
RichEditOleCallback_GetDragDropEffect(
154 IRichEditOleCallback
* This
,
159 WINE_TRACE("(%p, %d, %x, %p)\n", This
, fDrag
, grfKeyState
, pdwEffect
);
161 *pdwEffect
= DROPEFFECT_COPY
;
165 static HRESULT STDMETHODCALLTYPE
RichEditOleCallback_GetContextMenu(
166 IRichEditOleCallback
* This
,
168 LPOLEOBJECT lpoleobj
,
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);
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
.IRichEditOleCallback_iface
);