[RICHED20] Sync with Wine 3.0. CORE-14225
authorAmine Khaldi <amine.khaldi@reactos.org>
Sat, 20 Jan 2018 12:09:57 +0000 (13:09 +0100)
committerAmine Khaldi <amine.khaldi@reactos.org>
Sat, 20 Jan 2018 12:09:57 +0000 (13:09 +0100)
dll/win32/riched20/caret.c
dll/win32/riched20/editor.c
dll/win32/riched20/editor.h
dll/win32/riched20/ocr_reverse.cur
dll/win32/riched20/paint.c
dll/win32/riched20/richole.c
dll/win32/riched20/run.c
dll/win32/riched20/table.c
media/doc/README.WINE

index 26af743..8a99394 100644 (file)
@@ -551,6 +551,10 @@ void ME_InsertTextFromCursor(ME_TextEditor *editor, int nCursor,
       ME_DisplayItem *tp, *end_run, *run, *prev;
       int eol_len = 0;
 
+      /* Check if new line is allowed for this control */
+      if (!(editor->styleFlags & ES_MULTILINE))
+        break;
+
       /* Find number of CR and LF in end of paragraph run */
       if (*pos =='\r')
       {
index 645d06c..20ffb0c 100644 (file)
   + ES_DISABLENOSCROLL (scrollbar is always visible)
   - ES_EX_NOCALLOLEINIT
   + ES_LEFT
-  - ES_MULTILINE (currently single line controls aren't supported)
+  + ES_MULTILINE
   - ES_NOIME
   - ES_READONLY (I'm not sure if beeping is the proper behaviour)
   + ES_RIGHT
@@ -2291,6 +2291,14 @@ static BOOL paste_special(ME_TextEditor *editor, UINT cf, REPASTESPECIAL *ps, BO
     struct paste_format *format;
     IDataObject *data;
 
+    /* Protect read-only edit control from modification */
+    if (editor->styleFlags & ES_READONLY)
+    {
+        if (!check_only)
+            MessageBeep(MB_ICONERROR);
+        return FALSE;
+    }
+
     init_paste_formats();
 
     if (ps && ps->dwAspect != DVASPECT_CONTENT)
@@ -2348,6 +2356,30 @@ static BOOL ME_Copy(ME_TextEditor *editor, const ME_Cursor *start, int nChars)
   return SUCCEEDED(hr);
 }
 
+static BOOL copy_or_cut(ME_TextEditor *editor, BOOL cut)
+{
+    BOOL result;
+    int offs, num_chars;
+    int start_cursor = ME_GetSelectionOfs(editor, &offs, &num_chars);
+    ME_Cursor *sel_start = &editor->pCursors[start_cursor];
+
+    if (cut && (editor->styleFlags & ES_READONLY))
+    {
+        MessageBeep(MB_ICONERROR);
+        return FALSE;
+    }
+
+    num_chars -= offs;
+    result = ME_Copy(editor, sel_start, num_chars);
+    if (result && cut)
+    {
+        ME_InternalDeleteText(editor, sel_start, num_chars, FALSE);
+        ME_CommitUndo(editor);
+        ME_UpdateRepaint(editor, TRUE);
+    }
+    return result;
+}
+
 /* helper to send a msg filter notification */
 static BOOL
 ME_FilterEvent(ME_TextEditor *editor, UINT msg, WPARAM* wParam, LPARAM* lParam)
@@ -2642,22 +2674,7 @@ ME_KeyDown(ME_TextEditor *editor, WORD nKey)
     case 'C':
     case 'X':
       if (ctrl_is_down)
-      {
-        BOOL result;
-        int nOfs, nChars;
-        int nStartCur = ME_GetSelectionOfs(editor, &nOfs, &nChars);
-        ME_Cursor *selStart = &editor->pCursors[nStartCur];
-
-        nChars -= nOfs;
-        result = ME_Copy(editor, selStart, nChars);
-        if (result && nKey == 'X')
-        {
-          ME_InternalDeleteText(editor, selStart, nChars, FALSE);
-          ME_CommitUndo(editor);
-          ME_UpdateRepaint(editor, TRUE);
-        }
-        return result;
-      }
+        return copy_or_cut(editor, nKey == 'X');
       break;
     case 'Z':
       if (ctrl_is_down)
@@ -3401,21 +3418,7 @@ static void ME_SetText(ME_TextEditor *editor, void *text, BOOL unicode)
   int textLen;
 
   LPWSTR wszText = ME_ToUnicode(codepage, text, &textLen);
-
-  if (textLen > 0)
-  {
-    int len = -1;
-
-    /* uses default style! */
-    if (!(editor->styleFlags & ES_MULTILINE))
-    {
-      WCHAR *p = wszText;
-
-      while (*p != '\0' && *p != '\r' && *p != '\n') p++;
-      len = p - wszText;
-    }
-    ME_InsertTextFromCursor(editor, 0, wszText, len, editor->pBuffer->pDefaultStyle);
-  }
+  ME_InsertTextFromCursor(editor, 0, wszText, textLen, editor->pBuffer->pDefaultStyle);
   ME_EndToUnicode(codepage, wszText);
 }
 
@@ -4065,19 +4068,8 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam,
     return 0;
   case WM_CUT:
   case WM_COPY:
-  {
-    int nFrom, nTo, nStartCur = ME_GetSelectionOfs(editor, &nFrom, &nTo);
-    int nChars = nTo - nFrom;
-    ME_Cursor *selStart = &editor->pCursors[nStartCur];
-
-    if (ME_Copy(editor, selStart, nChars) && msg == WM_CUT)
-    {
-      ME_InternalDeleteText(editor, selStart, nChars, FALSE);
-      ME_CommitUndo(editor);
-      ME_UpdateRepaint(editor, TRUE);
-    }
+    copy_or_cut(editor, msg == WM_CUT);
     return 0;
-  }
   case WM_GETTEXTLENGTH:
   {
     GETTEXTLENGTHEX how;
index 9599a3e..8da0ed9 100644 (file)
@@ -283,7 +283,7 @@ int ME_GetParaBorderWidth(const ME_Context *c, int flags) DECLSPEC_HIDDEN;
 
 /* richole.c */
 LRESULT CreateIRichEditOle(IUnknown *outer_unk, ME_TextEditor *editor, LPVOID *ppvObj) DECLSPEC_HIDDEN;
-void ME_DrawOLE(ME_Context *c, int x, int y, ME_Run* run, ME_Paragraph *para, BOOL selected) DECLSPEC_HIDDEN;
+void ME_DrawOLE(ME_Context *c, int x, int y, ME_Run* run, BOOL selected) DECLSPEC_HIDDEN;
 void ME_GetOLEObjectSize(const ME_Context *c, ME_Run *run, SIZE *pSize) DECLSPEC_HIDDEN;
 void ME_CopyReObject(REOBJECT* dst, const REOBJECT* src) DECLSPEC_HIDDEN;
 void ME_DeleteReObject(REOBJECT* reo) DECLSPEC_HIDDEN;
index f6b5ca2..6392093 100644 (file)
Binary files a/dll/win32/riched20/ocr_reverse.cur and b/dll/win32/riched20/ocr_reverse.cur differ
index 41b3896..b4b6697 100644 (file)
@@ -481,7 +481,7 @@ static void ME_DrawRun(ME_Context *c, int x, int y, ME_DisplayItem *rundi, ME_Pa
   }
 
   if (run->nFlags & MERF_GRAPHICS)
-    ME_DrawOLE(c, x, y, run, para, (runofs >= nSelFrom) && (runofs < nSelTo));
+    ME_DrawOLE(c, x, y, run, (runofs >= nSelFrom) && (runofs < nSelTo));
   else
   {
     ME_DrawTextWithStyle(c, run, x, y, nSelFrom - runofs, nSelTo - runofs,
index 2507b77..b04b6b1 100644 (file)
@@ -936,14 +936,6 @@ 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;   
@@ -1979,23 +1971,6 @@ 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);
@@ -2005,13 +1980,7 @@ static HRESULT WINAPI ITextRange_fnSetRange(ITextRange *me, LONG anchor, LONG ac
     if (!This->child.reole)
         return CO_E_RELEASED;
 
-    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;
+    return E_NOTIMPL;
 }
 
 static HRESULT textrange_inrange(LONG start, LONG end, ITextRange *range, LONG *ret)
@@ -2624,10 +2593,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;
 }
 
@@ -2635,10 +2600,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;
 }
 
@@ -2646,10 +2607,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;
 }
 
@@ -2823,10 +2780,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;
 }
 
@@ -2834,10 +2787,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;
 }
 
@@ -3344,16 +3293,6 @@ 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);
@@ -3421,10 +3360,6 @@ 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;
 }
 
@@ -3432,10 +3367,6 @@ 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;
 }
 
@@ -3443,10 +3374,6 @@ 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;
 }
 
@@ -3454,10 +3381,6 @@ 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;
 }
 
@@ -3465,10 +3388,6 @@ 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;
 }
 
@@ -3476,10 +3395,6 @@ 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;
 }
 
@@ -3487,23 +3402,13 @@ 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);
-    static int once;
-
-    if (!once++) FIXME("(%p)->(%p)\n", This, value);
-
-    if (!para_get_reole(This))
-        return CO_E_RELEASED;
-
+    FIXME("(%p)->(%p)\n", This, value);
     return E_NOTIMPL;
 }
 
@@ -3511,10 +3416,6 @@ 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;
 }
 
@@ -3522,10 +3423,6 @@ 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;
 }
 
@@ -3533,10 +3430,6 @@ 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;
 }
 
@@ -3544,10 +3437,6 @@ 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;
 }
 
@@ -3555,10 +3444,6 @@ 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;
 }
 
@@ -3566,10 +3451,6 @@ 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;
 }
 
@@ -3577,10 +3458,6 @@ 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;
 }
 
@@ -3588,10 +3465,6 @@ 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;
 }
 
@@ -3599,10 +3472,6 @@ 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;
 }
 
@@ -3610,10 +3479,6 @@ 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;
 }
 
@@ -3621,10 +3486,6 @@ 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;
 }
 
@@ -3632,10 +3493,6 @@ 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;
 }
 
@@ -3643,10 +3500,6 @@ 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;
 }
 
@@ -3654,10 +3507,6 @@ 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;
 }
 
@@ -3665,10 +3514,6 @@ 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;
 }
 
@@ -3676,10 +3521,6 @@ 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;
 }
 
@@ -3687,10 +3528,6 @@ 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;
 }
 
@@ -3698,10 +3535,6 @@ 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;
 }
 
@@ -3709,10 +3542,6 @@ 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;
 }
 
@@ -3720,10 +3549,6 @@ 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;
 }
 
@@ -3731,10 +3556,6 @@ 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;
 }
 
@@ -3742,10 +3563,6 @@ 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;
 }
 
@@ -3753,10 +3570,6 @@ 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;
 }
 
@@ -3764,10 +3577,6 @@ 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;
 }
 
@@ -3775,10 +3584,6 @@ 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;
 }
 
@@ -3786,10 +3591,6 @@ 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;
 }
 
@@ -3797,10 +3598,6 @@ 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;
 }
 
@@ -3808,10 +3605,6 @@ 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;
 }
 
@@ -3819,10 +3612,6 @@ 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;
 }
 
@@ -3830,10 +3619,6 @@ 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;
 }
 
@@ -3841,10 +3626,6 @@ 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;
 }
 
@@ -3852,10 +3633,6 @@ 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;
 }
 
@@ -3863,10 +3640,6 @@ 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;
 }
 
@@ -3874,10 +3647,6 @@ 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;
 }
 
@@ -3885,10 +3654,6 @@ 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;
 }
 
@@ -3896,10 +3661,6 @@ 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;
 }
 
@@ -3907,10 +3668,6 @@ 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;
 }
 
@@ -3918,10 +3675,6 @@ 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;
 }
 
@@ -3929,10 +3682,6 @@ 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;
 }
 
@@ -3940,10 +3689,6 @@ 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;
 }
 
@@ -4282,12 +4027,26 @@ 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;
 
-    cp2range(This->editor, &cp1, &cp2);
+    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;
+
     return CreateITextRange(This, cp1, cp2, ppRange);
 }
 
@@ -5484,6 +5243,7 @@ void ME_GetOLEObjectSize(const ME_Context *c, ME_Run *run, SIZE *pSize)
       return;
     }
   }
+  IDataObject_Release(ido);
 
   switch (stgm.tymed)
   {
@@ -5491,19 +5251,17 @@ void ME_GetOLEObjectSize(const ME_Context *c, ME_Run *run, SIZE *pSize)
     GetObjectW(stgm.u.hBitmap, sizeof(dibsect), &dibsect);
     pSize->cx = dibsect.dsBm.bmWidth;
     pSize->cy = dibsect.dsBm.bmHeight;
-    if (!stgm.pUnkForRelease) DeleteObject(stgm.u.hBitmap);
     break;
   case TYMED_ENHMF:
     GetEnhMetaFileHeader(stgm.u.hEnhMetaFile, sizeof(emh), &emh);
     pSize->cx = emh.rclBounds.right - emh.rclBounds.left;
     pSize->cy = emh.rclBounds.bottom - emh.rclBounds.top;
-    if (!stgm.pUnkForRelease) DeleteEnhMetaFile(stgm.u.hEnhMetaFile);
     break;
   default:
     FIXME("Unsupported tymed %d\n", stgm.tymed);
     break;
   }
-  IDataObject_Release(ido);
+  ReleaseStgMedium(&stgm);
   if (c->editor->nZoomNumerator != 0)
   {
     pSize->cx = MulDiv(pSize->cx, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
@@ -5511,8 +5269,7 @@ void ME_GetOLEObjectSize(const ME_Context *c, ME_Run *run, SIZE *pSize)
   }
 }
 
-void ME_DrawOLE(ME_Context *c, int x, int y, ME_Run *run,
-                ME_Paragraph *para, BOOL selected)
+void ME_DrawOLE(ME_Context *c, int x, int y, ME_Run *run, BOOL selected)
 {
   IDataObject*  ido;
   FORMATETC     fmt;
@@ -5522,6 +5279,8 @@ void ME_DrawOLE(ME_Context *c, int x, int y, ME_Run *run,
   HDC           hMemDC;
   SIZE          sz;
   BOOL          has_size;
+  HBITMAP       old_bm;
+  RECT          rc;
 
   assert(run->nFlags & MERF_GRAPHICS);
   assert(run->ole_obj);
@@ -5547,36 +5306,31 @@ void ME_DrawOLE(ME_Context *c, int x, int y, ME_Run *run,
       return;
     }
   }
+  IDataObject_Release(ido);
+
   switch (stgm.tymed)
   {
   case TYMED_GDI:
     GetObjectW(stgm.u.hBitmap, sizeof(dibsect), &dibsect);
     hMemDC = CreateCompatibleDC(c->hDC);
-    SelectObject(hMemDC, stgm.u.hBitmap);
+    old_bm = SelectObject(hMemDC, stgm.u.hBitmap);
     if (has_size)
     {
       convert_sizel(c, &run->ole_obj->sizel, &sz);
     } else {
-      sz.cx = MulDiv(dibsect.dsBm.bmWidth, c->dpi.cx, 96);
-      sz.cy = MulDiv(dibsect.dsBm.bmHeight, c->dpi.cy, 96);
+      sz.cx = dibsect.dsBm.bmWidth;
+      sz.cy = dibsect.dsBm.bmHeight;
     }
     if (c->editor->nZoomNumerator != 0)
     {
       sz.cx = MulDiv(sz.cx, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
       sz.cy = MulDiv(sz.cy, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
     }
-    if (sz.cx == dibsect.dsBm.bmWidth && sz.cy == dibsect.dsBm.bmHeight)
-    {
-      BitBlt(c->hDC, x, y - sz.cy,
-             dibsect.dsBm.bmWidth, dibsect.dsBm.bmHeight,
-             hMemDC, 0, 0, SRCCOPY);
-    } else {
-      StretchBlt(c->hDC, x, y - sz.cy, sz.cx, sz.cy,
-                 hMemDC, 0, 0, dibsect.dsBm.bmWidth,
-                 dibsect.dsBm.bmHeight, SRCCOPY);
-    }
+    StretchBlt(c->hDC, x, y - sz.cy, sz.cx, sz.cy,
+               hMemDC, 0, 0, dibsect.dsBm.bmWidth, dibsect.dsBm.bmHeight, SRCCOPY);
+
+    SelectObject(hMemDC, old_bm);
     DeleteDC(hMemDC);
-    if (!stgm.pUnkForRelease) DeleteObject(stgm.u.hBitmap);
     break;
   case TYMED_ENHMF:
     GetEnhMetaFileHeader(stgm.u.hEnhMetaFile, sizeof(emh), &emh);
@@ -5584,8 +5338,8 @@ void ME_DrawOLE(ME_Context *c, int x, int y, ME_Run *run,
     {
       convert_sizel(c, &run->ole_obj->sizel, &sz);
     } else {
-      sz.cy = MulDiv(emh.rclBounds.bottom - emh.rclBounds.top, c->dpi.cx, 96);
-      sz.cx = MulDiv(emh.rclBounds.right - emh.rclBounds.left, c->dpi.cy, 96);
+      sz.cx = emh.rclBounds.right - emh.rclBounds.left;
+      sz.cy = emh.rclBounds.bottom - emh.rclBounds.top;
     }
     if (c->editor->nZoomNumerator != 0)
     {
@@ -5593,25 +5347,21 @@ void ME_DrawOLE(ME_Context *c, int x, int y, ME_Run *run,
       sz.cy = MulDiv(sz.cy, c->editor->nZoomNumerator, c->editor->nZoomDenominator);
     }
 
-    {
-      RECT    rc;
-
-      rc.left = x;
-      rc.top = y - sz.cy;
-      rc.right = x + sz.cx;
-      rc.bottom = y;
-      PlayEnhMetaFile(c->hDC, stgm.u.hEnhMetaFile, &rc);
-    }
-    if (!stgm.pUnkForRelease) DeleteEnhMetaFile(stgm.u.hEnhMetaFile);
+    rc.left = x;
+    rc.top = y - sz.cy;
+    rc.right = x + sz.cx;
+    rc.bottom = y;
+    PlayEnhMetaFile(c->hDC, stgm.u.hEnhMetaFile, &rc);
     break;
   default:
     FIXME("Unsupported tymed %d\n", stgm.tymed);
     selected = FALSE;
     break;
   }
+  ReleaseStgMedium(&stgm);
+
   if (selected && !c->editor->bHideSelection)
     PatBlt(c->hDC, x, y - sz.cy, sz.cx, sz.cy, DSTINVERT);
-  IDataObject_Release(ido);
 }
 
 void ME_DeleteReObject(REOBJECT* reo)
index 445bbc2..098c4f8 100644 (file)
@@ -185,10 +185,9 @@ 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, len);
+  nCharOfs = min(nCharOfs, ME_GetTextLength(editor));
 
   /* Find the paragraph at the offset. */
   next_item = editor->pBuffer->pFirst->member.para.next_para;
@@ -211,11 +210,7 @@ void ME_RunOfsFromCharOfs(ME_TextEditor *editor,
   nCharOfs -= item->member.run.nCharOfs;
 
   if (ppRun) *ppRun = item;
-  if (pOfs) {
-    if (((*ppRun)->member.run.nFlags & MERF_ENDPARA) && endOfs > len)
-      *pOfs = (*ppRun)->member.run.len;
-    else *pOfs = nCharOfs;
-  }
+  if (pOfs) *pOfs = nCharOfs;
 }
 
 /******************************************************************************
index b834bc7..d2cab9a 100644 (file)
@@ -400,7 +400,7 @@ void ME_ProtectPartialTableDeletion(ME_TextEditor *editor, ME_Cursor *c, int *nC
       }
     }
     if (*nChars < 0)
-      nChars = 0;
+      *nChars = 0;
   }
 }
 
index a30fea9..4b6fadf 100644 (file)
@@ -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.16
+reactos/dll/win32/riched20            # Synced to Wine-3.0
 reactos/dll/win32/riched32            # Synced to WineStaging-2.9
 reactos/dll/win32/rpcrt4              # Synced to WineStaging-2.16
 reactos/dll/win32/rsabase             # Synced to WineStaging-2.9