https://git.reactos.org/?p=reactos.git;a=commitdiff;h=661b8a2a05f70f5d2eddc…
commit 661b8a2a05f70f5d2eddc0fdf089f003e84c79bc
Author: Amine Khaldi <amine.khaldi(a)reactos.org>
AuthorDate: Sat Nov 23 12:10:55 2019 +0100
Commit: Amine Khaldi <amine.khaldi(a)reactos.org>
CommitDate: Sat Nov 23 12:10:55 2019 +0100
[RICHED20] Sync with Wine Staging 4.18. CORE-16441
---
dll/win32/riched20/caret.c | 68 +++++++++-------
dll/win32/riched20/context.c | 5 +-
dll/win32/riched20/editor.c | 181 +++++++++++++++++++++++--------------------
dll/win32/riched20/editor.h | 19 +++--
dll/win32/riched20/editstr.h | 8 +-
dll/win32/riched20/paint.c | 50 +++++-------
dll/win32/riched20/para.c | 7 +-
dll/win32/riched20/precomp.h | 2 -
dll/win32/riched20/richole.c | 57 ++++++--------
dll/win32/riched20/run.c | 25 +++---
dll/win32/riched20/style.c | 131 ++++++++++++++++++-------------
dll/win32/riched20/table.c | 3 +-
dll/win32/riched20/txthost.c | 37 +--------
dll/win32/riched20/txtsrv.c | 40 +---------
dll/win32/riched20/wrap.c | 5 +-
dll/win32/riched20/writer.c | 19 ++---
media/doc/README.WINE | 2 +-
17 files changed, 307 insertions(+), 352 deletions(-)
diff --git a/dll/win32/riched20/caret.c b/dll/win32/riched20/caret.c
index ad72511da46..212c9e9f992 100644
--- a/dll/win32/riched20/caret.c
+++ b/dll/win32/riched20/caret.c
@@ -122,8 +122,14 @@ int ME_GetTextLengthEx(ME_TextEditor *editor, const GETTEXTLENGTHEX
*how)
return length;
}
-
-int ME_SetSelection(ME_TextEditor *editor, int from, int to)
+/******************************************************************
+ * set_selection_cursors
+ *
+ * Updates the selection cursors.
+ *
+ * Note that this does not invalidate either the old or the new selections.
+ */
+int set_selection_cursors(ME_TextEditor *editor, int from, int to)
{
int selectionEnd = 0;
const int len = ME_GetTextLength(editor);
@@ -139,7 +145,6 @@ int ME_SetSelection(ME_TextEditor *editor, int from, int to)
{
ME_SetCursorToStart(editor, &editor->pCursors[1]);
ME_SetCursorToEnd(editor, &editor->pCursors[0], TRUE);
- ME_InvalidateSelection(editor);
return len + 1;
}
@@ -165,7 +170,6 @@ int ME_SetSelection(ME_TextEditor *editor, int from, int to)
end --;
}
editor->pCursors[1] = editor->pCursors[0];
- ME_Repaint(editor);
}
return end;
}
@@ -194,7 +198,6 @@ int ME_SetSelection(ME_TextEditor *editor, int from, int to)
{
ME_SetCursorToEnd(editor, &editor->pCursors[0], FALSE);
editor->pCursors[1] = editor->pCursors[0];
- ME_InvalidateSelection(editor);
return len;
}
@@ -266,36 +269,47 @@ void ME_GetCursorCoordinates(ME_TextEditor *editor, ME_Cursor
*pCursor,
return;
}
-
-void
-ME_MoveCaret(ME_TextEditor *editor)
+void create_caret(ME_TextEditor *editor)
{
int x, y, height;
ME_GetCursorCoordinates(editor, &editor->pCursors[0], &x, &y,
&height);
- if(editor->bHaveFocus && !ME_IsSelection(editor))
- {
- x = min(x, editor->rcFormat.right-1);
- ITextHost_TxCreateCaret(editor->texthost, NULL, 0, height);
- ITextHost_TxSetCaretPos(editor->texthost, x, y);
- }
+ ITextHost_TxCreateCaret(editor->texthost, NULL, 0, height);
+ editor->caret_height = height;
+ editor->caret_hidden = TRUE;
}
+void show_caret(ME_TextEditor *editor)
+{
+ ITextHost_TxShowCaret(editor->texthost, TRUE);
+ editor->caret_hidden = FALSE;
+}
-void ME_ShowCaret(ME_TextEditor *ed)
+void hide_caret(ME_TextEditor *editor)
{
- ME_MoveCaret(ed);
- if(ed->bHaveFocus && !ME_IsSelection(ed))
- ITextHost_TxShowCaret(ed->texthost, TRUE);
+ /* calls to HideCaret are cumulative; do so only once */
+ if (!editor->caret_hidden)
+ {
+ ITextHost_TxShowCaret(editor->texthost, FALSE);
+ editor->caret_hidden = TRUE;
+ }
}
-void ME_HideCaret(ME_TextEditor *ed)
+void update_caret(ME_TextEditor *editor)
{
- if(!ed->bHaveFocus || ME_IsSelection(ed))
+ int x, y, height;
+
+ if (!editor->bHaveFocus) return;
+ if (!ME_IsSelection(editor))
{
- ITextHost_TxShowCaret(ed->texthost, FALSE);
- DestroyCaret();
+ ME_GetCursorCoordinates(editor, &editor->pCursors[0], &x, &y,
&height);
+ if (height != editor->caret_height) create_caret(editor);
+ x = min(x, editor->rcFormat.right-1);
+ ITextHost_TxSetCaretPos(editor->texthost, x, y);
+ show_caret(editor);
}
+ else
+ hide_caret(editor);
}
BOOL ME_InternalDeleteText(ME_TextEditor *editor, ME_Cursor *start,
@@ -1200,8 +1214,7 @@ void ME_LButtonDown(ME_TextEditor *editor, int x, int y, int
clickNum)
}
}
ME_InvalidateSelection(editor);
- ITextHost_TxShowCaret(editor->texthost, FALSE);
- ME_ShowCaret(editor);
+ update_caret(editor);
ME_SendSelChange(editor);
}
@@ -1233,8 +1246,7 @@ void ME_MouseMove(ME_TextEditor *editor, int x, int y)
}
ME_InvalidateSelection(editor);
- ITextHost_TxShowCaret(editor->texthost, FALSE);
- ME_ShowCaret(editor);
+ update_caret(editor);
ME_SendSelChange(editor);
}
@@ -1627,9 +1639,9 @@ ME_ArrowKey(ME_TextEditor *editor, int nVKey, BOOL extend, BOOL
ctrl)
ME_InvalidateSelection(editor);
ME_Repaint(editor);
- ITextHost_TxShowCaret(editor->texthost, FALSE);
+ hide_caret(editor);
ME_EnsureVisible(editor, &tmp_curs);
- ME_ShowCaret(editor);
+ update_caret(editor);
ME_SendSelChange(editor);
return success;
}
diff --git a/dll/win32/riched20/context.c b/dll/win32/riched20/context.c
index 2cdaeff328a..66066b39e67 100644
--- a/dll/win32/riched20/context.c
+++ b/dll/win32/riched20/context.c
@@ -27,6 +27,8 @@ void ME_InitContext(ME_Context *c, ME_TextEditor *editor, HDC hDC)
c->pt.x = 0;
c->pt.y = 0;
c->rcView = editor->rcFormat;
+ c->current_style = NULL;
+ c->orig_font = NULL;
if (hDC) {
c->dpi.cx = GetDeviceCaps(hDC, LOGPIXELSX);
c->dpi.cy = GetDeviceCaps(hDC, LOGPIXELSY);
@@ -41,5 +43,6 @@ void ME_InitContext(ME_Context *c, ME_TextEditor *editor, HDC hDC)
void ME_DestroyContext(ME_Context *c)
{
- if (c->hDC) ITextHost_TxReleaseDC(c->editor->texthost, c->hDC);
+ select_style( c, NULL );
+ if (c->hDC) ITextHost_TxReleaseDC( c->editor->texthost, c->hDC );
}
diff --git a/dll/win32/riched20/editor.c b/dll/win32/riched20/editor.c
index c4ae49766ef..5ad25869997 100644
--- a/dll/win32/riched20/editor.c
+++ b/dll/win32/riched20/editor.c
@@ -1128,6 +1128,7 @@ static HRESULT insert_static_object(ME_TextEditor *editor,
HENHMETAFILE hemf, HB
LPOLECLIENTSITE lpClientSite = NULL;
LPDATAOBJECT lpDataObject = NULL;
LPOLECACHE lpOleCache = NULL;
+ LPRICHEDITOLE lpReOle = NULL;
STGMEDIUM stgm;
FORMATETC fm;
CLSID clsid;
@@ -1160,7 +1161,8 @@ static HRESULT insert_static_object(ME_TextEditor *editor,
HENHMETAFILE hemf, HB
}
if (OleCreateDefaultHandler(&CLSID_NULL, NULL, &IID_IOleObject,
(void**)&lpObject) == S_OK &&
- IRichEditOle_GetClientSite(editor->reOle, &lpClientSite) == S_OK &&
+ IUnknown_QueryInterface(editor->reOle, &IID_IRichEditOle,
(void**)&lpReOle) == S_OK &&
+ IRichEditOle_GetClientSite(lpReOle, &lpClientSite) == S_OK &&
IOleObject_SetClientSite(lpObject, lpClientSite) == S_OK &&
IOleObject_GetUserClassID(lpObject, &clsid) == S_OK &&
IOleObject_QueryInterface(lpObject, &IID_IOleCache, (void**)&lpOleCache) ==
S_OK &&
@@ -1192,6 +1194,7 @@ static HRESULT insert_static_object(ME_TextEditor *editor,
HENHMETAFILE hemf, HB
if (lpStorage) IStorage_Release(lpStorage);
if (lpDataObject) IDataObject_Release(lpDataObject);
if (lpOleCache) IOleCache_Release(lpOleCache);
+ if (lpReOle) IRichEditOle_Release(lpReOle);
return hr;
}
@@ -1623,7 +1626,7 @@ static LRESULT ME_StreamIn(ME_TextEditor *editor, DWORD format,
EDITSTREAM *stre
} else {
style = editor->pBuffer->pDefaultStyle;
ME_AddRefStyle(style);
- ME_SetSelection(editor, 0, 0);
+ set_selection_cursors(editor, 0, 0);
ME_InternalDeleteText(editor, &editor->pCursors[1],
ME_GetTextLength(editor), FALSE);
from = to = 0;
@@ -1757,9 +1760,9 @@ static LRESULT ME_StreamIn(ME_TextEditor *editor, DWORD format,
EDITSTREAM *stre
cf.dwMask = CFM_ALL2;
ME_MoveCursorChars(editor, &lastcharCursor, -1, FALSE);
ME_GetCharFormat(editor, &lastcharCursor, &linebreakCursor, &cf);
- ME_SetSelection(editor, newto, -1);
+ set_selection_cursors(editor, newto, -1);
ME_SetSelectionCharFormat(editor, &cf);
- ME_SetSelection(editor, newto, newto);
+ set_selection_cursors(editor, newto, newto);
ME_MoveCursorChars(editor, &linebreakCursor, -linebreakSize, FALSE);
ME_GetTextW(editor, lastchar, 2, &linebreakCursor, linebreakSize, FALSE,
FALSE);
@@ -1782,7 +1785,7 @@ static LRESULT ME_StreamIn(ME_TextEditor *editor, DWORD format,
EDITSTREAM *stre
ERR("EM_STREAMIN without SF_TEXT or SF_RTF\n");
/* put the cursor at the top */
if (!(format & SFF_SELECTION))
- ME_SetSelection(editor, 0, 0);
+ set_selection_cursors(editor, 0, 0);
ME_CursorFromCharOfs(editor, from, &start);
ME_UpdateLinkAttribute(editor, &start, to - from);
}
@@ -1803,9 +1806,7 @@ static LRESULT ME_StreamIn(ME_TextEditor *editor, DWORD format,
EDITSTREAM *stre
if (!(format & SFF_SELECTION)) {
ME_ClearTempStyle(editor);
}
- ITextHost_TxShowCaret(editor->texthost, FALSE);
- ME_MoveCaret(editor);
- ITextHost_TxShowCaret(editor->texthost, TRUE);
+ update_caret(editor);
ME_SendSelChange(editor);
ME_SendRequestResize(editor, FALSE);
@@ -1929,7 +1930,7 @@ ME_FindText(ME_TextEditor *editor, DWORD flags, const CHARRANGE
*chrg, const WCH
while (pCurItem && ME_CharCompare( *get_text( &pCurItem->member.run,
nCurStart + nMatched ), text[nMatched], (flags & FR_MATCHCASE)))
{
- if ((flags & FR_WHOLEWORD) && isalnumW(wLastChar))
+ if ((flags & FR_WHOLEWORD) && iswalnum(wLastChar))
break;
nMatched++;
@@ -1953,7 +1954,7 @@ ME_FindText(ME_TextEditor *editor, DWORD flags, const CHARRANGE
*chrg, const WCH
else
wNextChar = ' ';
- if (isalnumW(wNextChar))
+ if (iswalnum(wNextChar))
break;
}
@@ -2013,7 +2014,7 @@ ME_FindText(ME_TextEditor *editor, DWORD flags, const CHARRANGE
*chrg, const WCH
while (pCurItem && ME_CharCompare( *get_text( &pCurItem->member.run,
nCurEnd - nMatched - 1 ),
text[nLen - nMatched - 1], (flags &
FR_MATCHCASE) ))
{
- if ((flags & FR_WHOLEWORD) && isalnumW(wLastChar))
+ if ((flags & FR_WHOLEWORD) && iswalnum(wLastChar))
break;
nMatched++;
@@ -2039,7 +2040,7 @@ ME_FindText(ME_TextEditor *editor, DWORD flags, const CHARRANGE
*chrg, const WCH
else
wPrevChar = ' ';
- if (isalnumW(wPrevChar))
+ if (iswalnum(wPrevChar))
break;
}
@@ -2150,17 +2151,16 @@ static int ME_GetTextRange(ME_TextEditor *editor, WCHAR *strText,
}
}
-static int handle_EM_EXSETSEL( ME_TextEditor *editor, int to, int from )
+int set_selection( ME_TextEditor *editor, int to, int from )
{
int end;
TRACE("%d - %d\n", to, from );
- ME_InvalidateSelection( editor );
- end = ME_SetSelection( editor, to, from );
- ME_InvalidateSelection( editor );
- ITextHost_TxShowCaret( editor->texthost, FALSE );
- ME_ShowCaret( editor );
+ if (!editor->bHideSelection) ME_InvalidateSelection( editor );
+ end = set_selection_cursors( editor, to, from );
+ if (!editor->bHideSelection) ME_InvalidateSelection( editor );
+ update_caret( editor );
ME_SendSelChange( editor );
return end;
@@ -2686,7 +2686,7 @@ ME_KeyDown(ME_TextEditor *editor, WORD nKey)
case 'A':
if (ctrl_is_down)
{
- handle_EM_EXSETSEL( editor, 0, -1 );
+ set_selection( editor, 0, -1 );
return TRUE;
}
break;
@@ -3119,6 +3119,8 @@ ME_TextEditor *ME_MakeEditor(ITextHost *texthost, BOOL
bEmulateVersion10)
ed->bHaveFocus = FALSE;
ed->bDialogMode = FALSE;
ed->bMouseCaptured = FALSE;
+ ed->caret_hidden = FALSE;
+ ed->caret_height = 0;
for (i=0; i<HFONT_CACHE_SIZE; i++)
{
ed->pFontCache[i].nRefs = 0;
@@ -3219,7 +3221,7 @@ void ME_DestroyEditor(ME_TextEditor *editor)
ITextHost_Release(editor->texthost);
if (editor->reOle)
{
- IRichEditOle_Release(editor->reOle);
+ IUnknown_Release(editor->reOle);
editor->reOle = NULL;
}
OleUninitialize();
@@ -3530,10 +3532,59 @@ static LRESULT ME_WmCreate(ME_TextEditor *editor, LPARAM lParam,
BOOL unicode)
ME_CommitUndo(editor);
ME_WrapMarkedParagraphs(editor);
- ME_MoveCaret(editor);
+ update_caret(editor);
return 0;
}
+static LRESULT handle_EM_SETCHARFORMAT( ME_TextEditor *editor, WPARAM flags, const
CHARFORMAT2W *fmt_in )
+{
+ CHARFORMAT2W fmt;
+ BOOL changed = TRUE;
+ ME_Cursor start, end;
+
+ if (!cfany_to_cf2w( &fmt, fmt_in )) return 0;
+
+ if (flags & SCF_ALL)
+ {
+ if (editor->mode & TM_PLAINTEXT)
+ {
+ ME_SetDefaultCharFormat( editor, &fmt );
+ }
+ else
+ {
+ ME_SetCursorToStart( editor, &start );
+ ME_SetCharFormat( editor, &start, NULL, &fmt );
+ editor->nModifyStep = 1;
+ }
+ }
+ else if (flags & SCF_SELECTION)
+ {
+ if (editor->mode & TM_PLAINTEXT) return 0;
+ if (flags & SCF_WORD)
+ {
+ end = editor->pCursors[0];
+ ME_MoveCursorWords( editor, &end, +1 );
+ start = end;
+ ME_MoveCursorWords( editor, &start, -1 );
+ ME_SetCharFormat( editor, &start, &end, &fmt );
+ }
+ changed = ME_IsSelection( editor );
+ ME_SetSelectionCharFormat( editor, &fmt );
+ if (changed) editor->nModifyStep = 1;
+ }
+ else /* SCF_DEFAULT */
+ {
+ ME_SetDefaultCharFormat( editor, &fmt );
+ }
+
+ ME_CommitUndo( editor );
+ if (changed)
+ {
+ ME_WrapMarkedParagraphs( editor );
+ ME_UpdateScrollBar( editor );
+ }
+ return 1;
+}
#define UNSUPPORTED_MSG(e) \
case e: \
@@ -3682,7 +3733,6 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM
wParam,
ME_CommitUndo(editor);
ME_WrapMarkedParagraphs(editor);
ME_UpdateScrollBar(editor);
- ME_Repaint(editor);
return TRUE;
}
@@ -3750,7 +3800,7 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM
wParam,
}
case EM_SETSEL:
{
- return handle_EM_EXSETSEL( editor, wParam, lParam );
+ return set_selection( editor, wParam, lParam );
}
case EM_SETSCROLLPOS:
{
@@ -3775,7 +3825,7 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM
wParam,
{
CHARRANGE range = *(CHARRANGE *)lParam;
- return handle_EM_EXSETSEL( editor, range.cpMin, range.cpMax );
+ return set_selection( editor, range.cpMin, range.cpMax );
}
case EM_SHOWSCROLLBAR:
{
@@ -3935,46 +3985,7 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM
wParam,
case EM_GETEVENTMASK:
return editor->nEventMask;
case EM_SETCHARFORMAT:
- {
- CHARFORMAT2W p;
- BOOL bRepaint = TRUE;
- if (!cfany_to_cf2w(&p, (CHARFORMAT2W *)lParam))
- return 0;
- if (wParam & SCF_ALL) {
- if (editor->mode & TM_PLAINTEXT) {
- ME_SetDefaultCharFormat(editor, &p);
- } else {
- ME_Cursor start;
- ME_SetCursorToStart(editor, &start);
- ME_SetCharFormat(editor, &start, NULL, &p);
- editor->nModifyStep = 1;
- }
- } else if (wParam & SCF_SELECTION) {
- if (editor->mode & TM_PLAINTEXT)
- return 0;
- if (wParam & SCF_WORD) {
- ME_Cursor start;
- ME_Cursor end = editor->pCursors[0];
- ME_MoveCursorWords(editor, &end, +1);
- start = end;
- ME_MoveCursorWords(editor, &start, -1);
- ME_SetCharFormat(editor, &start, &end, &p);
- }
- bRepaint = ME_IsSelection(editor);
- ME_SetSelectionCharFormat(editor, &p);
- if (bRepaint) editor->nModifyStep = 1;
- } else { /* SCF_DEFAULT */
- ME_SetDefaultCharFormat(editor, &p);
- }
- ME_CommitUndo(editor);
- if (bRepaint)
- {
- ME_WrapMarkedParagraphs(editor);
- ME_UpdateScrollBar(editor);
- ME_Repaint(editor);
- }
- return 1;
- }
+ return handle_EM_SETCHARFORMAT( editor, wParam, (CHARFORMAT2W *)lParam );
case EM_GETCHARFORMAT:
{
CHARFORMAT2W tmp, *dst = (CHARFORMAT2W *)lParam;
@@ -3996,7 +4007,6 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM
wParam,
BOOL result = ME_SetSelectionParaFormat(editor, (PARAFORMAT2 *)lParam);
ME_WrapMarkedParagraphs(editor);
ME_UpdateScrollBar(editor);
- ME_Repaint(editor);
ME_CommitUndo(editor);
return result;
}
@@ -4116,7 +4126,7 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM
wParam,
TRACE("WM_SETTEXT - NULL\n");
ME_SetCursorToStart(editor, &cursor);
ME_UpdateLinkAttribute(editor, &cursor, INT_MAX);
- ME_SetSelection(editor, 0, 0);
+ set_selection_cursors(editor, 0, 0);
editor->nModifyStep = 0;
ME_CommitUndo(editor);
ME_EmptyUndoStack(editor);
@@ -4512,7 +4522,8 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM
wParam,
break;
case WM_SETFOCUS:
editor->bHaveFocus = TRUE;
- ME_ShowCaret(editor);
+ create_caret(editor);
+ update_caret(editor);
ME_SendOldNotify(editor, EN_SETFOCUS);
if (!editor->bHideSelection && !(editor->styleFlags &
ES_NOHIDESEL))
ME_InvalidateSelection( editor );
@@ -4521,7 +4532,8 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM
wParam,
ME_CommitUndo(editor); /* End coalesced undos for typed characters */
editor->bHaveFocus = FALSE;
editor->wheel_remain = 0;
- ME_HideCaret(editor);
+ hide_caret(editor);
+ DestroyCaret();
ME_SendOldNotify(editor, EN_KILLFOCUS);
if (!editor->bHideSelection && !(editor->styleFlags &
ES_NOHIDESEL))
ME_InvalidateSelection( editor );
@@ -4805,7 +4817,7 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM
wParam,
HeapFree(GetProcessHeap(), 0, lpCompStr);
if (dwIndex == GCS_COMPSTR)
- ME_SetSelection(editor,editor->imeStartIndex,
+ set_selection_cursors(editor,editor->imeStartIndex,
editor->imeStartIndex + dwBufLen/sizeof(WCHAR));
}
ME_ReleaseStyle(style);
@@ -4824,9 +4836,9 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM
wParam,
if (!editor->reOle)
if (!CreateIRichEditOle(NULL, editor, (LPVOID *)&editor->reOle))
return 0;
- *(LPVOID *)lParam = editor->reOle;
- IRichEditOle_AddRef(editor->reOle);
- return 1;
+ if (IUnknown_QueryInterface(editor->reOle, &IID_IRichEditOle, (LPVOID
*)lParam) == S_OK)
+ return 1;
+ return 0;
}
case EM_GETPASSWORDCHAR:
{
@@ -4975,41 +4987,46 @@ static LRESULT RichEditWndProc_common(HWND hWnd, UINT msg, WPARAM
wParam,
{
case WM_PAINT:
{
- HDC hDC;
+ HDC hdc;
RECT rc;
PAINTSTRUCT ps;
+ HBRUSH old_brush;
- hDC = BeginPaint(editor->hWnd, &ps);
+ update_caret(editor);
+ hdc = BeginPaint(editor->hWnd, &ps);
if (!editor->bEmulateVersion10 || (editor->nEventMask & ENM_UPDATE))
ME_SendOldNotify(editor, EN_UPDATE);
+ old_brush = SelectObject(hdc, editor->hbrBackground);
+
/* Erase area outside of the formatting rectangle */
if (ps.rcPaint.top < editor->rcFormat.top)
{
rc = ps.rcPaint;
rc.bottom = editor->rcFormat.top;
- FillRect(hDC, &rc, editor->hbrBackground);
+ PatBlt(hdc, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, PATCOPY);
ps.rcPaint.top = editor->rcFormat.top;
}
if (ps.rcPaint.bottom > editor->rcFormat.bottom) {
rc = ps.rcPaint;
rc.top = editor->rcFormat.bottom;
- FillRect(hDC, &rc, editor->hbrBackground);
+ PatBlt(hdc, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, PATCOPY);
ps.rcPaint.bottom = editor->rcFormat.bottom;
}
if (ps.rcPaint.left < editor->rcFormat.left) {
rc = ps.rcPaint;
rc.right = editor->rcFormat.left;
- FillRect(hDC, &rc, editor->hbrBackground);
+ PatBlt(hdc, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, PATCOPY);
ps.rcPaint.left = editor->rcFormat.left;
}
if (ps.rcPaint.right > editor->rcFormat.right) {
rc = ps.rcPaint;
rc.left = editor->rcFormat.right;
- FillRect(hDC, &rc, editor->hbrBackground);
+ PatBlt(hdc, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, PATCOPY);
ps.rcPaint.right = editor->rcFormat.right;
}
- ME_PaintContent(editor, hDC, &ps.rcPaint);
+ ME_PaintContent(editor, hdc, &ps.rcPaint);
+ SelectObject(hdc, old_brush);
EndPaint(editor->hWnd, &ps);
return 0;
}
@@ -5283,7 +5300,7 @@ LRESULT WINAPI REExtendedRegisterClass(void)
return result;
}
-static int wchar_comp( const void *key, const void *elem )
+static int __cdecl wchar_comp( const void *key, const void *elem )
{
return *(const WCHAR *)key - *(const WCHAR *)elem;
}
@@ -5332,7 +5349,7 @@ static BOOL ME_FindNextURLCandidate(ME_TextEditor *editor,
while (cursor.nOffset < run_len)
{
c = str[cursor.nOffset];
- if (!isspaceW( c ) && !isurlneutral( c ))
+ if (!iswspace( c ) && !isurlneutral( c ))
{
*candidate_min = cursor;
candidateStarted = TRUE;
@@ -5352,7 +5369,7 @@ static BOOL ME_FindNextURLCandidate(ME_TextEditor *editor,
while (cursor.nOffset < run_len)
{
c = str[cursor.nOffset];
- if (isspaceW( c ))
+ if (iswspace( c ))
{
if (quoted && c != '\r')
{
diff --git a/dll/win32/riched20/editor.h b/dll/win32/riched20/editor.h
index b9dc4ec74f9..2bd06be2cf6 100644
--- a/dll/win32/riched20/editor.h
+++ b/dll/win32/riched20/editor.h
@@ -21,7 +21,6 @@
#pragma once
#include "editstr.h"
-#include "wine/unicode.h"
struct _RTF_Info;
@@ -56,8 +55,7 @@ void ME_DestroyStyle(ME_Style *item) DECLSPEC_HIDDEN;
void ME_ReleaseStyle(ME_Style *item) DECLSPEC_HIDDEN;
ME_Style *ME_GetInsertStyle(ME_TextEditor *editor, int nCursor) DECLSPEC_HIDDEN;
ME_Style *ME_ApplyStyle(ME_TextEditor *ed, ME_Style *sSrc, CHARFORMAT2W *style)
DECLSPEC_HIDDEN;
-HFONT ME_SelectStyleFont(ME_Context *c, ME_Style *s) DECLSPEC_HIDDEN;
-void ME_UnselectStyleFont(ME_Context *c, ME_Style *s, HFONT hOldFont) DECLSPEC_HIDDEN;
+void select_style(ME_Context *c, ME_Style *s) DECLSPEC_HIDDEN;
void ME_InitCharFormat2W(CHARFORMAT2W *pFmt) DECLSPEC_HIDDEN;
void ME_SaveTempStyle(ME_TextEditor *editor, ME_Style *style) DECLSPEC_HIDDEN;
void ME_ClearTempStyle(ME_TextEditor *editor) DECLSPEC_HIDDEN;
@@ -107,7 +105,7 @@ static inline int ME_IsWSpace(WCHAR ch)
static inline int ME_CharCompare(WCHAR a, WCHAR b, int caseSensitive)
{
- return caseSensitive ? (a == b) : (toupperW(a) == toupperW(b));
+ return caseSensitive ? (a == b) : (towupper(a) == towupper(b));
}
/* note: those two really return the first matching offset (starting from EOS)+1
@@ -152,11 +150,12 @@ void ME_SetDefaultCharFormat(ME_TextEditor *editor, CHARFORMAT2W
*mod) DECLSPEC_
/* caret.c */
void ME_SetCursorToStart(ME_TextEditor *editor, ME_Cursor *cursor) DECLSPEC_HIDDEN;
-int ME_SetSelection(ME_TextEditor *editor, int from, int to) DECLSPEC_HIDDEN;
+int set_selection_cursors(ME_TextEditor *editor, int from, int to) DECLSPEC_HIDDEN;
BOOL ME_MoveCursorWords(ME_TextEditor *editor, ME_Cursor *cursor, int nRelOfs)
DECLSPEC_HIDDEN;
-void ME_HideCaret(ME_TextEditor *ed) DECLSPEC_HIDDEN;
-void ME_ShowCaret(ME_TextEditor *ed) DECLSPEC_HIDDEN;
-void ME_MoveCaret(ME_TextEditor *ed) DECLSPEC_HIDDEN;
+void hide_caret(ME_TextEditor *ed) DECLSPEC_HIDDEN;
+void show_caret(ME_TextEditor *ed) DECLSPEC_HIDDEN;
+void update_caret(ME_TextEditor *ed) DECLSPEC_HIDDEN;
+void create_caret(ME_TextEditor *ed) DECLSPEC_HIDDEN;
BOOL ME_CharFromPos(ME_TextEditor *editor, int x, int y, ME_Cursor *cursor, BOOL
*isExact) DECLSPEC_HIDDEN;
void ME_LButtonDown(ME_TextEditor *editor, int x, int y, int clickNum) DECLSPEC_HIDDEN;
void ME_MouseMove(ME_TextEditor *editor, int x, int y) DECLSPEC_HIDDEN;
@@ -241,7 +240,6 @@ void ME_DrawOLE(ME_Context *c, int x, int y, ME_Run* run, BOOL
selected) DECLSPE
void ME_GetOLEObjectSize(const ME_Context *c, ME_Run *run, SIZE *pSize) DECLSPEC_HIDDEN;
void ME_CopyReObject(REOBJECT *dst, const REOBJECT *src, DWORD flags) DECLSPEC_HIDDEN;
void ME_DeleteReObject(struct re_object *re_object) DECLSPEC_HIDDEN;
-void ME_GetITextDocument2OldInterface(IRichEditOle *iface, LPVOID *ppvObj)
DECLSPEC_HIDDEN;
/* editor.c */
ME_TextEditor *ME_MakeEditor(ITextHost *texthost, BOOL bEmulateVersion10)
DECLSPEC_HIDDEN;
@@ -258,6 +256,7 @@ void ME_RTFSpecialCharHook(struct _RTF_Info *info) DECLSPEC_HIDDEN;
void ME_StreamInFill(ME_InStream *stream) DECLSPEC_HIDDEN;
extern BOOL me_debug DECLSPEC_HIDDEN;
void ME_ReplaceSel(ME_TextEditor *editor, BOOL can_undo, const WCHAR *str, int len)
DECLSPEC_HIDDEN;
+int set_selection( ME_TextEditor *editor, int to, int from ) DECLSPEC_HIDDEN;
/* table.c */
BOOL ME_IsInTable(ME_DisplayItem *pItem) DECLSPEC_HIDDEN;
@@ -279,7 +278,7 @@ void ME_InitTableDef(ME_TextEditor *editor, struct RTFTable *tableDef)
DECLSPEC_
/* txthost.c */
ITextHost *ME_CreateTextHost(HWND hwnd, CREATESTRUCTW *cs, BOOL bEmulateVersion10)
DECLSPEC_HIDDEN;
-#ifdef __i386__ /* Use wrappers to perform thiscall on i386 */
+#if defined(__i386__) && !defined(__MINGW32__) /* Use wrappers to perform
thiscall on i386 */
#define TXTHOST_VTABLE(This) (&itextHostStdcallVtbl)
#else /* __i386__ */
#define TXTHOST_VTABLE(This) (This)->lpVtbl
diff --git a/dll/win32/riched20/editstr.h b/dll/win32/riched20/editstr.h
index 96c9a1f644b..a2e6f8584b7 100644
--- a/dll/win32/riched20/editstr.h
+++ b/dll/win32/riched20/editstr.h
@@ -51,7 +51,7 @@
#include "wine/heap.h"
#include "wine/list.h"
-#ifdef __i386__
+#if defined(__i386__) && !defined(__MINGW32__)
extern const struct ITextHostVtbl itextHostStdcallVtbl DECLSPEC_HIDDEN;
#endif /* __i386__ */
@@ -385,7 +385,7 @@ typedef struct tagME_TextEditor
{
HWND hWnd, hwndParent;
ITextHost *texthost;
- IRichEditOle *reOle;
+ IUnknown *reOle;
BOOL bEmulateVersion10;
ME_TextBuffer *pBuffer;
ME_Cursor *pCursors;
@@ -442,6 +442,8 @@ typedef struct tagME_TextEditor
/* Cache previously set scrollbar info */
SCROLLINFO vert_si, horz_si;
+ int caret_height;
+ BOOL caret_hidden;
BOOL bMouseCaptured;
int wheel_remain;
struct list style_list;
@@ -455,6 +457,8 @@ typedef struct tagME_Context
RECT rcView;
SIZE dpi;
int nAvailWidth;
+ ME_Style *current_style;
+ HFONT orig_font;
/* those are valid inside ME_WrapTextParagraph and related */
ME_TextEditor *editor;
diff --git a/dll/win32/riched20/paint.c b/dll/win32/riched20/paint.c
index e2ccef4fbf7..72128072380 100644
--- a/dll/win32/riched20/paint.c
+++ b/dll/win32/riched20/paint.c
@@ -43,7 +43,7 @@ void ME_PaintContent(ME_TextEditor *editor, HDC hDC, const RECT
*rcUpdate)
ME_InitContext(&c, editor, hDC);
SetBkMode(hDC, TRANSPARENT);
- ME_MoveCaret(editor);
+
item = editor->pBuffer->pFirst->next;
/* This context point is an offset for the paragraph positions stored
* during wrapping. It shouldn't be modified during painting. */
@@ -87,7 +87,7 @@ void ME_PaintContent(ME_TextEditor *editor, HDC hDC, const RECT
*rcUpdate)
IntersectRect(&rc, &rc, rcUpdate);
if (!IsRectEmpty(&rc))
- FillRect(hDC, &rc, c.editor->hbrBackground);
+ PatBlt(hDC, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, PATCOPY);
}
if (editor->nTotalLength != editor->nLastTotalLength ||
editor->nTotalWidth != editor->nLastTotalWidth)
@@ -291,11 +291,10 @@ static void draw_space( ME_Context *c, ME_Run *run, int x, int y,
{
COLORREF text_color = get_text_color( c, run->style, selected );
COLORREF old_text, old_back;
- HFONT old_font = NULL;
int y_offset = calc_y_offset( c, run->style );
static const WCHAR space[1] = {' '};
- old_font = ME_SelectStyleFont( c, run->style );
+ select_style( c, run->style );
old_text = SetTextColor( hdc, text_color );
if (selected) old_back = SetBkColor( hdc, back_color );
@@ -303,7 +302,6 @@ static void draw_space( ME_Context *c, ME_Run *run, int x, int y,
if (selected) SetBkColor( hdc, old_back );
SetTextColor( hdc, old_text );
- ME_UnselectStyleFont( c, run->style, old_font );
draw_underline( c, run, x, y - y_offset, text_color );
}
@@ -371,7 +369,6 @@ static void ME_DrawTextWithStyle(ME_Context *c, ME_Run *run, int x,
int y,
int nSelFrom, int nSelTo, int ymin, int cy)
{
HDC hDC = c->hDC;
- HGDIOBJ hOldFont;
int yOffset = 0;
BOOL selected = (nSelFrom < run->len && nSelTo >= 0
&& nSelFrom < nSelTo &&
!c->editor->bHideSelection &&
@@ -404,7 +401,7 @@ static void ME_DrawTextWithStyle(ME_Context *c, ME_Run *run, int x,
int y,
}
}
- hOldFont = ME_SelectStyleFont( c, run->style );
+ select_style( c, run->style );
if (sel_rgn) ExtSelectClipRgn( hDC, sel_rgn, RGN_DIFF );
@@ -431,8 +428,6 @@ static void ME_DrawTextWithStyle(ME_Context *c, ME_Run *run, int x,
int y,
if (old_style_selected)
PatBlt( hDC, sel_rect.left, ymin, sel_rect.right - sel_rect.left, cy, DSTINVERT );
-
- ME_UnselectStyleFont(c, run->style, hOldFont);
}
static void ME_DebugWrite(HDC hDC, const POINT *pt, LPCWSTR szText) {
@@ -603,7 +598,7 @@ static void ME_DrawParaDecoration(ME_Context* c, ME_Paragraph* para,
int y, RECT
rc.top = y;
bounds->top = ME_twips2pointsY(c, para->fmt.dySpaceBefore);
rc.bottom = y + bounds->top + top_border;
- FillRect(c->hDC, &rc, c->editor->hbrBackground);
+ PatBlt(c->hDC, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, PATCOPY);
}
if (para->fmt.dwMask & PFM_SPACEAFTER)
@@ -613,7 +608,7 @@ static void ME_DrawParaDecoration(ME_Context* c, ME_Paragraph* para,
int y, RECT
rc.bottom = y + para->nHeight;
bounds->bottom = ME_twips2pointsY(c, para->fmt.dySpaceAfter);
rc.top = rc.bottom - bounds->bottom - bottom_border;
- FillRect(c->hDC, &rc, c->editor->hbrBackground);
+ PatBlt(c->hDC, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, PATCOPY);
}
/* Native richedit doesn't support paragraph borders in v1.0 - 4.1,
@@ -652,7 +647,7 @@ static void ME_DrawParaDecoration(ME_Context* c, ME_Paragraph* para,
int y, RECT
rc.right = rc.left + border_width;
rc.top = y + bounds->top;
rc.bottom = y + para->nHeight - bounds->bottom;
- FillRect(c->hDC, &rc, c->editor->hbrBackground);
+ PatBlt(c->hDC, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top,
PATCOPY);
MoveToEx(c->hDC, c->pt.x + pen_width + 1, y + bounds->top + DD(4),
NULL);
LineTo(c->hDC, c->pt.x + pen_width + 1, y + para->nHeight -
bounds->bottom - DD(8));
}
@@ -667,7 +662,7 @@ static void ME_DrawParaDecoration(ME_Context* c, ME_Paragraph* para,
int y, RECT
rc.right = rc.left + pen_width;
rc.top = y + bounds->top;
rc.bottom = y + para->nHeight - bounds->bottom;
- FillRect(c->hDC, &rc, c->editor->hbrBackground);
+ PatBlt(c->hDC, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top,
PATCOPY);
MoveToEx(c->hDC, rightEdge - 1 - pen_width - 1, y + bounds->top + DD(4),
NULL);
LineTo(c->hDC, rightEdge - 1 - pen_width - 1, y + para->nHeight -
bounds->bottom - DD(8));
}
@@ -731,9 +726,8 @@ static void ME_DrawTableBorders(ME_Context *c, ME_DisplayItem
*paragraph)
rc.top = top + width;
width = cell->yTextOffset - width;
rc.bottom = rc.top + width;
- if (width) {
- FillRect(c->hDC, &rc, c->editor->hbrBackground);
- }
+ if (width)
+ PatBlt(c->hDC, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top,
PATCOPY);
}
/* Draw cell borders.
* The order borders are draw in is left, top, bottom, right in order
@@ -901,13 +895,12 @@ static void ME_DrawTableBorders(ME_Context *c, ME_DisplayItem
*paragraph)
static void draw_para_number( ME_Context *c, ME_DisplayItem *p )
{
ME_Paragraph *para = &p->member.para;
- HFONT old_font;
int x, y;
COLORREF old_text;
if (para->fmt.wNumbering)
{
- old_font = ME_SelectStyleFont( c, para->para_num.style );
+ select_style( c, para->para_num.style );
old_text = SetTextColor( c->hDC, get_text_color( c, para->para_num.style,
FALSE ) );
x = c->pt.x + para->para_num.pt.x;
@@ -916,7 +909,6 @@ static void draw_para_number( ME_Context *c, ME_DisplayItem *p )
ExtTextOutW( c->hDC, x, y, 0, NULL, para->para_num.text->szData,
para->para_num.text->nLen, NULL );
SetTextColor( c->hDC, old_text );
- ME_UnselectStyleFont( c, para->para_num.style, old_font );
}
}
@@ -974,18 +966,18 @@ static void ME_DrawParagraph(ME_Context *c, ME_DisplayItem
*paragraph)
rc.bottom = y + p->member.row.nHeight;
}
visible = RectVisible(c->hDC, &rc);
- if (visible) {
- FillRect(c->hDC, &rc, c->editor->hbrBackground);
- }
+ if (visible)
+ PatBlt(c->hDC, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top,
PATCOPY);
if (bounds.right)
{
/* If scrolled to the right past the end of the text, then
* there may be space to the right of the paragraph border. */
- RECT rcAfterBrdr = rc;
- rcAfterBrdr.left = rc.right + bounds.right;
- rcAfterBrdr.right = c->rcView.right;
- if (RectVisible(c->hDC, &rcAfterBrdr))
- FillRect(c->hDC, &rcAfterBrdr, c->editor->hbrBackground);
+ RECT after_bdr = rc;
+ after_bdr.left = rc.right + bounds.right;
+ after_bdr.right = c->rcView.right;
+ if (RectVisible(c->hDC, &after_bdr))
+ PatBlt(c->hDC, after_bdr.left, after_bdr.top, after_bdr.right -
after_bdr.left,
+ after_bdr.bottom - after_bdr.top, PATCOPY);
}
if (me_debug)
{
@@ -1034,9 +1026,7 @@ static void ME_DrawParagraph(ME_Context *c, ME_DisplayItem
*paragraph)
rc.top = c->pt.y + para->pt.y + para->nHeight;
rc.bottom = c->pt.y + p->member.cell.pt.y + p->member.cell.nHeight;
if (RectVisible(c->hDC, &rc))
- {
- FillRect(c->hDC, &rc, c->editor->hbrBackground);
- }
+ PatBlt(c->hDC, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top,
PATCOPY);
break;
default:
break;
diff --git a/dll/win32/riched20/para.c b/dll/win32/riched20/para.c
index 6eec6b5906b..1ba2a7ac541 100644
--- a/dll/win32/riched20/para.c
+++ b/dll/win32/riched20/para.c
@@ -312,7 +312,7 @@ static ME_String *para_num_get_str( ME_Paragraph *para, WORD num )
{
case PFN_ARABIC:
default:
- p += sprintfW( p, fmtW, num );
+ p += swprintf( p, fmtW, num );
break;
case PFN_LCLETTER:
@@ -399,9 +399,9 @@ void para_num_init( ME_Context *c, ME_Paragraph *para )
static const WCHAR bullet_font[] =
{'S','y','m','b','o','l',0};
static const WCHAR bullet_str[] = {0xb7, 0};
static const WCHAR spaceW[] = {' ', 0};
- HFONT old_font;
SIZE sz;
+ if (!para->fmt.wNumbering) return;
if (para->para_num.style && para->para_num.text) return;
if (!para->para_num.style)
@@ -432,12 +432,11 @@ void para_num_init( ME_Context *c, ME_Paragraph *para )
para->para_num.text = ME_MakeStringConst( bullet_str, 1 );
}
- old_font = ME_SelectStyleFont( c, para->para_num.style );
+ select_style( c, para->para_num.style );
GetTextExtentPointW( c->hDC, para->para_num.text->szData,
para->para_num.text->nLen, &sz );
para->para_num.width = sz.cx;
GetTextExtentPointW( c->hDC, spaceW, 1, &sz );
para->para_num.width += sz.cx;
- ME_UnselectStyleFont( c, para->para_num.style, old_font );
}
void para_num_clear( struct para_num *pn )
diff --git a/dll/win32/riched20/precomp.h b/dll/win32/riched20/precomp.h
index b492ada0979..1e8a99192f2 100644
--- a/dll/win32/riched20/precomp.h
+++ b/dll/win32/riched20/precomp.h
@@ -2,8 +2,6 @@
#ifndef _RICHED20_PRECOMP_H
#define _RICHED20_PRECOMP_H
-#include <wine/config.h>
-
#define WIN32_NO_STATUS
#define _INC_WINDOWS
#define COM_NO_WINDOWS_H
diff --git a/dll/win32/riched20/richole.c b/dll/win32/riched20/richole.c
index 88ce7b6bfb0..3bfc4663a28 100644
--- a/dll/win32/riched20/richole.c
+++ b/dll/win32/riched20/richole.c
@@ -372,7 +372,7 @@ static inline BOOL is_equal_textfont_prop_value(enum textfont_prop_id
propid, te
case FONT_WEIGHT:
return left->l == right->l;
case FONT_NAME:
- return !strcmpW(left->str, right->str);
+ return !wcscmp(left->str, right->str);
case FONT_POSITION:
case FONT_SIZE:
case FONT_SPACING:
@@ -1399,6 +1399,16 @@ IRichEditOle_fnGetObject(IRichEditOle *me, LONG iob,
else
reobj = cursor.pRun->member.run.reobj;
}
+ else if (iob == REO_IOB_SELECTION)
+ {
+ ME_Cursor *from, *to;
+
+ ME_GetSelection(This->editor, &from, &to);
+ if (!from->pRun->member.run.reobj)
+ return E_INVALIDARG;
+ else
+ reobj = from->pRun->member.run.reobj;
+ }
else
{
if (iob > IRichEditOle_GetObjectCount(me))
@@ -1686,7 +1696,7 @@ static HRESULT WINAPI ITextRange_fnSetText(ITextRange *me, BSTR
str)
}
/* it's safer not to rely on stored BSTR length */
- len = strlenW(str);
+ len = lstrlenW(str);
cursor = editor->pCursors[0];
ME_CursorFromCharOfs(editor, This->start, &editor->pCursors[0]);
style = ME_GetInsertStyle(editor, 0);
@@ -2027,6 +2037,7 @@ static HRESULT WINAPI ITextRange_fnSetIndex(ITextRange *me, LONG
unit, LONG inde
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);
@@ -2146,7 +2157,7 @@ static HRESULT WINAPI ITextRange_fnSelect(ITextRange *me)
if (!This->child.reole)
return CO_E_RELEASED;
- ME_SetSelection(This->child.reole->editor, This->start, This->end);
+ set_selection(This->child.reole->editor, This->start, This->end);
return S_OK;
}
@@ -2506,6 +2517,10 @@ static HRESULT WINAPI ITextRange_fnScrollIntoView(ITextRange *me,
LONG value)
ME_CursorFromCharOfs(editor, This->start, &cursor);
ME_GetCursorCoordinates(editor, &cursor, &x, &y, &height);
break;
+ case tomEnd:
+ ME_CursorFromCharOfs(editor, This->end, &cursor);
+ ME_GetCursorCoordinates(editor, &cursor, &x, &y, &height);
+ break;
default:
FIXME("bStart value %d not handled\n", value);
return E_NOTIMPL;
@@ -2715,10 +2730,6 @@ 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;
}
@@ -2726,10 +2737,6 @@ 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;
}
@@ -2737,10 +2744,6 @@ 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;
}
@@ -2914,10 +2917,6 @@ 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;
}
@@ -2925,10 +2924,6 @@ 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;
}
@@ -4754,7 +4749,7 @@ static HRESULT WINAPI ITextSelection_fnSetText(ITextSelection *me,
BSTR str)
return CO_E_RELEASED;
editor = This->reOle->editor;
- len = strlenW(str);
+ len = lstrlenW(str);
ME_GetSelectionOfs(editor, &from, &to);
ME_ReplaceSel(editor, FALSE, str, len);
@@ -4866,7 +4861,7 @@ static HRESULT WINAPI ITextSelection_fnSetStart(ITextSelection *me,
LONG value)
ME_GetSelectionOfs(This->reOle->editor, &start, &end);
hr = textrange_setstart(This->reOle, value, &start, &end);
if (hr == S_OK)
- ME_SetSelection(This->reOle->editor, start, end);
+ set_selection(This->reOle->editor, start, end);
return hr;
}
@@ -4901,7 +4896,7 @@ static HRESULT WINAPI ITextSelection_fnSetEnd(ITextSelection *me,
LONG value)
ME_GetSelectionOfs(This->reOle->editor, &start, &end);
hr = textrange_setend(This->reOle, value, &start, &end);
if (hr == S_OK)
- ME_SetSelection(This->reOle->editor, start, end);
+ set_selection(This->reOle->editor, start, end);
return hr;
}
@@ -5020,7 +5015,7 @@ static HRESULT WINAPI ITextSelection_fnCollapse(ITextSelection *me,
LONG bStart)
ME_GetSelectionOfs(This->reOle->editor, &start, &end);
hres = range_Collapse(bStart, &start, &end);
if (SUCCEEDED(hres))
- ME_SetSelection(This->reOle->editor, start, end);
+ set_selection(This->reOle->editor, start, end);
return hres;
}
@@ -5712,7 +5707,7 @@ LRESULT CreateIRichEditOle(IUnknown *outer_unk, ME_TextEditor
*editor, LPVOID *p
reo->outer_unk = outer_unk;
else
reo->outer_unk = &reo->IUnknown_inner;
- *ppvObj = &reo->IRichEditOle_iface;
+ *ppvObj = &reo->IUnknown_inner;
return 1;
}
@@ -5932,9 +5927,3 @@ void ME_CopyReObject(REOBJECT *dst, const REOBJECT *src, DWORD
flags)
IOleClientSite_AddRef(dst->polesite);
}
}
-
-void ME_GetITextDocument2OldInterface(IRichEditOle *iface, LPVOID *ppvObj)
-{
- IRichEditOleImpl *This = impl_from_IRichEditOle(iface);
- *ppvObj = &This->ITextDocument2Old_iface;
-}
diff --git a/dll/win32/riched20/run.c b/dll/win32/riched20/run.c
index b9e1269fe8f..3912384451c 100644
--- a/dll/win32/riched20/run.c
+++ b/dll/win32/riched20/run.c
@@ -464,7 +464,6 @@ int ME_CharFromPointContext(ME_Context *c, int cx, ME_Run *run, BOOL
closest, BO
ME_String *mask_text = NULL;
WCHAR *str;
int fit = 0;
- HGDIOBJ hOldFont;
SIZE sz, sz2, sz3;
if (!run->len || cx <= 0)
return 0;
@@ -503,7 +502,7 @@ int ME_CharFromPointContext(ME_Context *c, int cx, ME_Run *run, BOOL
closest, BO
else
str = get_text( run, 0 );
- hOldFont = ME_SelectStyleFont(c, run->style);
+ select_style(c, run->style);
GetTextExtentExPointW(c->hDC, str, run->len,
cx, &fit, NULL, &sz);
if (closest && fit != run->len)
@@ -516,7 +515,6 @@ int ME_CharFromPointContext(ME_Context *c, int cx, ME_Run *run, BOOL
closest, BO
ME_DestroyString( mask_text );
- ME_UnselectStyleFont(c, run->style, hOldFont);
return fit;
}
@@ -538,15 +536,16 @@ int ME_CharFromPoint(ME_TextEditor *editor, int cx, ME_Run *run,
BOOL closest, B
*/
static void ME_GetTextExtent(ME_Context *c, LPCWSTR szText, int nChars, ME_Style *s, SIZE
*size)
{
- HGDIOBJ hOldFont;
- if (c->hDC) {
- hOldFont = ME_SelectStyleFont(c, s);
- GetTextExtentPoint32W(c->hDC, szText, nChars, size);
- ME_UnselectStyleFont(c, s, hOldFont);
- } else {
- size->cx = 0;
- size->cy = 0;
- }
+ if (c->hDC)
+ {
+ select_style( c, s );
+ GetTextExtentPoint32W( c->hDC, szText, nChars, size );
+ }
+ else
+ {
+ size->cx = 0;
+ size->cy = 0;
+ }
}
/******************************************************************************
@@ -867,7 +866,7 @@ void ME_GetCharFormat(ME_TextEditor *editor, const ME_Cursor *from,
{
if (!(tmp.dwMask & CFM_FACE))
pFmt->dwMask &= ~CFM_FACE;
- else if (lstrcmpW(pFmt->szFaceName, tmp.szFaceName) ||
+ else if (wcscmp(pFmt->szFaceName, tmp.szFaceName) ||
pFmt->bPitchAndFamily != tmp.bPitchAndFamily)
pFmt->dwMask &= ~CFM_FACE;
}
diff --git a/dll/win32/riched20/style.c b/dll/win32/riched20/style.c
index c3f3fc3f9a9..8b9c2126b1b 100644
--- a/dll/win32/riched20/style.c
+++ b/dll/win32/riched20/style.c
@@ -85,6 +85,8 @@ BOOL cf2w_to_cfany(CHARFORMAT2W *to, const CHARFORMAT2W *from)
CopyMemory(t, from, FIELD_OFFSET(CHARFORMATA, szFaceName));
WideCharToMultiByte(CP_ACP, 0, from->szFaceName, -1, t->szFaceName,
sizeof(t->szFaceName), NULL, NULL);
t->cbSize = sizeof(*t); /* it was overwritten by CopyMemory */
+ t->dwMask &= CFM_ALL;
+ t->dwEffects &= CFM_EFFECTS;
return TRUE;
}
if (to->cbSize == sizeof(CHARFORMATW))
@@ -92,6 +94,8 @@ BOOL cf2w_to_cfany(CHARFORMAT2W *to, const CHARFORMAT2W *from)
CHARFORMATW *t = (CHARFORMATW *)to;
CopyMemory(t, from, sizeof(*t));
t->cbSize = sizeof(*t); /* it was overwritten by CopyMemory */
+ t->dwMask &= CFM_ALL;
+ t->dwEffects &= CFM_EFFECTS;
return TRUE;
}
if (to->cbSize == sizeof(CHARFORMAT2A))
@@ -348,62 +352,11 @@ static BOOL ME_IsFontEqual(const LOGFONTW *p1, const LOGFONTW *p2)
{
if (memcmp(p1, p2, sizeof(LOGFONTW)-sizeof(p1->lfFaceName)))
return FALSE;
- if (lstrcmpW(p1->lfFaceName, p2->lfFaceName))
+ if (wcscmp(p1->lfFaceName, p2->lfFaceName))
return FALSE;
return TRUE;
}
-HFONT ME_SelectStyleFont(ME_Context *c, ME_Style *s)
-{
- HFONT hOldFont;
- LOGFONTW lf;
- int i, nEmpty, nAge = 0x7FFFFFFF;
- ME_FontCacheItem *item;
- assert(s);
-
- ME_LogFontFromStyle(c, &lf, s);
-
- for (i=0; i<HFONT_CACHE_SIZE; i++)
- c->editor->pFontCache[i].nAge++;
- for (i=0, nEmpty=-1, nAge=0; i<HFONT_CACHE_SIZE; i++)
- {
- item = &c->editor->pFontCache[i];
- if (!item->nRefs)
- {
- if (item->nAge > nAge)
- nEmpty = i, nAge = item->nAge;
- }
- if (item->hFont && ME_IsFontEqual(&item->lfSpecs, &lf))
- break;
- }
- if (i < HFONT_CACHE_SIZE) /* found */
- {
- item = &c->editor->pFontCache[i];
- TRACE_(richedit_style)("font reused %d\n", i);
- item->nRefs++;
- }
- else
- {
- item = &c->editor->pFontCache[nEmpty]; /* this legal even when nEmpty ==
-1, as we don't dereference it */
-
- assert(nEmpty != -1); /* otherwise we leak cache entries or get too many fonts at
once*/
- if (item->hFont) {
- TRACE_(richedit_style)("font deleted %d\n", nEmpty);
- DeleteObject(item->hFont);
- item->hFont = NULL;
- }
- item->hFont = CreateFontIndirectW(&lf);
- TRACE_(richedit_style)("font created %d\n", nEmpty);
- item->nRefs = 1;
- item->lfSpecs = lf;
- }
- s->font_cache = item;
- hOldFont = SelectObject(c->hDC, item->hFont);
- /* should be cached too, maybe ? */
- GetTextMetricsW(c->hDC, &s->tm);
- return hOldFont;
-}
-
static void release_font_cache(ME_FontCacheItem *item)
{
if (item->nRefs > 0)
@@ -413,11 +366,77 @@ static void release_font_cache(ME_FontCacheItem *item)
}
}
-void ME_UnselectStyleFont(ME_Context *c, ME_Style *s, HFONT hOldFont)
+void select_style( ME_Context *c, ME_Style *s )
{
- SelectObject(c->hDC, hOldFont);
- release_font_cache(s->font_cache);
- s->font_cache = NULL;
+ HFONT old_font;
+ LOGFONTW lf;
+ int i, empty, age = 0x7FFFFFFF;
+ ME_FontCacheItem *item;
+
+ if (c->current_style == s) return;
+
+ if (s)
+ {
+ ME_LogFontFromStyle( c, &lf, s );
+
+ for (i = 0; i < HFONT_CACHE_SIZE; i++)
+ c->editor->pFontCache[i].nAge++;
+ for (i = 0, empty = -1, age = 0; i < HFONT_CACHE_SIZE; i++)
+ {
+ item = &c->editor->pFontCache[i];
+ if (!item->nRefs)
+ {
+ if (item->nAge > age)
+ {
+ empty = i;
+ age = item->nAge;
+ }
+ }
+
+ if (item->hFont && ME_IsFontEqual( &item->lfSpecs, &lf
))
+ break;
+ }
+
+ if (i < HFONT_CACHE_SIZE) /* found */
+ {
+ item = &c->editor->pFontCache[i];
+ TRACE_(richedit_style)( "font reused %d\n", i );
+ item->nRefs++;
+ }
+ else
+ {
+ assert(empty != -1);
+ item = &c->editor->pFontCache[empty];
+ if (item->hFont)
+ {
+ TRACE_(richedit_style)( "font deleted %d\n", empty );
+ DeleteObject(item->hFont);
+ item->hFont = NULL;
+ }
+ item->hFont = CreateFontIndirectW( &lf );
+ TRACE_(richedit_style)( "font created %d\n", empty );
+ item->nRefs = 1;
+ item->lfSpecs = lf;
+ }
+ s->font_cache = item;
+ old_font = SelectObject( c->hDC, item->hFont );
+ GetTextMetricsW( c->hDC, &s->tm );
+ if (!c->orig_font) c->orig_font = old_font;
+ }
+ else
+ {
+ SelectObject( c->hDC, c->orig_font );
+ c->orig_font = NULL;
+ }
+
+ if (c->current_style)
+ {
+ release_font_cache( c->current_style->font_cache );
+ c->current_style->font_cache = NULL;
+ }
+ c->current_style = s;
+
+ return;
}
void ME_DestroyStyle(ME_Style *s)
diff --git a/dll/win32/riched20/table.c b/dll/win32/riched20/table.c
index 7e8d7ffacb3..1b4b9143d16 100644
--- a/dll/win32/riched20/table.c
+++ b/dll/win32/riched20/table.c
@@ -613,8 +613,7 @@ void ME_TabPressedInTable(ME_TextEditor *editor, BOOL bSelectedRow)
}
ME_InvalidateSelection(editor);
ME_Repaint(editor);
- ITextHost_TxShowCaret(editor->texthost, FALSE);
- ME_ShowCaret(editor);
+ update_caret(editor);
ME_SendSelChange(editor);
}
diff --git a/dll/win32/riched20/txthost.c b/dll/win32/riched20/txthost.c
index d709502a1ec..5cdb8c06fd1 100644
--- a/dll/win32/riched20/txthost.c
+++ b/dll/win32/riched20/txthost.c
@@ -18,9 +18,6 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
-#include "config.h"
-#include "wine/port.h"
-
#define COBJMACROS
#include "editor.h"
@@ -28,6 +25,7 @@
#include "richole.h"
#include "imm.h"
#include "textserv.h"
+#include "wine/asm.h"
#include "wine/debug.h"
#include "editstr.h"
@@ -497,37 +495,6 @@ DECLSPEC_HIDDEN HRESULT WINAPI
ITextHostImpl_TxGetSelectionBarWidth(ITextHost *i
*lSelBarWidth = (style & ES_SELECTIONBAR) ? 225 : 0; /* in HIMETRIC */
return S_OK;
}
-
-
-#ifdef __i386__ /* thiscall functions are i386-specific */
-
-#define THISCALL(func) (void *) __thiscall_ ## func
-#ifdef _MSC_VER
-#define DEFINE_THISCALL_WRAPPER(func,args) \
- __declspec(naked) HRESULT __thiscall_##func(void) \
- { \
- __asm pop eax \
- __asm push ecx \
- __asm push eax \
- __asm jmp func \
- }
-#else /* _MSC_VER */
-#define DEFINE_THISCALL_WRAPPER(func,args) \
- extern HRESULT __thiscall_ ## func(void); \
- __ASM_GLOBAL_FUNC(__thiscall_ ## func, \
- "popl %eax\n\t" \
- "pushl %ecx\n\t" \
- "pushl %eax\n\t" \
- "jmp " __ASM_NAME(#func) __ASM_STDCALL(args) )
-#endif /* _MSC_VER */
-
-#else /* __i386__ */
-
-#define THISCALL(func) func
-#define DEFINE_THISCALL_WRAPPER(func,args) /* nothing */
-
-#endif /* __i386__ */
-
DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetDC,4)
DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxReleaseDC,8)
DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxShowScrollBar,12)
@@ -568,7 +535,7 @@ DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxImmGetContext,4)
DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxImmReleaseContext,8)
DEFINE_THISCALL_WRAPPER(ITextHostImpl_TxGetSelectionBarWidth,8)
-#ifdef __i386__ /* thiscall functions are i386-specific */
+#if defined(__i386__) && !defined(__MINGW32__) /* thiscall functions are
i386-specific */
#define STDCALL(func) (void *) __stdcall_ ## func
#ifdef _MSC_VER
diff --git a/dll/win32/riched20/txtsrv.c b/dll/win32/riched20/txtsrv.c
index 73815fbbd1f..ca38f5c72a9 100644
--- a/dll/win32/riched20/txtsrv.c
+++ b/dll/win32/riched20/txtsrv.c
@@ -18,9 +18,6 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
-#include "config.h"
-#include "wine/port.h"
-
#define COBJMACROS
#include "editor.h"
@@ -30,38 +27,10 @@
#include "tom.h"
#include "imm.h"
#include "textserv.h"
+#include "wine/asm.h"
#include "wine/debug.h"
#include "editstr.h"
-#ifdef __i386__ /* thiscall functions are i386-specific */
-
-#define THISCALL(func) (void *) __thiscall_ ## func
-#ifdef _MSC_VER
-#define DEFINE_THISCALL_WRAPPER(func,args) \
- __declspec(naked) HRESULT __thiscall_##func(void) \
- { \
- __asm pop eax \
- __asm push ecx \
- __asm push eax \
- __asm jmp func \
- }
-#else /* _MSC_VER */
-#define DEFINE_THISCALL_WRAPPER(func,args) \
- extern HRESULT __thiscall_ ## func(void); \
- __ASM_GLOBAL_FUNC(__thiscall_ ## func, \
- "popl %eax\n\t" \
- "pushl %ecx\n\t" \
- "pushl %eax\n\t" \
- "jmp " __ASM_NAME(#func) __ASM_STDCALL(args) )
-#endif /* _MSC_VER */
-
-#else /* __i386__ */
-
-#define THISCALL(func) func
-#define DEFINE_THISCALL_WRAPPER(func,args) /* nothing */
-
-#endif /* __i386__ */
-
WINE_DEFAULT_DEBUG_CHANNEL(richedit);
typedef struct ITextServicesImpl {
@@ -95,10 +64,7 @@ static HRESULT WINAPI ITextServicesImpl_QueryInterface(IUnknown *iface,
REFIID r
if (!This->editor->reOle)
if (!CreateIRichEditOle(This->outer_unk, This->editor, (void
**)(&This->editor->reOle)))
return E_OUTOFMEMORY;
- if (IsEqualIID(riid, &IID_ITextDocument) || IsEqualIID(riid,
&IID_ITextDocument2Old))
- ME_GetITextDocument2OldInterface(This->editor->reOle, ppv);
- else
- *ppv = This->editor->reOle;
+ return IUnknown_QueryInterface(This->editor->reOle, riid, ppv);
} else {
*ppv = NULL;
FIXME("Unknown interface: %s\n", debugstr_guid(riid));
@@ -312,7 +278,7 @@ DECLSPEC_HIDDEN HRESULT WINAPI fnTextSrv_TxSetText(ITextServices
*iface, LPCWSTR
ME_InternalDeleteText(This->editor, &cursor, ME_GetTextLength(This->editor),
FALSE);
if(pszText)
ME_InsertTextFromCursor(This->editor, 0, pszText, -1,
This->editor->pBuffer->pDefaultStyle);
- ME_SetSelection(This->editor, 0, 0);
+ set_selection_cursors(This->editor, 0, 0);
This->editor->nModifyStep = 0;
OleFlushClipboard();
ME_EmptyUndoStack(This->editor);
diff --git a/dll/win32/riched20/wrap.c b/dll/win32/riched20/wrap.c
index a66137d42c9..c3b5883dbf1 100644
--- a/dll/win32/riched20/wrap.c
+++ b/dll/win32/riched20/wrap.c
@@ -65,7 +65,6 @@ static BOOL get_run_glyph_buffers( ME_Run *run )
static HRESULT shape_run( ME_Context *c, ME_Run *run )
{
HRESULT hr;
- HFONT old_font;
int i;
if (!run->glyphs)
@@ -82,7 +81,7 @@ static HRESULT shape_run( ME_Context *c, ME_Run *run )
run->clusters = heap_alloc( run->max_clusters * sizeof(WORD) );
}
- old_font = ME_SelectStyleFont( c, run->style );
+ select_style( c, run->style );
while (1)
{
hr = ScriptShape( c->hDC, &run->style->script_cache, get_text( run,
0 ), run->len, run->max_glyphs,
@@ -103,8 +102,6 @@ static HRESULT shape_run( ME_Context *c, ME_Run *run )
run->nWidth += run->advances[i];
}
- ME_UnselectStyleFont( c, run->style, old_font );
-
return hr;
}
diff --git a/dll/win32/riched20/writer.c b/dll/win32/riched20/writer.c
index 2bd97d8db25..94001ee44b2 100644
--- a/dll/win32/riched20/writer.c
+++ b/dll/win32/riched20/writer.c
@@ -18,9 +18,6 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
-#include "config.h"
-#include "wine/port.h"
-
#define NONAMELESSUNION
#include "editor.h"
@@ -123,17 +120,17 @@ ME_StreamOutMove(ME_OutStream *pStream, const char *buffer, int
len)
}
-static BOOL
+static BOOL WINAPIV
ME_StreamOutPrint(ME_OutStream *pStream, const char *format, ...)
{
char string[STREAMOUT_BUFFER_SIZE]; /* This is going to be enough */
int len;
- va_list valist;
+ __ms_va_list valist;
- va_start(valist, format);
+ __ms_va_start(valist, format);
len = vsnprintf(string, sizeof(string), format, valist);
- va_end(valist);
-
+ __ms_va_end(valist);
+
return ME_StreamOutMove(pStream, string, len);
}
@@ -245,7 +242,7 @@ static void add_font_to_fonttbl( ME_OutStream *stream, ME_Style *style
)
{
for (i = 0; i < stream->nFontTblLen; i++)
if (table[i].bCharSet == charset
- && (table[i].szFaceName == face || !lstrcmpW(table[i].szFaceName,
face)))
+ && (table[i].szFaceName == face || !wcscmp(table[i].szFaceName,
face)))
break;
if (i == stream->nFontTblLen && i < STREAMOUT_FONTTBL_SIZE)
@@ -270,7 +267,7 @@ static BOOL find_font_in_fonttbl( ME_OutStream *stream, CHARFORMAT2W
*fmt, unsig
for (i = 0; i < stream->nFontTblLen; i++)
{
if (facename == stream->fonttbl[i].szFaceName
- || !lstrcmpW(facename, stream->fonttbl[i].szFaceName))
+ || !wcscmp(facename, stream->fonttbl[i].szFaceName))
if (!(fmt->dwMask & CFM_CHARSET)
|| fmt->bCharSet == stream->fonttbl[i].bCharSet)
{
@@ -841,7 +838,7 @@ ME_StreamOutRTFCharProps(ME_OutStream *pStream, CHARFORMAT2W *fmt)
}
}
- if (strcmpW(old_fmt->szFaceName, fmt->szFaceName) ||
+ if (wcscmp(old_fmt->szFaceName, fmt->szFaceName) ||
old_fmt->bCharSet != fmt->bCharSet)
{
if (find_font_in_fonttbl( pStream, fmt, &i ))
diff --git a/media/doc/README.WINE b/media/doc/README.WINE
index ab56c63fc48..b390f9e7bbc 100644
--- a/media/doc/README.WINE
+++ b/media/doc/README.WINE
@@ -159,7 +159,7 @@ dll/win32/qmgrprxy # Synced to WineStaging-2.9
dll/win32/query # Synced to WineStaging-4.18
dll/win32/rasapi32 # Synced to WineStaging-3.3
dll/win32/resutils # Synced to WineStaging-3.3
-dll/win32/riched20 # Synced to WineStaging-4.0
+dll/win32/riched20 # Synced to WineStaging-4.18
dll/win32/riched32 # Synced to WineStaging-3.3
dll/win32/rpcrt4 # Synced to WineStaging-4.0
dll/win32/rsabase # Synced to WineStaging-3.3