sync with trunk r46493
[reactos.git] / dll / win32 / riched20 / wrap.c
index 579f33a..3b15490 100644 (file)
@@ -456,6 +456,29 @@ static ME_DisplayItem *ME_WrapHandleRun(ME_WrapContext *wc, ME_DisplayItem *p)
   return p->next;
 }
 
+static int ME_GetParaLineSpace(ME_Context* c, ME_Paragraph* para)
+{
+  int   sp = 0, ls = 0;
+  if (!(para->pFmt->dwMask & PFM_LINESPACING)) return 0;
+
+  /* FIXME: how to compute simply the line space in ls ??? */
+  /* FIXME: does line spacing include the line itself ??? */
+  switch (para->pFmt->bLineSpacingRule)
+  {
+  case 0:       sp = ls; break;
+  case 1:       sp = (3 * ls) / 2; break;
+  case 2:       sp = 2 * ls; break;
+  case 3:       sp = ME_twips2pointsY(c, para->pFmt->dyLineSpacing); if (sp < ls) sp = ls; break;
+  case 4:       sp = ME_twips2pointsY(c, para->pFmt->dyLineSpacing); break;
+  case 5:       sp = para->pFmt->dyLineSpacing / 20; break;
+  default: FIXME("Unsupported spacing rule value %d\n", para->pFmt->bLineSpacingRule);
+  }
+  if (c->editor->nZoomNumerator == 0)
+    return sp;
+  else
+    return sp * c->editor->nZoomNumerator / c->editor->nZoomDenominator;
+}
+
 static void ME_PrepareParagraphForWrapping(ME_Context *c, ME_DisplayItem *tp);
 
 static void ME_WrapTextParagraph(ME_Context *c, ME_DisplayItem *tp) {
@@ -499,7 +522,7 @@ static void ME_WrapTextParagraph(ME_Context *c, ME_DisplayItem *tp) {
   if (!(pFmt->dwMask & PFM_TABLE && pFmt->wEffects & PFE_TABLE) &&
       pFmt->dwMask & PFM_BORDER)
   {
-    border = ME_GetParaBorderWidth(c->editor, tp->member.para.pFmt->wBorders);
+    border = ME_GetParaBorderWidth(c, tp->member.para.pFmt->wBorders);
     if (pFmt->wBorders & 1) {
       wc.nFirstMargin += border;
       wc.nLeftMargin += border;
@@ -580,7 +603,6 @@ BOOL ME_WrapMarkedParagraphs(ME_TextEditor *editor)
   ME_DisplayItem *item;
   ME_Context c;
   BOOL bModified = FALSE;
-  int yStart = -1;
   int totalWidth = 0;
 
   ME_InitContext(&c, editor, ITextHost_TxGetDC(editor->texthost));
@@ -598,11 +620,7 @@ BOOL ME_WrapMarkedParagraphs(ME_TextEditor *editor)
     ME_WrapTextParagraph(&c, item);
 
     if (bRedraw)
-    {
       item->member.para.nFlags |= MEPF_REPAINT;
-      if (yStart == -1)
-        yStart = c.pt.y;
-    }
 
     bModified = bModified | bRedraw;
 
@@ -776,6 +794,8 @@ ME_SendRequestResize(ME_TextEditor *editor, BOOL force)
     {
       REQRESIZE info;
 
+      info.nmhdr.hwndFrom = NULL;
+      info.nmhdr.idFrom = 0;
       info.nmhdr.code = EN_REQUESTRESIZE;
       info.rc = rc;
       info.rc.right = editor->nTotalWidth;