diff --git a/dll/win32/riched20/CMakeLists.txt b/dll/win32/riched20/CMakeLists.txt index 002fc5ad9b7..a135a70b2a8 100644 --- a/dll/win32/riched20/CMakeLists.txt +++ b/dll/win32/riched20/CMakeLists.txt @@ -21,7 +21,7 @@ list(APPEND SOURCE undo.c wrap.c writer.c - editor.h) + precomp.h) if(MSVC) if(ARCH STREQUAL "i386") @@ -49,5 +49,5 @@ add_dependencies(riched20 stdole2) set_module_type(riched20 win32dll) target_link_libraries(riched20 wine uuid) add_importlibs(riched20 ole32 oleaut32 usp10 imm32 user32 gdi32 msvcrt kernel32 ntdll) -add_pch(riched20 editor.h SOURCE) +add_pch(riched20 precomp.h SOURCE) add_cd_file(TARGET riched20 DESTINATION reactos/system32 FOR all) diff --git a/dll/win32/riched20/caret.c b/dll/win32/riched20/caret.c index 8a99394dcb6..d676a1bc38b 100644 --- a/dll/win32/riched20/caret.c +++ b/dll/win32/riched20/caret.c @@ -484,7 +484,7 @@ void ME_InsertOLEFromCursor(ME_TextEditor *editor, const REOBJECT* reo, int nCur di = ME_InternalInsertTextFromCursor(editor, nCursor, &space, 1, pStyle, MERF_GRAPHICS); - di->member.run.ole_obj = ALLOC_OBJ(*reo); + di->member.run.ole_obj = heap_alloc(sizeof(*reo)); ME_CopyReObject(di->member.run.ole_obj, reo); ME_ReleaseStyle(pStyle); } diff --git a/dll/win32/riched20/clipboard.c b/dll/win32/riched20/clipboard.c index 53287305613..578fb02fd99 100644 --- a/dll/win32/riched20/clipboard.c +++ b/dll/win32/riched20/clipboard.c @@ -18,6 +18,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#define NONAMELESSUNION + #include "editor.h" WINE_DEFAULT_DEBUG_CHANNEL(richedit); diff --git a/dll/win32/riched20/editor.c b/dll/win32/riched20/editor.c index 20ffb0cdc18..c0843dd4e5c 100644 --- a/dll/win32/riched20/editor.c +++ b/dll/win32/riched20/editor.c @@ -224,14 +224,21 @@ * */ +#define NONAMELESSUNION + #include "editor.h" - -#include -#include - +#include "commdlg.h" +#include "winreg.h" +#define NO_SHLWAPI_STREAM +#include "shlwapi.h" #include "rtf.h" +#include "imm.h" #include "res.h" +#ifdef __REACTOS__ +#include +#endif + #define STACK_SIZE_DEFAULT 100 #define STACK_SIZE_MAX 1000 @@ -258,9 +265,7 @@ static inline BOOL is_version_nt(void) } static ME_TextBuffer *ME_MakeText(void) { - - ME_TextBuffer *buf = ALLOC_OBJ(ME_TextBuffer); - + ME_TextBuffer *buf = heap_alloc(sizeof(*buf)); ME_DisplayItem *p1 = ME_MakeDI(diTextStart); ME_DisplayItem *p2 = ME_MakeDI(diTextEnd); @@ -603,8 +608,7 @@ void ME_RTFParAttrHook(RTF_Info *info) if (!info->editor->bEmulateVersion10) /* v4.1 */ { while (info->rtfParam > info->nestingLevel) { - RTFTable *tableDef = ALLOC_OBJ(RTFTable); - ZeroMemory(tableDef, sizeof(RTFTable)); + RTFTable *tableDef = heap_alloc_zero(sizeof(*tableDef)); tableDef->parent = info->tableDef; info->tableDef = tableDef; @@ -638,10 +642,7 @@ void ME_RTFParAttrHook(RTF_Info *info) { RTFTable *tableDef; if (!info->tableDef) - { - info->tableDef = ALLOC_OBJ(RTFTable); - ZeroMemory(info->tableDef, sizeof(RTFTable)); - } + info->tableDef = heap_alloc_zero(sizeof(*info->tableDef)); tableDef = info->tableDef; RTFFlushOutputBuffer(info); if (tableDef->tableRowStart && @@ -2139,12 +2140,12 @@ static int ME_GetTextRange(ME_TextEditor *editor, WCHAR *strText, return ME_GetTextW(editor, strText, INT_MAX, start, nLen, FALSE, FALSE); } else { int nChars; - WCHAR *p = ALLOC_N_OBJ(WCHAR, nLen+1); + WCHAR *p = heap_alloc((nLen+1) * sizeof(*p)); if (!p) return 0; nChars = ME_GetTextW(editor, p, nLen, start, nLen, FALSE, FALSE); WideCharToMultiByte(CP_ACP, 0, p, nChars+1, (char *)strText, nLen+1, NULL, NULL); - FREE_OBJ(p); + heap_free(p); return nChars; } } @@ -2990,7 +2991,7 @@ static BOOL ME_ShowContextMenu(ME_TextEditor *editor, int x, int y) ME_TextEditor *ME_MakeEditor(ITextHost *texthost, BOOL bEmulateVersion10) { - ME_TextEditor *ed = ALLOC_OBJ(ME_TextEditor); + ME_TextEditor *ed = heap_alloc(sizeof(*ed)); int i; DWORD props; LONG selbarwidth; @@ -3024,7 +3025,7 @@ ME_TextEditor *ME_MakeEditor(ITextHost *texthost, BOOL bEmulateVersion10) * or paragraph selection. */ ed->nCursors = 4; - ed->pCursors = ALLOC_N_OBJ(ME_Cursor, ed->nCursors); + ed->pCursors = heap_alloc(ed->nCursors * sizeof(*ed->pCursors)); ME_SetCursorToStart(ed, &ed->pCursors[0]); ed->pCursors[1] = ed->pCursors[0]; ed->pCursors[2] = ed->pCursors[0]; @@ -3157,10 +3158,9 @@ void ME_DestroyEditor(ME_TextEditor *editor) } OleUninitialize(); - FREE_OBJ(editor->pBuffer); - FREE_OBJ(editor->pCursors); - - FREE_OBJ(editor); + heap_free(editor->pBuffer); + heap_free(editor->pCursors); + heap_free(editor); } BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) @@ -4299,10 +4299,10 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam, int nChars = MultiByteToWideChar(CP_ACP, 0, ft->lpstrText, -1, NULL, 0); WCHAR *tmp; - if ((tmp = ALLOC_N_OBJ(WCHAR, nChars)) != NULL) + if ((tmp = heap_alloc(nChars * sizeof(*tmp))) != NULL) MultiByteToWideChar(CP_ACP, 0, ft->lpstrText, -1, tmp, nChars); r = ME_FindText(editor, wParam, &ft->chrg, tmp, NULL); - FREE_OBJ( tmp ); + heap_free(tmp); }else{ FINDTEXTW *ft = (FINDTEXTW *)lParam; r = ME_FindText(editor, wParam, &ft->chrg, ft->lpstrText, NULL); @@ -4317,10 +4317,10 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam, int nChars = MultiByteToWideChar(CP_ACP, 0, ex->lpstrText, -1, NULL, 0); WCHAR *tmp; - if ((tmp = ALLOC_N_OBJ(WCHAR, nChars)) != NULL) + if ((tmp = heap_alloc(nChars * sizeof(*tmp))) != NULL) MultiByteToWideChar(CP_ACP, 0, ex->lpstrText, -1, tmp, nChars); r = ME_FindText(editor, wParam, &ex->chrg, tmp, &ex->chrgText); - FREE_OBJ( tmp ); + heap_free(tmp); }else{ FINDTEXTEXW *ex = (FINDTEXTEXW *)lParam; r = ME_FindText(editor, wParam, &ex->chrg, ex->lpstrText, &ex->chrgText); diff --git a/dll/win32/riched20/editor.h b/dll/win32/riched20/editor.h index 8da0ed94d71..a4f53138f88 100644 --- a/dll/win32/riched20/editor.h +++ b/dll/win32/riched20/editor.h @@ -18,67 +18,15 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#ifndef _RICHED20_EDITOR_H -#define _RICHED20_EDITOR_H - -#include - -#include -#include - -#ifndef _WIN32_IE -#define _WIN32_IE 0x0400 -#endif - -#define WIN32_NO_STATUS -#define _INC_WINDOWS -#define COM_NO_WINDOWS_H - -#define COBJMACROS -#define NONAMELESSUNION -#define NONAMELESSSTRUCT - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include +#pragma once #include "editstr.h" +#include "wine/unicode.h" struct _RTF_Info; extern HANDLE me_heap DECLSPEC_HIDDEN; -static inline void * __WINE_ALLOC_SIZE(1) heap_alloc( size_t len ) -{ - return HeapAlloc( me_heap, 0, len ); -} - -static inline BOOL heap_free( void *ptr ) -{ - return HeapFree( me_heap, 0, ptr ); -} - -static inline void * __WINE_ALLOC_SIZE(2) heap_realloc( void *ptr, size_t len ) -{ - return HeapReAlloc( me_heap, 0, ptr, len ); -} - -#define ALLOC_OBJ(type) heap_alloc(sizeof(type)) -#define ALLOC_N_OBJ(type, count) heap_alloc((count)*sizeof(type)) -#define FREE_OBJ(ptr) heap_free(ptr) - #define RUN_IS_HIDDEN(run) ((run)->style->fmt.dwMask & CFM_HIDDEN \ && (run)->style->fmt.dwEffects & CFE_HIDDEN) @@ -393,5 +341,3 @@ LRESULT ME_StreamOut(ME_TextEditor *editor, DWORD dwFormat, EDITSTREAM *stream) HRESULT ME_GetDataObject(ME_TextEditor *editor, const ME_Cursor *start, int nChars, LPDATAOBJECT *lplpdataobj) DECLSPEC_HIDDEN; void release_typelib(void) DECLSPEC_HIDDEN; - -#endif /* _RICHED20_EDITOR_H */ diff --git a/dll/win32/riched20/editstr.h b/dll/win32/riched20/editstr.h index ac7ca31607e..a37c4de46e9 100644 --- a/dll/win32/riched20/editstr.h +++ b/dll/win32/riched20/editstr.h @@ -21,6 +21,36 @@ #ifndef __EDITSTR_H #define __EDITSTR_H +#ifndef _WIN32_IE +#define _WIN32_IE 0x0400 +#endif + +#include +#include +#include +#include +#include + +#define COBJMACROS + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "imm.h" +#include +#include "usp10.h" + +#include "wine/debug.h" +#include "wine/heap.h" +#include "wine/list.h" + #ifdef __i386__ extern const struct ITextHostVtbl itextHostStdcallVtbl DECLSPEC_HIDDEN; #endif /* __i386__ */ diff --git a/dll/win32/riched20/list.c b/dll/win32/riched20/list.c index d3214466845..58b64e8081d 100644 --- a/dll/win32/riched20/list.c +++ b/dll/win32/riched20/list.c @@ -174,13 +174,13 @@ void ME_DestroyDisplayItem(ME_DisplayItem *item) heap_free( item->member.run.clusters ); ME_ReleaseStyle(item->member.run.style); } - FREE_OBJ(item); + heap_free(item); } ME_DisplayItem *ME_MakeDI(ME_DIType type) { - ME_DisplayItem *item = ALLOC_OBJ(ME_DisplayItem); - ZeroMemory(item, sizeof(ME_DisplayItem)); + ME_DisplayItem *item = heap_alloc_zero(sizeof(*item)); + item->type = type; item->prev = item->next = NULL; return item; diff --git a/dll/win32/riched20/paint.c b/dll/win32/riched20/paint.c index b4b66971656..fcc4e105a33 100644 --- a/dll/win32/riched20/paint.c +++ b/dll/win32/riched20/paint.c @@ -216,9 +216,11 @@ static COLORREF get_back_color( ME_Context *c, ME_Style *style, BOOL highlight ) return color; } -static void get_underline_pen( ME_Style *style, COLORREF color, HPEN *pen ) +static HPEN get_underline_pen( ME_Style *style, COLORREF color ) { - *pen = NULL; + if (style->fmt.dwEffects & CFE_LINK) + return CreatePen( PS_SOLID, 1, color ); + /* Choose the pen type for underlining the text. */ if (style->fmt.dwEffects & CFE_UNDERLINE) { @@ -227,11 +229,9 @@ static void get_underline_pen( ME_Style *style, COLORREF color, HPEN *pen ) case CFU_UNDERLINE: case CFU_UNDERLINEWORD: /* native seems to map it to simple underline (MSDN) */ case CFU_UNDERLINEDOUBLE: /* native seems to map it to simple underline (MSDN) */ - *pen = CreatePen( PS_SOLID, 1, color ); - break; + return CreatePen( PS_SOLID, 1, color ); case CFU_UNDERLINEDOTTED: - *pen = CreatePen( PS_DOT, 1, color ); - break; + return CreatePen( PS_DOT, 1, color ); default: FIXME( "Unknown underline type (%u)\n", style->fmt.bUnderlineType ); /* fall through */ @@ -240,14 +240,14 @@ static void get_underline_pen( ME_Style *style, COLORREF color, HPEN *pen ) break; } } - return; + return NULL; } static void draw_underline( ME_Context *c, ME_Run *run, int x, int y, COLORREF color ) { HPEN pen; - get_underline_pen( run->style, color, &pen ); + pen = get_underline_pen( run->style, color ); if (pen) { HPEN old_pen = SelectObject( c->hDC, pen ); diff --git a/dll/win32/riched20/precomp.h b/dll/win32/riched20/precomp.h new file mode 100644 index 00000000000..b492ada0979 --- /dev/null +++ b/dll/win32/riched20/precomp.h @@ -0,0 +1,18 @@ + +#ifndef _RICHED20_PRECOMP_H +#define _RICHED20_PRECOMP_H + +#include + +#define WIN32_NO_STATUS +#define _INC_WINDOWS +#define COM_NO_WINDOWS_H + +#define NONAMELESSUNION +#define NONAMELESSSTRUCT + +#include "editor.h" + +#include + +#endif /* !_RICHED20_PRECOMP_H */ diff --git a/dll/win32/riched20/reader.c b/dll/win32/riched20/reader.c index 57d7d2329f6..03101090b3e 100644 --- a/dll/win32/riched20/reader.c +++ b/dll/win32/riched20/reader.c @@ -36,6 +36,17 @@ * any purpose whatsoever. */ +#include +#include +#include +#include +#include +#include + +#include "windef.h" +#include "winbase.h" +#include "wine/debug.h" + #include "editor.h" #include "rtf.h" diff --git a/dll/win32/riched20/richole.c b/dll/win32/riched20/richole.c index b04b6b10a30..170c426e8a2 100644 --- a/dll/win32/riched20/richole.c +++ b/dll/win32/riched20/richole.c @@ -19,13 +19,27 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include + +#define NONAMELESSUNION +#define COBJMACROS + +#include "windef.h" +#include "winbase.h" +#include "wingdi.h" +#include "winuser.h" +#include "ole2.h" +#include "richole.h" #include "editor.h" +#include "richedit.h" +#include "tom.h" +#include "wine/debug.h" WINE_DEFAULT_DEBUG_CHANNEL(richedit); /* there is no way to be consistent across different sets of headers - mingw, Wine, Win32 SDK*/ -#include +#include "initguid.h" DEFINE_GUID(LIBID_tom, 0x8cc497c9, 0xa1df, 0x11ce, 0x80, 0x98, 0x00, 0xaa, 0x00, 0x47, 0xbe, 0x5d); DEFINE_GUID(IID_ITextServices, 0x8d33f740, 0xcf58, 0x11ce, 0xa8, 0x9d, 0x00, 0xaa, 0x00, 0x6c, 0xad, 0xc5); @@ -936,6 +950,14 @@ static HRESULT WINAPI IRichEditOleImpl_inner_fnQueryInterface(IUnknown *iface, R IUnknown_AddRef((IUnknown *)*ppvObj); return S_OK; } + + if (IsEqualGUID(riid, &IID_ITextServices)) + { + static int once; + if (!once++) FIXME("%p: unhandled interface IID_ITextServices\n", This); + return E_NOINTERFACE; + } + FIXME("%p: unhandled interface %s\n", This, debugstr_guid(riid)); return E_NOINTERFACE; @@ -1971,6 +1993,23 @@ static HRESULT WINAPI ITextRange_fnSetIndex(ITextRange *me, LONG unit, LONG inde return E_NOTIMPL; } +static void cp2range(ME_TextEditor *editor, LONG *cp1, LONG *cp2) +{ + int len = ME_GetTextLength(editor) + 1; + *cp1 = max(*cp1, 0); + *cp2 = max(*cp2, 0); + *cp1 = min(*cp1, len); + *cp2 = min(*cp2, len); + if (*cp1 > *cp2) + { + int tmp = *cp1; + *cp1 = *cp2; + *cp2 = tmp; + } + if (*cp1 == len) + *cp1 = *cp2 = len - 1; +} + static HRESULT WINAPI ITextRange_fnSetRange(ITextRange *me, LONG anchor, LONG active) { ITextRangeImpl *This = impl_from_ITextRange(me); @@ -1980,7 +2019,13 @@ static HRESULT WINAPI ITextRange_fnSetRange(ITextRange *me, LONG anchor, LONG ac if (!This->child.reole) return CO_E_RELEASED; - return E_NOTIMPL; + cp2range(This->child.reole->editor, &anchor, &active); + if (anchor == This->start && active == This->end) + return S_FALSE; + + This->start = anchor; + This->end = active; + return S_OK; } static HRESULT textrange_inrange(LONG start, LONG end, ITextRange *range, LONG *ret) @@ -2593,6 +2638,10 @@ static HRESULT WINAPI TextFont_SetDuplicate(ITextFont *iface, ITextFont *pFont) { ITextFontImpl *This = impl_from_ITextFont(iface); FIXME("(%p)->(%p): stub\n", This, pFont); + + if (This->range && !get_range_reole(This->range)) + return CO_E_RELEASED; + return E_NOTIMPL; } @@ -2600,6 +2649,10 @@ static HRESULT WINAPI TextFont_CanChange(ITextFont *iface, LONG *ret) { ITextFontImpl *This = impl_from_ITextFont(iface); FIXME("(%p)->(%p): stub\n", This, ret); + + if (This->range && !get_range_reole(This->range)) + return CO_E_RELEASED; + return E_NOTIMPL; } @@ -2607,6 +2660,10 @@ static HRESULT WINAPI TextFont_IsEqual(ITextFont *iface, ITextFont *font, LONG * { ITextFontImpl *This = impl_from_ITextFont(iface); FIXME("(%p)->(%p %p): stub\n", This, font, ret); + + if (This->range && !get_range_reole(This->range)) + return CO_E_RELEASED; + return E_NOTIMPL; } @@ -2780,6 +2837,10 @@ static HRESULT WINAPI TextFont_GetStyle(ITextFont *iface, LONG *value) { ITextFontImpl *This = impl_from_ITextFont(iface); FIXME("(%p)->(%p): stub\n", This, value); + + if (This->range && !get_range_reole(This->range)) + return CO_E_RELEASED; + return E_NOTIMPL; } @@ -2787,6 +2848,10 @@ static HRESULT WINAPI TextFont_SetStyle(ITextFont *iface, LONG value) { ITextFontImpl *This = impl_from_ITextFont(iface); FIXME("(%p)->(%d): stub\n", This, value); + + if (This->range && !get_range_reole(This->range)) + return CO_E_RELEASED; + return E_NOTIMPL; } @@ -3293,6 +3358,16 @@ static ULONG WINAPI TextPara_Release(ITextPara *iface) return ref; } +static IRichEditOleImpl *para_get_reole(ITextParaImpl *This) +{ + if (This->range) + { + ITextRangeImpl *rng = impl_from_ITextRange(This->range); + return rng->child.reole; + } + return NULL; +} + static HRESULT WINAPI TextPara_GetTypeInfoCount(ITextPara *iface, UINT *pctinfo) { ITextParaImpl *This = impl_from_ITextPara(iface); @@ -3360,6 +3435,10 @@ static HRESULT WINAPI TextPara_GetDuplicate(ITextPara *iface, ITextPara **ret) { ITextParaImpl *This = impl_from_ITextPara(iface); FIXME("(%p)->(%p)\n", This, ret); + + if (!para_get_reole(This)) + return CO_E_RELEASED; + return E_NOTIMPL; } @@ -3367,6 +3446,10 @@ static HRESULT WINAPI TextPara_SetDuplicate(ITextPara *iface, ITextPara *para) { ITextParaImpl *This = impl_from_ITextPara(iface); FIXME("(%p)->(%p)\n", This, para); + + if (!para_get_reole(This)) + return CO_E_RELEASED; + return E_NOTIMPL; } @@ -3374,6 +3457,10 @@ static HRESULT WINAPI TextPara_CanChange(ITextPara *iface, LONG *ret) { ITextParaImpl *This = impl_from_ITextPara(iface); FIXME("(%p)->(%p)\n", This, ret); + + if (!para_get_reole(This)) + return CO_E_RELEASED; + return E_NOTIMPL; } @@ -3381,6 +3468,10 @@ static HRESULT WINAPI TextPara_IsEqual(ITextPara *iface, ITextPara *para, LONG * { ITextParaImpl *This = impl_from_ITextPara(iface); FIXME("(%p)->(%p %p)\n", This, para, ret); + + if (!para_get_reole(This)) + return CO_E_RELEASED; + return E_NOTIMPL; } @@ -3388,6 +3479,10 @@ static HRESULT WINAPI TextPara_Reset(ITextPara *iface, LONG value) { ITextParaImpl *This = impl_from_ITextPara(iface); FIXME("(%p)->(%d)\n", This, value); + + if (!para_get_reole(This)) + return CO_E_RELEASED; + return E_NOTIMPL; } @@ -3395,6 +3490,10 @@ static HRESULT WINAPI TextPara_GetStyle(ITextPara *iface, LONG *value) { ITextParaImpl *This = impl_from_ITextPara(iface); FIXME("(%p)->(%p)\n", This, value); + + if (!para_get_reole(This)) + return CO_E_RELEASED; + return E_NOTIMPL; } @@ -3402,13 +3501,23 @@ static HRESULT WINAPI TextPara_SetStyle(ITextPara *iface, LONG value) { ITextParaImpl *This = impl_from_ITextPara(iface); FIXME("(%p)->(%d)\n", This, value); + + if (!para_get_reole(This)) + return CO_E_RELEASED; + return E_NOTIMPL; } static HRESULT WINAPI TextPara_GetAlignment(ITextPara *iface, LONG *value) { ITextParaImpl *This = impl_from_ITextPara(iface); - FIXME("(%p)->(%p)\n", This, value); + static int once; + + if (!once++) FIXME("(%p)->(%p)\n", This, value); + + if (!para_get_reole(This)) + return CO_E_RELEASED; + return E_NOTIMPL; } @@ -3416,6 +3525,10 @@ static HRESULT WINAPI TextPara_SetAlignment(ITextPara *iface, LONG value) { ITextParaImpl *This = impl_from_ITextPara(iface); FIXME("(%p)->(%d)\n", This, value); + + if (!para_get_reole(This)) + return CO_E_RELEASED; + return E_NOTIMPL; } @@ -3423,6 +3536,10 @@ static HRESULT WINAPI TextPara_GetHyphenation(ITextPara *iface, LONG *value) { ITextParaImpl *This = impl_from_ITextPara(iface); FIXME("(%p)->(%p)\n", This, value); + + if (!para_get_reole(This)) + return CO_E_RELEASED; + return E_NOTIMPL; } @@ -3430,6 +3547,10 @@ static HRESULT WINAPI TextPara_SetHyphenation(ITextPara *iface, LONG value) { ITextParaImpl *This = impl_from_ITextPara(iface); FIXME("(%p)->(%d)\n", This, value); + + if (!para_get_reole(This)) + return CO_E_RELEASED; + return E_NOTIMPL; } @@ -3437,6 +3558,10 @@ static HRESULT WINAPI TextPara_GetFirstLineIndent(ITextPara *iface, FLOAT *value { ITextParaImpl *This = impl_from_ITextPara(iface); FIXME("(%p)->(%p)\n", This, value); + + if (!para_get_reole(This)) + return CO_E_RELEASED; + return E_NOTIMPL; } @@ -3444,6 +3569,10 @@ static HRESULT WINAPI TextPara_GetKeepTogether(ITextPara *iface, LONG *value) { ITextParaImpl *This = impl_from_ITextPara(iface); FIXME("(%p)->(%p)\n", This, value); + + if (!para_get_reole(This)) + return CO_E_RELEASED; + return E_NOTIMPL; } @@ -3451,6 +3580,10 @@ static HRESULT WINAPI TextPara_SetKeepTogether(ITextPara *iface, LONG value) { ITextParaImpl *This = impl_from_ITextPara(iface); FIXME("(%p)->(%d)\n", This, value); + + if (!para_get_reole(This)) + return CO_E_RELEASED; + return E_NOTIMPL; } @@ -3458,6 +3591,10 @@ static HRESULT WINAPI TextPara_GetKeepWithNext(ITextPara *iface, LONG *value) { ITextParaImpl *This = impl_from_ITextPara(iface); FIXME("(%p)->(%p)\n", This, value); + + if (!para_get_reole(This)) + return CO_E_RELEASED; + return E_NOTIMPL; } @@ -3465,6 +3602,10 @@ static HRESULT WINAPI TextPara_SetKeepWithNext(ITextPara *iface, LONG value) { ITextParaImpl *This = impl_from_ITextPara(iface); FIXME("(%p)->(%d)\n", This, value); + + if (!para_get_reole(This)) + return CO_E_RELEASED; + return E_NOTIMPL; } @@ -3472,6 +3613,10 @@ static HRESULT WINAPI TextPara_GetLeftIndent(ITextPara *iface, FLOAT *value) { ITextParaImpl *This = impl_from_ITextPara(iface); FIXME("(%p)->(%p)\n", This, value); + + if (!para_get_reole(This)) + return CO_E_RELEASED; + return E_NOTIMPL; } @@ -3479,6 +3624,10 @@ static HRESULT WINAPI TextPara_GetLineSpacing(ITextPara *iface, FLOAT *value) { ITextParaImpl *This = impl_from_ITextPara(iface); FIXME("(%p)->(%p)\n", This, value); + + if (!para_get_reole(This)) + return CO_E_RELEASED; + return E_NOTIMPL; } @@ -3486,6 +3635,10 @@ static HRESULT WINAPI TextPara_GetLineSpacingRule(ITextPara *iface, LONG *value) { ITextParaImpl *This = impl_from_ITextPara(iface); FIXME("(%p)->(%p)\n", This, value); + + if (!para_get_reole(This)) + return CO_E_RELEASED; + return E_NOTIMPL; } @@ -3493,6 +3646,10 @@ static HRESULT WINAPI TextPara_GetListAlignment(ITextPara *iface, LONG *value) { ITextParaImpl *This = impl_from_ITextPara(iface); FIXME("(%p)->(%p)\n", This, value); + + if (!para_get_reole(This)) + return CO_E_RELEASED; + return E_NOTIMPL; } @@ -3500,6 +3657,10 @@ static HRESULT WINAPI TextPara_SetListAlignment(ITextPara *iface, LONG value) { ITextParaImpl *This = impl_from_ITextPara(iface); FIXME("(%p)->(%d)\n", This, value); + + if (!para_get_reole(This)) + return CO_E_RELEASED; + return E_NOTIMPL; } @@ -3507,6 +3668,10 @@ static HRESULT WINAPI TextPara_GetListLevelIndex(ITextPara *iface, LONG *value) { ITextParaImpl *This = impl_from_ITextPara(iface); FIXME("(%p)->(%p)\n", This, value); + + if (!para_get_reole(This)) + return CO_E_RELEASED; + return E_NOTIMPL; } @@ -3514,6 +3679,10 @@ static HRESULT WINAPI TextPara_SetListLevelIndex(ITextPara *iface, LONG value) { ITextParaImpl *This = impl_from_ITextPara(iface); FIXME("(%p)->(%d)\n", This, value); + + if (!para_get_reole(This)) + return CO_E_RELEASED; + return E_NOTIMPL; } @@ -3521,6 +3690,10 @@ static HRESULT WINAPI TextPara_GetListStart(ITextPara *iface, LONG *value) { ITextParaImpl *This = impl_from_ITextPara(iface); FIXME("(%p)->(%p)\n", This, value); + + if (!para_get_reole(This)) + return CO_E_RELEASED; + return E_NOTIMPL; } @@ -3528,6 +3701,10 @@ static HRESULT WINAPI TextPara_SetListStart(ITextPara *iface, LONG value) { ITextParaImpl *This = impl_from_ITextPara(iface); FIXME("(%p)->(%d)\n", This, value); + + if (!para_get_reole(This)) + return CO_E_RELEASED; + return E_NOTIMPL; } @@ -3535,6 +3712,10 @@ static HRESULT WINAPI TextPara_GetListTab(ITextPara *iface, FLOAT *value) { ITextParaImpl *This = impl_from_ITextPara(iface); FIXME("(%p)->(%p)\n", This, value); + + if (!para_get_reole(This)) + return CO_E_RELEASED; + return E_NOTIMPL; } @@ -3542,6 +3723,10 @@ static HRESULT WINAPI TextPara_SetListTab(ITextPara *iface, FLOAT value) { ITextParaImpl *This = impl_from_ITextPara(iface); FIXME("(%p)->(%.2f)\n", This, value); + + if (!para_get_reole(This)) + return CO_E_RELEASED; + return E_NOTIMPL; } @@ -3549,6 +3734,10 @@ static HRESULT WINAPI TextPara_GetListType(ITextPara *iface, LONG *value) { ITextParaImpl *This = impl_from_ITextPara(iface); FIXME("(%p)->(%p)\n", This, value); + + if (!para_get_reole(This)) + return CO_E_RELEASED; + return E_NOTIMPL; } @@ -3556,6 +3745,10 @@ static HRESULT WINAPI TextPara_SetListType(ITextPara *iface, LONG value) { ITextParaImpl *This = impl_from_ITextPara(iface); FIXME("(%p)->(%d)\n", This, value); + + if (!para_get_reole(This)) + return CO_E_RELEASED; + return E_NOTIMPL; } @@ -3563,6 +3756,10 @@ static HRESULT WINAPI TextPara_GetNoLineNumber(ITextPara *iface, LONG *value) { ITextParaImpl *This = impl_from_ITextPara(iface); FIXME("(%p)->(%p)\n", This, value); + + if (!para_get_reole(This)) + return CO_E_RELEASED; + return E_NOTIMPL; } @@ -3570,6 +3767,10 @@ static HRESULT WINAPI TextPara_SetNoLineNumber(ITextPara *iface, LONG value) { ITextParaImpl *This = impl_from_ITextPara(iface); FIXME("(%p)->(%d)\n", This, value); + + if (!para_get_reole(This)) + return CO_E_RELEASED; + return E_NOTIMPL; } @@ -3577,6 +3778,10 @@ static HRESULT WINAPI TextPara_GetPageBreakBefore(ITextPara *iface, LONG *value) { ITextParaImpl *This = impl_from_ITextPara(iface); FIXME("(%p)->(%p)\n", This, value); + + if (!para_get_reole(This)) + return CO_E_RELEASED; + return E_NOTIMPL; } @@ -3584,6 +3789,10 @@ static HRESULT WINAPI TextPara_SetPageBreakBefore(ITextPara *iface, LONG value) { ITextParaImpl *This = impl_from_ITextPara(iface); FIXME("(%p)->(%d)\n", This, value); + + if (!para_get_reole(This)) + return CO_E_RELEASED; + return E_NOTIMPL; } @@ -3591,6 +3800,10 @@ static HRESULT WINAPI TextPara_GetRightIndent(ITextPara *iface, FLOAT *value) { ITextParaImpl *This = impl_from_ITextPara(iface); FIXME("(%p)->(%p)\n", This, value); + + if (!para_get_reole(This)) + return CO_E_RELEASED; + return E_NOTIMPL; } @@ -3598,6 +3811,10 @@ static HRESULT WINAPI TextPara_SetRightIndent(ITextPara *iface, FLOAT value) { ITextParaImpl *This = impl_from_ITextPara(iface); FIXME("(%p)->(%.2f)\n", This, value); + + if (!para_get_reole(This)) + return CO_E_RELEASED; + return E_NOTIMPL; } @@ -3605,6 +3822,10 @@ static HRESULT WINAPI TextPara_SetIndents(ITextPara *iface, FLOAT StartIndent, F { ITextParaImpl *This = impl_from_ITextPara(iface); FIXME("(%p)->(%.2f %.2f %.2f)\n", This, StartIndent, LeftIndent, RightIndent); + + if (!para_get_reole(This)) + return CO_E_RELEASED; + return E_NOTIMPL; } @@ -3612,6 +3833,10 @@ static HRESULT WINAPI TextPara_SetLineSpacing(ITextPara *iface, LONG LineSpacing { ITextParaImpl *This = impl_from_ITextPara(iface); FIXME("(%p)->(%d %.2f)\n", This, LineSpacingRule, LineSpacing); + + if (!para_get_reole(This)) + return CO_E_RELEASED; + return E_NOTIMPL; } @@ -3619,6 +3844,10 @@ static HRESULT WINAPI TextPara_GetSpaceAfter(ITextPara *iface, FLOAT *value) { ITextParaImpl *This = impl_from_ITextPara(iface); FIXME("(%p)->(%p)\n", This, value); + + if (!para_get_reole(This)) + return CO_E_RELEASED; + return E_NOTIMPL; } @@ -3626,6 +3855,10 @@ static HRESULT WINAPI TextPara_SetSpaceAfter(ITextPara *iface, FLOAT value) { ITextParaImpl *This = impl_from_ITextPara(iface); FIXME("(%p)->(%.2f)\n", This, value); + + if (!para_get_reole(This)) + return CO_E_RELEASED; + return E_NOTIMPL; } @@ -3633,6 +3866,10 @@ static HRESULT WINAPI TextPara_GetSpaceBefore(ITextPara *iface, FLOAT *value) { ITextParaImpl *This = impl_from_ITextPara(iface); FIXME("(%p)->(%p)\n", This, value); + + if (!para_get_reole(This)) + return CO_E_RELEASED; + return E_NOTIMPL; } @@ -3640,6 +3877,10 @@ static HRESULT WINAPI TextPara_SetSpaceBefore(ITextPara *iface, FLOAT value) { ITextParaImpl *This = impl_from_ITextPara(iface); FIXME("(%p)->(%.2f)\n", This, value); + + if (!para_get_reole(This)) + return CO_E_RELEASED; + return E_NOTIMPL; } @@ -3647,6 +3888,10 @@ static HRESULT WINAPI TextPara_GetWidowControl(ITextPara *iface, LONG *value) { ITextParaImpl *This = impl_from_ITextPara(iface); FIXME("(%p)->(%p)\n", This, value); + + if (!para_get_reole(This)) + return CO_E_RELEASED; + return E_NOTIMPL; } @@ -3654,6 +3899,10 @@ static HRESULT WINAPI TextPara_SetWidowControl(ITextPara *iface, LONG value) { ITextParaImpl *This = impl_from_ITextPara(iface); FIXME("(%p)->(%d)\n", This, value); + + if (!para_get_reole(This)) + return CO_E_RELEASED; + return E_NOTIMPL; } @@ -3661,6 +3910,10 @@ static HRESULT WINAPI TextPara_GetTabCount(ITextPara *iface, LONG *value) { ITextParaImpl *This = impl_from_ITextPara(iface); FIXME("(%p)->(%p)\n", This, value); + + if (!para_get_reole(This)) + return CO_E_RELEASED; + return E_NOTIMPL; } @@ -3668,6 +3921,10 @@ static HRESULT WINAPI TextPara_AddTab(ITextPara *iface, FLOAT tbPos, LONG tbAlig { ITextParaImpl *This = impl_from_ITextPara(iface); FIXME("(%p)->(%.2f %d %d)\n", This, tbPos, tbAlign, tbLeader); + + if (!para_get_reole(This)) + return CO_E_RELEASED; + return E_NOTIMPL; } @@ -3675,6 +3932,10 @@ static HRESULT WINAPI TextPara_ClearAllTabs(ITextPara *iface) { ITextParaImpl *This = impl_from_ITextPara(iface); FIXME("(%p)\n", This); + + if (!para_get_reole(This)) + return CO_E_RELEASED; + return E_NOTIMPL; } @@ -3682,6 +3943,10 @@ static HRESULT WINAPI TextPara_DeleteTab(ITextPara *iface, FLOAT pos) { ITextParaImpl *This = impl_from_ITextPara(iface); FIXME("(%p)->(%.2f)\n", This, pos); + + if (!para_get_reole(This)) + return CO_E_RELEASED; + return E_NOTIMPL; } @@ -3689,6 +3954,10 @@ static HRESULT WINAPI TextPara_GetTab(ITextPara *iface, LONG iTab, FLOAT *ptbPos { ITextParaImpl *This = impl_from_ITextPara(iface); FIXME("(%p)->(%d %p %p %p)\n", This, iTab, ptbPos, ptbAlign, ptbLeader); + + if (!para_get_reole(This)) + return CO_E_RELEASED; + return E_NOTIMPL; } @@ -4027,26 +4296,12 @@ ITextDocument_fnRange(ITextDocument* me, LONG cp1, LONG cp2, ITextRange** ppRange) { IRichEditOleImpl *This = impl_from_ITextDocument(me); - const int len = ME_GetTextLength(This->editor) + 1; TRACE("%p %p %d %d\n", This, ppRange, cp1, cp2); if (!ppRange) return E_INVALIDARG; - cp1 = max(cp1, 0); - cp2 = max(cp2, 0); - cp1 = min(cp1, len); - cp2 = min(cp2, len); - if (cp1 > cp2) - { - LONG tmp; - tmp = cp1; - cp1 = cp2; - cp2 = tmp; - } - if (cp1 == len) - cp1 = cp2 = len - 1; - + cp2range(This->editor, &cp1, &cp2); return CreateITextRange(This, cp1, cp2, ppRange); } @@ -5369,7 +5624,7 @@ void ME_DeleteReObject(REOBJECT* reo) if (reo->poleobj) IOleObject_Release(reo->poleobj); if (reo->pstg) IStorage_Release(reo->pstg); if (reo->polesite) IOleClientSite_Release(reo->polesite); - FREE_OBJ(reo); + heap_free(reo); } void ME_CopyReObject(REOBJECT* dst, const REOBJECT* src) diff --git a/dll/win32/riched20/rtf.h b/dll/win32/riched20/rtf.h index b05c2adfa22..66d88b55da9 100644 --- a/dll/win32/riched20/rtf.h +++ b/dll/win32/riched20/rtf.h @@ -1,6 +1,16 @@ #ifndef _RTF #define _RTF +#include +#include + +#include "windef.h" +#include "winbase.h" +#include "wingdi.h" +#include "winuser.h" +#include "richedit.h" + + /* * rtf.h - RTF document processing stuff. Release 1.10. */ diff --git a/dll/win32/riched20/run.c b/dll/win32/riched20/run.c index 098c4f8b4d0..445bbc2f918 100644 --- a/dll/win32/riched20/run.c +++ b/dll/win32/riched20/run.c @@ -185,9 +185,10 @@ void ME_RunOfsFromCharOfs(ME_TextEditor *editor, int *pOfs) { ME_DisplayItem *item, *next_item; + int endOfs = nCharOfs, len = ME_GetTextLength(editor); nCharOfs = max(nCharOfs, 0); - nCharOfs = min(nCharOfs, ME_GetTextLength(editor)); + nCharOfs = min(nCharOfs, len); /* Find the paragraph at the offset. */ next_item = editor->pBuffer->pFirst->member.para.next_para; @@ -210,7 +211,11 @@ void ME_RunOfsFromCharOfs(ME_TextEditor *editor, nCharOfs -= item->member.run.nCharOfs; if (ppRun) *ppRun = item; - if (pOfs) *pOfs = nCharOfs; + if (pOfs) { + if (((*ppRun)->member.run.nFlags & MERF_ENDPARA) && endOfs > len) + *pOfs = (*ppRun)->member.run.len; + else *pOfs = nCharOfs; + } } /****************************************************************************** diff --git a/dll/win32/riched20/style.c b/dll/win32/riched20/style.c index 4f08b3b1333..0b85d69f6f1 100644 --- a/dll/win32/riched20/style.c +++ b/dll/win32/riched20/style.c @@ -113,7 +113,7 @@ void ME_CopyToCFAny(CHARFORMAT2W *to, CHARFORMAT2W *from) ME_Style *ME_MakeStyle(CHARFORMAT2W *style) { - ME_Style *s = ALLOC_OBJ(ME_Style); + ME_Style *s = heap_alloc(sizeof(*s)); assert(style->cbSize == sizeof(CHARFORMAT2W)); s->fmt = *style; @@ -306,7 +306,8 @@ ME_LogFontFromStyle(ME_Context* c, LOGFONTW *lf, const ME_Style *s) lf->lfWeight = s->fmt.wWeight; if (s->fmt.dwEffects & s->fmt.dwMask & CFM_ITALIC) lf->lfItalic = 1; - if ((s->fmt.dwEffects & s->fmt.dwMask & (CFM_UNDERLINE | CFE_LINK)) && + if ((s->fmt.dwEffects & s->fmt.dwMask & CFM_UNDERLINE) && + !(s->fmt.dwEffects & CFE_LINK) && s->fmt.bUnderlineType == CFU_CF1UNDERLINE) lf->lfUnderline = 1; if (s->fmt.dwEffects & s->fmt.dwMask & CFM_STRIKEOUT) @@ -425,7 +426,7 @@ void ME_DestroyStyle(ME_Style *s) s->font_cache = NULL; } ScriptFreeCache( &s->script_cache ); - FREE_OBJ(s); + heap_free(s); } void ME_AddRefStyle(ME_Style *s) diff --git a/dll/win32/riched20/table.c b/dll/win32/riched20/table.c index d2cab9a817c..4cd77eb3996 100644 --- a/dll/win32/riched20/table.c +++ b/dll/win32/riched20/table.c @@ -637,8 +637,8 @@ void ME_MoveCursorFromTableRowStartParagraph(ME_TextEditor *editor) struct RTFTable *ME_MakeTableDef(ME_TextEditor *editor) { - RTFTable *tableDef = ALLOC_OBJ(RTFTable); - ZeroMemory(tableDef, sizeof(RTFTable)); + RTFTable *tableDef = heap_alloc_zero(sizeof(*tableDef)); + if (!editor->bEmulateVersion10) /* v4.1 */ tableDef->gapH = 10; return tableDef; diff --git a/dll/win32/riched20/txthost.c b/dll/win32/riched20/txthost.c index f926964719a..b479bde81bd 100644 --- a/dll/win32/riched20/txthost.c +++ b/dll/win32/riched20/txthost.c @@ -18,7 +18,18 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "config.h" +#include "wine/port.h" + +#define COBJMACROS + #include "editor.h" +#include "ole2.h" +#include "richole.h" +#include "imm.h" +#include "textserv.h" +#include "wine/debug.h" +#include "editstr.h" WINE_DEFAULT_DEBUG_CHANNEL(richedit); diff --git a/dll/win32/riched20/txtsrv.c b/dll/win32/riched20/txtsrv.c index 869534baecb..eb61e4eff6e 100644 --- a/dll/win32/riched20/txtsrv.c +++ b/dll/win32/riched20/txtsrv.c @@ -18,8 +18,20 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "editor.h" +#include "config.h" +#include "wine/port.h" +#define COBJMACROS + +#include "editor.h" +#include "ole2.h" +#include "oleauto.h" +#include "richole.h" +#include "tom.h" +#include "imm.h" +#include "textserv.h" +#include "wine/debug.h" +#include "editstr.h" #ifdef __i386__ /* thiscall functions are i386-specific */ diff --git a/dll/win32/riched20/version.rc b/dll/win32/riched20/version.rc index 22b5a701c68..8b3bbe21412 100644 --- a/dll/win32/riched20/version.rc +++ b/dll/win32/riched20/version.rc @@ -27,6 +27,7 @@ #include "res.h" +/* @makedep: ocr_reverse.cur */ OCR_REVERSE CURSOR ocr_reverse.cur 1 TYPELIB riched_tom.tlb diff --git a/dll/win32/riched20/writer.c b/dll/win32/riched20/writer.c index 3a646b9a241..aad2e448796 100644 --- a/dll/win32/riched20/writer.c +++ b/dll/win32/riched20/writer.c @@ -18,6 +18,11 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "config.h" +#include "wine/port.h" + +#define NONAMELESSUNION + #include "editor.h" #include "rtf.h" @@ -52,15 +57,11 @@ ME_StreamOutRTFText(ME_OutStream *pStream, const WCHAR *text, LONG nChars); static ME_OutStream* ME_StreamOutInit(ME_TextEditor *editor, EDITSTREAM *stream) { - ME_OutStream *pStream = ALLOC_OBJ(ME_OutStream); + ME_OutStream *pStream = heap_alloc_zero(sizeof(*pStream)); + pStream->stream = stream; pStream->stream->dwError = 0; - pStream->pos = 0; - pStream->written = 0; - pStream->nFontTblLen = 0; pStream->nColorTblLen = 1; - pStream->nNestingLevel = 0; - memset(&pStream->cur_fmt, 0, sizeof(pStream->cur_fmt)); pStream->cur_fmt.dwEffects = CFE_AUTOCOLOR | CFE_AUTOBACKCOLOR; pStream->cur_fmt.bUnderlineType = CFU_UNDERLINE; return pStream; @@ -96,7 +97,7 @@ ME_StreamOutFree(ME_OutStream *pStream) LONG written = pStream->written; TRACE("total length = %u\n", written); - FREE_OBJ(pStream); + heap_free(pStream); return written; } @@ -1143,8 +1144,7 @@ static BOOL ME_StreamOutText(ME_TextEditor *editor, ME_OutStream *pStream, nSize = WideCharToMultiByte(nCodePage, 0, get_text( &cursor.pRun->member.run, cursor.nOffset ), nLen, NULL, 0, NULL, NULL); if (nSize > nBufLen) { - FREE_OBJ(buffer); - buffer = ALLOC_N_OBJ(char, nSize); + buffer = heap_realloc(buffer, nSize); nBufLen = nSize; } WideCharToMultiByte(nCodePage, 0, get_text( &cursor.pRun->member.run, cursor.nOffset ), @@ -1158,7 +1158,7 @@ static BOOL ME_StreamOutText(ME_TextEditor *editor, ME_OutStream *pStream, cursor.pRun = ME_FindItemFwd(cursor.pRun, diRun); } - FREE_OBJ(buffer); + heap_free(buffer); return success; } diff --git a/media/doc/README.WINE b/media/doc/README.WINE index a3ca247d4d4..1b38747c0b6 100644 --- a/media/doc/README.WINE +++ b/media/doc/README.WINE @@ -158,7 +158,7 @@ reactos/dll/win32/qmgrprxy # Synced to WineStaging-2.9 reactos/dll/win32/query # Synced to WineStaging-3.3 reactos/dll/win32/rasapi32 # Synced to WineStaging-3.3 reactos/dll/win32/resutils # Synced to WineStaging-3.3 -reactos/dll/win32/riched20 # Synced to Wine-3.0 +reactos/dll/win32/riched20 # Synced to WineStaging-3.3 reactos/dll/win32/riched32 # Synced to WineStaging-2.9 reactos/dll/win32/rpcrt4 # Synced to WineStaging-3.3 reactos/dll/win32/rsabase # Synced to WineStaging-2.9