Sync to Wine-20050524:
Alexandre Julliard <julliard@winehq.org>
- Added rules for building import libraries in the individual dll
  makefiles, and added support for building a .def.a static import
  library too.
Ivan Leo Puoti <ivanleo@gmail.com>
- Fix crash in ME_GetRunSizeCommon(). Turn a FIXME into a TRACE.
Michael Stefaniuc <mstefani@redhat.de>
- Change an assert to a WARN.
Hannu Valtonen <Hannu.Valtonen@hut.fi>
- Use correct background color for the whole richedit control.
- Implement EM_LINESCROLL message handling
- Fix a problem with scrolling over the end of the text in
  WM_WHEELMOUSE.
Vincent Beron <vberon@mecano.gme.usherb.ca>
- Provide minimal API documentation in advapi/eventlog.c to silence some
  winapi_check output.
- Move around functions in riched20, richedit and rpcrt4 to achieve the
  same goal.
Krzysztof Foltman <wdev@foltman.com>
- Added stubs for a couple of missing 2.0 and 3.0 messages.
Phil Krylov <phil@newstar.rinet.ru>
- Fixed an error in my previous commit which caused an infinite loop in
  IE6 installer.
Modified: trunk/reactos/lib/riched20/Makefile.in
Modified: trunk/reactos/lib/riched20/editor.c
Modified: trunk/reactos/lib/riched20/paint.c
Modified: trunk/reactos/lib/riched20/run.c
Modified: trunk/reactos/lib/riched20/style.c

Modified: trunk/reactos/lib/riched20/Makefile.in
--- trunk/reactos/lib/riched20/Makefile.in	2005-05-28 12:43:26 UTC (rev 15577)
+++ trunk/reactos/lib/riched20/Makefile.in	2005-05-28 14:40:26 UTC (rev 15578)
@@ -3,6 +3,7 @@
 SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = riched20.dll
+IMPORTLIB = libriched20.$(IMPLIBEXT)
 IMPORTS   = user32 gdi32 kernel32
 EXTRALIBS = -luuid
 

Modified: trunk/reactos/lib/riched20/editor.c
--- trunk/reactos/lib/riched20/editor.c	2005-05-28 12:43:26 UTC (rev 15577)
+++ trunk/reactos/lib/riched20/editor.c	2005-05-28 14:40:26 UTC (rev 15578)
@@ -38,7 +38,10 @@
   - EM_FINDWORDBREAK
   - EM_FMTLINES
   - EM_FORMATRANGE
+  - EM_GETAUTOURLDETECT 2.0
+  - EM_GETBIDIOPTIONS 3.0
   - EM_GETCHARFORMAT (partly done)
+  - EM_GETEDITSTYLE
   + EM_GETEVENTMASK
   - EM_GETFIRSTVISIBLELINE
   - EM_GETIMECOLOR 1.0asian
@@ -53,24 +56,30 @@
   - EM_GETOLEINTERFACE
   - EM_GETOPTIONS
   + EM_GETPARAFORMAT
+  - EM_GETPASSWORDCHAR 2.0
   - EM_GETPUNCTUATION 1.0asian
   - EM_GETRECT
   - EM_GETREDONAME 2.0
   + EM_GETSEL
   + EM_GETSELTEXT (ANSI&Unicode)
+  - EM_GETSCROLLPOS 3.0
 ! - EM_GETTHUMB
+  - EM_GETTEXTEX 2.0
+  - EM_GETTEXTLENGTHEX
   - EM_GETTEXTMODE 2.0
 ? + EM_GETTEXTRANGE (ANSI&Unicode)
+  - EM_GETTYPOGRAPHYOPTIONS 3.0
   - EM_GETUNDONAME
   - EM_GETWORDBREAKPROC
   - EM_GETWORDBREAKPROCEX
   - EM_GETWORDWRAPMODE 1.0asian
+  - EM_SETZOOM 3.0
   - EM_HIDESELECTION
   - EM_LIMITTEXT
   - EM_LINEFROMCHAR
   - EM_LINEINDEX
   - EM_LINELENGTH
-  - EM_LINESCROLL
+  + EM_LINESCROLL
   - EM_PASTESPECIAL
   - EM_POSFROMCHARS
   + EM_REDO 2.0
@@ -79,9 +88,12 @@
   - EM_SCROLL
   - EM_SCROLLCARET
   - EM_SELECTIONTYPE
+  - EM_SETBIDIOPTIONS 3.0
   + EM_SETBKGNDCOLOR
   - EM_SETCHARFORMAT (partly done, no ANSI)
+  - EM_SETEDITSTYLE
   + EM_SETEVENTMASK (few notifications supported)
+  - EM_SETFONTSIZE
   - EM_SETIMECOLOR 1.0asian
   - EM_SETIMEOPTIONS 1.0asian
   - EM_SETLANGOPTIONS 2.0
@@ -89,18 +101,26 @@
   + EM_SETMODIFY (not sure if implementation is correct)
   - EM_SETOLECALLBACK
   - EM_SETOPTIONS
+  - EM_SETPALETTE 2.0
   + EM_SETPARAFORMAT
+  - EM_SETPASSWORDCHAR 2.0
   - EM_SETPUNCTUATION 1.0asian
   + EM_SETREADONLY no beep on modification attempt
   - EM_SETRECT
   - EM_SETRECTNP (EM_SETRECT without repainting) - not supported in RICHEDIT
   + EM_SETSEL
+  - EM_SETSCROLLPOS 3.0
+  - EM_SETTABSTOPS 3.0
   - EM_SETTARGETDEVICE
+  - EM_SETTEXTEX 3.0
   - EM_SETTEXTMODE 2.0
+  - EM_SETTYPOGRAPHYOPTIONS 3.0
   - EM_SETUNDOLIMIT 2.0
   - EM_SETWORDBREAKPROC
   - EM_SETWORDBREAKPROCEX
   - EM_SETWORDWRAPMODE 1.0asian
+  - EM_SETZOOM 3.0
+  - EM_SHOWSCROLLBAR 2.0
   - EM_STOPGROUPTYPING 2.0
   + EM_STREAMIN (can't fall back to text when the RTF isn't really RTF)
   + EM_STREAMOUT
@@ -268,6 +288,7 @@
     ME_InsertTextFromCursor(editor, 0, pText, nWideChars, style);
     if (stream->dwSize < STREAMIN_BUFFER_SIZE)
       break;
+    stream->dwSize = 0;
   } while(1);
   ME_CommitUndo(editor);
   ME_Repaint(editor);
@@ -485,7 +506,7 @@
   int nEventMask = editor->nEventMask;
   ME_InStream inStream;
 
-  TRACE("%p %p\n", stream, editor->hWnd);
+  TRACE("stream==%p hWnd==%p format==0x%X\n", stream, editor->hWnd, (UINT)format);
   editor->nEventMask = 0;
   
   ME_GetSelection(editor, &from, &to);
@@ -740,6 +761,33 @@
   FREE_OBJ(editor);
 }
 
+static WCHAR wszClassName[] = {'R', 'i', 'c', 'h', 'E', 'd', 'i', 't', '2', '0', 'W', 0};
+static WCHAR wszClassName50[] = {'R', 'i', 'c', 'h', 'E', 'd', 'i', 't', '5', '0', 'W', 0};
+
+BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
+{
+    TRACE("\n");
+    switch (fdwReason)
+    {
+    case DLL_PROCESS_ATTACH:
+      DisableThreadLibraryCalls(hinstDLL);
+      me_heap = HeapCreate (0, 0x10000, 0);
+      ME_RegisterEditorClass(hinstDLL);
+      break;
+
+    case DLL_PROCESS_DETACH:
+      UnregisterClassW(wszClassName, 0);
+      UnregisterClassW(wszClassName50, 0);
+      UnregisterClassA("RichEdit20A", 0);
+      UnregisterClassA("RichEdit50A", 0);
+      HeapDestroy (me_heap);
+      me_heap = NULL;
+      break;
+    }
+    return TRUE;
+}
+
+
 #define UNSUPPORTED_MSG(e) \
   case e: \
     FIXME(#e ": stub\n"); \
@@ -766,6 +814,9 @@
   UNSUPPORTED_MSG(EM_FINDWORDBREAK)
   UNSUPPORTED_MSG(EM_FMTLINES)
   UNSUPPORTED_MSG(EM_FORMATRANGE)
+  UNSUPPORTED_MSG(EM_GETAUTOURLDETECT)
+  UNSUPPORTED_MSG(EM_GETBIDIOPTIONS)
+  UNSUPPORTED_MSG(EM_GETEDITSTYLE)
   UNSUPPORTED_MSG(EM_GETFIRSTVISIBLELINE)
   UNSUPPORTED_MSG(EM_GETIMECOMPMODE)
   /* UNSUPPORTED_MSG(EM_GETIMESTATUS) missing in Wine headers */
@@ -775,34 +826,50 @@
   UNSUPPORTED_MSG(EM_GETLINECOUNT)
   /* UNSUPPORTED_MSG(EM_GETOLEINTERFACE) separate stub */
   UNSUPPORTED_MSG(EM_GETOPTIONS)
+  UNSUPPORTED_MSG(EM_GETPASSWORDCHAR)
   UNSUPPORTED_MSG(EM_GETRECT)
   UNSUPPORTED_MSG(EM_GETREDONAME)
+  UNSUPPORTED_MSG(EM_GETSCROLLPOS)
+  UNSUPPORTED_MSG(EM_GETTEXTEX)
+  UNSUPPORTED_MSG(EM_GETTEXTLENGTHEX)
   UNSUPPORTED_MSG(EM_GETTEXTMODE)
+  UNSUPPORTED_MSG(EM_GETTYPOGRAPHYOPTIONS)
   UNSUPPORTED_MSG(EM_GETUNDONAME)
   UNSUPPORTED_MSG(EM_GETWORDBREAKPROC)
   UNSUPPORTED_MSG(EM_GETWORDBREAKPROCEX)
+  UNSUPPORTED_MSG(EM_GETZOOM)
   UNSUPPORTED_MSG(EM_HIDESELECTION)
   UNSUPPORTED_MSG(EM_LIMITTEXT) /* also known as EM_SETLIMITTEXT */
   UNSUPPORTED_MSG(EM_LINEFROMCHAR)
   UNSUPPORTED_MSG(EM_LINEINDEX)
   UNSUPPORTED_MSG(EM_LINELENGTH)
-  UNSUPPORTED_MSG(EM_LINESCROLL)
   UNSUPPORTED_MSG(EM_PASTESPECIAL)
 /*  UNSUPPORTED_MSG(EM_POSFROMCHARS) missing in Wine headers */
   UNSUPPORTED_MSG(EM_REQUESTRESIZE)
   UNSUPPORTED_MSG(EM_SCROLL)
   UNSUPPORTED_MSG(EM_SCROLLCARET)
   UNSUPPORTED_MSG(EM_SELECTIONTYPE)
+  UNSUPPORTED_MSG(EM_SETBIDIOPTIONS)
+  UNSUPPORTED_MSG(EM_SETEDITSTYLE)
+  UNSUPPORTED_MSG(EM_SETFONTSIZE)
   UNSUPPORTED_MSG(EM_SETLANGOPTIONS)
   UNSUPPORTED_MSG(EM_SETOLECALLBACK)
   UNSUPPORTED_MSG(EM_SETOPTIONS)
+  UNSUPPORTED_MSG(EM_SETPALETTE)
+  UNSUPPORTED_MSG(EM_SETPASSWORDCHAR)
   UNSUPPORTED_MSG(EM_SETRECT)
   UNSUPPORTED_MSG(EM_SETRECTNP)
+  UNSUPPORTED_MSG(EM_SETSCROLLPOS)
+  UNSUPPORTED_MSG(EM_SETTABSTOPS)
   UNSUPPORTED_MSG(EM_SETTARGETDEVICE)
+  UNSUPPORTED_MSG(EM_SETTEXTEX)
   UNSUPPORTED_MSG(EM_SETTEXTMODE)
+  UNSUPPORTED_MSG(EM_SETTYPOGRAPHYOPTIONS)
   UNSUPPORTED_MSG(EM_SETUNDOLIMIT)
   UNSUPPORTED_MSG(EM_SETWORDBREAKPROC)
   UNSUPPORTED_MSG(EM_SETWORDBREAKPROCEX)
+  UNSUPPORTED_MSG(EM_SHOWSCROLLBAR)
+  UNSUPPORTED_MSG(EM_SETZOOM)
   UNSUPPORTED_MSG(WM_SETFONT)
   UNSUPPORTED_MSG(WM_STYLECHANGING)
   UNSUPPORTED_MSG(WM_STYLECHANGED)
@@ -950,6 +1017,22 @@
   case EM_GETPARAFORMAT:
     ME_GetSelectionParaFormat(editor, (PARAFORMAT2 *)lParam);
     return 0;
+  case EM_LINESCROLL:
+  {
+    int nPos = editor->nScrollPosY, nEnd= editor->nTotalLength - editor->sizeWindow.cy;
+    nPos += 8 * lParam; /* FIXME follow the original */
+    if (nPos>=nEnd)
+      nPos = nEnd;
+    if (nPos<0)
+      nPos = 0;
+    if (nPos != editor->nScrollPosY) {
+      ScrollWindow(hWnd, 0, editor->nScrollPosY-nPos, NULL, NULL);
+      editor->nScrollPosY = nPos;
+      SetScrollPos(hWnd, SB_VERT, nPos, TRUE);
+      UpdateWindow(hWnd);
+    }
+    return TRUE; /* Should return false if a single line richedit control */
+  }
   case WM_CLEAR:
   {
     int from, to;
@@ -1246,16 +1329,15 @@
   }
   case WM_MOUSEWHEEL:
   {
-    int gcWheelDelta = 0, nPos = editor->nScrollPosY;
+    int gcWheelDelta = 0, nPos = editor->nScrollPosY, nEnd = editor->nTotalLength - editor->sizeWindow.cy; 
     UINT pulScrollLines;
-
     SystemParametersInfoW(SPI_GETWHEELSCROLLLINES,0, &pulScrollLines, 0);
     gcWheelDelta -= GET_WHEEL_DELTA_WPARAM(wParam);
     if (abs(gcWheelDelta) >= WHEEL_DELTA && pulScrollLines)
-      nPos += pulScrollLines * (gcWheelDelta / WHEEL_DELTA) * 8;
-    if(nPos>=editor->nTotalLength)
-      nPos = editor->nTotalLength - 1;
-    if (nPos<0) 
+      nPos += pulScrollLines * (gcWheelDelta / WHEEL_DELTA) * 8; /* FIXME follow the original */
+    if (nPos>=nEnd)
+      nPos = nEnd;
+    if (nPos<0)
       nPos = 0;
     if (nPos != editor->nScrollPosY) {
       ScrollWindow(hWnd, 0, editor->nScrollPosY-nPos, NULL, NULL);
@@ -1376,9 +1458,6 @@
   return nWritten;  
 }
 
-static WCHAR wszClassName[] = {'R', 'i', 'c', 'h', 'E', 'd', 'i', 't', '2', '0', 'W', 0};
-static WCHAR wszClassName50[] = {'R', 'i', 'c', 'h', 'E', 'd', 'i', 't', '5', '0', 'W', 0};
-
 void ME_RegisterEditorClass(HINSTANCE hInstance)
 {
   BOOL bResult;
@@ -1417,30 +1496,6 @@
   bResult = RegisterClassA(&wcA);  
   assert(bResult);
 }
-
-BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
-{
-    TRACE("\n");
-    switch (fdwReason)
-    {
-    case DLL_PROCESS_ATTACH:
-      DisableThreadLibraryCalls(hinstDLL);
-      me_heap = HeapCreate (0, 0x10000, 0);
-      ME_RegisterEditorClass(hinstDLL);
-      break;
-
-    case DLL_PROCESS_DETACH:
-      UnregisterClassW(wszClassName, 0);
-      UnregisterClassW(wszClassName50, 0);
-      UnregisterClassA("RichEdit20A", 0);
-      UnregisterClassA("RichEdit50A", 0);
-      HeapDestroy (me_heap);
-      me_heap = NULL;
-      break;
-    }
-    return TRUE;
-}
-
 /******************************************************************
  *        CreateTextServices (RICHED20.4)
  *

Modified: trunk/reactos/lib/riched20/paint.c
--- trunk/reactos/lib/riched20/paint.c	2005-05-28 12:43:26 UTC (rev 15577)
+++ trunk/reactos/lib/riched20/paint.c	2005-05-28 14:40:26 UTC (rev 15578)
@@ -76,23 +76,19 @@
       if (rcUpdate->bottom < ye)
         ye = rcUpdate->bottom;
     }
-    
-    rc.left = xs; /* FIXME remove if it's not necessary anymore */
-    rc.top = c.pt.y;
-    rc.right = xe;
-    rc.bottom = c.pt.y+1;
-    FillRect(hDC, &rc, (HBRUSH)GetStockObject(BLACK_BRUSH));
 
-    if (ys == c.pt.y) /* don't overwrite the top bar */
-      ys++;
     if (ye>ys) {
+      HBRUSH hbr;
+      hbr = CreateSolidBrush(ME_GetBackColor(c.editor));
       rc.left = xs;
       rc.top = ys;
       rc.right = xe;
       rc.bottom = ye;
-      /* this is not supposed to be gray, I know, but lets keep it gray for now for debugging purposes */
-      FillRect(hDC, &rc, (HBRUSH)GetStockObject(LTGRAY_BRUSH));
+      FillRect(hDC, &rc, hbr);
+      DeleteObject(hbr);
     }
+    if (ys == c.pt.y) /* don't overwrite the top bar */
+      ys++;
   }
   editor->nLastTotalLength = editor->nTotalLength;
   ME_DestroyContext(&c);

Modified: trunk/reactos/lib/riched20/run.c
--- trunk/reactos/lib/riched20/run.c	2005-05-28 12:43:26 UTC (rev 15577)
+++ trunk/reactos/lib/riched20/run.c	2005-05-28 14:40:26 UTC (rev 15578)
@@ -466,8 +466,6 @@
    * in practice
    */
   ME_GetTextExtent(c, run->strText->szData, nLen, run->style, &size);
-  assert(run->style->tm.tmAscent>0);
-  assert(run->style->tm.tmDescent>0);
   *pAscent = run->style->tm.tmAscent;
   *pDescent = run->style->tm.tmDescent;
   size.cy = *pAscent + *pDescent;
@@ -519,7 +517,8 @@
   int nEnd = ME_StrVLen(run->strText);
   SIZE size = ME_GetRunSizeCommon(c, para, run, nEnd, &run->nAscent, &run->nDescent);
   run->nWidth = size.cx;
-  assert(size.cx);
+  if (!size.cx)
+    WARN("size.cx == 0\n");
 }
 
 void ME_MustBeWrapped(ME_Context *c, ME_DisplayItem *para)

Modified: trunk/reactos/lib/riched20/style.c
--- trunk/reactos/lib/riched20/style.c	2005-05-28 12:43:26 UTC (rev 15577)
+++ trunk/reactos/lib/riched20/style.c	2005-05-28 14:40:26 UTC (rev 15578)
@@ -383,7 +383,7 @@
     TRACE("destroy style %p, total refs=%d\n", s, all_refs);
   else
     TRACE("release style %p, new refs=%d, total refs=%d\n", s, s->nRefs, all_refs);
-  if (!all_refs) FIXME("all style references freed (good!)\n");
+  if (!all_refs) TRACE("all style references freed (good!)\n");
   assert(s->nRefs>=0);
   if (!s->nRefs)
     ME_DestroyStyle(s);