ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

olecallback.c
Go to the documentation of this file.
00001 /*
00002  * Wordpad implementation - Richedit OLE callback implementation
00003  *
00004  * Copyright 2010 by Dylan Smith <dylan.ah.smith@gmail.com>
00005  *
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Lesser General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2.1 of the License, or (at your option) any later version.
00010  *
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with this library; if not, write to the Free Software
00018  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
00019  */
00020 
00021 #define COBJMACROS
00022 
00023 #include <windows.h>
00024 #include <richedit.h>
00025 #include <ole2.h>
00026 #include <richole.h>
00027 
00028 #include "wine/debug.h"
00029 #include "wordpad.h"
00030 
00031 WINE_DEFAULT_DEBUG_CHANNEL(wordpad);
00032 
00033 struct IRichEditOleCallbackImpl {
00034     const IRichEditOleCallbackVtbl *vtbl;
00035     IStorage *stg;
00036     int item_num;
00037 };
00038 
00039 struct IRichEditOleCallbackImpl olecallback;
00040 
00041 static HRESULT STDMETHODCALLTYPE RichEditOleCallback_QueryInterface(
00042     IRichEditOleCallback* This,
00043     REFIID riid,
00044     void **ppvObject)
00045 {
00046     WINE_TRACE("(%p, %s, %p)\n", This, wine_dbgstr_guid(riid), ppvObject);
00047     if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IRichEditOleCallback))
00048     {
00049         *ppvObject = This;
00050         return S_OK;
00051     }
00052     WINE_FIXME("Unknown interface: %s\n", wine_dbgstr_guid(riid));
00053     return E_NOINTERFACE;
00054 }
00055 
00056 static ULONG STDMETHODCALLTYPE RichEditOleCallback_AddRef(
00057     IRichEditOleCallback* This)
00058 {
00059     WINE_TRACE("(%p)\n", This);
00060     /* singleton */
00061     return 1;
00062 }
00063 
00064 static ULONG STDMETHODCALLTYPE RichEditOleCallback_Release(
00065     IRichEditOleCallback* This)
00066 {
00067     WINE_TRACE("(%p)\n", This);
00068     return 1;
00069 }
00070 
00071 /*** IRichEditOleCallback methods ***/
00072 static HRESULT STDMETHODCALLTYPE RichEditOleCallback_GetNewStorage(
00073     IRichEditOleCallback* This,
00074     LPSTORAGE *lplpstg)
00075 {
00076     WCHAR name[32];
00077     static const WCHAR template[] = {'R','E','O','L','E','_','%','u','\0'};
00078 
00079     WINE_TRACE("(%p, %p)\n", This, lplpstg);
00080     wsprintfW(name, template, olecallback.item_num++);
00081     return IStorage_CreateStorage(olecallback.stg, name,
00082                       STGM_READWRITE | STGM_SHARE_EXCLUSIVE | STGM_CREATE,
00083                       0, 0, lplpstg);
00084 }
00085 
00086 static HRESULT STDMETHODCALLTYPE RichEditOleCallback_GetInPlaceContext(
00087     IRichEditOleCallback* This,
00088     LPOLEINPLACEFRAME *lplpFrame,
00089     LPOLEINPLACEUIWINDOW *lplpDoc,
00090     LPOLEINPLACEFRAMEINFO lpFrameInfo)
00091 {
00092     WINE_FIXME("(%p, %p, %p, %p) stub\n", This, lplpFrame, lplpDoc, lpFrameInfo);
00093     return E_INVALIDARG;
00094 }
00095 
00096 static HRESULT STDMETHODCALLTYPE RichEditOleCallback_ShowContainerUI(
00097     IRichEditOleCallback* This,
00098     BOOL fShow)
00099 {
00100     WINE_TRACE("(%p, %d)\n", This, fShow);
00101     return S_OK;
00102 }
00103 
00104 static HRESULT STDMETHODCALLTYPE RichEditOleCallback_QueryInsertObject(
00105     IRichEditOleCallback* This,
00106     LPCLSID lpclsid,
00107     LPSTORAGE lpstg,
00108     LONG cp)
00109 {
00110     WINE_TRACE("(%p, %p, %p, %d)\n", This, lpclsid, lpstg, cp);
00111     return S_OK;
00112 }
00113 
00114 static HRESULT STDMETHODCALLTYPE RichEditOleCallback_DeleteObject(
00115     IRichEditOleCallback* This,
00116     LPOLEOBJECT lpoleobj)
00117 {
00118     WINE_TRACE("(%p, %p)\n", This, lpoleobj);
00119     return S_OK;
00120 }
00121 
00122 static HRESULT STDMETHODCALLTYPE RichEditOleCallback_QueryAcceptData(
00123     IRichEditOleCallback* This,
00124     LPDATAOBJECT lpdataobj,
00125     CLIPFORMAT *lpcfFormat,
00126     DWORD reco,
00127     BOOL fReally,
00128     HGLOBAL hMetaPict)
00129 {
00130     WINE_TRACE("(%p, %p, %p, %x, %d, %p)\n",
00131                This, lpdataobj, lpcfFormat, reco, fReally, hMetaPict);
00132     return S_OK;
00133 }
00134 
00135 static HRESULT STDMETHODCALLTYPE RichEditOleCallback_ContextSensitiveHelp(
00136     IRichEditOleCallback* This,
00137     BOOL fEnterMode)
00138 {
00139     WINE_TRACE("(%p, %d)\n", This, fEnterMode);
00140     return S_OK;
00141 }
00142 
00143 static HRESULT STDMETHODCALLTYPE RichEditOleCallback_GetClipboardData(
00144     IRichEditOleCallback* This,
00145     CHARRANGE *lpchrg,
00146     DWORD reco,
00147     LPDATAOBJECT *lplpdataobj)
00148 {
00149     WINE_TRACE("(%p, %p, %x, %p)\n", This, lpchrg, reco, lplpdataobj);
00150     return E_NOTIMPL;
00151 }
00152 
00153 static HRESULT STDMETHODCALLTYPE RichEditOleCallback_GetDragDropEffect(
00154     IRichEditOleCallback* This,
00155     BOOL fDrag,
00156     DWORD grfKeyState,
00157     LPDWORD pdwEffect)
00158 {
00159     WINE_TRACE("(%p, %d, %x, %p)\n", This, fDrag, grfKeyState, pdwEffect);
00160     if (pdwEffect)
00161           *pdwEffect = DROPEFFECT_COPY;
00162     return S_OK;
00163 }
00164 
00165 static HRESULT STDMETHODCALLTYPE RichEditOleCallback_GetContextMenu(
00166     IRichEditOleCallback* This,
00167     WORD seltype,
00168     LPOLEOBJECT lpoleobj,
00169     CHARRANGE *lpchrg,
00170     HMENU *lphmenu)
00171 {
00172     HINSTANCE hInstance = GetModuleHandleW(0);
00173     HMENU hPopupMenu = LoadMenuW(hInstance, MAKEINTRESOURCEW(IDM_POPUP));
00174 
00175     WINE_TRACE("(%p, %x, %p, %p, %p)\n",
00176                This, seltype, lpoleobj, lpchrg, lphmenu);
00177 
00178     *lphmenu = GetSubMenu(hPopupMenu, 0);
00179     return S_OK;
00180 }
00181 
00182 struct IRichEditOleCallbackVtbl olecallbackVtbl = {
00183     RichEditOleCallback_QueryInterface,
00184     RichEditOleCallback_AddRef,
00185     RichEditOleCallback_Release,
00186     RichEditOleCallback_GetNewStorage,
00187     RichEditOleCallback_GetInPlaceContext,
00188     RichEditOleCallback_ShowContainerUI,
00189     RichEditOleCallback_QueryInsertObject,
00190     RichEditOleCallback_DeleteObject,
00191     RichEditOleCallback_QueryAcceptData,
00192     RichEditOleCallback_ContextSensitiveHelp,
00193     RichEditOleCallback_GetClipboardData,
00194     RichEditOleCallback_GetDragDropEffect,
00195     RichEditOleCallback_GetContextMenu
00196 };
00197 
00198 struct IRichEditOleCallbackImpl olecallback = {
00199     &olecallbackVtbl, NULL, 0
00200 };
00201 
00202 HRESULT setup_richedit_olecallback(HWND hEditorWnd)
00203 {
00204     HRESULT hr = StgCreateDocfile(NULL,
00205           STGM_READWRITE | STGM_SHARE_EXCLUSIVE | STGM_DELETEONRELEASE,
00206           0, &olecallback.stg);
00207 
00208     SendMessageW(hEditorWnd, EM_SETOLECALLBACK, 0, (LPARAM)&olecallback);
00209     return hr;
00210 }

Generated on Sat May 26 2012 04:16:32 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.