Ejemplo n.º 1
0
        public string GetFormattedBody(IResource res, string body, string replyToBody,
                                       ref WordPtr[] offsets, string fontFace, int fontSize)
        {
            string formattedText;
            string subject        = res.GetPropText(Core.Props.Subject);
            bool   needFormatting = res.HasProp("NoFormat");

            // If no offsets passed, default to the simple processing
            if ((offsets == null) || (offsets.Length == 0))
            {
                formattedText = GetFormattedText(needFormatting, body, replyToBody, subject, null, fontFace, fontSize);
            }
            else
            {
                // Save offsets, format text, retrieve offsets.
                using (MarkerInjector injector = new MarkerInjector())
                {
                    WordPtr[] modOffs = DocumentSection.RestrictResults(offsets, DocumentSection.BodySection);
                    body          = injector.InjectMarkers(body, modOffs);
                    formattedText = GetFormattedText(needFormatting, body, replyToBody, subject, injector, fontFace, fontSize);
                    formattedText = injector.CollectMarkers(formattedText, out modOffs);
                }
            }
            return(formattedText);
        }
Ejemplo n.º 2
0
        private static string GetFormattedText(bool isNoFormat, string body, string replyToBody, string subject,
                                               MarkerInjector injector, string fontFace, int fontSize)
        {
            string text;
            int    minWrapWidth = Core.SettingStore.ReadInt("Formatting", "MinimumWrapWidth", _iDefaultMessageWidth);

            if (isNoFormat)
            {
                text = "<pre>" + HttpUtility.HtmlEncode(body) + "</pre>";
            }
            else
            {
                MailBodyParser replyParser = new MailBodyParser(replyToBody, minWrapWidth);
                MailBodyParser parser      = new MailBodyParser(body, minWrapWidth, replyParser);
                text = MailBodyFormatter.FormatBody(parser, subject, false, injector, fontFace, fontSize);
            }
            return(text);
        }
Ejemplo n.º 3
0
        public string GetFormattedHtmlBody(IResource res, string body, ref WordPtr[] offsets)
        {
            string formattedText;
            string subject = res.GetPropText(Core.Props.Subject);

            // If no offsets passed, default to the simple processing
            if ((offsets == null) || (offsets.Length == 0))
            {
                formattedText = InsertHeaderWithStyle(body, subject);
            }
            else
            {
                // Save offsets, format text, retrieve offsets.
                using (MarkerInjector injector = new MarkerInjector())
                {
                    WordPtr[] modOffs = DocumentSection.RestrictResults(offsets, DocumentSection.BodySection);
                    body          = injector.InjectMarkers(body, modOffs);
                    formattedText = InsertHeaderWithStyle(body, subject);
                    formattedText = injector.CollectMarkers(formattedText, out modOffs);
                }
            }
            return(formattedText);
        }
Ejemplo n.º 4
0
 public MarkedHtmlLinkConverter(MarkerInjector injector)
 {
     _injector = injector;
 }
Ejemplo n.º 5
0
        public static string FormatBody(MailBodyParser parser, string subject, bool noWrap, MarkerInjector injector, string fontFace, int fontSize)
        {
            // A link converter that is capable of sweeping out the markers when
            // creating the links out of plain text (by using the MarkedHtmlLinkConverter).
            // If there are no markers injected, HtmlLinkConverter is used.
            HtmlLinkConverter linkconverter = (injector != null) ? new MarkedHtmlLinkConverter(injector) : new HtmlLinkConverter();
            string            style         = _cDefaultStyleTmpl.Replace("$FontFace$", fontFace).Replace("$FontSize$", fontSize.ToString());

            _builder.Length    = 0;
            _quoteTableStarted = _quoteRowStarted = false;

            FormatBody(parser, subject, linkconverter, style, noWrap);
            return(_builder.ToString());
        }
Ejemplo n.º 6
0
 public static string FormatBody(MailBodyParser parser, bool noWrap, MarkerInjector injector, string fontFace, int fontSize)
 {
     return(FormatBody(parser, null, noWrap, injector, fontFace, fontSize));
 }