Huw Davies : riched20: Emit RTF for paragraph numbering.

Alexandre Julliard julliard at winehq.org
Wed Oct 12 16:06:16 CDT 2016


Module: wine
Branch: master
Commit: c69e60efbcb8746dafa668d26728941a35f017dc
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=c69e60efbcb8746dafa668d26728941a35f017dc

Author: Huw Davies <huw at codeweavers.com>
Date:   Wed Oct 12 12:58:52 2016 +0100

riched20: Emit RTF for paragraph numbering.

Signed-off-by: Huw Davies <huw at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/riched20/writer.c | 79 +++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 78 insertions(+), 1 deletion(-)

diff --git a/dlls/riched20/writer.c b/dlls/riched20/writer.c
index e7d340a..77f50e3 100644
--- a/dlls/riched20/writer.c
+++ b/dlls/riched20/writer.c
@@ -456,6 +456,76 @@ ME_StreamOutRTFTableProps(ME_TextEditor *editor, ME_OutStream *pStream,
   return TRUE;
 }
 
+static BOOL stream_out_para_num( ME_OutStream *stream, ME_Paragraph *para, BOOL pn_dest )
+{
+    static const char fmt_label[] = "{\\*\\pn\\pnlvlbody\\pnf%u\\pnindent%d\\pnstart%d%s%s}";
+    static const char fmt_bullet[] = "{\\*\\pn\\pnlvlblt\\pnf%u\\pnindent%d{\\pntxtb\\'b7}}";
+    static const char dec[] = "\\pndec";
+    static const char lcltr[] = "\\pnlcltr";
+    static const char ucltr[] = "\\pnucltr";
+    static const char lcrm[] = "\\pnlcrm";
+    static const char ucrm[] = "\\pnucrm";
+    static const char period[] = "{\\pntxta.}";
+    static const char paren[] = "{\\pntxta)}";
+    static const char parens[] = "{\\pntxtb(}{\\pntxta)}";
+    const char *type, *style = "";
+    unsigned int idx;
+
+    find_font_in_fonttbl( stream, &para->para_num.style->fmt, &idx );
+
+    if (!ME_StreamOutPrint( stream, "{\\pntext\\f%u ", idx )) return FALSE;
+    if (!ME_StreamOutRTFText( stream, para->para_num.text->szData, para->para_num.text->nLen ))
+        return FALSE;
+    if (!ME_StreamOutPrint( stream, "\\tab}" )) return FALSE;
+
+    if (!pn_dest) return TRUE;
+
+    if (para->fmt.wNumbering == PFN_BULLET)
+    {
+        if (!ME_StreamOutPrint( stream, fmt_bullet, idx, para->fmt.wNumberingTab ))
+            return FALSE;
+    }
+    else
+    {
+        switch (para->fmt.wNumbering)
+        {
+        case PFN_ARABIC:
+        default:
+            type = dec;
+            break;
+        case PFN_LCLETTER:
+            type = lcltr;
+            break;
+        case PFN_UCLETTER:
+            type = ucltr;
+            break;
+        case PFN_LCROMAN:
+            type = lcrm;
+            break;
+        case PFN_UCROMAN:
+            type = ucrm;
+            break;
+        }
+        switch (para->fmt.wNumberingStyle & 0xf00)
+        {
+        case PFNS_PERIOD:
+            style = period;
+            break;
+        case PFNS_PAREN:
+            style = paren;
+            break;
+        case PFNS_PARENS:
+            style = parens;
+            break;
+        }
+
+        if (!ME_StreamOutPrint( stream, fmt_label, idx, para->fmt.wNumberingTab,
+                                para->fmt.wNumberingStart, type, style ))
+            return FALSE;
+    }
+    return TRUE;
+}
+
 static BOOL
 ME_StreamOutRTFParaProps(ME_TextEditor *editor, ME_OutStream *pStream,
                          ME_DisplayItem *para)
@@ -501,11 +571,18 @@ ME_StreamOutRTFParaProps(ME_TextEditor *editor, ME_OutStream *pStream,
   }
 
   if (prev_para && !memcmp( fmt, &prev_para->fmt, sizeof(*fmt) ))
+  {
+    if (fmt->wNumbering)
+      return stream_out_para_num( pStream, &para->member.para, FALSE );
     return TRUE;
+  }
 
   if (!ME_StreamOutPrint(pStream, "\\pard"))
     return FALSE;
 
+  if (fmt->wNumbering)
+    if (!stream_out_para_num( pStream, &para->member.para, TRUE )) return FALSE;
+
   if (!editor->bEmulateVersion10) { /* v4.1 */
     if (pStream->nNestingLevel > 0)
       strcat(props, "\\intbl");
@@ -515,7 +592,7 @@ ME_StreamOutRTFParaProps(ME_TextEditor *editor, ME_OutStream *pStream,
     if (fmt->dwMask & PFM_TABLE && fmt->wEffects & PFE_TABLE)
       strcat(props, "\\intbl");
   }
-  
+
   /* TODO: PFM_BORDER. M$ does not emit any keywords for these properties, and
    * when streaming border keywords in, PFM_BORDER is set, but wBorder field is
    * set very different from the documentation.




More information about the wine-cvs mailing list