Example #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);
        }
Example #2
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);
        }