diff options
author | George Hazan <ghazan@miranda.im> | 2017-04-07 14:36:22 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2017-04-07 14:36:22 +0300 |
commit | c46f4344f007d814131d25fa5aec6fdb4c7a049d (patch) | |
tree | 2728e27c52e2e12bcadcf2f5606196229607c7af /src/mir_core | |
parent | 77f05f77b497b1d69e8107caefd6d19fa9c609ab (diff) |
Windows-specific code moved to mir_core
Diffstat (limited to 'src/mir_core')
-rw-r--r-- | src/mir_core/src/CCtrlRichEdit.cpp | 86 | ||||
-rw-r--r-- | src/mir_core/src/mir_core.def | 1 | ||||
-rw-r--r-- | src/mir_core/src/mir_core64.def | 1 |
3 files changed, 88 insertions, 0 deletions
diff --git a/src/mir_core/src/CCtrlRichEdit.cpp b/src/mir_core/src/CCtrlRichEdit.cpp index cc87958e66..7c874f50f5 100644 --- a/src/mir_core/src/CCtrlRichEdit.cpp +++ b/src/mir_core/src/CCtrlRichEdit.cpp @@ -22,6 +22,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "stdafx.h" +#include <RichOle.h> + ///////////////////////////////////////////////////////////////////////////////////////// // CCtrlRichEdit class @@ -121,3 +123,87 @@ char* CCtrlRichEdit::GetRichTextRtf(bool bText, bool bSelection) const SendMessage(m_hwnd, EM_STREAMOUT, dwFlags, (LPARAM)&stream); return pszText; // pszText contains the text } + +/////////////////////////////////////////////////////////////////////////////////////////////////////// + +struct CREOleCallback : public IRichEditOleCallback +{ + CREOleCallback() : refCount(0), nextStgId(0), pictStg(nullptr) {} + unsigned refCount; + IStorage *pictStg; + int nextStgId; + + STDMETHOD(QueryInterface)(REFIID riid, LPVOID FAR *ppvObj) + { + if (IsEqualIID(riid, IID_IRichEditOleCallback)) { + *ppvObj = this; + AddRef(); + return S_OK; + } + *ppvObj = nullptr; + return E_NOINTERFACE; + } + + STDMETHOD_(ULONG, AddRef)(THIS) + { + if (refCount == 0) + StgCreateDocfile(nullptr, STGM_READWRITE | STGM_SHARE_EXCLUSIVE | STGM_CREATE | STGM_DELETEONRELEASE, 0, &pictStg); + + return ++refCount; + } + + STDMETHOD_(ULONG, Release)(THIS) + { + if (--refCount == 0) { + if (pictStg) { + pictStg->Release(); + pictStg = nullptr; + } + } + return refCount; + } + + STDMETHOD(GetNewStorage)(LPSTORAGE *lplpstg) + { + wchar_t sztName[64]; + mir_snwprintf(sztName, L"s%u", nextStgId++); + if (pictStg == nullptr) + return STG_E_MEDIUMFULL; + return pictStg->CreateStorage(sztName, STGM_READWRITE | STGM_SHARE_EXCLUSIVE | STGM_CREATE, 0, 0, lplpstg); + } + + STDMETHOD(ContextSensitiveHelp)(BOOL) + { return S_OK; } + STDMETHOD(GetInPlaceContext)(LPOLEINPLACEFRAME*, LPOLEINPLACEUIWINDOW*, LPOLEINPLACEFRAMEINFO) + { return E_INVALIDARG; } + STDMETHOD(ShowContainerUI)(BOOL) + { return S_OK; } + STDMETHOD(QueryInsertObject)(LPCLSID, LPSTORAGE, LONG) + { return S_OK; } + STDMETHOD(DeleteObject)(LPOLEOBJECT) + { return S_OK; } + STDMETHOD(QueryAcceptData)(LPDATAOBJECT, CLIPFORMAT*, DWORD, BOOL, HGLOBAL) + { return S_OK; } + STDMETHOD(GetClipboardData)(CHARRANGE*, DWORD, LPDATAOBJECT*) + { return E_NOTIMPL; } + STDMETHOD(GetDragDropEffect)(BOOL, DWORD, LPDWORD) + { return S_OK; } + STDMETHOD(GetContextMenu)(WORD, LPOLEOBJECT, CHARRANGE*, HMENU*) + { return E_INVALIDARG; } +}; + +struct CREOleCallback2 : public CREOleCallback +{ + STDMETHOD(QueryAcceptData)(LPDATAOBJECT, CLIPFORMAT *lpcfFormat, DWORD, BOOL, HGLOBAL) + { *lpcfFormat = CF_UNICODETEXT; + return S_OK; + } +}; + +CREOleCallback reOleCallback; +CREOleCallback2 reOleCallback2; + +void CCtrlRichEdit::SetReadOnly(bool bReadOnly) +{ + SendMsg(EM_SETOLECALLBACK, 0, (LPARAM)(bReadOnly ? &reOleCallback : &reOleCallback2)); +} diff --git a/src/mir_core/src/mir_core.def b/src/mir_core/src/mir_core.def index ee3c8ca055..cc09ff681f 100644 --- a/src/mir_core/src/mir_core.def +++ b/src/mir_core/src/mir_core.def @@ -1047,3 +1047,4 @@ CallFunctionSync @1170 ?SetRichTextRtf@CCtrlRichEdit@@QAEHPBD@Z @1234 NONAME
?GetRichTextUtf@CCtrlRichEdit@@QBEPADXZ @1235 NONAME
?GetRichTextRtf@CCtrlRichEdit@@QBEPAD_N0@Z @1236 NONAME
+?SetReadOnly@CCtrlRichEdit@@QAEX_N@Z @1237 NONAME
diff --git a/src/mir_core/src/mir_core64.def b/src/mir_core/src/mir_core64.def index 215d63fec8..6d4473cab5 100644 --- a/src/mir_core/src/mir_core64.def +++ b/src/mir_core/src/mir_core64.def @@ -1047,3 +1047,4 @@ CallFunctionSync @1170 ?SetRichTextRtf@CCtrlRichEdit@@QEAAHPEBD@Z @1234 NONAME
?GetRichTextUtf@CCtrlRichEdit@@QEBAPEADXZ @1235 NONAME
?GetRichTextRtf@CCtrlRichEdit@@QEBAPEAD_N0@Z @1236 NONAME
+?SetReadOnly@CCtrlRichEdit@@QEAAX_N@Z @1237 NONAME
|