Пример #1
0
        private void ReadHeaderFooterVmlDrawingPicture_shape(VmlDrawingPictureCollection target, XElement targetElement)
        {
            //奇数页眉  <oddHeader>  // 右 “RH”  中 "CH"  左 "LH"
            //偶数页眉  <evenHeader> // 右 "RHEVEN"  中间 “CHEVEN", 左 "LHEVEN" 
            //首页页眉  <firstHeader> // 右 ”RHFIRST“ 中间 "CHFIRST" 左 "LHFIRST"

            //奇数页脚  <oddFooter>   //F
            //偶数页脚  <evenFooter>  //CFEVEN 
            //首页页脚  <firstFooter>   FFIRST

            IEnumerable<XElement> shapetypes = targetElement.Elements(XName.Get("shape", ExcelCommon.schemaMicrosoftVml));
            VmlDrawingPicture itemPicture = null;
            XAttribute xAtbute = null;
            XElement childNode = null;
            foreach (XElement shapetypeNode in shapetypes)
            {
                itemPicture = new VmlDrawingPicture();
                xAtbute = shapetypeNode.Attribute(XName.Get("id"));
                if (xAtbute != null)
                    itemPicture.Id = xAtbute.Value;

                xAtbute = shapetypeNode.Attribute(XName.Get("style"));
                if (xAtbute != null)
                    ReadHeaderFooterVmlDrawingPicture_shape_style(itemPicture, xAtbute.Value);

                childNode = shapetypeNode.Element(XName.Get("imagedata", ExcelCommon.schemaMicrosoftVml));
                if (childNode != null)
                {
                    xAtbute = childNode.Attribute(XName.Get("relid", ExcelCommon.schemaMicrosoftOffice));
                    if (xAtbute != null)
                    {
                        PackageRelationship rel = this.Context.Package.GetPart(target.PictureUri).GetRelationship(xAtbute.Value);
                        Uri imageUri = PackUriHelper.ResolvePartUri(rel.SourceUri, rel.TargetUri);
                        itemPicture.Image = Image.FromStream(this.Context.Package.GetPart(imageUri).GetStream());
                    }

                    xAtbute = childNode.Attribute(XName.Get("title", ExcelCommon.schemaMicrosoftOffice));
                    if (xAtbute != null)
                        itemPicture.Title = xAtbute.Value;

                    xAtbute = childNode.Attribute(XName.Get("bilevel"));
                    if (xAtbute != null)
                        itemPicture.BiLevel = xAtbute.Value.Equals("t") ? true : false;

                    xAtbute = childNode.Attribute(XName.Get("grayscale"));
                    if (xAtbute != null)
                        itemPicture.BlackLevel = VmlDrawingPicture.GetFracDT(xAtbute.Value, 0);

                    xAtbute = childNode.Attribute(XName.Get("gain"));
                    if (xAtbute != null)
                        itemPicture.Gain = VmlDrawingPicture.GetFracDT(xAtbute.Value, 0);

                    xAtbute = childNode.Attribute(XName.Get("gamma"));
                    if (xAtbute != null)
                        itemPicture.Gamma = VmlDrawingPicture.GetFracDT(xAtbute.Value, 0);
                }

                /* <o:lock v:ext="edit" rotation="t"/>
                childNode = targetElement.Element(XName.Get("lock", ExcelCommon.schemaMicrosoftOffice));
                if (childNode != null)
                {
                    itemPicture.Title = childNode.Value;
                } */

                target.Add(itemPicture);
            }
        }