Commit a1324584 authored by Kevin Koltzau's avatar Kevin Koltzau Committed by Alexandre Julliard

riched20: Add IDataObject implementation and use it for cut/copy.

parent a8b20975
...@@ -9,6 +9,7 @@ EXTRALIBS = $(LIBUNICODE) -luuid ...@@ -9,6 +9,7 @@ EXTRALIBS = $(LIBUNICODE) -luuid
C_SRCS = \ C_SRCS = \
caret.c \ caret.c \
clipboard.c \
context.c \ context.c \
editor.c \ editor.c \
list.c \ list.c \
......
...@@ -1041,29 +1041,6 @@ typedef struct tagME_GlobalDestStruct ...@@ -1041,29 +1041,6 @@ typedef struct tagME_GlobalDestStruct
int nLength; int nLength;
} ME_GlobalDestStruct; } ME_GlobalDestStruct;
static DWORD CALLBACK ME_AppendToHGLOBAL(DWORD_PTR dwCookie, LPBYTE lpBuff, LONG cb, LONG *pcb)
{
ME_GlobalDestStruct *pData = (ME_GlobalDestStruct *)dwCookie;
int nMaxSize;
BYTE *pDest;
nMaxSize = GlobalSize(pData->hData);
if (pData->nLength+cb+1 >= cb)
{
/* round up to 2^17 */
int nNewSize = (((nMaxSize+cb+1)|0x1FFFF)+1) & 0xFFFE0000;
pData->hData = GlobalReAlloc(pData->hData, nNewSize, 0);
}
pDest = (BYTE *)GlobalLock(pData->hData);
memcpy(pDest + pData->nLength, lpBuff, cb);
pData->nLength += cb;
pDest[pData->nLength] = '\0';
GlobalUnlock(pData->hData);
*pcb = cb;
return 0;
}
static DWORD CALLBACK ME_ReadFromHGLOBALUnicode(DWORD_PTR dwCookie, LPBYTE lpBuff, LONG cb, LONG *pcb) static DWORD CALLBACK ME_ReadFromHGLOBALUnicode(DWORD_PTR dwCookie, LPBYTE lpBuff, LONG cb, LONG *pcb)
{ {
ME_GlobalDestStruct *pData = (ME_GlobalDestStruct *)dwCookie; ME_GlobalDestStruct *pData = (ME_GlobalDestStruct *)dwCookie;
...@@ -1790,38 +1767,18 @@ LRESULT WINAPI RichEditANSIWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lP ...@@ -1790,38 +1767,18 @@ LRESULT WINAPI RichEditANSIWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lP
case WM_CUT: case WM_CUT:
case WM_COPY: case WM_COPY:
{ {
int from, to, pars; LPDATAOBJECT dataObj;
WCHAR *data; CHARRANGE range;
HANDLE hData; HRESULT hr;
EDITSTREAM es; ME_GetSelection(editor, (int*)&range.cpMin, (int*)&range.cpMax);
ME_GlobalDestStruct gds; hr = ME_GetDataObject(editor, &range, &dataObj);
if(SUCCEEDED(hr)) {
if (!OpenClipboard(hWnd)) hr = OleSetClipboard(dataObj);
return 0; IDataObject_Release(dataObj);
EmptyClipboard();
ME_GetSelection(editor, &from, &to);
pars = ME_CountParagraphsBetween(editor, from, to);
hData = GlobalAlloc(GMEM_MOVEABLE, sizeof(WCHAR)*(to-from+pars+1));
data = (WCHAR *)GlobalLock(hData);
ME_GetTextW(editor, data, from, to-from, TRUE);
GlobalUnlock(hData);
if (editor->mode & TM_RICHTEXT)
{
gds.hData = GlobalAlloc(GMEM_MOVEABLE, 0);
gds.nLength = 0;
es.dwCookie = (DWORD)&gds;
es.pfnCallback = ME_AppendToHGLOBAL;
ME_StreamOutRange(editor, SF_RTF, from, to, &es);
GlobalReAlloc(gds.hData, gds.nLength+1, 0);
SetClipboardData(RegisterClipboardFormatA("Rich Text Format"), gds.hData);
} }
SetClipboardData(CF_UNICODETEXT, hData); if (SUCCEEDED(hr) && msg == WM_CUT)
CloseClipboard();
if (msg == WM_CUT)
{ {
ME_InternalDeleteText(editor, from, to-from); ME_InternalDeleteText(editor, range.cpMin, range.cpMax-range.cpMin);
ME_CommitUndo(editor); ME_CommitUndo(editor);
ME_UpdateRepaint(editor); ME_UpdateRepaint(editor);
} }
......
...@@ -28,6 +28,15 @@ ...@@ -28,6 +28,15 @@
#define RUN_IS_HIDDEN(run) ((run)->style->fmt.dwMask & CFM_HIDDEN \ #define RUN_IS_HIDDEN(run) ((run)->style->fmt.dwMask & CFM_HIDDEN \
&& (run)->style->fmt.dwEffects & CFE_HIDDEN) && (run)->style->fmt.dwEffects & CFE_HIDDEN)
#define InitFormatEtc(fe, cf, med) \
{\
(fe).cfFormat=cf;\
(fe).dwAspect=DVASPECT_CONTENT;\
(fe).ptd=NULL;\
(fe).tymed=med;\
(fe).lindex=-1;\
};
/* style.c */ /* style.c */
ME_Style *ME_MakeStyle(CHARFORMAT2W *style); ME_Style *ME_MakeStyle(CHARFORMAT2W *style);
void ME_AddRefStyle(ME_Style *item); void ME_AddRefStyle(ME_Style *item);
...@@ -249,3 +258,6 @@ extern void DoWrap(ME_TextEditor *editor); ...@@ -249,3 +258,6 @@ extern void DoWrap(ME_TextEditor *editor);
/* writer.c */ /* writer.c */
LRESULT ME_StreamOutRange(ME_TextEditor *editor, DWORD dwFormat, int nStart, int nTo, EDITSTREAM *stream); LRESULT ME_StreamOutRange(ME_TextEditor *editor, DWORD dwFormat, int nStart, int nTo, EDITSTREAM *stream);
LRESULT ME_StreamOut(ME_TextEditor *editor, DWORD dwFormat, EDITSTREAM *stream); LRESULT ME_StreamOut(ME_TextEditor *editor, DWORD dwFormat, EDITSTREAM *stream);
/* clipboard.c */
HRESULT ME_GetDataObject(ME_TextEditor *editor, CHARRANGE *lpchrg, LPDATAOBJECT *lplpdataobj);
...@@ -30,6 +30,10 @@ ...@@ -30,6 +30,10 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#define COBJMACROS
#define NONAMELESSUNION
#define NONAMELESSSTRUCT
#include <windef.h> #include <windef.h>
#include <winbase.h> #include <winbase.h>
#include <winnls.h> #include <winnls.h>
...@@ -38,7 +42,6 @@ ...@@ -38,7 +42,6 @@
#include <winuser.h> #include <winuser.h>
#include <richedit.h> #include <richedit.h>
#include <commctrl.h> #include <commctrl.h>
#define COBJMACROS
#include <ole2.h> #include <ole2.h>
#include <richole.h> #include <richole.h>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment