From ec29185ee5cc8fb28fbcf81c5ce36483bc25992e Mon Sep 17 00:00:00 2001 From: Amine Khaldi Date: Sun, 17 Sep 2017 22:57:18 +0000 Subject: [PATCH] [RICHED20] Sync with Wine Staging 2.16. CORE-13762 58cac9c riched20: Remove the separate implementation of IOleWindow as IOleInPlaceSite inherits from IOleWindow. adf53a9 riched20: Add support for pasting EMFs. bbf34a4 riched20: Use the implementation of EM_PASTESPECIAL for EM_CANPASTE. 46fef3d riched20: Use the implementation of EM_PASTESPECIAL for WM_PASTE. 9bec53f riched20: Add support for EM_PASTESPECIAL. 417c80d riched20: Don't create a special richedit ole instance for the RTF parser. 1bc48be riched20: Initialize ME_TextEditor members in ME_MakeEditor(). 5cc8c9f riched20: Retrieve the default paragraph alignment from the text host. 4cb7578 riched20: Move the editor initialization out of CreateTextHost(). 2d91663 riched20: New high resolution cursor generated from SVG. 17b7cde riched20: The background colour is set using \highlight. svn path=/trunk/; revision=75896 --- reactos/dll/win32/riched20/editor.c | 219 +++++++++++++++------ reactos/dll/win32/riched20/editor.h | 2 +- reactos/dll/win32/riched20/editstr.h | 1 - reactos/dll/win32/riched20/ocr_reverse.cur | Bin 326 -> 33134 bytes reactos/dll/win32/riched20/para.c | 14 +- reactos/dll/win32/riched20/reader.c | 2 +- reactos/dll/win32/riched20/richole.c | 77 ++------ reactos/dll/win32/riched20/rtf.h | 1 - reactos/dll/win32/riched20/txthost.c | 36 ++-- reactos/dll/win32/riched20/txtsrv.c | 4 +- reactos/dll/win32/riched20/writer.c | 2 +- reactos/media/doc/README.WINE | 2 +- 12 files changed, 213 insertions(+), 147 deletions(-) diff --git a/reactos/dll/win32/riched20/editor.c b/reactos/dll/win32/riched20/editor.c index a43a0e0034e..645d06cedcf 100644 --- a/reactos/dll/win32/riched20/editor.c +++ b/reactos/dll/win32/riched20/editor.c @@ -1119,8 +1119,8 @@ void ME_RTFSpecialCharHook(RTF_Info *info) } } -static BOOL ME_RTFInsertOleObject(RTF_Info *info, HENHMETAFILE hemf, HBITMAP hbmp, - const SIZEL* sz) +static HRESULT insert_static_object(ME_TextEditor *editor, HENHMETAFILE hemf, HBITMAP hbmp, + const SIZEL* sz) { LPOLEOBJECT lpObject = NULL; LPSTORAGE lpStorage = NULL; @@ -1130,7 +1130,7 @@ static BOOL ME_RTFInsertOleObject(RTF_Info *info, HENHMETAFILE hemf, HBITMAP hbm STGMEDIUM stgm; FORMATETC fm; CLSID clsid; - BOOL ret = FALSE; + HRESULT hr = E_FAIL; DWORD conn; if (hemf) @@ -1152,13 +1152,14 @@ static BOOL ME_RTFInsertOleObject(RTF_Info *info, HENHMETAFILE hemf, HBITMAP hbm fm.lindex = -1; fm.tymed = stgm.tymed; - if (!info->lpRichEditOle) + if (!editor->reOle) { - CreateIRichEditOle(NULL, info->editor, (VOID**)&info->lpRichEditOle); + if (!CreateIRichEditOle(NULL, editor, (LPVOID *)&editor->reOle)) + return hr; } if (OleCreateDefaultHandler(&CLSID_NULL, NULL, &IID_IOleObject, (void**)&lpObject) == S_OK && - IRichEditOle_GetClientSite(info->lpRichEditOle, &lpClientSite) == S_OK && + IRichEditOle_GetClientSite(editor->reOle, &lpClientSite) == S_OK && IOleObject_SetClientSite(lpObject, lpClientSite) == S_OK && IOleObject_GetUserClassID(lpObject, &clsid) == S_OK && IOleObject_QueryInterface(lpObject, &IID_IOleCache, (void**)&lpOleCache) == S_OK && @@ -1181,8 +1182,8 @@ static BOOL ME_RTFInsertOleObject(RTF_Info *info, HENHMETAFILE hemf, HBITMAP hbm reobject.dwFlags = 0; /* FIXME */ reobject.dwUser = 0; - ME_InsertOLEFromCursor(info->editor, &reobject, 0); - ret = TRUE; + ME_InsertOLEFromCursor(editor, &reobject, 0); + hr = S_OK; } if (lpObject) IOleObject_Release(lpObject); @@ -1191,7 +1192,7 @@ static BOOL ME_RTFInsertOleObject(RTF_Info *info, HENHMETAFILE hemf, HBITMAP hbm if (lpDataObject) IDataObject_Release(lpDataObject); if (lpOleCache) IOleCache_Release(lpOleCache); - return ret; + return hr; } static void ME_RTFReadShpPictGroup( RTF_Info *info ) @@ -1350,11 +1351,11 @@ static void ME_RTFReadPictGroup(RTF_Info *info) { case gfx_enhmetafile: if ((hemf = SetEnhMetaFileBits( size, buffer ))) - ME_RTFInsertOleObject( info, hemf, NULL, &sz ); + insert_static_object( info->editor, hemf, NULL, &sz ); break; case gfx_metafile: if ((hemf = SetWinMetaFileBits( size, buffer, NULL, &mfp ))) - ME_RTFInsertOleObject( info, hemf, NULL, &sz ); + insert_static_object( info->editor, hemf, NULL, &sz ); break; case gfx_dib: { @@ -1368,7 +1369,7 @@ static void ME_RTFReadPictGroup(RTF_Info *info) if ((hbmp = CreateDIBitmap( hdc, &bi->bmiHeader, CBM_INIT, (char*)(bi + 1) + nc * sizeof(RGBQUAD), bi, DIB_RGB_COLORS)) ) - ME_RTFInsertOleObject( info, NULL, hbmp, &sz ); + insert_static_object( info->editor, NULL, hbmp, &sz ); ReleaseDC( 0, hdc ); break; } @@ -1724,8 +1725,6 @@ static LRESULT ME_StreamIn(ME_TextEditor *editor, DWORD format, EDITSTREAM *stre } ME_CheckTablesForCorruption(editor); RTFDestroy(&parser); - if (parser.lpRichEditOle) - IRichEditOle_Release(parser.lpRichEditOle); if (parser.stackTop > 0) { @@ -2207,31 +2206,122 @@ static DWORD CALLBACK ME_ReadFromHGLOBALRTF(DWORD_PTR dwCookie, LPBYTE lpBuff, L return 0; } -static BOOL ME_Paste(ME_TextEditor *editor) +static const WCHAR rtfW[] = {'R','i','c','h',' ','T','e','x','t',' ','F','o','r','m','a','t',0}; + +static HRESULT paste_rtf(ME_TextEditor *editor, FORMATETC *fmt, STGMEDIUM *med) { - DWORD dwFormat = 0; - EDITSTREAM es; - ME_GlobalDestStruct gds; - UINT nRTFFormat = RegisterClipboardFormatA("Rich Text Format"); - UINT cf = 0; + EDITSTREAM es; + ME_GlobalDestStruct gds; + HRESULT hr; - if (IsClipboardFormatAvailable(nRTFFormat)) - cf = nRTFFormat, dwFormat = SF_RTF; - else if (IsClipboardFormatAvailable(CF_UNICODETEXT)) - cf = CF_UNICODETEXT, dwFormat = SF_TEXT|SF_UNICODE; - else - return FALSE; + gds.hData = med->u.hGlobal; + gds.nLength = 0; + es.dwCookie = (DWORD_PTR)&gds; + es.pfnCallback = ME_ReadFromHGLOBALRTF; + hr = ME_StreamIn( editor, SF_RTF | SFF_SELECTION, &es, FALSE ) == 0 ? E_FAIL : S_OK; + ReleaseStgMedium( med ); + return hr; +} - if (!OpenClipboard(editor->hWnd)) - return FALSE; - gds.hData = GetClipboardData(cf); - gds.nLength = 0; - es.dwCookie = (DWORD_PTR)&gds; - es.pfnCallback = dwFormat == SF_RTF ? ME_ReadFromHGLOBALRTF : ME_ReadFromHGLOBALUnicode; - ME_StreamIn(editor, dwFormat|SFF_SELECTION, &es, FALSE); +static HRESULT paste_text(ME_TextEditor *editor, FORMATETC *fmt, STGMEDIUM *med) +{ + EDITSTREAM es; + ME_GlobalDestStruct gds; + HRESULT hr; - CloseClipboard(); - return TRUE; + gds.hData = med->u.hGlobal; + gds.nLength = 0; + es.dwCookie = (DWORD_PTR)&gds; + es.pfnCallback = ME_ReadFromHGLOBALUnicode; + hr = ME_StreamIn( editor, SF_TEXT | SF_UNICODE | SFF_SELECTION, &es, FALSE ) == 0 ? E_FAIL : S_OK; + ReleaseStgMedium( med ); + return hr; +} + +static HRESULT paste_emf(ME_TextEditor *editor, FORMATETC *fmt, STGMEDIUM *med) +{ + HRESULT hr; + SIZEL sz = {0, 0}; + + hr = insert_static_object( editor, med->u.hEnhMetaFile, NULL, &sz ); + if (SUCCEEDED(hr)) + { + ME_CommitUndo( editor ); + ME_UpdateRepaint( editor, FALSE ); + } + else + ReleaseStgMedium( med ); + + return hr; +} + +static struct paste_format +{ + FORMATETC fmt; + HRESULT (*paste)(ME_TextEditor *, FORMATETC *, STGMEDIUM *); + const WCHAR *name; +} paste_formats[] = +{ + {{ -1, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL }, paste_rtf, rtfW }, + {{ CF_UNICODETEXT, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL }, paste_text }, + {{ CF_ENHMETAFILE, NULL, DVASPECT_CONTENT, -1, TYMED_ENHMF }, paste_emf }, + {{ 0 }} +}; + +static void init_paste_formats(void) +{ + struct paste_format *format; + static int done; + + if (!done) + { + for (format = paste_formats; format->fmt.cfFormat; format++) + { + if (format->name) + format->fmt.cfFormat = RegisterClipboardFormatW( format->name ); + } + done = 1; + } +} + +static BOOL paste_special(ME_TextEditor *editor, UINT cf, REPASTESPECIAL *ps, BOOL check_only) +{ + HRESULT hr; + STGMEDIUM med; + struct paste_format *format; + IDataObject *data; + + init_paste_formats(); + + if (ps && ps->dwAspect != DVASPECT_CONTENT) + FIXME("Ignoring aspect %x\n", ps->dwAspect); + + hr = OleGetClipboard( &data ); + if (hr != S_OK) return FALSE; + + if (cf == CF_TEXT) cf = CF_UNICODETEXT; + + hr = S_FALSE; + for (format = paste_formats; format->fmt.cfFormat; format++) + { + if (cf && cf != format->fmt.cfFormat) continue; + hr = IDataObject_QueryGetData( data, &format->fmt ); + if (hr == S_OK) + { + if (!check_only) + { + hr = IDataObject_GetData( data, &format->fmt, &med ); + if (hr != S_OK) goto done; + hr = format->paste( editor, &format->fmt, &med ); + } + break; + } + } + +done: + IDataObject_Release( data ); + + return hr == S_OK; } static BOOL ME_Copy(ME_TextEditor *editor, const ME_Cursor *start, int nChars) @@ -2547,7 +2637,7 @@ ME_KeyDown(ME_TextEditor *editor, WORD nKey) break; case 'V': if (ctrl_is_down) - return ME_Paste(editor); + return paste_special( editor, 0, NULL, FALSE ); break; case 'C': case 'X': @@ -2881,7 +2971,7 @@ static BOOL ME_ShowContextMenu(ME_TextEditor *editor, int x, int y) return TRUE; } -ME_TextEditor *ME_MakeEditor(ITextHost *texthost, BOOL bEmulateVersion10, DWORD csStyle) +ME_TextEditor *ME_MakeEditor(ITextHost *texthost, BOOL bEmulateVersion10) { ME_TextEditor *ed = ALLOC_OBJ(ME_TextEditor); int i; @@ -2895,11 +2985,7 @@ ME_TextEditor *ME_MakeEditor(ITextHost *texthost, BOOL bEmulateVersion10, DWORD ed->reOle = NULL; ed->bEmulateVersion10 = bEmulateVersion10; ed->styleFlags = 0; - ed->alignStyle = PFA_LEFT; - if (csStyle & ES_RIGHT) - ed->alignStyle = PFA_RIGHT; - if (csStyle & ES_CENTER) - ed->alignStyle = PFA_CENTER; + ed->exStyleFlags = 0; ITextHost_TxGetPropertyBits(texthost, (TXTBIT_RICHTEXT|TXTBIT_MULTILINE| TXTBIT_READONLY|TXTBIT_USEPASSWORD| @@ -2960,6 +3046,7 @@ ME_TextEditor *ME_MakeEditor(ITextHost *texthost, BOOL bEmulateVersion10, DWORD } ME_CheckCharOffsets(ed); + SetRectEmpty(&ed->rcFormat); ed->bDefaultFormatRect = TRUE; ITextHost_TxGetSelectionBarWidth(ed->texthost, &selbarwidth); if (selbarwidth) { @@ -3411,7 +3498,6 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam, UNSUPPORTED_MSG(EM_GETTYPOGRAPHYOPTIONS) UNSUPPORTED_MSG(EM_GETUNDONAME) UNSUPPORTED_MSG(EM_GETWORDBREAKPROCEX) - UNSUPPORTED_MSG(EM_PASTESPECIAL) UNSUPPORTED_MSG(EM_SELECTIONTYPE) UNSUPPORTED_MSG(EM_SETBIDIOPTIONS) UNSUPPORTED_MSG(EM_SETEDITSTYLE) @@ -3968,17 +4054,14 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam, return 1; } case EM_CANPASTE: - { - UINT nRTFFormat = RegisterClipboardFormatA("Rich Text Format"); - if (IsClipboardFormatAvailable(nRTFFormat)) - return TRUE; - if (IsClipboardFormatAvailable(CF_UNICODETEXT)) - return TRUE; - return FALSE; - } + return paste_special( editor, 0, NULL, TRUE ); case WM_PASTE: case WM_MBUTTONDOWN: - ME_Paste(editor); + wParam = 0; + lParam = 0; + /* fall through */ + case EM_PASTESPECIAL: + paste_special( editor, wParam, (REPASTESPECIAL *)lParam, FALSE ); return 0; case WM_CUT: case WM_COPY: @@ -4789,6 +4872,30 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam, return 0L; } +static BOOL create_windowed_editor(HWND hwnd, CREATESTRUCTW *create, BOOL emulate_10) +{ + ITextHost *host = ME_CreateTextHost( hwnd, create, emulate_10 ); + ME_TextEditor *editor; + + if (!host) return FALSE; + + editor = ME_MakeEditor( host, emulate_10 ); + if (!editor) + { + ITextHost_Release( host ); + return FALSE; + } + + editor->exStyleFlags = GetWindowLongW( hwnd, GWL_EXSTYLE ); + editor->styleFlags |= GetWindowLongW( hwnd, GWL_STYLE ) & ES_WANTRETURN; + editor->hWnd = hwnd; /* FIXME: Remove editor's dependence on hWnd */ + editor->hwndParent = create->hwndParent; + + SetWindowLongPtrW( hwnd, 0, (LONG_PTR)editor ); + + return TRUE; +} + static LRESULT RichEditWndProc_common(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam, BOOL unicode) { @@ -4805,11 +4912,9 @@ static LRESULT RichEditWndProc_common(HWND hWnd, UINT msg, WPARAM wParam, if (msg == WM_NCCREATE) { CREATESTRUCTW *pcs = (CREATESTRUCTW *)lParam; - ITextHost *texthost; TRACE("WM_NCCREATE: hWnd %p style 0x%08x\n", hWnd, pcs->style); - texthost = ME_CreateTextHost(hWnd, pcs, FALSE); - return texthost != NULL; + return create_windowed_editor( hWnd, pcs, FALSE ); } else { @@ -4935,12 +5040,10 @@ LRESULT WINAPI RichEdit10ANSIWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM { if (msg == WM_NCCREATE && !GetWindowLongPtrW(hWnd, 0)) { - ITextHost *texthost; CREATESTRUCTW *pcs = (CREATESTRUCTW *)lParam; TRACE("WM_NCCREATE: hWnd %p style 0x%08x\n", hWnd, pcs->style); - texthost = ME_CreateTextHost(hWnd, pcs, TRUE); - return texthost != NULL; + return create_windowed_editor( hWnd, pcs, TRUE ); } return RichEditANSIWndProc(hWnd, msg, wParam, lParam); } diff --git a/reactos/dll/win32/riched20/editor.h b/reactos/dll/win32/riched20/editor.h index 505733f7e52..9599a3eef68 100644 --- a/reactos/dll/win32/riched20/editor.h +++ b/reactos/dll/win32/riched20/editor.h @@ -290,7 +290,7 @@ void ME_DeleteReObject(REOBJECT* reo) DECLSPEC_HIDDEN; void ME_GetITextDocumentInterface(IRichEditOle *iface, LPVOID *ppvObj) DECLSPEC_HIDDEN; /* editor.c */ -ME_TextEditor *ME_MakeEditor(ITextHost *texthost, BOOL bEmulateVersion10, DWORD csStyle) DECLSPEC_HIDDEN; +ME_TextEditor *ME_MakeEditor(ITextHost *texthost, BOOL bEmulateVersion10) DECLSPEC_HIDDEN; void ME_DestroyEditor(ME_TextEditor *editor) DECLSPEC_HIDDEN; LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam, LPARAM lParam, BOOL unicode, HRESULT* phresult) DECLSPEC_HIDDEN; diff --git a/reactos/dll/win32/riched20/editstr.h b/reactos/dll/win32/riched20/editstr.h index 88a0a8dff14..ac7ca31607e 100644 --- a/reactos/dll/win32/riched20/editstr.h +++ b/reactos/dll/win32/riched20/editstr.h @@ -353,7 +353,6 @@ typedef struct tagME_TextEditor ME_TextBuffer *pBuffer; ME_Cursor *pCursors; DWORD styleFlags; - DWORD alignStyle; DWORD exStyleFlags; int nCursors; SIZE sizeWindow; diff --git a/reactos/dll/win32/riched20/ocr_reverse.cur b/reactos/dll/win32/riched20/ocr_reverse.cur index 179774c60ee788a09a61dc8d6fd3b8f0075e37b2..f6b5ca20f5d60aaa8df17235d3ccb2ef56d8bf45 100644 GIT binary patch literal 33134 zcmeHPdyo{x9iF{CSl-7=IG(qFAVDqA7z7pW5EI^*kfb6B!hwK6C<9`NAaE-$1tCyY zsuB<=Ql?5Q0%as91d!z=N&es{9wCB~<)J(a7AfHZd)xWGp6;o>y<_hp$KLEYzp8J) z?&+TC-|yEwGu=JiYgrjq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{j6%$!S2&4SoLk=c04x&RTyyf4EQE?ZWZeaX{`JHTrMt)255C z&$J)Vz9)11n@++xi=BYBf#ctF6ORAa0bc^ysZ!p4_`z{fQqS=m7L3J|aupLM!V)=f z)=m%Xv)ONR%>Rar$9w^sEt}&BoTK9ClFED`#bLz}#ZkpYierlP^@NIxuzej7Q5;oV zq&TKHu2^V(LzXYZKE-DxbJ92n?dnvBAhDW{Ol-TBG3t-E{%ai;d|AWc<>J6&*1+PuHhPTT#f%tU5zk(zld4AEo9;N;k+^R z1^6ww9#9$bDD017&f!+#e}U<8HS>R#P$1D0sI2m7!~M|V9Oi0n>b9rLGd+2tAcFboo1cC5nOUq8-nMOC3Mh6wNU^YRyzUTQQ$%lw6zS zzlJcF6AH;AS+6VJZF69s;wv`$MM)0WacqOMk83Va@m$3@inA1}^H8Vuc|OIK<^ub; zm8&>MahBqMV!vXaVp-MJw-vMjcZ%ITv)ec{jH!L6MVi%2DE6JoPF;~zP)I{c?>n{k zo5r2}rrC1l5-s26Py&ZlTrvDA^TFAY!-^w{ql(cCWjdOnWIWU)mntW$jz<(%+I~}e zW)>c>%N5D@ox)XD=r2AmIPl5`^z$NQjEvp>yzoPBioQEE`@{0ErP&v;VFde diff --git a/reactos/dll/win32/riched20/para.c b/reactos/dll/win32/riched20/para.c index 6c023f2d96d..f2a70e5746b 100644 --- a/reactos/dll/win32/riched20/para.c +++ b/reactos/dll/win32/riched20/para.c @@ -863,10 +863,22 @@ void ME_GetSelectionParaFormat(ME_TextEditor *editor, PARAFORMAT2 *pFmt) void ME_SetDefaultParaFormat(ME_TextEditor *editor, PARAFORMAT2 *pFmt) { + const PARAFORMAT2 *host_fmt; + HRESULT hr; + ZeroMemory(pFmt, sizeof(PARAFORMAT2)); pFmt->cbSize = sizeof(PARAFORMAT2); pFmt->dwMask = PFM_ALL2; - pFmt->wAlignment = editor->alignStyle; + pFmt->wAlignment = PFA_LEFT; pFmt->sStyle = -1; pFmt->bOutlineLevel = TRUE; + + hr = ITextHost_TxGetParaFormat( editor->texthost, (const PARAFORMAT **)&host_fmt ); + if (SUCCEEDED(hr)) + { + /* Just use the alignment for now */ + if (host_fmt->dwMask & PFM_ALIGNMENT) + pFmt->wAlignment = host_fmt->wAlignment; + ITextHost_OnTxParaFormatChange( editor->texthost, (PARAFORMAT *)pFmt ); + } } diff --git a/reactos/dll/win32/riched20/reader.c b/reactos/dll/win32/riched20/reader.c index db45c9e8677..57d7d2329f6 100644 --- a/reactos/dll/win32/riched20/reader.c +++ b/reactos/dll/win32/riched20/reader.c @@ -1366,7 +1366,7 @@ static RTFKey rtfKey[] = { rtfCharAttr, rtfSuperScrShrink, "super", 0 }, { rtfCharAttr, rtfInvisible, "v", 0 }, { rtfCharAttr, rtfForeColor, "cf", 0 }, - { rtfCharAttr, rtfBackColor, "cb", 0 }, + { rtfCharAttr, rtfBackColor, "highlight", 0 }, { rtfCharAttr, rtfRTLChar, "rtlch", 0 }, { rtfCharAttr, rtfLTRChar, "ltrch", 0 }, { rtfCharAttr, rtfCharStyleNum, "cs", 0 }, diff --git a/reactos/dll/win32/riched20/richole.c b/reactos/dll/win32/riched20/richole.c index 050b33cdc7d..2507b773448 100644 --- a/reactos/dll/win32/riched20/richole.c +++ b/reactos/dll/win32/riched20/richole.c @@ -244,7 +244,6 @@ typedef struct ITextParaImpl { struct IOleClientSiteImpl { struct reole_child child; IOleClientSite IOleClientSite_iface; - IOleWindow IOleWindow_iface; IOleInPlaceSite IOleInPlaceSite_iface; LONG ref; }; @@ -264,11 +263,6 @@ static inline IRichEditOleImpl *impl_from_IUnknown(IUnknown *iface) return CONTAINING_RECORD(iface, IRichEditOleImpl, IUnknown_inner); } -static inline IOleClientSiteImpl *impl_from_IOleWindow(IOleWindow *iface) -{ - return CONTAINING_RECORD(iface, IOleClientSiteImpl, IOleWindow_iface); -} - static inline IOleClientSiteImpl *impl_from_IOleInPlaceSite(IOleInPlaceSite *iface) { return CONTAINING_RECORD(iface, IOleClientSiteImpl, IOleInPlaceSite_iface); @@ -1062,9 +1056,8 @@ IOleClientSite_fnQueryInterface(IOleClientSite *me, REFIID riid, LPVOID *ppvObj) if (IsEqualGUID(riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_IOleClientSite)) *ppvObj = me; - else if (IsEqualGUID(riid, &IID_IOleWindow)) - *ppvObj = &This->IOleWindow_iface; - else if (IsEqualGUID(riid, &IID_IOleInPlaceSite)) + else if (IsEqualGUID(riid, &IID_IOleWindow) || + IsEqualGUID(riid, &IID_IOleInPlaceSite)) *ppvObj = &This->IOleInPlaceSite_iface; if (*ppvObj) { @@ -1175,56 +1168,6 @@ static const IOleClientSiteVtbl ocst = { IOleClientSite_fnRequestNewObjectLayout }; -/* IOleWindow interface */ -static HRESULT WINAPI IOleWindow_fnQueryInterface(IOleWindow *iface, REFIID riid, void **ppvObj) -{ - IOleClientSiteImpl *This = impl_from_IOleWindow(iface); - return IOleClientSite_QueryInterface(&This->IOleClientSite_iface, riid, ppvObj); -} - -static ULONG WINAPI IOleWindow_fnAddRef(IOleWindow *iface) -{ - IOleClientSiteImpl *This = impl_from_IOleWindow(iface); - return IOleClientSite_AddRef(&This->IOleClientSite_iface); -} - -static ULONG WINAPI IOleWindow_fnRelease(IOleWindow *iface) -{ - IOleClientSiteImpl *This = impl_from_IOleWindow(iface); - return IOleClientSite_Release(&This->IOleClientSite_iface); -} - -static HRESULT WINAPI IOleWindow_fnContextSensitiveHelp(IOleWindow *iface, BOOL fEnterMode) -{ - IOleClientSiteImpl *This = impl_from_IOleWindow(iface); - FIXME("not implemented: (%p)->(%d)\n", This, fEnterMode); - return E_NOTIMPL; -} - -static HRESULT WINAPI IOleWindow_fnGetWindow(IOleWindow *iface, HWND *phwnd) -{ - IOleClientSiteImpl *This = impl_from_IOleWindow(iface); - - TRACE("(%p)->(%p)\n", This, phwnd); - - if (!This->child.reole) - return CO_E_RELEASED; - - if (!phwnd) - return E_INVALIDARG; - - *phwnd = This->child.reole->editor->hWnd; - return S_OK; -} - -static const IOleWindowVtbl olewinvt = { - IOleWindow_fnQueryInterface, - IOleWindow_fnAddRef, - IOleWindow_fnRelease, - IOleWindow_fnGetWindow, - IOleWindow_fnContextSensitiveHelp -}; - /* IOleInPlaceSite interface */ static HRESULT STDMETHODCALLTYPE IOleInPlaceSite_fnQueryInterface(IOleInPlaceSite *iface, REFIID riid, void **ppvObj) { @@ -1247,13 +1190,24 @@ static ULONG STDMETHODCALLTYPE IOleInPlaceSite_fnRelease(IOleInPlaceSite *iface) static HRESULT STDMETHODCALLTYPE IOleInPlaceSite_fnGetWindow(IOleInPlaceSite *iface, HWND *phwnd) { IOleClientSiteImpl *This = impl_from_IOleInPlaceSite(iface); - return IOleWindow_GetWindow(&This->IOleWindow_iface, phwnd); + + TRACE("(%p)->(%p)\n", This, phwnd); + + if (!This->child.reole) + return CO_E_RELEASED; + + if (!phwnd) + return E_INVALIDARG; + + *phwnd = This->child.reole->editor->hWnd; + return S_OK; } static HRESULT STDMETHODCALLTYPE IOleInPlaceSite_fnContextSensitiveHelp(IOleInPlaceSite *iface, BOOL fEnterMode) { IOleClientSiteImpl *This = impl_from_IOleInPlaceSite(iface); - return IOleWindow_ContextSensitiveHelp(&This->IOleWindow_iface, fEnterMode); + FIXME("not implemented: (%p)->(%d)\n", This, fEnterMode); + return E_NOTIMPL; } static HRESULT STDMETHODCALLTYPE IOleInPlaceSite_fnCanInPlaceActivate(IOleInPlaceSite *iface) @@ -1355,7 +1309,6 @@ static HRESULT CreateOleClientSite(IRichEditOleImpl *reOle, IOleClientSite **ret return E_OUTOFMEMORY; clientSite->IOleClientSite_iface.lpVtbl = &ocst; - clientSite->IOleWindow_iface.lpVtbl = &olewinvt; clientSite->IOleInPlaceSite_iface.lpVtbl = &olestvt; clientSite->ref = 1; clientSite->child.reole = reOle; diff --git a/reactos/dll/win32/riched20/rtf.h b/reactos/dll/win32/riched20/rtf.h index 0aa1ca7a428..b05c2adfa22 100644 --- a/reactos/dll/win32/riched20/rtf.h +++ b/reactos/dll/win32/riched20/rtf.h @@ -1165,7 +1165,6 @@ struct _RTF_Info { RTFState stack[maxStack]; int stackTop; BOOL styleChanged; - LPRICHEDITOLE lpRichEditOle; RTFTable *tableDef; int nestingLevel; diff --git a/reactos/dll/win32/riched20/txthost.c b/reactos/dll/win32/riched20/txthost.c index 112295ad963..f926964719a 100644 --- a/reactos/dll/win32/riched20/txthost.c +++ b/reactos/dll/win32/riched20/txthost.c @@ -27,6 +27,7 @@ typedef struct ITextHostImpl { LONG ref; HWND hWnd; BOOL bEmulateVersion10; + PARAFORMAT2 para_fmt; } ITextHostImpl; static const ITextHostVtbl textHostVtbl; @@ -34,23 +35,22 @@ static const ITextHostVtbl textHostVtbl; ITextHost *ME_CreateTextHost(HWND hwnd, CREATESTRUCTW *cs, BOOL bEmulateVersion10) { ITextHostImpl *texthost; + texthost = CoTaskMemAlloc(sizeof(*texthost)); - if (texthost) - { - ME_TextEditor *editor; + if (!texthost) return NULL; - texthost->ITextHost_iface.lpVtbl = &textHostVtbl; - texthost->ref = 1; - texthost->hWnd = hwnd; - texthost->bEmulateVersion10 = bEmulateVersion10; - - editor = ME_MakeEditor(&texthost->ITextHost_iface, bEmulateVersion10, cs->style); - editor->exStyleFlags = GetWindowLongW(hwnd, GWL_EXSTYLE); - editor->styleFlags |= GetWindowLongW(hwnd, GWL_STYLE) & ES_WANTRETURN; - editor->hWnd = hwnd; /* FIXME: Remove editor's dependence on hWnd */ - editor->hwndParent = cs->hwndParent; - SetWindowLongPtrW(hwnd, 0, (LONG_PTR)editor); - } + texthost->ITextHost_iface.lpVtbl = &textHostVtbl; + texthost->ref = 1; + texthost->hWnd = hwnd; + texthost->bEmulateVersion10 = bEmulateVersion10; + memset( &texthost->para_fmt, 0, sizeof(texthost->para_fmt) ); + texthost->para_fmt.cbSize = sizeof(texthost->para_fmt); + texthost->para_fmt.dwMask = PFM_ALIGNMENT; + texthost->para_fmt.wAlignment = PFA_LEFT; + if (cs->style & ES_RIGHT) + texthost->para_fmt.wAlignment = PFA_RIGHT; + if (cs->style & ES_CENTER) + texthost->para_fmt.wAlignment = PFA_CENTER; return &texthost->ITextHost_iface; } @@ -258,9 +258,11 @@ DECLSPEC_HIDDEN HRESULT WINAPI ITextHostImpl_TxGetCharFormat(ITextHost *iface, } DECLSPEC_HIDDEN HRESULT WINAPI ITextHostImpl_TxGetParaFormat(ITextHost *iface, - const PARAFORMAT **ppPF) + const PARAFORMAT **fmt) { - return E_NOTIMPL; + ITextHostImpl *This = impl_from_ITextHost(iface); + *fmt = (const PARAFORMAT *)&This->para_fmt; + return S_OK; } DECLSPEC_HIDDEN COLORREF WINAPI ITextHostImpl_TxGetSysColor(ITextHost *iface, diff --git a/reactos/dll/win32/riched20/txtsrv.c b/reactos/dll/win32/riched20/txtsrv.c index 8e0ef388297..869534baecb 100644 --- a/reactos/dll/win32/riched20/txtsrv.c +++ b/reactos/dll/win32/riched20/txtsrv.c @@ -401,9 +401,7 @@ HRESULT WINAPI CreateTextServices(IUnknown *pUnkOuter, ITextHost *pITextHost, I ITextImpl->pMyHost = pITextHost; ITextImpl->IUnknown_inner.lpVtbl = &textservices_inner_vtbl; ITextImpl->ITextServices_iface.lpVtbl = &textservices_vtbl; - ITextImpl->editor = ME_MakeEditor(pITextHost, FALSE, ES_LEFT); - ITextImpl->editor->exStyleFlags = 0; - SetRectEmpty(&ITextImpl->editor->rcFormat); + ITextImpl->editor = ME_MakeEditor(pITextHost, FALSE); if (pUnkOuter) ITextImpl->outer_unk = pUnkOuter; diff --git a/reactos/dll/win32/riched20/writer.c b/reactos/dll/win32/riched20/writer.c index 607ef6d8289..3a646b9a241 100644 --- a/reactos/dll/win32/riched20/writer.c +++ b/reactos/dll/win32/riched20/writer.c @@ -770,7 +770,7 @@ ME_StreamOutRTFCharProps(ME_OutStream *pStream, CHARFORMAT2W *fmt) { if (fmt->dwEffects & CFE_AUTOBACKCOLOR) i = 0; else find_color_in_colortbl( pStream, fmt->crBackColor, &i ); - sprintf(props + strlen(props), "\\cb%u", i); + sprintf(props + strlen(props), "\\highlight%u", i); } if ((old_fmt->dwEffects ^ fmt->dwEffects) & CFE_AUTOCOLOR || (!(fmt->dwEffects & CFE_AUTOCOLOR) && old_fmt->crTextColor != fmt->crTextColor)) diff --git a/reactos/media/doc/README.WINE b/reactos/media/doc/README.WINE index b1543d64cbb..f768530c518 100644 --- a/reactos/media/doc/README.WINE +++ b/reactos/media/doc/README.WINE @@ -158,7 +158,7 @@ reactos/dll/win32/qmgrprxy # Synced to WineStaging-2.9 reactos/dll/win32/query # Synced to WineStaging-2.9 reactos/dll/win32/rasapi32 # Synced to WineStaging-2.9 reactos/dll/win32/resutils # Synced to WineStaging-2.9 -reactos/dll/win32/riched20 # Synced to WineStaging-2.9 +reactos/dll/win32/riched20 # Synced to WineStaging-2.16 reactos/dll/win32/riched32 # Synced to WineStaging-2.9 reactos/dll/win32/rpcrt4 # Synced to WineStaging-2.9 reactos/dll/win32/rsabase # Synced to WineStaging-2.9