Exemple #1
0
        public override bool ProcessImage(string imageUrl, int approximateRenderingPosition)
        {
            AttachmentLink attachmentLink = base.FindAttachmentByBodyReference(imageUrl);

            if (attachmentLink == null)
            {
                return(false);
            }
            attachmentLink.RenderingPosition = approximateRenderingPosition;
            attachmentLink.IsHidden          = false;
            attachmentLink.MarkInline(true);
            return(true);
        }
Exemple #2
0
        public override void ProcessTag(HtmlTagContext tagContext, HtmlWriter htmlWriter)
        {
            if (tagContext.TagId != HtmlTagId.Img)
            {
                tagContext.WriteTag(true);
                return;
            }
            AttachmentLink attachmentLink = null;
            string         text           = null;

            foreach (HtmlTagContextAttribute htmlTagContextAttribute in tagContext.Attributes)
            {
                if (htmlTagContextAttribute.Id == HtmlAttributeId.Src)
                {
                    text = htmlTagContextAttribute.Value;
                    break;
                }
            }
            if (!string.IsNullOrEmpty(text))
            {
                attachmentLink = base.FindAttachmentByBodyReference(text);
            }
            if (attachmentLink == null)
            {
                if (!this.clearEmptyLinks || !DefaultHtmlCallbacks.IsEmptyLink(text))
                {
                    tagContext.WriteTag(true);
                }
                return;
            }
            string text2;
            string text3;

            if (attachmentLink.AttachmentType == AttachmentType.Ole)
            {
                text2 = "image/jpeg";
                text3 = "jpg";
                attachmentLink.ConvertToImage();
            }
            else
            {
                text2 = attachmentLink.ContentType;
                text3 = attachmentLink.FileExtension;
            }
            bool flag = text.StartsWith("cid:Microsoft-Infopath-", StringComparison.OrdinalIgnoreCase) && string.IsNullOrEmpty(text3) && !string.IsNullOrEmpty(text2) && text2.Equals("application/octet-stream");

            if (DefaultHtmlCallbacks.IsInlineImage(text2, text3) || flag)
            {
                tagContext.WriteTag(false);
                foreach (HtmlTagContextAttribute htmlTagContextAttribute2 in tagContext.Attributes)
                {
                    if (htmlTagContextAttribute2.Id == HtmlAttributeId.Src)
                    {
                        string value = "cid:" + this.GetOrGenerateAttachContentId(attachmentLink);
                        htmlWriter.WriteAttribute(HtmlAttributeId.Src, value);
                    }
                    else
                    {
                        htmlTagContextAttribute2.Write();
                    }
                }
                attachmentLink.MarkInline(true);
                return;
            }
            if (!this.RemoveLinksToNonImageAttachments)
            {
                string text4 = attachmentLink.Filename;
                if (text4 == null)
                {
                    text4 = ServerStrings.DefaultHtmlAttachmentHrefText;
                }
                htmlWriter.WriteStartTag(HtmlTagId.A);
                htmlWriter.WriteAttribute(HtmlAttributeId.Href, "cid:" + this.GetOrGenerateAttachContentId(attachmentLink));
                htmlWriter.WriteText(text4);
                htmlWriter.WriteEndTag(HtmlTagId.A);
                attachmentLink.MarkInline(false);
            }
        }