Ejemplo n.º 1
0
        public bool itIsPic(Paragraph p)
        {
            IEnumerable <Run> runlist = p.Elements <Run>();

            foreach (Run r in runlist)
            {
                if (r != null)
                {
                    Drawing          d       = r.GetFirstChild <Drawing>();
                    Picture          pic     = r.GetFirstChild <Picture>();
                    EmbeddedObject   objects = r.GetFirstChild <EmbeddedObject>();
                    AlternateContent Alt     = r.GetFirstChild <AlternateContent>();
                    if (d != null || pic != null || objects != null)
                    {
                        return(true);
                    }
                    else if (Alt != null)
                    {
                        AlternateContentChoice   AltChoice   = Alt.GetFirstChild <AlternateContentChoice>();
                        AlternateContentFallback AltFallback = Alt.GetFirstChild <AlternateContentFallback>();
                        if (AltChoice != null && AltFallback != null)
                        {
                            if ((AltChoice.GetFirstChild <Drawing>() != null || AltFallback.GetFirstChild <Picture>() != null))
                            {
                                return(true);
                            }
                        }
                    }
                }
            }
            return(false);
        }
Ejemplo n.º 2
0
        //判断是否是图 参数picloc为图在第几段,所有可能的图都加进来了
        protected bool isPic(int picloc, Body body)
        {
            bool flag = false;

            if (matchPicName(picloc, body))
            {
                flag = true;
            }
            Paragraph p = null;

            if (body.ChildElements.GetItem(picloc).GetType().ToString() == "DocumentFormat.OpenXml.Wordprocessing.Paragraph")
            {
                p = (Paragraph)body.ChildElements.GetItem(picloc);
            }
            if (p != null)
            {
                IEnumerable <Run> runlist = p.Elements <Run>();
                foreach (Run r in runlist)
                {
                    if (r != null)
                    {
                        Drawing          d       = r.GetFirstChild <Drawing>();
                        Picture          pic     = r.GetFirstChild <Picture>();
                        EmbeddedObject   objects = r.GetFirstChild <EmbeddedObject>();
                        AlternateContent Alt     = r.GetFirstChild <AlternateContent>();
                        if (((d != null || pic != null)) || (flag == true && objects != null))
                        {
                            if (p.InnerText.Trim().Length < 65)
                            {
                                return(true);
                            }
                        }
                        else if (Alt != null)
                        {
                            AlternateContentChoice   AltChoice   = Alt.GetFirstChild <AlternateContentChoice>();
                            AlternateContentFallback AltFallback = Alt.GetFirstChild <AlternateContentFallback>();
                            if (AltChoice != null && AltFallback != null)
                            {
                                if (flag == true && (AltChoice.GetFirstChild <Drawing>() != null || AltFallback.GetFirstChild <Picture>() != null))
                                {
                                    return(true);
                                }
                            }
                        }
                    }
                }
            }
            return(false);
        }