[PATCH 17/24] [RichEdit]: added support for intra-paragraph line space

Eric Pouech eric.pouech at orange.fr
Tue Jan 1 15:04:58 CST 2008




A+
---

 dlls/riched20/editor.h |    1 +
 dlls/riched20/paint.c  |   23 +++++++++++++++++++++++
 dlls/riched20/wrap.c   |    8 ++++++--
 3 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/dlls/riched20/editor.h b/dlls/riched20/editor.h
index f67b9e7..0223b30 100644
--- a/dlls/riched20/editor.h
+++ b/dlls/riched20/editor.h
@@ -256,6 +256,7 @@ BOOL ME_GetYScrollVisible(ME_TextEditor *editor);
 
 /* other functions in paint.c */
 int  ME_GetParaBorderWidth(ME_TextEditor *editor, int);
+int  ME_GetParaLineSpace(ME_TextEditor *editor, ME_Paragraph*, int);
 
 /* richole.c */
 extern LRESULT CreateIRichEditOle(ME_TextEditor *editor, LPVOID *);
diff --git a/dlls/riched20/paint.c b/dlls/riched20/paint.c
index 72c03f1..3d43496 100644
--- a/dlls/riched20/paint.c
+++ b/dlls/riched20/paint.c
@@ -365,6 +365,29 @@ int  ME_GetParaBorderWidth(ME_TextEditor* editor, int flags)
   return width;
 }
 
+int  ME_GetParaLineSpace(ME_TextEditor* editor, ME_Paragraph* para, int dpi)
+{
+  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 = para->pFmt->dyLineSpacing * dpi / 1440; if (sp < ls) sp = ls; break;
+  case 4:       sp = para->pFmt->dyLineSpacing * dpi / 1440; break;
+  case 5:       sp = para->pFmt->dyLineSpacing / 20; break;
+  default: FIXME("Unsupported spacing rule value %d\n", para->pFmt->bLineSpacingRule);
+  }
+  if (editor->nZoomNumerator == 0)
+    return sp;
+  else
+    return sp * editor->nZoomNumerator / editor->nZoomDenominator;
+}
+
 static int ME_DrawParaDecoration(ME_Context* c, ME_Paragraph* para, int y, int dpi)
 {
   int           idx, border_width;
diff --git a/dlls/riched20/wrap.c b/dlls/riched20/wrap.c
index d1f6203..f0b2c49 100644
--- a/dlls/riched20/wrap.c
+++ b/dlls/riched20/wrap.c
@@ -343,6 +343,7 @@ static void ME_WrapTextParagraph(ME_Context *c, ME_DisplayItem *tp, DWORD begino
   ME_WrapContext wc;
   int dpi = GetDeviceCaps(c->hDC, LOGPIXELSX);
   int border = 0;
+  int linespace = 0;
 
   assert(tp->type == diParagraph);
   if (!(tp->member.para.nFlags & MEPF_REWRAP)) {
@@ -378,14 +379,17 @@ static void ME_WrapTextParagraph(ME_Context *c, ME_DisplayItem *tp, DWORD begino
   wc.nAvailWidth = wc.nTotalWidth - wc.nFirstMargin - wc.nRightMargin;
   wc.pRowStart = NULL;
 
+  linespace = ME_GetParaLineSpace(c->editor, &tp->member.para, dpi);
+
   ME_BeginRow(&wc);
   for (p = tp->next; p!=tp->member.para.next_para; ) {
     assert(p->type != diStartRow);
     if (p->type == diRun) {
       p = ME_WrapHandleRun(&wc, p);
-      continue;
     }
-    p = p->next;
+    else p = p->next;
+    if (wc.nRow && p == wc.pRowStart)
+      wc.pt.y += linespace;
   }
   ME_WrapEndParagraph(&wc, p);
   if ((tp->member.para.pFmt->dwMask & PFM_BORDER) && (tp->member.para.pFmt->wBorders & 8))





More information about the wine-patches mailing list